Stellaris

Stellaris

Aggressive Crisis Engine
 This topic has been pinned, so it's probably important
OldEnt  [developer] 25 Oct, 2020 @ 7:15pm
AI framework documentation (modders)
Aggressive Crisis Engine AI can be applied to any empire if a modder desires to. It is highly preferable to disable vanilla AI first, otherwise fleet commands will most likely be overridden by vanilla AI.

Currently the only way to disable AI is to edit country type file and set enabled = no in the ai = { } block as there is no disable AI effect on country/fleet/ship scope. You might want to try to disable individual components and modules but I received mixed results. Feel free to experiment and tell me the outcome, please.

You can always view the source code online at:
Effects are listed in /events/acemod_fleet_events.txt (always up to date) and in the post below (might be out of date).
< >
Showing 1-9 of 9 comments
OldEnt  [developer] 25 Oct, 2020 @ 7:16pm 
List of overwrites
CRITICAL:

00_country_types.txt (keys) - disables vanilla AI:
swarm
extradimensional
extradimensional_2
extradimensional_3
ai_empire

01_scripted_triggers_planet_killers.txt (keys) - allow crisis factions use vanilla planet killer weapons. Required to make ACE crisis colossi work.
planet_is_hostile_or_crisis

OPTIONAL:

00_starbase_levels.txt (keys) - allows for Dimensional Anchors to be marked on galactic map.
starbase_level_exd

