waaaks!
Zinctified
- Reaction score
- 256
I have this trigger that spawns runes randomly either in top or bottom regions, Im trying to replicate dota's rune system, after the rune is acquired, the trigger still runs the enumitemsinrect even though there are no items in that region
JASS:
scope Runes initializer init
globals
private integer top
private integer bot
private integer array rune
private integer count = 1
private integer botCount = 0
private integer topCount = 0
endglobals
private function con takes nothing returns boolean
return top == 0 and bot == 0
endfunction
private function filtRune takes nothing returns boolean
return GetItemType(GetFilterItem()) == ITEM_TYPE_POWERUP
endfunction
private function botRune takes nothing returns nothing
set botCount = 1
call BJDebugMsg("b.")
endfunction
private function topRune takes nothing returns nothing
set topCount = 1
call BJDebugMsg("t.")
endfunction
private function pact takes nothing returns nothing
call EnumItemsInRect(gg_rct_runeBot, Condition(function filtRune), function botRune)
call EnumItemsInRect(gg_rct_runeTop, Condition(function filtRune), function topRune)
if botCount == 0 then
set bot = 0
call BJDebugMsg("bottom no rune")
elseif botCount > 0 then
set bot = 1
endif
if topCount == 0 then
set top = 0
call BJDebugMsg("top no rune")
elseif topCount > 0 then
set top = 1
endif
set botCount = 0
set topCount = 0
endfunction
private function act takes nothing returns nothing
local integer where = GetRandomInt(1,2)
local integer ran = GetRandomInt(0,(count-1))
if where == 1 then
set bot = 1
call BJDebugMsg("rune on bottom")
call CreateItem(rune[ran],GetRectCenterX(gg_rct_runeBot),GetRectCenterY(gg_rct_runeBot))
elseif where == 2 then
set top = 1
call BJDebugMsg("rune on top")
call CreateItem(rune[ran],GetRectCenterX(gg_rct_runeTop),GetRectCenterY(gg_rct_runeTop))
endif
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( t, 10.00 )
call TriggerAddCondition(t, Condition(function con))
call TriggerAddAction( t, function act )
set t = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( t, 1.0 )
call TriggerAddAction(t,function pact)
set rune[0] = 039;I00I039;
set top = 0
set bot = 0
endfunction
endscope