Simple scripts to share

These are simple animation scripts usually used by enemies. It should be pasted on an animation header.

1. Desperation
Code:
@script   
    if(frame==0){
      void vSelf = getlocalvar("self");
      int MHealth = getentityproperty(vSelf,"maxhealth");
      int Health = getentityproperty(vSelf,"health");

      if(Health <= MHealth/3){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
      }
    }
@end_script

This animation script changes enemy's animation to FOLLOW1 if his/her/its HP fall below 1/3 of it's maximum HP.
Also useful for players too ;)
In detail, it works like this: at 1st frame of animation, entity's HP is compared with maximum HP. If it is 1/3 of maximum HP or less, animation is changed to FOLLOW1.

2. Randomness
Code:
@script   
    if(frame==0){
      void vSelf = getlocalvar("self");
      int r = rand()%30;

      if(r > 0){
        changeentityproperty(vSelf, "animation", openborconstant("ANI_FOLLOW1"));
      }
    }
@end_script

As name implies, it changes enemy's current animation to FOLLOW1 randomly with about 50% chance to change.
Players could use this too for attacks or spells which has low success rate ;).
It works like this: at 1st frame, an integer value between -30 and 30 is picked randomly. If it is higher than 0, animation is changed to FOLLOW1. If it is lower or same as 0, nothing will be done and the rest of animation will be played normally

3. Lonely
Code:
@script
    void self = getlocalvar("self");
    int Enemy = openborvariant("count_enemies");

    if(Enemy == 1){
      changeentityproperty(self, "velocity", 0, 0, 0); // Should be omitted if declared in IDLE
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script

Okay, this one has catchy name :) actually, this is used to change animation to summon backups animation which is usually performed when boss is alone. Summon backups animation could be anything from calling backups from offscreen to raising zombies from ground ;).
I usually declare this in boss's IDLE and WALK animation but it works in other animation as well.
The script works like this: in every frame of animation, number of enemies is counted. If it is higher than 1, nothing will happen and the animation will be played normally. But if it is 1, animation is changed to FOLLOW1.
Bear in mind that the enemy using this script is also counted

Values used in scripts above aren't fixed of course, you can change it for different randomness, different HP limit (for desperation) or for different loneliness.
This iss nice thanks @Bloodbane
 
Back
Top Bottom