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

Hero picking system for my map not working as intended

Status
Not open for further replies.
Level 3
Joined
Apr 4, 2020
Messages
31
Currently working on a basic hero picking system for my map, where you switch in between heroes with arrow keys and chose your hero with esc. Setup looking like this:

  • HS Setup
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Set VariableSet HS_Heroes[1] = Lira Windrun 0036 <gen>
      • Set VariableSet HS_Heroes[2] = Captain of the Guard 0325 <gen>
      • Set VariableSet HS_Heroes[3] = Dagren der Orcschlächter 0056 <gen>
      • Set VariableSet HS_Heroes[4] = Gul'dan 0030 <gen>
      • Set VariableSet HS_Heroes[5] = Bladedancer 0026 <gen>
      • Set VariableSet HS_Heroes[6] = Bestienmeister 0032 <gen>
      • Set VariableSet HS_Heroes[7] = Sylvanas Windrunner 0048 <gen>
      • Set VariableSet HS_Heroes[8] = Chen Sturmbräu 0201 <gen>
      • Set VariableSet HS_Heroes[9] = Ashenvale Protector 0271 <gen>
      • Custom script: set udg_HS_Hero_Descrip[1] = "Stormchaser\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[2] = "Captain of the Guard\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[2] = "Captain of the Guard\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[3] = "Paladin(WIP)\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\n\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[4] = "Warlock\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\n\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[5] = "Bladedancer\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\n\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[6] = "Beastmaster(WIP)\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\n\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[7] = "Sylvanas\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\n\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[8] = "Panda(WIP)\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\n\nInt 24 (+2,9)"
      • Custom script: set udg_HS_Hero_Descrip[9] = "Ashenvale Protector(WIP)\n\nStr: 17 (+1,9)\nAgi: 35 (|cff808000+3,8|r)\n\nInt 24 (+2,9)"
      • Set VariableSet Camera[1] = HPArcher <gen>
      • Set VariableSet Camera[2] = HPGuard <gen>
      • Set VariableSet Camera[3] = HPPaladin <gen>
      • Set VariableSet Camera[4] = HPWarlock <gen>
      • Set VariableSet Camera[5] = HPBladedancer <gen>
      • Set VariableSet Camera[6] = HPBeast <gen>
      • Set VariableSet Camera[7] = HPDarkArcher <gen>
      • Set VariableSet Camera[8] = HPPanda <gen>
      • Set VariableSet Camera[9] = HPGolem <gen>
      • -------- --------
      • Set VariableSet HS_Heroes_Total = 9
      • -------- --------
      • Set VariableSet HS_Players = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)).)
      • -------- --------
      • Player Group - Pick every player in HS_Players and do (Actions)
        • Loop - Actions
          • Set VariableSet PN = (Player number of (Picked player))
          • -------- --------
          • Set VariableSet HS_Selected[PN] = 1
          • Selection - Select HS_Heroes[1]
          • Camera - Apply Camera[1] for (Picked player) over 0.20 seconds
          • Game - Display to (All players) for 70.00 seconds the text: HS_Hero_Descrip[1]
          • -------- --------
          • Trigger - Add to HS Left Arrow <gen> the event (Player - (Picked player) Presses the Left Arrow key)
          • Trigger - Add to HS Right Arrow <gen> the event (Player - (Picked player) Presses the Right Arrow key)
          • Trigger - Add to HS Select Hero <gen> the event (Player - (Picked player) skips a cinematic sequence)
      • Trigger - Turn on HS Camera <gen>
      • -------- --------
      • Countdown Timer - Start HS_Timer as a One-shot timer that will expire in 120.00 seconds
Currently 2 things will happen: When Player 1 doesn't use arrow keys, player 2( or 3,4 etc) can freely use arrow keys and chose hero. When player 1 uses arrow keys, it's used for other players aswell. You can still chose a hero but only player one can use arrow keys in that instance.

