Anim Victory

kmilloz

Member
I know you have the script to make the victory of animation, but how to make the player go to the screen center, before making the animation of victory? Does anyone know how to do this?
 
you can check this post to learn how to geit working
http://www.chronocrash.com/forum/index.php?topic=2014.0

you can either difine the coordinates in an type none entity and spwan it
or use it in a enemy death anim
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

these are the script you can change the "ANI_IDLE" to another animation at the end of automv.c

            if ( getentityproperty(player, "animationid") != openborconstant("ANI_IDLE") ) changeentityproperty(player, "animation", openborconstant("ANI_IDLE"));
            changeentityproperty(player, "direction", final_direction);


automv.c
Code:
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;
}



endlevel anim
Code:
#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
      }
   }

}
 
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)
 
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)
In fact, only in a phase I need the players are at the center of the screen before showing the victory of animation ...
Na verdade, somente em uma fase que preciso que os players fiquem no centro da tela, antes de mostrar a animação de vitória...
 
Hi, with script:
Com o script:
https://www.youtube.com/watch?v=6Se59l-bkAY&feature=youtu.be

I need this:
Preciso de algo assim:
https://www.youtube.com/watch?v=2MgpdMP7y4s&feature=youtu.be

correct position players:
Posição correta para os jogadores:
teste_zps054b055e.png
 

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 ;)
 
Bloodbane said:

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 ;)

Sorry man... but script can´t compile...

this log openbor:
Can't compile script 'don2' data/chars/don/don2/don2.txt

@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
offset 32 83
sound data/chars/don/don2/ufoout2.wav
delay 100
frame data/chars/don/don2/foll01.gif
delay 10
offset 30 83
frame data/chars/don/don2/foll02.gif
delay 6
offset 28 83
frame data/chars/don/don2/foll03.gif
movea 3
offset 26 83
frame data/chars/don/don2/foll04.gif
offset 24 83
frame data/chars/don/don2/foll05.gif....
 
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
 
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

Thanks man! Now works!
 
I'm using an old version of the engine to create games for Dreamcast, in this case this function wouldn't work so I want to use the old way of doing it with script.
 
Okay, what about this script:
Code:
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

This script forces player 1 and player 2 to perform VICTORY animation when this empty entity is spawned.
 
Wouuu Thank you Bloodbane! This script will work perfet in my Story mode where players are coop.

But i need something like this to use in a PVP 4 players mode, so i need to perform VICTORY animation when just one player, the winner, remains alive.
 
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
 
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

@kdo, please use code tags when you post text samples and script.


DC
 
  • Like
Reactions: kdo
Back
Top Bottom