crisis_events_2.txt (keys) - fixes Extradimensional reinforcements spawning on RANDOM Dimensional Portals. (fixed in Stellaris 3.2 but keeping it as it includes ACOT Override/ACG compatch, feel free to overwrite).
crisis.1265
crisis.1266
crisis.1267
Last edited by OldEnt; 19 Dec, 2021 @ 11:33am
OldEnt  [developer] 25 Oct, 2020 @ 7:16pm 
List of effects:
# Note 1: In order to disable vanilla crisis AI this mod overwrites following keys in 00_country_types.txt: # swarm # extradimensional # extradimensional_2 # extradimensional_3 # ai_empire # # Note 2: Vanilla crisis countries are piloted by default. See instructions on how to exclude countries, including vanilla crisis countries. # # Note 3: In order to allow crisis factions use vanilla planet killer weapons this mod overwrites planet_is_hostile_or_crisis scripted trigger key in 01_scripted_triggers_planet_killers.txt.
# Instructions: # # set_global_flag = acemod_activated global Activates ACEMOD fleet AI. # set_country_flag = acemod_assisted_ai country Only countries with this flag will have their fleets piloted by ACEMOD. # acemod_set_fleet_piloted_exclusion_on = yes fleet ship Prevents ACEMOD from piloting marked fleets. # acemod_set_fleet_piloted_exclusion_off = yes fleet ship Resumes default operation. # acemod_set_country_piloted_exclusion_on = yes country Prevents ACEMOD from piloting fleets of given country. Use this if you don't want vanilla crisis country to be piloted. See acemod_fleet.10 event. # acemod_set_country_piloted_exclusion_off = yes country Removes exclusion *and* enables ACEMOD for given country. Does not activate global ACEMOD fleet AI (acemod_activated flag) if you had it off.
# set_country_flag = acemod_country_flag_custom_starbase_outpost country ACEMOD AI constructors will spawn normal starbases (outpost) using empire's graphical culture. # set_country_flag = acemod_country_flag_custom_starbase_citadel country ACEMOD AI constructors will spawn normal starbases (citadel) using empire's graphical culture.
# set_country_flag = acemod_country_flag_disabled_military_ai country Disables ACEMOD AI for military fleets. # set_country_flag = acemod_country_flag_disabled_constructor_ai country Disables ACEMOD AI for constructor fleets. # set_country_flag = acemod_country_flag_disabled_army_ai country Disables ACEMOD AI for army fleets. # set_country_flag = acemod_country_flag_disabled_colonizer_ai country Disables ACEMOD AI for colonizer fleets.
# set_global_flag = acemod_constructor_reinforcements_disabled global Disables constructor reinforcements for all countries. # set_country_flag = acemod_constructor_reinforcements country Enables constructor reinforcements for given country. Vanilla crisis countries receive them by default. Requires acemod_assisted_ai country flag. # acemod_set_country_constructor_reinforcements_exclusion_on = yes country Prevents ACEMOD from issuing constructor reinforcements. # acemod_set_country_constructor_reinforcements_exclusion_off = yes country Resumes default operation. # set_star_flag = acemod_star_flag_is_constructor_reinforcements_system solar_system Designates system to spawn constructor in. # set_fleet_flag = acemod_fleet_flag_is_constructor_reinforcements_fleet fleet Designates fleet to spawn constructor on.
# set_country_flag = acemod_defensive_jumpdrive_protocol country Enables defensive jumpdrive protocol for given country. Contingency has it by default. Requires acemod_assisted_ai country flag. # acemod_set_country_acemod_defensive_jumpdrive_protocol_exclusion_on = yes country Prevents ACEMOD from issuing defensive jumpdrive protocol. # acemod_set_country_acemod_defensive_jumpdrive_protocol_exclusion_off = yes country Resumes default operation. # set_star_flag = acemod_star_flag_is_defensive_jumpdrive_protocol_system fleet planet Designates defensive jumpdrive protocol protected system. # set_ambient_object_flag = acemod_ambient_object_flag_defensive_jumpdrive_protocol_target ambient_object Designates ambient object to move fleet to. # set_global_flag = acemod_defensive_jumpdrive_protocol_disabled global Disables defensive jumpdrive protocol for all countries.
# set_global_flag = acemod_technology_disabled global Prevents ACEMOD technologies from rolling (potential). # set_country_flag = acemod_country_flag_technology_allowed country Enables rolling of ACEMOD technologies for non-default empires (potential). Does not overrride ACEMOD technology disable global flag. # acemod_set_country_technology_exclusion_on = yes country Prevents ACEMOD technologies from rolling for given country (weight_modifier = 0). Overrides country technology_allowed flag. # acemod_set_country_technology_exclusion_off = yes country Resumes default operation. # set_global_flag = acemod_crisis_debuff_disabled global Disable applying anti-crisis damage debuffs. Does not remove the ones in place. # set_global_flag = acemod_fallen_awakened_empire_debuff_disabled global Disable applying anti-relics damage debuffs. Does not remove the ones in place.
# set_megastructure_flag = acemod_megastructure_flag_is_active_bypass megastructure Marks megastructure as being an accessible bypass (custom modded wormhole, custom modded gateway etc). Used in pathfinding. See acemod_is_active_bypass scripted trigger. # set_star_flag = acemod_star_flag_is_active_bypass solar_system Marks star system as being an accessible bypass (custom modded wormhole, custom modded gateway etc). Used in pathfinding. See acemod_is_active_bypass scripted trigger.
# set_planet_flag = acemod_planet_flag_bombardment_target_ignore planet Marks planet as excluded from being targeted for bombardment. # set_planet_flag = acemod_planet_flag_army_target_ignore planet Marks planet as excluded from being targeted for invasion. # set_planet_flag = acemod_planet_flag_colonizer_target_ignore planet Marks planet as excluded from being targeted for colonization or infestation. # set_planet_flag = acemod_planet_flag_colossus_target_ignore planet Marks planet as excluded from being targeted for colossus kill.
# set_global_flag = acemod_advanced_ai_disabled global Disables some of the fleet events which might require high amount of checks, like reaction to enemy movements. Do not use unless you really want to. # # set_fleet_flag = acemod_fleet_flag_starbase_defensive_protocol fleet Marks fleet as a trigger for territorial defensive actions. # set_star_flag = acemod_star_flag_starbase_defensive_protocol system Marks system as critical and to be defended immediately if needed. # set_country_flag = acemod_country_flag_starbase_defensive_protocol_disabled country Disables territorial defense for given country. # # set_country_flag = acemod_country_flag_starbase_defensive_protocol_fallback_event_disabled country Disables fallback event (acemod_fleet.132). Use if issues from triggering both 130 132 arise (should not). # # set_country_flag = acemod_country_flag_can_spawn_crisis_colossus country Enables automatic Colossus spawns for a given country. Requires specific Colossus type flag and planet flag as well. # set_country_flag = acemod_country_flag_can_spawn_crisis_ai_colossus country Automatic Colossus spawns are of Contingency type. Required for above to work. # set_planet_flag = acemod_planet_flag_can_spawn_crisis_ai_colossus planet Sets planet to spawn Contingency Colossus on. Required for above to work if pc_ai is not present. # set_variable = { which = acemod_var_country_colossus_spawn_limit value = 4 } country Sets game limit of automatic Colossus spawns for a given country (default 4). # set_country_flag = acemod_can_build_crisis_ai_colossus country Allows given country to build Contingency Colossus. # acemod_spawn_ai_colossus = yes root = country this = planet, fleet, ship, ambient_object Spawns Contingency Colossus on this scope for root scope country. # # set_country_flag = acemod_country_flag_system_pings_disabled country Disables pinging systems to indicate potential high value targets.
# set_country_flag = acemod_lib_country_flag_army_strength_modifier_assisted_ai country swarm, ai_empire, and countries with this flag receive Crisis Army Strength multiplier. # set_country_flag = acemod_lib_country_flag_army_strength_modifier_disabled country Disables automatic Crisis Army Strength multiplier recalculation for given country (useful for disabling swarm or ai_empire bonus).
# set_country_flag = acemod_country_flag_jumpdrive_order_enabled country Enables use of jumpdrives for a specific country. # set_global_flag = acemod_global_flag_jumpdrive_order_disabled global Disables globally use of jumpdrives by ACE. # set_country_flag = acemod_country_flag_jumpdrive_order_disabled country Disables use of jumpdrives for a specific country, overrides acemod_country_flag_jumpdrive_order_enabled. # set_fleet_flag = acemod_fleet_flag_jumpdrive_order_disabled fleet Disables use of jumpdrives for a specific fleet.
Last edited by OldEnt; 3 Oct, 2021 @ 7:23pm
OldEnt  [developer] 25 Oct, 2020 @ 7:17pm 
Fleet logic structure:
Fleet logic is separated into chains of events (modules), one chain for each fleet (ship) type:
shipclass_military
shipclass_constructor
shipclass_transport
shipclass_colonizer
shipclass_military_special

