/*#include "craft_itemprop"
#include "x4_inc_functions"

void main()
{
     object oPC = GetPCSpeaker();
     //Place any items in the main hand or the off-hand in the inventory
     object oCopied;
     int nCursed;
     if (GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC) != OBJECT_INVALID)
        {
            nCursed = GetItemCursedFlag(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC));
            oCopied = CopyItem(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC), oPC, TRUE);
            if (oCopied != OBJECT_INVALID) DestroyObject(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC));
            if (nCursed == TRUE) SetItemCursedFlag(oCopied, TRUE);
            nCursed = FALSE;
        }
     if (GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC) != OBJECT_INVALID)
        {
            nCursed = GetItemCursedFlag(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC));
            oCopied = CopyItem(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC), oPC, TRUE);
            if (oCopied != OBJECT_INVALID) DestroyObject(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC));
            if (nCursed == TRUE) SetItemCursedFlag(oCopied, TRUE);
            nCursed = FALSE;
        }
     //The end of this chunk of code

        object oItem = GetFirstItemInInventory(oPC);
        string sName = GetLastPCChatMessage(oPC);
        if (sName == "") return;
        while (GetIsObjectValid(oItem))
        {
        if (GetLocalInt(oItem, "Prototype") == TRUE)
        {
        SetName(oItem, sName);
        return;
        }
        oItem = GetNextItemInInventory(oPC);
        }
}   */


#include "x2_inc_itemprop"
#include "x4_inc_functions"

//This is actually the main function.
void script(object oItem, object oPC)
{
     string sName = GetLastPCChatMessage(oPC);
     sName = ColorString(sName, 64, 224, 208);
     AssignCommand(oPC, ActionUnequipItem(oItem));
     itemproperty ipAdd;
     ipAdd = ItemPropertyLimitUseByRace(RACIAL_TYPE_OOZE);
     DelayCommand(0.1, IPSafeAddItemProperty(oItem, ipAdd));
     SetItemCursedFlag(oItem, TRUE);
     SetName(oItem, sName);
     return;
}

void main()
{
     object oPC = GetPCSpeaker();
     int nSlot = 0;
     object oItem;

     //Check if the item being crafted is equipped
     while (nSlot < 18)
     {
     oItem = GetItemInSlot(nSlot, oPC);
     if (GetLocalInt(oItem, "Prototype") == TRUE) {script(oItem, oPC); return; }
     nSlot++;
     }
     //If the item is not equipped, search for it in the inventory
     oItem = GetFirstItemInInventory(oPC);
     while (GetIsObjectValid(oItem))
     {
     if (GetLocalInt(oItem, "Prototype") == TRUE) {script(oItem, oPC); return; }
     oItem = GetNextItemInInventory(oPC);
     }
}