• 🏆 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!

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

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
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

  • DPS.w3m
    19.3 KB · Views: 9
Last edited:
Status
Not open for further replies.
Top