WoR_PRC8/_module/nss/vg_ws_item.nss

168 lines
7.1 KiB
Plaintext
Raw Permalink Normal View History

2025-04-03 11:49:34 -04:00
//Create a potion that has the same tag as this script and give it a unique power self only (single use)
#include "x2_inc_switches"
#include "prc_inc_spells"
const float fSwimTime = 480.0;//<--how long the potion will last
void main()
{
int nEvent = GetUserDefinedItemEventNumber(); //Which event triggered this
object oPC;
object oItem;
object oSpellOrigin;
object oSpellTarget;
location lSpellLocation;
int iSpell;
int nRand;
int nResult = X2_EXECUTE_SCRIPT_END;
effect eEffect;
switch (nEvent)
{
/*
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 = GetSpellCastItem(); // The item triggering this spellscript
oPC = OBJECT_SELF; // The player triggering it
oSpellOrigin = OBJECT_SELF ; // Where the spell came from
oSpellTarget = GetSpellTargetObject(); // What the spell is aimed at
//Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
//X2_EXECUTE_SCRIPT_END if you want to prevent the calling of the
//code after the execute is done
nResult = X2_EXECUTE_SCRIPT_CONTINUE;
break;
*/
case X2_ITEM_EVENT_ACTIVATE:
// * This code runs when the Unique Power property of the item is used
// * Note that this event fires for PCs only
oPC = GetItemActivator(); // The player who activated the item
oItem = GetItemActivated(); // The item that was activated
lSpellLocation = GetItemActivatedTargetLocation();// The target creature
SetLocalInt(oPC, "WSPOTION",TRUE); // Tells the vg_water_enter script the PC has used a potion
SendMessageToPC(oPC,"** Your have grown fin-like features that will help you swim faster. **");
if(GetLocalInt(oPC, "UNDERWATER") == 1)
{
// Remove movement rate decreases
eEffect = GetFirstEffect(oPC);
while(GetIsEffectValid(eEffect))
{
if(GetEffectType(eEffect) == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE)
{
RemoveEffect(oPC, eEffect);
}
eEffect = GetNextEffect(oPC);
}
}
DelayCommand(fSwimTime-10,SendMessageToPC(oPC,"Your swimming potion is about to wear off."));
DelayCommand(fSwimTime,AssignCommand(oPC, DeleteLocalInt(oPC, "WSPOTION")));
//Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
//X2_EXECUTE_SCRIPT_END if you want to prevent the calling of the
//code after the execute is done
nResult = X2_EXECUTE_SCRIPT_CONTINUE;
break;
case X2_ITEM_EVENT_EQUIP:
// * This code runs when the item is equipped
// * Note that this event fires PCs only
oPC = GetPCItemLastEquippedBy(); // The player who equipped the item
oItem = GetPCItemLastEquipped(); // The item that was equipped
if((GetLocalInt(oPC, "UNDERWATER") == 1)&&(GetLocalInt(oPC, "WSPOTION") == 0))
{
// Remove movement rate decreases
eEffect = GetFirstEffect(oPC);
while(GetIsEffectValid(eEffect))
{
if(GetEffectType(eEffect) == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE)
{
RemoveEffect(oPC, eEffect);
}
eEffect = GetNextEffect(oPC);
}
}
//Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
//X2_EXECUTE_SCRIPT_END if you want to prevent the calling of the
//code after the execute is done
nResult = X2_EXECUTE_SCRIPT_CONTINUE;
break;
case X2_ITEM_EVENT_UNEQUIP:
// * This code runs when the item is unequipped
// * Note that this event fires PCs only
oPC = GetPCItemLastUnequippedBy(); // The player who unequipped the item
oItem = GetPCItemLastUnequipped(); // The item that was unequipped
if((GetLocalInt(oPC, "UNDERWATER") == 1)&&(GetLocalInt(oPC, "WSPOTION") == 0))
{
// Reduce the entering objects movement speed
ApplyEffectToObject(2, EffectMovementSpeedDecrease(75), oPC);
}
//Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
//X2_EXECUTE_SCRIPT_END if you want to prevent the calling of the
//code after the execute is done
nResult = X2_EXECUTE_SCRIPT_CONTINUE;
break;
/*
case X2_ITEM_EVENT_ACQUIRE:
// * This code runs when the item is acquired
// * Note that this event fires PCs only
oPC = GetModuleItemAcquiredBy(); // The player who acquired the item
oItem = GetModuleItemAcquired(); // The item that was acquired
//Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
//X2_EXECUTE_SCRIPT_END if you want to prevent the calling of the
//code after the execute is done
nResult = X2_EXECUTE_SCRIPT_CONTINUE;
break;
case X2_ITEM_EVENT_UNACQUIRE:
// * This code runs when the item is unacquired
// * Note that this event fires PCs only
oPC = GetModuleItemLostBy(); // The player who dropped the item
oItem = GetModuleItemLost(); // The item that was dropped
//Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
//X2_EXECUTE_SCRIPT_END if you want to prevent the calling of the
//code after the execute is done
nResult = X2_EXECUTE_SCRIPT_CONTINUE;
break;
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 = GetSpellTargetObject(); // The item targeted by the spell
iSpell = GetSpellId(); // The id of the spell that was cast
//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;
*/
}
// * X2_EXECUTE_SCRIPT_CONTINUE - continue calling script after executed script is done
// * X2_EXECUTE_SCRIPT_END - end calling script after executed script is done
SetExecutedScriptReturnValue(nResult);
}