Need help please
Moderators: Slitherine Core, BA Moderators
Need help please
I'm trying to make a multi scenario from slith1 into a simple solo scenario. I chose street fighting. Tried following directions and just don't get it. I really need simple, step by step, instructions. Here's what I want to do.
Delete all units from the map.
Add units of my choice. Would prefer setting up a list of available units for each side and a number of buy points.
Let each side buy units and have ai units placed on top fourth of map randomly. Also place all human units randomly on bottom fourth.
Setup bonus, mainly medic.
Setup all ai units for seek and destroy.
No turn limit. One side wins when the other is destroyed. Also how to easily setup victory points easily.
Any help would be appreciated.
Delete all units from the map.
Add units of my choice. Would prefer setting up a list of available units for each side and a number of buy points.
Let each side buy units and have ai units placed on top fourth of map randomly. Also place all human units randomly on bottom fourth.
Setup bonus, mainly medic.
Setup all ai units for seek and destroy.
No turn limit. One side wins when the other is destroyed. Also how to easily setup victory points easily.
Any help would be appreciated.
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Well, to get started, just copy the whole campaign folder from the install MULTIPLAYER directory into your My Documents/My Games/BBCBA/Campaigns directory. It will then be available to edit. The editor allows you to delete all the units (hold DEL and left click), determine which are fixed (hit F when over a hit to toggle), and the buy points are in a window on the main toolbar to the left.
The other elements are quite a lot of different things! So probably best to cover them one by one once you've got the bones in.
Cheers
Pip
The other elements are quite a lot of different things! So probably best to cover them one by one once you've got the bones in.
Cheers
Pip
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Ok, that's why I need simple step-by-step instructions. I found unit mode and deleted all the units.
What is the difference between fixed and not fixed?
My desktop is 1280x1024. That's what I set the game. Usually a game setup like this has the task bar on the bottom. This doesn't.
Next. I would like to play the US against the AI Germany. Infantry type units. How can I set it up with only units of my choice for me and the AI to pick before the scenario?
What is the difference between fixed and not fixed?
My desktop is 1280x1024. That's what I set the game. Usually a game setup like this has the task bar on the bottom. This doesn't.
Next. I would like to play the US against the AI Germany. Infantry type units. How can I set it up with only units of my choice for me and the AI to pick before the scenario?
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Fixed units are always selected on the force selection screen - non fixed must be purchased using the scenario points.
I'm not sure what you mean in the last line. You can place down whichever units you desire. The AI will use them all - it doesn't choose units in the way the player does.
Cheers
Pip
I'm not sure what you mean in the last line. You can place down whichever units you desire. The AI will use them all - it doesn't choose units in the way the player does.
Cheers
Pip
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Yes - you'll need to use a script. I would suggest that you place all the units, and then move them around at the very beginning of the mission (so in the StartTurn function, inside a check for GetTurn() == 0).
The one caveat here is you'll want to ensure that the tiles you are putting a unit on is valid (which isn't too tricky) and ensure that units can't get blocked in (probably more a map design solution there).
The best way to check whether a unit can sit on a tile is to use
GetTileCost(x,y) <= GetBaseAttrib(id, "AP) * GetBaseAttrib(id, "MoveCost")
Although the movecost generally is just 1 anyway, unless you are doing something else in the script (like modelling rain etc).
Use the UnitDeploy command to shift units around the map.
Cheers
Pip
The one caveat here is you'll want to ensure that the tiles you are putting a unit on is valid (which isn't too tricky) and ensure that units can't get blocked in (probably more a map design solution there).
The best way to check whether a unit can sit on a tile is to use
GetTileCost(x,y) <= GetBaseAttrib(id, "AP) * GetBaseAttrib(id, "MoveCost")
Although the movecost generally is just 1 anyway, unless you are doing something else in the script (like modelling rain etc).
Use the UnitDeploy command to shift units around the map.
Cheers
Pip
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
If you'd rather work your way up to scripting the behaviours, then I'd recommend getting the core mission working first, and then coming back to the random placement after that.
The next update includes plugin support and it wouldn't be hard for someone to come up with a plugin to act in the way you describe.
With regard to the scripting I describe, the full scope would be something like the following. This is done off the top of my head, so hopefully give you and idea of what I am talking about.
Cheers
Pip
The next update includes plugin support and it wouldn't be hard for someone to come up with a plugin to act in the way you describe.
With regard to the scripting I describe, the full scope would be something like the following. This is done off the top of my head, so hopefully give you and idea of what I am talking about.
Cheers
Pip
Code: Select all
FUNCTION StartTurn(side)
{
int i ;
int id ;
int x ;
int y ;
if( GetTurn() == 0 )
{
for(i=0;i<GetUnitCount(0);i++)
{
id = GetUnitID(i) ;
// move the unit around by 3 tiles around it.
x = GetUnitX(id) ;
y = GetUnitY(id) ;
x -= Rand(0,6) ;
x += 3 ;
y -= Rand(0,6) ;
y += 3 ;
if( GetTileCost(x, y) <= GetBaseAttrib(id, "AP") )
{
DeployUnit(id, x, y) ;
}
}
}
}
}What I did was take a bsf file and deleted the script part. Then I copy/pasted the above into it. Then I put it in the scenario folder with the map I saved, both have the same name. Then I went into the editor to enter units on the map. When I tried to open the saved map it went about an inch and froze.
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
You should have seen an error popup - as I say, the script was from memory and I missed out a few things. If you were running in a window you certainly should have seen the error - very odd.
This is a fully working and tested version - should help get you started.
Cheers
Pip
This is a fully working and tested version - should help get you started.
Cheers
Pip
Code: Select all
FUNCTION StartTurn(side)
{
int i ;
int id ;
int x ;
int y ;
if( GetTurn() == 0 )
{
for(i=0;i<GetUnitCount(0);i++)
{
id = GetUnitID(0, i) ;
// move the unit around by 3 tiles around it.
x = GetUnitX(id) ;
y = GetUnitY(id) ;
x -= Rand(0,6) ;
x += 3 ;
y -= Rand(0,6) ;
y += 3 ;
if( GetTileCost(id, x, y) <= GetBaseAttrib(id, "AP") )
{
UnitDeploy(id, x, y) ;
}
}
}
}
Ok, I set up units, all unfixed) for both sides, probably 5-600 points worth but set buy points for 300. I got into the game and it seemed to work for my side but can't tell for the ai side. Did the ai choose units up to 300 points (randomly?) or do I need to set all fixed units for the ai side?
I added some stuff from the slith template to your script. What I think I did was make all ai units seek and destroy, set turn limits to unlimited, set an option to add a victory point and a flag and the scenario will declare a victory when one side wins. Here's my script, is it ok? Will it work? Will it do the stuff I listed above?
FUNCTION StartTurn(side)
{
int i ;
int id ;
int x ;
int y ;
if( GetTurn() == 0 )
{
for(i=0;i<GetUnitCount(0);i++)
{
id = GetUnitID(0, i) ;
// move the unit around by 3 tiles around it.
x = GetUnitX(id) ;
y = GetUnitY(id) ;
x -= Rand(0,6) ;
x += 3 ;
y -= Rand(0,6) ;
y += 3 ;
if( GetTileCost(id, x, y) <= GetBaseAttrib(id, "AP") )
{
UnitDeploy(id, x, y) ;
{
// default team 0 to seek and destroy, use threat
SetTeamAggression(1, 0, 65) ;
// set the turn limit - zero means there is none
// remember there is 1 turn per side, so survive 10 of our turns requires
// we set the value to 20 (for example)
SetGlobal("gSkirmishTurns", 0) ;
// do we want a victory point?
// set the the target coordinates if we do, leave as -1 if not
SetGlobal("gVPX", -1) ;
SetGlobal("gVPY", -1) ;
// show a flag?
if( GetGlobal("gVPX") != -1 )
{
}
FUNCTION WIN_SCENARIO_CALLBACK(winner)
{
// use the normal logic of last man standing
}
}
}
}
EDIT: It looks like everything is bordered to the left. Can you make it out or can you tell me how to insert it the way you did?
I added some stuff from the slith template to your script. What I think I did was make all ai units seek and destroy, set turn limits to unlimited, set an option to add a victory point and a flag and the scenario will declare a victory when one side wins. Here's my script, is it ok? Will it work? Will it do the stuff I listed above?
FUNCTION StartTurn(side)
{
int i ;
int id ;
int x ;
int y ;
if( GetTurn() == 0 )
{
for(i=0;i<GetUnitCount(0);i++)
{
id = GetUnitID(0, i) ;
// move the unit around by 3 tiles around it.
x = GetUnitX(id) ;
y = GetUnitY(id) ;
x -= Rand(0,6) ;
x += 3 ;
y -= Rand(0,6) ;
y += 3 ;
if( GetTileCost(id, x, y) <= GetBaseAttrib(id, "AP") )
{
UnitDeploy(id, x, y) ;
{
// default team 0 to seek and destroy, use threat
SetTeamAggression(1, 0, 65) ;
// set the turn limit - zero means there is none
// remember there is 1 turn per side, so survive 10 of our turns requires
// we set the value to 20 (for example)
SetGlobal("gSkirmishTurns", 0) ;
// do we want a victory point?
// set the the target coordinates if we do, leave as -1 if not
SetGlobal("gVPX", -1) ;
SetGlobal("gVPY", -1) ;
// show a flag?
if( GetGlobal("gVPX") != -1 )
{
}
FUNCTION WIN_SCENARIO_CALLBACK(winner)
{
// use the normal logic of last man standing
}
}
}
}
EDIT: It looks like everything is bordered to the left. Can you make it out or can you tell me how to insert it the way you did?
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
The copy and paste stuff should be fine. The AI won't pick random units - you'd need to do some scripting for that to add units in a way similar to the survival scripts. Or you can replicate the UnitDeploy loop but for side 1 rather than side 0 and it will then move around the AI units as it does the allied ones.
To show code you can use the Code button above and it will format it in the grey style.
Cheers
Pip
To show code you can use the Code button above and it will format it in the grey style.
Cheers
Pip
Pip,
I've been trying to write code for that for days ... Thank you!
One thing though ... Don't place the units within 3 tiles of the playing map edge, otherwise they may deploy "out of bounds".
I know that simply adding the code to check mapwidth and height helps prevent this, but unfortunately it might cancel the deploy instead of checking again.
Of course, one can add more code to prevent this ... and add more code to prevent that... etc, etc.
Thanks for the basic code though!!
Much appreciated ... saves me a weeks worth of headaches!
EDIT : I'm sure glad Rich is asking these questions ... makes a good tutorial for later.
I've been trying to write code for that for days ... Thank you!
One thing though ... Don't place the units within 3 tiles of the playing map edge, otherwise they may deploy "out of bounds".
I know that simply adding the code to check mapwidth and height helps prevent this, but unfortunately it might cancel the deploy instead of checking again.
Of course, one can add more code to prevent this ... and add more code to prevent that... etc, etc.
Thanks for the basic code though!!
Much appreciated ... saves me a weeks worth of headaches!
EDIT : I'm sure glad Rich is asking these questions ... makes a good tutorial for later.
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm
Yep - sorry, I was going to make sure to post that tip while I was writing to code, to keep it simple, but forgot!
Putting a check around would be fine - you can just use the IsValidTile function to see whether the final position is on the map or not. If not it would just leave the unit where it is - as UnitDeploy doesn't actually create the unit, just moves it around - it also handles putting it onto another unit automatically, which saves some scripting
Cheers
Pip
Putting a check around would be fine - you can just use the IsValidTile function to see whether the final position is on the map or not. If not it would just leave the unit where it is - as UnitDeploy doesn't actually create the unit, just moves it around - it also handles putting it onto another unit automatically, which saves some scripting
Cheers
Pip
The { starts the function commands and the } ends it.rich12545 wrote:I'm still figuring this out.
What are { and } for? What is the difference between the two? When would you use one and when would you use the other?
What is the purpose of indenting? Is it necessary? How do you know how much to indent?
In this FUNCTION StartTurn(side)
you declare the name of the function (StartTurn) and that this function takes one parameter (side) which can be used later. But as I see no usage of side later this has top be explained by Pip.
The purpose of indenting is to make reading your code easier. There're a lot of explaination how to use indent but if the language don't need special indent rules you are free to use it.
Standard indent should be one tab but the space used for one tab can vary between different editors or is even configurable by editors like Notepad++.
But I'm sure that Pip can explain it better
-
PirateJock_Wargamer
- Staff Sergeant - Kavallerie

- Posts: 325
- Joined: Fri Apr 17, 2009 9:21 pm
- Location: North West, UK
- Contact:
The curly brackets are used to enclose blocks of script, for example
Indents are used to make code easier to read. You indent blocks of script, i.e. script enclosed by set of curly brackets, to show the program's structure, e.g. when you have nested If statements.
Using Notepad ++ is a good way of writing the script because if you use the C language syntax option (on the Menu bar select Language > C > C) it colour codes the script for you and click on one curly bracket it shows you were its partner is ... you really need to try it yourself to see what I mean as I'm not sure my explaination is that good
Code: Select all
if( <condition> )
{
execute if condition true
}
else
{
execute if condition false
} Using Notepad ++ is a good way of writing the script because if you use the C language syntax option (on the Menu bar select Language > C > C) it colour codes the script for you and click on one curly bracket it shows you were its partner is ... you really need to try it yourself to see what I mean as I'm not sure my explaination is that good
-
pipfromslitherine
- Site Admin

- Posts: 9928
- Joined: Wed Mar 23, 2005 10:35 pm


