Solved Timer Doesn't Stop Running After Enemy Health is Zero

Question that is answered or resolved.

maxman

Well-known member
I have a problem with knocking out an opponent with player type entity in 1 player mode. I have a script which calls out certain opponent's health to 0 and it's supposed to stop the timer. However, it doesn't play the same way as 2 players. Pay attention to the opponent's health number. When players die, it becomes true for the timer to stop running. When enemies die, it becomes false. How can I stop the timer from running after knocking him/her out?

timer.txt:
C:
name Timer
type obstacle
health 60
speed 10
nomove     1 1
stealth      350
antigravity   100
subject_to_wall   0
subject_to_minz 0
#offscreenkill   3000
nodrop      2
defense    normal9 0 2000 #defense {type} {factor} {pain} {knockdown} {blockpower} {blockthreshold} {blockratio} {blocktype}
ondrawscript data/scripts/timer.c
#animationscript data/scripts/scenefx.c
#animationscript    data/scripts/wasitS.c
animationscript data/scripts/special.c
#diesound data/sounds/timeover.wav

anim spawn
delay 463
offset 1 1
frame data/chars/misc/empty.gif

#anim respawn
#delay 463
#offset 1 1
#frame data/chars/misc/empty.gif

anim idle
@script
    void self = getlocalvar("self");
    int Health = getentityproperty(self, "health");
    int P1 = getplayerproperty(0, "entity"); // Player 1
    int P2 = getplayerproperty(1, "entity"); // Player 2
    void T1 = findtarget(P1); // Enemy 1
    void T2 = findtarget(P2); // Enemy 2

    int HP1 = getentityproperty(P1, "health");
    int HP2 = getentityproperty(P2, "health");

    int THP1 = getentityproperty(T1, "health");
    int THP2 = getentityproperty(T2, "health");

    void TAni1 = getentityproperty(T1, "animationid");
    void TAni2 = getentityproperty(T2, "animationid");

    int CountP = openborvariant("count_players");

    if(HP1 <= 0 || HP2 <= 0 || THP1 <= 0 || THP2 <= 0){ // Who loses first before time runs out?
    performattack(self, openborconstant("ANI_FOLLOW1")); // Does the timer stop running?
    }

    if(HP1 <= 0 && HP2 <= 0){ // Both fighters (player 1 and 2) lose their respective health?
    performattack(self, openborconstant("ANI_DIE")); // Does the timer detect a draw according to both players' health meters
    }

    if(CountP == 1){

    if(HP1 <= 0 && THP1 <= 0){ // Both fighters (player 1 and enemy 1) lose their respective health?
        performattack(self, openborconstant("ANI_DIE"));
    }

    else if(HP2 <= 0 && THP2 <= 0){ // Both fighters (player 2 and enemy 2) lose their respective health?
        performattack(self, openborconstant("ANI_DIE"));
    }

    else if(HP1 <= 0 || HP2 <= 0){ // Who loses first before time runs out?
        performattack(self, openborconstant("ANI_FOLLOW1")); // Does the timer stop running?
    }

    else if(THP1 <= 0 || THP2 <= 0){ // Who loses first before time runs out?
        performattack(self, openborconstant("ANI_FOLLOW1")); // Does the timer stop running?
    }

    }

    if(frame==1){
      changeentityproperty(self, "health", Health-1);

      if (Health <= 0){
    performattack(self, openborconstant("ANI_DIE"));
      }
    }
@end_script
   loop   1 1
   delay   1
   offset   1 1
   frame   data/chars/misc/empty.gif
   delay   105
   frame   data/chars/misc/empty.gif
   delay   1
   frame   data/chars/misc/empty.gif

anim follow1 #Stop running timer
   loop   1
   delay   5
   offset   1 1
   frame   data/chars/misc/empty.gif
   frame   data/chars/misc/empty.gif

anim follow2 #Save room for setting it as no timer
   loop   1
   delay   5
   offset   1 1
   frame   data/chars/misc/empty.gif
   frame   data/chars/misc/empty.gif


