Forcing a creature to use an item
Moderator: Event DM
- Deider
- Demigod of Posts
- Posts: 13259
- Joined: Sun May 11, 2003 12:33 pm
- Timezone: GMT -8
- Location: California
Forcing a creature to use an item
I'm looking for a way to force a creature (PC or NPC) to use an item - specifically, drink a potion. Not just standard Bioware potions, but custom potions and even our custom booze. There seems to be no ActionUseItem function. Any thoughts?
- TiVO25
- Sage
- Posts: 1641
- Joined: Wed Jun 30, 2004 5:07 am
- Location: Arlington, TX. (GMT -5); Dreaming of Austin
- Contact:
Okay, I'm no scripting monkey, and only a fledgling tool-set monkey, (i'm tryin' to learn) but I had a notion, so I thought I'd share it, for what it's worth.
If you can't make the individual drink the actual potion (for example) could you at least force the animation, and fire a spell that has the same effect?
If you can't make the individual drink the actual potion (for example) could you at least force the animation, and fire a spell that has the same effect?
You can't stop the signal.
"Every calling is great when greatly pursued."
~Oliver Wendell Holmes
Dr. Horrible's Sing-Along Blog
"Every calling is great when greatly pursued."
~Oliver Wendell Holmes
Dr. Horrible's Sing-Along Blog
- Deider
- Demigod of Posts
- Posts: 13259
- Joined: Sun May 11, 2003 12:33 pm
- Timezone: GMT -8
- Location: California
Yes, you can, but there are drawbacks:TiVO25 wrote:If you can't make the individual drink the actual potion (for example) could you at least force the animation, and fire a spell that has the same effect?
- it requires multiple actions, which could generate lag if you were using this for say, a custom AI that has enemies use healkits and custom potions (like the shadowshield pots crafters will one day be able to make)
- it may cast the spell at a different level than is what the potion has, usually a higher level.
- the server window would indicate that the NPC or PC cast a spell instead of drank a potion. Minor, but purists might not like it

- this would work for potions, but not our custom booze

- Aloro
- Team Member; Retired with Honors
- Posts: 12805
- Joined: Sat Dec 28, 2002 5:11 am
- Location: Rainbow's End
- Contact:
Feh. Nope, I don't know how this is done, or if it's even possible. I looked in nwnlexicon, and didn't see anything there that would force an NPC to actually use an item. 
- Aloro

- Aloro
Aleksandr Solzhenitsyn wrote:The meaning of earthly existence lies, not as we have grown used to thinking, in prosperity, but in the development of the soul.
- Deider
- Demigod of Posts
- Posts: 13259
- Joined: Sun May 11, 2003 12:33 pm
- Timezone: GMT -8
- Location: California
Tossing some stuff out there that might ignite some minds:
- Sindol mentioned using talents, like TalentBuffSelf or TalentAdvancedBuff. I found a thread on the BioBoards where a guy had modified the talent scripts to get them to make NPCs drink SOME potions, even some custom ones.
- The same poster was able to get NPCs to use healkits, using talents IIRC. I'll link the thread later when I find it again.
- Sindol mentioned using talents, like TalentBuffSelf or TalentAdvancedBuff. I found a thread on the BioBoards where a guy had modified the talent scripts to get them to make NPCs drink SOME potions, even some custom ones.
- The same poster was able to get NPCs to use healkits, using talents IIRC. I'll link the thread later when I find it again.
yup, talents is the way to go.
Playing as: Sir Douglas Hope of Gorethar, old school paladin | Krator Blackfist, gold mage | Warren, half nymph barbarian
- Aloro
- Team Member; Retired with Honors
- Posts: 12805
- Joined: Sat Dec 28, 2002 5:11 am
- Location: Rainbow's End
- Contact:
Nope.Krator wrote:yup, talents is the way to go.

TalentBuffSelf works only if you want the NPC to use an item that's recognized as protective or enhancing. It is not a correct general answer to the question, "How can I make an NPC use an item" because it only works on a narrow range of items, which does not include e.g. our custom booze.
Now, you can edit the script x0_i0_talent so that all our custom booze is viewed as protective or enhancing items, but this will then break the utility of TalentBuffSelf for other purposes - because then if you want an NPC to actually buff itself using a potion, it might drink custom booze instead. So tweaking the core AI to allow this to work will break the core AI in undesirable ways.
TalentAdvancedBuff works with spellcasting instead of items, and has the same sorts of restrictions as TalentBuffSelf anyhow.
It's a bit stupid, but I don't know of any generic way to simply make an NPC use an item.
- Aloro
Aleksandr Solzhenitsyn wrote:The meaning of earthly existence lies, not as we have grown used to thinking, in prosperity, but in the development of the soul.
- Sindol
- Team Member; Retired with Honors
- Posts: 6479
- Joined: Mon Jan 06, 2003 4:23 pm
- Location: Nijmegen - Netherlands (GMT+1)
- Contact:
I think just plonking things like booze under the SelfHealing or SelfBuff talents isn't really going to cut it. As far as I can see atm there's no conceivable way to do this nicely. Maybe I'll come up with an ugly fix though. It's getting to be a very complicated problem, where I had initialy suspected a really simple solution. Intriguing.
So much fun,
yet so little time to enjoy it.
- Sindol
yet so little time to enjoy it.
- Sindol
- PlasmaJohn
- CCC / Release Admin
- Posts: 9010
- Joined: Fri Dec 26, 2003 10:37 pm
- Timezone: US/Eastern
- Location: Negaria
- Contact:
Unfortunately I don't think anyone's actually written this feat.For Unique Power and scripted Activate Items, you could add a custom NPC feat via a hak pack, let's call it Activate Item. You could then give that feat to your NPC and give them an item.
When it comes time to use the item, you could set a variable on the creature that holds a reference to the item you want activated.
Next, you'd tell the NPC to use the feat with ActionUseFeat. If your item's action needs a target, then you specify it to ActionUseFeat, if not you could always use OBJECT_SELF or OBJECT_INVALID.
That should call the script for the feat. You'd want to write the script for the feat so that it gets the item to activate off the creature, the target object from ActionUseFeat's second paramater, then gets the target's location, and uses those to construct an EventActivateItem even.
Finally, your script calls SignalEvent to send that event to the module.
The above should run the custom code in your module to fire the unique power or activate item power on your item.

But... maybe it would be worth it to add into a future hak? There sure seem like there's a lot of custom items in Avlis, and writing a feat like that would give an NPC access to all of them.
I don't know, I've actually never written a custom feat before, and certainly not one to suggest what you talented team members should be doing with their time! Just wanted you to be aware of this solution that was suggested.


Ua mau ke ea o ka ina i ka pono.