scope FS1 initializer Init_FlameShackles
globals
private constant integer ABILITY_ID = 'A000'
private constant integer DUMMY_ID = 'e000'
private constant string LIGHTNING = "LEAS"
private constant real RADIUS = 300.00000
private constant real DURATION = 5.50000
private constant real MAX_HEIGHT = 200.00000
private constant real HEIGHT_RATE = 100.00000
private constant real TIMER_INTERVAL = 0.03125
private integer index = 0
private integer array temp_this
private hashtable hash = InitHashtable()
private constant timer tim = CreateTimer()
endglobals
private struct flame extends array
player owner
unit dummy
unit caster
real cast_x
real cast_y
real dummy_z
integer count
implement Alloc
static method filter takes player owner, unit u returns boolean
return IsUnitEnemy(u,owner) and IsUnitType(u,UNIT_TYPE_GROUND)
endmethod
static method rise takes nothing returns nothing
local thistype this
local integer a = 0
local integer b
local lightning l
local unit u
local real x1
local real y1
local real z1
local real x2
local real y2
local real z2
loop
exitwhen a == index
set this = temp_this[a]
set x1 = this.cast_x
set y1 = this.cast_y
set z1 = this.dummy_z
if z1 < MAX_HEIGHT then
set z1 = z1 + MAX_HEIGHT * TIMER_INTERVAL/1.500
call SetUnitFlyHeight(this.dummy,z1,0.0)
set this.dummy_z = z1
endif
set b = 1
loop
exitwhen b >= this.count
@set u = LoadUnitHandle(hash,this,b)@
set x2 = GetUnitX(u)
set y2 = GetUnitY(u)
set z2 = GetUnitFlyHeight(u)
@set l = LoadLightningHandle(hash,this,b)@
call MoveLightningEx(l,false,x1,y1,z1 + 48.,x2,y2,z2)
set b = b + 1
endloop
set u = null
set l = null
set a = a + 1
endloop
endmethod
static method start takes unit caster, real x1, real y1 returns nothing
local thistype this = thistype.allocate()
local unit temp_u
local lightning l
local integer i = 1
local real x2
local real y2
local real z2
set temp_this[index] = this
set this.owner = GetOwningPlayer(caster)
set this.caster = caster
set this.cast_x = x1
set this.cast_y = y1
set this.dummy_z = 0.0
set this.dummy = CreateUnit(this.owner,DUMMY_ID,x1,y1,0)
call GroupEnumUnitsInRange(bj_lastCreatedGroup,x1,y1,RADIUS,null)
//set i = 1
loop
set temp_u = FirstOfGroup(bj_lastCreatedGroup)
set this.count = i
exitwhen temp_u == null
if filter(this.owner,temp_u) then
set x2 = GetUnitX(temp_u)
set y2 = GetUnitY(temp_u)
set z2 = GetUnitFlyHeight(temp_u)
set l = AddLightningEx(LIGHTNING,false,x1,y1,0,x2,y2,z2)
@call SaveUnitHandle( hash , this , i , temp_u )@
@call SaveLightningHandle( hash , this , i , l )@
set i = i + 1
endif
call GroupRemoveUnit(bj_lastCreatedGroup,temp_u)
endloop
if index == 0 then
call TimerStart(tim,TIMER_INTERVAL,true,function flame.rise)
endif
set index = index + 1
endmethod
endstruct
private function FlameShackles_Conditions takes nothing returns boolean
if GetSpellAbilityId() == ABILITY_ID then
call flame.start(GetTriggerUnit(),GetSpellTargetX(),GetSpellTargetY())
endif
return false
endfunction
private function Init_FlameShackles takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,function FlameShackles_Conditions)
set t = null
endfunction
endscope