1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  4. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Do you have good ideas for new contests? If so, please open new threads in the Contest Submission sub-forum to discuss them.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

GUI - Hero Click-Selection (Advanced)

Discussion in 'Trigger (GUI) Editor Tutorials' started by Fulla, Oct 4, 2007.

  1. Fulla

    Fulla

    Joined:
    Aug 3, 2005
    Messages:
    757
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Heya,

    In this tutorial I hope to show you how to make an advanced hero selection system in a step by step guide.
    This one works via players clicking on heroes they wish to use as opposed to taverns or region methods.

    I've tried to include as many pictures & samples as possible.
    If you have any suggestions, recommendations or critiques, by all means tell me.
    Please note the sample triggers probably have some Leaks in them, but as they are only going to be run at the start of the game its no real big deal.

    I'd Strongly Recommend first of, to download the sample map attached, to see how it works & looks in game.
    If you are already fairly experienced with the World Editor you could simply copy/paste across the system into your map & skip this tutorial.
    It might however be a good idea, to read it anyways.

    Contents

    Globals

    First off, the dreaded global variables must be created:

    Globals.JPG

    • Boolean Array - This is so when a player has selected a Hero we can mark him as already having a hero, preventing him from selecting any more.
    • Unit Groups - A/B - These are there to group up the heroes for selection purposes. We can detect if a player clicks on them, with necessary conditions
    • Unit Group - Used - This is used to store current Heroes that are selected by players and being considered for use. Stops a player snatching someone else players before he can confirm.
    • Player Groups - These are to group the players into their appropriate teams. Simplifies a lot of things later on, which you'll see.
    • Unit Array - This is to store a players current hero he has selected. We use this to change the ownership/color of previous selected heroes back to normal when selecting a new hero

    Dummy Units/Abilities

    For the selection system, well need 1 dummy unit & 1 dummy ability.
    I recommend basing these on the militia unit + the tornado slow aura ability.

    Dummy Unit
    - Will be used as fake unit sold on Heroes, to confirm/select that Hero.
    - Will be used as a dummy to lock/rotate the camera around.
    • Add/replace invulnerable/locust abilities
    • Remove his shadow
    • Disable attacks
    • Remove his sound speed
    • Reduce Gold/Lumber/Food cost to 0
    • Alter his tooltips, something like:
      - Tooltip Basic - 'Select this Hero'
      - Tooltip Extended - 'Selects this Hero to fight for your cause.'
    • Give him an appropriate icon, I recommend MC's tick box icon
    Unit.JPG

    Selection Arrow Ability
    This is very easy, only need to add 2 minor things:
    • Art target - Stop Sharing
    • Art target attachment point - Overhead
    Ability.JPG

    Terrain/Units/Rects

    Now we need to setup the terrain & the units, creating both a hero selection area & a base for each team.

    Hero Selection Areas:
    - All heroes should be computer ally player of team A/B, in this case player's 6/12.
    - Place a militia unit in the center (more on that later).

    HA.JPG

    HB.JPG

    Team Bases:
    - Place a rect, where the heroes can teleport to after picking a hero.

    BA.JPG

    BB.JPG

    Player Teams

    Next we need to setup the teams, in this test map/tutorial I'll be using 2 teams:
    - Players 1-6 - (Player 6 being the computer ally)
    - Players 7-12 - (Player 12 being the computer ally)

    Here is a sample trigger on how I'd recommend going about this:

    [trigger="Sample Teams Trigger"]
    Init 2
    Events
    Map initialization
    Conditions
    Actions
    For each (Integer A) from 1 to 12, do (Actions)
    Loop - Actions
    For each (Integer B) from 1 to 12, do (Actions)
    Loop - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    (Integer A) Less than 7
    (Integer B) Less than 7
    Then - Actions
    Player - Make (Player((Integer A))) treat (Player((Integer B))) as an Ally with shared vision
    Player - Make (Player((Integer B))) treat (Player((Integer A))) as an Ally with shared vision
    Player Group - Add (Player((Integer A))) to ForceA
    Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    (Integer A) Less than 7
    (Integer B) Greater than 6
    Then - Actions
    Player - Make (Player((Integer A))) treat (Player((Integer B))) as an Enemy
    Player - Make (Player((Integer B))) treat (Player((Integer A))) as an Enemy
    Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    (Integer A) Greater than 6
    (Integer B) Greater than 6
    Then - Actions
    Player - Make (Player((Integer A))) treat (Player((Integer B))) as an Ally with shared vision
    Player - Make (Player((Integer B))) treat (Player((Integer A))) as an Ally with shared vision
    Player Group - Add (Player((Integer A))) to ForceB
    Else - Actions[/trigger]


    Cameras

    It would also be nice to set up a nice camera for each player:

    Cameras:
    • Create a cinematic fade in for all players.
    • Move the camera for each team to their hero selection areas.
    • Lock the camera for each team onto that militia in their hero selection areas.
    • Rotate the camera for each team around that militia in their hero selection areas.
    • Disable user control.

    [trigger="Sample Camera Trigger"]
    Initz
    Events
    Map initialization
    Conditions
    Actions
    Cinematic - Fade in over 8.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
    For each (Integer A) from 1 to 6, do (Actions)
    Loop - Actions
    Camera - Pan camera for (Player((Integer A))) to (Position of Selection Unit 0016 <gen>) over 0.00 seconds
    Camera - Lock camera target for (Player((Integer A))) to Selection Unit 0016 <gen>, offset by (0.00, 0.00) using Default rotation
    Camera - Rotate camera 720.00 degrees around (Position of Selection Unit 0016 <gen>) for Player 1 (Red) over 120.00 seconds
    For each (Integer A) from 7 to 12, do (Actions)
    Loop - Actions
    Camera - Pan camera for (Player((Integer A))) to (Position of Selection Unit 0028 <gen>) over 0.00 seconds
    Camera - Lock camera target for (Player((Integer A))) to Selection Unit 0028 <gen>, offset by (0.00, 0.00) using Default rotation
    Camera - Rotate camera 720.00 degrees around (Position of Selection Unit 0028 <gen>) for Player 1 (Red) over 120.00 seconds
    Cinematic - Disable user control for (All players)
    [/trigger]


    Heroes Setup

    Prepare the Heroes:
    • Place heroes in their groups
    • Change color to Black (Neutral color)
    • Disable attack/movement on all heroes
    • Reduce Skill Points to 0
    • Add Sell Units ability
    • Add Militia (Dummy Unit Selection) to stock
    • Make invulnerable
    [trigger="Heroes"]
    Unit Group - Add Paladin 0000 <gen> to GroupA
    Unit Group - Add Blood Mage 0003 <gen> to GroupA
    Unit Group - Add Keeper of the Grove 0004 <gen> to GroupA
    Unit Group - Add Warden 0007 <gen> to GroupA
    Unit Group - Add Demon Hunter 0006 <gen> to GroupA
    Unit Group - Add Priestess of the Moon 0005 <gen> to GroupA
    Unit Group - Add Archmage 0001 <gen> to GroupA
    Unit Group - Add Mountain King 0002 <gen> to GroupA
    -------- --------
    Unit Group - Add Death Knight 0012 <gen> to GroupB
    Unit Group - Add Shadow Hunter 0011 <gen> to GroupB
    Unit Group - Add Far Seer 0009 <gen> to GroupB
    Unit Group - Add Tauren Chieftain 0010 <gen> to GroupB
    Unit Group - Add Blademaster 0008 <gen> to GroupB
    Unit Group - Add Dreadlord 0014 <gen> to GroupB
    Unit Group - Add Lich 0013 <gen> to GroupB
    Unit Group - Add Crypt Lord 0015 <gen> to GroupB
    -------- --------
    Unit Group - Pick every unit in GroupA and do (Actions)
    Loop - Actions
    Unit - Change color of (Picked unit) to Black
    Hero - Modify unspent skill points of (Picked unit): Set to 0 points
    Custom script: call UnitRemoveAbility(GetEnumUnit(),'Amov')
    Custom script: call UnitRemoveAbility(GetEnumUnit(),'Aatk')
    Unit - Remove Shadow Meld from (Picked unit)
    Unit - Add Sell Units to (Picked unit)
    Neutral Building - Add Selection Unit to (Picked unit) with 1 in stock and a max stock of 1
    Unit - Make (Picked unit) Invulnerable
    Unit Group - Pick every unit in GroupB and do (Actions)
    Loop - Actions
    Unit - Change color of (Picked unit) to Black
    Hero - Modify unspent skill points of (Picked unit): Set to 0 points
    Custom script: call UnitRemoveAbility(GetEnumUnit(),'Amov')
    Custom script: call UnitRemoveAbility(GetEnumUnit(),'Aatk')
    Unit - Add Sell Units to (Picked unit)
    Neutral Building - Add Selection Unit to (Picked unit) with 1 in stock and a max stock of 1
    Unit - Make (Picked unit) Invulnerable[/trigger]


    Select Hero

    Finally we are reaching the good stuff.
    This trigger will handle players clicking on a hero.
    For this we need:
    • Detect player unit selection.
    • Check the player hasn't already got a hero.
    • Check the hero isn't already being selected by another player.
    • Check the player is selecting from the right group of heroes.
    • Remove the selection arrow from the previously selected hero.
    • Change the previously selected hero back to computer ally.
    • Change the previously selected heroes color back to black.
    • Add the selection arrow to the new hero selected.
    • Change ownership of the newly selected hero, also changing color.
    • Set the newly selected hero as the players Selection
    • Add the hero to the used group, marking it as being used.
    [trigger="Select Hero"]Select Hero
    Events
    Player - Player 1 (Red) Selects a unit
    Player - Player 2 (Blue) Selects a unit
    Player - Player 3 (Teal) Selects a unit
    Player - Player 4 (Purple) Selects a unit
    Player - Player 5 (Yellow) Selects a unit
    Player - Player 6 (Orange) Selects a unit
    Player - Player 7 (Green) Selects a unit
    Player - Player 8 (Pink) Selects a unit
    Player - Player 9 (Gray) Selects a unit
    Player - Player 10 (Light Blue) Selects a unit
    Player - Player 11 (Dark Green) Selects a unit
    Player - Player 12 (Brown) Selects a unit
    Conditions
    Finished[(Player number of (Triggering player))] Equal to False
    ((Triggering unit) is in Used) Equal to False
    Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    ((Triggering player) is in ForceA) Equal to True
    ((Triggering unit) is in GroupA) Equal to True
    Then - Actions
    Unit - Remove Selection Arrow from Selected[(Player number of (Triggering player))]
    Unit - Change ownership of Selected[(Player number of (Triggering player))] to Player 6 (Orange) and Retain color
    Unit - Change color of Selected[(Player number of (Triggering player))] to Black
    -------- --------
    Unit - Add Selection Arrow to (Triggering unit)
    Unit - Change ownership of (Triggering unit) to (Triggering player) and Change color
    Set Selected[(Player number of (Triggering player))] = (Triggering unit)
    Unit Group - Add (Triggering unit) to Used
    Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    ((Triggering player) is in ForceB) Equal to True
    ((Triggering unit) is in GroupB) Equal to True
    Then - Actions
    Unit - Remove Selection Arrow from Selected[(Player number of (Triggering player))]
    Unit - Change ownership of Selected[(Player number of (Triggering player))] to Player 12 (Brown) and Retain color
    Unit - Change color of Selected[(Player number of (Triggering player))] to Black
    -------- --------
    Unit - Add Selection Arrow to (Triggering unit)
    Unit - Change ownership of (Triggering unit) to (Triggering player) and Change color
    Set Selected[(Player number of (Triggering player))] = (Triggering unit)
    Else - Actions[/trigger]


    Confirm Hero

    Nearly there. This trigger will handle players confirming their hero.
    It will detect them 'buying' the fake selection unit, returning the selected hero back to normal & then lastly creating a fresh new hero at their teams base for them to use.

    For this we need:
    • Detect unit being sold.
    • Check the unit being sold is the dummy selection unit.
    • Set the players boolean, marking him as having a hero (prevents him from picking any others).
    • As in the unit selection, remove the selection arrow from previous unit, change it back to computer ally & change its color to black.
    • Reset the players camera & move it to his team's base.
    • Create the hero he selected at his team's base for him.
    • Add a special effect onto the freshly created hero, I recommend tomb of retraining.
    • Select the newly created hero for him.

    [trigger="Confirm Hero"]Confirm Hero
    Events
    Unit - A unit Sells a unit
    Conditions
    (Unit-type of (Sold unit)) Equal to Selection Unit
    Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    ((Selling unit) is in GroupA) Equal to True
    Then - Actions
    Set Finished[(Player number of (Triggering player))] = True
    Unit - Remove Selection Arrow from (Triggering unit)
    Unit - Change ownership of (Triggering unit) to Player 6 (Orange) and Retain color
    Unit - Change color of (Triggering unit) to Black
    Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
    Camera - Pan camera for (Triggering player) to (Center of BaseA <gen>) over 0.00 seconds
    Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at (Center of BaseA <gen>) facing 0.00 degrees
    Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
    Selection - Select (Last created unit) for (Triggering player)
    Game - Display to (All players) the text: ((Name of (Triggering player)) + ( has chosen + ((Proper name of (Last created unit)) + (, the + (Name of (Last created unit))))))
    Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    ((Selling unit) is in GroupB) Equal to True
    Then - Actions
    Set Finished[(Player number of (Triggering player))] = True
    Unit - Remove Selection Arrow from (Triggering unit)
    Unit - Change ownership of (Triggering unit) to Player 12 (Brown) and Retain color
    Unit - Change color of (Triggering unit) to Black
    Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
    Camera - Pan camera for (Triggering player) to (Center of BaseA <gen>) over 0.00 seconds
    Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at (Center of BaseB <gen>) facing 0.00 degrees
    Special Effect - Create a special effect attached to the origin of (Last created unit) using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
    Selection - Select (Last created unit) for (Triggering player)
    Game - Display to (All players) the text: ((Name of (Triggering player)) + ( has chosen + ((Proper name of (Triggering unit)) + (, + (Name of (Triggering unit))))))
    Else - Actions[/trigger]


    Final Touches

    As a small add-on I'd recommend adding a finishing touch to the Dummy Unit. in his Model File, change it to 'blank' / a 'space'.
    This will make him invisible, in the editor hell show up as a green box, but ignore that.

    new2.jpg

    new.JPG

    Thats all folks, thx for reading this tutorial.
    I hope you enjoyed it and learned something from it.
     

    Attached Files:

    Last edited by a moderator: Oct 13, 2007
  2. HeretoDLstuff

    HeretoDLstuff

    Joined:
    Feb 27, 2007
    Messages:
    2,093
    Resources:
    4
    Models:
    3
    Maps:
    1
    Resources:
    4
    Goodjob, +rep!!
     
  3. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    How many of these do we need? -.-

    You people should really get together and write one large tutorial or something.

    By the way, tip, setting the max slots of an array in the variable manager doesn't do anything that you will notice 99% of the time. (It just initializes that many array values to null/0/false)

    Also, you leak a lot.
     
  4. Fulla

    Fulla

    Joined:
    Aug 3, 2005
    Messages:
    757
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    This one has a few slight add-ons than most other click hero selection systems. It also includes a testmap + lots of pics.
    A guy can simply copy paste and setup the whole system within 15min or so.

    Ah ok, didnt know arrays worked like that.
    I usualyl work in 100% jass anyways, was a bit strange working in GUI again :).

    Yea I knew as I was making it, there were many leaks, but I thought they were irrelevant in this case, as I wanted to keep the samples size toa bare minimum.
     
  5. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    I agree with PurplePoot.

    As tutoril makers we should make only 1 tutorial, instead of 3 !! We have 3 hero tutorials in THW, all about the same topic, we should get together.
     
  6. Fulla

    Fulla

    Joined:
    Aug 3, 2005
    Messages:
    757
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Sounds like a good idea, I could add the others onto this map.
    - Taverns
    - Regions
     
  7. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    That is NOT what he means. His idea is to put OUR tutorials all together in one. Not to put them into your work. Check my taverns system, you may like it.
     
  8. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    You guys can have separate ones if you really want, I doubt people will get along that well with one giant tut ;)

    I'll just name them according to the method.

    And Fulla, at least please note the leaks; tell people somewhere (top or bottom of the tutorial) that it has them, then give a link on How to remove them.

    And how's the new title? (Or is there a better word to describe it?)
     
  9. Fulla

    Fulla

    Joined:
    Aug 3, 2005
    Messages:
    757
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    I meant we combined all the maps into one, but it doesnt really matter.

    @ Purple
    Ill mention the leaks. New title seems great.
     
  10. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    Sry i miss understood your setence. However i think it DOES matter, as it will be a benefict for all people.
     
  11. Need_O2

    Need_O2

    Joined:
    Aug 24, 2007
    Messages:
    2,880
    Resources:
    0
    Resources:
    0
    Sorry I didnt like it much thing is too many globals and triggers for a this kind of system
    Hey guyz you know what would be good ?
    everyone has his own choosing place
    you change hero with arrow keys
    fading when changing
    camera turn around unit and there is a demonstration button for each ability hero has that shows what does ability do
    And a Description about hero and spells ofcourse
    I think it wont cost more then 20kb
     
  12. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    You are describing a system that look like Vexorians system ...
    It requires JASS ... to much advanced for this tut.
     
  13. Fulla

    Fulla

    Joined:
    Aug 3, 2005
    Messages:
    757
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Yea I originally made this in Jass, but then scaled it back to GUI, so more ppl could use it.
     
  14. HappyTauren

    HappyTauren

    Joined:
    Nov 3, 2006
    Messages:
    8,408
    Resources:
    87
    Models:
    61
    Icons:
    23
    Packs:
    1
    Tutorials:
    2
    Resources:
    87
    I made vexorian-like system in jass, then reverted it into gui. Wasnt particularly hard.
     
  15. Flame_Phoenix

    Flame_Phoenix

    Joined:
    May 4, 2007
    Messages:
    2,283
    Resources:
    11
    Tools:
    1
    Maps:
    1
    Spells:
    6
    Tutorials:
    3
    Resources:
    11
    It isn't hard because like me, you DO understand JASS.

    But many people don't. Besides this tutorial is ment to teach all audiences.
    Also, Gui is less efective then JASS ... Always.
     
  16. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Are you planning on making future changes, or would'ya like this to finish the process? It seems fine for approval.

    Also, what section would you like it in? General Mapping or GUI?
     
  17. Fulla

    Fulla

    Joined:
    Aug 3, 2005
    Messages:
    757
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    If its ok with you, approve it.
    I'd prefer you decided, where you feel it is best for it to go.

    I may update it in the future, but currently planning on making a multiboard tutorial.
     
  18. Wolverabid

    Wolverabid

    Joined:
    Oct 23, 2006
    Messages:
    8,302
    Resources:
    5
    Tutorials:
    5
    Resources:
    5
    This fine tutorial still requires some editing before its approval.
    1. General Tutorial Submitting Rules & Guidelines - README!
    2. The [hidden][/hidden] tags should be removed: please don't make the reader work in order to learn: easier is better.

    3. The images should be placed in their proper positions rather than attached at the bottom of the document.
     
  19. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Haha, I didn't even notice the images ;)

    Well then, Wolver's the boss, Fulla, I guess I'll approve it once the aforementioned changes are made.
     
  20. Fulla

    Fulla

    Joined:
    Aug 3, 2005
    Messages:
    757
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Ok sure nps, but
    - How do I remove my signature from a thread?
    - How do I display images from attachments as opposed to from links.

    I thought simply [​IMG] - with images tags but doesn work.