Reseting the life count

O Ilusionista

Captain 100K
This is another unwanted behaviour I am facing in my game: after a NEXT, the life count resets to the one I put in the SET, like it was explained here.

set  *__Story_Mode
nosame 1
lives 3
credits 5
maxplayers 2
continuescore 1
cansave 2
noshare 1

This render the bonus game useless, because you will loose all the life you earned.

Is there any way to bypass this?
 
O Ilusionista said:
Is there any way to bypass this?

That's the default behavior. You could bypass it by recording lives with script and applying them after the NEXT. There may be a way to do without script, but if so I don't recall.

DC
 
Think I totally misunderstood you. I was thinking of exiting a game. Duh... my bad.

Check and see if lives are reset when you have LESS than the set default. If not, I'm betting I know the flaw.

DC
 
I've edited the title to be more precise.
The issue is: if you get more lifes on the bonus stage (say, 5), when you go to next stage, the life count will be reseted to the default value configured in the SET.
 
Sure sounds like a bug. A workaround could be to capture lives in a globalvariable with endlevelscript then apply it at the the start of a new level.
 
Guys, I found the culprit: Skipselect

If you don't use skipselect to skip the default select screen, even if you set a specific select screen, OpenBOR just ignores it and let you choose all the characters which are loaded into the game, screwing up the unlockables.

To bypass this, I was using a "skipselect" with no parameters. And this is where the error happens:

next

skipselect
select data/select/sel1.txt

See that skipselect with no parameters? if you include it, it will ignore the actual life count and reverting it the default set life count.

Then I've made a test using a skilect with parameters:

next

skipselect Beast

The same result: the engine resets the credit count to the default number used in the level set.

I had 11 lives...
AbrAnfI.png


...them it get reseted to 5
0kMHGjo.png


If you don't use skipselect, the life count is kept normally.
 
I've able to make a script to fix this (but it would be better if the devs can fix it on the engine code).

You will need two scripts:

1- In your UPDATED.C file (if you don't have one, you will need to create one), add this:

Code:
if(openborvariant("in_showcomplete"))
// Live count hack
// 2017.12.03 - Douglas Baldan / O Ilusionista	
{
void P1 = getplayerproperty(0, "entity");
void P2 = getplayerproperty(1, "entity");

void livesP1 = getplayerproperty(P1, "lives");
void livesP2 = getplayerproperty(P2, "lives");

if (P1)
{
	setglobalvar("liveCountP1",livesP1);
}

if (P2)
{
	setglobalvar("liveCountP2",livesP2);
}


}

if(openborvariant("in_gameoverscreen"))
// Live count hack
// 2017.12.03 - Douglas Baldan / O Ilusionista	
// resets the Live Count global variable
{
		if(getglobalvar("liveCountP1"))
    {
        setglobalvar("liveCountP1",  NULL());
    }
	
	if(getglobalvar("liveCountP2"))
    {
        setglobalvar("liveCountP2",  NULL());
    }
	
		if(getglobalvar("liveP1"))
    {
           setglobalvar("liveP1",  NULL());
    }
	
	if(getglobalvar("liveP2"))
    {
           setglobalvar("liveP2",  NULL());
    }
}

Pay attention that this code is NOT inside the main() loop and it will fail if you include it there. The code should be outside that loop, so it will trigger "in_showcomplete", which detects COMPLETE SCREEN.  Why I am using COMPLETE SCREEN instead of SELECT SCREEN? Because at select screen, the life count was already reseted to the default value (so there is something wrong with it too).

After that code, we have another block of code of "in_gameoverscreen", which detects GAME OVER SCREEN. In this block, we resets all the global variables we use on the code above. If you don't include this, the next time you start a new game, you will have the same number of lives of your last stage.

2- Create a file called LEVEL.C and save it on your scripts folder with this script:

Code:
void main()
{
// Live count hack
// 2017.12.03 - Douglas Baldan / O Ilusionista

	void P1 = getplayerproperty(0, "entity"); // Gets the Player 1
	void P2 = getplayerproperty(1, "entity"); // Gets the Player 2
			
	void liveP1 = getglobalvar("liveCountP1"); // Gets the Global Var with the P1 live count
	void liveP2 = getglobalvar("liveCountP2"); // Gets the Global Var with the P1 live count
			
	if (P1 && liveP1 != NULL()) // Check if there is a P1 and if the global var is set
		{
			changeplayerproperty(P1,"lives",liveP1); // Change P1 live count
		}
		
	if (P2 && liveP2 != NULL())
		{
			changeplayerproperty(P2,"lives",liveP2); // Change P2 live count
		}
		
}

As the manual says, LEVEL.C is a code which runs when any level begings and just one time.

Note: this code was made to 2 player game only. If you have more than 2 players, you will need to adapt it to the other players.
 
Back
Top Bottom