Thegr8test
Member
Is there a script to target nearby enemies during an attack? I want to have the player rush towards the enemy and perform a rush combo attack. I checked the scripts section but I don't see anything for this type of attacks
void targetL(float Vy, float dx, float dz)
{// Targetting opponent before performing targetted leap attack
// Vy = y Velocity
// dx = x added distance
// dz = z added distance
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(Tx < x){
changeentityproperty(self, "direction", 0);
} else {
changeentityproperty(self, "direction", 1);
}
x = x+dx;
z = z+dz;
setlocalvar("x"+self, (Tx-x)/(22*Vy));
setlocalvar("z"+self, (Tz-z)/(22*Vy));
} else {
setlocalvar("z"+self, 0);
setlocalvar("x"+self, 0);
}
}
void dash()
{// Dash with previously attained speed!
void self = getlocalvar("self");
float Vx = getlocalvar("x"+self);
float Vz = getlocalvar("z"+self);
if( Vx!=NULL() && Vz!=NULL() ){
changeentityproperty(self, "velocity", Vx, Vz); //Move towards target!
}
}
void leap(float Vely)
{// Leap with previously attained speed!
void self = getlocalvar("self");
float Vx = getlocalvar("x"+self);
float Vz = getlocalvar("z"+self);
if( Vx!=NULL() && Vz!=NULL() ){
tossentity(self, Vely, Vx, Vz); //Leap towards target!
}
}
@cmd target 0.7 0.5 0 0 1
@cmd leap 4
frame data/chars/caro/jump0.png
@cmd target 1 1 0 0 2
@cmd dash
frame data/chars/midas/at2c.png
Script compile error: can't find function 'target'
Script compile error in 'animationscript': target line 25, column 12
********** An Error Occurred **********
* Shutting Down *
Can't compile script 'animationscript' data/chars/Yususke/Yususke.txt
Total Ram: 4207882240 Bytes
Free Ram: 2183176192 Bytes
Used Ram: 37928960 Bytes
Release level data........... Done!
Release graphics data........ Done!
Release game data............
Release game data............ Done!
Release timer................ Done!
Release input hardware....... Done!
Release sound system......... Done!
Release FileCaching System... Done!
**************** Done *****************
Can't compile script 'animationscript' data/chars/Yususke/Yususke.txt
anim freespecial4
com D F A freespecial4
fastattack 1
delay 15
offset 25 66
@cmd target 0.7 0.5 0 0 1
@cmd leap 4
frame data/chars/yususke/turn.png
delay 15
offset 25 48
frame data/chars/yususke/fd.png
delay 5
offset 21 67
frame data/chars/yususke/rp1.png
attack 30 1 20 15 7 0 1 0 9 0
delay 10
offset 20 66
frame data/chars/yususke/qp2.png
attack 0 0 0 0 0 0 0 0 0 0
delay 5
offset 21 66
frame data/chars/yususke/qp1.png
delay 5
offset 19 53
frame data/chars/yususke/uc2.png
attack 37 3 19 28 9 0 1 0 8 0
delay 9
offset 19 58
frame data/chars/yususke/uc3.png
attack 0 0 0 0 0 0 0 0 0 0
delay 5
offset 19 53
frame data/chars/yususke/uc2.png
attack 30 1 20 15 7 0 1 0 9 0
delay 10
offset 20 66
frame data/chars/yususke/qp2.png
attack 0 0 0 0 0 0 0 0 0 0
delay 5
offset 21 66
frame data/chars/yususke/qp1.png
delay 5
offset 16 64
frame data/chars/yususke/hk1.png
delay 9
attack 19 14 12 18 9 0 1 0 5 0
offset 15 67
frame data/chars/yususke/sk1.png
attack 0 0 0 0 0 0 0 0 0 0
delay 7
offset 25 66
frame data/chars/yususke/mp1.png
delay 5
offset 21 68
frame data/chars/yususke/qk1.png
attack 35 3 28 16 8 0 1 0 12 0
delay 9
offset 32 68
frame data/chars/yususke/qk2.png
attack 0 0 0 0 0 0 0 0 0 0
delay 5
offset 21 68
frame data/chars/yususke/qk1.png
delay 5
offset 16 64
frame data/chars/yususke/hk1.png
delay 5
offset 16 67
frame data/chars/yususke/sk1.png
delay 9
attack 39 11 19 16 8 2 1 0 12 0
dropv 3 3 0
offset 10 67
frame data/chars/yususke/sk3.png
delay 5
offset 8 70
frame data/chars/yususke/hk3.png
delay 12
offset 10 78
frame data/chars/yususke/sk2.png
delay 5
offset 10 67
frame data/chars/yususke/sk3.png
delay 5
offset 21 66
frame data/chars/yususke/mp1.png
Script compile error: can't find function 'target'
void target(float Velx, float Velz, float dx, float dz, int Stop)
{// 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(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); }
}
}
}
Thegr8test said:yeah I saved it in ilu script and thats included in my script.c file
can you share pls?I've just noticed that the target function is really old one. The latest version has flip parameter to define if entity would flip to target or not if target is found.
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
}