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

Leaderboard [Solved]

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
335
Basically I'm trying to make a leaderboard that counts a unit.
I have a small problem with it, it cannot count when units are placed in those areas! also when a unit dies, it starts counting negative instead of staying at 0!

  • West Arena Unit Count
    • Events
      • Unit - A unit enters ArenaWestSpawn <gen>
    • Conditions
      • Boolean_LevelCompleted Equal to True
      • Boolean_Arena Equal to True
      • ((Entering unit) is Undead) Equal to False
    • Actions
      • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Entering unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Entering unit)))] + 1)
      • Leaderboard - Change the value for Player 21 (Coal) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Entering unit)))]
  • East Arena Unit Count
    • Events
      • Unit - A unit enters ArenaEastSpawn <gen>
    • Conditions
      • Boolean_LevelCompleted Equal to True
      • Boolean_Arena Equal to True
      • ((Entering unit) is Undead) Equal to False
    • Actions
      • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Entering unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Entering unit)))] + 1)
      • Leaderboard - Change the value for Player 22 (Snow) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Entering unit)))]
  • Arena Unit Count Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • Boolean_LevelCompleted Equal to True
      • Boolean_Arena Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 23 (Emerald)
        • Then - Actions
          • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] - 1)
          • Leaderboard - Change the value for Player 21 (Coal) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))]
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 24 (Peanut)
        • Then - Actions
          • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] - 1)
          • Leaderboard - Change the value for Player 22 (Snow) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))]
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,567
Integers_ArenaFighterCount is an Integer, so it's only natural that it can go negative if you subtract from it. If you don't want it to go below 0 then simply check if it's less than 0 after subtracting from it and set it back to 0. That's what an If Then Else is for, to ask a question in your Actions and then change things based on the answer.

Is Integers_ArenaFighterCount less than zero? If yes, then set it to 0. Otherwise, don't do anything.

I'm not sure what this means:
it cannot count when units are placed in those areas!
What areas? And can you go into greater detail because I still don't know what that means exactly.
 
Last edited:
Level 10
Joined
Jun 20, 2017
Messages
335
I have some round in my map, let say 40 round with a bonus round after every 10 round.
So for the bonus round 2 teams will fight each other, in certain areas (same as legion td).
Before starting the round you need to build some towers on the map, after the round starts, they become units and fight, but you cannot control them.

