Page 1 of 1

EndBattle(1)

Posted: Fri Sep 14, 2012 8:15 am
by enric
Hi Pip, should EndBattle(1), end the battle?

I've the following

FUNCTION Tick(side)
{
...
VictoryConditions(); //when exited 7 units game should end
}


then in:

FUNCTION VictoryConditions()

{

if(( GetGlobal("vps") >= 1 ) && ( GetGlobal("exitcount") >= 7 ))

{
Log ("End_1");
ShowUIScreenX( "BattlePop0", "Anim1", "IDS_BUCH_VICTORY", "BHead0Image:german_infantry_head");
Log ("End_2");
AddVizDelay(20) ;
EndBattle(1);
}
}

--------
I got an infinite loop, showing the BattlePop0 again and again, Logs 1 and 2 are displayed so… maybe I'm using the wrong function?

Re: EndBattle(1)

Posted: Fri Sep 14, 2012 11:09 am
by rf900
Check for VictoryConditions should be in StartTurn function, probably doing it at the Tick function is causing the loop.

If you want to do it in the Tick to end inmediately put a global variable check first so it only triggers once.

EndBattle(1); Ends the game with defeat, EndBattle(0) ends with victory.

Re: EndBattle(1)

Posted: Fri Sep 14, 2012 3:42 pm
by enric
rf900 wrote:Check for VictoryConditions should be in StartTurn function, probably doing it at the Tick function is causing the loop.

If you want to do it in the Tick to end inmediately put a global variable check first so it only triggers once.

EndBattle(1); Ends the game with defeat, EndBattle(0) ends with victory.
Thank you rf900, I'already found a bypass like you explain, but I would like to know if EndBattle should really end the battle.

Re: EndBattle(1)

Posted: Fri Sep 14, 2012 4:23 pm
by pipfromslitherine
Yes - EndBattle does indeed end the battle (by setting the winner flag internally) but it doesn't immediately (as you have discovered) stop script processing, so you can indeed get multiple calls to code for popups etc. EndBattle will ignore any subsequent winners (e.g. calling it more than once has no more effect than a single call).

Cheers

Pip