//Spell Name: Shockwave Thrust
//Made by: Mckill2009
scope SWT
globals
private constant hashtable HASH = InitHashtable() //Dont touch!
private constant integer SPELL_ID = 'A003' //Based on Carrion swarm
private constant real AOE = 250
private constant real TRUST_SPEED = 30
private constant real TIMEOUT = 0.03125
private constant string THRUST_SFX = "Abilities\\Spells\\Orc\\Shockwave\\ShockwaveMissile.mdl"
private constant attacktype ATK = ATTACK_TYPE_NORMAL
private constant damagetype DMG = DAMAGE_TYPE_NORMAL
endglobals
private function Damage takes integer i returns real
return 25 + i * 25.
endfunction
private module Init
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function thistype.go))
set t = null
endmethod
endmodule
private struct SW
unit caster
integer level
real angle
real distance
real distx
real damage
real x
real y
static thistype DATA
static method onFilter takes nothing returns boolean
local unit u = GetFilterUnit()
local SW this = DATA
if GetWidgetLife(u) > 0.405 and IsUnitEnemy(.caster, GetOwningPlayer(u)) and not IsUnitType(u, UNIT_TYPE_FLYING) then
call UnitDamageTarget(.caster, u, .damage, false, false, ATK, DMG, null)
endif
set u = null
return false
endmethod
static method looper takes nothing returns nothing
local timer t = GetExpiredTimer()
local SW this = LoadInteger(HASH, GetHandleId(t), 1)
local real x
local real y
local real x1 = GetUnitX(.caster)
local real y1 = GetUnitY(.caster)
if .distance > .distx then
set .distx = .distx + TRUST_SPEED
set x = .x+.distx*Cos(.angle)
set y = .y+.distx*Sin(.angle)
call SetUnitX(.caster, x)
call SetUnitY(.caster, y)
call DestroyEffect(AddSpecialEffect(THRUST_SFX, x1, y1))
set DATA = this
call GroupEnumUnitsInRange(bj_lastCreatedGroup, x1, y1, AOE, Filter(function SW.onFilter))
else
call .destroy(this)
call FlushChildHashtable(HASH, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
endif
set t = null
endmethod
static method create takes unit u, integer level returns SW
local SW this = SW.allocate()
local timer t = CreateTimer()
local real x1 = GetSpellTargetX()
local real y1 = GetSpellTargetY()
local real dx
local real dy
set .caster = u
set .level = GetUnitAbilityLevel(u, SPELL_ID)
set .x = GetUnitX(u)
set .y = GetUnitY(u)
set dx = x1-.x
set dy = y1-.y
set .angle = Atan2(y1-.y, x1-.x)
set .distx = 0
set .distance = SquareRoot(dx*dx+dy*dy)
set .damage = Damage(.level)*TIMEOUT
call SaveInteger(HASH, GetHandleId(t), 1, this)
call TimerStart(t, TIMEOUT, true, function SW.looper)
set t = null
return this
endmethod
static method go takes nothing returns boolean
local unit u
local integer level
if GetSpellAbilityId()==SPELL_ID then
set u = GetTriggerUnit()
set level = GetUnitAbilityLevel(u, SPELL_ID)
call SW.create(u, level)
endif
set u = null
return false
endmethod
implement Init
endstruct
endscope