anim death # Time Out
@script
if(frame == 0){
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void T1 = findtarget(P1);
    void T2 = findtarget(P2);
    //void T1 = getentityproperty(P1, "opponent");
    //void T2 = getentityproperty(P2, "opponent");

    int p1y = getentityproperty(P1, "y");
    int p1base = getentityproperty(P1, "base");
    int p2y = getentityproperty(P2, "y");
    int p2base = getentityproperty(P2, "base");

    int T1y = getentityproperty(T1, "y");
    int T1base = getentityproperty(T1, "base");
    int T2y = getentityproperty(T2, "y");
    int T2base = getentityproperty(T2, "base");

    void P1ani = getentityproperty(P1, "animationid");
    void P2ani = getentityproperty(P2, "animationid");
    void T1ani = getentityproperty(T1, "animationid");
    void T2ani = getentityproperty(T2, "animationid");

    void P1atk = getentityproperty(P1, "attacking");
    void P2atk = getentityproperty(P2, "attacking");
    void T1atk = getentityproperty(T1, "attacking");
    void T2atk = getentityproperty(T2, "attacking");

    changeopenborvariant("lasthitc", 0);

    if(P1){
        changeentityproperty(P1, "noaicontrol", 1);
    }

    if(P2){
        changeentityproperty(P2, "noaicontrol", 1);
    }

    if(T1){
        changeentityproperty(T1, "noaicontrol", 1);
    }

    if(T2){
        changeentityproperty(T2, "noaicontrol", 1);
    }

    if(P1atk == NULL() && p1y == p1base || P1ani == openborconstant("ANI_WALK") || P1ani == openborconstant("ANI_BACKWALK") ){
    changeentityproperty(P1, "velocity", 0, 0, 0);
    changeentityproperty(P1, "noaicontrol", 1);
    changeentityproperty(P1, "animation", openborconstant("ANI_IDLE"));
    }
    if(p2y == p2base || P2ani == openborconstant("ANI_WALK") || P2ani == openborconstant("ANI_BACKWALK") ){
    //changeentityproperty(P2, "velocity", 0, 0, 0);
    changeentityproperty(P2, "noaicontrol", 1);
    changeentityproperty(P2, "animation", openborconstant("ANI_IDLE"));
    }

    if(P1atk != NULL() && p1y == p1base){
    changeentityproperty(P1, "velocity", 0, 0, 0);
    }

    if(P1atk != NULL() && p1base){
    changeentityproperty(P1, "velocity", 0, 0, 0);
    }

}
if(frame == 1){

    void self = getlocalvar("self");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int HP1 = getentityproperty(P1, "health");
    int HP2 = getentityproperty(P2, "health");

    void target = findtarget(P1);
    void target2 = findtarget(P2);
    //void target = getentityproperty(P1, "opponent");
    //void target2 = getentityproperty(P2, "opponent");
   
    int THP1 = getentityproperty(target, "health");
    int THP2 = getentityproperty(target2, "health");
    int CountP = openborvariant("count_players");

    //void subent;

    if(CountP == 2){
        if(HP1 > HP2){ // Player 1 wins and player 2 loses?
            performattack(P1, openborconstant("ANI_FOLLOW61"));
            performattack(P2, openborconstant("ANI_FOLLOW15"));
        }
        if(HP1 == HP2){ // Draw?
            //subent = spawn();
            //clearspawnentry();
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(P2, openborconstant("ANI_FOLLOW15"));
        }if(HP1 < HP2){ // Player 2 wins?
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(P2, openborconstant("ANI_FOLLOW61"));
        }
    }

    if(CountP == 1){
        if(HP1 > THP1){
            performattack(P1, openborconstant("ANI_FOLLOW61"));
            performattack(target, openborconstant("ANI_FOLLOW15"));
        }
        else if(HP1 == THP1){
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(target, openborconstant("ANI_FOLLOW15"));
        }else if(HP1 < THP1){
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(target, openborconstant("ANI_FOLLOW61"));
        }

        else if(HP2 > THP2){
            performattack(P2, openborconstant("ANI_FOLLOW61"));
            performattack(target2, openborconstant("ANI_FOLLOW15"));
        }
        else if(HP2 == THP2){
            performattack(P2, openborconstant("ANI_FOLLOW15"));
            performattack(target2, openborconstant("ANI_FOLLOW15"));
        }else if(HP2 < THP2){
            performattack(P2, openborconstant("ANI_FOLLOW15"));
            performattack(target2, openborconstant("ANI_FOLLOW61"));
        }
    }

}

