//:://///////////////////////////////////////////// //:: 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(); AssignCommand(oPC, ActionStartConversation(oPC, "dye_dyekit", TRUE, FALSE)); } // * 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(); } // * 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(); } // * 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(); } }