BRUTAL
I'm working
- Reaction score
- 118
Ice Trap
Requires GTrigger, Key Timers 2; all included in the map.
Spell Description: Icicles pop out of the ground circling a targeted unit, and trapping everything inside. Any ground units trapped inside cannot get out, and no ground units can enter. This ability can be used to separate you from an army, and fight off a smaller number of enemy at a time. Deals damage per second to enemy ground units near the icicles.
Screen Shots:
Code:
Feedback is welcomed, if you see any bugs or mistakes let me know.
DL the map.
Requires GTrigger, Key Timers 2; all included in the map.
Spell Description: Icicles pop out of the ground circling a targeted unit, and trapping everything inside. Any ground units trapped inside cannot get out, and no ground units can enter. This ability can be used to separate you from an army, and fight off a smaller number of enemy at a time. Deals damage per second to enemy ground units near the icicles.
Screen Shots:


Code:
JASS:
// Ice Trap by BRUTAL.
// Requires GT, and KT2.
// Credits are welcome but not necessary.
// October 12th 2009.
scope icetrap initializer init
globals
private constant integer ID='A000' // ID of the ice trap spell.
private constant integer IMMO_ID='A001' // ID of the ice immolation spell.
private constant integer DUMMY_ID='h000' // ID of the ice trap unit.
private constant integer PATH_BLOCK='YTpb' // ID of the path blocker that is created.
private constant real PERIOD=.04 // Period of the KT2 timer.
private constant real SCALE=1. // Scale size of ice trap unit.
private constant integer ALPHA=75 // Percent transparency of ice trap unit.
private constant integer MAX_UNITS=36 // Number of units that will circle around.
endglobals
private constant function DURATION takes integer level returns real
return 6.+3.*level
endfunction
private constant function DISTANCE takes integer level returns real
return 270.+ 20.*level
endfunction
private struct Data
unit caster
real x
real y
real angle
integer pbInt=0
integer ticks
integer maxTicks
destructable array pathBlock[MAX_UNITS]
static method create takes unit u, real tx, real ty returns Data
local Data data=Data.allocate()
set data.caster=u
set data.x=tx
set data.y=ty
set data.angle=GetUnitFacing(u)+140
set data.ticks=R2I(DURATION(GetUnitAbilityLevel(data.caster,ID))/PERIOD)+10
set data.maxTicks=data.ticks
return data
endmethod
method circle takes nothing returns nothing
local integer level=GetUnitAbilityLevel(.caster,ID)
local real dis=DISTANCE(level)
local real dur=DURATION(level)
local real x=.x+dis*Cos(.angle*bj_DEGTORAD)
local real y=.y+dis*Sin(.angle*bj_DEGTORAD)
local unit u=CreateUnit(GetOwningPlayer(.caster),DUMMY_ID,x,y,bj_RADTODEG*Atan2(y-.y,x-.x))
call SetUnitScale(u,SCALE,SCALE,SCALE)
call SetUnitVertexColor(u,255,255,255,R2I(2.55*ALPHA))
call UnitApplyTimedLife(u,'BTLF',dur)
call UnitAddAbility(u,IMMO_ID)
call SetUnitAbilityLevel(u,IMMO_ID,level)
call IssueImmediateOrder(u,"immolation")
set .angle=.angle+360./MAX_UNITS
set .pathBlock[.pbInt]=CreateDestructable(PATH_BLOCK,x,y,0,1,0)
set .pbInt=.pbInt+1
set u=null
endmethod
method end takes nothing returns nothing
local integer i=0
loop
exitwhen i==MAX_UNITS
call KillDestructable(.pathBlock<i>)
set i=i+1
endloop
endmethod
endstruct
private function PeriodicFunc takes nothing returns boolean
local Data data=KT_GetData()
set data.ticks=data.ticks-1
if data.ticks<=0 then
call data.end()
return true
else
if data.ticks>=data.maxTicks-MAX_UNITS then
call data.circle()
endif
return false
endif
endfunction
private function actions takes nothing returns nothing
call KT_Add(function PeriodicFunc,Data.create(GetTriggerUnit(),GetSpellTargetX(),GetSpellTargetY()),PERIOD)
endfunction
private function init takes nothing returns nothing
call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),ID),function actions)
endfunction
endscope</i>
Feedback is welcomed, if you see any bugs or mistakes let me know.
DL the map.
Attachments
-
51 KB Views: 753
-
54.4 KB Views: 532