@end_script
   delay   200
   offset   1 1
   @cmd setindexedvar "fightStarted" 0
    @cmd    DeControl 0 1
    @cmd    DeControl 1 1
   sound data/sounds/SND_COM2_8.wav
   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
 
Last edited:
Solution
maxman, there's a reason why I made special referee entity to determine win/lose/draw. This entity (usually named Wasit) uses its IDLE to check which fighter has their HP dropped to 0. This IDLE has only 2 centisecond delay making it very responsive. This Wasit is independent from timer.
You use timer as referee which has its own delay to suit its duty as timer which makes it less responsive.
I've said before and I'll say it again, you should use wasit entity to determine match winner :) .

As for your issue, have you confirmed that the timer does acquire the enemy opponent?
Code:
    void T1 = findtarget(P1); // Enemy 1
    void T2 = findtarget(P2); // Enemy 2

if T1 is empty, any related scripts would produce empty result also...
maxman, there's a reason why I made special referee entity to determine win/lose/draw. This entity (usually named Wasit) uses its IDLE to check which fighter has their HP dropped to 0. This IDLE has only 2 centisecond delay making it very responsive. This Wasit is independent from timer.
You use timer as referee which has its own delay to suit its duty as timer which makes it less responsive.
I've said before and I'll say it again, you should use wasit entity to determine match winner :) .

As for your issue, have you confirmed that the timer does acquire the enemy opponent?
Code:
    void T1 = findtarget(P1); // Enemy 1
    void T2 = findtarget(P2); // Enemy 2

if T1 is empty, any related scripts would produce empty result also and thus could prevent timer from getting death status of enemy 1. Same goes with enemy 2 with T2.
 
Solution
You use timer as referee which has its own delay to suit its duty as timer which makes it less responsive.
I've said before and I'll say it again, you should use wasit entity to determine match winner :) .
I copied the timer scripts and transferred/pasted to the main wasit entity and the player win ondraw, but the result becomes very odd for 1-player mode because when it's time out, it repeats back to Round 1 after player loses.

C:
anim    follow15
@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;
        int XPos = openborvariant("xpos");
        int YPos = openborvariant("ypos");
        int Screen = openborvariant("hResolution");

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

    clearspawnentry();

    loadmodel("enemywin");
    setspawnentry("name", "enemywin");

    vSpawn = spawn();

    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;
        int XPos = openborvariant("xpos");
        int YPos = openborvariant("ypos");
        int Screen = openborvariant("hResolution");

    clearspawnentry();
    loadmodel("darkblue");
    setspawnentry("name", "darkblue");

    vSpawn = spawn();

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

    if(frame==5 && PLAY == 2  && set > 0){
      if( (win1 == 2 || win2 == 2) || (win1 == 2 && win2 == 2) ){
    void vSpawn;
        int XPos = openborvariant("xpos");
        int YPos = openborvariant("ypos");
        int Screen = openborvariant("hResolution");

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

    clearspawnentry();
    loadmodel("darkblue");
    setspawnentry("name", "darkblue");

    vSpawn = spawn();

    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
    frame    data/chars/ryu/0017000000.gif
    offset    23 107
    frame    data/chars/ryu/0017000001.gif
    frame    data/chars/ryu/0017000002.gif
    offset    23 108
    frame    data/chars/ryu/0017000003.gif
    offset    23 109
    delay    300
    frame    data/chars/ryu/0017000004.gif
    delay    84
    frame    data/chars/ryu/0017000004.gif
    delay    5
    frame    data/chars/ryu/0017000004.gif
    frame    data/chars/ryu/0017000004.gif
    frame    data/chars/ryu/0017000004.gif

I even modified the wasit entity, but I don't like the result of the going back to round 1 after the same round.

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


anim    spawn
@script
  if(frame==1 && openborvariant("count_players")==1){
    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){
    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);
    }
  }

  if(frame == 3){
    void self = getlocalvar("self");
    setidle(self, openborconstant("ANI_IDLE"));
  }
@end_script
    delay    2
    offset    1 1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    delay    459
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

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

    if(Habis>=1){
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
  }

  if(frame == 4){
    changeentityproperty(self, "health", Health-1);

    if(Health <= 0){
    performattack(self, openborconstant("ANI_DIE"));
    }
  }
