Adaptive AI settings and Lua (Full Version)

All Forums >> [New Releases from Matrix Games] >> Campaign Series: Vietnam >> Scenario Design and Modding



Message


Crossroads -> Adaptive AI settings and Lua (2/2/2022 7:34:21 AM)

Want to have scenario specific settings for Adaptive AI for a new scenario you are putting together?

There's two ways to approach this.



Add a scenario specific *.ai file

First, you can create a scenario specific *.ai file, where the "*" part must exactly match the scenario file you have created. For instance: IC_510529_DR1_Ninh_Binh.scn -> IC_510529_DR1_Ninh_Binh.ai

In that *.ai file, override the Side specific and / or Nation specific values you want to alter with values you want to use. Just fill those values, on scenario specific ai files it is recommended to have all unchanged values as "-1" ie. "no change".

I put together a boilerplate for that, to be made available in 1.01, also attached to this post.

Pros: Just add the *.ai file, change the values you want to alter. That's it.
Cons: Static, *.ai file is read once scenario loads, those values then stick for the whole game play



Change AAI parameters from scenario specific *.lua file

With this approach, you'd call a CSEE api for setting the parameters you want to change:

quote:

FUNCTION

set_adaptive_ai (side, nation, index, value)

DESCRIPTION

Sets the Adaptive AI value for the given index, and side or nation.

If nation is -1, set the side parameter value. Otherwise, set the nation parameter value.

INPUTS

side -- "a", "b", or some function or expression evaluating to either of those side values
nation -- integer, or some function or expression evaluating to an integer; from 0 to 99
index -- integer, or some function or expression evaluating to an integer; from 0 to max Adaptive AI parameter #
value -- integer, -1 or greater


Look for examples on how to do that from for instance all Day River lua files: for instance IC_510529_DR1_Ninh_Binh.lua. I do them in static manner at on_startup() by calling a custome init_aai_settings() function that is at the end of the lua file. You can alter AAI settings at any stage of gameplay though, this is dynamic.

For example:

quote:

-- # 45 [ n] AI_oplimit_otherfiring_othertarget
set_adaptive_ai ("nil", FRENCH_NATION, 45, OP_MEDIUM)
set_adaptive_ai ("nil", VIETNAMESE_NATIONAL_ARMY_NATION, 45, OP_MEDIUM)
set_adaptive_ai ("nil", VIET_MINH_NATION, 45, OP_SHORT)


I find it helpful that I first copy the parameter info from the init.ai file, to also document what's happening. Then just provide the Side and or Nation ID, you can hardcore "a" or "b" for Side, or Nation ID such as 10 for US, or use declared values. All Nation names can be found from user.lua.

Pros: this is fully dynamic, you can change any parameters for instance Op Fire settings on a fly
Cons: Lua file and some programming required




I hope this helps, sorry for lack of documentatio at this stage on AAI or Lua for that matter, we will remedy this with documentation over the coming weeks.

Any questions, please let us know!

_scenario_boilerplate.ai attached below.




TomWalton -> RE: Adaptive AI settings and Lua (2/2/2022 8:05:53 AM)

Interesting! What would be really great (no rush ;-)!) would be to have a couple of really, really simple step-by-step video tutorials for those of us who are pretty much complete beginners at this...

As with all the Campaign Series games, amazing that the game even comes with editors, though this of course is a step up!




Crossroads -> RE: Adaptive AI settings and Lua (2/2/2022 8:16:19 AM)

Berto's in process of writing a CSEE Lua manual, but that will take some time, with 1.01 UPDATE having priority. Agreed, a video tutorial would be nice too. Stay tuned!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1.09375