Skip to content

Jasperre’s AI

Array ( [blocks] => specificItem [show] => [itemId] => 381 [exactSize] => 200 [itemFrame] => none [albumFrame] => none )
  • in modules/core/classes/GalleryStorage.class at line 494 (GalleryCoreApi::error)
  • in modules/core/classes/Gallery.class at line 202 (GalleryStorage::search)
  • in modules/core/classes/helpers/GalleryUserGroupHelper_simple.class at line 105 (Gallery::search)
  • in modules/core/classes/GalleryCoreApi.class at line 1876 (GalleryUserGroupHelper_simple::fetchGroupsForUser)
  • in modules/core/classes/helpers/GalleryPermissionHelper_simple.class at line 64 (GalleryCoreApi::fetchGroupsForUser)
  • in modules/core/classes/helpers/GalleryPermissionHelper_simple.class at line 39 (GalleryPermissionHelper_simple::_fetchAccessListIds)
  • in modules/core/classes/GalleryCoreApi.class at line 501 (GalleryPermissionHelper_simple::fetchAccessListIds)
  • in modules/core/classes/helpers/GalleryUserHelper_simple.class at line 76 (GalleryCoreApi::fetchAccessListIds)
  • in modules/core/classes/GalleryCoreApi.class at line 566 (GalleryUserHelper_simple::hasItemPermission)
  • in modules/imageblock/classes/ImageBlockHelper.class at line 217 (GalleryCoreApi::hasItemPermission)
  • in modules/imageblock/classes/ImageBlockHelper.class at line 93 (ImageBlockHelper::_getBlockData)
  • in /home/aarmgorg/public_html/journal/wp-content/plugins/wpg2/ at line 1352 (ImageBlockHelper::loadImageBlocks)
  • in /home/aarmgorg/public_html/journal/wp-content/plugins/wpg2/ at line 867
  • in /home/aarmgorg/public_html/journal/wp-content/plugins/wpg2/ : regexp code at line 1
  • in /home/aarmgorg/public_html/journal/wp-content/plugins/wpg2/ at line 1245
  • in ??? at line 0
  • in /home/aarmgorg/public_html/journal/wp-includes/plugin.php at line 213
  • in /home/aarmgorg/public_html/journal/wp-includes/post-template.php at line 230
  • in /home/aarmgorg/public_html/journal/wp-content/themes/barthelme/page.php at line 12
  • in /home/aarmgorg/public_html/journal/wp-includes/template-loader.php at line 75
  • in /home/aarmgorg/public_html/journal/wp-blog-header.php at line 16
  • in /home/aarmgorg/public_html/index.php at line 4
I worked on AI for Neverwinter Nights, under the guise of Jasperre, where I managed to get a rewrite of the NPC battle AI done. Still said to be competitive today, despite me not updating it for a while, I was working on a Neverwinter Nights 2 version but never got anywhere – see below.

The newest (and least buggy) version of the AI is 1.4 beta 3, which fixed some logic errors and restructured part of the AI.

Download locations:

Quick changelog on the beta’s:

  • Fixes logic errors that I found.
  • Fixes some bugs in the code, most detailed at the forums.
  • Beta 2: Quickfix for something in beta 1.
  • Beta 3: Fixed bad bug with beta 1 and 2 causing creatures to not properly cast spells.
  • Beta 3: Fixed logic for polymorph spells. People can have advanced crossbow feats and now be turned into trolls any more.

I used to have a Neverwinter Nights Guild for this project (linked here for those who uses the wayback machine). I didn’t really feel the need to back this up or constantly keep acting on the reminders. If you have any serious feedback, comments or anything, post them below :)

BePower Update

Here is a project I’ve not yet checked out but looks to fix a ton of errors in my code. Thanks to BePower it appears! I have no idea what’s really changed under the hood, apart from fixes, but a glance looks good and I’m happy for people to rip it apart – other projects have existed based on my code. I am not going to officially incorporate this, for two reasons: 1. BePower is awesome and deserves full credit for the separate update. 2. As I say below, I don’t like some parts of the code and intended to rewrite them basically entirely (with similar functionality) meaning this kind of fix would have been moot I hope! :)

I actually only realised after writing the above he’s the same person who prompted me to re-do this page…*slaps forehead* thanks dude :)

Future Updates

I stopped working on a new version (either a proper 1.4 update to add to the vault – after all I called the last release “Least buggy”, or a full rewrite for NWN2) due to, basically, getting annoyed at Neverwinter Nights 2’s poor scripting support – ie; bugs everywhere (yeah, saying there were bugs got me nowhere), meaning the AI would actually be harder to write, or just more dumb, then the original game. There was no additional functionality, and a good-as update Henchmen AI mod was, truly, for combat AI probably just as good as a custom-made item. Cest la vie!

It’s tempting to go back to this and continue the newly revamped project I was working on. This would be nothing done soon, and the game is so old it isn’t like there is a huge demand for it, but it might satisfy my urge to rewrite the thing so there is no huge spell routine (which picks a spell to run). I will also be checking out Dragon Age, which has a similar pseudo-turn-base feel with parties of monsters – and I expect, the same kind of scripts that ran on Neverwinter Nights 1! I’ll have to see :)

{ 17 } Comments

  1. BePower | November 23rd, 2009 at 11:06 | Permalink

    Man, your AI is a piece of art. Why didn’t you post it in the vault?
    Thx anyways for having it somewhere :)

  2. Andrew Armstrong | November 30th, 2009 at 18:19 | Permalink

    It is on the vault (although my Guild I let lapse and had no worthwhile things worth saving except for some feeling of self importance). It is only the 1.3 version however:

    Maybe I should update it to the 1.4beta3 version. Hmm…

  3. Olblach | October 26th, 2010 at 10:24 | Permalink

    Hi Jassperre, maybe you remember me I was member in your NWN2’s AI guild! However I came back to NWN2 this year and wanted to use your AI. So I downloaded this file and adapted it (quite easily) for NWN2.

    So I’d like to have your word about this. Is it ok to publish it on the vault (I really did nothing but rename spells and feats and comment out what could not be changed) or would you prefer to publish what you’ve done yourself, or send it to me so I or someone else finish it eventually or maybe you don’t want it published at all?

    I can send you what I’ve done if you want to check but I’m convinced you went past that anyway.

    Please let me know.
    Thanks for the great AI!

  4. Andrew Armstrong | October 26th, 2010 at 12:51 | Permalink

    You can put it on the vault, just give me some credit like BePower did. :) If you do, send me a link and I’ll add it here – NWN2 sadly went a bit backwards with AI (I’m surprised it fully worked, some of the functions I used got half broken!) so I kind of just gave up with it, sadly!

  5. Olblach | October 26th, 2010 at 15:20 | Permalink

    Ok fine, I will thanks. I was hoping to get some code from you hehe. It got better with the last patch (I had given up myself too at that time). They added some fun things like a possibility to create instances from areas.
    As for your code fully working I have not 100% tested it so I wouldn’t say so it’s probably terrible for warlocks but I tested some PC vs Clone fights with CopyObject() they were doing much better than with regular or TonyK’s AI.

    There also might be some glitches with the action stack which is quite tricky to handle in NWN2. I think I understood how it works though and will try to improve the things I can (like adding the missing spells and feats).

    I’ll make a demo mod then post it on the vault and keep you informed.

  6. Olblach | October 30th, 2010 at 9:53 | Permalink

    Hello, it is on the vault now:

    Not 100% happy with the test encounters but I think it’s a good base for testing and improving it.

  7. Andrew Armstrong | November 3rd, 2010 at 19:58 | Permalink

    Good stuff, only it’s “Jasperre” not “Jassperre” – I had enough trouble distinguishing myself from “Jassper” in the original NWN community, haha! (If only Bioware allowed name changes on their site, heh).

  8. Fizzbang | March 5th, 2011 at 23:40 | Permalink

    Just a quick query…using your AI on NWN 1 still and having a few issues with a sorcerer that won’t attack with a dagger when engaged in melee…fires off her spells fine from range…but once the PC rushes her..she just stands there taking hits until she dies without even reacting…any thoughts?

  9. Joshua | July 12th, 2014 at 21:44 | Permalink

    I installed your AI on a module 6 years ago, and have recently pulled it out from storage. One thing I’m trying to find is where spontaneous conversion for clerics is treated. I understand the basic game is *not* supposed to convert spells? PCs are getting annoyed by NPCs spamming Inflict X Wounds upon them back to back.

  10. Andrew Armstrong | July 13th, 2014 at 16:59 | Permalink

    Okay Joshua, seems I never added a flag to sort NPC’s doing that or not – easiest thing would be to alter

    AI_ActionCastSpontaeousSpell in j_inc_generic_ai

    And put something like return FALSE; as the first line or comment out all of the function except for return FALSE;

    This would stop healing spontaneously too which might help or hinder; if so you could check for what nSpellID is and if it matches a healing spell, continue as normal, else fail.

  11. Joshua | July 13th, 2014 at 17:31 | Permalink

    Thanks, I’ll try that. Wouldn’t be bad if it was only doing it a few times, but the way it was working the NPC decided that ALL spells needed to be spontaneously converted to Inflict.

  12. Andrew Armstrong | July 13th, 2014 at 18:29 | Permalink

    1.5 would have made it so there was less..predictability. Never finished it though, alas! Since they go “all out” inflict wounds sometimes seems like the best option due to the lack of cleric offensive spells sadly.

  13. Joshua | July 23rd, 2014 at 17:36 | Permalink

    Speaking of flags, do you remember off-hand which script was used as the “toggle” one to change flags for desired behavior? I was searching around, and couldn’t find it.

    Related to this, some of my PCs have asked about target priorities of NPCs since they seemed to be focused on attacking casters and will ignore their pets or other bodyguards. Might be more realistic but is making playing a low-level mage very hard.

  14. Andrew Armstrong | July 24th, 2014 at 18:59 | Permalink

    The spawn script sets the settings – nw_c2_default9 – it affects all default NPCs. It is rather extreme since I put the “best” settings on to drop into a higher level game module and not take tons of effort to make it all intelligent.

    The settings for targeting are named as AI_SetAITargetingValues. These are the best to mess with to get it to be more fair. These use the stats of the enemy with a importance value to choose what to attack, so yes, attacking mages a lot due to them having low AC, saves, etc.

    Essentially AI_SetAITargetingValues will filter a list of all targets – eg; a party of 4 with 2 summons – will get more and more limited as the categories work. They’re sequential so removing some of them (uncommenting) will alow others to be used only. Try just having the range one, or perhaps a larger band on all of them – set AI_SetAITargetingValues numbers to be 4 and 10 then it’ll get a minimum of 4 targets (the lowest 4) and a maximum of 10 (if there are lots which fit).

    Otherwise uncomment everything but the range, mantal and saves line to make it fairer on mages. See how that goes. Remember to recompile everything as well (and also beta 3 fails to include some spawn override scripts like the lycan spawn script so some monsters may remain unaffected).

    That was one area I was going to upgrade if I ever went back to it funnily enough :)

  15. Joshua | July 25th, 2014 at 22:06 | Permalink

    Thanks, I’ll look at that.

    In a way, it makes sense that they would target the mage, as PCs will typically do the same for NPCs. However, PCs don’t have the huge supply of bodyguards that an NPC mage does, and they don’t always have the luxury of casting all of their spells at once expecting a single fight.

    Couple this with the tendency in NWN for fighter-types to be much more powerful than their PnP counterparts(and mages are only moderately better), the tendency for module designers to add extra HP to monsters due to damage bloat, and you end up with mages sometimes having a pretty challenging time, especially if they solo.

    On a different topic, I’m having complete AI failure when I create an NPC with Bard levels. I’ve tried it on default NWN AI, and on yours, and in both cases they pretty much just sit there and use Song and/or Curse Song repeatedly until the PCs beat them down. Any thoughts?

  16. Andrew Armstrong | July 31st, 2014 at 18:12 | Permalink

    Nope, no idea why a bard won’t cast spells at least, unless it was a bug with the functions. I remember testing bards especially due to their new sub classes and improvements with epic levels, and they seemed to work fine. Basically in my AI they are treated as sorcerers. Maybe there is a bug with the NPC creator/leveller where it isn’t adding spells or abilities they usually have?

    Also you could try the Henchman AI which does some basic changes, it’s possibly going to work better for bards if mine fails completely!

    You can also try making the bard song only have a % chance to come into effect – see AI_AttemptFeatBardSong. It usually runs first rather than casting spells.

    TBH It probably is a buggy function (not seeing the fact it has the spell effect maybe?) maybe due to the later NWN patches? Not sure :)

  17. Quilistan | May 4th, 2018 at 4:19 | Permalink

    Any Chance you can or are going to work on this a bit more, with the NWN EE coming out and the new support of Beamdog?
    If so I might possible have some requests, like dragons casting ranged spells while flying :)


Post a Comment

Your email is never published nor shared. Required fields are marked *