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

[General] how to easy calculate the position of damage done in chart?

Status
Not open for further replies.
Level 25
Joined
Sep 26, 2009
Messages
2,378
The difference is that everything related to the damage saving will require only 1 trigger.
I imagine you have either 1 trigger with multiple ITEs to check the player, or multiple trigger where each fires for 1 players only.

MPI type of systems are best when your system needs to differentiate only players (not units), which is the case here.

Also, the trigger for sorting damage will require many many ITEs if you use unique variable for each player, on the other hand if you use array, it will require 1 or 2 loops. The complexity and inefficiency decreases dramatically when using array for this.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
Arrays are more scalable. If the number of players changes all that might be required to support it is a single integer variable change, the number of players.

The simplest approach is to store the damage in an array at the index representing the player slot number who dealt the damage. Then when the game ends you order it simply by a list of active players that you use an ordering algorithm on by comparing the damages dealt for that player.

Since ordering an unordered collection is inefficient, you would not want to do it continuously (multiple times a second). The best approach for a running ordering is to keep a persistent ordered list (ordered list of players) and update it each time a player deals damage. Each update will be performed very fast as mostly only 1 element will need to be checked (the player above him in damage ranking) and that will mostly fail (chances of players changing rank is very low compared with the number of times damage is dealt). You can also use this to order change to update UI and things efficiently in the case of a multiboard or leaderboard.
 
OK, I tried with the leaderboard. I made leaderboard and this message:
  • Game - Display to (Player group(Players[(Integer A)])) the text: (You did + ((String(DAMAGE_DONE[(Player number of Players[(Integer A)])])) + ( damage. + (You place + (Position[(Position of Players[(Integer A)] in Leaderboard)] + (. You earned + ((String(HONOR[(Player number of Players[(Integer A)])])) + honor points.
one question : in order to sort the position of the player should I loop refresh every 0.10 seconds or it will sort automatically? And if I want the 1st player to be on top should I use descending of ascending order? :D
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
imo I don't think it is important to sort it all the time whenever damage is dealt, because he wants to show it only at the end.
You may sort the list too many times for no reason, which is why I think sorting it via two loops at the end will be best.
 
Status
Not open for further replies.
Top