• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Creeps death victory condition.

Status
Not open for further replies.
Level 2
Joined
May 15, 2019
Messages
14
Hello, I am currently working on a Tower defense and I would like that when the units of the last wave are killed, we obtain victory. But I can't find the right way to formulate this trigger. Thank you all in advance for your help.
 
Level 24
Joined
Jun 26, 2020
Messages
1,928
You can do:
  1. Set a variable (I will call it i) that indicates the number of units of the final wave are spawning (I will call the max m), with the event "Unit enters on Playable map area".
  2. Create a trigger with the event "A unit dies"
  3. The conditions will be "i Equal to m" and "Unit type of Dying unit Equal to <That type of uni>")
  4. In actions put victory.
 
Last edited:
Level 2
Joined
May 15, 2019
Messages
14
I forgot to mention that there' s a line for each player and that if a player is not in the game then he doesn't have a wave in his line. So it's almost impossible to know the number of units. I think it would require a much more complex trigger to make it work :(
 
Level 24
Joined
Feb 27, 2019
Messages
835
How does your game detect when a wave ends? Its good to have some systems that are easily modifiable. Like what Herly is saying.

For example:

First trigger
Spawn 20 units
Add units to group

Next trigger
Unit dies
Unit is in group
Remove unit from group
Nmbr of units in group = 0
Then
Start next segment of triggers
 
Level 2
Joined
May 15, 2019
Messages
14
I think I'm going to have to reconsider the way I make my waves. This is my first map for life, well, the first one I'm trying to do seriously. I've made a rather messy wave system. I'll show it to you.

Each wave is made of three triggers. The first wave is triggered when the indicated time is exceeded.

