PDA

View Full Version : [K1]Scripting help - inventory


jimbo32
02-05-2007, 02:24 PM
Hey everybody,

I'm in the process of creating a recruitment mod, and need some advice.

What I'd like to do is remove an item from the party's inventory using a script attached to dialogue (if that's possible).

This is to simulate "giving" the item to the new recruit, who will be equipped with it when joining.

Any assistance would be appreciated.

stoffe
02-05-2007, 03:06 PM
I'm in the process of creating a recruitment mod, and need some advice.

What I'd like to do is remove an item from the party's inventory using a script attached to dialogue (if that's possible).

This is to simulate "giving" the item to the new recruit, who will be equipped with it when joining.


Do you want to move the item from the party inventory to the new recruit, or do you just want to delete the item from the party inventory? Both are possible to do. If you just want to delete it, you can use a script like this, set as action script on your dialog node:


void main() {
object oItem = GetItemPossessedBy(GetFirstPC(), "TagOfItem");
if (GetIsObjectValid(oItem))
DestroyObject(oItem);
}


Where you change TagOfItem to the Tag of the item you want to remove (this is set in the UTI template).

jimbo32
02-05-2007, 03:22 PM
Thanks a million stoffe. That's just what I need.

Just for future reference, how does the script differ if you actually want to move the item?

stoffe
02-05-2007, 03:37 PM
Just for future reference, how does the script differ if you actually want to move the item?

You'd replace the DestroyObject() line with...

ActionTakeItem(oItem, GetFirstPC());

...provided that the conversation owner is the NPC who should receive the item.