Aerisetta
Active member
So I have an issue where my player will target the closest enemy and dash towards them.
One issue I have is that the game targets the closest OBSTACLES as well, which I don't want.
Is it possible to edit the targeting script I use to not target obstacles? or perhaps a differet method?
the attack
the targeting script
One issue I have is that the game targets the closest OBSTACLES as well, which I don't want.
Is it possible to edit the targeting script I use to not target obstacles? or perhaps a differet method?
the attack
Code:
anim attack1 ### Claw 1
cancel 0 999 0 A2 freespecial41 # Launcher
fastattack 1
jugglecost 1
delay 3
offset 120 350
bbox 98 93 88 260
@cmd target 6 6 1 1 1
@cmd dash
#jumpframe 1 0 1
@cmd spawn01 "effect3" 150 150 2
sound data/sounds/punch_.wav
hitfx data/sounds/slashl.wav
frame data/chars/aerisetta/attack201.png
sound data/sounds/A_Attack1.wav
attack1 163 0 90 304 6 0 0 0 20 50
#@cmd finishlevel() ######################################### Level Skip
forcedirection -1
frame data/chars/aerisetta/attack202.png
@cmd target 0 0 0 0 1
@cmd dash
frame data/chars/aerisetta/attack203.png
attack 0
frame data/chars/aerisetta/attack204.png
delay 3
frame data/chars/aerisetta/attack205.png
the targeting script
Code:
void target(float Velx, float Velz, float dx, float dz, int Stop, int Flip)
{// Targetting opponent before leaping or dashing.
// Velx = x Velocity
// Velz = z Velocity
// dx = x added distance
// dz = z added distance
// Stop = flag to stop moving if no target is found
void self = getlocalvar("self");
int dir = getentityproperty(self, "direction");
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
if (dir == 0){ //Is entity facing left?
dx = -dx; //Reverse X direction to match facing
}
setlocalvar("T"+self, findtarget(self)); //Get nearest player
if( getlocalvar("T"+self) != NULL()){
void target = getlocalvar("T"+self);
float Tx = getentityproperty(target, "x");
float Tz = getentityproperty(target, "z");
if(Flip == 1){
if(Tx < x){
changeentityproperty(self, "direction", 0);
} else {
changeentityproperty(self, "direction", 1);
}
}
x = x+dx;
z = z+dz;
float Disx = Tx - x;
float Disz = Tz - z;
//Set both distance as positive value
if(Disx < 0){
Disx = -Disx;
}
if(Disz < 0){
Disz = -Disz;
}
// Calculate velocity for targetting
if(Disz < Disx)
{
if(Tx < x){
setlocalvar("x"+self, -Velx);
} else { setlocalvar("x"+self, Velx); }
setlocalvar("z"+self, Velx*(Tz-z)/Disx);
} else {
if(Tz < z){
setlocalvar("z"+self, -Velz);
} else { setlocalvar("z"+self, Velz); }
setlocalvar("x"+self, Velz*(Tx-x)/Disz);
}
} else {
if(Stop == 1)
{
setlocalvar("z"+self, 0);
setlocalvar("x"+self, 0);
} else {
setlocalvar("z"+self, 0);
if(dir==0){
setlocalvar("x"+self, -Velx);
} else { setlocalvar("x"+self, Velx); }
}
}
setlocalvar("T"+self, NULL()); //Clears variable
}

