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

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

Status
Not open for further replies.
Level 28
Joined
Sep 26, 2009
Messages
2,520
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 64
Joined
Jan 18, 2005
Messages
27,258
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
 
Status
Not open for further replies.
Top