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

[Solved] Counting structures that are noot finished!

Status
Not open for further replies.
Hi everyone, in my map there is a leaderboard that shows structure count of each player.
Adds when player begins construction
Subtracts when buildings gets destroyed or cancels constructions

It works with the first two fine, but then with "cancels cosntruction" it actually substracts (all + 1)
So i added
  • Set Score_Buildings[TempInt] = (Score_Buildings[TempInt] - 1)
it worked in singleplayer, but in multiplayer it just doesnt seems right on the leaderboard.

My question is how do I soolvee this problem, and how to check if the progress of a construction is 100% or not



  • Add Building
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set Score_Buildings[TempInt] = (Score_Buildings[TempInt] + 1)
      • Leaderboard - Change the value for (Player(TempInt)) in Leaderboard to Score_Buildings[TempInt]
  • Cancel Building
    • Events
      • Unit - A unit Cancels construction
    • Conditions
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set Score_Buildings[TempInt] = (Number of units in (Units owned by (Player(TempInt)) matching (((Matching unit) is A structure) Equal to True)))
      • Set Score_Buildings[TempInt] = (Score_Buildings[TempInt] - 1)
      • Leaderboard - Change the value for (Player(TempInt)) in Leaderboard to Score_Buildings[TempInt]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • Score_Buildings[TempInt] Equal to 0
              • Workers_Count[TempInt] Equal to 0
        • Then - Actions
          • Leaderboard - Change the color of the label for (Player(TempInt)) in Leaderboard to (100.00%, 100.00%, 100.00%) with 0.00% transparency
          • Leaderboard - Change the color of the value for (Player(TempInt)) in Leaderboard to (100.00%, 100.00%, 100.00%) with 0.00% transparency
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AllyOf[TempInt] slot status) Not equal to Is playing
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Score_Buildings[TempInt] Equal to 0
            • Then - Actions
              • Leaderboard - Change the color of the label for (Player(TempInt)) in Leaderboard to (67.00%, 93.00%, 87.00%) with 0.00% transparency
              • Leaderboard - Change the color of the value for (Player(TempInt)) in Leaderboard to (67.00%, 93.00%, 87.00%) with 0.00% transparency
            • Else - Actions
        • Else - Actions
  • Destroed Building
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to True
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set Score_Buildings[TempInt] = (Score_Buildings[TempInt] - 1)
      • Leaderboard - Change the value for (Player(TempInt)) in Leaderboard to Score_Buildings[TempInt]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • Score_Buildings[TempInt] Equal to 0
              • Workers_Count[TempInt] Equal to 0
        • Then - Actions
          • Leaderboard - Change the color of the label for (Player(TempInt)) in Leaderboard to (100.00%, 100.00%, 100.00%) with 0.00% transparency
          • Leaderboard - Change the color of the value for (Player(TempInt)) in Leaderboard to (100.00%, 100.00%, 100.00%) with 0.00% transparency
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AllyOf[TempInt] slot status) Not equal to Is playing
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Score_Buildings[TempInt] Equal to 0
            • Then - Actions
              • Leaderboard - Change the color of the label for (Player(TempInt)) in Leaderboard to (67.00%, 93.00%, 87.00%) with 0.00% transparency
              • Leaderboard - Change the color of the value for (Player(TempInt)) in Leaderboard to (67.00%, 93.00%, 87.00%) with 0.00% transparency
            • Else - Actions
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
If it works in singleplayer but not multiplayer then something weird is going on. Maybe the array isn't working properly, I assume TempInt represents the Player Number.

And you can use a Unit Indexer to track the state of a structure:

A unit finishes construction -> Set IsConstructed[custom value of triggering unit] = True

This boolean will be false by default, so unfinished structures will return False and finished structures will return True.

Remember to set it to False when a structure dies since the custom value will get recycled and used by future units.

Edit:
I THINK you want to delete this line:
Set Score_Buildings[TempInt] = (Number of units in (Units owned by (Player(TempInt)) matching (((Matching unit) is A structure) Equal to True)))
 
Last edited:
Status
Not open for further replies.
Top