Solved Retaining Opponent Win Count After Opponent Loses/Player Wins in Second Round of Three

Question that is answered or resolved.

maxman

Well-known member
This one is mainly about player VS enemy in a single player mode. I have no problem with players winning first round and on, but I am having trouble with the player win only in the second round.

I tried using this one:
Code:
if(win1 == 1 && win2 == 1){
            if(P1 && Opp1){ // Player 1
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }else if(P2 && Opp2){ // Player 2
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }

Even this one too:

Code:
if(win1 == 1 && win2 == 1){
            if(P1){ // Player 1
                drawsprite(win, 142, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 174, 25, 500);
            }
            if(Opp1){
                drawsprite(win, 174, 25, 500);
            }if(Opp2){
                drawsprite(win, 142, 25, 500);
            }
        }

Both of them don't retain their display of the win counts after the opponent loses in the second round, so only for the win count display on player's side. Each of their win count from both sides after third round starts to show.

Here's a script for the win count.

Code:
void main(){
    void win = getglobalvar("win");
    int P1 = getplayerproperty(0, "entity"); // Player 1
    int P2 = getplayerproperty(1, "entity"); // Player 2
    void Opp1 = findtarget(P1); // Player 1's opponent
    void Opp2 = findtarget(P2); // Player 2's opponent
    void win1 = getglobalvar("win1"); // Win point for Player type in single player mode; player 1 in dual mode
    void win2 = getglobalvar("win2"); // Win point for Enemy type in single player mode; player 2 in dual mode
    int PLAY = openborvariant("count_players");
   
    if(!win){
        win = loadsprite("data/chars/misc/win.png");
        setglobalvar("win", win);
    }
   
    if(PLAY == 2){ // 2 players in dual mode
        if(win1 == 1){
            if(P1){ // Player 1
                drawsprite(win, 1, 25, 500);
            }
        }
        if(win1 == 2){
            if(P1){ // Player 1
                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);
            }
        }
        if(win2 == 1){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
            }
        }
        if(win2 == 2){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);
            }
        }
    }
   
    if(PLAY == 1){ // Single player only?
        if(win1 == 1){ // Fighter 1's single victory?
            if(P1){ // Player 1
                drawsprite(win, 142, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 174, 25, 500);
            }
        }if(win1 == 2){ // Fighter 1's double victory?
            if(P1){ // Player 1
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }
        }
        if(win2 == 1){ // Fighter 2's single victory?
            if(Opp1){
                drawsprite(win, 174, 25, 500);
            }if(Opp2){
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win2 == 2){ // Fighter 2's double victory?
            if(Opp1){
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(Opp2){
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win1 == 1 && win2 == 1){ // Player wins 1 and Enemy wins 1
            if(P1 || Opp2){ // Player 1
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(Opp1 || P2){ // Player 2
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
       
        if(win1 == 2 && win2 == 1){ // Player wins 2 and Enemy wins 1
            if(P1){ // Player 1
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
            }if(Opp1){
                drawsprite(win, 174, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(Opp2){
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win1 == 1 && win2 == 2){ // Player wins 1 but Enemy wins 2
            if(P1){ // Player 1
                drawsprite(win, 142, 25, 500);
            }if(Opp1){
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 189, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 174, 25, 500);
            }if(Opp2){
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 127, 25, 500);
            }
        }
       
    }
}
/*
void ondestroy(){
    void win = getglobalvar("win");
    if(win) {
        free(win);
        setglobalvar("win", NULL());
    }
}
void oncreate(){
    void win = loadsprite("data/chars/misc/win.png");
    setglobalvar("win", win);
}*/

Also, I tried this one, but it's still okay, despite having the count disappear after the enemy opponent loses.

Code:
if(win1 == 1 && win2 == 1){ // Player wins 1 and Enemy wins 1
            if(P1 || Opp2){ // Player 1 or Opponent of Player 2
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(Opp1 || P2){ // Player 2 or Opponent of Player 1
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }

Code:
name        RefPlays
type        none
animationscript    data/scripts/wasitS.c
ondrawscript data/scripts/playerwin.c

anim    spawn
@script
  if(frame==1 && openborvariant("count_players")==1){ // Player vs enemy
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");

    if(P1){
      setglobalvar("F1", P1);
    } else if(P2){
      setglobalvar("F2", P2);
    }
  }

  if(frame>=1 && openborvariant("count_players")==2){ // Player vs player
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");

    if(P1 && P2){
      void self = getlocalvar("self");
      setglobalvar("F1", P1);
      setglobalvar("F2", P2);

      changeentityproperty(P2, "direction", 0);
      setidle(self, openborconstant("ANI_IDLE"));
    }
  }
@end_script
    delay    2
    offset    1 1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

anim    idle
@script
  if(frame==1){
    void self = getlocalvar("self");
    int Habis = Desid();

    if(Habis==1){
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
  }
@end_script
    loop    1
    delay    2
    offset    1 1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

anim    follow1
@script
  if(frame == 0){
    void P1 = getplayerproperty(0, "entity"); // Calling player 1
    void P2 = getplayerproperty(1, "entity"); // Calling player 2
    void EnemP1 = findtarget(P1); // Player 1's specific enemy
    void EnemP2 = findtarget(P2); // Player 2's specific enemy
    void self = getlocalvar("self");
    void Model = getentityproperty(self, "model");
    int CountP = openborvariant("count_players");

    void P1name = getentityproperty(P1, "name");
    void P2name = getentityproperty(P2, "name");

    void EnemP1name = getentityproperty(EnemP1, "name");
    void EnemP2name = getentityproperty(EnemP2, "name");

    if(Model == "timer"){
    performattack(Model, openborconstant("ANI_FOLLOW1"));
    }

    if(P1){ // Player 1?
    changeentityproperty(P1, "noaicontrol", 1); // Stop moving
    }
    if(P2){
    changeentityproperty(P2, "noaicontrol", 1); // Stop moving
    }
    if(EnemP1){ // Enemy of player 1?
    changeentityproperty(EnemP1, "noaicontrol", 1);
    }
    if(EnemP2){
    changeentityproperty(EnemP2, "noaicontrol", 1);
    }

    if(CountP == 1){
    changelevelproperty("scrollspeed", 0);
    }

  }
  if(frame==1){
    void Lead = LeaderFind();
    int PLAY = openborvariant("count_players");

   
    if(PLAY == 2){
    void P1 = getplayerproperty(0, "entity"); // Calling player 1
    void P2 = getplayerproperty(1, "entity"); // Calling player 2

    void P1name = getentityproperty(P1, "name");
    void P2name = getentityproperty(P2, "name");

    if(P1){
        ShowTeks(+P1name+"_wins", 0, 1, 160, 100, 0); // ShowTeks(Text, Index, Font, x, y, z);
    }
    if(P2){
        ShowTeks(+P2name+"_wins", 0, 0, 160, 100, 0);
    }
    }
   

    changeentityproperty(Lead, "velocity", 0, 0, 0);
    performattack(Lead, openborconstant("ANI_FOLLOW61"));
  }
@end_script
    delay    150
    offset    1 1
    @cmd setindexedvar "fightStarted" 0
    frame    data/chars/misc/empty.gif
    delay    300
    frame    data/chars/misc/empty.gif
    delay    10
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

Player txt with anim death:
Code:
anim death
@script
    void self = getlocalvar("self");
    void Return = getglobalvar("Return");
    void Current = openborvariant("current_branch");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int COUNTPLAY = openborvariant("count_players");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");

    int set = openborvariant("current_set");


   if(frame==6 && COUNTPLAY == 1){
    if(win2 == NULL()){
        setglobalvar("win2", 1);
    }
    if(win2 == 1){
        setglobalvar("win2", 2);
    }
   }

    if(frame==8  && COUNTPLAY == 1  && set == 0){
      if(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);

      } else {
    jumptobranch(Current,1);
    //setglobalvar("Return", NULL());
      }
    }


    if(frame==8 && COUNTPLAY == 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 {
    //setglobalvar("Return", Current);
    jumptobranch(Current,1);
      }
    }


 // ANIM FOLLOW5 FOR SPAWNED MODEL NOT YET DONE
    if(frame==8 && COUNTPLAY == 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

    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"));
    //jumptobranch("VS_Select", 1);
    setglobalvar("Wait", 1);
    clearglobalvar();
      } else {
    jumptobranch(Current,1);
      }
    }

    @end_script   
    offset    49 40
    delay    15
    sound data/sounds/fall.wav
    frame    data/chars/ryu/0504000010.gif # 0 15
    delay 250
    frame    data/chars/ryu/0504000010.gif # 1 265
    delay 10
    frame    data/chars/ryu/0504000010.gif # 2 275
    frame    data/chars/ryu/0504000010.gif # 3 285
    frame    data/chars/ryu/0504000010.gif # 4 295
    frame    data/chars/ryu/0504000010.gif # 5 305
    frame    data/chars/ryu/0504000010.gif # 6 315
    delay 50
    frame    data/chars/ryu/0504000010.gif # 7 365
    frame    data/chars/ryu/0504000010.gif # 8 415
    frame    data/chars/ryu/0504000010.gif # 9 465

Enemy's anim death:
Code:
anim    death
@script
    void self = getlocalvar("self");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int PLAY = openborvariant("count_players");
    void Current = openborvariant("current_branch");

    if(frame==6){
   
    if(win1 == NULL()){
        setglobalvar("win1", 1);
    }
    if(win1 == 1){
        setglobalvar("win1", 2);
    }
   
    }
    if(frame==8){
    if(win1 == 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 = findtarget(self); // Calling target.
    void name = getentityproperty(target, "name"); // Calling target's name.

    clearspawnentry(); //Clear current spawn entry.

    loadmodel("victory");
    setspawnentry("name", "victory"); //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{ // Defaultly switch to Ryu?
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    }
    changeentityproperty(vSpawn, "position", 160 + XPos, 120);
      //setglobalvar("Wait", 1);
      clearglobalvar();
      } else {
      jumptobranch(Current,1);
      }
    }
    @end_script   
    offset    49 40
    delay    30
    frame    data/chars/ryu/0504000010.gif # 0
    delay 40
    frame    data/chars/ryu/0504000010.gif # 1
    @cmd    spawnAni "WinLose" 160 120 240 "ANI_FOLLOW1" #"You Win" for players / Opponent's loss
    #delay 15
    frame    data/chars/ryu/0504000010.gif # 2
    frame    data/chars/ryu/0504000010.gif # 3
    frame    data/chars/ryu/0504000010.gif # 4
    frame    data/chars/ryu/0504000010.gif # 5
    frame    data/chars/ryu/0504000010.gif # 6
    delay 40
    frame    data/chars/ryu/0504000010.gif # 7
    delay    2000
    frame    data/chars/ryu/0504000010.gif # 8

EDIT: Here are the steps: First round, opponent wins. Second round, player wins.
 
Last edited:
maxman, I think that since you are already using referee to manage the match, why not let it manage the win counter also?
It's much simpler and you don't need to copy deathscript from one fighter text to other fighter's text.

As for unable to retain win count, did you reset Win1 and Win2 after/before the match begin?
 
Oops. I forgot to include the Round text entity.

Code:
name        RondeText
type        panel
facing        1
palette        none
setlayer     10000
animationscript        data/scripts/sceneFX.c
noquake 1 1 # for GUI
speedf 1.0
speed 10
shadow 0
load darkblue
onspawnscript @script
void main(){
    void self = getlocalvar("self");
    int x; int y;
    int xpos = openborvariant("xpos");
    int ypos = openborvariant("ypos");
    int hres = openborvariant("hresolution");
    int vres = openborvariant("vresolution");

    x = xpos+hres/2; //X position (not X coordinate) and width/horizontal resolution over 2 which is the whole width of resolution is divided by 2 to make it middle. e.g. 320 / 2 = 160; 160 width
    y = ypos+vres/2;
    int a = 6;

    changeentityproperty(self, "position", x, y, a); //Increase 6 or higher for altitude in case you want it to appear til it finishes its progress. But using 5 or lower will make this entity appear shortly and vanish without completing its progress
    changeentityproperty(self, "direction", 1); //Forcing this entity to face right
}
@end_script


anim spawn
@script
void P1 = getplayerproperty(0, "entity");
void P2 = getplayerproperty(1, "entity");
int maxhp1 = getentityproperty(P1, "maxhealth");
int maxhp2 = getentityproperty(P2, "maxhealth");
int PLAY = openborvariant("count_players");
int set = openborvariant("current_set");

/*if(PLAY == 1 && set == 0){
    changeopenborvariant("nojoin", 0);
}*/

if(P1){
    changeentityproperty(P1, "health", maxhp1);
}

if(P2){
    changeentityproperty(P2, "health", maxhp2);
}
@end_script
    offset 1 1
    delay 2
    @cmd setindexedvar "fightStarted" 0
#    @cmd changeopenborvariant "nopause" 1
    @cmd    DeControl 0 1
    @cmd    DeControl 1 1
    frame data/chars/misc/empty.gif


anim    follow1 #Round 2
@script
void self = getlocalvar("self");

    if(frame==0){
    setindexedvar("fightStarted", 0);
//    setglobalvar("fightStarted", 0);
    changeopenborvariant("nopause", 1);
    }

    if(frame==4){
    setindexedvar("fightStarted", 1);
//    setglobalvar("fightStarted", 1);
    changeopenborvariant("nopause", 0);
    }
    @end_script
    delay    6
    offset    155 116
    frame    data/chars/misc/ronde/round1-32.gif
    delay    200
    sound data/sounds/two.wav
    frame    data/chars/misc/ronde/round1-34.gif
    offset    1 1
    delay    1
    frame    data/chars/misc/empty.gif
    delay    110
    @cmd    DeControl 0 1
    @cmd    DeControl 1 1
    sound    data/sounds/fight.wav
    #offset    125 80
    offset    109 50
    frame    data/chars/misc/fight.gif
    delay    3
    offset    1 1
    @cmd    EnemyStart
    @cmd    killentity getlocalvar("self") #Suicide
    @cmd    DeControl 0 0
    @cmd    DeControl 1 0
    frame    data/chars/misc/empty.gif
    
anim    follow2 # Round 3
@script
void self = getlocalvar("self");

    if(frame==0){
//    setindexedvar("fightStarted", 0);
    setglobalvar("fightStarted", 0);
    changeopenborvariant("nopause", 1);
    }

    if(frame==4){
//    setindexedvar("fightStarted", 1);
        setglobalvar("fightStarted", 1);
    changeopenborvariant("nopause", 0);
    }
    @end_script
    delay    6
    offset    155 116
    frame    data/chars/misc/ronde/round1-32.gif
    delay    200
    sound data/sounds/three.wav
    frame    data/chars/misc/ronde/round1-35.gif
    offset    1 1
    delay    1
    frame    data/chars/misc/empty.gif
    delay    110
    @cmd    DeControl 0 1
    @cmd    DeControl 1 1
    sound    data/sounds/fight.wav
    offset    109 50
    #offset    125 80
    frame    data/chars/misc/fight.gif
    delay    3
    offset    1 1
    @cmd    EnemyStart
    @cmd    killentity getlocalvar("self") #Suicide
    @cmd    DeControl 0 0
    @cmd    DeControl 1 0
    frame    data/chars/misc/empty.gif
    
anim    idle # Round 1
@script
    void self = getlocalvar("self");
    void win1 = getglobalvar("win1");
    void win2 = getglobalvar("win2");
    int PLAY = openborvariant("count_players");
    changeopenborvariant("nopause", 0); //No pausing at this moment
 
    if(frame==0){
//    setindexedvar("fightStarted", 0);
    setglobalvar("fightStarted", 0);
    //setindexedvar("PauseInLevel", 0);
    }

    if(frame==32){
      if(PLAY == 1 || PLAY == 2){
    if(win1 == 1 && win2 == 1){ // 1 win for fighter 1 and 1 win for fighter 2
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
    }if(win1 == 1 || win2 == 1){ // 1 win for either fighter 1 or fighter 2 from first round
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
    }
      }
 
    }

    if(frame==37){
//    setindexedvar("fightStarted", 1);
    setglobalvar("fightStarted", 1);
    changeopenborvariant("nopause", 0); //Let there be pause
    }
    if(frame == 37 && openborvariant("count_players") == 1){
    changelevelproperty("scrollspeed", 0);
    }
    @end_script
    delay    8
    offset    155 116
    @cmd    DirPlayer 0 1
    @cmd    DirPlayer 1 0
    @cmd    DeControl 0 1
    @cmd    DeControl 1 1
    frame    data/chars/misc/ronde/round1-0.gif
    frame    data/chars/misc/ronde/round1-1.gif
    frame    data/chars/misc/ronde/round1-2.gif
    frame    data/chars/misc/ronde/round1-3.gif
    frame    data/chars/misc/ronde/round1-4.gif
    delay    3
    sound    data/sounds/round.wav
    frame    data/chars/misc/ronde/round1-5.gif
    frame    data/chars/misc/ronde/round1-6.gif
    frame    data/chars/misc/ronde/round1-7.gif
    frame    data/chars/misc/ronde/round1-8.gif
    frame    data/chars/misc/ronde/round1-9.gif
    frame    data/chars/misc/ronde/round1-10.gif
    frame    data/chars/misc/ronde/round1-11.gif
    frame    data/chars/misc/ronde/round1-12.gif
    frame    data/chars/misc/ronde/round1-13.gif
    frame    data/chars/misc/ronde/round1-14.gif
    frame    data/chars/misc/ronde/round1-15.gif
    frame    data/chars/misc/ronde/round1-16.gif
    frame    data/chars/misc/ronde/round1-17.gif
    frame    data/chars/misc/ronde/round1-18.gif
    frame    data/chars/misc/ronde/round1-19.gif
    frame    data/chars/misc/ronde/round1-20.gif
    frame    data/chars/misc/ronde/round1-21.gif
    frame    data/chars/misc/ronde/round1-22.gif
    frame    data/chars/misc/ronde/round1-23.gif
    frame    data/chars/misc/ronde/round1-24.gif
    frame    data/chars/misc/ronde/round1-25.gif
    frame    data/chars/misc/ronde/round1-26.gif
    frame    data/chars/misc/ronde/round1-27.gif
    frame    data/chars/misc/ronde/round1-28.gif
    frame    data/chars/misc/ronde/round1-29.gif
    frame    data/chars/misc/ronde/round1-30.gif
    frame    data/chars/misc/ronde/round1-31.gif
    frame    data/chars/misc/ronde/round1-32.gif
    delay    218
    sound data/sounds/one.wav
    frame    data/chars/misc/ronde/round1-33.gif
    delay    4
    frame    data/chars/misc/empty.gif
    offset    1 1
    delay    1
    frame    data/chars/misc/empty.gif
    delay    110
    @cmd    DeControl 0 1
    @cmd    DeControl 1 1
    offset    109 50
    sound    data/sounds/fight.wav
    frame    data/chars/misc/fight.gif
    delay    3
    offset    1 1
    @cmd    EnemyStart
    @cmd    killentity getlocalvar("self") #Suicide
    @cmd    DeControl 0 0
    @cmd    DeControl 1 0
    frame    data/chars/misc/empty.gif
    
#|edited by openBor Stats v 0.67

maxman, I think that since you are already using referee to manage the match, why not let it manage the win counter also?
It's much simpler and you don't need to copy deathscript from one fighter text to other fighter's text.

As for unable to retain win count, did you reset Win1 and Win2 after/before the match begin?
And how am I gonna do that? How am I gonna identify which entity type will win? I just tried to add the win count in the second frame of the referee with this below, but two win counts appear from both sides and it skips to the third round.

Code:
  if(frame==1){
    void Lead = LeaderFind();
    int PLAY = openborvariant("count_players");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");

    if(PLAY == 1){

    if(win1 == NULL()){
        setglobalvar("win1", 1);
    }
    if(win1 == 1){
        setglobalvar("win1", 2);
    }

    if(win2 == NULL()){
        setglobalvar("win2", 1);
    }
    if(win2 == 1){
        setglobalvar("win2", 2);
    }

    }

    changeentityproperty(Lead, "velocity", 0, 0, 0);
    performattack(Lead, openborconstant("ANI_FOLLOW61"));
  }

I'm not sure if I reset them before or after the match. I have clearglobalvar which is meant for challenger callout for 2 players.

Anyway, I just fixed the player's side and it's all good. Now my only problem is the enemy's side for win2 for the first victory.

Code:
if(frame==1){
    void P1 = getplayerproperty(0, "entity"); // Calling player 1
    void P2 = getplayerproperty(1, "entity"); // Calling player 2
    void Opp1 = findtarget(P1); // Player 1's specific enemy
    void Opp2 = findtarget(P2); // Player 2's specific enemy
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    void Lead = LeaderFind();
    int PLAY = openborvariant("count_players");

    //int set = openborvariant("current_set"):

    if(PLAY == 1){

       if(win1 == NULL() && (P1 || P2) ){
        setglobalvar("win1", 1);
       }
       if(win1 == 1 && (P1 || P2) ){
        setglobalvar("win1", 2);
       }
       if(win2 == NULL() && (Opp1 || Opp2) ){
        setglobalvar("win2", 1);
       }
       if(win2 == 1 && (Opp1 || Opp2) ){
        setglobalvar("win2", 2);
       }
    }
 

    changeentityproperty(Lead, "velocity", 0, 0, 0);
    performattack(Lead, openborconstant("ANI_FOLLOW61"));
  }

EDIT: I forgot this update of this too.

Code:
void main(){
    void win = getglobalvar("win");
    int P1 = getplayerproperty(0, "entity"); // Player 1
    int P2 = getplayerproperty(1, "entity"); // Player 2
    void Opp1 = findtarget(P1); // Player 1's opponent
    void Opp2 = findtarget(P2); // Player 2's opponent
    void win1 = getglobalvar("win1"); // Win point for Player type in single player mode; player 1 in dual mode
    void win2 = getglobalvar("win2"); // Win point for Enemy type in single player mode; player 2 in dual mode
    int PLAY = openborvariant("count_players");
 
    if(!win){
        win = loadsprite("data/chars/misc/win.png");
        setglobalvar("win", win);
    }
 
    if(PLAY == 2){ // 2 players in dual mode
        if(win1 == 1){
            if(P1){ // Player 1
                drawsprite(win, 1, 25, 500);
            }
        }
        if(win1 == 2){
            if(P1){ // Player 1
                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);
            }
        }
        if(win2 == 1){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
            }
        }
        if(win2 == 2){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);
            }
        }
    }
 
    if(PLAY == 1){ // Single player only?
        if(win1 == 1){ // Fighter 1's single victory?
            if(P1){ // Player 1
                drawsprite(win, 142, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 174, 25, 500);
            }
        }if(win1 == 2){ // Fighter 1's double victory?
            if(P1){ // Player 1
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }
        }
     
        if(win2 == 1 && win1 == NULL()){ // Fighter 2's single victory?
            if(Opp1){
                drawsprite(win, 174, 25, 500);
            }if(Opp2){
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win2 == 2 && win1 == NULL()){ // Fighter 2's double victory?
            if(Opp1){
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(Opp2){
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
        /*if(Opp1){
            if(win2 == 1){
                drawsprite(win, 174, 25, 500);
            }
            if(win2 == 2){
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }
        }*/
     
        /*if(win1 == 1 && win2 == 1){ // Player wins 1 and Enemy wins 1
            if(P1 || Opp2){ // Player 1
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(P2 || Opp1){ // Player 2
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }*/
     
        if(win1 == 2 && win2 == 1){ // Player wins 2 and Enemy wins 1
            if(P1){ // Player 1
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win1 == 1 && win2 == 2){ // Player wins 1 and Enemy wins 2
            if(Opp2){ // Player 1
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(Opp1){ // Player 2
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
     
    }
}

Just found that this one with both declared player victory and enemy victory caused two win counts to appear in the first round after enemy wins.

Code:
if(win1 == 1 && win2 == 1){ // Player wins 1 and Enemy wins 1
            if(P1 || Opp2){ // Player 1
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(P2 || Opp1){ // Player 2
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }

So I just removed/excluded it. This time in the first round, player 1's opponent's win count is on the left side instead of being on the right side and it skips to the third round. If player 1 wins the first round, and the opponent wins the second, two win counts (plus one if player wins the first round so you see three there from all sides) from both sides appear but it skips to the third round instead of ending the battle.
 
Last edited:
And how am I gonna do that?

By using LeaderFind() function. This function returns fighter with highest health from 2 registered fighters. The winner obviously has more health than the loser.

How am I gonna identify which entity type will win?

If you could acquire winning entity, you could acquire its type, name etc ;).

There's also LeaderCode() function which could acquire code of winning side. If it's fighter 1, player 1 or enemy 1 (player 2's opponent), it will return 1. If it's fighter2, player 2 or enemy 2 (player 1's opponent), it will return 2.
With this acquired code, you can decide which Win variable to increment.
 
By using LeaderFind() function. This function returns fighter with highest health from 2 registered fighters. The winner obviously has more health than the loser.
The funny thing is every time I include that function, and the enemy 1 wins, the winner has two win counts from both player 1 and enemy 1 that appear from the first round. I'm still having a problem with the 3rd frame(s) which declares win points in player 1 mode.

Code:
anim    follow1
@script
void P1 = getplayerproperty(0, "entity"); // Calling player 1
void P2 = getplayerproperty(1, "entity"); // Calling player 2
void Opp1 = findtarget(P1); // Player 1's specific enemy
void Opp2 = findtarget(P2); // Player 2's specific enemy
int win1 = getglobalvar("win1");
int win2 = getglobalvar("win2");
int PLAY = openborvariant("count_players");
int set = openborvariant("current_set");
int Current = openborvariant("current_branch");
void Type;

if(frame==1){ // Declare winner!
  void Lead = LeaderFind();

  changeentityproperty(Lead, "velocity", 0, 0, 0);
  performattack(Lead, openborconstant("ANI_FOLLOW61"));
}


if(frame == 2 && PLAY == 1 && P1){ // Display win point
    if(win1 == NULL()){
        setglobalvar("win1", 1);
    }if(win1 == 1){
        setglobalvar("win1", 2);
    }
}

if(frame == 2 && Opp1){ // Display win point
    if(win2 == NULL()){
        setglobalvar("win2", 1);
    }if(win2 == 1){
        setglobalvar("win2", 2);
    }
}
@end_script
    delay    150
    offset    1 1
    @cmd setindexedvar "fightStarted" 0
    frame    data/chars/misc/empty.gif # 0
    delay    20
    frame    data/chars/misc/empty.gif # 1
    delay    100
    frame    data/chars/misc/empty.gif # 2
    delay 1000
    frame    data/chars/misc/empty.gif # 3
    frame    data/chars/misc/empty.gif # 4
    frame    data/chars/misc/empty.gif # 5

If you could acquire winning entity, you could acquire its type, name etc ;).

There's also LeaderCode() function which could acquire code of winning side. If it's fighter 1, player 1 or enemy 1 (player 2's opponent), it will return 1. If it's fighter2, player 2 or enemy 2 (player 1's opponent), it will return 2.
With this acquired code, you can decide which Win variable to increment.
Should I use localvar with its varname "player" with player property of "entity", if I want to make a referee to change type or to call which entity type wins according to a specific winner with specifc type (or name)? What I mean is that the referee is the one who will detect which type whether it's an enemy type or a player type to win. It probably could change its "none" type to whichever type. As well as summoning the portrait of each winner ("EnemyWin" for winning enemies and "Victory" for winning players)

Code:
if(frame == 3 && PLAY == 1 && set == 0){ // Single player Arcade style

  if(win2 == 2){ // Player's defeat and enemy's victory

    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
    int index = getlocalvar("player");
    void self = getplayerproperty(index, "entity");
      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(win1 == 2){ // Player's victory and enemy's defeat
      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

    int index = getlocalvar("player");
    void self = getplayerproperty(index, "entity");
      void target = findtarget(self); // Calling target.
      void name = getentityproperty(target, "name"); // Calling target's name.

      clearspawnentry(); //Clear current spawn entry.

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

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

      if(name == "Ken"){
          changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL"));
    }else if(name == "Chun-Li"){
        //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
          changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL2"));
      }else if(name == "Zangief"){
        //    changeentityproperty(vSpawn, "position", 160 + XPos, 120);
          changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL3"));
      }else{ // Defaultly switch to Ryu?
          changeentityproperty(vSpawn, "position", 160 + XPos, 120);
      }
      changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    clearglobalvar();
    setglobalvar("Wait", 1);
  } else {
        jumptobranch(Current,1);
  }
}

I have LeaderFind, but no LeaderCode at all. Do you have LeaderCode?

I have trouble with the win variable and it increments to 2 win variables on both sides, especially player 1's enemy winning to acquire player 1's own victory point.

Code:
if(PLAY == 1){ // Single player only?
        if(win1 == 1 && win2 == NULL()){ // Fighter 1's single victory?
            if(P1){ // Player 1
                drawsprite(win, 142, 25, 500);
            }else if(P2){ // Player 2
                drawsprite(win, 174, 25, 500);
            }
        }if(win1 == 2 && win2 == NULL()){ // Fighter 1's double victory?
            if(P1){ // Player 1
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
            }else if(P2){ // Player 2
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }
        }
        if(win2 == 1 && win1 == NULL()){ // Fighter 2's single victory?
            if(Opp1){
                drawsprite(win, 174, 25, 500);
            }else if(Opp2){
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win2 == 2 && win1 == NULL()){ // Fighter 2's double victory?
            if(Opp1){
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
            }else if(Opp2){
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win1 == 1 && win2 == 1){
            if(P1 || Opp2){ // Player 1
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }else if(Opp1 || P2){ // Player 2
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win1 == 2 && win2 == 1){
            if(P1){ // Player 1
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(P2){ // Player 2
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
        if(win1 == 1 && win2 == 2){
            if(Opp2){ // Player 2 enemy
                drawsprite(win, 127, 25, 500);
                drawsprite(win, 142, 25, 500);
                drawsprite(win, 174, 25, 500);
            }if(Opp1){ // Player 1 enemy
                drawsprite(win, 189, 25, 500);
                drawsprite(win, 174, 25, 500);
                drawsprite(win, 142, 25, 500);
            }
        }
    }
 
and the enemy 1 wins, the winner has two win counts from both player 1 and enemy 1 that appear from the first round.

You'd have to remove win increment script for fighter's DEATH animation. I never declared such script there that's why win count works normally here.

I'm still having a problem with the 3rd frame(s) which declares win points in player 1 mode.

What's the problem?

Should I use localvar with its varname "player" with player property of "entity", if I want to make a referee to change type or to call which entity type wins according to a specific winner with specifc type (or name)?

No need to do that,
C:
void Lead = LeaderFind();
 int LType = getentityproperty(Lead,"type");

This should be enough.

I have LeaderFind, but no LeaderCode at all. Do you have LeaderCode?

Oh I thought you have latest version of Versus demo, alright, here it is:
C:
void LeaderCode()
{//Finds fighter with highest health then gets his/her number
    void Lead = LeaderFind();
    void D1 = getglobalvar("F1");
    void D2 = getglobalvar("F2");

    if(Lead == D1){
      return 1;
    } else if(Lead == D2){
      return 2;
    } else {
      return 0;
    }
}

I have trouble with the win variable and it increments to 2 win variables on both sides, especially player 1's enemy winning to acquire player 1's own victory point.

Hmmm.... try removing or at least disabling win count increment script from both players and enemies text and let Referee do the win count.
 
Thank you so much Bloodbane! The Lead type helps! Despite successfully getting those win counts not being forced to skip to round 3, as well as calling type, this is the very same result like I acquired win points for both player and enemy entities because the enemy's first win point disappears after player knocks him/her out in the second round for the third round. It does not result having the enemy win 2 win points from both sides for round 3 in the first round, which is good. I need the player to acquire his/her win point while the enemy retains his/hers.

How about this? Player vs Enemy in 3 rounds. Let's conceptualize how rounds are set with A (player) and B (enemy) on victories/losses:

SET 1: Round 1: A wins; round 2: A wins; VICTORY
SET 2: Round 1: A wins; round 2: B wins; round 3: A wins; VICTORY
SET 3: Round 1: A wins; round 2: B wins; round 3: B wins; LOSS
SET 4: Round 1: B wins; round 2: B wins; LOSS
SET 5: Round 1: B wins; round 2: A wins; round 3: A wins; VICTORY
SET 6: Round 1: B wins; round 2: A wins; round 3: B wins; LOSS

Main problem for me is the middle of set 5 and/or 6.

What's the problem?

You'll see in the video which skips fast after winning or losing. It's from the referee entity. I'll switch back to the death animation script which works perfectly for displaying portraits.

P.S.: Wow! I cannot believe something happened while I was testing the win counts. I just encountered a Double KO for the first time! I think I have Ken's ondoattack script active but I don't know how to give damage to the attacked opponent. At least the attacked opponent remained winning despite getting knocked out.


EDIT: Every time I use LeaderCode, even though player or enemy wins, it crashes when it's about to display a win point.

Referee entity:
Code:
if(frame==1){ // Declare winner!
  void Lead = LeaderFind();

  changeentityproperty(Lead, "velocity", 0, 0, 0);
  performattack(Lead, openborconstant("ANI_FOLLOW61"));
}


if(frame == 2 && PLAY == 1){
    void Lead = LeaderCode();
    int LType = getentityproperty(Lead,"type");

    if(LType == openborconstant("TYPE_PLAYER")){
        if(win1 == 0){
            setglobalvar("win1", 1);
        }if(win1 == 1){
            setglobalvar("win1", 2);
        }
    }

    if(LType == openborconstant("TYPE_ENEMY")){
        if(win2 == 0){
            setglobalvar("win2", 1);
        }if(win2 == 1 && win1 == 0){
            setglobalvar("win2", 2);
        }
    }
}

With its win count:

Code:
        if(win1 == 1 && win2 == 0){
            if(P1){ // Player 1
                drawsprite(win, 142, 25, 500);
            }else if(P2){ // Player 2
                drawsprite(win, 174, 25, 500);
            }
        }

        if(win1 == 0 && win2 == 1){
            if(Opp2){ // Player 1
                drawsprite(win, 142, 25, 500);
            }else if(Opp1){ // Player 2
                drawsprite(win, 174, 25, 500);
            }
        }
 
Last edited:
Main problem for me is the middle of set 5 and/or 6.

I've contemplated this and realized that winning count may not actually disappear but instead it increments beyond accepted values.
For debugging phase, try replacing sprite display script with number display script which displays winning count in digital values. This would be useful to see if winning count exceeds limit or something else happens.

OTOH I noticed that your win icon display logic is too much and redundant. Your logic is something like : if this win combo occurs display win icons like this. You could miss one or more win combo this way.
I suggest changing the logic into this: at what condition win icon 1 appear? at what condition win icon 2 appear? and so on.

Every time I use LeaderCode, even though player or enemy wins, it crashes when it's about to display a win point.

What was the error message?
 
Thanks for suggesting the logic change, Bloodbane! The result of the number display script looks wonderful. I found out the real culprit for that problem is the input of the specific side(s) for players and opponents. The one without putting certain sides does work, but putting them makes one of the points disappear until player 1 is declared a winner in the 2nd round. For example, if you put it like this (without using certain entity type sides), it works:

Code:
if(win1 == 1 || win1 == 2){
                drawstring(33, 60, 3, win1);
            }

if(win2 == 1 || win2 == 2){
                drawstring(309, 60, 3, win2);
            }

This worked better before, but it resulted with only P1 and P2 on the left side and enemy opponent(s) on the right side. It used to work well before. Strange. I don't like when win1/fighter 1 is either player 1 or enemy 1 (player 2's enemy) because Leader Type win1 is already type player and LT win2 is type enemy in the referee text:

Code:
if(win1 == 1 || win1 == 2 && (P1 || Opp2)){
                drawstring(33, 60, 3, win1);
            }

if(win2 == 1 || win2 == 2 && (P2 || Opp1)){
                drawstring(309, 60, 3, win2);
            }

Referee:
Code:
if(frame == 2 && PLAY == 1){
    void Lead = LeaderFind();
    int LType = getentityproperty(Lead,"type");

    if(LType == openborconstant("TYPE_PLAYER")){
        if(win1 == NULL()){
            setglobalvar("win1", 1);
        }if(win1 == 1){
            setglobalvar("win1", 2);
        }
    }

    if(LType == openborconstant("TYPE_ENEMY")){
        if(win2 == NULL()){
            setglobalvar("win2", 1);
        }if(win2 == 1){
            setglobalvar("win2", 2);
        }
    }
}

If you put them like this here, it looks like it doesn't display (though there's incremented values) until winner is declared in the second round.

Code:
        if(Opp1){
            if(win2 == 1 || win2 == 2){
                drawstring(309, 60, 3, win2);
            }
        }
        if(Opp2){
            if(win2 == 1 || win2 == 2){
                drawstring(33, 60, 3, win2);
            }
        }
        if(P1){
            if(win1 == 1 || win1 == 2){
                drawstring(33, 60, 3, win1);
            }
        }
        if(P2){
            if(win1 == 1 || win1 == 2){
                drawstring(309, 60, 3, win1);
            }
        }

I'm trying to have P2 receive its win point on the right side and P1 on the left side, as well as their respective opponents on each of its opposite side, which difficult to do. Finding which condition for the win icon to appear is very tricky.

What was the error message?
It's way too long. Just a bunch of lines which say "openbor_loadsprite" and two lines of "openbor_array".


EDIT: I was trying this edit to see how the number display starting with 0, according to certain entity type, but the number disappears after player wins. For example, player 1 or 2 defeats its opponent with its first win (whether it's round 1 or 2), but it results its opponent's win point to disappear until next round.

Code:
        if(win1 == NULL() && P1){
            drawstring(33, 60, 3, 0);
        }
        if(win1 == NULL() && P2){
            drawstring(309, 60, 3, 0);
        }
        if((win1 == 1 || win1 == 2) && P1){
            drawstring(33, 60, 3, win1);
        }
        if((win1 == 1 || win1 == 2) && P2){
            drawstring(309, 60, 3, win1);
        }
        if(win2 == NULL() && Opp1){
            drawstring(309, 60, 3, 0);
        }
        if(win2 == NULL() && Opp2){
            drawstring(33, 60, 3, 0);
        }
        if((win2 == 1 || win2 == 2) && Opp1){
            drawstring(309, 60, 3, win2);
        }
        if((win2 == 1 || win2 == 2) && Opp2){
            drawstring(33, 60, 3, win2);
        }
 
Last edited:
@Bloodbane This one works well without having player check.

Attachment: Player 2 wins 2 points on the left side instead of right. That was a good start which I did it (over) a month ago, but I took this shot today. This one is without player index check.

C:
        if(win1 == 2){
            drawstring(43, 60, 3, win1);
            drawstring(33, 60, 3, 1);
        }
        if(win2 == 2){
            drawstring(299, 60, 3, win2);
            drawstring(309, 60, 3, 1);
        }
        if(win1 == 1){
            drawstring(33, 60, 3, win1);
        }
        if(win2 == 1){
            drawstring(309, 60, 3, win2);
        }
        if(win1 == NULL()){
            drawstring(33, 60, 3, 0);
        }
        if(win2 == NULL()){
            drawstring(309, 60, 3, 0);
        }

I have win1 declared for players and win2 for enemies but I don't know how I can change that for fitting player sides. Do I need to have player check on the "wins" as you suggested like player 1 and enemy 2 for win1, and player 2 and enemy 1 for win2? Look at win2 for the single player side. That's meant for the opponent to win.

C:
anim death
@script
    void self = getlocalvar("self");
    void Return = getglobalvar("Return");
    void Current = openborvariant("current_branch");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int COUNTPLAY = openborvariant("count_players");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int set = openborvariant("current_set");


    if(frame==8 && COUNTPLAY == 1 && set == 0){
      if(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"); // Load model.
    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);
    }

    //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    setglobalvar("Wait", 1);
      } else {
    jumptobranch(Current,1);
    //setglobalvar("Return", NULL());
      }
    }


    if(frame==8 && COUNTPLAY == 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.
    //setspawnentry("coords", 200, 180);

    //loadmodel("choicevs");
    //setspawnentry("name", "choicevs"); //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);
      }
    }



    if(frame==8 && COUNTPLAY == 2  && set == 0){
      if(win1 == 2 || win2 == 2){
    killentity(self);
    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);
    clearglobalvar();
      } else {
    //setglobalvar("Return", Current);
    jumptobranch(Current,1);
      }
    }

    @end_script 
    delay    100
    offset    336 292
    jumpframe 0 0.8 -1 0
    landframe    1
    custentity black-fade-out
    spawnframe 5 0 0 0 0
    frame    data/chars/ken/cvs2_ken_581.png # 0
    delay 7
    frame    data/chars/ken/cvs2_ken_582.png # 1 - 7
    frame    data/chars/ken/cvs2_ken_583.png # 2 - 14
    delay 100
    frame    data/chars/ken/cvs2_ken_584.png # 3 - 114
    frame    data/chars/ken/cvs2_ken_584.png # 4 - 214
    @cmd    fademusic 1 "data/music/silence.bor" 0
    frame    data/chars/ken/cvs2_ken_584.png # 5 - 314
    delay 10
    frame    data/chars/ken/cvs2_ken_584.png # 6 - 324
    delay 50
    frame    data/chars/ken/cvs2_ken_584.png # 7 - 375
    delay 40
    frame    data/chars/ken/cvs2_ken_584.png # 8 - 415# <== End
    delay 50
    frame    data/chars/ken/cvs2_ken_584.png # 9 - 465

EDIT: I forgot to mention that I added a 0 text when win is empty/null.

EDIT 2: The player wins the 2nd round but the points from both sides start to disappear until that player is declared a winner. The points reappear. It happens only if I have player check.
 

Attachments

  • My Mod - 0791.png
    My Mod - 0791.png
    31.1 KB · Views: 1
Last edited:
This one works well without having player check.

That's the point of storing win counter in global variable, so you don't need to check player or even entity type who owns the win counter.
Versus demo I've made before registers both fighters before match starts regardless of their type. Therefore player check or type check was never needed.

but I don't know how I can change that for fitting player sides

Just register player 2 as second fighter and the enemy opponent as first fighter. The wasit will do the counting.

I forgot to mention that I added a 0 text when win is empty/null.

You won't need to do that if you always reset win counters in main menu or title screen. You could do the reset every time level end if you want to.
 
Just register player 2 as second fighter and the enemy opponent as first fighter. The wasit will do the counting.
Player 2 as win2 and its opponent (Opponent/Enemy 2) as win1?

I should've mentioned that one with win2 from anim death above is from player, not enemy.

Enemy's anim death:

C:
anim    death
@script
    void self = getlocalvar("self");
    int win1 = getglobalvar("win1");
    //int win2 = getglobalvar("win2");
    int PLAY = openborvariant("count_players");
    void Current = openborvariant("current_branch");


    if(frame==8){
    if(win1 == 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 = findtarget(self); // Calling target.
    void name = getentityproperty(target, "name"); // Calling target's name.

    clearspawnentry(); //Clear current spawn entry.

    loadmodel("victory");
    setspawnentry("name", "victory"); //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 if(name == "Chun-Li"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL2"));
    }else if(name == "Zangief"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL3"));
    }else if(name == "Dhalsim"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL4"));
    }else if(name == "Guy"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL5"));
    }else if(name == "Joe"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL6"));
    }else if(name == "Eagle"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL7"));
    }else if(name == "Balrog"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL8"));
    }else if(name == "Bison" || name == "M._Bison"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL9"));
    }else if(name == "Guile"){
        //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL10"));
    }else if(name == "Vega"){
        //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL11"));
    }else{ // Defaultly switch to Ryu?
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    }
    changeentityproperty(vSpawn, "position", 160 + XPos, 120);
      //setglobalvar("Wait", 1);
      clearglobalvar();
      } else {
      jumptobranch(Current,1);
      }
    }
    @end_script    
    offset    49 40
    delay    30
    frame    data/chars/ryu/0504000010.gif # 0
    delay 40
    frame    data/chars/ryu/0504000010.gif # 1
    @cmd    spawnAni "WinLose" 160 120 240 "ANI_FOLLOW1" #"You Win" for players / Opponent's loss
    #delay 15
    frame    data/chars/ryu/0504000010.gif # 2
    frame    data/chars/ryu/0504000010.gif # 3
    frame    data/chars/ryu/0504000010.gif # 4
    frame    data/chars/ryu/0504000010.gif # 5
    frame    data/chars/ryu/0504000010.gif # 6
    delay 40
    frame    data/chars/ryu/0504000010.gif # 7
    delay    2000
    frame    data/chars/ryu/0504000010.gif # 8

If I want to call player 2 as second fighter, I guess I gotta change it with this for the opponent's death.

C:
if(win1 == 2 || win2 == 2)

I changed a new script for the referee in the 3rd frame under anim follow1, but my new problem is that when an opponent wins, s/he gets his points from both sides and that leads to Round 3 (if it's Round 1). Winning in round 2 after player wins in round 1, leads to losing with Continue screen.

C:
name        RefPlays
type        none
animationscript    data/scripts/wasitS.c
ondrawscript data/scripts/playerwin.c

anim    spawn
@script
  if(frame==1 && openborvariant("count_players")==1){ // Player vs enemy
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");

    if(P1){
      setglobalvar("F1", P1);
    } else if(P2){
      setglobalvar("F2", P2);
    }
  }

  if(frame>=1 && openborvariant("count_players")==2){ // Player vs player
    void P1 = getplayerproperty(0, "entity");
    void P2 = getplayerproperty(1, "entity");

    if(P1 && P2){
      void self = getlocalvar("self");
      setglobalvar("F1", P1);
      setglobalvar("F2", P2);

      changeentityproperty(P2, "direction", 0);
      setidle(self, openborconstant("ANI_IDLE"));
    }
  }
@end_script
    delay    2
    offset    1 1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

anim    idle
@script
  if(frame==1){
    void self = getlocalvar("self");
    int Habis = Desid();

    if(Habis==1){
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
  }
@end_script
    loop    1
    delay    2
    offset    1 1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

anim    follow1
@script
void P1 = getplayerproperty(0, "entity"); // Calling player 1
void P2 = getplayerproperty(1, "entity"); // Calling player 2
void Opp1 = findtarget(P1); // Player 1's specific enemy
void Opp2 = findtarget(P2); // Player 2's specific enemy
int win1 = getglobalvar("win1");
int win2 = getglobalvar("win2");
int PLAY = openborvariant("count_players");
int set = openborvariant("current_set");
int Current = openborvariant("current_branch");
void Type;

if(frame == 0){ // Freeze!
  void P1 = getplayerproperty(0, "entity"); // Calling player 1
  void P2 = getplayerproperty(1, "entity"); // Calling player 2
  void EnemP1 = findtarget(P1); // Player 1's specific enemy
  void EnemP2 = findtarget(P2); // Player 2's specific enemy
  int CountP = openborvariant("count_players");

  if(P1){ // Player 1?
      changeentityproperty(P1, "noaicontrol", 1); // Stop moving
  }
  if(P2){
      changeentityproperty(P2, "noaicontrol", 1); // Stop moving
  }
  if(EnemP1){ // Enemy of player 1?
      changeentityproperty(EnemP1, "noaicontrol", 1);
  }
  if(EnemP2){
      changeentityproperty(EnemP2, "noaicontrol", 1);
  }

  if(CountP == 1){
      changelevelproperty("scrollspeed", 0);
  }
}

if(frame==1){ // Declare winner!
  void Lead = LeaderFind();
  //void Lead = LeaderCode();

  changeentityproperty(Lead, "velocity", 0, 0, 0);
  performattack(Lead, openborconstant("ANI_FOLLOW61"));
}


if(frame == 2 && PLAY == 1){
    void Lead = LeaderFind();
    int LType = getentityproperty(Lead,"type");
    int P1 = getplayerproperty(0, "entity"); // Calling player 1
    int P2 = getplayerproperty(1, "entity"); // Calling player 2
    void Opp1 = findtarget(P1); // Player 1's specific enemy
    void Opp2 = findtarget(P2); // Player 2's specific enemy

    
    if(P1 || Opp2){
        if(win1 == NULL()){
            setglobalvar("win1", 1);
        }if(win1 == 1){
            setglobalvar("win1", 2);
        }
    }

    if(P2 || Opp1){
        if(win2 == NULL()){
            setglobalvar("win2", 1);
        }if(win2 == 1){
            setglobalvar("win2", 2);
        }
    }
    
}

@end_script
    delay    150
    offset    1 1
    @cmd setindexedvar "fightStarted" 0
    frame    data/chars/misc/empty.gif # 0
    delay    20
    frame    data/chars/misc/empty.gif # 1
    delay    100
    frame    data/chars/misc/empty.gif # 2
    delay 1000
    frame    data/chars/misc/empty.gif # 3
    frame    data/chars/misc/empty.gif # 4
    frame    data/chars/misc/empty.gif # 5

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


    if(frame==8 && COUNTPLAY == 1 && set == 0){
      if(win2 == 2 || win1 == 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"); // Load model.
    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);
    }

    //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    setglobalvar("Wait", 1);
      } else {
    jumptobranch(Current,1);
    //setglobalvar("Return", NULL());
      }
    }


    if(frame==8 && COUNTPLAY == 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.
    //setspawnentry("coords", 200, 180);

    //loadmodel("choicevs");
    //setspawnentry("name", "choicevs"); //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);
      }
    }



    if(frame==8 && COUNTPLAY == 2  && set == 0){
      if(win1 == 2 || win2 == 2){
    killentity(self);
    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);
    clearglobalvar();
      } else {
    //setglobalvar("Return", Current);
    jumptobranch(Current,1);
      }
    }

    @end_script    
    delay    100
    offset    336 292
    jumpframe 0 0.8 -1 0
    landframe    1
    #custentity black-fade-out
    #spawnframe 5 0 0 0 0
    frame    data/chars/ken/cvs2_ken_581.png # 0
    delay 7
    frame    data/chars/ken/cvs2_ken_582.png # 1 - 7
    frame    data/chars/ken/cvs2_ken_583.png # 2 - 14
    delay 100
    frame    data/chars/ken/cvs2_ken_584.png # 3 - 114
    frame    data/chars/ken/cvs2_ken_584.png # 4 - 214
    #@cmd    fademusic 1 "data/music/silence.bor" 0
    frame    data/chars/ken/cvs2_ken_584.png # 5 - 314
    delay 10
    frame    data/chars/ken/cvs2_ken_584.png # 6 - 324
    delay 50
    frame    data/chars/ken/cvs2_ken_584.png # 7 - 375
    delay 40
    frame    data/chars/ken/cvs2_ken_584.png # 8 - 415# <== End
    delay 50
    frame    data/chars/ken/cvs2_ken_584.png # 9 - 465

Referee script (PlayerWin.c):
C:
void main(){
    void win = getglobalvar("win");
    int P1 = getplayerproperty(0, "entity"); // Player 1
    int P2 = getplayerproperty(1, "entity"); // Player 2
    void Opp1 = findtarget(P1); // Player 1's opponent
    void Opp2 = findtarget(P2); // Player 2's opponent
    void win1 = getglobalvar("win1"); // Win point for Player type in single player mode; player 1 in dual mode
    void win2 = getglobalvar("win2"); // Win point for Enemy type in single player mode; player 2 in dual mode
    int PLAY = openborvariant("count_players");
    void none = getglobalvar("none");
    void player1 = openborvariant("player1");
    void player2 = openborvariant("player2");
    //log("\nOpp1" + "\nOpp2");
    
    if(!win){
        win = loadsprite("data/chars/misc/win.png");
        setglobalvar("win", win);
    }
    
    if(!none){
        none = loadsprite("data/chars/misc/empty.gif");
        setglobalvar("none", none);
    }
    
    
    if(PLAY == 2){ // 2 players in dual mode
        if(win1 == 1){
            if(P1){ // Player 1
                drawsprite(win, 1, 25, 500);
            }
        }if(win2 == 1){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
            }
        }if(win1 == 2){
            if(P1){ // Player 1
                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);
            }
        }if(win2 == 2){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);
            }
        }if(win1 == 2 && win2 == 1){
            if(P1){ // Player 1
                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);
                drawsprite(win, 309, 25, 500);
            }
        }if(win2 == 2 && win1 == 1){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);
                drawsprite(win, 1, 25, 500);
            }
        }
    }
    
    if(PLAY == 1){ // Single player only?
        if(win1 == 1 || win1 == 2){
            drawstring(33, 60, 3, win1);
        }
        if(win2 == 1 || win2 == 2){
            drawstring(309, 60, 3, win2);
        }
        if(win1 == NULL()){
            drawstring(33, 60, 3, 0);
        }
        if(win2 == NULL()){
            drawstring(309, 60, 3, 0);
        }        
     
    }
}
 
Mmm.... are you mixing win script from Joust mode with versus demo?
If you do, you'd get conflicting issues mostly in win counting and winner announcement department.

Before we continue our discussion further, you'd need to decide which script system you'll be using. Joust mode uses old win script cause I had assumption that Joust will always be PvE. That's why it's simpler however it's not expandable for PvP nor EvE.
Versus demo uses newest win script cause it is designed for PvE, PvP and EvE. It's more complex but it's compatible for those 3 modes.
So once again, which script system are you using? the one I've coded for Joust or the one I've coded in versus demo?
 
I just figured out how the logic of the script system goes for retaining the win count and found out which script system I can use. First off, Bloodbane suggested I'd assign fighter 1 as player 1 or enemy 1 (player 2's opponent; which I call enemy 1 as "enemy 2" for being player 2's opponent) and fighter 2 as player 2 or enemy 2, which I didn't like to do until I did it at the last moment. Second, he also suggested me to debug it with numbers instead of sprites for count testing, which turns out nice and simple to do. The digital values did help a lot! Third, I realized I don't need to have player check for detecting the win counts. Sadly, LeaderCode doesn't work and it crashes, but LeaderFind is quite useful.

After getting the digital values done with what I wanted, I put the sprites back to where they were, but with new scripts, and now it's working properly! Now I know why enemy won points on both sides. That's because I didn't put entity type check on specified entities (players and findtargets) in the third frame of anim follow from the referee entity. I fixed the referee entity with type check.

C:
anim    follow1
@script
void P1 = getplayerproperty(0, "entity"); // Calling player 1
void P2 = getplayerproperty(1, "entity"); // Calling player 2
void Opp1 = findtarget(P1); // Player 1's specific enemy
void Opp2 = findtarget(P2); // Player 2's specific enemy
int win1 = getglobalvar("win1");
int win2 = getglobalvar("win2");

int PLAY = openborvariant("count_players");
int set = openborvariant("current_set");
int Current = openborvariant("current_branch");
void Type;

if(frame == 0){ // Freeze!
  void P1 = getplayerproperty(0, "entity"); // Calling player 1
  void P2 = getplayerproperty(1, "entity"); // Calling player 2
  void EnemP1 = findtarget(P1); // Player 1's specific enemy
  void EnemP2 = findtarget(P2); // Player 2's specific enemy
  int CountP = openborvariant("count_players");

  if(P1){ // Player 1?
      changeentityproperty(P1, "noaicontrol", 1); // Stop moving
  }
  if(P2){
      changeentityproperty(P2, "noaicontrol", 1); // Stop moving
  }
  if(EnemP1){ // Enemy of player 1?
      changeentityproperty(EnemP1, "noaicontrol", 1);
  }
  if(EnemP2){
      changeentityproperty(EnemP2, "noaicontrol", 1);
  }

  if(CountP == 1){
      changelevelproperty("scrollspeed", 0);
  }
}

if(frame==1){ // Declare winner!
  void Lead = LeaderFind();
  //void Lead = LeaderCode();

  changeentityproperty(Lead, "velocity", 0, 0, 0);
  performattack(Lead, openborconstant("ANI_FOLLOW61"));
}


if(frame == 2 && PLAY == 1){
    void Lead = LeaderFind();
    int LType = getentityproperty(Lead,"type");
    int P1 = getplayerproperty(0, "entity"); // Calling player 1
    int P2 = getplayerproperty(1, "entity"); // Calling player 2
    void Opp1 = findtarget(P1); // Player 1's specific enemy
    void Opp2 = findtarget(P2); // Player 2's specific enemy

    if(LType == openborconstant("TYPE_PLAYER")){

        if(P1){
            if(win1 == NULL()){
                setglobalvar("win1", 1);
            }if(win1 == 1){
                setglobalvar("win1", 2);
            }
        }
   
        if(P2){
            if(win2 == NULL()){
                setglobalvar("win2", 1);
            }if(win2 == 1){
                setglobalvar("win2", 2);
            }
        }

    }

    if(LType == openborconstant("TYPE_ENEMY")){

        if(Opp1){
            if(win2 == NULL()){
                setglobalvar("win2", 1);
            }if(win2 == 1){
                setglobalvar("win2", 2);
            }
        }

        if(Opp2){
            if(win1 == NULL()){
                setglobalvar("win1", 1);
            }if(win1 == 1){
                setglobalvar("win1", 2);
            }
        }

    }

}

@end_script
    delay    150
    offset    1 1
    @cmd setindexedvar "fightStarted" 0
    frame    data/chars/misc/empty.gif # 0
    delay    20
    frame    data/chars/misc/empty.gif # 1
    delay    100
    frame    data/chars/misc/empty.gif # 2
    delay 1000
    frame    data/chars/misc/empty.gif # 3
    frame    data/chars/misc/empty.gif # 4
    frame    data/chars/misc/empty.gif # 5

With certain type in check on specified types of entities, I'm able to get the points properly. I changed from numbers that work well...

C:
        if(win1 == 1 || win1 == 2){ // player 1
            drawstring(33, 60, 3, win1);
        }
        if(win2 == 1 || win2 == 2){ // player 2
            drawstring(309, 60, 3, win2);
        }
        if(win1 == NULL()){
            drawstring(33, 60, 3, 0);
        }
        if(win2 == NULL()){
            drawstring(309, 60, 3, 0);
        }

To this one with sprites which now I'm reverting.

C:
void main(){
    void win = getglobalvar("win");
    int P1 = getplayerproperty(0, "entity"); // Player 1
    int P2 = getplayerproperty(1, "entity"); // Player 2
    void Opp1 = findtarget(P1); // Player 1's opponent
    void Opp2 = findtarget(P2); // Player 2's opponent
    void win1 = getglobalvar("win1"); // Win point for Player type in single player mode; player 1 in dual mode
    void win2 = getglobalvar("win2"); // Win point for Enemy type in single player mode; player 2 in dual mode
    int PLAY = openborvariant("count_players");

   
    if(!win){
        win = loadsprite("data/chars/misc/win.png");
        setglobalvar("win", win);
    }
    
   
    if(PLAY == 2){ // 2 players in dual mode
        if(win1 == 1){
            if(P1){ // Player 1
                drawsprite(win, 1, 25, 500);
            }
        }if(win2 == 1){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
            }
        }if(win1 == 2){
            if(P1){ // Player 1
                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);
            }
        }if(win2 == 2){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);
            }
        }if(win1 == 2 && win2 == 1){
            if(P1){ // Player 1
                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);
                drawsprite(win, 309, 25, 500);
            }
        }if(win2 == 2 && win1 == 1){
            if(P2){ // Player 2
                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);
                drawsprite(win, 1, 25, 500);
            }
        }
    }
   
    if(PLAY == 1){ // Single player only?
       
        if(win1 == 1){
            drawsprite(win, 142, 25, 500);
        }
        if(win1 == 2){
            drawsprite(win, 142, 25, 500);
            drawsprite(win, 127, 25, 500);
        }
        if(win2 == 1){
            drawsprite(win, 174, 25, 500);
        }
        if(win2 == 2){
            drawsprite(win, 174, 25, 500);
            drawsprite(win, 189, 25, 500);
        }
    }
}

