Author Sticky: Post Working Scripts Here
bravesfan Posted: Monday, 22 July 07:24PM
script name: curseditems_oh

what it does: Waits until a PC equips a certain "bait" item and then replaces the item with a cursed item and will not allow the PC to unequip it until the item is removed with a DestroyObject function.

okay now for setup instructions:

1) You need 2 items for this to work, the actual cursed item with the bad properties and a bait item, with properties which will get the PC to equip it.

2) Go through my script and change all the tags to the ones you have set for your items, its pretty straightforward. The only thing that is not a tag is the "cursedarmorofneg" which is the cursed armors resref.

3) Place this in your module's onheartbeat and you should be good to go.

4) To remove the item, just create a basic script that destroys the cursed item.

Ive tested this and it works fine for me, let me know if you encounter any problems...enjoy!


NWScript:
//Cursed Item OnHeartbeat Script

//Author: bravesfan

//This will make a cursed item unable to be unequipped until it is removed

//via scripting. The PC must equip the items before this script takes effect.

//

//Setup:

//In order for this to work correctly, you will need 2 items, one that is the

//"bait" item that does not have the cursed properties, and one that is the

//actual "cursed" item. Remember, the PC has to equip it, so make the bait item

//worth equipping.

//

//Comments or questions can be emailed to tmsaunde@tampabay.rr.com

void main()

{

    object armor = GetObjectByTag("CursedArmor");

    object oPC = GetLocalObject(armor, "CursedTo");

    if (GetIsObjectValid(oPC))

    {

        //this returns the item to the player if the drop or unequip it

        object check = GetItemInSlot(INVENTORY_SLOT_CHEST);

        if(check != armor)

        {

            DestroyObject(armor);

            armor = CreateItemOnObject("cursedarmorofneg", oPC, 1);

            AssignCommand(oPC, ActionEquipItem(armor, INVENTORY_SLOT_CHEST));

            SetLocalObject(armor, "CursedTo", oPC);

            SetIdentified(armor, TRUE);

        }

        else

        {

        //this watches for the initial equiping of the item by the PC

        object oArmorBait = GetObjectByTag("CursedArmorBait");

        oPC = GetItemPossessor(oArmorBait);

        if(GetIsObjectValid(oPC))

        {

            object checkC = GetItemInSlot(INVENTORY_SLOT_CHEST);

            if(checkC == oArmorBait)

            {

                object newarmor = CreateItemOnObject("cursedarmorofneg", oPC, 1);

                SendMessageToPC(oPC, "Armor: " + GetName(newarmor));

                AssignCommand(oPC, ActionEquipItem(newarmor, INVENTORY_SLOT_CHEST));

                SetLocalObject(newarmor, "CursedTo", oPC);

                SetIdentified(newarmor, TRUE);

                DestroyObject(oArmorBait);

            }

        }

    }

}



_________________
Bravesfan

"Normal people ... believe that if it ain't broke, don't fix it. Engineers believe that if it ain't broke, it doesn't have enough features yet."