Jump to content

AI Behaviour help: Is Writing new AI code possible?


LeaderEnemyBoss

Recommended Posts

Hi everyone,

 

I am currently working on a new enemy. One of its abilities has the following functionality:

 

  • target a single unit that meets a certain stat condition (in my case PsiOffense>0, the target can be friend or enemy)
  • deal damage to the primary target and to all units in an area around the primary target

Creating this ability was the easy part, however getting the AI to work in a non stupid way proved to be harder than expected

 

The problem:

 

  • AoEProfiles are an easy way to let enemies somewhat smartly chose its targets (avoid allies, hit many enemies etc.). Sadly they only work with free targeting cursor abilities, my ability however has a simplesingletarget style with aoe attached.
  • Treating my ability like a normal single target ability works for the most basic functionality
  • However I also want my enemy to consider sacrifing its fellow alien teamembers and choose them as primary target if enough XCom units are in the respective aoe around the primary target unit
  • AbilityTargetUnitCount lets me count the units in the AoE, however it counts all eligible units. And since friendly and enemy targets can be targeted and damaged by the explosion, this condition is useless for my purpose.

The easiest way to get what I want would be to create a new condition that allows me to only count enemy and allied units separately. I could raise the target score, if many XCom units are around the target, and I could lower the target score, if many aliens are around it. I had a look at the ai files, and the function is really simple. However all AI classes I found seem to be native, and the functions dont seem to be very "accessible" from the outside. Is it possible to write own AI routines or functions without overriding classes (because a class override for a single enemy mod is something i want to avoid)? Or maybe someone has an easier solution for my issue?

Edited by LeaderEnemyBoss
Link to comment
Share on other sites

Update:

 

The good news:

I got the X2DebugBehavior command to work thanks to another thread on this board.

 

The bad news:

With help of this command I noticed, that AbilityTargetUnitCount counts ALL visible targets that are reachable with the ability, not just the ones around the selected primary target. Appearently this condition is only useful for selftargeting AoE abilities (shield barrier, the unimplemented lightning field ability). So back to square one.

Edited by LeaderEnemyBoss
Link to comment
Share on other sites

Update:

 

Fxsjosh posted some hints in my corresponding reddit thread. Appearently a new "hidden feature" of the patch is, that one can indeed define new custom node types. So far I have no Idea how this works (or if any modder has already done something like this so I can use it as a blueprint), but atleast there is hope!

 

https://www.reddit.com/r/xcom2mods/comments/4jdsg4/ai_behaviour_help_is_writing_new_ai_code_possible/

Link to comment
Share on other sites

Update:

 

Turns out there is a blueprint ... in the code of the DLC. Making good progress now. Defining new conditions and actions is very possible and actually not that hard. Will post a final update when my mod is online, so other modders can use my stuff as a template.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...