A question about the movement of AI.

DD Tokki

Well-known 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.
 
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.
 
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.
 
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.
 
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?
 
No it wont.

However, the easiest solution is to repeat that 1 frame multiple times in IDLE animation. Visually it looks the same but technically it's different.
 
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 :)
 
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?
 
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.
Hi, a doubt occurred to me: is it true that scripts like this within animations require loop 0 and not loop 1 to work?
 
The script itself doesn't care. It's whether or not you care if it is executed on each animation loop.

DC
Did I understand well?
C:
anim    idle
loop 1
@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
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif

C:
anim    idle

loop 0 //or without loop

@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

frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif
 
Did I understand well?
C:
anim    idle
loop 1
@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
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif
@script
  if(frame > 0){
    ....
@end_script
frame    data/chars/cody/idle.gif

C:
anim    idle

loop 0 //or without loop

@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

frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif
frame    data/chars/cody/idle.gif

Honestly I'm kind of lost here. I just meant to answer your last question, I'm not up on the whole thread. That's probably better left to @Bloodbane since he's been working with you on it.

DC
 
Back
Top Bottom