I already assigned player type entity as win1 and win2, the same goes for the enemy type, to check which fighter they are.

Player's death anim check:
C:
anim death
@script
    void self = getlocalvar("self");
    void Return = getglobalvar("Return");
    void Current = openborvariant("current_branch");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int COUNTPLAY = openborvariant("count_players");
    int set = openborvariant("current_set");


    if(frame==8 && COUNTPLAY == 1 && set == 0){
      if(win2 == 2 || win1 == 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"); // Load model.
    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);
    }

    //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    setglobalvar("Wait", 1);
      } else {
    jumptobranch(Current,1);
    //setglobalvar("Return", NULL());
      }
    }


    if(frame==8 && COUNTPLAY == 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.
    //setspawnentry("coords", 200, 180);

    //loadmodel("choicevs");
    //setspawnentry("name", "choicevs"); //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);
      }
    }



    if(frame==8 && COUNTPLAY == 2  && set == 0){
      if(win1 == 2 || win2 == 2){
    killentity(self);
    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);
    clearglobalvar();
      } else {
    //setglobalvar("Return", Current);
    jumptobranch(Current,1);
      }
    }

    @end_script   
    delay    100
    offset    336 292
    jumpframe 0 0.8 -1 0
    landframe    1
    frame    data/chars/ken/cvs2_ken_581.png # 0
    delay 7
    frame    data/chars/ken/cvs2_ken_582.png # 1 - 7
    frame    data/chars/ken/cvs2_ken_583.png # 2 - 14
    delay 100
    frame    data/chars/ken/cvs2_ken_584.png # 3 - 114
    frame    data/chars/ken/cvs2_ken_584.png # 4 - 214
    frame    data/chars/ken/cvs2_ken_584.png # 5 - 314
    delay 10
    frame    data/chars/ken/cvs2_ken_584.png # 6 - 324
    delay 50
    frame    data/chars/ken/cvs2_ken_584.png # 7 - 375
    delay 40
    frame    data/chars/ken/cvs2_ken_584.png # 8 - 415# <== End
    delay 50
    frame    data/chars/ken/cvs2_ken_584.png # 9 - 465