@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
    delay    105
    frame    data/chars/misc/empty.gif

anim death
@script
if(frame == 0){
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void T1 = findtarget(P1);
    void T2 = findtarget(P2);

    int p1y = getentityproperty(P1, "y");
    int p1base = getentityproperty(P1, "base");
    int p2y = getentityproperty(P2, "y");
    int p2base = getentityproperty(P2, "base");

    int T1y = getentityproperty(T1, "y");
    int T1base = getentityproperty(T1, "base");
    int T2y = getentityproperty(T2, "y");
    int T2base = getentityproperty(T2, "base");

    void P1ani = getentityproperty(P1, "animationid");
    void P2ani = getentityproperty(P2, "animationid");
    void T1ani = getentityproperty(T1, "animationid");
    void T2ani = getentityproperty(T2, "animationid");

    void P1atk = getentityproperty(P1, "attacking");
    void P2atk = getentityproperty(P2, "attacking");
    void T1atk = getentityproperty(T1, "attacking");
    void T2atk = getentityproperty(T2, "attacking");

    changeopenborvariant("lasthitc", 0);

    if(P1){
        changeentityproperty(P1, "noaicontrol", 1);
    }

    if(P2){
        changeentityproperty(P2, "noaicontrol", 1);
    }

    if(T1){
        changeentityproperty(T1, "noaicontrol", 1);
    }

    if(T2){
        changeentityproperty(T2, "noaicontrol", 1);
    }

    if(P1atk == NULL() && p1y == p1base || P1ani == openborconstant("ANI_WALK") || P1ani == openborconstant("ANI_BACKWALK")){
    changeentityproperty(P1, "noaicontrol", 1);
    changeentityproperty(P1, "animation", openborconstant("ANI_IDLE"));
    }
    if(p2y == p2base || P2ani == openborconstant("ANI_WALK") || P2ani == openborconstant("ANI_BACKWALK") ){
    changeentityproperty(P2, "noaicontrol", 1);
    changeentityproperty(P2, "animation", openborconstant("ANI_IDLE"));
    }

    if(P1atk != NULL() && p1y == p1base){
    changeentityproperty(P1, "velocity", 0, 0, 0);
    }

    if(P1atk != NULL() && p1base){
    changeentityproperty(P1, "velocity", 0, 0, 0);
    }

}
if(frame == 1){

    void self = getlocalvar("self");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int HP1 = getentityproperty(P1, "health");
    int HP2 = getentityproperty(P2, "health");

    void target = findtarget(P1);
    void target2 = findtarget(P2);
  
    int THP1 = getentityproperty(target, "health");
    int THP2 = getentityproperty(target2, "health");
    int CountP = openborvariant("count_players");

    if(CountP == 2){
        if(HP1 > HP2){
            performattack(P1, openborconstant("ANI_FOLLOW61"));
            performattack(P2, openborconstant("ANI_FOLLOW15"));
        }
        if(HP1 == HP2){
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(P2, openborconstant("ANI_FOLLOW15"));
        }if(HP1 < HP2){
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(P2, openborconstant("ANI_FOLLOW61"));
        }
    }

    if(CountP == 1){
        if(HP1 > THP1){
            performattack(P1, openborconstant("ANI_FOLLOW61"));
            performattack(target, openborconstant("ANI_FOLLOW15"));
        }
        else if(HP1 == THP1){
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(target, openborconstant("ANI_FOLLOW15"));
        }else if(HP1 < THP1){
            performattack(P1, openborconstant("ANI_FOLLOW15"));
            performattack(target, openborconstant("ANI_FOLLOW61"));
        }

        else if(HP2 > THP2){
            performattack(P2, openborconstant("ANI_FOLLOW61"));
            performattack(target2, openborconstant("ANI_FOLLOW15"));
        }
        else if(HP2 == THP2){
            performattack(P2, openborconstant("ANI_FOLLOW15"));
            performattack(target2, openborconstant("ANI_FOLLOW15"));
        }else if(HP2 < THP2){
            performattack(P2, openborconstant("ANI_FOLLOW15"));
            performattack(target2, openborconstant("ANI_FOLLOW61"));
        }
    }

}

