Start without full Health and MP

Luca Natale

New member
Ahoy.
By default, you start every stage off with full health and full MP.
For the project I'm working on, the player starts with an empty MP gauge, and respawns with an empty MP gauge if a life is lost.
When the next stage begins, their health should be the same as when they finished the previous stage.

I know there's a script out there that can change how much health and MP you start stages with, if anybody here could point me in the right direction? Thanks!
 
Ahoy.
By default, you start every stage off with full health and full MP.
For the project I'm working on, the player starts with an empty MP gauge, and respawns with an empty MP gauge if a life is lost.
When the next stage begins, their health should be the same as when they finished the previous stage.

I know there's a script out there that can change how much health and MP you start stages with, if anybody here could point me in the right direction? Thanks!

@Luca Natale,

I'm on the phone and can't really write code. I would advise looking through @Bloodbane's posts. I think he put one up a while back. I believe @O Ilusionista has one too.

DC
 
Ahoy.
By default, you start every stage off with full health and full MP.
For the project I'm working on, the player starts with an empty MP gauge, and respawns with an empty MP gauge if a life is lost.
When the next stage begins, their health should be the same as when they finished the previous stage.

I know there's a script out there that can change how much health and MP you start stages with, if anybody here could point me in the right direction? Thanks!
@Luca Natale

You can use the endlevel.c event in order to save all current health/mp into variables when a level ends, then load it in the level.c to reapply the previous values when a new level starts. For the respawn event you can use the respawn1.c for player 1, respawn2.c for player 2 and so on in order to run any script when each player respawns.

Below an example of how you can make all players to always start with no mp every time a new level starts. To save/load current values you can use setglobalvar / getglobalvar for player ID related scripts, and setentityvar / getentityvar for entity related scripts.

Level.c
C:
void main()
{
    void player1 = getplayerproperty(0, "entity");
    void player2 = getplayerproperty(1, "entity");
    void player3 = getplayerproperty(2, "entity");
    void player4 = getplayerproperty(3, "entity");
    int amount = 0;

    changeentityproperty(player1, "mp", amount);
    changeentityproperty(player2, "mp", amount);
    changeentityproperty(player3, "mp", amount);
    changeentityproperty(player4, "mp", amount);
}

EDIT: Fixed the code to work properly for players 2-4
 
Last edited:
@Luca Natale

You can use the endlevel.c event in order to save all current health/mp into variables when a level ends, then load it in the level.c to reapply the previous values when a new level starts. For the respawn event you can use the respawn1.c for player 1, respawn2.c for player 2 and so on in order to run any script when each player respawns.

Below an example of how you can make all players to always start with no mp every time a new level starts. To save/load current values you can use setglobalvar / getglobalvar for player ID related scripts, and setentityvar / getentityvar for entity related scripts.

Level.c
C:
void main()
{
    void player1 = getplayerproperty(0, "entity");
    void player2 = getplayerproperty(0, "entity");
    void player3 = getplayerproperty(0, "entity");
    void player4 = getplayerproperty(0, "entity");
    int amount = 0;

    changeentityproperty(player1, "mp", amount);
    changeentityproperty(player2, "mp", amount);
    changeentityproperty(player3, "mp", amount);
    changeentityproperty(player4, "mp", amount);
}
You meant these for players 2-4.

C:
    void player2 = getplayerproperty(1, "entity");
    void player3 = getplayerproperty(2, "entity");
    void player4 = getplayerproperty(3, "entity");
 
Yeah. I think I had that same mistake before. When you forget about changing player indexes and leave all of them to 0 (player index) which is only gonna result to just player 1, players 2-4 will not start with 0 MP in any level except player 1.
 
Back
Top Bottom