Page 1 of 1

AI not using side bonuses (and other questions)

Posted: Wed Jan 02, 2013 5:53 am
by Halibutt
Hello everyone. I've been working on a Polish 1939 campaign for quite some time now. My coding skills are far from perfect, but usually I can cope with many things by myself. Recently I created two maps of the campaign (Tczew bridge and Westerplatte), created Polish units (all right, renamed the British ones), balanced the maps a little, played them a couple of times and... now the weird parts.

1. The AI side never uses the side bonuses. It's particularly troubling in the case of Westerplatte: in the editor I gave the Krauts Stuka attacks, arty attacks and naval artillery (historically they were pounding the peninsula with everything they had for 7 days straight). Yet, the AI never-ever uses them. Which makes the Poles way too powerful, the German assault stalls before reaching the first objective and the entire battle turns into 20 turns of boring bloodbath. Any ideas what did I do wrong?

2. Is there a way to script an artillery attack at the very first turn of the battle?

3. How exactly do I add reinforcements to one of the sides? I see something like the following in a couple of scenarios, but I'm not sure where should I define the PlaceUnit thingy.

Code: Select all

	// German reinforcements
		
	if ( GetTurn() == 3 )
	{
		x = 77;
		y = 34;
		PlaceUnit(x, y, 4, 0, 0, "German_Infantry");
	
		y = 35;
		PlaceUnit(x, y, 4, 0, 0, "German_Infantry");
		
		y = 36
		PlaceUnit(x, y, 4, 0, 0, "German_Infantry");
	}
4. How do I set which side moves first?

Cheers and thanks for any help you can provide. BTW, the attachment is a early beta of the two scenarios I'm working on right now. Without the German arty and dive bombers there is little balance, but the basic idea is there.

Re: AI not using side bonuses (and other questions)

Posted: Wed Jan 02, 2013 7:17 pm
by pipfromslitherine
The AI doesn't use side bonuses. This is by design. You can indeed use scripting to trigger any bonus you like. I don't have an example to hand at the moment, but I perhaps someone else can dig one up for you. Otherwise I can certainly do so once I get back into the office.

PlaceUnit is defined in (IIRC) tools.bsf, you will need to include it at the top of your mission script.

The side which moves first is always the side defined first in the SIDES.TXT file. There is a script command (SkipFirstPlayerTurn) which can be used on missions where player 0 can deploy.

Cheers

Pip

Re: AI not using side bonuses (and other questions)

Posted: Wed Jan 02, 2013 8:38 pm
by Halibutt
pipfromslitherine wrote:The AI doesn't use side bonuses. This is by design. You can indeed use scripting to trigger any bonus you like. I don't have an example to hand at the moment, but I perhaps someone else can dig one up for you. Otherwise I can certainly do so once I get back into the office.
Thanks, that would be awesome. What Tczew and Westerplatte truly lack right now is the Stukas in large numbers.
PlaceUnit is defined in (IIRC) tools.bsf, you will need to include it at the top of your mission script.
No such file on my hard drive... EDIT / Found it, thanks.
The side which moves first is always the side defined first in the SIDES.TXT file. There is a script command (SkipFirstPlayerTurn) which can be used on missions where player 0 can deploy.

Cheers

Pip
Thanks a lot, that explains it.

Re: AI not using side bonuses (and other questions)

Posted: Wed Jan 02, 2013 11:36 pm
by Halibutt
I'm trying to copy the reinforcements code over from Enric's "Fortified Line Leaders" scenario, but I keep getting errors over and over again. Do you guys remember any scenarios where the reinforcements code is a tad simpler?

Re: AI not using side bonuses (and other questions)

Posted: Thu Jan 03, 2013 8:24 am
by enric
Halibutt wrote:I'm trying to copy the reinforcements code over from Enric's "Fortified Line Leaders" scenario, but I keep getting errors over and over again. Do you guys remember any scenarios where the reinforcements code is a tad simpler?
Using others code is the best way to learn but you must understand what the code does.

I'd suggest to use the simple code:

AddUnit(x, y, side, typeString);

On the editor you must write down the coordinates where you wish the reinforcements appear.

AddUnit(43,32, 1, "StugG");

Re: AI not using side bonuses (and other questions)

Posted: Tue Jan 08, 2013 9:03 am
by Amaris
Well It is preferable to use the PlaceUnit function rather than AddUnit:

//add a unit to the map. The string is the unit name. If the tile is not clear the unit is not added. Returns the id of the new unit, or -1 if there was a problem
AddUnit(x, y, side, typeString)

While PlaceUnit tries adjacent tiles if target tile was occupied. :wink:

Re: AI not using side bonuses (and other questions)

Posted: Tue Jan 08, 2013 9:35 am
by enric
Amaris wrote:Well It is preferable to use the PlaceUnit function rather than AddUnit:

//add a unit to the map. The string is the unit name. If the tile is not clear the unit is not added. Returns the id of the new unit, or -1 if there was a problem
AddUnit(x, y, side, typeString)

While PlaceUnit tries adjacent tiles if target tile was occupied. :wink:
Sure, I just suggested it's easier to use (less parameters, not need a include, etc) a expert will prefer PlaceUnit, a beginner will be happy to use AddUnit, and when it works, advance to deep code. :wink:

Re: AI not using side bonuses (and other questions)

Posted: Sat Jan 19, 2013 11:49 pm
by Halibutt
Thanks for your help gentlemen, I got it working now. What I still have no idea how to script are enemy air and naval attacks. Can you think of any scenario where such attack was scripted? Or perhaps have any idea how to do it?

Re: AI not using side bonuses (and other questions)

Posted: Sun Jan 27, 2013 1:09 pm
by Halibutt
Any ideas? Anyone?

Re: AI not using side bonuses (and other questions)

Posted: Sun Jan 27, 2013 2:01 pm
by junk2drive
Desert1 bsf has a Stuka attack.