@end_script
   delay   200
   offset   1 1
   @cmd setindexedvar "fightStarted" 0
   sound data/sounds/SND_COM2_8.wav
   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

anim    follow1 # Who wins?
@script
void P1 = getplayerproperty(0, "entity");
void P2 = getplayerproperty(1, "entity");
void Opp1 = findtarget(P1);
void Opp2 = findtarget(P2);
int win1 = getglobalvar("win1");
int win2 = getglobalvar("win2");

int PLAY = openborvariant("count_players");
int set = openborvariant("current_set");
int Current = openborvariant("current_branch");
void Lead = LeaderFind();
void LType = getentityproperty(Lead, "type");

if(frame == 0){ // Freeze!
  void P1 = getplayerproperty(0, "entity");
  void P2 = getplayerproperty(1, "entity");
  void EnemP1 = findtarget(P1);
  void EnemP2 = findtarget(P2);
  int CountP = openborvariant("count_players");
  int base1 = getentityproperty(P1, "base") == getentityproperty(P1, "y");
  int base2 = getentityproperty(P2, "base") == getentityproperty(P2, "y");

  if(P1){ // Player 1?
    if(base1){
      changeentityproperty(P1, "noaicontrol", 1);
      changeentityproperty(P1, "velocity", 0, 0, 0);
      setidle(P1, openborconstant("ANI_IDLE"));
    }
  }
  if(P2){
    if(base2){
      changeentityproperty(P2, "noaicontrol", 1);
      changeentityproperty(P2, "velocity", 0, 0, 0);
      setidle(P2, openborconstant("ANI_IDLE"));
    }
  }
  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
    delay    20 # 170
    frame    data/chars/misc/empty.gi
    delay    100 # 270
    frame    data/chars/misc/empty.gif
    delay 1000
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

anim follow2

    offset    1 1
    @cmd setindexedvar "fightStarted" 0
    frame    data/chars/misc/empty.gif
    delay    20
    frame    data/chars/misc/empty.gif
    delay    100
    frame    data/chars/misc/empty.gif
    delay 1000
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

C:
void main(){
    RoundCount();
    levelTimer();
}

void levelTimer(){
    void self = getlocalvar("self");
    int hp = getentityproperty(self, "health");
    void ani = getentityproperty(self, "animationid");
  
    if(hp>=100){
        drawstring(153,7,6,hp);
    }else if(hp<100 && hp>= 20){
        drawstring(155,7,6,hp);
    }else if(hp<20 && hp>=10){
        drawstring(157,7,6,hp);
    }else if(hp<10){
        drawstring(155,7,6,"0"+hp);
    }
}

void RoundCount(){
    void win = getglobalvar("win");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void Opp1 = findtarget(P1);
    void Opp2 = findtarget(P2);
    void win1 = getglobalvar("win1");
    void win2 = getglobalvar("win2");
    int PLAY = openborvariant("count_players");

  
    if(!win){
        win = loadsprite("data/chars/misc/win.png");
        setglobalvar("win", win);
    }
  
    if(PLAY == 2){
        if(win1 == 1){

                drawsprite(win, 1, 25, 500);

        }if(win2 == 1){

                drawsprite(win, 309, 25, 500);

        }if(win1 == 2){

                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);

        }if(win2 == 2){

                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);

        }if(win1 == 2 && win2 == 1){

                drawsprite(win, 13, 25, 500);
                drawsprite(win, 1, 25, 500);
                drawsprite(win, 309, 25, 500);

        }if(win2 == 2 && win1 == 1){

                drawsprite(win, 309, 25, 500);
                drawsprite(win, 297, 25, 500);
                drawsprite(win, 1, 25, 500);

        }
    }
  
    if(PLAY == 1){
      
        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);
        }

    }
}

Player's winning poses:
C:
anim    follow12
@script
    void self = getlocalvar("self");
    void name = getentityproperty(self, "name");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int COUNTPLAY = openborvariant("count_players");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int hres = openborvariant("hresolution")/2;
    int xpos = openborvariant("xpos");
    int x = hres+xpos;

    if(frame == 1 && COUNTPLAY == 2){
    if(self == P1){
       settextobj(0, x, 60, 1, 800, +name+"_wins");
       if(win1 == NULL()){
        setglobalvar("win1", 1);
       }
       if(win1 == 1){
        setglobalvar("win1", 2);
       }
    }
    if(self == P2){
       settextobj(1, 138, 60, 0, 800, "Ryu_wins");
       if(win2 == NULL()){
        setglobalvar("win2", 1);
       }
       if(win2 == 1){
        setglobalvar("win2", 2);
       }
    }
    }

