/*********************************************************************
*
* Sub Zero v4.0.0.0
* By Magtheridon96
*
* Description:
* ------------
*
* - This spell is a nova spell that creates projectiles of ice
* that emerge from the center of the casting unit even while he
* is moving.
*
* Requirements:
* -------------
*
* - CTL [By Nestharus]
* - WorldBounds [By Nestharus]
* - SpellEffectEvent [By Bribe]
* - Table [By Bribe]
*
* Implementation:
* ---------------
*
* - Implement all the required systems
* - Copy this code into a new trigger
* - Paste all the object data from the Object editor into your map
* - Configure the system
* - Done!
*
*********************************************************************/
library SubZero requires CTL, WorldBounds, SpellEffectEvent
globals
// Ability Code
private constant integer ABIL_CODE = 'A000'
// Dummy Code
private constant integer DUMMY = 'h000'
// Projectile Speed
private constant real VELOCITY = 18.0
// Attack Type
private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
// Damage Type
private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_MAGIC
// Max Collision size in Map
private constant real MAX_COLLISION = 197.0
// Missile Damage Radius
private constant real PROJ_DMG_RADIUS = 175.0
endglobals
private function GetMissiles takes integer level returns integer
return 6 + level * 2
endfunction
private function GetDamage takes integer level returns real
return level * 70.0
endfunction
private function GetRange takes integer level returns real
return 550. + level * 50.
endfunction
private function TargetFilter takes unit u, player p, real x, real y returns boolean
return IsUnitEnemy(u, p) and not IsUnitType(u, UNIT_TYPE_DEAD) and not IsUnitType(u, UNIT_TYPE_STRUCTURE) and not IsUnitType(u, UNIT_TYPE_MAGIC_IMMUNE) and IsUnitInRangeXY(u, x, y, PROJ_DMG_RADIUS)
endfunction
private struct Spell extends array
static Table data
static Table array missiles
static Table array hit
static player array owner
static unit array caster
static real array distance
static real array damage
// You mad Jesus4Lyf?
implement CTL
local integer k
local integer i
local unit u
local unit v
local real x
local real y
implement CTLExpire
set distance[this] = distance[this] + VELOCITY
set i = 0
loop
set u = missiles[this].unit[i]
exitwhen null == u
set k = GetHandleId(u)
set x = GetUnitX(caster[this]) + distance[this] * data.real[k * 2]
set y = GetUnitY(caster[this]) + distance[this] * data.real[k * 2 + 1]
if x < WorldBounds.maxX and x > WorldBounds.minX and y < WorldBounds.maxY and y > WorldBounds.minY and GetWidgetLife(u)>0.405 then
call SetUnitX(u, x)
call SetUnitY(u, y)
// You mad Rising_Dusk?
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x, y, PROJ_DMG_RADIUS + MAX_COLLISION, null)
loop
set v = FirstOfGroup(bj_lastCreatedGroup)
exitwhen null == v
set k = GetHandleId(v)
if not hit[this].boolean.has(k) then
if TargetFilter(v, owner[this], x, y) then
call UnitDamageTarget(caster[this], v, damage[this], false, false, ATTACK_TYPE, DAMAGE_TYPE, null)
set hit[this].boolean[k] = true
endif
endif
call GroupRemoveUnit(bj_lastCreatedGroup, v)
endloop
else
call destroy()
set caster[this] = null
set owner[this] = null
call hit[this].destroy()
set i = 0
loop
set u = missiles[this].unit[i]
exitwhen null == u
call KillUnit(u)
set i = i + 1
endloop
call missiles[this].destroy()
exitwhen true
endif
set i = i + 1
endloop
implement CTLNull
implement CTLEnd
static method start takes unit u, integer lvl returns nothing
local thistype this = create()
local integer m = GetMissiles(lvl)
local integer i = m - 1
local integer k = 0
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real r = 0.03125 * GetRange(lvl) / VELOCITY
set caster[this] = u
set owner[this] = GetTriggerPlayer()
set distance[this] = 0.0
set damage[this] = GetDamage(lvl)
set missiles[this] = Table.create()
set hit[this] = Table.create()
loop
set u = CreateUnit(owner[this], DUMMY, x, y, i * 360.0 / m)
set k = GetHandleId(u)
set data.real[k*2] = Cos(i * 6.2831853 / m)
set data.real[k*2+1] = Sin(i * 6.2831853 / m)
call UnitApplyTimedLife(u, 'BTLF', r)
set missiles[this].unit[i] = u
// You mad Nestharus?
exitwhen i == 0
set i = i - 1
endloop
set u = null
endmethod
static method run takes nothing returns nothing
call start(GetTriggerUnit(), GetUnitAbilityLevel(GetTriggerUnit(), ABIL_CODE))
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(ABIL_CODE, function thistype.run)
// You mad Vexorian?
set data = Table.create()
endmethod
endstruct
endlibrary