Reinforcements and scripting

Download scenarios and talk about scenario design.

Moderators: Slitherine Core, BA Moderators

Post Reply
burnsibub
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 18
Joined: Thu Nov 19, 2009 4:08 pm

Reinforcements and scripting

Post by burnsibub »

Hi all
I am in need of a bit of help please, I have trawled the forum the last couple of days but still cant figure out what I am doing wrong.

Its come to a point where I need my .BSF script file as part of a scenario to work, simply because side0 needs reinforcements on a certain turn - simple right?

however it looks like it just isnt being read or there is an error that stops it working!

my file (Phase2Battle1.BSF, which puts a sherman on 16,16 on turn 2 of side 0) looks like this:-

Code: Select all

include "Functions.BSF"

FUNCTION StartTurn
{
// Reinforcements
if(GetTurn() == 2)
{
if(side == 0)
{
// AddUnit with more options : FUNCTION PlaceUnit(x, y, facing, side, team, type)
PlaceUnit(16, 16, 2, 0, 1, "SHERMAN") ;
AddVizCamCenter(16, 16);
}
}
am I doing anything silly?

cheers
Lee
pipfromslitherine
Site Admin
Site Admin
Posts: 9885
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

I'm guessing that the script file isn't being read, because there are some errors there that would cause it to stop and tell you :).

The script file should be in the same folder as the scenario (.BAM) file that you have created in the editor, and with the same name, but the .BSF type (so mission1.BAM and mission1.BSF).

The only error, actually, is that the function definition is missing it's input, so should be

FUNCTION StartTurn (side)

otherwise the side variable doesn't exist in the function. Note also that on GetTurn() == 2 side will always be 0, but that extra check won't cause any issues. I fixed the function definition, and it seems to work fine - so you are on the right track! :)

Any other questions, feel free to ask and myself or one of our other experts will be sure to answer.

Cheers

Pip
burnsibub
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 18
Joined: Thu Nov 19, 2009 4:08 pm

Post by burnsibub »

Damned those type 'o's!!!

Working now!
fantastic Pip, many thanks!

Lee
onwards, forwards!!!!
burnsibub
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 18
Joined: Thu Nov 19, 2009 4:08 pm

Post by burnsibub »

just as a development on the subject, if I wanted to load up infantry into a carrier as reinforcements I have this script outlined below, however how do i get to amend their facing?

Code: Select all


include "Functions.BSF"

FUNCTION StartTurn (side)

{ 
int i ;
int id ;
// Reinforcements 
if( (GetTurn() == 2) )
{ 
if(side == 0) 
{ 

if( GetGlobal("AddRein") == 0)
{
SetGlobal("AddRein", 1) ;
id = AddUnit(16, 16, 0, "Brencarrier");
i = AddUnit(17, 16, 0, "British_Infantry"); 
LoadUnit(id, i) ;
}

AddVizCamCenter(16, 16); 
} 
}
}
is there a list of functions and what their assignments are, as Im working on trial and error at the moment. eg AddUnit (X,Y,side, "unittype")

cheers
Lee
pipfromslitherine
Site Admin
Site Admin
Posts: 9885
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

If you grab the modding doc from the modding portal (stickied) it should list (most) of the script commands - and there is an always up to date version in My Docs\My Games\BBCBA\Autodocs.

If you check in the Functions.BSF file, you'll find a handy helper function called PlaceUnit which allows you to set the facing as part of it's call, so that's might save some time :)

// definition
FUNCTION PlaceUnit(x, y, facing, side, team, type)

it's worth reading through the function, as it has some special functionality which allows for simple loading of units into prior units.

Cheers

Pip
burnsibub
Lance Corporal - Panzer IA
Lance Corporal - Panzer IA
Posts: 18
Joined: Thu Nov 19, 2009 4:08 pm

Post by burnsibub »

great stuff
thanks pip!
Post Reply

Return to “Battle Academy : Scenario Design”