Greetings!
I am working on a script based off a script by The Fred - combining a fly script with a hard landing that will damage enemies around the landing in a circle. It is class based, so I am setting the local variable in the OnEnter fucntion of the mod. The fly portion works, but no damage or knockdown efect is being applied to any enemies around. It is a tag based script.
#include "x0_i0_spells"
#include "x2_inc_switches"
void DeathAbove(int nSmashPower);
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
object oPC;
object oItem;
// * 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 = GetSpellCastItem(); // The item casting triggering this spellscript
object oSpellOrigin = OBJECT_SELF ;
object oSpellTarget = GetSpellTargetObject();
oPC = GetItemPossessor(oItem);
}
// * 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();
object oTarget = GetItemActivatedTarget();
location lTarget = GetItemActivatedTargetLocation();
if((GetIsObjectValid(oTarget))&&(oTarget==oPC))
{
int iPhenoFinal;
switch(GetPhenoType(oTarget))
{
case 0: iPhenoFinal = 16; break;//normal Pheno
case 16: iPhenoFinal = 0; break;//CEP flying pheno
case 2: iPhenoFinal = 25; break;//large Pheno
case 25: iPhenoFinal = 2; break;//CEP flying large pheno
default: iPhenoFinal = 0;break;
}
SetPhenoType(iPhenoFinal, oTarget);
}
else
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectDisappearAppear(lTarget), oPC, 3.0f);
//Do Death From Above when landing
int nSmashPower = GetLocalInt(oPC, "DeathAbove");
if(nSmashPower)
{
DelayCommand(5.0, DeathAbove(nSmashPower));
}
}
// * 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();
}
// * 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();
}
// * 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 = GetSpellTargetObject();
}
}
void DeathAbove(int nSmashPower)
{
location lTarget = GetItemActivatedTargetLocation();
effect eDust = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eDust, lTarget);
int nNotCreature;
int nDamage1;
int nDamage2;
effect eDamage;
effect eKD = EffectKnockdown();
float fDelay;
float fRadius = 5.0 + IntToFloat(nSmashPower) / 2;
if(fRadius >= 10.0) fRadius = 10.0;
object oStomped = GetFirstObjectInShape(SHAPE_SPHERE, fRadius, lTarget, FALSE,
OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE |
OBJECT_TYPE_DOOR);
while(GetIsObjectValid(oStomped))
{
if(GetObjectType(oStomped) == OBJECT_TYPE_PLACEABLE ||
GetObjectType(oStomped) == OBJECT_TYPE_DOOR)
{
nNotCreature = TRUE;
}
if(GetIsEnemy(oStomped) || nNotCreature)
{
fDelay = GetRandomDelay();
if(spellsIsFlying(oStomped))
{
nDamage1 = d10(nSmashPower);
nDamage2 = GetReflexAdjustedDamage(nDamage1, oStomped, 15 +
(nSmashPower / 2));
}
else
{
nDamage1 = d10(nSmashPower + nSmashPower * nNotCreature);
nDamage2 = GetReflexAdjustedDamage(nDamage1, oStomped, 15 +
nSmashPower);
}
eDamage = EffectDamage(nDamage2, DAMAGE_TYPE_BLUDGEONING);
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage,
oStomped));
if(nDamage1 == nDamage2)
{
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY,
eKD, oStomped, GetRandomDelay(3.5, 4.5)));
}
}
oStomped = GetNextObjectInShape(SHAPE_SPHERE, fRadius, lTarget, FALSE,
OBJECT_TYPE_CREATURE | OBJECT_TYPE_PLACEABLE |
OBJECT_TYPE_DOOR);
}
}
Edit: Corrected mistype in answer to Magical Master.
Modifié par valasc, 03 septembre 2012 - 06:08 .