AI not using side bonuses (and other questions)

Download scenarios and talk about scenario design.

Moderators: Slitherine Core, BA Moderators

Post Reply
Halibutt
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 200
Joined: Sun Sep 09, 2012 3:43 am

AI not using side bonuses (and other questions)

Post by Halibutt » Wed Jan 02, 2013 5:53 am

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.
Attachments
Halibutt_Poland.zip
Beta version
(181.21 KiB) Downloaded 116 times
Originally posted by Juu:
The Soviets won the war. We happened to be nearby.

pipfromslitherine
Site Admin
Site Admin
Posts: 9246
Joined: Wed Mar 23, 2005 10:35 pm

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

Post by pipfromslitherine » Wed Jan 02, 2013 7:17 pm

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

Halibutt
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 200
Joined: Sun Sep 09, 2012 3:43 am

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

Post by Halibutt » Wed Jan 02, 2013 8:38 pm

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.
Originally posted by Juu:
The Soviets won the war. We happened to be nearby.

Halibutt
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 200
Joined: Sun Sep 09, 2012 3:43 am

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

Post by Halibutt » Wed Jan 02, 2013 11:36 pm

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?
Originally posted by Juu:
The Soviets won the war. We happened to be nearby.

enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

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

Post by enric » Thu Jan 03, 2013 8:24 am

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

Amaris
Captain - Heavy Cruiser
Captain - Heavy Cruiser
Posts: 929
Joined: Fri Jul 23, 2010 11:08 am
Location: France
Contact:

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

Post by Amaris » Tue Jan 08, 2013 9:03 am

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:
“Take care, my friend; watch your six, and do one more roll… just for me.”

enric
Brigadier-General - 8.8 cm Pak 43/41
Brigadier-General - 8.8 cm Pak 43/41
Posts: 1855
Joined: Sun May 15, 2011 8:47 am

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

Post by enric » Tue Jan 08, 2013 9:35 am

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:

Halibutt
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 200
Joined: Sun Sep 09, 2012 3:43 am

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

Post by Halibutt » Sat Jan 19, 2013 11:49 pm

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?
Originally posted by Juu:
The Soviets won the war. We happened to be nearby.

Halibutt
Sergeant - 7.5 cm FK 16 nA
Sergeant - 7.5 cm FK 16 nA
Posts: 200
Joined: Sun Sep 09, 2012 3:43 am

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

Post by Halibutt » Sun Jan 27, 2013 1:09 pm

Any ideas? Anyone?
Originally posted by Juu:
The Soviets won the war. We happened to be nearby.

junk2drive
BA Moderator
BA Moderator
Posts: 1478
Joined: Sun May 23, 2010 4:47 pm
Location: Arizona USA -7GMT

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

Post by junk2drive » Sun Jan 27, 2013 2:01 pm

Desert1 bsf has a Stuka attack.
You can call me junk - and type that with one hand.

Post Reply

Return to “Battle Academy : Scenario Design”