Changing ownership and moving to regions works fine, but when they are placed in the regions, the unit is not counted?
  • Create Fighters For Arena
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UnitGroup_Towers and do (Actions)
        • Loop - Actions
          • Unit - Hide (Picked unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of (Picked unit)) is an ally of Player 23 (Emerald).) Equal to True
            • Then - Actions
              • Set VariableSet Player_Temp = Player 23 (Emerald)
            • Else - Actions
              • Set VariableSet Player_Temp = Player 24 (Peanut)
          • -------- --------
          • -------- Create Fighters --------
          • For each (Integer A) from 1 to Integer_Towers, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Picked unit)) Equal to UnitTypes_Towers[(Integer A)]
                • Then - Actions
                  • Set VariableSet Point_Temp = (Position of (Picked unit))
                  • Unit - Create 1 UnitTypes_TowersUnit[(Integer A)] for Player_Temp at Point_Temp facing Default building facing degrees
                  • Unit - Change color of (Last created unit) to (Color of (Owner of (Picked unit)))
                  • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Picked unit)))
                  • Unit - Reset ability cooldowns for (Last created unit).
                  • Unit - Set (Last created unit) movement speed to 0.00
                  • Unit - Turn collision for (Last created unit) On.
                  • Unit - Order (Last created unit) to Move To ((Owner of (Picked unit)) start location)
                  • Custom script: call RemoveLocation(udg_Point_Temp)
                  • -------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of (Last created unit)) is an ally of Player 23 (Emerald).) Equal to True
                    • Then - Actions
                      • Unit Group - Add (Last created unit) to UnitGroup_WestFighters
                    • Else - Actions
                      • Unit Group - Add (Last created unit) to UnitGroup_EastFighters
                • Else - Actions
      • -------- --------
      • Trigger - Run Guardian Spirit Effect <gen> (ignoring conditions)
  • Arena Fighters
    • Events
    • Conditions
    • Actions
      • Trigger - Turn off Red Leaves Base <gen>
      • Trigger - Turn off Blue Leaves Base <gen>
      • Trigger - Turn off Teal Leaves Base <gen>
      • Trigger - Turn off Purple Leaves Base <gen>
      • Trigger - Turn off Yellow Leaves Base <gen>
      • Trigger - Turn off Orange Leaves Base <gen>
      • Trigger - Turn off Green Leaves Base <gen>
      • Trigger - Turn off Pink Leaves Base <gen>
      • Trigger - Turn off Gray Leaves Base <gen>
      • Trigger - Turn off Light Blue Leaves Base <gen>
      • Trigger - Turn off Dark Green Leaves Base <gen>
      • Trigger - Turn off Brown Leaves Base <gen>
      • -------- --------
      • -------- Teleport Builders --------
      • Player Group - Pick every player in PlayerGroup_AllPlayers and do (Actions)
        • Loop - Actions
          • Unit - Move Units_Builder[(Player number of (Picked player))] instantly to Points_Arena[(Player number of (Picked player))]
          • Unit - Set Units_Builder[(Player number of (Picked player))] movement speed to 0.00
          • Set VariableSet Point_Temp = (Position of Units_Builder[(Player number of (Picked player))])
          • Special Effect - Create a special effect at Point_Temp using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Point_Temp)
          • Set VariableSet Point_Temp = (Position of Units_Builder[(Player number of (Picked player))])
          • Special Effect - Create a special effect at Point_Temp using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Camera - Pan camera for (Picked player) to Point_Temp over 1.00 seconds
          • Custom script: call RemoveLocation(udg_Point_Temp)
      • -------- --------
      • -------- West Team --------
      • Wait 0.50 seconds
      • Unit Group - Pick every unit in UnitGroup_WestFighters and do (Actions)
        • Loop - Actions
          • Set VariableSet Point_Temp = (Random point in ArenaWestSpawn <gen>)
          • Unit - Move (Picked unit) instantly to Point_Temp
          • Custom script: call RemoveLocation(udg_Point_Temp)
          • -------- --------
          • Set VariableSet Point_Temp = (Position of (Picked unit))
          • Special Effect - Create a special effect at Point_Temp using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Point_Temp)
          • Set VariableSet Point_Temp = (Position of (Picked unit))
          • Special Effect - Create a special effect at Point_Temp using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Point_Temp)
          • -------- --------
          • Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))
          • Set VariableSet Point_Temp2 = (Center of EastAttackEndArena <gen>)
          • Unit - Order (Picked unit) to Set Rally Point To Point_Temp2
          • Unit - Order (Picked unit) to Hold Position.
          • Custom script: call RemoveLocation(udg_Point_Temp2)
      • -------- --------
      • -------- East Team --------
      • Wait 0.50 seconds
      • Unit Group - Pick every unit in UnitGroup_EastFighters and do (Actions)
        • Loop - Actions
          • Set VariableSet Point_Temp = (Random point in ArenaEastSpawn <gen>)
          • Unit - Move (Picked unit) instantly to Point_Temp
          • Custom script: call RemoveLocation(udg_Point_Temp)
          • -------- --------
          • Set VariableSet Point_Temp = (Position of (Picked unit))
          • Special Effect - Create a special effect at Point_Temp using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Point_Temp)
          • Set VariableSet Point_Temp = (Position of (Picked unit))
          • Special Effect - Create a special effect at Point_Temp using Abilities\Spells\Human\MassTeleport\MassTeleportTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation(udg_Point_Temp)
          • -------- --------
          • Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))
          • Set VariableSet Point_Temp2 = (Center of WestAttackEndArena <gen>)
          • Unit - Order (Picked unit) to Set Rally Point To Point_Temp2
          • Unit - Order (Picked unit) to Hold Position.
          • Custom script: call RemoveLocation(udg_Point_Temp2)
 
Level 10
Joined
Jun 20, 2017
Messages
335
Thanks. I think it works well now, but I haven't tested it on multiplayer yet.
  • Arena Fighters Count
    • Events
    • Conditions
    • Actions
      • Set VariableSet UnitGroup_ArenaFighters = (Units in ArenaWestSpawn <gen>)
      • Unit Group - Pick every unit in UnitGroup_ArenaFighters and do (Actions)
        • Loop - Actions
          • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Picked unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Picked unit)))] + 1)
          • Leaderboard - Change the value for Player 21 (Coal) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Picked unit)))]
      • Custom script: call DestroyGroup(udg_UnitGroup_ArenaFighters)
      • -------- --------
      • Set VariableSet UnitGroup_ArenaFighters = (Units in ArenaEastSpawn <gen>)
      • Unit Group - Pick every unit in UnitGroup_ArenaFighters and do (Actions)
        • Loop - Actions
          • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Picked unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Picked unit)))] + 1)
          • Leaderboard - Change the value for Player 22 (Snow) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Picked unit)))]
      • Custom script: call DestroyGroup(udg_UnitGroup_ArenaFighters)
  • Arena Fighters Count Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • Boolean_LevelCompleted Equal to True
      • Boolean_Arena Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 23 (Emerald)
        • Then - Actions
          • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] - 1)
          • Leaderboard - Change the value for Player 21 (Coal) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] Less than 0
            • Then - Actions
              • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] = 0
            • Else - Actions
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Dying unit)) Equal to Player 24 (Peanut)
        • Then - Actions
          • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] = (Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] - 1)
          • Leaderboard - Change the value for Player 22 (Snow) in Leaderboard to Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] Less than 0
            • Then - Actions
              • Set VariableSet Integers_ArenaFighterCount[(Player number of (Owner of (Dying unit)))] = 0
            • Else - Actions
        • Else - Actions
 
Status
Not open for further replies.

Similar threads

D
  • Locked
Replies
2
Views
725
Deleted member 177737
D
Top