Enemy's death anim type check:
C:
anim    death
@script
    void self = getlocalvar("self");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int PLAY = openborvariant("count_players");
    void Current = openborvariant("current_branch");

    if(frame==8){
    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 = findtarget(self); // Calling target.
    void name = getentityproperty(target, "name"); // Calling target's name.

    clearspawnentry(); //Clear current spawn entry.

    loadmodel("victory");
    setspawnentry("name", "victory"); //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 if(name == "Chun-Li"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL2"));
    }else if(name == "Zangief"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL3"));
    }else if(name == "Dhalsim"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL4"));
    }else if(name == "Guy"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL5"));
    }else if(name == "Joe"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL6"));
    }else if(name == "Eagle"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL7"));
    }else if(name == "Balrog"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL8"));
    }else if(name == "Bison" || name == "M._Bison"){
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL9"));
    }else if(name == "Guile"){
        //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL10"));
    }else if(name == "Vega"){
        //changeentityproperty(vSpawn, "position", 160 + XPos, 120);
        changeentityproperty(vSpawn, "animation", openborconstant("ANI_FREESPECIAL11"));
    }else{ // Defaultly switch to Ryu?
        changeentityproperty(vSpawn, "position", 160 + XPos, 120);
    }
    changeentityproperty(vSpawn, "position", 160 + XPos, 120);
      //setglobalvar("Wait", 1);
      clearglobalvar();
      } else {
      jumptobranch(Current,1);
      }
    }
    @end_script   
    offset    49 40
    delay    30
    frame    data/chars/ryu/0504000010.gif # 0
    delay 40
    frame    data/chars/ryu/0504000010.gif # 1
    @cmd    spawnAni "WinLose" 160 120 240 "ANI_FOLLOW1" #"You Win" for players / Opponent's loss
    #delay 15
    frame    data/chars/ryu/0504000010.gif # 2
    frame    data/chars/ryu/0504000010.gif # 3
    frame    data/chars/ryu/0504000010.gif # 4
    frame    data/chars/ryu/0504000010.gif # 5
    frame    data/chars/ryu/0504000010.gif # 6
    delay 40
    frame    data/chars/ryu/0504000010.gif # 7
    delay    2000
    frame    data/chars/ryu/0504000010.gif # 8

