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

Custom Value for players?

Status
Not open for further replies.
Level 2
Joined
Feb 12, 2023
Messages
11
Is there anyway to keep track of kill_count for specific PlayerGroup? I'm doing a quest and it's a Group Quest (there are 2 groups on the map) and I don't want any group to override the kill_count of each other's

Let's say that the quest is to kill 10 boars. If any player from group1 kills 5 boars, then it'll also show as "5 killed" for players in group2. How to make it specific for each group?
 
Level 2
Joined
Feb 12, 2023
Messages
11
Oh yeah that should work. Was also wondering if there's a way to make it work just like Custom Value of units but for Players
 
Level 23
Joined
Apr 3, 2018
Messages
460

If you make your variable an array you can do
  • Set VariableSet kill_count[(Player number of (Owner of (Killing unit)))] = (1 + kill_count[(Player number of (Owner of (Killing unit)))])
Now your one variable stores multiple values, one for each player.

Then for player groups it becomes a question of how to infer the array index from the player group.
For example your player groups could themselves be stored in an array.
  • For each (Integer A) from 1 to 2, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Killing unit)) is in playergroups[(Integer A)].) Equal to True
        • Then - Actions
          • Set VariableSet killcount[(Integer A)] = (1 + killcount[(Integer A)])
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
Adding to what Biridius said.

Remember to initialize the size of your Player Group array. Timers, Unit Groups, and Player Groups (might be forgetting some others) will require you to set a specific size otherwise you'll only have access to [index] 0 and 1 by default.

And here's an example trigger for your Boar Quest trigger:
  • Quest Example
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Boar
    • Actions
      • -------- Figure out which team the killing player is on and increase their team's kill count by 1: --------
      • Set Variable TeamNumber = (Team number of (Owner of (Killing unit)))
      • -------- --------
      • Set Variable Quest_BoarKills[TeamNumber] = (Quest_BoarKills[TeamNumber] + 1)
      • -------- --------
      • -------- Your team has finished the quest: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Quest_BoarKills[TeamNumber] Equal to 5
        • Then - Actions
          • -------- Reward gold: --------
          • Player Group - Pick every player in Players[TeamNumber] and do (Actions)
            • Loop - Actions
              • Player - Add 200 to (Picked player).Current gold
          • -------- --------
          • -------- Reward exp: --------
          • Unit Group - Pick every unit in Heroes[TeamNumber] and do (Actions)
            • Loop - Actions
              • Hero - Add 200 experience to (Picked unit), Show level-up graphics
        • Else - Actions
Players is a Player Group array with a size of 2.
Heroes is a Unit Group array with a size of 2.

If the opposing players are on the same team (Force) for some reason, simply change the way TeamNumber gets Set:
  • Set Variable TeamNumber = GetTeamNumber[(Player number of (Owner of (Killing unit)))]
So for example Players 1 to 5 would have a GetTeamNumber value of 1 and Players 6 to 10 would have a GetTeamNumber value of 2. Then your Player Group and Unit Group arrays can use these values (1 and 2) as their [indexes] to reference the appropriate data.
 
Last edited:
Status
Not open for further replies.
Top