• 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.

[General] Easy way to make trigger about regions?

Status
Not open for further replies.
Level 18
Joined
Jun 2, 2009
Messages
1,233
--- What i am trying to do ---

Players have a 10 units (2 players map) and players must set each of the unit before start of the game

--- What i am doing ---

I have created 20 regions and of course 40 triggers

If unit enters region "1"
Set triggering unit to "number1"

If unit leaves region "1"
Set "number1" to "no unit"

But as you see, it seems pointless to create 20 triggers for entering and 20 for leaving


--- My point is ---


Let the players decide to give numbers of 10 of their units and i am looking for easiest way instead of creating 40 triggers


--- Advanced part ---

I would be happy if we can give oppurtunity to players change the units numbers anytime
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
How about you add 2 abilities to these units.
One that increases their number, and one that lowers it. So when the player clicks on their first unit, they press the +1 once, 2nd one twice. etc.

Alternatively, you could give them a spell book that has abilities that correspond to 1 thru 10 so instead of going up 1 at a time they simply go right the correct number.

Both of these methods potentially run the risk of having more than 1 unit at a particular number so be sure to prevent the player if that shouldn't be allowed.
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
Uhm can you explain a little? It would be nice with a simple template. By the way let me explain a little bit.

There is 10 circles in the start point for the 10 units and players must see to which unit in which circle. This is why i think it is not clear to giving them ability and let the player check one by one to every units.
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
So as far as I understand there are 10 circles that need to each be occupied by a single unit. The player gets to determine which unit goes into which circle. The circles are organized in numerical order from 1 to 10. Rather than creating a region on all of these circles you're looking for a cleaner way. Hopefully I deliver that..

For my first method, I was assuming you had a pool of units, like a 2 peons, 3 grunts, and 5 raiders. These 10 units needed to go into the proper circle. When a player clicks on Peon #1 the player decides to put this peon in circle 3.

To accomplish this under method one: If applicable probably hide all the abilities of the peon so not to get in the way. Then you'd add the +1 or -1 abilities. Then when the player presses the +1 or -1 ability you would set some dummy ability to the corresponding level. Then you would have a confirm ability that would let the player finalize the circle chosen.
It would look like this:
Unit Starts the Effect of an Ability > +1 was cast or -1 was cast > Set the Level of Dummy Ability to current level +1 or -1 depending on which was cast.
Then after the player is done setting the level
Unit Starts the Effect of an Ability > Confirm was cast > Get the level of the dummy ability and then move it the corresponding circle. You probably would also want an error message here when a player tries to put 2 in the same spot.

Back to the example: You would click on the peon press the +1 ability 2 times to get to 3 then confirm.

Keep in mind you can be printing the level of the dummy ability to the player, or have a floating text if you worried the player might not remember what number they are on.

Method two is very similar to method on except that instead of adding +1 or -1 abilities you just have abilities that correspond to 1 thru 10. Meaning when the player clicks on the ability that corresponds to number 3 it just instantly sets the dummy ability to level 3 at which point they can confirm. Then you follow the same steps as shown above to move them to the proper circle.
 
Level 18
Joined
Jun 2, 2009
Messages
1,233
Uhm your english is beyond my knowledge but i think maybe i understand :D thank you so much
Edit: I have decided to create 40 triggers for each regions because i do not fully understand :/ (i am pure imbecil about mathematic)
 
Last edited:
Level 13
Joined
Mar 24, 2013
Messages
1,105
Here is the template for method one, using the map you provided.