@end_script
    delay    6
    offset    25 100
    loop    1 8# 14
    frame    data/chars/ryu/93.gif # 0
    offset    26 102
    frame    data/chars/ryu/94.gif # 1
    offset    21 103
    frame    data/chars/ryu/95.gif # 2
    frame    data/chars/ryu/96.gif # 3
    frame    data/chars/ryu/97.gif # 4
    frame    data/chars/ryu/98.gif # 5
    frame    data/chars/ryu/99.gif # 6
    frame    data/chars/ryu/100.gif # 7
    frame    data/chars/ryu/101.gif # 8
    frame    data/chars/ryu/102.gif # 9
    frame    data/chars/ryu/103.gif # 10
    frame    data/chars/ryu/104.gif # 11
    frame    data/chars/ryu/105.gif # 12
    frame    data/chars/ryu/106.gif # 13
    frame    data/chars/ryu/106.gif # 14

anim    follow13
@script
    void self = getlocalvar("self");
    void name = getentityproperty(self, "name");
    int win1 = getglobalvar("win1");
    int win2 = getglobalvar("win2");
    int COUNTPLAY = openborvariant("count_players");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    int hres = openborvariant("hresolution")/2;
    int xpos = openborvariant("xpos");
    int x = hres+xpos;

    if(frame == 1 && COUNTPLAY == 2){
    if(self == P1){
       settextobj(0, 138, 60, 1, 800, +name+"_wins");
       if(win1 == NULL()){
        setglobalvar("win1", 1);
       }
       if(win1 == 1){
        setglobalvar("win1", 2);
       }
    }
    if(self == P2){
       settextobj(1, 138, 60, 0, 800, "Ryu_wins");
       if(win2 == NULL()){
        setglobalvar("win2", 1);
       }
       if(win2 == 1){
        setglobalvar("win2", 2);
       }
    }
    }

@end_script
    offset    25 102
    delay    10
    frame    data/chars/ryu/107.gif
    offset    23 105
    frame    data/chars/ryu/108.gif
    offset    23 129
    frame    data/chars/ryu/109.gif
    offset    23 127
    delay    500
    frame    data/chars/ryu/110.gif
    delay 1000
    frame    data/chars/ryu/110.gif
    frame    data/chars/ryu/110.gif
    frame    data/chars/ryu/110.gif
    frame    data/chars/ryu/110.gif
    delay 3000
    frame    data/chars/ryu/110.gif

Enemy win:
C:
anim    follow12
@script
void self = getlocalvar("self");
int win1 = getglobalvar("win1");
int win2 = getglobalvar("win2");


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

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

@end_script
    delay    10
    offset    25 102
    loop 1 6
    frame    data/chars/ryu/107.gif
    offset    23 105
    frame    data/chars/ryu/108.gif
    offset    23 129
    frame    data/chars/ryu/109.gif
    offset    23 127
    frame    data/chars/ryu/110.gif
    #delay    200
    frame    data/chars/ryu/110.gif
    @cmd    spawnAni "WinLose" 160 120 240 "ANI_FOLLOW2"
    frame    data/chars/ryu/110.gif
    delay    2000
    frame    data/chars/ryu/110.gif
    frame    data/chars/ryu/110.gif
    delay    3000
    frame    data/chars/ryu/110.gif

As for your issue, have you confirmed that the timer does acquire the enemy opponent?
Nope. I realized I didn't. I might have two referees since mixing with some scripts in main wasit entity makes the proceeding rounds go wrong. One as main which is wasit and the other as timer, another wasit. :p Thanks for reminding me about wasit script.
 
Last edited:
@Bloodbane, you were right. I changed it with wasit and it worked. :) I don't have to have two referees at the same time. Having that particular wasit works better than having one entity (that's supposed to be a timer) that has empty calls. Thank you. I solved it after that, but I didn't post it here.
 
Back
Top Bottom