Author Topic: One-armed man  (Read 388 times)

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
One-armed man
« on: October 23, 2015, 06:50:57 am »


               

Hi all!


 


 


I want to make a companion npc wich you can modify inventory as you wish, one armed.


 


So, he  has his right hand invisible, and i want to make it impossible to equip items in that hand.


 


I tried creating an invisible object (fashion) wich goes in the right hand and flaging it cursed, but can be unequiped. 


 


There is a way to flag items as un-unequipables?


 


Or maybe another idea. 


 


Thank you.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
One-armed man
« Reply #1 on: October 23, 2015, 09:15:23 am »


               

I have a very similar problem with an NPC who has to keep a stick in her left hand, because she only has one good leg.


 


I'd be very interested if anyone has a better solution.


 


The frustration is that the OnEquip event doesn't fire for companions.


 


The kludge I came up with is to use the companion's OnHeartbeat to check that the stick is still in the left hand. In my case, it doesn't look too bad - if the PC forces an item into her left hand, or a two-handed item into her right hand, she almost immediately re-equips the stick. In your case, you might want a pseudoheartbeat running very frequently (once per second?) to make it seem that the right hand can't be equipped.


 


Another consideration is that my henchman AI equips the most effective weapon. I have the following system to prevent two-handed weapons being equipped:


 



   Spoiler
   


 


This is not quite foolproof if the PC removes all other weapons from inventory, but the heartbeat kludge overcomes that.


 


My function which checks if an item is a weapon is as follows:


 



   Spoiler
   


 


No doubt that check could made more general by examining baseitems.2da, as long as it isn't called too often.



               
               

               
            

Legacy_Nebril2

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
One-armed man
« Reply #2 on: October 23, 2015, 03:00:14 pm »


               

Thanks for your reply.


 


I will use the pseudoheartbeat, but isnt this method heavy for the pc? i mean my module uses lots of onheartbeat functions, and im trying to reduce them, making a pseudoheartbeat consumes much than a simple heartbeat? or is not something i shouldnt worry about?


 


Been here i will also ask, if i add some scripts to the cached list, will it help? and will it change the way this heartbeat scripts work?


 


 


Thankkks   '<img'>  ':ph34r:'



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
One-armed man
« Reply #3 on: October 23, 2015, 07:17:19 pm »


               

Pseudoheartbeat isnt much better than normal heartbeat, however you can use it in different intervals and you can turn it off and on as needed which can make it much more efficient than normal heartbeat.



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
One-armed man
« Reply #4 on: October 23, 2015, 10:24:39 pm »


               My understanding is that the script cache does more harm than good. This is the Lexicon info:

http://www.nwnlexico...=Script_Caching


I don't find it helps, even in SP.


A pseudoheartbeat on one NPC will have a negligible effect on performance if it's only checking whether an item's equipped in the right hand. It's a good way to achieve a near-instantaneous result.