@Bloodbane I was referencing the win count system with OX entity which was from the joust level before. Now I no longer use an OX-like entity for win counts, but the ondrawscript I have for win count is based on that, which I'm using it for the referee. I cannot say I'm mixing both scripts from joust mode with versus demo.

C:
name Rounds
type panel
subject_to_gravity 0
shadow 0
facing 1
noquake 1 1
speed 0
setlayer 10000
load black-fade-in

animationscript    data/scripts/sceneFX.c
onspawnscript data/chars/misc/rounds/rondspwn.c

anim spawn
@script
void self = getlocalvar("self");
void P1 = getplayerproperty(0, "entity");
void P2 = getplayerproperty(1, "entity");
int maxhp1 = getentityproperty(P1, "maxhealth");
int maxhp2 = getentityproperty(P2, "maxhealth");
int PLAY = openborvariant("count_players");
int win1 = getglobalvar("win1");
int win2 = getglobalvar("win2");


if(P1){
    changeentityproperty(P1, "health", maxhp1);
}

if(P2){
    changeentityproperty(P2, "health", maxhp2);
}

if(frame == 1){
    if(PLAY == 1 ||PLAY == 2){
        if(win1 == 1 && win2 == 1){ // 1 win for fighter 1 and 1 win for fighter 2
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2")); // Round 3
        }if(win1 == 1 || win2 == 1){ // 1 win for either fighter 1 or fighter 2 from first round
            changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1")); // Round 2
        }
    }

}
@end_script
delay 2
offset 1 1
spawnframe 0 0 500 0 1
custentity black-fade-in
@cmd setindexedvar "fightStarted" 0
@cmd DeControl 0 1
@cmd DeControl 1 1
frame none
frame none

