Jump to content

Photo

Sand Crab Enemy Behavior

enemy

  • Please log in to reply
21 replies to this topic

#16 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 11 August 2018 - 02:57 PM

Now if only there were some way we could see the script, one of us could perhaps tell you what's wrong so you can fix it.


Edited by klop422, 11 August 2018 - 02:58 PM.


#17 Mlvluu

Mlvluu

    Recipient of Ways

  • Members

Posted 15 August 2018 - 02:22 PM

The script is in this topic.


Edited by Mlvluu, 15 August 2018 - 02:23 PM.


#18 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 15 August 2018 - 05:23 PM

Your script is wrong, as TBT has pointed out and TBT's script is incomplete, so?? Try out this script:

global script Crab{
	void run(){
		while(true){
			for(int i = 1; i <= Screen->NumNPCs(); i++){ //cycle through all enemies
				npc enemy = Screen->LoadNPC(i);
				if( enemy->Attributes[15] == 5 ){ //if the correct attribute is set, it's a crab
					if ( enemy->Dir == DIR_LEFT || enemy->Dir == DIR_RIGHT )
						enemy->Step = 150; //higher horizontal speed
					else
						enemy->Step = 100; //normal speed
				}
			}
			Waitframe();
		}
	}
}

Keeping it a global, since you wanted a global script.

 

Here's a different script, using ghost.zh:

ffc script Ghost_Crab{
	void run(int enemyid){
		npc ghost = Ghost_InitAutoGhost(this, enemyid);
		Ghost_SetFlag(GHF_KNOCKBACK);
		Ghost_SetFlag(GHF_STUN);
		int counter = -1;
		while(true){
			if ( Ghost_Dir == DIR_LEFT || Ghost_Dir == DIR_RIGHT )
				counter = Ghost_ConstantWalk8(counter, 80, 4, 0, 0);
			else if ( Ghost_Dir == DIR_UP || Ghost_Dir == DIR_DOWN )
				counter = Ghost_ConstantWalk8(counter, 30, 4, 0, 0);
			else
				Ghost_Dir = Choose(DIR_UP, DIR_DOWN, DIR_LEFT, DIR_RIGHT);
			Ghost_Waitframe(this, ghost, true, true);
		}
	}
}

This one isn't bound to the grid. Work's better imo. ^^


Edited by Avataro, 15 August 2018 - 05:25 PM.


#19 Mlvluu

Mlvluu

    Recipient of Ways

  • Members

Posted 15 August 2018 - 06:11 PM

The grid?



#20 klop422

klop422

    Guess I'm full of monsters and treasure

  • Members
  • Real Name:Not George
  • Location:Planet Earth

Posted 15 August 2018 - 06:54 PM

I'd assumed you'd corrected it as directed, and the first post is unchanged. I've probably misunderstoof something.

Anyway, if I understand correctly, the grid is where Link walks if you play without 8-way movement. Basically every quarter combo is part of the grid.

#21 Mlvluu

Mlvluu

    Recipient of Ways

  • Members

Posted 15 August 2018 - 07:42 PM

So... how is that better?


Edited by Mlvluu, 15 August 2018 - 07:43 PM.


#22 Avaro

Avaro

    o_o

  • Members
  • Real Name:Robin
  • Location:Germany

Posted 15 August 2018 - 07:58 PM

Nevermind xD Try for yourself.


Edited by Avataro, 15 August 2018 - 08:01 PM.




Also tagged with one or more of these keywords: enemy

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users