//:://///////////////////////////////////////////// //:: Example Item Event Script //:: x2_it_example //:: Copyright (c) 2003 Bioware Corp. //::////////////////////////////////////////////// /* This is an example on how to use the new default module events for NWN to have all code concerning one item in a single file. Note that this system only works, if the following events set on your module OnEquip - x2_mod_def_equ OnUnEquip - x2_mod_def_unequ OnAcquire - x2_mod_def_aqu OnUnAcqucire - x2_mod_def_unaqu OnActivate - x2_mod_def_act */ //::////////////////////////////////////////////// //:: Created By: Georg Zoeller //:: Created On: 2003-09-10 //::////////////////////////////////////////////// #include "prc_inc_spells" #include "x2_inc_switches" void main() { int nEvent =GetUserDefinedItemEventNumber(); object oPC; object oItem; //SendMessageToPC(GetFirstPC(),IntToString(nEvent)); // * This code runs when the item has the OnHitCastSpell: Unique power property // * and it hits a target(weapon) or is being hit (armor) // * Note that this event fires for non PC creatures as well. if (nEvent ==X2_ITEM_EVENT_ONHITCAST) { oItem = PRCGetSpellCastItem(); // The item casting triggering this spellscript object oSpellOrigin = OBJECT_SELF ; object oSpellTarget = PRCGetSpellTargetObject(); oPC = OBJECT_SELF; } // * This code runs when the Unique Power property of the item is used // * Note that this event fires PCs only else if (nEvent == X2_ITEM_EVENT_ACTIVATE) { oPC = GetItemActivator(); oItem = GetItemActivated(); } // * This code runs when the item is equipped // * Note that this event fires PCs only else if (nEvent ==X2_ITEM_EVENT_EQUIP) { oPC = GetPCItemLastEquippedBy(); oItem = GetPCItemLastEquipped(); int npallevel = GetLevelByClass(CLASS_TYPE_PALADIN, oPC) + GetLevelByClass(CLASS_TYPE_DIVINE_CHAMPION, oPC) + GetLevelByClass(CLASS_TYPE_KNIGHT_CHALICE, oPC) + GetLevelByClass(CLASS_TYPE_SOLDIER_OF_LIGHT, oPC); int nUMD = d20(1) + GetSkillRank(SKILL_USE_MAGIC_DEVICE, oPC) - 20; if (GetAlignmentGoodEvil(oPC) != ALIGNMENT_GOOD) { if (!GetIsSkillSuccessful(oPC, SKILL_USE_MAGIC_DEVICE, 30)) nUMD = 0; } if (nUMD > npallevel) npallevel = nUMD; if (npallevel > 0) { itemproperty ipAdd; ipAdd = ItemPropertyEnhancementBonus(5); IPSafeAddItemProperty(oItem, ipAdd); ipAdd = ItemPropertyCastSpell(IP_CONST_CASTSPELL_GREATER_DISPELLING_7, IP_CONST_CASTSPELL_NUMUSES_UNLIMITED_USE); if (npallevel > 11) ipAdd = ItemPropertyCastSpell(IP_CONST_CASTSPELL_GREATER_DISPELLING_15, IP_CONST_CASTSPELL_NUMUSES_UNLIMITED_USE); IPSafeAddItemProperty(oItem, ipAdd); switch ( npallevel ) { case 12: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_12); IPSafeAddItemProperty(oItem, ipAdd); break; case 13: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_12); IPSafeAddItemProperty(oItem, ipAdd); break; case 14: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_14); IPSafeAddItemProperty(oItem, ipAdd); break; case 15: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_14); IPSafeAddItemProperty(oItem, ipAdd); break; case 16: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_16); IPSafeAddItemProperty(oItem, ipAdd); break; case 17: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_16); IPSafeAddItemProperty(oItem, ipAdd); break; case 18: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_18); IPSafeAddItemProperty(oItem, ipAdd); break; case 19: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_18); IPSafeAddItemProperty(oItem, ipAdd); break; case 20: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_20); IPSafeAddItemProperty(oItem, ipAdd); break; case 21: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_20); IPSafeAddItemProperty(oItem, ipAdd); break; case 22: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_22); IPSafeAddItemProperty(oItem, ipAdd); break; case 23: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_22); IPSafeAddItemProperty(oItem, ipAdd); break; case 24: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_24); IPSafeAddItemProperty(oItem, ipAdd); break; case 25: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_24); IPSafeAddItemProperty(oItem, ipAdd); break; case 26: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_26); IPSafeAddItemProperty(oItem, ipAdd); break; case 27: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_26); IPSafeAddItemProperty(oItem, ipAdd); break; case 28: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_28); IPSafeAddItemProperty(oItem, ipAdd); break; case 29: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_28); IPSafeAddItemProperty(oItem, ipAdd); break; case 30: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_30); IPSafeAddItemProperty(oItem, ipAdd); break; case 31: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_30); IPSafeAddItemProperty(oItem, ipAdd); break; default: ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_10); IPSafeAddItemProperty(oItem, ipAdd); break; } if (npallevel > 31) { ipAdd = ItemPropertyBonusSpellResistance(IP_CONST_SPELLRESISTANCEBONUS_32); IPSafeAddItemProperty(oItem, ipAdd); } ipAdd = ItemPropertyVisualEffect(ITEM_VISUAL_HOLY); IPSafeAddItemProperty(oItem, ipAdd); ipAdd = ItemPropertyLight(IP_CONST_LIGHTBRIGHTNESS_BRIGHT, IP_CONST_LIGHTCOLOR_WHITE); IPSafeAddItemProperty(oItem, ipAdd); } } // * This code runs when the item is unequipped // * Note that this event fires PCs only else if (nEvent ==X2_ITEM_EVENT_UNEQUIP) { oPC = GetPCItemLastUnequippedBy(); oItem = GetPCItemLastUnequipped(); IPRemoveAllItemProperties(oItem, DURATION_TYPE_PERMANENT); itemproperty ipAdd; ipAdd = ItemPropertyEnhancementBonus(2); IPSafeAddItemProperty(oItem, ipAdd); } // * This code runs when the item is acquired // * Note that this event fires PCs only else if (nEvent == X2_ITEM_EVENT_ACQUIRE) { oPC = GetModuleItemAcquiredBy(); oItem = GetModuleItemAcquired(); } // * This code runs when the item is unaquire d // * Note that this event fires PCs only else if (nEvent == X2_ITEM_EVENT_UNACQUIRE) { oPC = GetModuleItemLostBy(); oItem = GetModuleItemLost(); } //* This code runs when a PC or DM casts a spell from one of the //* standard spellbooks on the item else if (nEvent == X2_ITEM_EVENT_SPELLCAST_AT) { oPC = GetLastSpellCaster(); oItem = PRCGetSpellTargetObject(); } }