Sign in to follow this  
Salk

Help with CreateItemOnObject()

Recommended Posts

Hello!

I would like for a creature to wear the armor that another creature is currently wearing (in this case, Carth) so I was thinking of this:

object oArmor = GetItemInSlot(INVENTORY_SLOT_BODY, GetObjectByTag("Carth"));

but CreateItemOnObject() requires the item's TemplateStrRef rather than the object so my question is: how do I make it work? GetTag() is not the right function and neither is GetName().

Thanks for the assistance!

Share this post


Link to post
Share on other sites

There is no function to get the ResRef. The game doesn't store that value. That's why vanilla items typically use the same value for both Tag and ResRef, so yes, using GetTag is the right function. Unless he is wearing an item from a mod, in which case all bets are off.

  • Thanks 1

Share this post


Link to post
Share on other sites

There are, however, some items for which the two don't match. These are the ones I know of, in K2:

g_danceroutfit / DancersOutfit
a_khoonda / KhoondaMilitiaArmor

Only thing that can be done for those is to add an if statment to take care of the exceptions.

Share this post


Link to post
Share on other sites

Indeed it seems like this solution may work for all the vanilla items. I made a quick search and it seems the only difference between the Tag and the TemplateResRef is upper and lower case for the same string.

I will have to look for possible exception, as suggested by JC but overall it should be alright.

I had also another idea that worked fine but wouldn't solve the problem: it is possible to use the EffectDisguise() but even in this case it would not produce a creature wearing the equipment of the party NPC.

Cheers!

Share this post


Link to post
Share on other sites
Just now, Salk said:

I made a quick search and it seems the only difference between the Tag and the TemplateResRef is upper and lower case for the same string.

If I recall correctly, GetTag() always returns a lowercase string anyway.

  • Like 1

Share this post


Link to post
Share on other sites

That does mean it probably won't work on Linux/Mac, since they are case-sensitive OSs. Although the actual filenames are all lowercase aren't they? So that should be fine in that case.

Also, as to ones not matching, yeah, a lot of the unique/quest-related items don't use matching Tags/ResRefs. Maybe your next coding project can be to browse every UTI in both games and compile a database of mismatches.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this