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

Creating Double-Click Hero Selections (GUI)

Level 3
Joined
Nov 23, 2008
Messages
18
This tutorial assumes that you have basic knowledge of the trigger editor, terrain editor, and regions.

This tutorial will guide you through the steps in making a double-click hero selection system with only three triggers needed in the trigger editor.

Step 1: Designate a section of our map to where the neutral player's heroes will be. We will use these as the selectable heroes. I suggest surrounding the area in either boundary or raised ground. This will properly isolate the area for easier gameplay.

Step 2: We need heroes for the players to select in order to play the game. Place heroes in the area you have just designated. It is optional that you create rings of power below each hero, but this does add some decoration to the area.

Step 3: Place a region around the area containing the heroes. We need this so we can differ between these heroes and other heroes on the map. I named my region HeroSelectRegion.

Heroes.jpg


Step 4: Create a new area for spawning the selected hero to take place. Make sure that you make another region here, too. My region name is HeroSpawn.

The triggers aren't very complicated, so it shouldn't be very hard even if you are a newbie. We need three separate triggers: one for the first selection event (click), another for the second, and the final is to time out the triggers so that both events must occur within a certain timeslot.

We will need one variable for these triggers. I like to use integers because they are the easiest to change. My variable's name is ClickCounter and it is an integer.

Our first trigger will look something like this:
  • DoubleClickFirst
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • ((Triggering Unit) is A Hero) Equal to True
      • (Owner of (Triggering Unit)) Equal to Neutral Passive
      • ClickCounter Equal to 0
    • Actions
      • Set ClickCounter = 1
      • Trigger - Run Timeout <gen> (Checking conditions)
This states that when a unit is selected by player one matching the given conditions, it will set ClickCounter and begin running a separate trigger.

Here would be the second trigger:
  • DoubleClickSecond
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • ((Triggering Unit) is A Hero) Equal to True
      • (Owner of (Triggering Unit)) Equal to Neutral Passive
      • ClickCounter Equal to 1
    • Actions
      • Set ClickCounter = 2
      • Unit - Create 1 (Unit-type of (Triggering Unit)) for (Triggering Player) at (Center of HeroSpawn <gen>) facing Default building facing degrees
This trigger does close to the same thing, but two of the conditions have changed and one of the actions has been replaced with the spawning of the selected unit.

Our third trigger, the timeout trigger, would look like this:
  • Timeout
    • Events
    • Conditions
    • Actions
      • Wait (0.50) seconds
      • If (ClickCounter Equal to 1) then do (Set ClickCounter = 0) else do (Do nothing)
This resets the ClickCounter variable back to zero if a hero has not been chosen within half a second of the first click.

Here is a map of the completed system, feel free to test it out, copy, or edit it. To modify it to accommodate multiple users, simply change the variable to an array and add the other player's events to the triggers.
 

Attachments

  • DoubleClickSelection.w3x
    18.3 KB · Views: 69
Level 31
Joined
May 3, 2008
Messages
3,155
too simple and poor cause

1) Instead of 3 separate trigger, you could easily done in 1.

2) Using Wait was a terrible idea.

3) Does not folow proper format for tutorial submission.

4) Defective and inefficient as it only work for 1 player.

The right way to do it should be like this.

  • Hero Selection
    • Events
    • Conditions
      • (((Triggering unit) is A Hero) Equal to True) and ((Owner of (Triggering unit)) Equal to Neutral Passive)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ClickCounter[(Player number of (Triggering player))] Equal to 0
        • Then - Actions
          • Set ClickCounter[(Player number of (Triggering player))] = 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ClickCounter[(Player number of (Triggering player))] Equal to 1
            • Then - Actions
              • Set ClickCounter[(Player number of (Triggering player))] = 2
              • Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at (Center of (Hero Spawn)) facing Default building facing degrees
              • -------- This is just an example, I do not remove memory leak. I am sure you know what I mean with memory leak. --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ClickCounter[(Player number of (Triggering player))] Equal to 2
                • Then - Actions
                  • Set ClickCounter[(Player number of (Triggering player))] = 0
                • Else - Actions
As for the event, there is 2 way to do it.

  • Option 1
    • Events
      • Player - (Player(12)) Selects a unit
  • Option 2
    • Events
      • Player - Player 1 Selects a unit
      • Player - Player 2 Selects a unit
      • Player - Player 3 Selects a unit
      • Player - Player 4 Selects a unit
      • Player - Player 5 Selects a unit
      • Player - Player 6 Selects a unit
      • Player - Player 7 Selects a unit
      • Player - Player 8 Selects a unit
      • Player - Player 9 Selects a unit
      • Player - Player 10 Selects a unit
      • Player - Player 11 Selects a unit
      • Player - Player 12 Selects a unit
 
Last edited:
Level 31
Joined
May 3, 2008
Messages
3,155
You could click 1 hero and then another and it would select the second hero automatically. :p

oops.. I forgot about it.

It can be done in this example below.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Unit_Selection[1] = Paladin 0000 <gen>
      • Set Unit_Selection[2] = Archmage 0001 <gen>
      • Set Unit_Selection[3] = Mountain King 0002 <gen>
      • Unit Group - Add Unit_Selection[(Min(1, 3))] to Unit_Selection_Group
      • Unit Group - Pick every unit in Unit_Selection_Group and do (Set Unit_Values[Player_Values[(Player number of (Player(12)))]] = 0)
You can set all unit into 1 group and then set the unit to have their own personal values for all player. Then change the values of the unit for the player who select it.

So if player 1 click at unit A, the unit A values for player 1 would be change from 0 to 1. If player 1 click at unit B, it would not make player 1 automatically choose unit B as the heroes since unit B values would be at 1 instead of 2.

If player 1 have heroes, then simply change the values for all unit from 0 to 3.
 
Top