Time expires, the character loses life and the level is repeated from the beginning (without script).

Steven1985

Active member
Hi, I'd like to know if there is a way without script in the following case: when the time expires, I'd like that the character loses one life and the level is repeated from the beginning.
Thanks in advance.
 
No, there isn't. Also, I don't mean to be unfriendly but you need to stop putting "without script" into your questions. It's rude to people who would help you and limits what we can offer.

The point of our help is to get you the best solution, script or not.

DC
 
No, there isn't. Also, I don't mean to be unfriendly but you need to stop putting "without script" into your questions. It's rude to people who would help you and limits what we can offer.

The point of our help is to get you the best solution, script or not.

DC
I apologise. I will no longer put 'without script'.
 
@Steven1985,

I noticed you marked my answer above as a solution, but we didn't actually solve your question. While you can't do this with native functions, it is easily possible if you are willing to look at scripted solutions.

DC
 
So you pretty much get game over when the time is up?
I think what he means is restarting the level without losing ALL your lives and getting a game over. That's the difference.

DC
Probably he means restart the level like dying in Mario, Ninja Gaiden, Battletoads (Turbo Tunnel).
I think one of the Mortal Kombat mods have this scripted in one of the stages.

If time runs out, you lose life and re-start the level (like Die_In-Fire has written).
 
If time runs out, you lose life and re-start the level (like Die_In-Fire has written).
If that's the case, you
If time runs out, you lose life and re-start the level (like Die_In-Fire has written).
I'm interested in the solution is a good question. Is your game or Mod a single player game? Because what happens if player one looses but player 2 is still alive?

I haven't looked at the manual, but if there's restart, or game over function, I would assume that placing such function in the very beginning of the respawn(or is it called restart) animation would do the trick.
 
I'm interested in the solution is a good question.

I have an idea on how to implement this with script. However to make it easier and more stable, I prefer to use scripted timer instead of default timer. Of course, this means default timer must be disabled when this scripted timer is used.

what happens if player one looses but player 2 is still alive?
From my understanding of the first post, when timer hits 0, all active players will lose one life doesn't matter if they lose one life before that.
 
I have an idea on how to implement this with script. However to make it easier and more stable, I prefer to use scripted timer instead of default timer. Of course, this means default timer must be disabled when this scripted timer is used.


From my understanding of the first post, when timer hits 0, all active players will lose one life doesn't matter if they lose one life before that.

That works for me, because my mod doesn't have a timer anyways.
 
Ack! I forgot about the life decrement part.
But if anyone wants to see the scripted timer without life decrement script, here it is:
Code:
name        TimerGo
health         100
type        none
antigravity    100
subject_to_wall    0
offscreenkill    3000
animationscript    data/scripts/prscript.c
script    @script
void main()
{
    void self = getlocalvar("self");
    int MTime = getentityproperty(self,"maxhealth");
    int Time = getentityproperty(self,"health");

    if(Time > 0){
      drawstring(140, 16, 3, Time/10);
    }
}
@end_script


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

      changeentityproperty(self, "health", Health-10);

      if(Health > 10){
        updateframe(self, 1);
      }
    }
    if(frame==3){
      void self = getlocalvar("self");
      char Go = getentityproperty(self, "name");

      jumptobranch(Go, 1);
    }
@end_script
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
    delay    99
    frame    data/chars/misc/empty.gif
    delay    1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

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

This TimerGo will decrement its health 10 unit per second. IOW with 100 health, it will end current level after 10 seconds.
Unlike the other timer I have posted here somewhere before, TimerGo will send player to branch with same name as TimerGo's alias. If no matching branch, it will simply go to next level.
I prefer to code it like this cause it's more flexible as modder can easily set alias in a level matching branch for that level. This also allows using TimerGo for bonus round with limited time or for crucial level in which player must destroy something or kill an enemy before time expires.

I'll modify the script to add life decrement code.

[couple hours later]
Here's the version with life decrement code:
Code:
name        TimerGoL
health         100
type        none
antigravity    100
subject_to_wall    0
offscreenkill    3000
animationscript    data/scripts/prscript.c
script    @script
void main()
{
    void self = getlocalvar("self");
    int MTime = getentityproperty(self,"maxhealth");
    int Time = getentityproperty(self,"health");

    if(Time > 0){
      drawstring(140, 16, 3, Time/10);
    }
}
@end_script


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

      changeentityproperty(self, "health", Health-10);

      if(Health > 10){
        updateframe(self, 1);
      }
    }
    if(frame==3){
      void self = getlocalvar("self");
      char Go = getentityproperty(self, "name");
      void P1 = getplayerproperty(0, "entity");
      void P2 = getplayerproperty(1, "entity");
      void P3 = getplayerproperty(2, "entity");
      void P4 = getplayerproperty(3, "entity");

      if(P1){
        int P1L = getplayerproperty(0, "lives");

        changeplayerproperty(0, "lives", P1L-1);
      }

      if(P2){
        int P2L = getplayerproperty(1, "lives");

        changeplayerproperty(1, "lives", P2L-1);
      }

      if(P3){
        int P3L = getplayerproperty(2, "lives");

        changeplayerproperty(2, "lives", P3L-1);
      }

      if(P4){
        int P4L = getplayerproperty(3, "lives");

        changeplayerproperty(3, "lives", P4L-1);
      }

      jumptobranch(Go, 1);
    }
@end_script
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
    delay    99
    frame    data/chars/misc/empty.gif
    delay    1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

anim    spawn
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
 
Last edited:
Ack! I forgot about the life decrement part.
But if anyone wants to see the scripted timer without life decrement script, here it is:
Code:
name        TimerGo
health         100
type        none
antigravity    100
subject_to_wall    0
offscreenkill    3000
animationscript    data/scripts/prscript.c
script    @script
void main()
{
    void self = getlocalvar("self");
    int MTime = getentityproperty(self,"maxhealth");
    int Time = getentityproperty(self,"health");

    if(Time > 0){
      drawstring(140, 16, 3, Time/10);
    }
}
@end_script


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

      changeentityproperty(self, "health", Health-10);

      if(Health > 10){
        updateframe(self, 1);
      }
    }
    if(frame==3){
      void self = getlocalvar("self");
      char Go = getentityproperty(self, "name");

      jumptobranch(Go, 1);
    }
@end_script
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
    delay    99
    frame    data/chars/misc/empty.gif
    delay    1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

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

This TimerGo will decrement its health 10 unit per second. IOW with 100 health, it will end current level after 10 seconds.
Unlike the other timer I have posted here somewhere before, TimerGo will send player to branch with same name as TimerGo's alias. If no matching branch, it will simply go to next level.
I prefer to code it like this cause it's more flexible as modder can easily set alias in a level matching branch for that level. This also allows using TimerGo for bonus round with limited time or for crucial level in which player must destroy something or kill an enemy before time expires.

I'll modify the script to add life decrement code.

[couple hours later]
Here's the version with life decrement code:
Code:
name        TimerGoL
health         100
type        none
antigravity    100
subject_to_wall    0
offscreenkill    3000
animationscript    data/scripts/prscript.c
script    @script
void main()
{
    void self = getlocalvar("self");
    int MTime = getentityproperty(self,"maxhealth");
    int Time = getentityproperty(self,"health");

    if(Time > 0){
      drawstring(140, 16, 3, Time/10);
    }
}
@end_script


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

      changeentityproperty(self, "health", Health-10);

      if(Health > 10){
        updateframe(self, 1);
      }
    }
    if(frame==3){
      void self = getlocalvar("self");
      char Go = getentityproperty(self, "name");
      void P1 = getplayerproperty(0, "entity");
      void P2 = getplayerproperty(1, "entity");
      void P3 = getplayerproperty(2, "entity");
      void P4 = getplayerproperty(3, "entity");

      if(P1){
        int P1L = getplayerproperty(0, "lives");

        changeplayerproperty(0, "lives", P1L-1);
      }

      if(P2){
        int P2L = getplayerproperty(1, "lives");

        changeplayerproperty(1, "lives", P2L-1);
      }

      if(P3){
        int P3L = getplayerproperty(2, "lives");

        changeplayerproperty(2, "lives", P3L-1);
      }

      if(P4){
        int P4L = getplayerproperty(3, "lives");

        changeplayerproperty(3, "lives", P4L-1);
      }

      jumptobranch(Go, 1);
    }
@end_script
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
    delay    99
    frame    data/chars/misc/empty.gif
    delay    1
    frame    data/chars/misc/empty.gif
    frame    data/chars/misc/empty.gif

anim    spawn
    delay    1
    offset    1 1
    frame    data/chars/misc/empty.gif
Thank you @Bloodbane ,
I'm sure this will help me and others.
 
Back
Top Bottom