• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

DPS System and large number abbreviation

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2020
Messages
86
I'm adding a system where if you have a unit selected there is an ability placeholder that will tell you that unit's DPS.

I am probably doing it wrong, here is the trigger:
  • DPS
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • ((Damage source) is selected by (Owner of (Damage source)).) Equal to True
    • Actions
      • Set VariableSet PN = (Player number of (Owner of (Damage source)))
      • Set VariableSet DPSUnit[PN] = (Damage source)
      • Set VariableSet DPS[PN] = (DPS[PN] + (Damage taken))

And "DPS" ability
  • DPS Timer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in ActivePlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet PN = (Player number of (Picked player))
          • Ability - Set Extended Tooltip of DPS (Icon) to ((Name of DPSUnit[PN]) + ( + (String(DPS[PN], 0, 0)))) for level 0
          • Set VariableSet DPS[PN] = 0.00

So I am looking to solve two issues
1. Optimize/Fix the DPS trigger
2. Create abbreviations for long numbers

eg.
10,000 = 10k
100,000 = 100k
1,000,000 = 1M etc...
 
I would make sure to use unique variables for the DPS trigger to avoid any conflicts.

Here's how you can adjust the string for large numbers:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • DPS[DPS_PN] Greater than or equal to 1000000.00
    • Then - Actions
      • Set VariableSet DPS_String = ((Substring((String(DPS[DPS_PN])), 1, 1)) + (. + ((Substring((String(DPS[DPS_PN])), 2, 2)) + m)))
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DPS[DPS_PN] Greater than or equal to 100000.00
        • Then - Actions
          • Set VariableSet DPS_String = ((Substring((String(DPS[DPS_PN])), 1, 3)) + k)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DPS[DPS_PN] Greater than or equal to 10000.00
            • Then - Actions
              • Set VariableSet DPS_String = ((Substring((String(DPS[DPS_PN])), 1, 2)) + k)
            • Else - Actions
              • -------- Converting a Real to an Integer shaves off the decimals: --------
              • Set VariableSet DPS_String = (String((Integer(DPS[DPS_PN]))))
< 10,000 will display the damage dealt as a whole number ---> 248
10,000-99,000 will display the first two damage numbers + the letter "k" ---> 15k
100,000 to 999,000 will display the first three damage numbers + the letter "k" ---> 147k
1,000,000+ will display the first damage number then a "." followed by the second dmg number and a "m" ---> 5.6m


I attached a map with an example of a DPS meter and the above actions put to use.

I believe you want to subtract each damage instance after 1.00 second rather than resetting the damage to 0 every 1.00 second. Although, both methods are probably incorrect for properly tracking DPS, I'm not 100% sure and I suppose it depends on what you really want.
 

Attachments

Last edited:
Status
Not open for further replies.
Back
Top