Birnbaum
Member
Hello!
I'm trying to create a script to a boss.
Basically if the final blow throw the boss off the screen and the script made him return to the screen performing a jump to return and then ending the death animation.
The script doesnt work and I dont know exactly what is wrong.
Could be a mistake about the concept of how and when to use ondeathscript or a syntax error?
Thanks in advance.
Detail on the char header:
falldie 2
nodieblink 3
I'm trying to create a script to a boss.
Basically if the final blow throw the boss off the screen and the script made him return to the screen performing a jump to return and then ending the death animation.
The script doesnt work and I dont know exactly what is wrong.
Could be a mistake about the concept of how and when to use ondeathscript or a syntax error?
Thanks in advance.
Detail on the char header:
falldie 2
nodieblink 3
Code:
#include data/scripts/escript.c
void main(){
void self = getlocalvar("self");
int x = getentityproperty(self,"x");
int z = getentityproperty(self,"z");
int WidthB = openborvariant("PLAYER_MAX_Z");
int WidthA = openborvariant("PLAYER_MIN_Z");
int Screen = openborvariant("hResolution");
int Base1;
int Base2;
if(frame==1){
if(x<=0){
Base1 = x+Screen;
Base2 = WidthB-(WidthA/2);
targetPos(4.6,Base1,Base2);
}
if(x>Screen){ Base1 = x-Screen;
Base2 = WidthB-(WidthA/2);
targetPos(4.6,Base1,Base2);}
} }
if(frame==7){ leap(4.6); }
}
}
//Functions used:
void targetPos(float Vy, int Tx, int Tz)
{// Targetting certain position before leaping there
// Vy : Leaping speed
// Tx : Leaping destination x coordinate
// Tz : Leaping destination z coordinate
// Used with 'leap' or 'toss2'
void self = getlocalvar("self");
float x = getentityproperty(self, "x"); // Get entity's x coordinate
float z = getentityproperty(self, "z"); // Get entity's z coordinate
if(Tx < x){
changeentityproperty(self, "direction", 0); // Face left
} else {
changeentityproperty(self, "direction", 1); // Face right
}
setlocalvar("x"+self, (Tx-x)/(20*Vy)); // Calculate Vx then store value in local variable
setlocalvar("z"+self, (Tz-z)/(20*Vy)); // Calculate Vz then store value in local variable
}
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!
}
}