• 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.

Tracking total damage done to specific target

Status
Not open for further replies.
Level 2
Joined
Dec 28, 2023
Messages
2
Hello everyone! Long-time lurker, first time poster.

I'm working on a 1v1 map with multiple phases and during several of them I want there to be a contest of dealing damage to a mutual enemy. I've read through several forum posts here and on thehelper.net and still don't see what I'm looking for, it seems excessive, or I don't seem to understand it. I'm trying to stick with GUI; do I have to pull a whole damage system, or can I manage with just triggers and variables? It's okay if the triggers are long or annoying to compile, I'm patient enough for the GUI struggle, I just don't want to take the time to learn JASS.. yet.

Thanks in advance!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
Hello!

So Bribe's Damage Engine (the most popular system to use) used to be necessary if you wanted to work in GUI. However, it's no longer necessary as of patch 1.31 which introduced generic Damage Events to the GUI editor. That being said, his system has so many useful features (damage recursion being a huge one) that you may find yourself wanting to use it anyway.

But your use case sounds simple enough. Here's how you could go about it (I attached a map example below):
  • Damage Tracker Simple
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Owner of (Damage Target)) Equal to Neutral Hostile
    • Actions
      • Set VariableSet Dmg_PN = (Player number of (Owner of (Damage source)))
      • Set VariableSet Dmg_Total[Dmg_PN] = (Dmg_Total[Dmg_PN] + (Damage taken))
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Player(Dmg_PN))) + ( total damage dealt: + (String(Dmg_Total[Dmg_PN]))))
This trigger tracks Total damage dealt by each Player against the Neutral Hostile player.


Here's a more elaborate trigger that does the above but also tracks Damage Per Second (DPS):
  • Damage Tracker Advanced
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Owner of (Damage Target)) Equal to Neutral Hostile
    • Actions
      • -------- We're using a technique called Shadowing to make our global variables act like local variables in this trigger. --------
      • -------- Ideally you would keep this trigger off while it's not being used. --------
      • -------- --------
      • Custom script: local real udg_Dmg_Dealt
      • Custom script: local integer udg_Dmg_PN
      • -------- --------
      • Set VariableSet Dmg_PN = (Player number of (Owner of (Damage source)))
      • Set VariableSet Dmg_Dealt = (Damage taken)
      • Set VariableSet Dmg_Per_Second[Dmg_PN] = (Dmg_Per_Second[Dmg_PN] + Dmg_Dealt)
      • Set VariableSet Dmg_Total[Dmg_PN] = (Dmg_Total[Dmg_PN] + Dmg_Dealt)
      • -------- --------
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Player(Dmg_PN))) + ( dps: + (String(Dmg_Per_Second[Dmg_PN]))))
      • -------- --------
      • Wait 1.00 seconds
      • -------- --------
      • Set VariableSet Dmg_Per_Second[Dmg_PN] = (Dmg_Per_Second[Dmg_PN] - Dmg_Dealt)
      • -------- --------
      • Game - Display to (All players) for 30.00 seconds the text: ((Name of (Player(Dmg_PN))) + ( total damage dealt: + (String(Dmg_Total[Dmg_PN]))))
The Text Messages in both triggers are optional.

(Damage source) = The unit that dealt the damage.
(Damage Target) = The unit that was dealt damage.
(Damage taken) = How much damage the target has received.

The variables are all Integers/Reals (some Arrays).

There's a bunch of other Conditions/Actions/Functions you can find related to this Event. Unfortunately, Blizzard devs were a bit poor in their organization and put these under the "Event Response" category which makes absolutely no sense. They should've all been categorized under a new "Damage" category.
 

Attachments

  • Damage Tracker.w3m
    19.3 KB · Views: 5
Last edited:
Level 2
Joined
Dec 28, 2023
Messages
2
Thank you for the quick and helpful response, Uncle!

After posting I found something that worked, but not as well as I was hoping. I haven't tested your post yet, but I can already see how it works just from the sequence. [I will tweek my map and post complete confirmation of this soon.]

I would also like to display the damage total for the players on a board during the phase in "real-time" during the event, can you also help me with that? [I could probably figure this out with the effort, but it's also new to me, so a nudge in the right direction would be helpful and appreciated] :)

Bonus question, just for my own organization in the editor.. Can you make notes INSIDE the triggers, or is that just something we can do here in the hive? [See attachment]
 

Attachments

  • WE Trigger Comment.png
    WE Trigger Comment.png
    6.3 KB · Views: 9

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
No problem, I can show you how to implement it with a Leaderboard. Also, I edited my last post a few times, so hopefully that didn't confuse you too much. I originally thought you wanted DPS for some reason so I implemented that - realizing my mistake afterwards hence why I made a simple and advanced trigger.

1) Create a trigger to handle the creation of the leaderboard and to get things started:
  • Damage Tracker Start
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- Run this trigger when you're ready to START the Damage Tracker phase! --------
      • Leaderboard - Create a leaderboard for (All players) titled Total Damage:
      • Set VariableSet Dmg_Leaderboard = (Last created leaderboard)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Leaderboard - Add (Picked player) to Dmg_Leaderboard with label (Name of (Picked player)) and value 0
      • Trigger - Turn on Damage Tracker <gen>
You can manually Add individual Players to the Leaderboard or change (All players) in the Player Group to your specific set of Players.

2) Create a trigger to handle what happens when you're finished tracking damage. This shows the winner and destroys the leaderboard:
  • Damage Tracker Stop
    • Events
    • Conditions
    • Actions
      • -------- Run this trigger when you're ready to STOP the Damage Tracker phase! --------
      • Leaderboard - Sort Dmg_Leaderboard by Value in Descending order
      • Game - Display to (All players) for 30.00 seconds the text: (The winner: + (Name of (Player in position 1 of Dmg_Leaderboard.)))
      • Leaderboard - Destroy Dmg_Leaderboard
      • Trigger - Turn off Damage Tracker <gen>

3) Then simply update the leaderboard value in our original Damage Tracker trigger:
  • Damage Tracker
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Owner of (Damage Target)) Equal to Neutral Hostile
    • Actions
      • Set VariableSet Dmg_PN = (Player number of (Owner of (Damage source)))
      • Set VariableSet Dmg_Total[Dmg_PN] = (Dmg_Total[Dmg_PN] + (Damage taken))
      • Leaderboard - Change the value for (Player(Dmg_PN)) in Dmg_Leaderboard to (Integer(Dmg_Total[Dmg_PN]))
Note: The Events for both Start and Stop triggers should be customized to fit your map.


Regarding notes and organization, everything you see in my triggers has been copied straight from the Trigger Editor:
What you see in your picture is a Comment action which acts as a note. Additionally, you can write anything you want above the Events section of the trigger in that large white space. You can even leave Comments in the Folder/Trigger/Variable section on the left-hand side.
 

Attachments

  • Damage Tracker Leaderboard.w3m
    19 KB · Views: 4
Last edited:
Status
Not open for further replies.
Top