Scripting
Moderators: Slitherine Core, BA Moderators
Scripting
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!
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!
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.
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) ;
}
wrong flags!?
Ostwind, I copied and chanced the script due to my scenario; everything is OK!
But, I have POLISH flags, instead of ITALIAN!

But, I have POLISH flags, instead of ITALIAN!

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.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);
ShowTextMarker are optional but allow you to add a name to the VPs (or any other tile on the map).
Re: wrong flags!?
pomakli wrote:Ostwind, I copied and chanced the script due to my scenario; everything is OK!
But, I have POLISH flags, instead of ITALIAN!


Thanks adherbal for your explanation.
I really don't know....I'll make some tests....insidius wrote:Ostwind,
Is there a way to have a Victory Point not held by either nation at the start of the game?
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