(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Tutorials > Trigger (GUI) Editor Tutorials

Trigger (GUI) Editor Tutorials Contains tutorials concerning the usage of GUI features.
Read the Rules before posting.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 03-23-2007, 10:03 PM   #1 (permalink)

User
 
Join Date: Feb 2007
Posts: 407

Tonks has little to show at this moment (24)Tonks has little to show at this moment (24)Tonks has little to show at this moment (24)


Hero Selection Systems

Various Hero Selection Systems and How They Work

In this tutorial I'm going explain many of the methods for hero selection.
Index-
1 · Next / Previous Hero Viewing
2 · Dialog Menu Selection
3 · Using a Unit and Circles of Power
4 · Hero Taverns
5 · Clicking and Doubleclicking
6 · Random Hero
1 - Next / Previous Hero Viewing


Difficulty: Moderate
Note: This is not a good idea if you have more than 8-12 heroes.
This is not a very common method of hero selection. In fact, I've only ever seen it used in the Blizzard map Azeroth Grand Prix. I used it myself in one of my maps.
Essentially what this system entails is having a unit that has several abilities; Next, Previous, and an ability with the icon of the Hero. When you click Next, it locks your camera to the next hero in line, and when you click Previous it locks your camera to the previous hero. Then when you click the ability with the Hero's icon, it selects that hero.

Variables:
- HeroSelector - Unit Array Variable - Size 12
- HeroSelectAbil - Ability Array Variable - Size 12 (Initial Value set to your first hero)
- L - Point Variable

Abilities:
- You will need an ability for every hero. The ability should be named after the hero and should have the same icon as the hero.
- Next - Should be based off an ability easily modified to do nothing.
- Previous - Should be based off an ability easily modified to do nothing, but should not be based off the same ability as "Next."

Units:
- You will need one of each of your heroes (preferably in a line) owned by Neutral Passive.
- You will need one Hero Selector unit for each player. Should have the Abilities Next, Previous, and the ability corresponding to the first hero.

Triggers:
View Previous
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Previous
Actions
Actions
Unit - Remove HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] from (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Dwarves
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Panda
Camera - Lock camera target for (Owner of (Triggering unit)) to Panda 0040 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Clubz
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Dwarves
Camera - Lock camera target for (Owner of (Triggering unit)) to Dwarves 0037 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Muskles
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Clubz
Camera - Lock camera target for (Owner of (Triggering unit)) to Ice T 0036 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions

[trigger] Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Previous [/code]

Runs this trigger when an ability is cast, but only if it is the "Previous" Ability.

Unit - Remove HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] from (Triggering unit)

Removes the ability that is assigned to HeroSelectAbil for that player.

If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Dwarves
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Panda
Camera - Lock camera target for (Owner of (Triggering unit)) to Panda 0040 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)

This checks if the HeroSelectAbil variable is set to the Dwarves ability. If it is, it sets it to the Panda ability, Locks the camera to the Panda unit, and adds the Panda ability to the unit.

Skip remaining actions

This is in there to make sure that it doesn't continue the function.

The rest of the trigger is repetitive, and does not need to be explained.




View Next
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Next
Actions
Unit - Remove HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] from (Triggering unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Panda
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Dwarves
Camera - Lock camera target for (Owner of (Triggering unit)) to Dwarves 0037 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] Equal to Dwarves
Then - Actions
Set HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] = Clubz
Camera - Lock camera target for (Owner of (Triggering unit)) to Ice T 0036 <gen>, offset by (0.00, 0.00) using Default rotation
Unit - Add HeroSelectAbil[(Player number of (Owner of (Triggering unit)))] to (Triggering unit)
Skip remaining actions
Else - Actions

As you can tell, the Next trigger is just the same as the Previous trigger, in reverse.



Pick Cart
Events
Unit - A unit Starts the effect of an ability
Conditions
(Unit-type of (Triggering unit)) Equal to Hero Selection
Or - Any (Conditions) are true
Conditions
(Ability being cast) Equal to Panda
(Ability being cast) Equal to Bonez
(Ability being cast) Equal to Clubz
(Ability being cast) Equal to Dwarves
(Ability being cast) Equal to Fatty
(Ability being cast) Equal to Muskles
(Ability being cast) Equal to Priest
(Ability being cast) Equal to Revenant
(Ability being cast) Equal to Spirit
(Ability being cast) Equal to Tinker
(Ability being cast) Equal to Troll
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Bonez
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Bonez for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Clubz
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Ice T for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Dwarves
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Dwarves for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Fatty
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Fatty for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Muskles
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Muskles for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Panda
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Panda for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Priest
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Priest for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Revenant
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Revenant for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Spirit
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Toad for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Tinker
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Tinker for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Troll
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Troll for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)
Else - Actions
Camera - Apply Camera 002 <gen> for (Owner of (Triggering unit)) over 0.00 seconds
Unit - Remove (Triggering unit) from the game

This trigger creates the unit corresponding to the clicked ability.

