Updated to PRC8. Further function integration. Fixed NPC onDeath script. Full compile. Updated release archive.
223 lines
8.1 KiB
Plaintext
223 lines
8.1 KiB
Plaintext
//Script Name:
|
||
//////////////////////////////////////////
|
||
// Created By: Genisys (Guile)
|
||
// Created On: 8/13/08
|
||
//
|
||
// (TABASED ITEM SCRIPT TEMPLATE)
|
||
/////////////////////////////////////////
|
||
/*
|
||
This template is used for ALL events which
|
||
happen for an item which has the same
|
||
tagname as the name of this script.
|
||
(You need to name this script the item's tagname)
|
||
|
||
Every event below will fire when the event
|
||
happens, ie. If the player activates the item
|
||
the X2_ITEM_EVENT_ACTIVATE: script code will run.
|
||
|
||
*/
|
||
////////////////////////////////////////
|
||
#include "x2_inc_switches"
|
||
#include "prc_inc_spells"
|
||
|
||
|
||
//Required Include For Color Messages(Read include to learn more)
|
||
#include "gen_inc_color"
|
||
|
||
//Main Script
|
||
void main()
|
||
{
|
||
|
||
//All Major Variables Declared (Commonly used variables as well)
|
||
|
||
int nEvent = GetUserDefinedItemEventNumber(); //Which event triggered this
|
||
object oPC; //The player character using the item
|
||
object oItem; //The item being used
|
||
object oSpellOrigin; //The origin of the spell
|
||
object oSpellTarget; //The target of the spell
|
||
int iSpell; //The Spell ID number
|
||
object oTarget; //Define oTarget below
|
||
object oObject; //Define oObject below
|
||
int nInt; //A commonly used intergal (Must be defined)
|
||
int nLvl; //Commonly used intergal for levels (ie. GetHitDice(oTarget); etc.)
|
||
string sTag; //Used to define a tagname of something
|
||
string sResref; //Used to define a resref name of something
|
||
string sMsg; //Used to define a message
|
||
effect eEffect; //Used to define an effect to be applied to an object or location
|
||
effect eVis; //Used to define a visual effect to be applied to an object or location
|
||
location lTarget; //The Target Location of the PC ONLY! (USE - Getlocation(oPC);)
|
||
location lway; //The Target location for the Activated Item's Target only! (See below)
|
||
|
||
//Get the restart time on the module...
|
||
int nHr = GetLocalInt(GetModule(), "HOURS_LEFT");
|
||
int nMin = GetLocalInt(GetModule(), "MINS_LEFT");
|
||
int nResetMin = GetLocalInt(GetModule(), "RESET_MIN");
|
||
|
||
//Calculate time for DM Message..
|
||
int nSec = GetLocalInt(GetModule(), "MODULE_BEAT");
|
||
int nTotalMin = nSec/60;
|
||
int nTimeTillReset = nResetMin - nTotalMin;
|
||
int nHrs;
|
||
if(nTotalMin>=60)
|
||
{nHrs = nTotalMin /60;}
|
||
else
|
||
{nHrs = 0;}
|
||
|
||
string sDMTime;
|
||
sDMTime = "<c <20><>>";
|
||
sDMTime += "The Module has been up: ";
|
||
sDMTime += IntToString(nHrs);
|
||
sDMTime += " Hrs. & ";
|
||
sDMTime += IntToString(nTotalMin);
|
||
sDMTime += " Minutes.";
|
||
|
||
|
||
string sTime;
|
||
sTime = "<c <20><>>"; //cyan
|
||
sTime += "Server will Restart in: ";
|
||
sTime += IntToString(nHr);
|
||
sTime += " Hours & ";
|
||
sTime += IntToString(nMin);
|
||
sTime += " Minutes.";
|
||
sTime += "</c>";
|
||
|
||
|
||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||
//Set the return value for the item event script
|
||
// * X2_EXECUTE_SCRIPT_CONTINUE - continue calling script after executed script is done
|
||
// * X2_EXECUTE_SCRIPT_END - end calling script after executed script is done
|
||
int nResult = X2_EXECUTE_SCRIPT_END;
|
||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||
|
||
//Deterimine which event has fired for the item...
|
||
switch (nEvent)
|
||
{
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
///////The Item has the property: On-Hit Cast Spell: Unique Power/////////
|
||
|
||
case X2_ITEM_EVENT_ONHITCAST:
|
||
// * This code runs when the item has the 'OnHitCastSpell: Unique power' property
|
||
// * and it hits a target(if it is a weapon) or is being hit (if it is a piece of armor)
|
||
// * Note that this event fires for non PC creatures as well.
|
||
|
||
oItem = PRCGetSpellCastItem(); // The item triggering this spellscript
|
||
oPC = OBJECT_SELF; // The player triggering it
|
||
oSpellOrigin = OBJECT_SELF ; // Where the spell came from
|
||
oSpellTarget = PRCGetSpellTargetObject(); // What the spell is aimed at
|
||
|
||
//Your code goes here
|
||
|
||
break;
|
||
|
||
///////////////////////////////////////////////////////////////////////////
|
||
/////////////Cast Spell: Unique Power /or/ Activate Item//////////////////
|
||
|
||
//I seperated this cause it's more commonly used..
|
||
case X2_ITEM_EVENT_ACTIVATE:
|
||
// * This code runs when the Unique Power property of the item is used
|
||
// * or the item is activated. Note that this event fires for PCs only.
|
||
|
||
oPC = GetItemActivator(); // The player who activated the item
|
||
oItem = GetItemActivated(); // The item that was activated
|
||
oTarget = GetItemActivatedTarget(); //The target of the item's power
|
||
lway = GetItemActivatedTargetLocation(); //To get the location of the target!
|
||
|
||
if(GetIsDM(oPC))
|
||
{
|
||
FloatingTextStringOnCreature(sDMTime, oPC, TRUE);
|
||
DelayCommand(1.0, FloatingTextStringOnCreature(sTime, oPC, TRUE));
|
||
}
|
||
else
|
||
{
|
||
FloatingTextStringOnCreature(sTime, oPC, TRUE);
|
||
DelayCommand(0.5, FloatingTextStringOnCreature(sTime, oPC, TRUE));
|
||
DelayCommand(1.0, FloatingTextStringOnCreature(sTime, oPC, TRUE));
|
||
}
|
||
|
||
//Your code goes here
|
||
|
||
break;
|
||
|
||
///////////////////////////////////////////////////////////////////////////
|
||
///////////When the User Equips this item////////////////////////////////
|
||
|
||
case X2_ITEM_EVENT_EQUIP:
|
||
// * This code runs when the item is equipped
|
||
// * Note that this event fires for PCs only
|
||
|
||
oPC = GetPCItemLastEquippedBy(); // The player who equipped the item
|
||
oItem = GetPCItemLastEquipped(); // The item that was equipped
|
||
|
||
//Your code goes here
|
||
|
||
break;
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
/////////////When the User Unequips this item//////////////////////////////
|
||
|
||
case X2_ITEM_EVENT_UNEQUIP:
|
||
// * This code runs when the item is unequipped
|
||
// * Note that this event fires for PCs only
|
||
|
||
oPC = GetPCItemLastUnequippedBy();// The player who unequipped the item
|
||
oItem = GetPCItemLastUnequipped(); // The item that was unequipped
|
||
|
||
//Your code goes here
|
||
|
||
break;
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
////////////Everytime ANYONE Acquires this item////////////////////////////
|
||
|
||
case X2_ITEM_EVENT_ACQUIRE:
|
||
// * This code runs when the item is acquired
|
||
// * Note that this event fires for PCs only
|
||
|
||
oPC = GetModuleItemAcquiredBy(); // The player who acquired the item
|
||
oItem = GetModuleItemAcquired(); // The item that was acquired
|
||
|
||
//Your code goes here
|
||
|
||
break;
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
//////////Everytime ANYONE Loses this item/////////////////////////////////
|
||
|
||
case X2_ITEM_EVENT_UNACQUIRE:
|
||
// * This code runs when the item is unacquired
|
||
// * Note that this event fires for PCs only
|
||
|
||
oPC = GetModuleItemLostBy(); // The player who dropped the item
|
||
oItem = GetModuleItemLost(); // The item that was dropped
|
||
|
||
//Your code goes here
|
||
|
||
break;
|
||
|
||
////////////////////////////////////////////////////////////////////////////
|
||
/////Everytime ANYONE Cast a spell at this item////////////////////////////
|
||
|
||
case X2_ITEM_EVENT_SPELLCAST_AT:
|
||
//* This code runs when a PC or DM casts a spell from one of the
|
||
//* standard spellbooks on the item
|
||
|
||
oPC = OBJECT_SELF; // The player who cast the spell
|
||
oItem = PRCGetSpellTargetObject();// The item targeted by the spell
|
||
iSpell = PRCGetSpellId(); // The id of the spell that was cast
|
||
// See the list of SPELL_* constants
|
||
|
||
//Your code goes here
|
||
|
||
//Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
|
||
//X2_EXECUTE_SCRIPT_END if you want to prevent the spell that was
|
||
//cast on the item from taking effect
|
||
nResult = X2_EXECUTE_SCRIPT_CONTINUE;
|
||
break;
|
||
}
|
||
|
||
//Pass the return value back to the calling script
|
||
SetExecutedScriptReturnValue(nResult);
|
||
}
|
||
|