Solved Player's Choices during Continue Screen

Question that is answered or resolved.

maxman

Well-known member
I created an NPC type entity that serves as player's continue "substitute" to appear in the very last frame of player's death animation and one frame after it's killed/removed under a time-over animation. As for now, I'm only gonna show the one with player's time-over pose.

There are other issues that I couldn't get it right, but only one I succeeded. The one I succeeded is when a number of players do not exist where NPC is still there, he acts ready with a shout as you press start as player 1 and you return to select screen normally. However, this causes one issue as if a second player joins (player 1 is dead or removed) while the NPC is still there, the NPC shouts since one of the players starts to exist. Thus, two players start in the select screen. What I'm trying to do is to have P2 join in during the continue screen while eliminating P1 before P2 goes to the select screen alone. Also, while pressing start on the P2 side, I'm trying not to let NPC from dead P1 shout if P2 joins. I haven't added the continue-countdown text for P1 yet.

Another issue is the countdown trigger for NPC to die after it finishes. The problem I'm having with it is that NPC can't die after the countdown is over, as well as not reducing health points. I'm trying to deduct NPC's health points to 0, based on the countdown button trigger for skipping. You either skip it to the next frame or you wait for the next frame to start, so that its health point reduces 1 at a time. When it reaches to 0, the NPC starts to die with anim death.

Here's the one that plays a role in continue screen after player's death. (Yes, I know that script tags are not necessary, but I use them temporarily for testing purposes.)
Code:
name Ryu_continue
type npc
health 9
speed 10
nomove 1
antigravity 100
death 1
nopain 1
setlayer 510000000
subject_to_minz 0
subject_to_maxz 0
subject_to_wall 0
subject_to_platform 0
subject_to_obstacle 0

diesound data/sounds/fighters/ryu/SND_PL00_0.wav

takedamagescript @script
void main(){
    void self = getlocalvar("self");
    int hp = getentityproperty(self, "health");
    int skip = getglobalvar("MenuSelect");
    if(skip == 1){
        changeentityproperty(self, "health", hp-1);
    }
}
@end_script

script @script
void main(){
    void self = getlocalvar("self");
    int PLAY = openborvariant("count_players");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int P1join = getplayerproperty(P1, "joining");
    int P2join = getplayerproperty(P2, "joining");
    if(PLAY == 1){
        performattack(self, openborconstant("ANI_FOLLOW1"));
    }
}
@end_script

onspawnscript @script
void main(){
    void self = getlocalvar("self");
    int xpos = openborvariant("xpos");
    int ypos = openborvariant("ypos");
    changeentityproperty(self, "position", xpos+91, ypos+182, NULL());
}
@end_script

anim spawn
    delay 2
    offset 28 97
    frame data/CHARS/Ryu/0530000000.gif
    frame data/CHARS/Ryu/0530000000.gif

anim idle #Groggy
    loop 1
    delay 30
    offset 28 97
    frame data/CHARS/Ryu/0530000000.gif
    offset 28 96
    frame data/CHARS/Ryu/0530000001.gif
    offset 29 95
    frame data/CHARS/Ryu/0530000002.gif
    frame data/CHARS/Ryu/0530000003.gif
    offset 29 97
    frame data/CHARS/Ryu/0530000004.gif
    offset 28 98
    frame data/CHARS/Ryu/0530000005.gif

anim follow1 #Continue
    #loop    1
    delay    50
    offset    25 99
    sound    data/sounds/ryu/shoryuken.wav
    frame    data/chars/ryu/0000000000.gif
    @cmd killentity(getlocalvar("self"))
    frame    data/chars/ryu/0000000000.gif

anim death #Game over
delay 23
    offset 31 94
    frame data/CHARS/Ryu/0595000000.gif
    delay 21
    offset 26 68
    frame data/CHARS/Ryu/0595000001.gif
    offset 26 70
    delay 65
    frame data/CHARS/Ryu/0595000002.gif
    delay 19
    offset 31 65
    frame data/CHARS/Ryu/0595000003.gif
    delay 18
    offset 40 58
    frame data/CHARS/Ryu/0595000004.gif
    delay 14
    offset 46 58
    frame data/CHARS/Ryu/0508000000.gif
    offset    49 40
    delay    595
    frame    data/chars/ryu/0504000010.gif

