Need help please

Download scenarios and talk about scenario design.

Moderators: Slitherine Core, BA Moderators

Post Reply
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Need help please

Post by rich12545 »

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

Post by pipfromslitherine »

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
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Post by rich12545 »

The reason I asked about deleting is I had tried holding the delete key and left clicking. Nothing happened. Not sure what you mean by "over a hit" to toggle. Also, now the game won't go into a window when I uncheck full screen.
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

You'll need to be in unit mode for the deletion to work, so I'm guessing that's the issue there.

Very strange that it won't go into windowed mode - one thing to check is that the window isn't the full size of the desktop otherwise it will behave pretty much like fullscreen mode.

Cheers

Pip
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Post by rich12545 »

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

Post by pipfromslitherine »

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
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Post by rich12545 »

Ok, here's the next topic.

have ai units placed on top fourth of map randomly. Also place all human units randomly on bottom fourth.
OR allow each unit to have four or five different starting points that the game chooses randomly for each unit.

I think this needs a script and now things get sticky.
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

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
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Post by rich12545 »

Pip, this post might as well be in Greek for all I understand it.
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

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

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) ;
				}
			}
		}
	}

}
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Post by rich12545 »

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

Post by pipfromslitherine »

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

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) ; 
		} 
	 }  
   } 
}
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Post by rich12545 »

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

Post by pipfromslitherine »

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
Merr
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 903
Joined: Mon Aug 16, 2010 2:00 pm

Post by Merr »

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". :shock:
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
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

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
rich12545
Staff Sergeant - StuG IIIF
Staff Sergeant - StuG IIIF
Posts: 294
Joined: Wed Aug 11, 2010 3:36 pm

Post by rich12545 »

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?
berndN
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 141
Joined: Sat Aug 07, 2010 6:13 pm

Post by berndN »

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?
The { starts the function commands and the } ends it.

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
Staff Sergeant - Kavallerie
Posts: 325
Joined: Fri Apr 17, 2009 9:21 pm
Location: North West, UK
Contact:

Post by PirateJock_Wargamer »

The curly brackets are used to enclose blocks of script, for example

Code: Select all

if( <condition> )
{
   execute if condition true
}
else
{
   execute if condition false
} 
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 :wink:
pipfromslitherine
Site Admin
Site Admin
Posts: 9928
Joined: Wed Mar 23, 2005 10:35 pm

Post by pipfromslitherine »

I would definitely recommend using Notepad with the syntax options set up - it's all explained at the very end of the Engine Documentation.

Cheers

Pip
Post Reply

Return to “Battle Academy : Scenario Design”