Scripting

Download scenarios and talk about scenario design.

Moderators: Slitherine Core, BA Moderators

Post Reply
insidius
Sergeant - Panzer IIC
Sergeant - Panzer IIC
Posts: 195
Joined: Sun Aug 08, 2010 9:49 pm

Scripting

Post by insidius »

Anyone good at scripting able to take a fairly simple request? I'd be grateful.

I'm looking for a script that I can plug in that would create 3 Victory Points on the map with a flag for whichever side controls it. In order to win the scenario, you must control all 3 points. If you could write the script, I can plug in the coordinates for where I want the points to be on the map.

Is someone able to do this for me?

Thanks!
ostwind
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 52
Joined: Fri Sep 11, 2009 5:34 pm

Post by ostwind »

You can try this one, I used it for my scenario and works.
You also need to have the file "functions.bsf" into your "scenarios" folder.

Copy this text in a .bsf file with the same name of your scenario.
There are some explanations in the text after the //
If you have any problem, I'll try to help
Hope this helps.

include "Functions.BSF"


// called at the start of every turn.
// You would tend to use this for events
FUNCTION StartTurn(side)
{
int i ;
int x ;
int y ;
int id ;
int playerCount ;

if (GetTurn() == -1 )
{
// Setup VPs, damaged tiled, ...
PreBattleSetup() ;
}
else
{
// Check if any victory conditions are met
VictoryConditions() ;
}

if(side == 1)
{
}

if(side == 0)
{
}

}


FUNCTION PreBattleSetup()
{

//For instance, play with the us (1) and german (4) sides
SetGlobal("gNation0", 1) ;
SetGlobal("gNation1", 4) ;


//You can add as many vp you want, max 9;vp2 and vp3 held by enemy(side 1), vp1 by you (side 0)
SetGlobal("vp1", 0) ;
SetGlobal("vp2", 1) ;
SetGlobal("vp3", 1) ;

//Here we place the flags and the text in the vp
//x1,x2,x3 are the coordinates
//you must add to the text1 file these lines:
//IDS_LOC_German_Base, "GERMAN BASE",
//IDS_LOC_US_Base, "US BASE",
//changing the names and the content at will
ShowEffectMarker(-1, x1, x1, "US_victory_marker", 0) ;
ShowTextMarker(1, x1, x1, "IDS_LOC_US_Base", 6, "FFFFFF", 1);
ShowEffectMarker(-2, x2, x2, "german_victory_marker", 0) ;
ShowTextMarker(2, x2, x2, "IDS_LOC_German_Base", 6, "FFFFFF", 1);
ShowEffectMarker(-3, x3, x3, "german_victory_marker", 0) ;
ShowTextMarker(3, x3, x3, "IDS_LOC_German_Base", 6, "FFFFFF", 1);



// Amount of VPs held by player:
SetGlobal("vps", 1) ;
}


FUNCTION VictoryConditions()
{
int i ;
int j ;
int id ;
int counter ;

if (GetGlobal("vps") == 3)
{
EndBattle(0) ;
}


if (GetGlobal("vps") == 0)
{
EndBattle(1) ;
}


}


// called every game tick.
// You would tend to use this for reactive logic and
// win situations etc
// x1,x2,x3 are the coordinates of vp
FUNCTION Tick(side)
{
CheckVP(-1, GetGlobal("vp1"), x1, x1) ;
CheckVP(-2, GetGlobal("vp2"), x2, x2) ;
CheckVP(-3, GetGlobal("vp3"), x3, x3) ;

}

insidius
Sergeant - Panzer IIC
Sergeant - Panzer IIC
Posts: 195
Joined: Sun Aug 08, 2010 9:49 pm

Post by insidius »

I'll give it a shot, thanks!
pomakli
Captain - Bf 110D
Captain - Bf 110D
Posts: 893
Joined: Thu Dec 03, 2009 12:40 pm
Location: Munich/Germany

wrong flags!?

Post by pomakli »

Ostwind, I copied and chanced the script due to my scenario; everything is OK!

But, I have POLISH flags, instead of ITALIAN!

:shock:
adherbal
The Artistocrats
The Artistocrats
Posts: 3900
Joined: Fri Jun 24, 2005 6:42 pm
Location: Belgium

Post by adherbal »

For italian player flags:
SetGlobal("gNation0", 5) ;
or AI flags:
SetGlobal("gNation1", 5) ;
adherbal
The Artistocrats
The Artistocrats
Posts: 3900
Joined: Fri Jun 24, 2005 6:42 pm
Location: Belgium

Post by adherbal »

ShowEffectMarker(-1, x1, x1, "US_victory_marker", 0) ;
ShowTextMarker(1, x1, x1, "IDS_LOC_US_Base", 6, "FFFFFF", 1);
ShowEffectMarker(-2, x2, x2, "german_victory_marker", 0) ;
ShowTextMarker(2, x2, x2, "IDS_LOC_German_Base", 6, "FFFFFF", 1);
ShowEffectMarker(-3, x3, x3, "german_victory_marker", 0) ;
ShowTextMarker(3, x3, x3, "IDS_LOC_German_Base", 6, "FFFFFF", 1);
Note that all the ShowEffectMarker commands in this section are nolonger required, the CheckVP function takes care of placing them at the start of the mission.
ShowTextMarker are optional but allow you to add a name to the VPs (or any other tile on the map).
pomakli
Captain - Bf 110D
Captain - Bf 110D
Posts: 893
Joined: Thu Dec 03, 2009 12:40 pm
Location: Munich/Germany

DONE!

Post by pomakli »

adherbal wrote:For italian player flags:
SetGlobal("gNation0", 5) ;
or AI flags:
SetGlobal("gNation1", 5) ;
Noticed and Done!

Thank you!

:)
ostwind
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 52
Joined: Fri Sep 11, 2009 5:34 pm

Re: wrong flags!?

Post by ostwind »

pomakli wrote:Ostwind, I copied and chanced the script due to my scenario; everything is OK!

But, I have POLISH flags, instead of ITALIAN!

:shock:
:shock: ... :D It's a matter of defining the nations...
Thanks adherbal for your explanation.
insidius
Sergeant - Panzer IIC
Sergeant - Panzer IIC
Posts: 195
Joined: Sun Aug 08, 2010 9:49 pm

Post by insidius »

Ostwind,

Is there a way to have a Victory Point not held by either nation at the start of the game?
ostwind
Corporal - Strongpoint
Corporal - Strongpoint
Posts: 52
Joined: Fri Sep 11, 2009 5:34 pm

Post by ostwind »

insidius wrote:Ostwind,

Is there a way to have a Victory Point not held by either nation at the start of the game?
I really don't know....I'll make some tests....

Edit:

Tests made, and it's easier than I thougt.
You have to set the victory point to any other side different from side 0 or side 1, f.ex.:

SetGlobal("vpn", 2) ;

and add the sentence for checking it

CheckVP(-n, GetGlobal("vpn"), x, y) ;

Also you need to draw a new blank flag for marking the position
Post Reply

Return to “Battle Academy : Scenario Design”