Initial upload
Initial upload. PRC8 has been added. Module compiles, PRC's default AI & treasure scripts have been integrated. Started work on top hak for SLA / Ability / Scripting modifications.
This commit is contained in:
87
_module/nss/jw_firefun_spell.nss
Normal file
87
_module/nss/jw_firefun_spell.nss
Normal file
@@ -0,0 +1,87 @@
|
||||
void main()
|
||||
{
|
||||
// will only do it every so often
|
||||
// sets "NW_DO_ONCE" back to 0 if nSpawnDelay has passed
|
||||
int nCurrentHour = (GetCalendarYear()-1)*12*28*24 +
|
||||
(GetCalendarMonth()-1)*28*24 +
|
||||
(GetCalendarDay()-1)*24 +
|
||||
GetTimeHour();
|
||||
int nLastSpawnHour = GetLocalInt(OBJECT_SELF,"LAST_SPAWN_HOUR");
|
||||
int nSpawnDelay = 0;
|
||||
if (nCurrentHour > (nLastSpawnHour + nSpawnDelay))
|
||||
{
|
||||
SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",0);
|
||||
}
|
||||
|
||||
//return if time has not passed yet
|
||||
if (GetLocalInt(OBJECT_SELF,"NW_DO_ONCE") != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// will explode if a fire spell is cast on it
|
||||
int iSpell=GetLastSpell();
|
||||
//SpeakString("a spell was cast on me");
|
||||
|
||||
// Check if a fire-spell was used
|
||||
if (iSpell == SPELL_BURNING_HANDS || iSpell == SPELL_FIRE_STORM || iSpell == SPELL_FIREBALL || iSpell == SPELL_DELAYED_BLAST_FIREBALL || iSpell == SPELL_SHADES_FIREBALL ||
|
||||
iSpell == SPELL_SHADES_WALL_OF_FIRE || iSpell == SPELL_WALL_OF_FIRE || iSpell == SPELL_FLAME_ARROW || iSpell == SPELL_FLAME_LASH ||
|
||||
iSpell == SPELL_FLAME_STRIKE || iSpell == SPELL_FLARE || iSpell == SPELL_INCENDIARY_CLOUD || iSpell == SPELL_INFERNO | iSpell == SPELL_METEOR_SWARM
|
||||
|| iSpell == SPELL_COMBUST || iSpell == SPELL_FLARE || iSpell == SPELL_GRENADE_FIRE)
|
||||
|
||||
{
|
||||
SpeakString("*The flames set off a reaction in the fungus*");
|
||||
|
||||
// Set the times
|
||||
SetLocalInt(OBJECT_SELF,"NW_DO_ONCE",1);
|
||||
SetLocalInt(OBJECT_SELF,"LAST_SPAWN_HOUR",nCurrentHour);
|
||||
|
||||
// Do the spell effect
|
||||
//Declare major variables
|
||||
object oCaster = OBJECT_SELF;
|
||||
int nCasterLvl = 5;
|
||||
int nDamage;
|
||||
float fDelay;
|
||||
effect eExplode = EffectVisualEffect(VFX_FNF_FIREBALL);
|
||||
effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
|
||||
effect eDam;
|
||||
//Get the spell target location as opposed to the spell target.
|
||||
location lTarget = GetLocation(OBJECT_SELF);
|
||||
//Apply the fireball explosion at the location captured above.
|
||||
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eExplode, lTarget);
|
||||
//Declare the spell shape, size and the location. Capture the first target object in the shape.
|
||||
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 30.0, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
|
||||
//Cycle through the targets within the spell shape until an invalid object is captured.
|
||||
while (GetIsObjectValid(oTarget))
|
||||
{
|
||||
|
||||
//Fire cast spell at event for the specified target
|
||||
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_FIREBALL));
|
||||
//Get the distance between the explosion and the target to calculate delay
|
||||
fDelay = GetDistanceBetweenLocations(lTarget, GetLocation(oTarget))/20;
|
||||
|
||||
//Roll damage for each target
|
||||
nDamage = d6(nCasterLvl);
|
||||
//Resolve metamagic
|
||||
|
||||
//Adjust the damage based on the Reflex Save, Evasion and Improved Evasion.
|
||||
nDamage = GetReflexAdjustedDamage(nDamage, oTarget, 20, SAVING_THROW_TYPE_FIRE);
|
||||
//Set the damage effect
|
||||
eDam = EffectDamage(nDamage, DAMAGE_TYPE_FIRE);
|
||||
if(nDamage > 0)
|
||||
{
|
||||
// Apply effects to the currently selected target.
|
||||
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
|
||||
//This visual effect is applied to the target object not the location as above. This visual effect
|
||||
//represents the flame that erupts on the target not on the ground.
|
||||
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
|
||||
}
|
||||
|
||||
//Select the next target within the spell shape.
|
||||
oTarget = GetNextObjectInShape(SHAPE_SPHERE, 30.0, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user