Player's Time over:
C:
anim    follow15 #Time out
@script
    void self = getlocalvar("self");
    void Return = getglobalvar("Return");
    void Current = openborvariant("current_branch");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int PLAY = openborvariant("count_players");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int set = openborvariant("current_set");

    if(frame==5 && PLAY == 1 && set == 0){
      if(win1 == 2 || win2 == 2){

    void vSpawn; //Spawn object.
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int YPos = openborvariant("ypos"); // Get camera position
        int Screen = openborvariant("hResolution"); // Get screen width

    void target = getentityproperty(self, "opponent");
    void name = getentityproperty(target, "name");

    clearspawnentry(); //Clear current spawn entry.

    loadmodel("enemywin");
    setspawnentry("name", "enemywin"); //Acquire spawn entity by name.

    vSpawn = spawn(); //Spawn in entity.

    if(name == "Ken"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL"));
    }else{
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    }
    setglobalvar("Wait", 1);
    clearglobalvar();
      } else {
    jumptobranch(Current,1);
      }
    }

    if(frame==5 && PLAY == 2 && set == 0){
      if(win1 == 2 || win2 == 2){
    void vSpawn; //Spawn object.
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int YPos = openborvariant("ypos"); // Get camera position
        int Screen = openborvariant("hResolution"); // Get screen width

    clearspawnentry(); //Clear current spawn entry.
    loadmodel("darkblue");
    setspawnentry("name", "darkblue"); //Acquire spawn entity by name.

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", 160 + XPos, 246 + YPos);
    changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW4"));
      setglobalvar("Wait", 1);
      } else {
    jumptobranch(Current,1);
      }
    }

 // ANIM FOLLOW5 FOR SPAWNED MODEL NOT YET DONE

    if(frame==5 && PLAY == 2  && set > 0){
      if( win1 == 2 || win2 == 2 || (win1 == 2 && win2 == 2) ){
    void vSpawn; //Spawn object.
        int XPos = openborvariant("xpos"); //Get screen edge's position
        int YPos = openborvariant("ypos"); // Get camera position
        int Screen = openborvariant("hResolution"); // Get screen width

    void target = getentityproperty(self, "opponent");
    void name = getentityproperty(target, "name");

    clearspawnentry(); //Clear current spawn entry.
    loadmodel("darkblue");
    setspawnentry("name", "darkblue"); //Acquire spawn entity by name.

    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", 160 + XPos, 246 + YPos);
    changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW5"));
    setglobalvar("Wait", 1);
    clearglobalvar();
      } else {
    jumptobranch(Current,1);
      }
    }
    @end_script  
    delay    9
    offset    25 105
    @cmd stop
    custentity ryu_continue
    spawnframe 6 0 200 0 0
    frame    data/chars/ryu/0017000000.gif #0- 9
    offset    23 107
    frame    data/chars/ryu/0017000001.gif #1 - 18
    frame    data/chars/ryu/0017000002.gif #2 - 27
    offset    23 108
    frame    data/chars/ryu/0017000003.gif #3 - 36
    offset    23 109
    delay    339
    frame    data/chars/ryu/0017000004.gif #4 - 365
    delay    30
    frame    data/chars/ryu/0017000004.gif #5 - 425
    delay    5
    @cmd suicide
    frame    data/chars/ryu/0017000004.gif #6 - 430
    #delay    250
    frame    data/chars/ryu/0017000004.gif
    frame    data/chars/ryu/0017000004.gif

Here's the countdown.


contAnim.c:
C:
#include "data/scripts/scenefx.c"

void noplayerJoin (int iG)
{
// controls if other players can join the game or not
// 1 - players CAN NOT join, 0 play CAN join
// remember to set it 0 when you are done, or you will have a 1P only game.
// Douglas Baldan/O Ilusionista - 20/09/14
changeopenborvariant("nojoin", iG);
}

void noPJoin(int P, int iG){
    void Player = getplayerproperty(P, "entity");
    changeopenborvariant("nojoin", iG);
}

void Skip(int Frame){
    void self = getlocalvar("self");
    int skip = getglobalvar("MenuSelect"); // Look at contkey.c for key inputs

    if(skip == 1){
        updateframe(self, Frame);
    }
}

void noCredits(){

    void self = getlocalvar("self");
    int P1 = getplayerproperty(0, "entity"); // This is IMPORTANT!!!
    int P2 = getplayerproperty(1, "entity"); // This is IMPORTANT!!!
    int P1Cred = getplayerproperty(P1, "credits");
    int P2Cred = getplayerproperty(P2, "credits");

    if(P1Cred < 1 || P2Cred < 1){
        performattack(self, openborconstant("ANI_FOLLOW1"));
    }

}

keyall.c:
C:
#import "data/scripts/dcancel.c"
#import "data/chars/misc/continueanim/contkey.c"

void main(){
   
    daimaoKeyCancel();
    continueKey();
}

contkey.c:
C:
void main(){
    continueKey();
}

