Choose Your Language

Friday, 30 January 2015

AI AI .... Oh!

Old MacDonald may not have had many issues keeping his animals in check, but the beast known as the AI in NWN can certainly be a tricky issue to tame. In the last week or so, I have been looking at the AI (Artificial Intelligence) when it comes to NPCs using spells. While I was running a combat test, I noted that the spell casters would prefer to run into close melee combat rather than cast their spells. This was certainly not going to work for me, and so I decided to take a closer look and see if I could make my spell casters do what they should be doing best ... and cast their spells when entering combat.

There's Gonna Be A Fight!
Eventually, I managed to narrow down the problem to two areas of code, which with a little adjustment to my own code, managed to make the spell casters behave more intelligently, and cast their spells. The two adjustments included:-

1) Where possible, switch to using the function HenchDetermineCombatRound rather than using the ActionAttack function. I thought the latter function would have triggered the former, but this is not the case. (Obvious in hindsight.) Using the former function throws the NPC into immediately using its combat AI code, whereas the latter makes the NPC close to attack before thinking about it.

2) Update my own AI script (used for many other combat situations, including things like healing and weapon choice) to make reference to the older NWN function DetermineCombatRound if the NPC is a spell caster. This older function appears to give better results than the newer one (mentioned in 1 above). Therefore, while I use the newer HenchDetermineCombatRound to initiate the AI for the NPC, I actually re-direct the AI to use the older DetermineCombatRound function via my own AI script.

The end result of making these two adjustments is that my spell casters definitely use their spells before entering combat.

Combat Begins! The spell casters cast from the back!

Creatures Summoned! Now for their next trick!

Other Testing

While testing, I also discovered some other issues that needed fixing. (Some due to later updates I had made that affected the very early stuff.):-

1) Fixed creatures dropping their "creature items" due to a new ID system I had implemented.
2) Fixed a container found on a creature that was using an OC GUI that does not work.
3) Fixed creature auras that were clashing with my NPC detection aura system.
4) Fixed/Updated a Scroll GUI trigger system to use newer functions to allow more script calls.

There were a handful of other minor issues that I fixed along the way and which I encountered as I did another quick play test. In the coming weeks, I hope to carry on finishing conversations and finishing area scripts.

Monday, 19 January 2015

Back On Track Again

Time for another update ... and the first for this year. Probably like most NWN builders, I have a paper notebook in which I keep a list of all those bits and pieces I need to do. Items get added or removed from that list as I go about designing the module, make changes or mark things as completed. My goal for this year is to NOT add anything else to that list at all ... and to concentrate on finishing those final stages to get this module ready for BETA, and perhaps, even its release.

There always seems to be new obstacles at times trying to hamper progress, but while they may slow me down, I am still committed to finishing this module. At the risk of repeating myself, all the core code is now in place and it is just a matter of me adding content. However, I now have to add content with respect to my own systems as well. E.g. Monsters that may appear in the bestiary and spells need code adding to work with the various systems I have relating to spell usage.

As a whole, I only have four quests lines to finish and then I am done! Occasionally, I do still find I come across small problems like the flute animation issue I have posted about recently, but overall, I am still making progress. So, just to say, it's a new year and I am back on track again!

Not Much Further Now!