Server Totals
Mikona - (1)
Le'Or - (1)
M'Chek - (1)
Wilderness - (1)
Underdark - (0)
Elysia - (0)
Ferrell - (0)
Deglos - (0)
Visimontium - (0)
Total players: 4
Gallery

Links Menu

Forcing a creature to use an item

Moderators: Nighthawk4, Dungeon Masters

Forcing a creature to use an item

PostAuthor: 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
Deider
Uber Posting Whor3
 
Posts: 7997
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8

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

PostAuthor: 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
Deider
Uber Posting Whor3
 
Posts: 7997
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8

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

PostAuthor: 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
Deider
Uber Posting Whor3
 
Posts: 7997
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8

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

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

PostAuthor: 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
Deider
Uber Posting Whor3
 
Posts: 7997
Images: 3
Joined: Sun May 11, 2003 12:33 pm
Location: California
Timezone: GMT -8

PostAuthor: 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
Sindol
Team Member; Retired with Honors
 
Posts: 6487
Joined: Mon Jan 06, 2003 4:23 pm
Location: Nijmegen - Netherlands (GMT+1)

PostAuthor: 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
PlasmaJohn
Team Member; Retired with Honors; Has a Tom Selleck Stache
 
Posts: 8822
Joined: Fri Dec 26, 2003 10:37 pm
Location: New Eden
Timezone: US/Eastern

PostAuthor: 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
Jordicus
Team Member; Retired with Honors
 
Posts: 8048
Joined: Tue Jan 21, 2003 3:46 pm
Location: Whitehall, PA (GMT -4)

PostAuthor: GG26 » Thu Sep 08, 2005 11:09 pm

griefer!
User avatar
GG26
Scholar of Fools
 
Posts: 327
Joined: Sun Jun 13, 2004 7:59 pm
Location: I quit. It's been fun guys.

PostAuthor: 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.
User avatar
Tigg
Elder Sage
 
Posts: 3491
Joined: Wed Feb 09, 2005 11:18 pm
Location: Into the sunset/Hyboria


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot]