So I'm working on an arena game in which each player controls one hero unit at a time. I have a good trigger that allows players to choose a unit type and spawn when the map initializes, but I'm having trouble making one that triggers when a players unit dies.
This trigger need to independent for each player and occur when that player's unit dies. Possibly add a timer in there that makes it so they have to wait 5 seconds to spawn. something of that nature.
I have the dialog actions set up for the trigger i just cant seem to find event/condition that activate the trigger for each player respectively when their units die.
I made a respawn trigger for like normal mops in WoW or any MMO or game that has mob respawn timers.. Maybe you can use it for your map. If you kill 5 of them then each mob respawns like 10 secs later they dont ALL spawn.. 1 Spawns every 10 seconds.. so if you kill 5. You would have to wait 50 secs for all 5 mobs to respawn... I was trying to make a timer Array and have each mob its own timer, but I couldnt quite figure it out.. so i simplified it.. here is the Code as text. You need a global to track how many mobs died if you only want to have 5 mobs on screen at a time.. That variable is just to say when to stop.
**First Trigger:**
UnitKilled
Events
Unit - Any Unit dies
Local Variables
Conditions
((Triggering unit) is in Test) == true
And
Conditions
(Owner of (Triggering unit)) == 15
Actions
Variable - Modify UnitsDead: + 1
** Test is the Test Region I made to test this trigger out. You can set the Region to Entire World if you want**
**2nd Trigger**
Respawn
Events
Timer - Every 5.0 seconds of Game Time
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
UnitsDead > 0
Then
Unit - Create 1 Zergling for player 15 at (Random point in Test) using default facing (No Options)
Variable - Modify UnitsDead: - 1
Deku, I think something such as this is what you are looking for, quite simple really (make sure you play around with events/actions, search for functions youre looking for, etc.)
Make a global variable say PlayerUnits of type Unit, make it an array of size 15 (1 for each possible player, doesnt matter how many players you actually are going to have):
PlayerUnits=NoUnit<Unit[15]>
In your trigger where you spawn the unit for a player, make an action that adds that unit to the variable, something like:
Im not sure if this next part works exactly, but it would be something very similar if not. Make a new trigger, Player Unit Dies or whatever. Make the event:
Took a few day sabbatical from my map and came back with a spark of genius.
the dialog box was created via another trigger at initialization.
this is the trigger that I am now using:
So I'm working on an arena game in which each player controls one hero unit at a time. I have a good trigger that allows players to choose a unit type and spawn when the map initializes, but I'm having trouble making one that triggers when a players unit dies. This trigger need to independent for each player and occur when that player's unit dies. Possibly add a timer in there that makes it so they have to wait 5 seconds to spawn. something of that nature.
I have the dialog actions set up for the trigger i just cant seem to find event/condition that activate the trigger for each player respectively when their units die.
I made a respawn trigger for like normal mops in WoW or any MMO or game that has mob respawn timers.. Maybe you can use it for your map. If you kill 5 of them then each mob respawns like 10 secs later they dont ALL spawn.. 1 Spawns every 10 seconds.. so if you kill 5. You would have to wait 50 secs for all 5 mobs to respawn... I was trying to make a timer Array and have each mob its own timer, but I couldnt quite figure it out.. so i simplified it.. here is the Code as text. You need a global to track how many mobs died if you only want to have 5 mobs on screen at a time.. That variable is just to say when to stop.
**First Trigger:**
UnitKilled
Events
Unit - Any Unit dies
Local Variables
Conditions
((Triggering unit) is in Test) == true
And
Conditions
(Owner of (Triggering unit)) == 15
Actions
Variable - Modify UnitsDead: + 1
** Test is the Test Region I made to test this trigger out. You can set the Region to Entire World if you want**
**2nd Trigger**
Respawn
Events
Timer - Every 5.0 seconds of Game Time
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
UnitsDead > 0
Then
Unit - Create 1 Zergling for player 15 at (Random point in Test) using default facing (No Options)
Variable - Modify UnitsDead: - 1
Else
Hope this helps.
Nice trigger. it's sexy.... if game code can be such. I'm not well versed in the multifunctions of global variables so it's good to see some examples
Unfortunately I don't think it helps for this specific issue.
what i need is something for the events and conditions that says: anytime a player's unit count = 0 create dialog box for that player.
i have the actions i want already; a dialog box from which the player chooses what to spawn as.
@Dekuleaf: Go
Deku, I think something such as this is what you are looking for, quite simple really (make sure you play around with events/actions, search for functions youre looking for, etc.)
Make a global variable say PlayerUnits of type Unit, make it an array of size 15 (1 for each possible player, doesnt matter how many players you actually are going to have):
In your trigger where you spawn the unit for a player, make an action that adds that unit to the variable, something like:
Im not sure if this next part works exactly, but it would be something very similar if not. Make a new trigger, Player Unit Dies or whatever. Make the event:
Now in the actions, respawn the unit.
Took a few day sabbatical from my map and came back with a spark of genius. the dialog box was created via another trigger at initialization. this is the trigger that I am now using:
if anyone sees a major flaw, let me know
@Dekuleaf: Go
oh, forgot to mention that the unit actually spawns from the clicking of a dialog button: