• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Kill certain amount of units triggers something

Status
Not open for further replies.
Level 5
Joined
Apr 3, 2015
Messages
104
Hello everyone, i have a little problem trying to figure out something i want to do.

In my map, you're a kind of a serial killer but if you kill 5 bystanders (there are multiple unit marked as bystanders not only one e.x: villager 1, 2 and dog are bystanders meanwhile "Eric" and cops are not.) in less than 10 seconds, cops will appear and look for you.

Problem is, i dont know how to do the trigger when if you go on a rampage cops come. any help? :(
 
Level 10
Joined
Apr 4, 2010
Messages
286
  • Trigger 1
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Add Villager 1 to UnitGroupBystanders
    • Add Villager 2 to UnitGroupBystanders
    • Add Dog to UnitGroupBystanders
  • Trigger 2
  • Events
    • A unit is killed
  • Conditions
    • Boolean (Killed unit is in UnitGroupBystanders) Equal to True
  • Actions
    • Turn off (this trigger)
    • Turn on Trigger 3
    • Set IntegerVariable = IntegerVariable + 1
    • Start RampageTimer as a One-shot timer that will expire in 30 seconds
  • Trigger 3 -- Initially off
  • Events
    • A unit is killed
  • Conditions
    • Boolean (Killed unit is in UnitGroupBystanders) Equal to True
  • Actions
    • Set IntegerVariable = IntegerVariable + 1
    • If / Then / Else (multiple functions)
      • If (conditions)
        • IntegerVariable > 5
      • Then (actions)
        • ------- Spawn cops -------
  • Trigger 4
  • Events
    • RampageTimer expires
  • Conditions
  • Actions
    • Turn off Trigger 3
    • Turn on Trigger 2
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
There is an error above. IntegerVariable is never reset to 0 so it will count any 5 kills at any time.

Assuming that error is corrected, the problem with that solution is that it does not count kills made within a certain time of each other but rather in bursts from the first kill. It would fail the following test with a rampage timer of 10 seconds and 5 kills being required.
  1. Kill 1
  2. Wait 9 seconds.
  3. Kill 3
  4. Wait 2 seconds.
  5. Kill 2 <- This should spawn as it was 5 kills in 2 seconds but will not as the 3 kills were lost by timer expiring.
One has to track each kill as an instance which will expire within 10 seconds. If 5 such instances accumulate at any given time then the units spawn, and possibly all accumulated instances are destroyed.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Hey I have a solution instead of making the unit group like that (if it is annoying to make such a group - say there are a hundred units on the map).

A trick I use in my own maps is to make a dummy ability (like item bonus armor but it adds 0 armor), name it something like "bystander" and then give this ability to every unit in the object editor that will be a bystander. Then, instead of
  • Boolean (Killed unit is in UnitGroupBystanders) Equal to True
you would just use
  • Boolean Level of (bystander) for (Killed Unit) Equal to 1
This would save the hassle of setting up who is and who isn't a bystander by adding them to a unit group one at a time.

The only downside is if there are units that will sometimes be a bystander and sometimes not. Depending on how it works in your map, you could use triggers to add / remove the ability or use a system like a unit indexer which is more flexible and can be used for a lot of other things.
 
Level 10
Joined
Apr 4, 2010
Messages
286
Hey I have a solution instead of making the unit group like that (if it is annoying to make such a group - say there are a hundred units on the map).

A trick I use in my own maps is to make a dummy ability (like item bonus armor but it adds 0 armor), name it something like "bystander" and then give this ability to every unit in the object editor that will be a bystander. Then, instead of
  • Boolean (Killed unit is in UnitGroupBystanders) Equal to True
you would just use
  • Boolean Level of (bystander) for (Killed Unit) Equal to 1
This would save the hassle of setting up who is and who isn't a bystander by adding them to a unit group one at a time.

The only downside is if there are units that will sometimes be a bystander and sometimes not. Depending on how it works in your map, you could use triggers to add / remove the ability or use a system like a unit indexer which is more flexible and can be used for a lot of other things.

This is clever.
 
Level 10
Joined
Apr 4, 2010
Messages
286
Okay, here's another approach to this system. It's goofy and uses a totally unnecessary resource (units) but it should do what you want.

I'm not gonna spell out all the triggers but the gist is this:
1. Make a dummy unit with no model, no vision or attacks, and the locust and invulnerable (neutral) abilities.
2. Make a trigger that fires every time one of the "Bystanders" dies, that creates a dummy unit and adds it to a Unit Group. Have that trigger also add a timed life/expiration timer to the created unit of 10 sec (or whatever you want the Rampage time to be).
3. Make a trigger that removes the dummy units from the Unit Group when they die.
4. Whenever a player kills a bystander, you can query the number of units in the Unit Group to see how many dummy units are alive. This should functionally be equivalent to how many Bystanders were killed in the last N seconds (Rampage time).

I probably wouldn't use this approach if A) you have a lot of general "A unit dies" triggers already or if B) you're already using dummy units/dummy casters for a lot of stuff. But otherwise this would probably work fine.
 
Level 5
Joined
Apr 3, 2015
Messages
104
Between Jake and SAUS's solutions it's working :D thanks a lot guys, dummies probed to work a lot better with leaving a dummy everytime a bystander dies, so what i did is add "Count Units by Type" and when there are 5 dummies (they expire in 15 seconds) you enter on "Rampage" what that triggers does it makes the screen shakes and creates a red fog reducing your visibilty also, it spawns 3 cops that will try to stop you (snaring you) when that happens you're teleported to a prison where other killers can rescue you or a detective can execute you :) Fin...
 
Last edited:
Status
Not open for further replies.
Top