156 lines
5.5 KiB
Plaintext
156 lines
5.5 KiB
Plaintext
//::///////////////////////////////////////////////
|
|
//:: 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 nCrimsonItems = 0;
|
|
if (GetTag(GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC)) == "crimson")
|
|
nCrimsonItems = nCrimsonItems + 1;
|
|
if (GetTag(GetItemInSlot(INVENTORY_SLOT_CLOAK, oPC)) == "crimson")
|
|
nCrimsonItems = nCrimsonItems + 1;
|
|
if (GetTag(GetItemInSlot(INVENTORY_SLOT_CHEST, oPC)) == "crimson")
|
|
nCrimsonItems = nCrimsonItems + 1;
|
|
if (GetTag(GetItemInSlot(INVENTORY_SLOT_ARMS, oPC)) == "crimson")
|
|
nCrimsonItems = nCrimsonItems + 1;
|
|
if (GetTag(GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC)) == "crimson")
|
|
nCrimsonItems = nCrimsonItems + 1;
|
|
|
|
if (nCrimsonItems == 5)
|
|
{
|
|
object oTarget;
|
|
oTarget = oPC;
|
|
|
|
effect eEffect;
|
|
eEffect = EffectImmunity(IMMUNITY_TYPE_ABILITY_DECREASE);
|
|
|
|
eEffect = SupernaturalEffect(eEffect);
|
|
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget));
|
|
|
|
eEffect = EffectImmunity(IMMUNITY_TYPE_CRITICAL_HIT);
|
|
eEffect = SupernaturalEffect(eEffect);
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget));
|
|
|
|
eEffect = EffectImmunity(IMMUNITY_TYPE_DEATH);
|
|
eEffect = SupernaturalEffect(eEffect);
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget));
|
|
|
|
eEffect = EffectImmunity(IMMUNITY_TYPE_SNEAK_ATTACK);
|
|
eEffect = SupernaturalEffect(eEffect);
|
|
AssignCommand(oItem, ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget));
|
|
|
|
//Visual effects can't be applied to waypoints, so if it is a WP
|
|
//the VFX will be applied to the WP's location instead
|
|
|
|
int nInt;
|
|
nInt = GetObjectType(oTarget);
|
|
|
|
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_REDUCE_ABILITY_SCORE), oTarget);
|
|
else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_REDUCE_ABILITY_SCORE), GetLocation(oTarget));
|
|
|
|
SendMessageToPC(oPC, "You feel your blood cool and your pulse slow as you become more like the undead.");
|
|
}
|
|
}
|
|
|
|
// * 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();
|
|
int nEffectRemoved = 0;
|
|
effect eEffect;
|
|
eEffect = GetFirstEffect(oPC);
|
|
while (GetIsEffectValid(eEffect))
|
|
{
|
|
if (GetEffectSpellId(eEffect) == -1 && GetEffectSubType(eEffect) == SUBTYPE_SUPERNATURAL && GetEffectDurationType(eEffect) == DURATION_TYPE_PERMANENT)
|
|
{
|
|
RemoveEffect(oPC, eEffect);
|
|
nEffectRemoved = 1;
|
|
}
|
|
eEffect = GetNextEffect(oPC);
|
|
}
|
|
if (nEffectRemoved == 1)
|
|
SendMessageToPC(oPC, "You feel your connection with undeath wane and fade, leaveing you feeling cold and vulnerable.");
|
|
}
|
|
// * 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();
|
|
}
|
|
}
|