Login

russian armor

Short guide to add a A.I script into a tuning pack

11 Oct 2021, 16:31 PM
#1
avatar of Zycat

Posts: 14

This is the way to create a custom "personality" SCAR .ai script and add it in your tuning pack :

First, we need the .ai files from Data.sga. At the bare minimum you will need the default_skirmish.ai, but if you want to overwrite all the standard .ai files you will need the skirmish.ai and tactics.ai as well. I would recommend just extracting the entire .ai folder


the default_skirmish.ai only contains :
import("skirmish.ai")

function InitializeAIPersonality()

end

InitializeSkirmishAI()
InitializeAIPersonality()


and it's quite bare. You can add your own settings and economy overrides just fine, but beware if you looked at the other .ai personality files for inspiration because they contains mistypes. In particular, the basic_personality_template.ai uses Game_GetLocalPlayer() which is incorrect since it refers to the human player. It should be AI_GetPlayer().

If you notice it imports skirmish.ai. Now, if you want to modify skirmish.ai and tactics.ai you can only copy and paste the whole skirmish.ai to your personality file replacing the respective import line (NOT the whole skirmish.ai file). And if you notice the skirmish.ai itself it imports tactics.ai as well as util/debug.ai and ai-view.ai. We're only interested in the tactics.ai so replace the import line in skirmish.ai with the whole tactics.ai. Leave the debug and ai-view functions alone as they only contain debugging stuff.

So now you have one big .ai file, put it somewhere in your mod folder and create a folder and burn file like these (example from my A.I mod) :



Note that the folder structure has to be exactly like this. No you can't put your own skirmish.ai to the \data\ai folder, it will not be recognized by CoH2 although it can be built. We only have access to the \data\ai\personality folder for a tuning pack, hence the whole copy and paste thing.

And finally, don't forget to change the ai_personality attributes :


Congrats, now you can use SCAR scripting (albeit very limited in scope) in a tuning pack. And change or add all the TacticFilter stuff.

I personally tested a lot of SCAR functions and those that modify anything (resources, experience, CP, etc.) always results in either Fatal AI Error in game or sync-errors in the replay (not sure about multiplayer) with certain exceptions like AI_EnableEconomicOverride. Some ai_settings can be modified on the fly just by assigning a variable to those like for example :
aisettings_combat_eval_required_win_ratio_at_min_class_rating = 0.5

Other functions that just retrieve the state/data usually works fine like World_GetGameTime() or Player_GetMaxPopulation(AI_GetPlayer(), CT_Personnel).
1 user is browsing this thread: 1 guest

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

757 users are online: 757 guests
0 post in the last 24h
8 posts in the last week
34 posts in the last month
Registered members: 49107
Welcome our newest member, Falac851
Most online: 2043 users on 29 Oct 2023, 01:04 AM