ramdom anim script

Gurtag

Active member
hey guys, this is a inline script i got from bloodbane, it is for ramdomize enemies´s attacks, but i think it´s inline nature causes small gamefreezes some times so i wanted to ask if it can be turned in to a function.

@script
    if(frame==0){
      void vSelf = getlocalvar("self");
      int r = rand()%20;

      if(r > 0){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_runattack"));
      }
    }
@end_script
 
Game freeze? in what animation you declared that function?

OTOH, turning this script into a function shouldn't be too hard. You just need to decide which elements of the script would be variable and which are not :).
 
Gurtag, I've build a function for that, where you can set the limit and the chance

Code:
void randomAnim(int iLimit, int iChance, void Ani)
{ // Randonly goes to another animation, based on the chance
// O Ilusionista - 15/06/2018. Thanks Bloodbane.
// http://www.brazilmugenteam.com
	void self = getlocalvar("self");
	int r = rand()%iLimit;
	if(r > iChance){
		performattack(self, openborconstant(Ani));
	}
}

Usage:
@cmd randomAnim 30 0 "ANI_ATTACK4"

This is what I use on my project for random animations
 
The one I’m using is this one:
Code:
Anim attack1
@script
      void vSelf = getlocalvar("self");

   if(frame==0){
      int r = rand()%30;

      if(r > 0 && r <= 15){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
       } else if (r > 15){
         changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW2"));
      } else if (r < -15){
         changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW3"));
    }
   @end_script
range 0 20

Etc

The game don’t froze, but enemies are a little slow to react.
 
Bloodbane said:
Game freeze? in what animation you declared that function?

well it is not really so much of a problem as the freeze last like a nanosecond lol, but it can be quite anoying at times though.
i use it in freespecials ant attack anims mostly, has hapened on all enemies i declared it, though i declared several times on most enemies, may be i abuse it´s use.



thanks a lot for your codes guys your a god send
 
Back
Top Bottom