I was trying something more simple, to see if it works and to get used to the functions. But still, I had some problems.
First i am trying to discover in what slot the equiped weapon will be (left or rigth hand). But i couldnt get this info, since it seems the weapon wasnt equiped yet.
then, i try to create the template item using CreateItemOnObject, but it always fails to create the item, and im sure the blueprint is right.
Here is my code:
void main(){
object pc = GetPCItemLastEquippedBy();
object item = GetPCItemLastEquipped();
int slot; //what i really wanted was a function like getItemSlotInInventory(object item, object pc) but i couldnt find it
if (GetItemInSlot(INVENTORY_SLOT_CWEAPON_R,pc) == item){
slot = INVENTORY_SLOT_CWEAPON_R;
}else if (GetItemInSlot(INVENTORY_SLOT_CWEAPON_L,pc) == item){
slot = INVENTORY_SLOT_CWEAPON_L;
}else if (GetItemInSlot(INVENTORY_SLOT_CWEAPON_B,pc) == item){ //WTF is CWEAPON_B??
slot = INVENTORY_SLOT_CWEAPON_B;
}else {
slot = INVENTORY_SLOT_CWEAPON_R; //it always come here, leading me to believe the weapon was not equiped yet
}
object correspItem = CreateItemOnObject("mace_magical",pc); //my intent here is to create my template mace with the magical effect in pc' inventory
if (correspItem == OBJECT_INVALID) // but it fails...
SendMessageToPC(pc, "error creating object");
.
. //copy appearance....
.
DestroyObject(item);
ActionEquipItem(correspItem,slot);
}