Chains are similar between the classes, but vary, depending on the specific requirements for the class.

Main event
Main fleet type event will trigger (monthly) only when ACEMOD AI is globally on. Effects on executing include iterating through every ACEMOD assisted country which is not specifically excluded from having given fleet type assisted. It will then fire fleet events for given class of fleets, but only if those fleets weren't specifically excluded and are idle (have no queued commands).

System event
Fleets proceed to seek valid target within the system. This might include:
- a valid target to be bombarded (shipclass_military)
- primary star to construct starbase on in a system without owner (shipclass_constructor)
- valid invasion target (shipclass_transport)
- valid colonisation target in a system owned by fleet owner (shipclass_colonizer)
- valid planet killer target (shipclass_military_special)

Bypass event
Fleet without valid target in the system might attempt to cross bypass (wormhole, gateway) if one exists in it.

Target seeking event
Fleets which did not find valid target in the system and did not cross bypass will proceed to seek accessible (i.e. not behind FTL inhibitor) target on a galactic map.
- shipclass_military: nearest system owned by a hostile,
- shipclass_constructor: nearest unowned system without hostiles,
- shipclass_transport: nearest system with a planet which is a valid invasion target,
- shipclass_colonizer: nearest owned system with valid colonisation target, and without hostiles,
- shipclass_military_special: nearest friendly shipclass_military fleet which is not excluded.
Last edited by OldEnt; 16 Jul, 2021 @ 7:46pm
OldEnt  [developer] 25 Oct, 2020 @ 7:17pm 
Implementation into other mods

ACEMOD sets up a global flag acemod_installed which in itself does nothing but other mods can check against it to see if the mod is present.

Applying AI to a country
Global flag acemod_activated gates off entirety of ACEMOD fleet logic. Without it no fleet movements are made. It is not present on default (ACEMOD AI is OFF) and only switches on when crisis arrives. Modder has to manually set it up if he intends to use ACEMOD AI with custom country.

To enable ACEMOD AI for your country simply apply country flag acemod_assisted_ai (and the global flag above). Please note that vanilla AI should be disabled. See initial notes on editing country types.

Please keep in mind that disabling AI by setting enabled = no in the ai = { } section will disable ALL of the AI, this includes economy AI (planet management, leaders, diplomacy etc). Crisis countries do not have economy so they remain unaffected. Use of ACEMOD AI with countries which have economy *is not supported*.

