Forcing a creature to use an item

Moderator: Event DM

Post Reply
User avatar
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

Post by Deider » Thu Sep 08, 2005 4:23 pm

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?
User avatar
TiVO25
Sage
Posts: 1641
Joined: Wed Jun 30, 2004 5:07 am
Location: Arlington, TX. (GMT -5); Dreaming of Austin
Contact:

Post by TiVO25 » Thu Sep 08, 2005 4:42 pm

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?
You can't stop the signal.

"Every calling is great when greatly pursued."
~Oliver Wendell Holmes

Dr. Horrible's Sing-Along Blog
User avatar
Deider
Demigod of Posts
Posts: 13259
Joined: Sun May 11, 2003 12:33 pm
Timezone: GMT -8
Location: California

Post by Deider » Thu Sep 08, 2005 4:59 pm

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?
Yes, you can, but there are drawbacks:

- 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 :(
User avatar
Aloro
Team Member; Retired with Honors
Posts: 12805
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End
Contact:

Post by Aloro » Thu Sep 08, 2005 5:27 pm

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
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.
User avatar
Deider
Demigod of Posts
Posts: 13259
Joined: Sun May 11, 2003 12:33 pm
Timezone: GMT -8
Location: California

Post by Deider » Thu Sep 08, 2005 5:37 pm

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.
User avatar
Krator
Elder Sage
Posts: 4935
Joined: Thu Jun 10, 2004 6:44 pm
Timezone: GMT
Location: Amsterdam

Post by Krator » Thu Sep 08, 2005 5:43 pm

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
User avatar
Aloro
Team Member; Retired with Honors
Posts: 12805
Joined: Sat Dec 28, 2002 5:11 am
Location: Rainbow's End
Contact:

Post by Aloro » Thu Sep 08, 2005 5:53 pm

Krator wrote:yup, talents is the way to go.
Nope. :)

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.
User avatar
Deider
Demigod of Posts
Posts: 13259
Joined: Sun May 11, 2003 12:33 pm
Timezone: GMT -8
Location: California

Post by Deider » Thu Sep 08, 2005 5:56 pm

Yeah, those are the downsides. It worked for the guy on the bioboards because he wanted his NPCs to drink Ultravision pots or something. But it wouldn't work for haste potions, because of what Aloro has mentioned above.
User avatar
Sindol
Team Member; Retired with Honors
Posts: 6479
Joined: Mon Jan 06, 2003 4:23 pm
Location: Nijmegen - Netherlands (GMT+1)
Contact:

Post by Sindol » Thu Sep 08, 2005 9:19 pm

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
User avatar
PlasmaJohn
CCC / Release Admin
CCC / Release Admin
Posts: 9010
Joined: Fri Dec 26, 2003 10:37 pm
Timezone: US/Eastern
Location: Negaria
Contact:

Post by PlasmaJohn » Thu Sep 08, 2005 10:48 pm

mumbles something about LOCAL vars and conditional branches
Yeah, hackish...

How does it vector into x0_i0_talent? Is it possible to add additional talent categories (TALENT_GET_SLOPPY_WASTED)?
Calvin: This is so cool!
Hobbes: This is so stupid.
User avatar
Jordicus
Team Member; Retired with Honors
Posts: 8042
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)
Contact:

Post by Jordicus » Thu Sep 08, 2005 10:54 pm

what does x0_i0_talent look for anyway? a specific set of tags/resrefs?
You see things and you say, "Why?" But I dream things that never were and say, "Why not?" George Bernard Shaw
User avatar
GG26
Scholar of Fools
Posts: 327
Joined: Sun Jun 13, 2004 7:59 pm
Location: I quit. It's been fun guys.

Post by GG26 » Thu Sep 08, 2005 11:09 pm

griefer!
User avatar
Tigg
Elder Sage
Posts: 3486
Joined: Wed Feb 09, 2005 11:18 pm
Location: Into the sunset/Hyboria

Post by Tigg » Thu Sep 08, 2005 11:39 pm

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.
Unfortunately I don't think anyone's actually written this feat. :(

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.
Post Reply