Expelliarmus
Where to change the sig?
- Reaction score
- 48
JASS:
scope IllusoryOrb
globals
private constant integer AbilID = 039;A002039;
private constant integer DummyID = 039;h001039;
private constant real IORadius = 225.00
private constant real IORange = 1400.00
private constant real IOInterval = 0.0375
private constant real IOMissilespeed = 500
endglobals
constant function IOIntervalex takes nothing returns real
return (IOMissilespeed * IOInterval)
endfunction
constant function IODamage takes integer level returns real
return (level * 70.00)
endfunction
struct IO
real x
real y
real xx
real yy
real dist
timer IOtimer
group damaged
real distance
unit dummy
unit caster
location loc
real dummyx
real dummyy
real angle
static method create takes nothing returns IO
local IO io = IO.allocate()
set io.loc= GetSpellTargetLoc()
set io.xx = GetLocationX(io.loc)
set io.yy = GetLocationY(io.loc)
set io.caster = GetTriggerUnit()
set io.x = GetUnitX(io.caster)
set io.y = GetUnitY(io.caster)
set io.dist = IOIntervalex()
call RemoveLocation(io.loc)
set io.loc = null
set io.angle = Atan2(io.yy - io.y, io.xx - io.x) * bj_DEGTORAD
return io
endmethod
private method onDestroy takes nothing returns nothing
call ReleaseTimer(.IOtimer)
call GroupClear(.damaged)
call RemoveUnit(.dummy)
set .caster = null
set .dummy = null
call BJDebugMsg("Struct Clear")
call ClearTimerStructA(.IOtimer)
call DestroyGroup( .damaged)
endmethod
endstruct
private function GetEnumFilter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) != true and GetWidgetLife(GetFilterUnit())>.405 and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) != true and GetFilterUnit() != GetTriggerUnit()
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == AbilID
endfunction
private function IOTimeout takes nothing returns nothing
local IO io = GetTimerStructA(GetExpiredTimer())
local unit u
local group damage = CreateGroup()
local integer level = GetUnitAbilityLevel(io.caster, AbilID)
local real polarx = io.dummyx + IOIntervalex() * Cos(io.angle)
local real polary =io.dummyy + IOIntervalex() * Sin(io.angle )
call GroupEnumUnitsInRange(damage, io.dummyx, io.dummyy, IORadius, Condition( function GetEnumFilter))
loop
set u = FirstOfGroup(damage)
exitwhen u == null
if IsUnitInGroup(u, io.damaged) == false then
call GroupAddUnit(io.damaged, u)
call GroupRemoveUnit( damage, u)
call UnitDamageTarget(io.caster, u, IODamage(level) , false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_CLAW_LIGHT_SLICE)
endif
set u = null
call DestroyGroup(damage)
endloop
call SetUnitPosition(io.dummy, polarx, polary)
if io.dist <=IORange then
set io.dist = io.dist + IOIntervalex()
call BJDebugMsg( R2S(io.dist))
set io.dummyx = GetUnitX(io.dummy)
set io.dummyy = GetUnitY(io.dummy)
else
call io.destroy()
call BJDebugMsg( "Struct Destroyed1")
endif
endfunction
private function Actions takes nothing returns nothing
local IO io = IO.create()
call BJDebugMsg("Dummy")
set io.IOtimer = NewTimer()
set io.dummy = CreateUnit(GetOwningPlayer(io.caster), DummyID, io.x, io.y, io.angle)
call SetTimerStructA(io.IOtimer, io)
call TimerStart(io.IOtimer, IOInterval, true, function IOTimeout)
endfunction
//__________________________________________________________________________________________
public function InitTrig takes nothing returns nothing
local trigger trig = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( trig, Condition( function Conditions ) )
call TriggerAddAction( trig, function Actions )
endfunction
endscope
2 things happen when I cast this spell:
- dummy gets created at where the previous dummy left off (from previous cast); how did the data get passed to the next cast
- dummy always travel to the right, I know something is wrong
What works:
- dummy created
- max distance
- speed of missile
- damage (to correct units)
Please hint me optimization tips
Also, is this MUI/ Leakless? Just wanted to know
Thanks in Advance