Aggressive Crisis Engine AI is a crisis AI (it's in the name), not a default empire AI. Applying it to a typical empire will result in a tactical and strategic disaster.

Tweaking fleet logic
Modder can flip ACEMOD AI exclusion on a fleet/ship/country scope if they want to stop ACEMOD from issuing commands to a given scope. See country_piloted_exclusion effects in the effects list. From a technical standpoint a variable of value 1 is applied which is checked against before executing any command. See acemod_scripted_effects.txt.

Example use:
1. Modder finds desired fleet and executes acemod_set_fleet_piloted_exclusion_on = yes effect on it.
2. Modder uses fleet as seen fit, as ACEMOD AI won't touch excluded fleet.
3. Modder applies acemod_set_fleet_piloted_exclusion_off = yes effect to remove exclusion. Fleet will proceed as normal.

Disabling individual modules
Given fleet types can also be excluded from control by ACEMOD AI. For example acemod_country_flag_disabled_constructor_ai will stop ACEMOD from issuing commands to constructors on a country scope. Modder will have to take care of these excluded fleet types in one way or another.

Overwriting ACEMOD
Any overwrites of ACEMOD files or individual components might affect mods which use ACEMOD AI framework. Please be considerate to other mod authors and mod users and disclose any overwrites on your mod page, preferably with technical details.

Using exclusion effects for a ship/fleet/country scope should provide a lot of flexibility so always consider if these would do instead of an overwrite. Feel free to copy and modify fleet logic code. A clone of an ACEMOD fleet event combined with exclusion effect can save on overwrite.

If there is a feature you think cannot be implemented with exclusion effects and without overwrite just ask, I might be able to accomodate or find a solution.

If you *really* have to do overwrite: remember that you can overwrite individual events instead of the whole file.
OldEnt  [developer] 25 Oct, 2020 @ 7:17pm 
Additional fleet actions
Override of default fleet movements can happen on:
- Critical system wormhole station fleet recall (on_entering_system_fleet acemod_fleet.610)
- Territorial defense actions (on_space_battle_lost acemod_fleet.130)
- Pinging nearby systems (acemod_fleet.150 monthly random chance)

Wormhole recall
Can be enabled and disabled for a country and on a global scope. Requires setting up a critical system. Refer to acemod_defensive_jumpdrive_protocol list of effects.

Territorial defense actions
This is a functionality always enabled for main crisis factions but any critial fleets can be marked as triggers (acemod_fleet_flag_starbase_defensive_protocol). Response will trigger for any country with acemod_assisted_ai. You can globally disable this feature to save a little bit on performance via country flag (acemod_country_flag_starbase_defensive_protocol_disabled) or global flag (acemod_advanced_ai_disabled). Refer to list of effects.

Pinging nearby systems
Fleets will ping at random chance nearby systems in order to find valuable targets which happen to be too close. This can be disabled via country flag (acemod_country_flag_system_pings_disabled) or global flag (acemod_advanced_ai_disabled). Refer to list of effects.

Merging fleets
Fleets will merge under certain conditions. Action invoked by acemod_custom_on_action_merge_fleets custom on_action.
Last edited by OldEnt; 20 Jun, 2021 @ 4:39pm
OldEnt  [developer] 25 Oct, 2020 @ 7:17pm 
Harmless error.log entries (do not report):
[22:29:02][pdx_entity.cpp:2653]: State 'moving' in animated entity 'acemod_ai_colossus_core_entity' is missing an animation! [22:29:02][pdx_entity.cpp:2653]: State 'death' in animated entity 'acemod_ai_colossus_core_entity' is missing an animation! [22:29:03][game_singleobjectdatabase.h:147]: Object with key: swarm already exists [22:29:03][game_singleobjectdatabase.h:147]: Object with key: extradimensional already exists [22:29:03][game_singleobjectdatabase.h:147]: Object with key: extradimensional_2 already exists [22:29:03][game_singleobjectdatabase.h:147]: Object with key: extradimensional_3 already exists [22:29:03][game_singleobjectdatabase.h:147]: Object with key: ai_empire already exists [22:29:04][game_singleobjectdatabase.h:147]: Object with key: planet_is_hostile_or_crisis already exists [22:29:04][effect_impl.cpp:6827]: Failed to read key reference fe_omnimech from database file: events/acemod_fleet_events.txt line: 3386 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4691 " in file: "events/acemod_fleet_events.txt" near line: 4692 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4725 " in file: "events/acemod_fleet_events.txt" near line: 4726 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4759 " in file: "events/acemod_fleet_events.txt" near line: 4760 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4793 " in file: "events/acemod_fleet_events.txt" near line: 4794 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4827 " in file: "events/acemod_fleet_events.txt" near line: 4828 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4861 " in file: "events/acemod_fleet_events.txt" near line: 4862 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4895 " in file: "events/acemod_fleet_events.txt" near line: 4896 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4929 " in file: "events/acemod_fleet_events.txt" near line: 4930 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4963 " in file: "events/acemod_fleet_events.txt" near line: 4964 [22:29:04][fleet_actions.cpp:227]: Error: "Malformed token: prev, near line: 4997 " in file: "events/acemod_fleet_events.txt" near line: 4998 [22:29:04][eventmanager.cpp:355]: an event with id [crisis.1265] already exists! file: events/crisis_events_2.txt line: 2664 [22:29:04][eventmanager.cpp:355]: an event with id [crisis.1266] already exists! file: events/crisis_events_2.txt line: 2962 [22:29:04][eventmanager.cpp:355]: an event with id [crisis.1267] already exists! file: events/crisis_events_2.txt line: 3076 [22:29:04][game_singleobjectdatabase.h:147]: Object with key: starbase_level_exd already exists [22:29:06][trigger_impl.cpp:15435]: Error in [is_country_type] trigger, cannot find country type with key: ascended_empire in, file: events/acemod_crisis_manager_vanilla_substitute_events.txt line: 443 [22:29:06][trigger_impl.cpp:15435]: Error in [is_country_type] trigger, cannot find country type with key: lost_empire in, file: events/acemod_crisis_manager_vanilla_substitute_events.txt line: 444 [22:29:06][metascript.cpp:148]: Compiling source for failed for missing args: DMM_NAME, DMM_FLAG [22:29:06][metascript.cpp:148]: Compiling source for failed for missing args: DMM_FLAG [22:29:06][effect_impl.cpp:811]: Script Error: Invalid scripted effect: dmm_register_mod at file: events/acemod_dmm_new_events.txt line: 8 [22:29:06][effect_impl.cpp:811]: Script Error: Invalid scripted effect: dmm_hide_button_all at file: events/acemod_dmm_new_events.txt line: 50 [22:29:06][effect_impl.cpp:811]: Script Error: Invalid scripted effect: dmm_add_button_exception at file: events/acemod_dmm_new_events.txt line: 65 [22:29:06][effect_impl.cpp:811]: Script Error: Invalid scripted effect: dmm_show_button_all at file: events/acemod_dmm_new_events.txt line: 75 [22:29:06][effect_impl.cpp:811]: Script Error: Invalid scripted effect: dmm_remove_button_exception at file: events/acemod_dmm_new_events.txt line: 82 [22:29:06][effect_impl.cpp:6897]: create_army: missing or invalid army type file: events/acemod_fleet_events.txt line: 3383
Last edited by OldEnt; 31 Jul, 2021 @ 6:45am
OldEnt  [developer] 25 Oct, 2020 @ 7:17pm 
Known additional crises support:

Overgrowth (Fatal Foundations Story Pack)
Native support. To disable ACE AI for Overgrowth execute while crisis is active:
effect every_country = { limit = { is_country_type = overgrowth_country } remove_country_flag = acemod_assisted_ai set_country_flag = acemod_do_not_set_assisted_ai }
Wait until new year for the built-in AI to reactivate.

Gray Tempest:
Execute the following console command once Gray Tempest spawned:
effect every_country = { limit = { is_country_type = gray_goo } set_country_flag = acemod_assisted_ai } set_global_flag = acemod_activated every_system = { limit = { has_star_flag = graygoo_factory_system } set_star_flag = acemod_star_flag_starbase_defensive_protocol every_neighbor_system = { set_star_flag = acemod_star_flag_starbase_defensive_protocol } every_fleet_in_system = { limit = { owner = { is_country_type = gray_goo } } acemod_set_fleet_piloted_exclusion_on = yes } }

Katzenartig Imperium (Gigastructural Engineering & More):
Use KACE patch.
Last edited by OldEnt; 24 Jan, 2022 @ 4:25pm
OldEnt  [developer] 25 Oct, 2020 @ 7:17pm 
Reserved
OldEnt  [developer] 25 Oct, 2020 @ 7:17pm 
Reserved
You may post below.
< >
Showing 1-9 of 9 comments
Per page: 1530 50