EndBattle(1)

Modders can post their questions on scripting and more.

Moderators: Slitherine Core, BA Moderators

Post Reply
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

EndBattle(1)

Post 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?
rf900
Staff Sergeant - Kavallerie
Staff Sergeant - Kavallerie
Posts: 339
Joined: Fri May 04, 2012 6:59 am

Re: EndBattle(1)

Post 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.
enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

Re: EndBattle(1)

Post 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.
pipfromslitherine
Site Admin
Site Admin
Posts: 9937
Joined: Wed Mar 23, 2005 10:35 pm

Re: EndBattle(1)

Post 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
Post Reply

Return to “Battle Academy : Modders Corner ”