I'll post the triggers just in case anyone might see a glaring error.
I tried to comment it so you can understand my thought process.

  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Player 1's circles --------
      • Set Circles[1] = Left2Setup <gen>
      • Set Circles[3] = Left3Setup <gen>
      • Set Circles[2] = Left4Setup <gen>
      • Set Circles[4] = Left5Setup <gen>
      • Set Circles[5] = Left6Setup <gen>
      • Set Circles[6] = Left7Setup <gen>
      • Set Circles[7] = Left8Setup <gen>
      • Set Circles[8] = Left9Setup <gen>
      • Set Circles[9] = Left10Setup <gen>
      • Set Circles[10] = Left11Setup <gen>
      • -------- Player 2's circles --------
      • Set Circles[11] = Right2Setup <gen>
      • Set Circles[12] = Right3Setup <gen>
      • Set Circles[13] = Right4Setup <gen>
      • Set Circles[14] = Right5Setup <gen>
      • Set Circles[15] = Right2Setup <gen>
      • Set Circles[16] = Right2Setup <gen>
      • Set Circles[17] = Right2Setup <gen>
      • Set Circles[18] = Right2Setup <gen>
      • Set Circles[19] = Right2Setup <gen>
      • Set Circles[20] = Right2Setup <gen>
      • -------- When the players shouldn't be able to change the position anymore change this variable to anything that is not 0. --------
      • Set GameState = 0
      • -------- This variable will hold who is in each circle, at the start of the game, this is just making sure it is empty and ready. --------
      • For each (Integer TempInteger) from 1 to 20, do (Actions)
        • Loop - Actions
          • Set Number[TempInteger] = No unit

  • Selection
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
    • Conditions
      • GameState Equal to 0
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPlayer = (Owner of TempUnit)
      • -------- This If is which units are allowed to be assigned by the players. You'll need to add all the unittypes that can be assigned to the circles --------
      • -------- I've only picked 2 here to showcase. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempUnit belongs to an ally of TempPlayer) Equal to True
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of TempUnit) Equal to Morisaki // Nankatsu GK
              • (Unit-type of TempUnit) Equal to Urabe // Nankatsu
        • Then - Actions
          • Unit - Add +1 to TempUnit
          • Unit - Add -1 to TempUnit
          • Unit - Add Confirm to TempUnit
          • Unit - Add Which Circle to TempUnit
        • Else - Actions
          • -------- If the units have abilities that you don't want to show during this part, use this function to disable them, and turn them on after. --------
          • -------- This is an example of how: --------
          • Player - Disable Block // for TempPlayer

  • Deselection
    • Events
      • Player - Player 1 (Red) Deselects a unit
      • Player - Player 2 (Blue) Deselects a unit
    • Conditions
      • GameState Equal to 0
    • Actions
      • Game - Display to (All players) the text: deselected
      • Set TempUnit = (Triggering unit)
      • Set TempPlayer = (Owner of TempUnit)
      • -------- This If is which units are allowed to be assigned by the players. You'll need to add all the unittypes that can be assigned to the circles --------
      • -------- I've only picked 2 here to showcase. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempUnit belongs to an ally of TempPlayer) Equal to True
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of TempUnit) Equal to Morisaki // Nankatsu GK
              • (Unit-type of TempUnit) Equal to Urabe // Nankatsu
        • Then - Actions
          • Unit - Remove +1 from TempUnit
          • Unit - Remove -1 from TempUnit
          • Unit - Remove Confirm from TempUnit
          • Unit - Remove Which Circle from TempUnit
        • Else - Actions
          • -------- Need to turn back on any abilities that were turned off. --------
          • -------- This is an example of how: --------
          • Player - Enable Block // for TempPlayer

  • Add or Subtract
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to +1
          • (Ability being cast) Equal to -1
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempInteger = (Level of Which Circle for TempUnit)
      • Set TempForce = (Player group((Owner of TempUnit)))
      • -------- In this If we see which ability was just cast. Was it +1 or -1 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to +1
        • Then - Actions
          • -------- Here it was +1, so we set which circle the player is trying for by adding +1 to the dummy ability on the unit --------
          • -------- Remember that the dummy ability lets us keep track of which circle the player wants the unit to go. --------
          • -------- So if you click +1 twice, the player's circle will be set to 3, but they still need to confirm (Next Trigger). Which actually moves it there. --------
          • -------- If the player tries to go too high and goes past circle 10, it will tell them they cannot go that high. --------
          • Set TempInteger = (TempInteger + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempInteger Equal to 11
            • Then - Actions
              • -------- This is the debug msg --------
              • Game - Display to TempForce the text: Cannot go over 10. ...
            • Else - Actions
              • Unit - Set level of Which Circle for TempUnit to TempInteger
        • Else - Actions
          • -------- Here it was the opposite -1, so we set which circle the player is trying for by adding -1 to the dummy ability on the unit --------
          • -------- Remember that the dummy ability lets us keep track of which circle the player wants the unit to go. --------
          • -------- So if you click -1 when the circle is set to 1, then player's circle will try to be set to 0, that is too low so it prints that it cannot do that. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to -1
            • Then - Actions
              • Set TempInteger = (TempInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInteger Equal to 0
                • Then - Actions
                  • -------- This is the debug msg --------
                  • Game - Display to TempForce the text: Cannot go under 1. ...
                • Else - Actions
                  • Unit - Set level of Which Circle for TempUnit to TempInteger
            • Else - Actions
      • -------- This If checks to see if the player already got a message. If so, they don't need to get a msg. --------
      • -------- If they did not recieve a debug msg for going too high or too low. Tell the player which unit was just set to which circle. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • TempInteger Equal to 0
              • TempInteger Equal to 11
        • Then - Actions
        • Else - Actions
          • Game - Display to TempForce the text: (Current Circle for + ((Name of TempUnit) + ( is + (String(TempInteger)))))
      • Custom script: call DestroyForce(udg_TempForce)

  • Confirm
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Confirm
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPlayer = (Owner of TempUnit)
      • Set TempInteger = (Level of Which Circle for TempUnit)
      • -------- Here we check to see which player is confirming so we know which region to send the unit to. --------
      • -------- Look back at Setup and you'll see that Blue has his regions from 11-20 so when we check the dummy ability level --------
      • -------- we need to add 10 so we can easily send the unit to Blue's regions --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempPlayer Equal to Player 1 (Red)
        • Then - Actions
          • Set TempPoint2 = (Center of DebugRegionRed <gen>)
        • Else - Actions
          • Set TempPoint2 = (Center of DebugRegionBlue <gen>)
          • Set TempInteger = (TempInteger + 10)
      • -------- Here if the circle is empty we don't need to do anything. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Number[TempInteger] Equal to No unit
        • Then - Actions
        • Else - Actions
          • -------- Here if the circle already has the unit the player is trying to move into it. We print that it doesn't need to move. --------
          • -------- Think about it like this: If your TV is plugged in, you don't need plug it in again, it's already that way. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Number[TempInteger] Equal to TempUnit
            • Then - Actions
              • Set TempForce = (Player group(TempPlayer))
              • Game - Display to TempForce the text: ((Name of Number[TempInteger]) + ( was not moved because the unit was already in the assigned spot. + ))
              • Custom script: call DestroyForce(udg_TempForce)
            • Else - Actions
              • -------- Lastly, we check to see if a unit has already taken that spot. If so, we kick out the old unit, put that unit to the side --------
              • -------- and let the player set the kicked out unit's circle again. --------
              • Set TempForce = (Player group(TempPlayer))
              • Unit - Move Number[TempInteger] instantly to TempPoint2
              • Game - Display to TempForce the text: ((Name of Number[TempInteger]) + ( was occupying this spot. It has been moved off and needs to be assigned. + ))
              • Custom script: call DestroyForce(udg_TempForce)
      • Set Number[TempInteger] = TempUnit
      • Set TempPoint = (Center of Circles[TempInteger])
      • Unit - Move TempUnit instantly to TempPoint
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call RemoveLocation(udg_TempPoint2)

  • Change Game State
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • -------- You can use any event here that you want. You just need to make sure this trigger happens when the players can no longer change their unit's circles. --------
      • -------- If you want to let them change it again later. You need to Set GameState back = 0 --------
      • Selection - Clear selection for Player 1 (Red)
      • Selection - Clear selection for Player 2 (Blue)
      • -------- The purpose of this wait is because without it, the deselection was being evaluated as if it was already set to 1 when we still needed it to be 0. --------
      • -------- The wait should not cause any problems. To be ultra sure you could potentially fire a 0.00 timer and then set Game State to 1 --------
      • -------- I don't think this is necessary. --------
      • Wait 0.00 seconds
      • Set GameState = 1
 

Attachments

  • example.w3x
    225.8 KB · Views: 19
Status
Not open for further replies.
Top