| Author: | Keallen |
| Author Website: | n/a |
| Script Name: | Cursed Items |
| Description: | Simulates cursed items by making an item which looks benign, but then cannot be unequipped. |
| Instructions on Use: | There are two possible methods: Items which equip themselves
automatically when acquired, and items which don't reveal themselves until
they are equipped. Both items will, once equipped, stay that way until
programmatically un-cursed. Some setup is required. You'll need to make two items: One is the actual cursed item, and the other is what I call the "bait" item. Since inspection shows negative effects as well as positive, this is required to prevent things from being seen even before they're picked up. The bait can be whatever you want, but for continuity should look exactly the same as the cursed item. If it's going to be an on-equip curse, make sure you make it something worth equipping For on-acquire curses, you have to script in OnAcquireItem and OnHeartBeat. The on-equip curse requires only the OnHeartBeat. All scripts should be for the module as a whole. The following scripts show a cursed ring of the on-acquire variety, and an on-equip cursed dagger. The INVENTORY_SLOT
constants should be a single word, obviously - had to break them up for the
system. |
Script 1 (OnAquireItem):
*NOTE: This script is not required if the item is only going to
initiate the curse when the PC equips the item.
| // Cursed item handling, initial trigger. // Kevin E. Allen // keallen@mail.stic.net // 11 July, 2002 void main() { // Make sure to use the created object tag here, and the cursed item's // blueprint ResRef for the create object item = GetModuleItemAcquired(); if (GetTag(item) == "CursedRingBait") { object oPC = GetItemPossessor(item); DestroyObject(item); item = CreateItemOnObject("CursedRing", oPC, 1); SetIdentified(item, TRUE); AssignCommand(oPC, ActionEquipItem(item, INVENTORY_ SLOT_ RIGHTRING)); SetLocalObject(item, "Cursed To", oPC); } } |
Script 2 (OnHeartBeat):
// Heartbeat script for maintenance of cursed items. // Kevin E. Allen // keallen@mail.stic.net // 11 July, 2002 void main() { // This will maintain an on-pickup cursed item. Make sure that you use // the in-game tag for the GetObjectByTag, and the Blueprint ResRef for // the CreateItemOnObject. Also, customize the INVENTORY_SLOT settings // for where the item should remain stuck. object ring = GetObjectByTag("CursedRing"); object oPC = GetLocalObject(ring, "Cursed To"); if (GetIsObjectValid(oPC)) { object check = GetItemInSlot(INVENTORY_SLOT_ RIGHTRING, oPC); if (check != ring) { DestroyObject(ring); ring = CreateItemOnObject("CursedRing", oPC, 1); AssignCommand(oPC, ActionEquipItem(ring, INVENTORY_SLOT_ RIGHTRING)); SetLocalObject(ring, "Cursed To", oPC); SetIdentified(ring, TRUE); } } // This will handle an on-equip cursed item. Make sure that you use // the in-game tag for the GetObjectByTag, and the Blueprint ResRef for // the CreateItemOnObject. Also, customize the INVENTORY_SLOT settings // for where the item should remain stuck. object dagger = GetObjectByTag("CursedDagger"); oPC = GetLocalObject(dagger, "Cursed To"); if (GetIsObjectValid(oPC)) { // This returns the item to the character if they've unequipped or // dropped it. object check = GetItemInSlot(INVENTORY_SLOT_ RIGHTHAND, oPC); if (check != dagger) { DestroyObject(dagger); dagger = CreateItemOnObject("daggerofslayi001", oPC, 1); AssignCommand(oPC, ActionEquipItem(dagger, INVENTORY_SLOT_ RIGHTHAND)); SetLocalObject(dagger, "Cursed To", oPC); SetIdentified(dagger, TRUE); } } else { // This watches for the initial equipping of the item object daggerbait = GetObjectByTag("CursedDaggerBait"); oPC = GetItemPossessor(daggerbait); if (GetIsObjectValid(oPC)) { object checkr = GetItemInSlot(INVENTORY_SLOT_ RIGHTHAND, oPC); object checkl = GetItemInSlot(INVENTORY_SLOT_ LEFTHAND, oPC); if (checkr == daggerbait || checkl == daggerbait) { object newdagger = CreateItemOnObject("daggerofslayi001", oPC, 1); SendMessageToPC(oPC, "Dagger: " + GetName(newdagger)); AssignCommand(oPC, ActionEquipItem(newdagger, INVENTORY_SLOT_ RIGHTHAND)); SetLocalObject(newdagger, "Cursed To", oPC); SetIdentified(newdagger, TRUE); DestroyObject(daggerbait); } } } } |