Trouble recognizing a variable

Freespace03

New Member
Reaction score
0
Hi everybody I've made this and can't seem to make Warcraft recognize the "SpectateModifier" variable, meaning I can't destroy the visibility modifier in another trigger. Is the issue visible in the trigger below? Any help and info is greatly appreciated.

Trigger:
  • Vision
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is A Hero) Equal to True
    • Actions
      • Set VisionCheckPlayer = (Owner of (Dying unit))
      • Set VisionCheck1 = (Units in CurrentArena <gen> matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an ally of VisionCheckPlayer) Equal to True))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in VisionCheck1) Equal to 0
        • Then - Actions
          • Visibility - Destroy SpectateModifier
          • Player Group - Add VisionCheckPlayer to SpectatingPlayers
          • Player Group - Pick every player in SpectatingPlayers and do (Actions)
            • Loop - Actions
              • Visibility - Create an initially Enabled visibility modifier for (Picked player) emitting Visibility across CurrentArena <gen>
              • Set SpectateModifier = (Last created visibility modifier)
        • Else - Actions
 

Jedi

New Member
Reaction score
63
Trigger:
  • For each integer variable 1 to Number of players in SpectatingPlayers
    • Visibility - Create modifier
    • Set SpectateModifier(variable) = (last created modifier)

Try to create and destroy modifier with this way.
 

the Lumpy

►►►
Reaction score
53
You're creating the visibility modifiers in a loop -- which means you create a new one for each player. So if there are multiple players in the SpectatingPlayers group, then multiple visibility modifiers will be created. However, each time you create one, you set the SpectateModifier variable equal to the last created one.

So, say you had 5 spectating players. You'd create 5 different visibility modifiers, but the variable would only reference the 5th one, so you'll only be able to destroy the 5th one.

You need to make your SpectateModifier an array and store each visibility modifier in a different index of the array. (This is exactly what Jedi suggested above.) Then you'll be able to destroy all of the modifiers, not just the last one.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top