Page 1 of 1

Copy Object

Posted: Thu Aug 21, 2003 5:37 pm
by Jeffi0
Seems only to work once. I have an object, and when a conversation is started with a certain NPC that object is copied into the PC's inventory. However, once the PC completes the quest and the copied item in the PC's inventory is destroyed, the PC cannot get the item again. The conversation and the rest of the script goes as normal, but the object doesn't copy into the PC's inventory. :( Is there something about CopyObject that I don't know about?

Posted: Thu Aug 21, 2003 6:01 pm
by Neve
Try CreateObject and DestroyObject instead. If you use the object only to check wether a quest is being done, you should check the function GetLocalInt and SetLocalInt. That way you don't add junk into the inventory, but use imaginary numbers =)

(Doesn't this thread belong in the Scripting forum though ?)

Posted: Thu Aug 21, 2003 6:16 pm
by Jeffi0
Oops, I thought this was the scripting forum. Misclick. :shock:

I can't use CreateObject & DestoryObject because that doesnt get it into the PC's inventory, I'd have to do another CopyObject anyway. I could do that, but I think I tried it and found a reason that I couldn't do it, which I can't remember right now. I'll try it again. I'd like to use CreateItemOnObject, but that doesn't let you change the tag of the new object, which I need to do. :(

Posted: Thu Aug 21, 2003 6:19 pm
by Jeff
Can we see the code in question?

Posted: Thu Aug 21, 2003 7:03 pm
by Neve
Jeffi0 wrote:Oops, I thought this was the scripting forum. Misclick. :shock:

I can't use CreateObject & DestoryObject because that doesnt get it into the PC's inventory, I'd have to do another CopyObject anyway. I could do that, but I think I tried it and found a reason that I couldn't do it, which I can't remember right now. I'll try it again. I'd like to use CreateItemOnObject, but that doesn't let you change the tag of the new object, which I need to do. :(
Hmm... If the new object is only temporary you can give it a Local Int. Localints are as easy to check as Tags, I'm not sure wether it's possible to change an object's tag...

object oItem = GetItemPosessedBy(oPlayer, "ItemTag");

//To create a "Tag"
SetLocalInt(oItem, "TempTag", <Put value here>);

//To read a "Tag"
GetLocalInt(oItem, "TempTag");

You can search for the object with that temporary tag aswell :

object FindItem(oPlayer){
oItem = GetFirstItemInInventory(oPlayer);
while(oItem != OBJECT_INVALID){
if(GetTag(oItem, "TempTag")) return oItem
oItem = GetNextItemInInventory(oPlayer);
}
return OBJECT_INVALID;
}