LoD_PRC8/_module/nss/phs_wndestr_act.nss
Jaysyn904 94990edc60 Initial Upload
Initial Upload
2023-09-21 21:20:34 -04:00

183 lines
5.6 KiB
Plaintext

//::///////////////////////////////////////////////
//:: phs_wndestr_act
//:://////////////////////////////////////////////
/*
OnActivateItem script for the
Wand of Destruction
add the following to the module's
OnActivateItem event to activate this item
ExecuteScript("phs_wndestr_act",OBJECT_SELF);
Oct 12:
- small tweak that should make it clean up non
destroyable corpses properly
*/
//:://////////////////////////////////////////////
//:: Created By: Piotr "Phantom" Banasik
//:: Created On: 26 Sept 2002
//:: Last Modified: Oct 12, 2002
//:://////////////////////////////////////////////
void ActivateAOE(location lTarg, object oActivator, object oAct);
void myDestroyObject(object oObj);
void EmptyObject(object oObj);
void main()
{
object oAct = GetItemActivated();
if (GetTag(oAct) == "WandofDestruction") {
object oActivator = GetItemActivator();
if (!GetIsDM(oActivator)) {
SendMessageToPC(oActivator,"Mortals are not allowed to use this item!");
SendMessageToPC(oActivator,"The wand crumbles in your hands.");
SendMessageToAllDMs(GetName(oActivator)+" just tried to use the Cloud of Destruction Wand!");
DestroyObject(oAct);
return;
}
object oActTarget = GetItemActivatedTarget();
if (oActTarget == OBJECT_INVALID) {
location lActLoc = GetItemActivatedTargetLocation();
ActivateAOE(lActLoc,oActivator,oAct);
} else {
if (GetObjectType(oActTarget) == OBJECT_TYPE_CREATURE) {
if (GetIsPC(oActTarget)) {
SendMessageToPC(oActivator,"You can't destroy players!");
return;
}
if (GetIsDM(oActTarget)) {
SendMessageToPC(oActivator,"You can't destroy DM's!");
return;
}
}
myDestroyObject(oActTarget);
}
}
}
//::///////////////////////////////////////////////
//:: void ActivateAOE(
//:: location lTarg,
//:: object oActivator,
//:: object oAct)
//:://////////////////////////////////////////////
/*
Activates an area of effect type thing that
anhiliates anything in its radius
*/
//:://////////////////////////////////////////////
//:: Created By: Piotr "Phantom" Banasik
//:: Created On: 26 Sept 2002
//:: Last Modified: 26 Sept 2002
//:://////////////////////////////////////////////
void ActivateAOE(location lTarg, object oActivator, object oAct)
{
int iEffectType = VFX_FNF_LOS_HOLY_10;
float fRadius = RADIUS_SIZE_MEDIUM;
int iObjectFilter = OBJECT_TYPE_CREATURE | OBJECT_TYPE_ITEM | OBJECT_TYPE_PLACEABLE;
effect eAOE = EffectVisualEffect(iEffectType);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eAOE,lTarg);
//Find first target in the size
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, fRadius, lTarg, FALSE, iObjectFilter);
//Cycle through the objects in the radius
while (GetIsObjectValid(oTarget))
{
myDestroyObject(oTarget);
//Get next target in the shape.
oTarget = GetNextObjectInShape(SHAPE_SPHERE, fRadius, lTarg, FALSE, iObjectFilter);
}
}
//::///////////////////////////////////////////////
//:: void myDestroyObject(object oObj)
//:://////////////////////////////////////////////
/*
Destroys oObj .. displays a visual effect for
the item destroyed too (depending on object
type displays a diffrent effect)
Oct 12:
- added default effect to be the harm effect
(affects non standard things destroyed like
doors)
- added a tweak that should hopefuly destroy
corpses that have been set to not fade out
*/
//:://////////////////////////////////////////////
//:: Created By: Piotr "Phantom" Banasik
//:: Created On: 26 Sept 2002
//:: Last Modified: Oct 12, 2002
//:://////////////////////////////////////////////
void myDestroyObject(object oObj)
{
int iEffectType = VFX_IMP_HARM;
int iOType = GetObjectType(oObj);
// make sure players and dms are left out of the carnage
if (iOType == OBJECT_TYPE_CREATURE) {
if (GetIsPC(oObj)) BootPC(oObj); // Added by SoulFlame to boot players with Destruction Wand.
if (GetIsDM(oObj)) return;
}
switch (iOType) {
case OBJECT_TYPE_CREATURE:
iEffectType = VFX_IMP_DEATH_L;
break;
case OBJECT_TYPE_ITEM:
iEffectType = VFX_IMP_FLAME_S;
break;
case OBJECT_TYPE_PLACEABLE:
iEffectType = VFX_IMP_FLAME_M;
break;
}
effect eDestr = EffectVisualEffect(iEffectType);
location lObj = GetLocation(oObj);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eDestr,lObj);
EmptyObject(oObj);
if (GetObjectType(oObj) == OBJECT_TYPE_CREATURE) {
// set the creature to insta die
AssignCommand(oObj,SetIsDestroyable(TRUE,FALSE,TRUE));
}
DestroyObject(oObj);
}
//::///////////////////////////////////////////////
//:: void EmptyObject(object oObj)
//:://////////////////////////////////////////////
/*
if oObj has an inventory destroys everything
inside first
*/
//:://////////////////////////////////////////////
//:: Created By: Piotr "Phantom" Banasik
//:: Created On: 26 Sept 2002
//:: Last Modified: 26 Sept 2002
//:://////////////////////////////////////////////
void EmptyObject(object oObj)
{
// if doesnt have inventory .. just return .. nothing to do
if (!GetHasInventory(oObj)) return;
object oItem;
oItem = GetFirstItemInInventory(oObj);
while (oItem != OBJECT_INVALID) {
DestroyObject(oItem);
oItem = GetNextItemInInventory(oObj);
}
}