anim idle # Round 1
delay 90
offset 192 64
sound    data/sounds/round.wav
drawmethod scale 0.62 0.62
frame data/chars/misc/rounds/round_1.png
delay 150
sound    data/sounds/one.wav
frame data/chars/misc/rounds/round_1.png
delay 52
#frame data/chars/misc/empty.gif
@cmd changeentityproperty getlocalvar("self") "shadowbase" 0
frame none
delay 110
sound    data/sounds/fight.wav
frame data/chars/misc/rounds/fight.png
    delay    3
    offset    1 1
    @cmd    EnemyStart
    @cmd    suicide
    @cmd    DeControl 0 0
    @cmd    DeControl 1 0
    @cmd    setindexedvar "fightStarted" 1
frame data/chars/misc/rounds/fight.png

anim follow1 # Round 2
delay 90
offset 192 64
drawmethod scale 0.62 0.62
sound    data/sounds/round.wav
frame data/chars/misc/rounds/round_2.png
delay 150
sound    data/sounds/two.wav
frame data/chars/misc/rounds/round_2.png
delay 52
#frame data/chars/misc/empty.gif
frame none
delay 110
sound    data/sounds/fight.wav
frame data/chars/misc/rounds/fight.png
    delay    3
    offset    1 1
    @cmd    EnemyStart
    @cmd    suicide
    @cmd    DeControl 0 0
    @cmd    DeControl 1 0
    @cmd    setindexedvar "fightStarted" 1
frame data/chars/misc/rounds/fight.png

anim follow2 # Round 3
delay 90
offset 192 64
sound    data/sounds/round.wav
drawmethod scale 0.62 0.62
frame data/chars/misc/rounds/round_3.png
delay 150
sound    data/sounds/three.wav
frame data/chars/misc/rounds/round_3.png
delay 52
#frame data/chars/misc/empty.gif
frame none
delay 110
sound    data/sounds/fight.wav
frame data/chars/misc/rounds/fight.png
    delay    3
    offset    1 1
    @cmd    EnemyStart
    @cmd    suicide
    @cmd    DeControl 0 0
    @cmd    DeControl 1 0
    @cmd    setindexedvar "fightStarted" 1
frame data/chars/misc/rounds/fight.png

Thanks for the big help, Bloodbane!✌️😁 Your suggestions did help a lot! Problem solved! ;)
 
Last edited:
Back
Top Bottom