It's looking like this (quite identical for right arrow key)

  • HS Left Arrow
    • Events
    • Conditions
      • HS_Selected[(Player number of (Triggering player))] Not equal to 0
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HS_Selected[PN] Equal to 1
        • Then - Actions
          • Set VariableSet HS_Selected[PN] = HS_Heroes_Total
          • Cinematic - Clear the screen of text messages for HS_Players.
          • Camera - Lock camera target for (Triggering player) to HS_Heroes[HS_Selected[PN]], offset by (0.00, 0.00) using Default rotation
          • Selection - Select HS_Heroes[HS_Selected[PN]] for (Triggering player)
          • Game - Display to HS_Players for 70.00 seconds the text: HS_Hero_Descrip[HS_Selected[PN]]
        • Else - Actions
          • Set VariableSet HS_Selected[PN] = (HS_Selected[PN] - 1)
          • Cinematic - Clear the screen of text messages for HS_Players.
          • Camera - Lock camera target for (Triggering player) to HS_Heroes[HS_Selected[PN]], offset by (0.00, 0.00) using Default rotation
          • Selection - Select HS_Heroes[HS_Selected[PN]] for (Triggering player)
          • Game - Display to (All players) for 70.00 seconds the text: HS_Hero_Descrip[HS_Selected[PN]]
Finally, once you have chosen your hero, this hero shouldn't be able to be playable by others. Atm you can chose a hero and this hero is still pickable for others.

  • HS Select Hero
    • Events
    • Conditions
      • HS_Selected[(Player number of (Triggering player))] Not equal to 0
      • HS_Hero_Check[HS_Selected[PN]] Not equal to 1.00
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Set VariableSet HS_Point = (Position of HS_Heroes[HS_Selected[PN]])
      • Set VariableSet HS_Heroes_Total = (HS_Heroes_Total - 1)
      • Set VariableSet HS_Hero_Check[HS_Selected[PN]] = (HS_Hero_Check[HS_Selected[PN]] + 1.00)
      • Unit - Remove HS_Heroes[HS_Selected[PN]] from the game
      • -------- --------
      • Unit - Create 1 (Unit-type of HS_Heroes[HS_Selected[PN]]) for (Triggering player) at HS_Point facing (Facing of HS_Heroes[HS_Selected[PN]]) degrees
      • Hero - Create Ankh der Reinkarnation and give it to (Last created unit)
      • Unit Group - Add (Last created unit) to RealHero
      • Player - Make Player 20 (Lavender) treat (Owner of (Last created unit)) as an Ally with shared vision
      • Player - Make (Owner of (Last created unit)) treat Player 20 (Lavender) as an Ally with shared vision
      • Selection - Clear selection for (Triggering player).
      • Selection - Select (Last created unit) for (Triggering player)
      • Cinematic - Clear the screen of text messages for (All players matching (HS_Hero_Check[HS_Selected[PN]] Equal to 1.00).).
      • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
      • Camera - Pan camera for (Triggering player) to HS_Point over 0.00 seconds
      • Set VariableSet HS_Selected[PN] = 0
      • -------- Clean up Point memory leak --------
      • Custom script: call RemoveLocation(udg_HS_Point)
      • Set VariableSet HS_Selected[0] = 0
      • Set VariableSet AmountOfHeroes = (AmountOfHeroes + 1)
      • Player Group - Pick every player in HS_Players and do (Actions)
        • Loop - Actions
          • Set VariableSet PN = (Player number of (Picked player))
          • Set VariableSet HS_Selected[0] = (HS_Selected[0] + HS_Selected[PN])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HS_Selected[0] Equal to 0
        • Then - Actions
          • Unit Group - Pick every unit in (Units owned by Player 20 (Lavender) matching (((Matching unit) is A Hero) Equal to Wahr).) and do (Actions)
            • Loop - Actions
              • Unit - Remove (Picked unit) from the game
              • Trigger - Turn on GoodMid 1 <gen>
              • Trigger - Turn on GoodLeft1 <gen>
              • Trigger - Turn on GoodRight 1 <gen>
              • Trigger - Turn on BadLeft 1 <gen>
              • Trigger - Turn on BadRight 1 <gen>
              • Trigger - Turn on BadMid 1 <gen>
              • Trigger - Turn off (This trigger)
          • Trigger - Turn off HS Camera <gen>
          • Trigger - Turn off HS Left Arrow <gen>
          • Trigger - Turn off HS Right Arrow <gen>
          • Countdown Timer - Pause HS_Timer
          • Custom script: call DestroyTimer(udg_HS_Timer)
        • Else - Actions
