- Joined
- Jun 19, 2009
- Messages
- 556
vJASS:
scope DummyUnit initializer Init
globals
unit hero
group dummies = CreateGroup()
hashtable hash = InitHashtable()
endglobals
private function Spawn takes nothing returns nothing
set hero = CreateUnit(GetLocalPlayer(),'Otch',0,0,bj_UNIT_FACING)
endfunction
private function Esc takes nothing returns nothing
local integer c = 1
local real x = GetUnitX(hero)
local real y = GetUnitY(hero)
local real f = GetUnitFacing(hero)
local location l = GetUnitLoc(hero)
local unit g
loop
exitwhen c > 8
set g = CreateUnitAtLoc(GetLocalPlayer(),'h000',l,c*45)
call SaveInteger(hash,0,GetHandleId(g),0)
call GroupAddUnitSimple(g,dummies)
set c = c + 1
endloop
set g = null
call RemoveLocation(l)
endfunction
private function Damage takes nothing returns nothing
local unit t = GetEnumUnit()
if IsPlayerEnemy(GetOwningPlayer(t),GetLocalPlayer()) == true then
call UnitDamageTarget(hero,t,4,true,true,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
endif
set t = null
endfunction
private function MoveDummy takes nothing returns nothing
local unit d = GetEnumUnit()
local location l = GetUnitLoc(d)
local location t = PolarProjectionBJ(l,50,GetUnitFacing(d))
local integer i = LoadInteger(hash,0,GetHandleId(d))
local group targets = CreateGroup()
if i < 1000 then
call SetUnitPositionLoc(d,t)
call SaveInteger(hash,0,GetHandleId(d),i+50)
set targets = GetUnitsInRangeOfLocAll(150,t)
call ForGroup(targets,function Damage)
else
call GroupRemoveUnit(dummies,d)
call KillUnit(d)
call RemoveUnit(d)
endif
set d = null
call GroupClear(targets)
call DestroyGroup(targets)
call RemoveLocation(l)
call RemoveLocation(t)
set targets = null
endfunction
private function Move takes nothing returns nothing
call ForGroup(dummies, function MoveDummy)
endfunction
private function Init takes nothing returns nothing
local trigger trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg,0.2,false)
call TriggerAddAction(trg, function Spawn)
set trg = CreateTrigger()
call TriggerRegisterPlayerEventEndCinematic(trg,GetLocalPlayer())
call TriggerAddAction(trg,function Esc)
set trg = CreateTrigger()
call TriggerRegisterTimerEvent(trg,0.04,true)
call TriggerAddAction(trg,function Move)
endfunction
endscope