Charapanga
New Member
- Reaction score
- 46
It only spawns first wave, the dialog works but the buttons don't
its 4 triggers in one so...and the library is going to be for later usage too
JASS:
library Library initializer InitLib
globals
integer SpawnIdEast = 039;hfoo039;
integer SpawnIdWest = 039;hfoo039;
timer spawntimer = CreateTimer()
timerdialog spawntimerdialog = CreateTimerDialog(spawntimer)
force EastTeam = CreateForce()
force WestTeam = CreateForce()
player EastSpawner = Player(10)
player WestSpawner = Player(11)
player EastLeader = Player(0)
player WestLeader = Player(1)
dialog array SpawnDialog
button array SpawnDialogButtons
endglobals
private function Init takes nothing returns nothing
call ForceEnumAllies(EastTeam, EastSpawner, null)
call ForceEnumAllies(WestTeam, WestSpawner, null)
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "|cff00ff00Welcome to Team Line Tower Defense!|r\n|cff0000ffPlayers Red and Blue are team leaders, they can chose what creeps by typing in|r -spawns !\n|cffff0000Good luck and have fun!|r")
call StartTimerBJ(spawntimer, true, 5)
call TimerDialogSetTitle(spawntimerdialog, "Spawns in: ")
call TimerDialogDisplay(spawntimerdialog, true)
set SpawnDialog[1] = DialogCreate()
set SpawnDialog[2] = DialogCreate()
set SpawnDialogButtons[1] = DialogAddButton(SpawnDialog[1], "F|cffff0000ootman|r", 039;F039;)
set SpawnDialogButtons[2] = DialogAddButton(SpawnDialog[1], "K|cffff0000night|r", 039;K039;)
set SpawnDialogButtons[11] = DialogAddButton(SpawnDialog[2], "F|cffff0000ootman|r", 039;F039;)
set SpawnDialogButtons[12] = DialogAddButton(SpawnDialog[2], "K|cffff0000night|r", 039;K039;)
endfunction
private function InitLib takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.01, false)
call TriggerAddAction(t, function Init)
endfunction
endlibrary
scope Spawns initializer Init
private function IsEastSpawn takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == SpawnIdEast and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0.5
endfunction
private function IsWestSpawn takes nothing returns boolean
return GetUnitTypeId(GetFilterUnit()) == SpawnIdWest and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0.5
endfunction
private function AllUnitsAreDead takes nothing returns boolean
local group g = CreateGroup()
local group g1 = CreateGroup()
call GroupEnumUnitsInRect(g, gg_rct_AreaEast, Condition(function IsEastSpawn))
call GroupEnumUnitsInRect(g, gg_rct_AreaWest, Condition(function IsWestSpawn))
if CountUnitsInGroup(g) + CountUnitsInGroup(g1) == 0 then
call DestroyGroup(g)
call DestroyGroup(g1)
set g = null
set g1 = null
return true
endif
call DestroyGroup(g)
call DestroyGroup(g1)
set g = null
set g1 = null
return false
endfunction
private function Actions takes nothing returns nothing
local integer i = 0
local unit dummy
loop
exitwhen i == 15
set dummy = CreateUnit(EastSpawner, SpawnIdEast, GetRectCenterX(gg_rct_StartEast), GetRectCenterY(gg_rct_StartEast), 0)
call IssuePointOrder(dummy, "move", GetRectCenterX(gg_rct_EndEast), GetRectCenterY(gg_rct_EndEast))
set dummy = null
set dummy = CreateUnit(WestSpawner, SpawnIdWest, GetRectCenterX(gg_rct_StartWest), GetRectCenterY(gg_rct_StartWest), 0)
call IssuePointOrder(dummy, "move", GetRectCenterX(gg_rct_EndWest), GetRectCenterY(gg_rct_EndWest))
set dummy = null
set i = i + 1
endloop
call TimerDialogDisplay(spawntimerdialog, false)
call DestroyTimerDialog(spawntimerdialog)
call DestroyTimer(spawntimer)
loop
exitwhen AllUnitsAreDead()
call TriggerSleepAction(1)
endloop
set spawntimer = CreateTimer()
call StartTimerBJ(spawntimer, false, 5)
set spawntimerdialog = CreateTimerDialog(spawntimer)
call TimerDialogSetTitle(spawntimerdialog, "Spawns in:")
call TimerDialogDisplay(spawntimerdialog, true)
call TriggerRegisterTimerExpireEvent(GetTriggeringTrigger(), spawntimer)
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterTimerExpireEvent(t, spawntimer)
call TriggerAddAction( t, function Actions )
endfunction
endscope
scope SpawnDialog initializer Init
private function Actions takes nothing returns nothing
local player p = GetTriggerPlayer()
local integer pn = GetPlayerId(p) + 1
call DialogDisplayBJ(true, SpawnDialog[pn], p)
if pn == 2 then
call DisplayTextToForce(WestTeam, "|cff00ff00Player|r |cff0000ffBlue|r |cff00ff00will now choose the spawns!|r")
elseif pn == 1 then
call DisplayTextToForce(EastTeam, "|cff00ff00Player|r |cffff0000Red|r |cff00ff00will now choose the spawns!|r")
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, EastLeader, "-spawns", true)
call TriggerRegisterPlayerChatEvent(t, WestLeader, "-spawns", true)
call TriggerAddAction(t, function Actions)
set t = null
endfunction
endscope
scope SpawnPick initializer init
private function Actions takes nothing returns nothing
local button b = GetClickedButton()
if b == SpawnDialogButtons[1] then
set SpawnIdWest = 039;hfoo039;
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Footmen will now spawn for the West Team!")
elseif b == SpawnDialogButtons[2] then
set SpawnIdWest = 039;hkni039;
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Knights will now spawn for the West Team!")
elseif b == SpawnDialogButtons[11] then
set SpawnIdEast = 039;hfoo039;
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Footmen will now spawn for the East Team!")
elseif b == SpawnDialogButtons[12] then
set SpawnIdEast = 039;hkni039;
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS, "Knights will now spawn for the East Team!")
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
set i = i + 1
call TriggerRegisterDialogEvent(t, SpawnDialog<i>)
exitwhen i == 2
endloop
call TriggerAddAction(t, function Actions)
endfunction
endscope</i>
its 4 triggers in one so...and the library is going to be for later usage too