Author Topic: TonyK's AI are switching weapons at random  (Read 249 times)

Legacy_Kolbarten

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
TonyK's AI are switching weapons at random
« on: July 01, 2013, 05:42:51 am »


               Sorry for troubling you all again. I just don't know or have courage enough to meddle on the programming.

Something that keeps happening is that henchmen change weapons at random between the ones they have on their inventory. For example, if Valen Shadowbreath has a dagger, a longsword +3, and his traditional Devil Bane, he will equip the dagger and attack once, then equip the Devil Bane and attack once, then equip the dagger again and attack once, then equip the longsword etc etc...

This happens in every module, and is especially frustrating when a henchman has an nontransferable weapon, like Valen, or is dual-wielding two weapons of the same type, like two short swords.

Did someone else had this problem or knows how to solve it?
               
               

               


                     Modifié par Kolbarten, 01 juillet 2013 - 04:43 .
                     
                  


            

Legacy_cds13

  • Sr. Member
  • ****
  • Posts: 360
  • Karma: +0/-0
TonyK's AI are switching weapons at random
« Reply #1 on: July 01, 2013, 11:03:21 am »


               Can answer only by having played the OC and other modules. I didn't play SoU or HoU that much. Tony K AI applies to all of the above so I assume the solutions should be the same.

You have to limit the number of weapons to the ones you effectively want your companion to use. If I don't go wrong Valen should have as standard equipment a heavy flail. Anyway if you want to equip him with other weapons that could be a problem.

A companion who comes with no untransferable weapons should be easier to customize. Let us assume you have Sharwyn and you want her to dual wield a +1 longsword and a +2 kama she will be using the kama as primary weapon losing some benefits coming from the smallest weapon in the left hand. You have to put some care into equipping not only the largest weapon on the right hand but even the one with the higher modifier. I.e. a +2 katana and a +1 kukri should work fine. Anyway, as stated before strangely she will bash (if not able to lockpick it) the 1st chest with the kukri and the second with the katana. Odd, I know but that's how the companions act.

That limit (the one concerning with the modifier regardless of the size of the weapons) cannot be avoided even if you instruct the "use only light weapons offhand" command.
               
               

               
            

Legacy_Mystery X

  • Full Member
  • ***
  • Posts: 248
  • Karma: +0/-0
TonyK's AI are switching weapons at random
« Reply #2 on: July 02, 2013, 07:20:35 am »


               It seems to me that cluttered inventory- particularly the first screen- sometimes hinders henchman's decisions about using equipment.  If you are using Valen to carry around treasure, see what happens if you put the treasure on the last inventory screens, and keep the first screen clear except for equipment you want him to use (like Heal potions).
               
               

               
            

Legacy_MrZork

  • Hero Member
  • *****
  • Posts: 1643
  • Karma: +0/-0
TonyK's AI are switching weapons at random
« Reply #3 on: July 03, 2013, 07:50:49 am »


               I am pretty sure that TonyK's AI scripts don't care on which page in the inventory a given weapon is placed. Not that it's a bad guess or that it wouldn't be a convenient way of cluing in the AI as to what you want it to do. But, it would be quite difficult to use NWN scripting to determine what page a given item is on, much less use that information to decide to equip it or not. My guess is that the scripts search the whole inventory for possible weapons, using some heuristic to decide which one to equip. Of course, it's possible that the inventory script stops after finding a certain number of items and decides among those (rather than finish looking through the rest of the inventory) and that might make it seem that only items "early" in the inventory are used. However, I sort of doubt TonyK's AI does that and the documentation for Bioware's ActionEquipMostDamagingMelee() (which I think TonyK uses for choosing the mainhand weapon) doesn't mention that.

There is a potential helpful tidbit, however. I haven't looked at TonyK's scripts in a long time, but I am pretty sure that they ignore items in containers (e.g. wooden box, magic bag, etc.) when choosing weapons to equip offhand. So, you may be able to put any item you don't want the henchman to equip inside a container and it should be ignored. I do not know if that works for mainhand weapons, as I think TonyK's AI uses Bioware's ActionEquipMostDamagingMelee() function for that, and I don't know if it ignored items in containers. And, I supposed that it's possible that the mainhand script might pull an item out of a bag and then, if it's unequipped for some reason to the main inventory, it might later get chosen by the offhand script. So, there may not be a foolproof way to do things.

I also think that TonyK just uses the GP value of the weapon to determine which one is best for offhand use, whereas the ActionEquipMostDamagingMelee() function checks only the enhancement bonus of the weapon. I have never tested it, but that may make it possible to get TonyK's to pick an offhand item that you prefer by adding a permanent property like light to it (e.g. cast continual light or use a light gem).
               
               

               


                     Modifié par MrZork, 03 juillet 2013 - 06:53 .
                     
                  


            

Legacy_Kolbarten

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
TonyK's AI are switching weapons at random
« Reply #4 on: July 08, 2013, 04:01:19 am »


               Okay, I've been looking closely to why and how the NPC decides to change a weapon, so i made a few tests, and it seems it's not so random after all, only somewhat wrong.

assuming Daelan Redtiger (Dual-axe wielder) have a shield, a dagger +1 with 1d6 ice damage, a greatsword +3, a short sword +2 vs outsider +5, and a dual-axe +3. when the opponent is CR effortless, he'll take the dagger AND the shield, or the short sword AND the shield, since he doesn't see the enemy as a treat, but he'll protect himself of damage. If the enemy is effortless, but has any elemental resistance, he'll take the short sword, probably because the AI sees all elemental resistances as one. If the enemy is stronger than easy, he'll use the greatsword, since it has the strongest damage per attack (2d6+1.5 STR). If it is an Outsider, he'll use the short sword, above all other options, because it's a +5 weapon at the moment. Removing the shield, he'll dual-wield dagger and short sword, or use the greatsword. He'll never use the Dual-axe, because it doesn't fit the categories above.

So in short, it seems that the NPC AI takes what it considers the best option for the moment, but disregards feats or choices of the player. At least, that's what I noticed testing a few times.