A question about the movement of AI.

DD Tokki

Active member
hello. As more and more people test recently, the pros and cons of my game are becoming clearer. It is a very grateful situation.

One of the problems is that it shows a very linear movement even with the naked eye.
Can the AI change its behavior or attack pattern depending on its HP state?
Or is there a script that normally moves more elaborately?

Or something else, if the AI only approaches the wall, it will try to keep jumping. Could it be possible to apply a different behavior?

I want to give a luxurious change to a monotonous movement.
 

Bloodbane

Well-known member
Can the AI change its behavior or attack pattern depending on its HP state?

Only with script such as this:
C:
anim    idle
@script
  if(frame > 0){
    void self = getlocalvar("self");
    int MHP = getentityproperty(self,"maxhealth");
    int HP = getentityproperty(self,"health");

    if(HP < MHP*0.5){
      changeentityproperty(self, "aimove", openborconstant("AIMOVE1_AVOID"));
    }
  }
@end_script
...

This script will change enemy's movement AI to avoid when his health drops below half.

if the AI only approaches the wall, it will try to keep jumping. Could it be possible to apply a different behavior?

Ah that's the issue with enemy's JUMP animation. It might work well in some situations but if there are many walls, enemy might jump at a wall when it's not needed to jump at all.
That's why I don't bother to give enemies JUMP animation but instead use FOLLOW animation played with certain function. This function checks wall's height and player's position to determine if enemy should jump or not.
 

DD Tokki

Active member
Only with script such as this:
C:
anim    idle
@script
  if(frame > 0){
    void self = getlocalvar("self");
    int MHP = getentityproperty(self,"maxhealth");
    int HP = getentityproperty(self,"health");

    if(HP < MHP*0.5){
      changeentityproperty(self, "aimove", openborconstant("AIMOVE1_AVOID"));
    }
  }
@end_script
...

This script will change enemy's movement AI to avoid when his health drops below half.



Ah that's the issue with enemy's JUMP animation. It might work well in some situations but if there are many walls, enemy might jump at a wall when it's not needed to jump at all.
That's why I don't bother to give enemies JUMP animation but instead use FOLLOW animation played with certain function. This function checks wall's height and player's position to determine if enemy should jump or not.
anim idle
@script
if(frame > 0){
void self = getlocalvar("self");
int MHP = getentityproperty(self,"maxhealth");
int HP = getentityproperty(self,"health");

if(HP < MHP*1.0){
changeentityproperty(self, "aimove", openborconstant("AIMOVE1_AVOID"));
}
}
@end_script
loop 1
@cmd degravity -0.3
delay 10
offset 11 31
bbox 3 0 16 32
frame data/sprites/cr/za1/idle.gif
thank you But even if the script is applied, it does not try to avoid it when the hp is half.
 

Bloodbane

Well-known member
It works here. Test enemy I'm applying this script on has chasez aimove as his default aimove so when his health falls below half, his movement change is easily spotted.
 

Steven1985

Active member
Only with script such as this:
C:
anim    idle
@script
  if(frame > 0){
    void self = getlocalvar("self");
    int MHP = getentityproperty(self,"maxhealth");
    int HP = getentityproperty(self,"health");

    if(HP < MHP*0.5){
      changeentityproperty(self, "aimove", openborconstant("AIMOVE1_AVOID"));
    }
  }
@end_script
...

This script will change enemy's movement AI to avoid when his health drops below half.
Does this script work also if the character has only 1 frame?
 

Bloodbane

Well-known member
You're welcome :)

You know, while thinking how to answer problems posted by other members, I remembered alternate way to do this which is by using thinkscript. The ai change above can also be done using thinkscript like this:
Awas.c
C:
void main(){
  void self = getlocalvar("self");
  int MHP = getentityproperty(self,"maxhealth");
  int HP = getentityproperty(self,"health");

  if(HP < MHP*0.5){
    changeentityproperty(self, "aimove", openborconstant("AIMOVE1_AVOID"));
  }
}

Save and copy that in data/scripts folder then declare the script in header text with this line:
thinkscript data/scripts/awas.c

By using this, you don't need to worry about frame count anymore :)
 

Steven1985

Active member
You're welcome :)

You know, while thinking how to answer problems posted by other members, I remembered alternate way to do this which is by using thinkscript. The ai change above can also be done using thinkscript like this:
Awas.c
C:
void main(){
  void self = getlocalvar("self");
  int MHP = getentityproperty(self,"maxhealth");
  int HP = getentityproperty(self,"health");

  if(HP < MHP*0.5){
    changeentityproperty(self, "aimove", openborconstant("AIMOVE1_AVOID"));
  }
}

Save and copy that in data/scripts folder then declare the script in header text with this line:
thinkscript data/scripts/awas.c

By using this, you don't need to worry about frame count anymore :)
can I give this script any name, even simply think?
 
Top Bottom