CustomAIRedux

If you liked this item, please rate it up on Steam Workshop page.

Author: catalystwyrm

Last revision: 9 Jan at 00:47 UTC (5)

File size: 276.92 KB

On Steam Workshop

Description:
CustomAI Redux

"Define precise AI behavior for your companions with conditional logic and party-wide coordination."

CustomAI Redux allows you to program your party members’ combat behavior using conditional instructions with support for AND logic, party-wide coordination, and flexible targeting.

Core Mechanics

Instruction Format

Each instruction follows: IF [Entity] [Condition] [Comparison] [Value] THEN [Action]

Example:

ALLY HP < 50%: Cure Wounds

Translation: "If any ally has less than 50% HP, cast Cure Wounds on that ally"

AND Logic: Cascading Search

AND conditions let you combine multiple requirements before taking action. When you switch to checking a different type of character, the system performs a new search. When you keep checking the same type of character, it validates the same entity meets all conditions.

Example 1: Entity Type Changes (Multiple Searches)

ANY_PARTY Distance <= 2: And ALLY HP <= 45%: And ALLY Status != Poison: Cure Wounds

First checks if anyone is within 2 tiles. If yes, performs NEW SEARCH for wounded ally without poison. The distance check gates the healing – "only heal when not fighting alone."

Example 2: Same Entity Type (Single Search)

ALLY Distance <= 2: And ALLY HP <= 45%: And ALLY Status != Poison: Cure Wounds

Searches for closest ally who meets ALL three conditions simultaneously. All checks apply to the same ally because entity type (ALLY) doesn’t change.

Entity Types

Single-Target Entities (Direct Reference):
TARGET – Current combat enemy
PLAYER – The player character
SELF – The AI-controlled companion itself
RIDING – Player’s mount

Search Entities (Find Closest Match):
ALLY – Party members (alive, visible, excludes self/player/mount)
ANY_PARTY – All party members including player (alive, visible)
ANY_ENEMY – All hostile visible enemies
DEAD_PARTY – Dead ex-party members (for resurrection spells)

Special Entities (Universal Quantifiers):
WHOLE_PARTY – Validates ALL party members meet condition, casts on entire party
ALL_ENEMIES – Validates ALL enemies meet condition, casts on all enemies

Conditions

HP – Hit points (number or percentage: "50" or "50%")
MP – Mana points (number or percentage: "30" or "30%")
SP – Stamina points (number or percentage: "20" or "20%")
DISTANCE – Distance in tiles (number: "5")
STATUS – Status effect check (name: "Blind", "Haste", "Poison")
SUMMONS – Number of active summons (number or "100%" for max)
DEAD – Is dead ("True" or "False")

Comparisons

= – Equals
!= – Not equals
> – Greater than
< – Less than
>= – Greater than or equals
<= – Less than or equals

Note: STATUS condition only allows = and !=. DEAD condition only allows =.

Cast On Override

The "Cast On" dropdown allows you to override which entity receives the action, separating who you check from who you affect.

Example:

TARGET HP < 50%: Cast "Cure Wounds" on SELF

Translation: "If my current enemy is wounded, heal myself instead"

UI Features

Use Stashed Spells

Toggle that allows companions to cast spells that have been stashed from Vanilla AI using NPCSpellManager mod’s Stash feature. Spells appear in action dropdown with [Stashed] suffix.

Verbose Instruction Logs

Toggle for detailed debug logging of instruction evaluation. Shows which conditions matched/failed and entity resolution results. Useful for debugging complex instruction sets.

Fallback to Default AI

When enabled and no custom instruction matches, character switches to vanilla AI. If EnableFallbackTactics config is enabled, a dropdown appears to select which vanilla tactics profile to use (archer, healer, tank, mage, etc.).

When disabled (default), character shows "doesn’t know how to respond" message if no instruction matches.

Configuration (BepInEx)

Config file location:

BepInEx/config/dragoonearth.elin.customairedux.cfg

UseVanillaPartyCastRestrictions

Default: false

QOL Mode (false):
• Friendly spells with CanSelectParty show "Whole Party" option
• Hostile spells with RequireChara show "All Enemies" option
• Example: Cure Minor Wound can cast on whole party

Vanilla Mode (true):
• Only spells with ForceParty flag or party-cast genes can target whole party
• Stricter but more faithful to base game mechanics

EnableFallbackTactics

Default: true

Enabled (true):
• When "Fallback to Default AI" is enabled, a dropdown appears to select vanilla tactics profile
• Provides fine-tuned control over fallback behavior

Disabled (false):
• Works as before this feature was added
• Fallback uses character’s original tactics without modification (for veterans who prefer to use Brain Cells to change NPC Combat AI)

Import/Export System

Export Format (JSON)

Exports to clipboard as JSON with complete instruction data:
• Entity type, condition, comparison, test value
• Action name, action entity, targeting flags
• Fallback setting, human-readable descriptions

Import Behavior

When importing instructions:
Action Validation: Only imports actions the character actually knows
Skipped Actions: Logs warning for unavailable spells/abilities
Fallback Preserved: Imports fallback toggle state from exported data
Log Reports: Shows count of imported vs. skipped instructions

Preset System

Save Preset: Store instruction set with custom name per character
Load Preset: Quick-load saved configurations
Auto-Load: Automatically loads last used preset for each character

Example Instruction Sets

Smart Healer
ALLY HP <= 40%: And ALLY Status != Regeneration: Cure Critical Wounds

Only heal allies below 40% HP who don’t already have regeneration buff.

Tactical Resurrector
DEAD_PARTY Dead = True: Resurrection ALLY HP < 25%: Cure Critical Wounds TARGET HP > 0%: Attack (Ranged)

Prioritize resurrection, then emergency healing, then offensive actions.

Compatibility

• Elin version: Stable / Nightly
• Save-compatible: Uses character data storage, no save file modifications
• Mod conflicts: Should not conflict with other mods unless they also patch Chara.SetAIAggro
• Tome of Memory Loss integration: Optional, enables stashed spells feature

Credits

Requires YK Framework. Tested on Nightly builds.

Companion mods:

NPC Spell Learning: https://steamcommunity.com/sharedfiles/filedetails/?id=3557997205

Tome of Memory Loss: https://steamcommunity.com/sharedfiles/filedetails/?id=3561086399

Player Gene System: https://steamcommunity.com/sharedfiles/filedetails/?id=3568525292

Original CustomAI mod by air1068

https://steamcommunity.com/sharedfiles/filedetails/?id=346365

If you like the work I do, please support me with a small tip on https://ko-fi.com/catalystwyrm

Download
Required items:

Click the title to search on this site.


YK FrameworkSteam Workshop
Revisions:

Old revisions of this mod are available below. Click the link to download.