The script: Custom Armos.

The problems:


EDIT:fixed a few, although ComboS is picky about what it wants to change for some reason. I tried a pointer to armos via e=Screen->NumNPCs(); then one frame later after creating an enemy armos1=Screen->LoadNPC(e+1);
...but that didn't work...back to the drawing board.

-Armos will spawn while link is far away...or not at all.

-ComboS doesn't want to make the combo walkable after an armos spawn.

-The FFC projectile part is completely non-functional..

I haven't had this many problems for such a basic script before. I don't know what's wrong with it.

Code:
ffc script Armos_custom{

	void run(int enemy_id, int enemyHP, int power_armos, int fire, int weapon_combo, int speed,){

		int trigger = 0;
		int delay = 0;
		npc armos;
		ffc shoot;
		int ffc_fire = fire;

		while(true){

			if(ffc_fire >= fire+3){ffc_fire = fire;}
			if(trigger == 3 && delay > 0){ delay--;}

			if(trigger == 0){ 
				Screen->ComboS[ComboAt(this->X, this->Y)] = 15;
	
				if(this->Y > Link->Y && this->Y < Link->Y+18 && this->X > Link->X+8 && this->X < Link->X-8){
					if(Link->InputDown){trigger = 1;}
				}
				if(this->Y < Link->Y && this->Y > Link->Y-18 && this->X > Link->X+8 && this->X < Link->X-8){
					if(Link->InputUp){trigger = 1;}
				}
				if(this->X > Link->X && this->X < Link->X+18 && this->Y > Link->Y+8 && this->Y < Link->X-8){
					if(Link->InputRight){trigger = 1;}
				}
				if(this->X < Link->X && this->X > Link->X-18 && this->Y > Link->Y+8 && this->Y < Link->X-8){
					if(Link->InputLeft){trigger = 1;}
				}
			}
			if(trigger == 1){
			
				if(delay == 0){ this->Data++; delay++;}
				if(delay == 60){ this->Data++;trigger = 2;}
				delay++;
			}
			if(trigger == 2){

				Screen->ComboS[ComboAt(this->X, this->Y)] = 0;
				npc armos = Screen->CreateNPC(enemy_id);
				armos->X = this->X; armos->Y = this->Y;
				armos->HP = enemyHP;
				trigger = 3; delay = 0;
			}
			if(trigger == 3 && power_armos == 1){

				if(delay == 0){
	
					if(Link->X > armos->X && Link->Y > armos->Y+2 && Link->Y < armos->Y-2){
						shoot = Screen->LoadFFC(ffc_fire);
						shoot->Data = weapon_combo;
						shoot->Y = armos->Y; shoot->X = armos->X + 16;
						shoot->Vx = speed;
						armos->Dir = 3; delay = 60;ffc_fire++;
					}
					if(Link->X < armos->X && Link->Y > armos->Y+2 && Link->Y < armos->Y-2){
						shoot = Screen->LoadFFC(ffc_fire);
						shoot->Data = weapon_combo;
						shoot->Y = armos->Y; shoot->X = armos->X - 16;
						shoot->Vx = -speed;
						armos->Dir = 2; delay = 60;ffc_fire++;
					}
					else{
						if(Link->Y > armos->Y && Link->X > armos->X+2 && Link->X < armos->X-2){
							shoot = Screen->LoadFFC(ffc_fire);
							shoot->Data = weapon_combo;
							shoot->Y = armos->Y+16; shoot->X = armos->X;
							shoot->Vy = speed;
							armos->Dir = 1; delay = 60;ffc_fire++;
						}
						if(Link->Y < armos->Y && Link->X > armos->X+2 && Link->X < armos->X-2){
							shoot = Screen->LoadFFC(ffc_fire);
							shoot->Data = weapon_combo;
							shoot->Y = armos->Y-16; shoot->X = armos->X;
							shoot->Vy = -speed;
							armos->Dir = 0; delay = 60;ffc_fire++;
						}
					}
				}
			}
		Waitframe();
		}
	}
}

Anyone got any idea's?