• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Will this global counter work inside local?

Status
Not open for further replies.

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
If i put a global variable inside a local function, will it still be global?


I almost never use custom script locals, but I have to since the attacking unit is being dispersed quickly.

If someone confirms this works I'm happy. I cannot test the assist system before release, so I need someone who knows how locals works to take a look at this trigger.


  • Assistance Normal Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Owner of (Attacking unit)) Not equal to Neutral Hostile
      • ((Triggering unit) belongs to an ally of (Owner of (Attacking unit))) Equal to False
    • Actions
      • Set blahblah blah LOTS of non important triggers -then...
      • Custom script: local player udg_AssAtt
      • Custom script: local player udg_AssDef
      • Set AssAtt = (Owner of (Attacking unit))
      • Set AssDef = (Owner of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Attacking unit)) is in AssistPlayerGroup[(Player number of (Owner of (Triggering unit)))]) Equal to False
        • Then - Actions
          • Player Group - Add AssAtt to AssistPlayerGroup[(Player number of AssDef)]
        • Else - Actions
      • Set AssistCounter[(Player number of AssAtt)] = (AssistCounter[(Player number of AssAtt)] + 1)
      • Wait 4.00 seconds
      • Set AssistCounter[(Player number of AssAtt)] = (AssistCounter[(Player number of AssAtt)] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AssistCounter[(Player number of AssAtt)] Less than 1
        • Then - Actions
          • Set AssistCounter[(Player number of AssAtt)] = 0
          • Player Group - Remove AssAtt from AssistPlayerGroup[(Player number of AssDef)]
        • Else - Actions
      • Custom script: set udg_AssDef = null
      • Custom script: set udg_AssAtt = null


The purpose of the trigger:
The assistance counters is supposed to work in that way the assistance should count until 4 seconds after the last attack. The counter is a global variable, while the attacking player is decleared local.
 
Move the local declaration at the top of your actions, otherwise it won't work.

A logical thing: You set the assist counter -1 in all situations, but only in the <1 situation the player is removed from the group. Are you sure it has to be like that?

EDIT: Yeah, seems to be fine after I understood what you did there. Still locals need to be on top.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
Will it work inside and If - Then - Else - Trigger? Or must it be on top on the actions in the trigger?


I need to know cuz I have If - Then - Else in between the local declearation.



And can locals be on top inside a If - Then - Else? Or must it be on top in the trigger itself?
 
Last edited:

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,267
Ok, i created a new trigger for the locals (phoenix fire kill projectile, so the killer is the unit being hit!!).

Well, then this should also work fine?

  • Assist Projectile Check
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Killing unit)) Not equal to Collision Dummy
      • (Race of (Killing unit)) Not equal to Orc
      • ((Killing unit) is A Hero) Equal to True
      • (Owner of (Killing unit)) Not equal to Player 1 (Red)
      • (Owner of (Killing unit)) Not equal to Player 2 (Blue)
      • ((Killing unit) belongs to an ally of (Owner of (Triggering unit))) Equal to False
      • Or - Any (Conditions) are true
        • Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Custom value of (Triggering unit)) Equal to 2
              • (Race of (Triggering unit)) Equal to Orc
          • ((Triggering unit) is in Move) Equal to True
          • ((Triggering unit) is in MoveFast) Equal to True
          • ((Triggering unit) is in MoveSlow) Equal to True
    • Actions
      • Custom script: local player udg_AssAtt
      • Custom script: local player udg_AssDef
      • Set AssAtt = (Owner of (Triggering unit))
      • Set AssDef = (Owner of (Killing unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (AssAtt is in AssistPlayerGroup[(Player number of AssDef)]) Equal to False
        • Then - Actions
          • Player Group - Add AssAtt to AssistPlayerGroup[(Player number of AssDef)]
        • Else - Actions
      • Set AssistCounter[(Player number of AssAtt)] = (AssistCounter[(Player number of AssAtt)] + 1)
      • Wait 6.00 seconds
      • Set AssistCounter[(Player number of AssAtt)] = (AssistCounter[(Player number of AssAtt)] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AssistCounter[(Player number of AssAtt)] Less than 1
        • Then - Actions
          • Set AssistCounter[(Player number of AssAtt)] = 0
          • Player Group - Remove AssAtt from AssistPlayerGroup[(Player number of AssDef)]
        • Else - Actions
      • Custom script: set udg_AssDef = null
      • Custom script: set udg_AssAtt = null
This is a assist check system for Naval Battle map
 
Status
Not open for further replies.
Top