void continueKey()
{
    int player = getlocalvar("player");
    void self = getlocalvar("self");
    void keySound = loadsample("data/sounds/common/beep4.wav");

    int anybuttonH = playerkeys(player, 0, "anybutton"); // Hold any button key?
    int anybutton = playerkeys(player, 1, "anybutton"); // Press any button key?
    int anybuttonR = playerkeys(player, 2, "anybutton"); // Release any button key?

    // Action/Movement event capture

    if(anybutton){
        setglobalvar("MenuSelect", 1); // Press?
    }else if(anybuttonR){
        setglobalvar("MenuSelect", 0); // Release?
    }else if(anybuttonH){
        setglobalvar("MenuSelect", 2); // Hold?
    }
}

EDIT: Do I need to use ondeathscript? I don't know how to create a death script. Is there any example of how to deal with it in players or any entity types?
 
Last edited:
I tried to use this entity for killing one NPC, so that it would activate his dying animation after the countdown. However, it doesn't work when I tried to do this one. What I'm trying to do is to make this one only attack that continuing NPC instead of player. I got a crash for including walk anim without idle anim, or maybe its speed is over 9000.

Code:
name ContKill
type enemy
subtype chase
speed 9900
candamage npc
hostile npc
offscreenkill 400000000
subject_to_minz 0
subject_to_maxz 0
subject_to_wall 0
subject_to_platform 0
subject_to_obstacle 0
subject_to_screen 0

animationscript data/scripts/script.c

anim idle
offset 0 0
delay 3
loop 1
frame data/chars/misc/empty.gif
@cmd attack0 "ANI_WALK"
frame data/chars/misc/empty.gif

anim walk
offset 1 1
delay 6
loop 1
followanim 2
followcond 1
attack 0 0 1000 1000 10 0 0 0 0 0
hitfx data/sounds/empty.wav
hitflash empty
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
delay 2
attack 0
frame data/chars/misc/empty.gif

anim follow1

offset 1 1
delay 6
loop 1
followanim 2
followcond 1
attack 0 0 1000 1000 10 0 0 0 0 0
hitfx data/sounds/empty.wav
hitflash empty
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
delay 2
attack 0
frame data/chars/misc/empty.gif

anim follow2

offset 0 0
delay 3
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
@cmd suicide
frame data/chars/misc/empty.gif
 
OK. I'm back. Here's a shot showing the character's health point for pressing any button to reduce his health.

My Mod - 0887.png

For example, Ryu's health point is 9 and it's an NPC. It's supposed to reduce his health number based on the countdown press before he dies. What I'm trying to do is to have any key press to skip everytime the countdown skips while his health point is deducted to 1 at a time. Also, there shouldn't be a pain reaction every time the health reduces. When the countdown skips from 9 to 8, his health should be reduced to 8. It's whether you skip it or not. You let the countdown deduct his health until he dies.

I just added the text for displaying his health in his anim spawn to better understand the point.

Code:
anim spawn
@script
void self = getlocalvar("self");
int hp = getentityproperty(self, "health");

settextobj(0, 52, 50, 0, 610000000, "Health:_" + hp);
@end_script
    delay 2
    offset 28 97
    frame data/CHARS/Ryu/0530000000.gif
    frame data/CHARS/Ryu/0530000000.gif

anim idle #Groggy
@script
int skip = getglobalvar("MenuSelect");

if(skip == 1){
    if(frame >= 0 && frame <= 5){
        void self = getlocalvar("self");
        int health = getentityproperty(self, "health");

        if(health <= 9){
            changeentityproperty(self, "health", health-1);
        }
        //if(health == 1){
        //    changeentityproperty(self, "health", health-1);
        //    changeentityproperty(self, "animation", openborconstant("ANI_DIE"));
        //}
    }
}
@end_script
    loop 1
    delay 30
    offset 28 97
    bbox 5 1 50 98
    frame data/CHARS/Ryu/0530000000.gif
    offset 28 96
    bbox 5 0 50 98
    frame data/CHARS/Ryu/0530000001.gif
    offset 29 95
    bbox 6 -1 50 98
    frame data/CHARS/Ryu/0530000002.gif
    frame data/CHARS/Ryu/0530000003.gif
    offset 29 97
    bbox 6 1 50 98
    frame data/CHARS/Ryu/0530000004.gif
    offset 28 98
    bbox 5 2 50 98
    frame data/CHARS/Ryu/0530000005.gif

I'm not using ContKill for it, though I forgot to add its health before which I did.

I should've included this header here.
Code:
name Ryu_continue
type npc
health 9
speed 10
nomove 1
antigravity 100
death 1
nopain 1
facing 1
setlayer 510000000
subject_to_minz 0
subject_to_maxz 0
subject_to_wall 0
subject_to_platform 0
subject_to_obstacle 0

#animationscript data/scripts/textpos.c
keyscript data/chars/misc/continueanim/contkey.c

diesound data/sounds/fighters/ryu/SND_PL00_0.wav
 
Last edited:
Back
Top Bottom