I've made such enemy before which jumps instead of walk. This enemy uses targetting script to ensure it jumps toward player (not jump right at player)
I set this in his WALK animation:
anim walk
@script
void self = getlocalvar("self"); //Get calling entity.
changeentityproperty(self, "velocity", 0, 0);
setidle(self, openborconstant("ANI_IDLE"));
@end_script
...
The script is to forcefully cancel WALK animation before enemy walks
I do this cause setting
nomove 1 1 also sets
nodrop 1 which I don't want for this enemy
As for its wa.. jump AI or I should say movement AI, so far I only has random jump function which makes enemy jumps to random direction.
It is
rdodgez posted below:
Code:
void dodgez( float Vx, float Vy, float Vz )
{// Dodge by moving up or down depending on z location
void self = getlocalvar("self");
int z = getentityproperty(self, "z");
int dir = getentityproperty(self,"direction");
if(dir==0){ // Facing left?
Vx = -Vx ;
}
if(z > (openborvariant("PLAYER_MIN_Z") + openborvariant("PLAYER_MAX_Z")) / 2 ) {
Vz = -Vz ;
}
if( Vx!=NULL() && Vy!=NULL() && Vz!=NULL() ){
changeentityproperty(self, "velocity", Vx, Vz, Vy); //Dodge away!
}
}
void Rdodgez( float Vx, float Vy, float Vz, float Rx, float Rz )
{// Dodgez with random velocity effect
// Only randomize x and z velocities
// Vx : x velocity
// Vy : y velocity
// Vz : z velocity
// Rx : x velocity randomness effect
// Rz : z velocity randomness effect
int iDX;
int iDZ;
if(Rx!=0){
iDX = (rand()%(Rx*10)*0.1);
} else {
iDX = 0;
}
if(Rz!=0){
iDZ = (rand()%(Rz*10)*0.1);
} else {
iDZ = 0;
}
dodgez( Vx+iDX, Vy, Vz+iDZ );
}
I include
dodgez as well since
Rdodgez calls it
This function is set in enemy's attack animaiton like this:
anim attack1
range 0 900
rangez -200 200
delay 1
offset 128 96
bbox 113 27 37 69
frame data/chars/troglodyte/idle1.png
delay 10
bbox 110 58 45 48
frame data/chars/troglodyte/jump1.png
delay 14
bbox 113 34 34 42
@cmd Rdodgez 0 2 0 3 1
sound data/chars/gnolla/sounds/jump.wav
frame data/chars/troglodyte/jump2.png
frame data/chars/troglodyte/jump3.png
frame data/chars/troglodyte/jump2.png
delay 30
bbox 110 58 45 48
frame data/chars/troglodyte/jump1.png
This attack animation will be used as its movement.
Work great in my end