//
// (NOTE: This is a template script, save it under a new name FIRST)
////////////////////////////////////////////////////////////////////////////////
// Created by: The Krit
// Created on: 04-03-2010
// Modified by: Genisys / Guile
// Modified on: 04-30-2011
///////////////////////////////////////////////////////////////////////////////
// This is intended to be a starting point for writing an item's tag-based script.
// Copy this to a script whose name is the tag of the item in question.
// Edit the event handlers (scroll down to find them) as desired.
// -----------------------------------------------------------------------------
//Required Include (DO NOT TOUCH!)
#include "x2_inc_switches"
//------------------------------------------------------------------------------
// Delcare ALL Common Integers / Floats / Strings
// NOTE: These can be used anywhere in any of the Prototypes
// By declaring at the top of the script they do not need to be delcared anywhere else!
int nInt, i, nGold, nXP, nclass, nCon; // nCon = nConstant
float fDelay, fTime;
string sName, sTag, sMsg, sResref;
//Add more if needed!
// -----------------------------------------------------------------------------
// Event handlers
// -----------------------------------------------------------------------------
// This second part is where you add your desired functionality. Each event
// has its own function with relavant information passed as parameters.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// oItem was acquired (by a PC or an NPC).
// Run by the module.
void OnAcquire(object oItem, object oAcquiredBy, object oTakenFrom, int nStackSize)
{
// Enter code to execute when this event happens
}
// -----------------------------------------------------------------------------
// oItem was activated ("activate item" or "unique power").
// Run by the module.
void OnActivate(object oItem, object oActTarget, location lActTarget, object oActivator)
{
// Enter code to execute when this event happens
}
// -----------------------------------------------------------------------------
// oItem was equipped by a PC.
// Run by the module.
void OnEquip(object oItem, object oEquippedBy)
{
object oWay = GetWaypointByTag("ec_caster_way");
object oEC = GetNearestObjectByTag("eff_caster", oWay);
effect eMas = EffectModifyAttacks(1);
eMas = SupernaturalEffect(eMas);
effect eVis = EffectVisualEffect(VFX_DUR_IOUNSTONE_YELLOW);
if(oWay == OBJECT_INVALID)
{
FloatingTextStringOnCreature("ERROR, notify DMs that the waypoint for this item is missing!", oEquippedBy, TRUE);
return;
}
if(oEC == OBJECT_INVALID)
{
oEC = CreateObject(OBJECT_TYPE_PLACEABLE, "eff_caster", GetLocation(oWay), FALSE);
}
AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, eMas, oEquippedBy));
AssignCommand(oEC, ApplyEffectToObject(
DURATION_TYPE_PERMANENT, eVis, oEquippedBy));
}
// -----------------------------------------------------------------------------
// oItem is a weapon that just hit a target, or it is the armor of someone who
// was just hit by someone else's weapon.
// Run by the caster.
void OnHit(object oItem, object oHitTarget, object oCaster)
{
// Enter code to execute when this event happens
}
// -----------------------------------------------------------------------------
// Someone cast a spell at oItem.
// Run by the caster.
int OnSpellCast(object oItem, int nSpell, object oCaster)
{
// Enter code to execute when this event happens
return FALSE; //Necessary return (Do this !)
}
// -----------------------------------------------------------------------------
// oItem was unacquired/lost (by a PC or NPC).
// Run by the module.
void OnUnacquire(object oItem, object oLostBy)
{
// Enter code to execute when this event happens
}
// -----------------------------------------------------------------------------
// oItem was unequipped by a PC.
// Run by the module.
void OnUnequip(object oItem, object oUnequippedBy)
{
//Remove Speed Increase
object oPC = oUnequippedBy;
effect e = GetFirstEffect(oPC);
string sTag;
while(GetIsEffectValid(e))
{
sTag = GetTag(GetEffectCreator(e)) ;
if(sTag == "eff_caster")
{
FloatingTextStringOnCreature("Effect Removed!", oPC, FALSE);
RemoveEffect(oPC, e);
}
e = GetNextEffect(oPC);
}
}
//////////////////////////////////////////////////////////////////////////////
// ##### WARNINING:: DON'T TOUCH ANYTHING BELOW THIS LINE!!! #### ///////////
////////////////////////////////////////////////////////////////////////////
// The main function.
void main()
{
int nEvent = GetUserDefinedItemEventNumber();
// Spells might continue to their spell scripts. All other events are
// completely handled by this script.
if ( nEvent != X2_ITEM_EVENT_SPELLCAST_AT )
SetExecutedScriptReturnValue();
// Determine which event triggered this script's execution.
switch ( nEvent )
{
// Item was acquired.
case X2_ITEM_EVENT_ACQUIRE:
OnAcquire(GetModuleItemAcquired(), GetModuleItemAcquiredBy(),
GetModuleItemAcquiredFrom(), GetModuleItemAcquiredStackSize());
break;
// Item was activated ("activate item" or "unique power").
case X2_ITEM_EVENT_ACTIVATE:
OnActivate(GetItemActivated(), GetItemActivatedTarget(),
GetItemActivatedTargetLocation(), GetItemActivator());
break;
// Item was equipped by a PC.
case X2_ITEM_EVENT_EQUIP:
OnEquip(GetPCItemLastEquipped(), GetPCItemLastEquippedBy());
break;
// Item is a weapon that just hit a target, or it is the armor of someone
// who was just hit.
case X2_ITEM_EVENT_ONHITCAST:
OnHit(GetSpellCastItem(), GetSpellTargetObject(), OBJECT_SELF);
break;
// A PC (or certain NPCs) cast a spell at the item.
case X2_ITEM_EVENT_SPELLCAST_AT:
if ( OnSpellCast(GetSpellTargetObject(), GetSpellId(), OBJECT_SELF) )
SetExecutedScriptReturnValue();
break;
// Item was unacquired.
case X2_ITEM_EVENT_UNACQUIRE:
OnUnacquire(GetModuleItemLost(), GetModuleItemLostBy());
break;
// Item was unequipped by a PC.
case X2_ITEM_EVENT_UNEQUIP:
OnUnequip(GetPCItemLastUnequipped(), GetPCItemLastUnequippedBy());
break;
}
}