ArmyOfFrogs
New Member
- Reaction score
- 20
This is a trigger snippet/system thing I just implemented into my map, thought some other people would possibly like it. It stores players' damage dealt, then can be shown to players, in order from greatest to least. Credits to Chocobo for the first 2 triggers pretty much, Romek for Leaderboard idea, and Komaqtion for leak fixing
Players are stored in Player[PlayerNumber]
Player Colors are just strings storing the hexcode for their colors
These first two detect units in the map
This will add it to the variable storing the total damage dealt
This is the first part of showing the damage to the players
Here is the second part which organizes the damage dealt, so it can be properly displayed
There you have it. Every time a player damages a unit, it stores the damage dealt in an array. When they type -dmg it will order the damage dealt from greatest to least, then display it to him in order.
Please point out if you see something I'm missing or that needs correcting. Thanks and I hope this is useful
Known problems
If a player skips a slot (I.E, 1 2 3 are occupied, 4 is empty then theres someone at 5) it will not display properly.
Status: No clue how to fix that.
Code:
Variables used
Name Array Type
DamageMeter Yes Integer
Player Yes Player
DmgeShowOrder Yes Integer
DmgShowNames Yes String
Temp_Group No Unit Group
Temp_PGroup No Player Group
Players are stored in Player[PlayerNumber]
Player Colors are just strings storing the hexcode for their colors
These first two detect units in the map
Trigger:
- Damage Detect New Units
- Events
- Unit - A unit enters (Playable map area)
- Conditions
- Actions
- Trigger - Add to DamagesAdd <gen> the event (Unit - (Triggering unit) Takes damage)
- Events
Trigger:
- Preplaced Units
- Events
- Map initialization
- Conditions
- Actions
- Set Temp_Group = (Units in (Playable map area))
- Unit Group - Pick every unit in Temp_Group and do (Actions)
- Loop - Actions
- Trigger - Add to DamageAdd <gen> the event (Unit - (Picked unit) Takes damage)
- Loop - Actions
- Custom script: call DestroyGroup(udg_Temp_Group)
- Events
This will add it to the variable storing the total damage dealt
Trigger:
- DamageAdd
- Events
- Conditions
- Or - Any (Conditions) are true
- Conditions
- (Owner of (Damage source)) Equal to Player 1 (Red)
- (Owner of (Damage source)) Equal to Player 2 (Blue)
- (Owner of (Damage source)) Equal to Player 3 (Teal)
- (Owner of (Damage source)) Equal to Player 4 (Purple)
- (Owner of (Damage source)) Equal to Player 5 (Yellow)
- (Owner of (Damage source)) Equal to Player 6 (Orange)
- (Owner of (Damage source)) Equal to Player 7 (Green)
- (Owner of (Damage source)) Equal to Player 8 (Pink)
- (Owner of (Damage source)) Equal to Player 9 (Gray)
- (Owner of (Damage source)) Equal to Player 10 (Light Blue)
- Conditions
- Or - Any (Conditions) are true
- Actions
- Set DamageMeter[(Player number of (Owner of (Damage source)))] = (DamageMeter[(Player number of (Owner of (Damage source)))] + (Integer((Damage taken))))
This is the first part of showing the damage to the players
Trigger:
- DmgShow
- Events
- Player - Player 1 (Red) types a chat message containing -dmg as An exact match
- Player - Player 2 (Blue) types a chat message containing -dmg as An exact match
- Player - Player 3 (Teal) types a chat message containing -dmg as An exact match
- Player - Player 4 (Purple) types a chat message containing -dmg as An exact match
- Player - Player 5 (Yellow) types a chat message containing -dmg as An exact match
- Player - Player 6 (Orange) types a chat message containing -dmg as An exact match
- Player - Player 7 (Green) types a chat message containing -dmg as An exact match
- Player - Player 8 (Pink) types a chat message containing -dmg as An exact match
- Player - Player 9 (Gray) types a chat message containing -dmg as An exact match
- Player - Player 10 (Light Blue) types a chat message containing -dmg as An exact match
- Conditions
- Actions
- Trigger - Run DmgOrder <gen> (ignoring conditions)
- Wait 0.50 seconds
- Set Temp_PGroup = (Player group(Player[(Player number of (Triggering player))]))
- For each (Integer A) from 1 to PlayersActive, do (Actions)
- Loop -
- Game - Display to Temp_PGroup the text: (((DmgShowNames[(Integer A)]) + <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile :)" loading="lazy" data-shortname=":)" /> + (String(DamageMeter[DmgShowOrder[(Integer A)]]))))
- Loop -
- Custom script: call DestroyForce(udg_Temp_PGroup)
- Events
Here is the second part which organizes the damage dealt, so it can be properly displayed
Trigger:
- DmgOrder
- Events
- Conditions
- Actions
- Leaderboard - Create a leaderboard for (All players) titled damage order
- Leaderboard - Hide (Last created leaderboard)
- Player Group - Pick every player in (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) controller) Equal to User))) and do (Actions)
- Loop - Actions
- Leaderboard - Add (Picked player) to (Last created leaderboard) with label Rank and value DamageMeter[(Player number of (Picked player))]
- Loop - Actions
- Leaderboard - Sort (Last created leaderboard) by Value in Descending order
- For each (Integer A) from 1 to PlayersActive, do (Actions)
- Loop - Actions
- Set DmgShowNames[(Integer A)] = (Name of (Player in position (Integer A) of (Last created leaderboard)))
- Set DmgShowOrder[(Integer A)] = (Position of Player[(Integer A)] in (Last created leaderboard))
- Loop - Actions
- Leaderboard - Destroy (Last created leaderboard)
There you have it. Every time a player damages a unit, it stores the damage dealt in an array. When they type -dmg it will order the damage dealt from greatest to least, then display it to him in order.
Please point out if you see something I'm missing or that needs correcting. Thanks and I hope this is useful
Known problems
If a player skips a slot (I.E, 1 2 3 are occupied, 4 is empty then theres someone at 5) it will not display properly.
Status: No clue how to fix that.