Example of wave 1 (then it's only copies) :

Wave 1 timer starts :
  • lvl 1
    • Events
      • Time - Elapsed game time is 44.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start lvl_1_timer as a One-shot timer that will expire in 30.00 seconds
      • Sound - Play Warning <gen> at 100.00% volume, skipping the first 0.00 seconds
      • Game - Display to (All players) the text: Evil forces are ris...
      • Set VariableSet lvl_1_timer = (Last started timer)
      • Countdown Timer - Create a timer window for (Last started timer) with title |cffd45e19Footmen|r...
      • Set VariableSet lvl_1_windows = (Last created timer window)
      • Countdown Timer - Show (Last created timer window)

Wave 1 creeps spawning

  • level 1 spawn
    • Events
      • Time - lvl_1_timer expires
    • Conditions
    • Actions
      • Countdown Timer - Start lvl_1_rates as a Repeating timer that will expire in 0.50 seconds
      • Game - Display to (All players) the text: |cff808080Level 1 -...
      • Set VariableSet lvl_1_rates = (Last started timer)
      • Sound - Play ClanInvitation <gen> at 50.00% volume, skipping the first 0.00 seconds

Wave 1 creeps spawning rates (it makes the creeps spawn 1 by 1 instead of a mass)
  • level 1 spawn
    • Events
      • Time - lvl_1_timer expires
    • Conditions
    • Actions
      • Countdown Timer - Start lvl_1_rates as a Repeating timer that will expire in 0.50 seconds
      • Game - Display to (All players) the text: |cff808080Level 1 -...
      • Set VariableSet lvl_1_rates = (Last started timer)
      • Sound - Play ClanInvitation <gen> at 50.00% volume, skipping the first 0.00 seconds

I'm going to have to set a variable to identify the number of creatures that are created but I don't understand much the variables yet.
 
Level 24
Joined
Feb 27, 2019
Messages
835
You can set a few variable arrays in the begining of the game if you want. It will make the game easier to modify. Just make sure to set the array size pretty high because you cant change it later without having to redo a lot of things. Here are some examples:

Set CreepAmount[1] = 20
Set SpawnRate[1] = 0.50
Set RoundDisplay[1] = Your text
Set LevelUnit[1] = Footman
Set CreepAmount[2] = 10
Set SpawnRate[2] = 1.00
Set RoundDisplay[2] = Your text
Set LevelUnit[2] = Kodo Beast
...

You can also set player based variables and use Player Number of (X) to get the correct index.

Set SpawnLoc[1] = Center of Spawn P1
Set SpawnLoc[2] = Center of Spawn P2
...

Timer expires

Set Level = Level + 1
Countdown Timer - Start Timer as a Repeating timer that will expire in SpawnRate[Level] seconds
Game - Display to (All players) the text: RoundDisplay[Level]
Set TotalCreepAmount = CreepAmount[Level] x (Players matching conditions) (equal to is playing, has not lost etc)
Turn off this trigger
Turn on Spawn


Spawn

Timer expires

If
CreepCount not equal to CreepAmount[Level]
Then
Set CreepCount = CreepCount + 1
Create 1 LevelUnit[Level] for Player X at X facing X
Add (Last created unit) to Group
Else
Set CreepCount = 0
Turn off this trigger
Turn on End Wave


End Wave

Unit dies

Dying unit is in Group = true

Remove (Dying unit) from Group
IF
TotalCreepAmount = 0
THEN
If
Level not equal to 20 (Lets say 20 is last level)
Then
Do the next triggers to start next spawn or whatever
Turn off this trigger
Else
Victory
ELSE
 
Last edited:
Level 2
Joined
May 15, 2019
Messages
14
Thanks a lot, I was to noob to make it works in your way but I managed to make it work with settings up my variables.

So it works this way :

When units enter last region, instead of removing it from the game, i'm killing it.

  • Lives lost red
    • Events
      • Unit - A unit enters Red Spawn C <gen>
    • Conditions
      • (Owner of (Entering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set VariableSet Red_lives = (Red_lives - 1)
      • Unit - Kill (Entering unit)
      • Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to Red_lives
      • Trigger - Run Red <gen> (checking conditions)
Then I was able to make this trigger

  • Lastwave
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Footmen ( I just have to change it to the last unit )
    • Actions
      • Set VariableSet Creep_amount[1] = (Creep_amount[1] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Creep_amount[1] Equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: YOU WON!
        • Else - Actions
          • Do nothing
 
Level 24
Joined
Feb 27, 2019
Messages
835
I didnt explain well enough but you did good on your own.

I will attempt to give some tips:
You could set an Integer Variable to + 1 each time a new level occurs. This way the Integer will keep track of the current level.

If you set
Unit[1] = footman
Unit[2] = footman
...
You only need 1 trigger for every level like so:
Create 1 Unit[Level] for Player 12 at X facing X

Then you can set Point variables for each players spawn

Set Spawn[1] = Center of Region1
Set Spawn[2] = Center of Region2
Set FirstPoint[1] = Center of Region 12
Set FirstPoint[2] = Center of Region 13
...
Set TempForce = Players matching...
Pick every player in TempForce and do multiple actions
Create 1 Unit[Level] for (Player 12) at Spawn[Player number of (Picked player)] facing FirstPoint[Player number of (Picked player)]
Order last created unit to move to FirstPoint[Player number of (Picked player)]
call DestroyForce(udg_TempForce)

Player number of player means 1 for player 1, 2 for player 2, 3 for player 3 ... so the variable Spawn[2] is for player 2.

Instead of using TempForce one could create a Force as the game begins. Then remove defeated players aswell as leavers from the Force.
Set ActivePlayers = ...

On the trigger youve made though, theres a slight chance that player red has 1 life left as the last unit enters the region. Have you considered or tested what will happen then?
 
Level 2
Joined
May 15, 2019
Messages
14
Thanks for the tips!

And for "chance that player red has 1 life left as the last unit enters the region" I just tested it, for now it gives both but in my victory trigger, it asks to wait for 20 seconds before giving victory. So for now you get defeated with the victory text haha. I might have to make a condition where if red lives is equal or greater to 1, set victory = on. And then if victory = on, run victory else defeat. I will brainstorm about a efficient way to do it.
 
Status
Not open for further replies.
Top