Crossroads
Posts: 17372
Joined: 7/5/2009 Status: offline
|
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.
Attachment (1)
_____________________________
|