kirinelf
New Member
- Reaction score
- 10
Well, I'm making a Castle Defense, and the problem is that the spawn doesn't work. It's similar in theory to the spawning system in a tower defense: At a certain point in time, a wave of creeps is spawned and ordered to move to a certain point. The key difference between my CD and conventional TDs is that most TDs have that 'certain time' as a time interval, every minute, say, or 30 seconds. My CD has it said 'certain time' as when all the units on the field belonging to a certain player has gone south.
I also decided to spice things up a bit by adding a -spawn command. This will override the default spawn settings, immediately spawning the next wave of creeps whether or not there're any left living. If done at the beginning of a wave, in effect, it'd be taking on two waves at once.
These are my triggers. The Spawn Initialization and Spawn Commands are in GUI, and the actual spawning is in JASS:
Now, the problem is this: The game successfully detects that the units are dead and starts the timer. All good. The thing is, once the timer hits zero, nothing happens. The Timer Window just stays there at 0, and I know that there's a line of code in the Spawn Creeps trigger that kills it. From what I gather, the Spawn Creeps trigger (The one in JASS) just plain isn't being run after the timer hits 0. The -spawn command works perfectly though, probably because it forces the trigger to run...?
Anyways, this is rather crucial to the map, unless I decide to make it so that only Red can decide when the next wave comes. So I'd really appreciate some help with this. +Rep for helpers! ^^;;
I also decided to spice things up a bit by adding a -spawn command. This will override the default spawn settings, immediately spawning the next wave of creeps whether or not there're any left living. If done at the beginning of a wave, in effect, it'd be taking on two waves at once.
These are my triggers. The Spawn Initialization and Spawn Commands are in GUI, and the actual spawning is in JASS:
Trigger:
- Spawn Initialization
- Events
- Time - Elapsed game time is 5.00 seconds
- Player - Player 12 (Brown)'s Food used becomes Equal to 0.00
- Conditions
- Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- LevelCount Greater than 0
- Then - Actions
- Game - Display to inGamePlayers for 5.00 seconds the text: Wave complete. Well...
- Set LevelCount = (LevelCount + 1)
- Set BonusIncome = (BonusIncome + 200)
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- LevelCount Equal to (CreepCount_LastIndex + 1)
- Then - Actions
- Wait 2.00 seconds
- Player Group - Pick every player in inGamePlayers and do (Actions)
- Loop - Actions
- Game - Victory (Picked player) (Show dialogs, Show scores)
- Loop - Actions
- Else - Actions
- Player Group - Pick every player in inGamePlayers and do (Actions)
- Loop - Actions
- Player - Add BonusIncome to (Picked player) Current gold
- Loop - Actions
- Countdown Timer - Create a timer window for CreepTimer with title (Wave + ((String(LevelCount)) + ( - + ( ( + (CreepName[LevelCount] + ))))))
- Countdown Timer - Start CreepTimer as a One-shot timer that will expire in 10.00 seconds
- Set CreepTimerWindow = (Last created timer window)
- Countdown Timer - Show CreepTimerWindow
- Player Group - Pick every player in inGamePlayers and do (Actions)
- If - Conditions
- Else - Actions
- Set LevelCount = (LevelCount + 1)
- Set BonusIncome = (BonusIncome + 200)
- Countdown Timer - Create a timer window for CreepTimer with title (Wave + ((String(LevelCount)) + ( - + ( ( + (CreepName[LevelCount] + ))))))
- Countdown Timer - Start CreepTimer as a One-shot timer that will expire in 10.00 seconds
- Set CreepTimerWindow = (Last created timer window)
- Countdown Timer - Show CreepTimerWindow
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Events
Trigger:
- Spawn Command
- Events
- Player - Player 1 (Red) types a chat message containing -spawn as An exact match
- Conditions
- LevelCount Greater than 0
- LevelCount Less than CreepCount_LastIndex
- Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Remaining time for CreepTimer) Less than or equal to 0.00
- Then - Actions
- Set LevelCount = (LevelCount + 1)
- Set BonusIncome = (BonusIncome + 200)
- Trigger - Run Spawn Creeps <gen> (ignoring conditions)
- Else - Actions
- Trigger - Run Spawn Creeps <gen> (ignoring conditions)
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Events
JASS:
function Trig_Spawn_Creeps_Actions takes nothing returns nothing
local integer i
local integer unitspawn
local integer unitamount
// Destroy the timer window, to make room for the next one, when the time comes.
set unitspawn = udg_CreepArray[udg_LevelCount]
set unitamount = udg_CreepAmount[udg_LevelCount]
call DestroyTimerDialog(udg_CreepTimerWindow)
set udg_CreepTimer = CreateTimer()
// Lets have a small wait between each spawn.
// Reduces lagg by reducing the amount of units created per second.
set i = 1
loop
exitwhen i > unitamount
call TriggerSleepAction(1)
call CreateUnitAtLoc(udg_HostileCreeps, unitspawn, udg_creepSpawn[1], 0.00 )
call CreateUnitAtLoc(udg_HostileCreeps, unitspawn, udg_creepSpawn[2], 0.00 )
call CreateUnitAtLoc(udg_HostileCreeps, unitspawn, udg_creepSpawn[3], 0.00 )
call CreateUnitAtLoc(udg_HostileCreeps, unitspawn, udg_creepSpawn[4], 0.00 )
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_Spawn_Creeps takes nothing returns nothing
set gg_trg_Spawn_Creeps = CreateTrigger()
call TriggerRegisterTimerExpireEvent(gg_trg_Spawn_Creeps, udg_CreepTimer)
call TriggerAddAction(gg_trg_Spawn_Creeps, function Trig_Spawn_Creeps_Actions)
endfunction
Now, the problem is this: The game successfully detects that the units are dead and starts the timer. All good. The thing is, once the timer hits zero, nothing happens. The Timer Window just stays there at 0, and I know that there's a line of code in the Spawn Creeps trigger that kills it. From what I gather, the Spawn Creeps trigger (The one in JASS) just plain isn't being run after the timer hits 0. The -spawn command works perfectly though, probably because it forces the trigger to run...?
Anyways, this is rather crucial to the map, unless I decide to make it so that only Red can decide when the next wave comes. So I'd really appreciate some help with this. +Rep for helpers! ^^;;