Not sure if this will help in the slightest, but a 'Shockwave' spell was one of the spells I used when trying out my custom magic system for my module (was designed around cooldowns replacing uses/day - blasphemous I know). This version fires in the players facing direction but is a targeted spell in spells.2da, which basically allows for a limited range whilst still able to use creatures as targets to assist aiming. Here's the code, for interest's sake. The include is just for my custom feat constants.
// SHOCKWAVE FEAT SCRIPT// Version 0.5: 2011/05/08
#include "spell_geninc"
void shockwave(float fAngle, int nWaves, int nWaveNum, int nNumDie){
// Calculate position of this 'step' of the wave
vector vPos = GetPosition(OBJECT_SELF);
vPos.x += cos(fAngle) * nWaveNum; vPos.y += sin(fAngle) * nWaveNum;
location lLoc = Location(GetArea(OBJECT_SELF), vPos, fAngle);
ApplyEffectAtLocation(0, EffectVisualEffect(VFX_FNF_PWSTUN), lLoc);
// Damage (and knockback?) all enemies around current 'step' of the wave
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 0.95, lLoc, FALSE, OBJECT_TYPE_CREATURE);
while(GetIsObjectValid(oTarget))
{ ApplyEffectToObject(0, EffectDamage(d6(nNumDie), DAMAGE_TYPE_SONIC, DAMAGE_POWER_NORMAL), oTarget);
ApplyEffectToObject(0, EffectVisualEffect(VFX_IMP_SONIC), oTarget);
if(GetHasFeat(UPGRADE_SW_TREMOR, OBJECT_SELF))
{ ApplyEffectToObject(1, EffectKnockdown(), oTarget, 6.0f); }
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 0.5f, lLoc, FALSE, OBJECT_TYPE_CREATURE);
}
nWaves--;
nWaveNum++;
if(nWaves > 0) DelayCommand(0.1f, shockwave(fAngle, nWaves, nWaveNum, nNumDie));
}
void main()
{ location lTarg = GetSpellTargetLocation(); object oCaster = OBJECT_SELF;
int nNumDie = 2;
float fCooldown = 5.0f;
int nWaveLen = 6;
if(GetHasFeat(UPGRADE_SW_LONGWAVE, oCaster)) { nWaveLen = 10; fCooldown += 2.0f; }
if(GetHasFeat(UPGRADE_SW_TREMOR, OBJECT_SELF)) { fCooldown += 2.0f; }
shockwave(GetFacing(oCaster), nWaveLen, 1, nNumDie);
SendMessageToPC(OBJECT_SELF, "<cÌwþ>Shockwave cooling down</c>");
DelayCommand(fCooldown, IncrementRemainingFeatUses(OBJECT_SELF, 52));
DelayCommand(fCooldown, SendMessageToPC(OBJECT_SELF, "<cÌwþ>Shockwave cooldown complete</c>"));
}
In retrospect, I did a pretty inefficient variant, calculating the direction vector from the caster's facing angle every time the function recurs when I could've just passed it in as a vector (plus a few Gets inside the loop that would return the same value every time). Ah well, lessons learned and all that.
Modifié par _six, 28 mai 2012 - 08:09 .