/*
Creeping Flame 1.02
by Adiktuz
The caster conjures a powerful flame which moves toward the front, burning enemies in
it's path. The flame could also change direction once it reaches the end of its
current path.
And by changing the model of the "flame" you can turn it into any other
creeping something like creeping lightning, creeping water etc.
How to use:
1)Copy paste this library and all the required ones
2)Export/Import the dummy.mdx if you haven't have it yet
3)Copy the dummy caster if you haven't got one yet
4)Copy the creeping flame spell
5)Modify the values on the configurables part to suit your needs
Those accustomed to vJASS can modify the main code so that they can
utilize the interface methods of the Nova system to bring more possibilities to the spell.
Credits to Bribe for SpellEffectEvent
Credits for the creators of the required libraries of the Nova system is at
the Nova system's code
*/
library CreepingFlame requires Nova, SpellEffectEvent
//Configurables
globals
//model path for the flame
private constant string FLAME_FX = "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl"
//rawcode of the creeping flame spell
private constant integer CF_ID = 'A000'
//attack type of the flame
private constant attacktype CF_AT= ATTACK_TYPE_CHAOS
//damage type of the flame
private constant damagetype CF_DT= DAMAGE_TYPE_FIRE
endglobals
//Distance per second travelled by the flame
private function DistPerSec takes integer level, unit caster returns real
return 400.0
endfunction
//Interval of flame "movement"
private function FlameInterval takes integer level, unit caster returns real
return 0.09
endfunction
//AOE of the flame damage
private function AOE takes integer level, unit caster returns real
return 150.0
endfunction
//offset of the flame from the caster
private function Offset takes integer level, unit caster returns real
return 100.0
endfunction
//Scale of the flame
private function Scale takes integer level, unit caster returns real
return 1.15
endfunction
//Damage per second of the flame
private function DamPerSec takes integer level, unit caster returns real
return (100.0 + GetHeroInt(caster, true))*level
endfunction
//max distance that can be travelled by the flame
private function DistMax takes integer level, unit caster returns real
return 200.0*(1 + level)
endfunction
//max time of each creeping flame
private function MaxTime takes integer level, unit caster, real distpersec returns real
return DistMax(level,caster)/distpersec
endfunction
/*
Max creeping flames (each flame is created once the current one finishes it's path)
Direction of the first flame is towards the facing of the caster while the
direction of all successive flames are randomized
*/
private function MaxCreeps takes integer level, unit caster returns integer
return level + 1
endfunction
//Do not modify beyond this unless you know what you're doing
module CFInit
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(CF_ID, function CreepingFlameSpell.onCast)
endmethod
endmodule
//Made it extend NovaSystem just so that it will have its own instance
//which might be helpful in prevention of reaching the
//instance limit for Nova in a map that uses it a lot
//since this creates lots of Nova
//But if you want you can remove the extends part then replace the
//thistype.SimpleCreateDelay with NovaSystem.SimpleCreateDelay
struct CreepingFlameSpell extends NovaSystem
static method onCast takes nothing returns nothing
local unit caster = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(caster, CF_ID)
local real distpersec = DistPerSec(level,caster)
local real aoe = AOE(level,caster)
local real i = 0.0
local real offset = Offset(level,caster)
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local real angle = Atan2(GetSpellTargetY()-y,GetSpellTargetX()-x)
local real flameint = FlameInterval(level, caster)
local real scale = Scale(level, caster)
local real damage = flameint*DamPerSec(level,caster)
local real distperintx = flameint*distpersec*Cos(angle)
local real distperinty = flameint*distpersec*Sin(angle)
local real maxtime = MaxTime(level,caster,distpersec)
local real maxcreeps = MaxCreeps(level,caster)
local integer count = 1
local real maxtimex = 0.0
set x = x + offset*Cos(angle)
set y = y + offset*Sin(angle)
loop
exitwhen count > maxcreeps
set maxtimex = maxtime*count
loop
exitwhen i > maxtimex
set x = x + distperintx
set y = y + distperinty
call thistype.SimpleCreateDelay(caster, x, y, i,0.0, aoe, 0.0,/*
*/ damage, scale, FLAME_FX, CF_AT, CF_DT, CF_ID)
set i = i + flameint
endloop
set angle = GetRandomReal(0.0,6.2832)
set distperintx = flameint*distpersec*Cos(angle)
set distperinty = flameint*distpersec*Sin(angle)
set count = count + 1
endloop
set caster = null
endmethod
implement CFInit
endstruct
endlibrary