What i want to add finally is an option that you get a random hero if you didnt chose one after 120 seconds, since i have a trigger that removes all heroes once all players have one, since the area is used for the map.
Any help is much appreciated
 
Level 3
Joined
Apr 4, 2020
Messages
31
Can you please attach the map. Or a demo map with just these triggers.
Attached the map. Relevant Triggers are in the "Hero" folder. Pretty sure you helped me out when i started originally working on this map a few years back :) Thanks for helping me again
 

Attachments

  • Hero Siege Test.w3m
    3.9 MB · Views: 13

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Okay, I think it should be fixed now.

What I did:
I added two Player Groups, ActiveUsers and Users to keep track of players that are actively playing the game.
I added a Player Leaves trigger which handles when someone leaves the game. It removes them from ActiveUsers and removes them from the hero selection process.
I added a Random Hero trigger so that players will get random heroes once the timer expires.
I added a Unit Group that contains all of the selectable Heroes (HS_HeroGroup).
I got rid of the Aerial Shackles Debuff stuff you were doing. Instead, I'm stunning the Heroes using the BlzPauseUnitEx() function.

Your old HS Select Hero trigger had some issues:
You're checking PN inside of the Conditions before it's been set.
You're subtracting 1 from HS_Heroes_Total which does not work the way you want it to. This will simply remove the very last hero, not the chosen hero.

The system needs to be slightly more advanced if you want to prevent players from being able to view already chosen heroes. But as it is now the bugs you mentioned should all be fixed, although I couldn't test the Player 1 arrow key stuff.
 

Attachments

  • Hero Siege Test U1.w3m
    3.9 MB · Views: 15
Last edited:
Level 3
Joined
Apr 4, 2020
Messages
31
Okay, I think it should be fixed now.

What I did:
I added two Player Groups, ActiveUsers and Users to keep track of players that are actively playing the game.
I added a Player Leaves trigger which handles when someone leaves the game. It removes them from ActiveUsers and removes them from the hero selection process.
I added a Random Hero trigger so that players will get random heroes once the timer expires.
I added a Unit Group that contains all of the selectable Heroes (HS_HeroGroup).
I got rid of the Aerial Shackles Debuff stuff you were doing. Instead, I'm stunning the Heroes using the BlzPauseUnitEx() function.

Your old HS Select Hero trigger had some issues:
You're checking PN inside of the Conditions before it's been set.
You're subtracting 1 from HS_Heroes_Total which does not work the way you want it to. This will simply remove the very last hero, not the chosen hero.

The system needs to be slightly more advanced if you want to prevent players from being able to view already chosen heroes. But as it is now the bugs you mentioned should all be fixed, although I couldn't test the Player 1 arrow key stuff.
Hey man, thanks for your input! Yeah 2 Hero Groups to distinguish between active players wasnt even something i thought of.
Makes it easier to handle leavers aswell.

The Pause function def is smoother than my approach.

You're checking PN inside of the Conditions before it's been set.
Ahhh okay, yeah thanks for clearing that up.

So far it seems to work fine, have yet to test it in multiplayer tho.
One thing that i couldnt seem to fix was the random hero: You always get sylvanas. I tried it 6 times and i always got her. Just incredibly lucky/unlucky?
Thanks so far for your help.
 
Status
Not open for further replies.
Top