/***********************************************
*
* Epicenter
* v2.1.0.0
* By Magtheridon96
*
* - Requires:
* - TimerTools By Nestharus
* - hiveworkshop.com/forums/jass-resources-412/system-timer-tools-201165/
* - SpellEffectEvent By Bribe
* - hiveworkshop.com/forums/jass-resources-412/snippet-spelleffectevent-187193/
*
***********************************************/
library Epicenter requires Tt, SpellEffectEvent
globals
private constant integer ABIL_CODE = 'A000'
private constant string EFFECT_PATH = "Epicenter.mdx"
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
private constant boolean PRELOAD_EFFECT = true
endglobals
private function GetDamage takes integer level returns real
return 90. + level * 60.
endfunction
private function GetTimeout takes integer level returns real
return 0.4
endfunction
private function GetRadius takes integer level returns real
return 450. + level * 50.
endfunction
private function GetWaves takes integer level returns integer
return 6 + level * 2
endfunction
private function TargetFilter takes unit caster, player owner, unit target returns boolean
return not IsUnitType(target, UNIT_TYPE_STRUCTURE) and not IsUnitType(target, UNIT_TYPE_DEAD) and IsUnitEnemy(target, owner)
endfunction
private struct Spell extends array
private static unit array caster
private static player array owner
private static integer array waves
private static real array radius
private static real array damage
implement CTM
local real x
local real y
local unit u
implement CTMExpire
// Get the caster's coordinates.
set x = GetUnitX(caster[this])
set y = GetUnitY(caster[this])
// Enumerate units in range of the caster.
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, radius[this], null)
loop
// Get the first unit in the group, check if he's null, and remove him.
set u = FirstOfGroup(bj_lastCreatedGroup)
exitwhen null == u
call GroupRemoveUnit(bj_lastCreatedGroup, u)
// Only damage wanted units.
if TargetFilter(caster[this], owner[this], u) then
call UnitDamageTarget(caster[this], u, damage[this], false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
endif
endloop
// Create and destroy special effect.
call DestroyEffect(AddSpecialEffect(EFFECT_PATH, x, y))
// Decrease number of waves left.
set waves[this] = waves[this] - 1
// If number of waves left is 0, we destroy the current instance.
if waves[this] == 0 then
call this.destroy()
set caster[this] = null
set owner[this] = null
endif
implement CTMEnd
private static method run takes nothing returns nothing
local integer level = GetUnitAbilityLevel(GetTriggerUnit(), ABIL_CODE)
local thistype this = create(GetTimeout(level))
// Get the caster and the triggering player.
set caster[this] = GetTriggerUnit()
set owner[this] = GetTriggerPlayer()
// Cache the radius and damage to avoid repeating calculations.
set radius[this] = GetRadius(level)
set damage[this] = GetDamage(level)
// Get the number of times the periodic function will run.
set waves[this] = GetWaves(level)
endmethod
private static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(ABIL_CODE, function thistype.run)
static if PRELOAD_EFFECT then
call Preload(EFFECT_PATH)
endif
endmethod
endstruct
endlibrary