Skip to content

Follow on AI scripting question

I've created a lot of creature specific behavior (casting spells, using objects, moving/teleporting, buffing, etc) by setting creatures to use code I put in x2_def_userdef (usually the EVENT_END_COMBAT_ROUND section). I can usually get them to do what I want, but it hasn't been without problems.

How does putting the code in x2_def_userdef compare to having the creature execute a custom ai script? (i.e. X2_SPECIAL_COMBAT_AI_SCRIPT)


Comments

  • ShadooowShadooow Member Posts: 402
    I never used UserDefined for creatures because it doesn't prevent the original code in those event to run. Plus you need to enable it in OnSpawn which defeats the purpose really.

    Anyway, each creature script will be doing some stuff and eventually run creature internal AI. The events scripts are just external layer of this AI and it is internal AI (DetermineCombatRound) when the real stuff happens.

    UserDefined cannot prevent any of that happen. So even if the creature does what you want her to do via UserDefined, it is at the very least ineffective as the creature is doing stuff and you are canceling it in middle and replacing with your own instructions. You can even break the AI this way - I fixed numerous issues in henchman AI caused by canceling the current AI action in middle in external script. This is because the internal AI sets variable to TRUE, then issues the spell cast action, and then issues the ActionDoCommand(variable to FALSE)); and when the variable is TRUE that internal AI won't do anything as it things it is casting the spell.

    User Defined events are usefull, but definitely not for AI coding purposes.
  • TerrorbleTerrorble Member Posts: 179
    Thanks Shadooow, I was hoping you'd chime in.

    After what I learned from your article and posts in the other thread, I figured the inconsistencies in my NPC behavior was probably due to conflicts between my external commands and the internal AI.

    If anyone else has pearls of wisdom to share about scripting custom AI combat behavior I'd like to hear them.
Sign In or Register to comment.