- Joined
- Jul 18, 2010
- Messages
- 2,377
JASS:
//Filters STRUCTURE and dead
function GroupCon takes nothing returns boolean
return not(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE)) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.4
endfunction
//Filters Non STRUCTURE and dead
function FilterUnits takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.4
endfunction
//Destroys the timers of the Buildings
function DisableTimer takes nothing returns nothing
call PauseTimer(LoadTimerHandle(udg_Hash,GetHandleId(GetEnumUnit()),1))
call DestroyTimer(LoadTimerHandle(udg_Hash,GetHandleId(GetEnumUnit()),1))
endfunction
function GroupAction takes nothing returns nothing
call ExplodeUnitBJ( GetEnumUnit() )
endfunction
//Timer Action
function SpawnUnit takes nothing returns nothing
local timer t = GetExpiredTimer ()
local unit u = LoadUnitHandle(udg_Hash, GetHandleId(t), 0)
if GetUnitState(u, UNIT_STATE_LIFE) < 0.4 then
call PauseTimer(t)
call DestroyTimer(t)
set u = null
set t = null
return
endif
if GetRandomInt(0,1)==0 then
call IssuePointOrder( CreateUnit(GetOwningPlayer(u), 'hfoo', GetUnitX(u), GetUnitY(u), 270) , "Attack", 0,0)
else
call IssuePointOrder( CreateUnit(GetOwningPlayer(u), 'hrif', GetUnitX(u), GetUnitY(u), 270) , "Attack", 0,0)
endif
set u = null
set t = null
endfunction
//Are all Creeps Dead?
function Kill_Con takes nothing returns boolean
set bj_wantDestroyGroup = true
return CountUnitsInGroup(GetUnitsOfPlayerMatching(Player(PLAYER_NEUTRAL_AGGRESSIVE), Condition(function GroupCon))) == 0
endfunction
//If Kill_Con -> Stop Timers, Victory, Explode Armee
function Kill takes nothing returns nothing
set bj_wantDestroyGroup = true
call ForGroupBJ( GetUnitsInRectMatching(GetPlayableMapRect(), Condition (function FilterUnits)), function DisableTimer )
set bj_wantDestroyGroup = true
call ForGroupBJ( GetUnitsInRectMatching(GetPlayableMapRect(), Condition (function GroupCon)), function GroupAction )
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 99999.00, "You Won!" )
endfunction
//===========================================================================
function InitTrig_UnitSpawn takes nothing returns nothing
local trigger tr = CreateTrigger()
local integer loopA = 0
local integer loopB = 0
local unit u
local timer t
local real angel = -45
set udg_Hash = InitHashtable()
//Spawn Creeps
loop
exitwhen loopA >19
call CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(-1), 0, 0, GetRandomReal(0,360))
set loopA = loopA + 1
endloop
//Spawn Baracks and Timers
set loopA = 0
loop
exitwhen loopA >3
set t = CreateTimer()
set angel = angel + 90
set u = CreateUnit(Player(loopA), 'hbar', 3000 * Cos(angel * bj_DEGTORAD), 3000 * Sin(angel * bj_DEGTORAD), 270)
call SaveUnitHandle(udg_Hash, GetHandleId(t), 0, u)
call SaveTimerHandle(udg_Hash, GetHandleId(u),1,t)
call TimerStart(t, 2.5, true, function SpawnUnit)
set loopB = 0
loop
exitwhen loopB > 3
call SetPlayerAllianceStateAllyBJ( Player(loopA), Player(loopB), true )
call SetPlayerAllianceStateAllyBJ( Player(loopB), Player(loopA), true )
set loopB = loopB + 1
endloop
set loopA = loopA + 1
endloop
set t = null
//Regiester Creep Killing
call TriggerRegisterPlayerUnitEvent( tr, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH, null )
call TriggerAddAction( tr, function Kill )
call TriggerAddCondition( tr, Condition( function Kill_Con ) )
set tr = null
endfunction
Edit: Changed Init and Made Buildings knowing their timers instead of the Player
Edit: Fixed Route -> Square
Attachments
Last edited: