Aller au contenu

Photo

Scripting a Henchman to Use an Item


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
AndarianTD

AndarianTD
  • Members
  • 706 messages
Does anyone know how to script a henchman to use an item? I've observed that henchmen with their "casting" toggle set will often do this with items such as scrolls and the like, but there are situations where I'd like to be able to do this deliberately. I don't seem to be able to find anything in the API that would enable this.

Also, does anyone know how the variable "X2_L_STOPCASTING" is handled by the engine? I've been setting it to 0 and 10 respectively to enable and disable casting, which is consistent with the base game scripts I've looked at. Is it just that "0" is treated as "false" (don't stop casting) and "10" treated as "true" (do stop casting), or are there other values that this can be set to for different behaviors?

Thanks in advance for any feedback!

- Andarian

#2
Pattycake1

Pattycake1
  • Members
  • 49 messages
For the first part, what are you trying to get them to use and when?

For the second part I wish I could help ya with that but I'm not sure...

#3
AndarianTD

AndarianTD
  • Members
  • 706 messages

Pattycake1 wrote...

For the first part, what are you trying to get them to use and when?


I'm thinking in terms of a general capability that I could script for a variety of items. What I have in mind is an item with the "Cast Spell" added to it, giving it to the henchman, and having the henchman use it instead of the player. Henchmen will do this spontaneously with items like spell scrolls if their casting flag is enabled. I'm trying to figure out if this is locked into the engine, or if there is a hook into this behavior that would allow me to initiate it from a script.

Hope that helps --

#4
Pattycake1

Pattycake1
  • Members
  • 49 messages
I don't remember if there is a specific hook for it. I do know in Jasper AI system he has NPC's switch from ranged weapons to melee weapons. You should look into that to see how he does it.

#5
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Short Answer.   No it is part of the engine.    There is a nwnx function that you can use though.  Here is a recent thread nwnx_funcs ActionUseItem()

Long answer.  ( Well I guess short also) :

There may be a way to do it using the talent system.  But I myself have never figured it out or even seen the talent functions disscused much on the boards.

#6
AndarianTD

AndarianTD
  • Members
  • 706 messages
Thanks, Lightfoot. I was afraid of that, but it's better to know so that I can cross that idea off my list.

#7
henesua

henesua
  • Members
  • 3 883 messages
Interesting problem, Andarian. I would think you could do this by sending an item activation event for a particular item, but I haven't looked into doing this for an NPC, only for PCs. I don't know if NPCs respond to that event at all.