name endlevel_anim
type none
health 1
#nolife 1
#setlayer 1
facing 2
nomove 1 0
script data/scripts/endlevel_anim.c
anim idle
@script
void self = getlocalvar("self");
setentityvar(self, 5, 6650); // coord x
setentityvar(self, 6, 310); // coord z
setentityvar(self, 7, 1); // direction 0 left 1 right
setentityvar(self, 8, 0); // player nº
@end_script
loop 0
delay 100
offset 20 25
bbox 0 0 0 0
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
if ( getentityproperty(player, "animationid") != openborconstant("ANI_IDLE") ) changeentityproperty(player, "animation", openborconstant("ANI_IDLE"));
changeentityproperty(player, "direction", final_direction);
float abs(float num) {
if (num < 0) num *= -1;
return num;
}
int movetoxz(void player, float dir_x, float dir_z, int final_direction) {
float x = getentityproperty(player, "x");
float z = getentityproperty(player, "z");
float a = getentityproperty(player, "y");
float base = getentityproperty(player, "base");
float threshold = 0.99; // precisione
float speed = getentityproperty(player,"speed");
float speed_x, speed_z;
if ( getentityproperty(player, "animationid") != openborconstant("ANI_SPAWN") && getentityproperty(player, "animationid") != openborconstant("ANI_RESPAWN") ) {
if ( a != base ) changeentityproperty(player, "position", x, z, base);
if ( x > dir_x-threshold && x < dir_x+threshold ) {
speed_x = 0;
} else if ( x < dir_x+threshold ) { // pg deve andare a destra
if ( getentityproperty(player, "animationid") != openborconstant("ANI_WALK") ) changeentityproperty(player, "animation", openborconstant("ANI_WALK"));
changeentityproperty(player, "direction", 1);
speed_x = speed;
if ( (dir_x-x) <= threshold ) speed_x = (dir_x-x)*(2/3); // Impostiamo la velocità proprio uguale alla distanza che manca
} else if ( x > dir_x-threshold ) { // pg deve andare a sinistra
if ( getentityproperty(player, "animationid") != openborconstant("ANI_WALK") ) changeentityproperty(player, "animation", openborconstant("ANI_WALK"));
changeentityproperty(player, "direction", 0);
speed_x = -1*speed;
if ( (x-dir_x) <= threshold ) speed_x = -1*(x-dir_x)*(2/3);
}
// Diamo la priorità all'animazione UP/DOWN
if ( z > dir_z-threshold && z < dir_z+threshold ) {
speed_z = 0;
} else if ( z < dir_z+threshold ) { // pg deve andare giù
if ( getentityproperty(player, "animationid") != openborconstant("ANI_DOWN") ) changeentityproperty(player, "animation", openborconstant("ANI_DOWN"));
speed_z = speed/2;
if ( (dir_z-z) <= threshold ) speed_z = (dir_z-z)*(2/3);
} else if ( z > dir_z-threshold ) { // pg deve andare su
if ( getentityproperty(player, "animationid") != openborconstant("ANI_UP") ) changeentityproperty(player, "animation", openborconstant("ANI_UP"));
speed_z = -1*(speed/2);
if ( (z-dir_z) <= threshold ) speed_z = -1*(z-dir_z)*(2/3);
}
if ( speed_x == 0 && speed_z == 0 ) {
changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
if ( getentityproperty(player, "animationid") != openborconstant("ANI_IDLE") ) changeentityproperty(player, "animation", openborconstant("ANI_IDLE"));
changeentityproperty(player, "direction", final_direction);
return 1;
}
changeentityproperty(player, "velocity", speed_x, speed_z, NULL());
} // fine if spawn
return 0;
}
#import "data/scripts/automv.c"
void main() {
void self = getlocalvar("self");
float x = getentityvar(self, 5); //move x
float z = getentityvar(self, 6); //move z
float d = getentityvar(self, 7); //face left right
float p = getentityvar(self, 8); //player nº 0 1 2
void player = getplayerproperty(p,"entity"); // retrieve player 1 handler
if ( getentityproperty(player,"exists") ) {
if ( getentityproperty(player,"noaicontrol") == 0 ) changeentityproperty(player,"noaicontrol",1);
if ( movetoxz(player,x,z,d,0.5) ) {
//if ( getentityproperty(player,"noaicontrol") == 1 ) changeentityproperty(player,"noaicontrol",0);
//drawstring(200,200,0,"player has finished to move on");
//killentity(self); // to finish the script
}
}
}
@script
if(frame==1){
void self = getlocalvar("self");
float x = getentityproperty(self, "x");
float z = getentityproperty(self, "z");
float Tx = openborvariant("xpos") + openborvariant("hResolution")/2;
float Tz = (openborvariant("PLAYER_MIN_Z") + openborvariant("PLAYER_MAX_Z"))/2;
float Vx;
float Vz;
Vx = (Tx-x)/66;
Vz = (Tz-z)/66;
tossentity(self, 3, Vx, Vz);
}
@end_script
In fact, only in a phase I need the players are at the center of the screen before showing the victory of animation ...Bloodbane said:If you only want players to center themselves to center of playing field, you can just use script to force them to play 'jump-to-center' animation. Well, you can just clone JUMP animation and name it FOLLOW2 or something
Then in that animation declare this script:
Code:@script if(frame==1){ void self = getlocalvar("self"); float x = getentityproperty(self, "x"); float z = getentityproperty(self, "z"); float Tx = openborvariant("xpos") + openborvariant("hResolution")/2; float Tz = (openborvariant("PLAYER_MIN_Z") + openborvariant("PLAYER_MAX_Z"))/2; float Vx; float Vz; Vx = (Tx-x)/66; Vz = (Tz-z)/66; tossentity(self, 3, Vx, Vz); } @end_script
This script will toss or make entity jumps to center of playing field at 2nd frame
Although it's possible to 'walk' instead of jumping, I recommend jumping since it's easier to set, even Capcom beat'm ups use this method (they don't always jump to center though)
That's the first part. Now, the next part is.... before I continue, I need to ask: do you have other situations in which you need players to move to certain point? like in Punisher, in which Punisher and Nick Fury jump to left side before Bruno walks in (at first stage)
Why 66?
tossentity(self, 3, Vx, Vz)
anim follow1 # assuming your victory animation is FOLLOW1
@script
if(frame==1){
void self = getlocalvar("self");
float x = getentityproperty(self, "x");
float Tx = openborvariant("xpos") + openborvariant("hResolution")/2;
float Vx;
Vx = (Tx-x)/100;
changeentityproperty(self, "velocity", Vx);
} else if(frame==2){
changeentityproperty(self, "velocity", 0);
}
@end_script
...
delay 1
frame {path}
delay 100
frame {path} # move to center is done in this frame
delay 10
frame {path} # turtles stop here
... (paste the hover to infinity animation here)
Bloodbane said:Why 66?
It's related to this:
tossentity(self, 3, Vx, Vz)
This tossentity function produces jump similar to jumpframe x 3 x x
Vx = (Tx-x)/66 calculates required velocity to reach Tx from x if entity reaches it by jumping. 66 is the predicted time to reach it gained from 3x20 + adjustment (the blue text are related)
I don't know how gravity affects timing but I know for sure that the required time is more than 3x20 so I just set some small adjustment such as 6
@kmilloz: I'll be back after I watched your video
[couple minutes later]
Alright, I've watched it and I understand what's needed here. You only need to add this script to your victory animation:
anim follow1 # assuming your victory animation is FOLLOW1
@script
if(frame==1){
void self = getlocalvar("self");
float x = getentityproperty(self, "x");
float Tx = openborvariant("xpos") + openborvariant("hResolution")/2;
float Vx;
Vx = (Tx-x)/100;
changeentityproperty(self, "velocity", Vx);
} else if(frame==2){
changeentityproperty(self, "velocity", 0);
}
@end_script
...
delay 1
frame {path}
delay 100
frame {path} # move to center is done in this frame
delay 10
frame {path} # turtles stop here
... (paste the hover to infinity animation here)
The idea is to add 'move to center' part before your 'victory' animation. During that part, Turtle will move to center in 1 second after it starts
I think we need to discuss this further since I'm sure you want each player to move to different spots![]()
@script
if(frame==1){
void self = getlocalvar("self");
float x = getentityproperty(self, "x");
float Tx = openborvariant("xpos") + openborvariant("hResolution")/2;
float Vx;
Vx = (Tx-x)/100;
changeentityproperty(self, "velocity", Vx);
} else if(frame==2){
void self = getlocalvar("self");
changeentityproperty(self, "velocity", 0);
}
@end_script
Bloodbane said:Oops, missing small thing, replace it with this:
Code:@script if(frame==1){ void self = getlocalvar("self"); float x = getentityproperty(self, "x"); float Tx = openborvariant("xpos") + openborvariant("hResolution")/2; float Vx; Vx = (Tx-x)/100; changeentityproperty(self, "velocity", Vx); } else if(frame==2){ void self = getlocalvar("self"); changeentityproperty(self, "velocity", 0); } @end_script
spawn empty
@script
void main(){
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
if(P1){
changeentityproperty(P1, "velocity", 0, 0, 0);
performattack(P1, openborconstant("ANI_VICTORY"));
}
if(P2){
changeentityproperty(P2, "velocity", 0, 0, 0);
performattack(P2, openborconstant("ANI_VICTORY"));
}
}
@end_script
coords 240 200
at 0
I1am a script noob, this script for 4 players would be something like this?
spawn empty
@script
void main(){
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
int P3 = getplayerproperty(2, "entity");
int P4 = getplayerproperty(3, "entity");
if(P1){
changeentityproperty(P1, "velocity", 0, 0, 0);
performattack(P1, openborconstant("ANI_VICTORY"));
}
if(P2){
changeentityproperty(P2, "velocity", 0, 0, 0);
performattack(P2, openborconstant("ANI_VICTORY"));
}
if(P3){
changeentityproperty(P3, "velocity", 0, 0, 0);
performattack(P1, openborconstant("ANI_VICTORY"));
}
if(P4){
changeentityproperty(P4, "velocity", 0, 0, 0);
performattack(P2, openborconstant("ANI_VICTORY"));
}
}
@end_script
coords 240 200
at 0
Iam Sorry, next time i'll use the code tag. I didn't know how to use it, thanks for the explanation @DC.