• 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] Trouble with Variables

Status
Not open for further replies.
Level 8
Joined
Aug 23, 2007
Messages
491
  • GovVariables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Player1Gov[1] = Government Building
      • Set Player1Gov[2] = Government Building (Absolute Monarchy)
      • Set Player1Gov[3] = Government Building (Communist)
      • Set Player1Gov[4] = Government Building (Constitutional Monarchy)
      • Set Player1Gov[5] = Government Building (Republic)
      • Set Player1Gov[6] = Government Building (Theocracy)
So I'm trying to learn how to use variables, and I came up with this trigger.

Question #1: Does it work? XD Can I have the variable equal those 6 different buildings?

Question #2: I want a Condition where if Player1 owns any of those buildings the Action will work. So if I were to set the variable as the unit for the trigger, would that work?

Here's the trigger the condition would be part of.

  • Trade to Red
    • Events
      • Unit - A unit enters TradeRed <gen>
    • Conditions
      • ((Entering unit) is A structure) Equal to False
      • (Owner of (Entering unit)) Not equal to Player 1 (Red)
      • ((Owner of (Entering unit)) is an enemy of Player 1 (Red)) Equal to False
    • Actions
      • Unit - Move (Entering unit) instantly to (Center of Moscow <gen>)
      • Unit - Make (Entering unit) Vulnerable
      • Game - Display to Player Group - Player 1 (Red) the text: ((Name of (Owner of (Entering unit))) + ( has sent you a + ((Name of (Entering unit)) + on the World Market.)))
      • Unit - Change ownership of (Entering unit) to Player 1 (Red) and Change color
 
Level 12
Joined
Oct 16, 2010
Messages
680
Question #1: Does it work? XD Can I have the variable equal those 6 different buildings?

yes, if the variable array you've made (Player1Gov) is a unit type array:p

  • Events
    • Unit - A unit enters TradeRed <gen>
  • Conditions
    • ((Entering unit) is A structure) Equal to False
    • (Owner of (Entering unit)) Not equal to Player 1 (Red)
    • ((Owner of (Entering unit)) is an enemy of Player 1 (Red)) Equal to False
    • Multiple ConditionsOr - Any (Conditions) are true
      • Conditions
        • (Owner of Player1Gov[1]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[2]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[3]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[4]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[5]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[6]) Equal to (==) Player 1 (Red)
  • Actions
    • Unit - Move (Entering unit) instantly to (Center of Moscow <gen>)
    • Unit - Make (Entering unit) Vulnerable
    • Game - Display to Player Group - Player 1 (Red) the text: ((Name of (Owner of (Entering unit))) + ( has sent you a + ((Name of (Entering unit)) + on the World Market.)))
    • Unit - Change ownership of (Entering unit) to Player 1 (Red) and Change color
you think like this? this will check if any of those units belongs to player1 than that OR section will return true
that means if the other (your) conditions are true either , the actions will be executed
 
Level 8
Joined
Aug 23, 2007
Messages
491
yes, if the variable array you've made (Player1Gov) is a unit type array:p

  • Events
    • Unit - A unit enters TradeRed <gen>
  • Conditions
    • ((Entering unit) is A structure) Equal to False
    • (Owner of (Entering unit)) Not equal to Player 1 (Red)
    • ((Owner of (Entering unit)) is an enemy of Player 1 (Red)) Equal to False
    • Multiple ConditionsOr - Any (Conditions) are true
      • Conditions
        • (Owner of Player1Gov[1]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[2]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[3]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[4]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[5]) Equal to (==) Player 1 (Red)
        • (Owner of Player1Gov[6]) Equal to (==) Player 1 (Red)
  • Actions
    • Unit - Move (Entering unit) instantly to (Center of Moscow <gen>)
    • Unit - Make (Entering unit) Vulnerable
    • Game - Display to Player Group - Player 1 (Red) the text: ((Name of (Owner of (Entering unit))) + ( has sent you a + ((Name of (Entering unit)) + on the World Market.)))
    • Unit - Change ownership of (Entering unit) to Player 1 (Red) and Change color
you think like this? this will check if any of those units belongs to player1 than that OR section will return true
that means if the other (your) conditions are true either , the actions will be executed

Ok, I'm going to have copies of the trigger for 12 players in total, that wont affect it right?
 
Since you're using arrays, each index has it's own data; this means that as long as indexes are differend from each other you can set multiple units to that array-variable without problems.

Btw Destroyer25's trigger leaks. It'd be great to store (Entering unit) into variable for speed.

  • Set p = (Center of Moscow <gen>)
  • Set unit = (Entering unit)
  • Unit - Move unit instantly to p
  • Unit - Make unit Vulnerable
  • Set force = (PlayerGroup(Player 1 (Red))
  • Game - Display to force the text: ((Name of (Owner of unit)) + ( has sent you a + ((Name of unit) + on the World Market.)))
  • Unit - Change ownership of unit to Player 1 (Red) and Change color
  • Custom script: call RemoveLocation(udg_p)
  • Custom script: call DestroyForce(udg_force)
"force" - player group variable
"p" - point variable
"unit" - unit variable

I'd even say, that after setting "unit" to (Entering unit), you could remove all the conidtions in Conditions" and just move them into actions via "If (All condtions are true) then do (Then Actions) else do (Else actions)" function, so (Entering unit) spam is prevented.

Edit: What!? Twelve times? You want to make it MPI (working for multiple players)?
 
Level 8
Joined
Aug 23, 2007
Messages
491
Since you're using arrays, each index has it's own data; this means that as long as indexes are differend from each other you can set multiple units to that array-variable without problems.

Btw Destroyer25's trigger leaks. It'd be great to store (Entering unit) into variable for speed.

  • Set p = (Center of Moscow <gen>)
  • Set unit = (Entering unit)
  • Unit - Move unit instantly to p
  • Unit - Make unit Vulnerable
  • Set force = (PlayerGroup(Player 1 (Red))
  • Game - Display to force the text: ((Name of (Owner of unit)) + ( has sent you a + ((Name of unit) + on the World Market.)))
  • Unit - Change ownership of unit to Player 1 (Red) and Change color
  • Custom script: call RemoveLocation(udg_p)
  • Custom script: call DestroyForce(udg_force)
"force" - player group variable
"p" - point variable
"unit" - unit variable

I'd even say, that after setting "unit" to (Entering unit), you could remove all the conidtions in Conditions" and just move them into actions via "If (All condtions are true) then do (Then Actions) else do (Else actions)" function, so (Entering unit) spam is prevented.

Edit: What!? Twelve times? You want to make it MPI (working for multiple players)?

Well, basically how the trigger is suppose to work in game is.

If you have a Gov building, then you can receive units. And there are 12 buildings, so I need 12 triggers to check that Player X has a Gov building, and if so, transfer the units to a region.
 
Status
Not open for further replies.
Top