scope DarkLightningNova initializer init
/***********************************************************************************/
/* Dark Lightning Nova v1.3 */
/* by: msongyyy */
/* */
/* requires: JNGP 1.5e or better */
/* WorldBounds by Nestharus */
/* */
/* Big thanks to JetFangInferno for the DarkLightningNova and DarkLightning Models */
/* */
/* HOW TO IMPORT Dark Lightning Nova */
/* 1. Copy the dummy/spell into your map */
/* 2. Import the icon/models to the correct paths */
/* 3. Set the first 4 configurables to the right path */
/* the DLN_NOVA = the imported DarkLightningNova path */
/* the DLN_LIGHT = the imported DarkLightning path */
/* the DLN_ID = Spell Rawcode ID for Dark Lightning Nova */
/* the DLN_VISION_DUMMY = Unit Rawcode ID for Vision Dummy */
/* 4. Set the rest of the configurables to your liking ^^ */
/* */
/* */
/* ENJOY - PLEASE REPORT ALL BUGS TO ME */
/* AT HIVEWORKSHOP.COM */
/* */
/***********************************************************************************/
globals
private constant string NOVA = "war3mapImported\\DarkLightningNova.mdx"
private constant string LIGHT = "war3mapImported\\DarkLightning.mdx"
private constant integer ID = 'A000'
private constant integer VISION_DUMMY = 'h001'
/***********************************************************************************/
/* */
/* START OF CONFIGURABLES :) */
/* LEVEL = Level of DLN for unit - not really a configurable lol */
/* */
/* NOVA_AOE = AoE real of the initial lightning */
/* LIGHT_AOE = AoE real of the lightning lines after initial */
/* */
/* MAX_DIST_INC = Increment of max distance traveled by LEVEL */
/* MAX_DIST_BASE = Base distance traveled by DLN */
/* MAX_DIST = MAX_DIST_INC * LEVEL + MAX_DIST_BASE */
/* */
/* NDMG_INC = Increment of damage of initial lightning by LEVEL */
/* NDMG_BASE = Base damage of initial lightning */
/* NOVA_DAMAGE = NDMG_INC * LEVEL + NDMG_BASE (Total Damage) */
/* */
/* LDMG_INC = Increment of damage of lightning after initial by LEVEL */
/* LDMG_BASE = Base damage of lightning after initial */
/* LIGHT_DAMAGE = LDMG_INC * LEVEL + LDMG_BASE (Total Damage) */
/* */
/* TIME_INC = How often each lighting strike fires off */
/* DIST_INC = Distance between each instance */
/* */
/***********************************************************************************/
private constant real NOVA_AOE = 250.00
private constant real LIGHT_AOE = 135.00
private constant real MAX_DIST_INC = 500.00
private constant real MAX_DIST_BASE = 500.00
private constant real NDMG_INC = 100.00
private constant real NDMG_BASE = 50.00
private constant real LDMG_INC = 50.00
private constant real LDMG_BASE = 25.00
private constant real DIST_INC = 50.00
private constant real TIME_INC = .05
private timer TMR = CreateTimer()
endglobals
/***********************************************************************************/
/* DLN_MAX_DIST = Max distance traveled by DLN */
/***********************************************************************************/
private constant function MAX_DIST takes real level returns real
return level*MAX_DIST_INC + MAX_DIST_BASE
endfunction
/***********************************************************************************/
/* DLN_NOVA_DAMAGE = Dealt by the initial lightning */
/***********************************************************************************/
private constant function NOVA_DAMAGE takes real level returns real
return level*NDMG_INC + NDMG_BASE
endfunction
/***********************************************************************************/
/* DLN_LIGHT_DAMAGE = Damage dealt by each of the lightning strikes after the */
/* initial lightning */
/***********************************************************************************/
private constant function LIGHT_DAMAGE takes real level returns real
return level*LDMG_INC + LDMG_BASE
endfunction
/***********************************************************************************/
/* DLN_LEVEL = Just gets the level of DLN for a unit to make code a lil cleaner :) */
/***********************************************************************************/
private function LEVEL takes unit u returns real
return I2R(GetUnitAbilityLevel(u, ID))
endfunction
/***********************************************************************************/
/* */
/* END OF CONFIGURABLES, DON'T TOUCH PAST HERE :( */
/* */
/***********************************************************************************/
globals
private group g = CreateGroup()
private unit fog
private unit array caster
private unit array dummy
private player array play
private real array x
private real array y
private real array dist
private real array ang
private integer array next
private integer array prev
private integer array rn
private integer ic = 0
endglobals
private function dlnLight takes nothing returns nothing
local integer this = next[0]
loop
if next[0] == 0 then
call PauseTimer(TMR)
endif
if dist[this] > MAX_DIST(LEVEL(caster[this])) then
set caster[this] = null
set play[this] = null
set prev[next[this]] = prev[this]
set next[prev[this]] = next[this]
set rn[this] = rn[0]
set rn[0] = this
return
else
if dist[this] == 0 then
call DestroyEffect(AddSpecialEffect(NOVA, x[this], y[this]))
call DestroyEffect(AddSpecialEffect(LIGHT, x[this], y[this]))
call GroupEnumUnitsInRange(g, x[this], y[this], NOVA_AOE, null)
loop
set fog = FirstOfGroup(g)
exitwhen fog == null
if IsUnitEnemy(fog, GetOwningPlayer(caster[this])) then
call UnitDamageTarget(caster[this], fog, NOVA_DAMAGE(LEVEL(caster[this])), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, null)
endif
call GroupRemoveUnit(g, fog)
endloop
elseif dist[this] >= NOVA_AOE and dist[this] <= MAX_DIST(LEVEL(caster[this])) then
call DestroyEffect(AddSpecialEffect(LIGHT, x[this], y[this]))
call GroupEnumUnitsInRange(g, x[this], y[this], LIGHT_AOE, null)
loop
set fog = FirstOfGroup(g)
exitwhen fog == null
if IsUnitEnemy(fog, GetOwningPlayer(caster[this])) then
call UnitDamageTarget(caster[this], fog, LIGHT_DAMAGE(LEVEL(caster[this])), false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, null)
endif
call GroupRemoveUnit(g, fog)
endloop
endif
endif
set dummy[this] = CreateUnit(play[this], VISION_DUMMY, x[this], y[this], 0)
call UnitApplyTimedLife(dummy[this], 'BTLF', .6)
set dummy[this] = null
set dist[this] = dist[this] + DIST_INC
set x[this] = x[this] + DIST_INC * Cos(ang[this])
set y[this] = y[this] + DIST_INC * Sin(ang[this])
if x[this] > I2R(WorldBounds.maxX) then
set x[this] = I2R(WorldBounds.maxX) - 25
endif
if x[this] < I2R(WorldBounds.minX) then
set x[this] = I2R(WorldBounds.minX) + 25
endif
if y[this] > I2R(WorldBounds.maxY) then
set y[this] = I2R(WorldBounds.maxY) - 25
endif
if y[this] < I2R(WorldBounds.minY) then
set y[this] = I2R(WorldBounds.minY) + 25
endif
set this = next[this]
exitwhen this == 0
endloop
endfunction
private function dlnCreate takes unit u, real xc, real yc, real r returns nothing
local integer this = rn[0]
if this == 0 then
set ic = ic + 1
set this = ic
else
set rn[0] = rn[this]
endif
set caster[this] = u
set dist[this] = 0
set x[this] = xc
set y[this] = yc
set ang[this] = r
set play[this] = GetOwningPlayer(caster[this])
set next[this] = 0
set prev[this] = prev[0]
set next[prev[0]] = this
set prev[0] = this
if prev[this] == 0 then
call TimerStart(TMR, TIME_INC, true, function dlnLight)
endif
endfunction
private function dlnNova takes nothing returns boolean
local unit lvUnit = GetTriggerUnit()
local real lvAng = Atan2(GetSpellTargetY() - GetUnitY(lvUnit), GetSpellTargetX() - GetUnitX(lvUnit))
if GetSpellAbilityId() == ID then
call dlnCreate(lvUnit, GetSpellTargetX(), GetSpellTargetY(), lvAng)
endif
set lvUnit = null
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function dlnNova))
set t = null
endfunction
endscope