• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Trigger] Trigger that detects if a lot of peasants died in a small time frame

Status
Not open for further replies.
Level 2
Joined
Jun 28, 2015
Messages
20
do you mean track it?
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • Set peasantsdead = (peasantsdead + 1)
peasantsdead will be the amount of peasants that have died
then simply use a timer to set the time frame, resetting the interger.
  • Untitled Trigger 002
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start PeasentTimer as a Repeating timer that will expire in 60.00 seconds
  • Untitled Trigger 003
    • Events
      • Time - PeasentTimer expires
    • Conditions
    • Actions
      • Set peasantsdead = 0
 
Level 21
Joined
Nov 4, 2013
Messages
2,017
This should work instead. Use an array countdown timer variable of size 5 and do this:

  • Peasant Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • Set peasantsdead = (peasantsdead + 1)
      • Countdown Timer - Start PeasantTimer[peasantsdead] as a One-shot timer that will expire in 60.00 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • peasantsdead Greater than or equal to 5
        • Then - Actions
          • Do what you want here...
        • Else - Actions
If it is supposed to run once only then turn off this trigger when the peasantsdead reach 5.

  • Timer Expires
    • Events
      • Time - PeasantTimer[1] expires
      • Time - PeasantTimer[2] expires
      • Time - PeasantTimer[3] expires
      • Time - PeasantTimer[4] expires
      • Time - PeasantTimer[5] expires
    • Conditions
    • Actions
      • Set peasantsdead = (peasantsdead - 1)
So if a peasant died and 60 seconds have passed, it will be removed from the peasants dead in the last minute.
 
Level 5
Joined
Jan 17, 2014
Messages
131
Just when I posted the triggers I thought about this... let me think about a solution.

What is there to think about, just index it (use arrays or hash tables). If I was home right now I would do it myself, and if there isn't a solution that works posted by the time I get home, I'll post one. :p

Edit: Ok, I'm home, and it seems that no one has posted a working solution, so I guess that I'll be the first. Here are 2 simple triggers + attached test map. For those who can follow the array's path of logic, this is simplicity itself. The system should be working for all players (including Neutral Passive, Neutral Hostile, Neutral Extra and Neutral Victim). I have done some tests and it seems to be working properly, but if someone finds a glitch, please let me know. Thank you. :)

Edit_2: Ops, made a little mistake in one of the lines. Don't mind the the triggers or the map, I'll fix them when I get home from work. (Sorry, I'm not perfect. :p)

Edit_3: Fixed. Now you can mind the triggers and the attached map.

  • Trigger
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • Set index = (index + 1)
      • Set owner[index] = (Player number of (Owner of (Triggering unit)))
      • Set timer[index] = 60.00
      • Set owner_index[(Player number of (Owner of (Triggering unit)))] = (owner_index[(Player number of (Owner of (Triggering unit)))] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • owner_index[(Player number of (Owner of (Triggering unit)))] Equal to 5
        • Then - Actions
          • For each (Integer integer) from 1 to index, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • owner[integer] Equal to (Player number of (Owner of (Triggering unit)))
                • Then - Actions
                  • Set owner[integer] = owner[index]
                  • Set timer[integer] = timer[index]
                  • Set index = (index - 1)
                  • Set integer = (integer - 1)
                • Else - Actions
                  • Do nothing
          • Set owner_index[(Player number of (Owner of (Triggering unit)))] = 0
          • -------- Place your action here \/ --------
          • Game - Display to (All players matching ((Matching player) Equal to (Owner of (Triggering unit)))) the text: Five of your Peasan...
          • -------- Place your action here /\ --------
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Trigger Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Trigger Loop <gen>
        • Else - Actions
          • Do nothing
  • Trigger Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer integer) from 1 to index, do (Actions)
        • Loop - Actions
          • Set timer[integer] = (timer[integer] - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • timer[integer] Equal to 0.00
            • Then - Actions
              • Set owner_index[owner[integer]] = (owner_index[owner[integer]] - 1)
              • Set owner[integer] = owner[index]
              • Set timer[integer] = timer[index]
              • Set index = (index - 1)
              • Set integer = (integer - 1)
            • Else - Actions
              • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • index Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing
Variables Legend:
Name --- Type --- Initial Value:


index --- Integer --- 0 (Default)

integer --- Integer --- 0 (Default)

owner --- Integer Array (1) --- 0 (Default)

timer --- Real Array (1) --- 0 (Default)

owner_index --- Integer Array (16) --- 0 (Default)
 

Attachments

  • Test Map for dontsnoozeondalose.w3x
    15.2 KB · Views: 81
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,275
One approach would be an Infinite Impulse Response filter of the period or frequency between deaths. Death frequency is then 1 / T where T is determined period. For example 5 peasants within 1 minute would be a frequency greater than 0.08333 Hz or a period less than 12 seconds.

The only down side of this is the mechanics of an IIR filter. The filter has to be stable for all possible input values and it must have a response function such that it does not get strange values if multiple units die at once. One logically puts a range test on the output of the filter to determine when such a kill frequency is achieved.
 
Level 5
Joined
Jan 17, 2014
Messages
131
One approach would be an Infinite Impulse Response filter of the period or frequency between deaths. Death frequency is then 1 / T where T is determined period. For example 5 peasants within 1 minute would be a frequency greater than 0.08333 Hz or a period less than 12 seconds.

The only down side of this is the mechanics of an IIR filter. The filter has to be stable for all possible input values and it must have a response function such that it does not get strange values if multiple units die at once. One logically puts a range test on the output of the filter to determine when such a kill frequency is achieved.

Dude, you're making this sound way too complicated (not sure if he/she would understand you :p). That's why the system I made is (like I said earlier) simplicity itself and it works fine. :)
 
Level 4
Joined
Jul 25, 2014
Messages
57
Trigger

There is another soltion. Just make 5 timers, if a unit of that type dies the one of the timers start. The timers turn off after 60 seconds. ( make sure that your trigger won´t restart a running timer ). If all the timers are turned on make your action and turn off the timer which has the least time left.
But keep in mind that if 10 peasants die in that 1 min this way your action will occur 6 times. If you dont want it so, then turn off all the timers when your action is ordered.
 
Status
Not open for further replies.
Top