Conditions
(Unit-type of (Triggering unit)) Equal to Hero Selection
Or - Any (Conditions) are true
Conditions
(Ability being cast) Equal to Panda
(Ability being cast) Equal to Bonez
(Ability being cast) Equal to Clubz
(Ability being cast) Equal to Dwarves
(Ability being cast) Equal to Fatty
(Ability being cast) Equal to Muskles
(Ability being cast) Equal to Priest
(Ability being cast) Equal to Revenant
(Ability being cast) Equal to Spirit
(Ability being cast) Equal to Tinker
(Ability being cast) Equal to Troll

Checks if the triggering unit is the Hero Selection unit and if the cast Ability is any of the abilities corresponding to the heroes.

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to Bonez
Then - Actions
Set L = (Random point in Team1Spawn <gen>)
Unit - Create 1 Bonez for (Owner of (Triggering unit)) at L facing Default building facing degrees
Custom script: call RemoveLocation(udg_L)

Checks if the ability being cast is the ability corresponding to the Bonez hero. If it is, it creates 1 Bonez at a random point in the Team1Spawn region.

Note: "Set L = ..." and "call RemoveLocation(udg_L)" are used to avoid a memory leak in this trigger.


Last but not least you'll want to have a trigger that sets the Hero Selectors.

HeroSelectors
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Set HeroSelector[1] = Hero Selection 0012 <gen>
Set HeroSelector[2] = Hero Selection 0013 <gen>
Set HeroSelector[3] = Hero Selection 0014 <gen>
Set HeroSelector[4] = Hero Selection 0015 <gen>
Set HeroSelector[5] = Hero Selection 0011 <gen>
Set HeroSelector[6] = Hero Selection 0017 <gen>
Set HeroSelector[7] = Hero Selection 0016 <gen>
Set HeroSelector[8] = Hero Selection 0020 <gen>
Set HeroSelector[9] = Hero Selection 0019 <gen>
Set HeroSelector[10] = Hero Selection 0018 <gen>
Set HeroSelector[11] = Hero Selection 0021 <gen>
Set HeroSelector[12] = Hero Selection 0022 <gen>

This sets the HeroSelector variables according to their arrays. "HeroSelector[1]" is set to Red's Hero Selector unit, "HeroSelector[2]" is set to Blue's, etc..

2 - Dialog Button Selection


Difficulty: Easy
This is a fairly easy to create and very easy to comprehend method. It only requires two triggers, and only a few variables.

Variables:
- Dialog_Var - Dialog Variable
- Hero1_Var - Dialog Button Variable
- Hero2_Var - Dialog Button Variable
- You must create a Dialog Button Variable for each of the Dialog Buttons.

Triggers:
Dialog
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Dialog - Change the title of Dialog_Var to Pick your Hero
Dialog - Create a dialog button for Dialog_Var labelled Hero 1
Set Hero1_Var = (Last created dialog Button)
Dialog - Create a dialog button for Dialog_Var labelled Hero 2
Set Hero2_Var = (Last created dialog Button)
For each (Integer A) from 1 to 12, do (Dialog - Show Dialog_Var for (Player((Integer A))))

Dialog - Change the title of Dialog_Var to Pick your Hero

Changes the title of the Dialog_Var variable to "Pick your Hero." This is what will be displayed at the top of the menu.

Dialog - Create a dialog button for Dialog_Var labelled Hero 1
Set Hero1_Var = (Last created dialog Button)

Puts a dialog button on the menu labeled "Hero 1" This is what will be displayed on the button itself. Then it sets the Hero1_Var variable to the button that was just created. You need to set the variable so that you can reference it later.


Now you need this trigger to register when a button is clicked, and what button it was:

ClickedButton
Events
Dialog - A dialog button is clicked for Dialog_Var
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to Hero1_Var
Then - Actions
Unit - Create 1 Footman for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Clicked dialog button) Equal to Hero2_Var
Then - Actions
Unit - Create 1 Footman for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees
Else - Actions

If - Conditions
(Clicked dialog button) Equal to Hero1_Var
Then - Actions
Unit - Create 1 Mountain King for (Triggering player) at (Center of (Playable map area)) facing Default building facing degrees

Creates a Mountain King if the clicked button was the Hero1_Var button.
Tonks is offline  
Old 03-24-2007, 12:51 AM   #2 (permalink)
Overall Site Manager
 
Wolverabid's Avatar

 
Join Date: Oct 2006
Posts: 8,793

Wolverabid has much of which to be proud (1206)Wolverabid has much of which to be proud (1206)

Respected User: This user has been given the respected user award. User of the Year: 2007 

Thumbs up roxx0rz

At first glance this tutorial seems helpful, powerful and useful.

As its further development continues, I'm sure that this will become an even more informative document.
__________________
SuperSecretSearchSystem .......Netiquette....... Posting And You..........Read Me.......Vote

Antivirus Chat Dictionary Games Hoaxes Links Music News Quotations Reference Software

Wolverabid is offline  
Old 03-24-2007, 12:52 AM   #3 (permalink)

User
 
Join Date: Feb 2007
Posts: 407

Tonks has little to show at this moment (24)Tonks has little to show at this moment (24)Tonks has little to show at this moment (24)


Quote: