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

Hero -> race

Status
Not open for further replies.
Level 1
Joined
Jun 6, 2013
Messages
4
I want to make a script which does something like this :
- give every player a hero spawned in their base in the beggining of the map based on the race they chose
- if a player has the same race as another player, he will get a different hero

Note: The map is partially melee so you get the basic starting with 5 workers and the main building.

Any tips/help?
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
This trigger fires at map initialization.
  • Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ---- Sets max pick for each race ---- --------
      • Set Hu_MaxPick = 4
      • Set Orc_MaxPick = 4
      • Set Un_MaxPick = 4
      • Set NE_MaxPick = 4
      • -------- ---- Sets human heroes ---- --------
      • Set Hu_Hero[1] = Paladin
      • Set Hu_Hero[2] = Archmage
      • Set Hu_Hero[3] = Mountain King
      • Set Hu_Hero[4] = Blood Mage
      • -------- ---- Sets orc heroes ---- --------
      • Set Orc_Hero[1] = Blademaster
      • Set Orc_Hero[2] = Far Seer
      • Set Orc_Hero[3] = Tauren Chieftain
      • Set Orc_Hero[4] = Shadow Hunter
      • -------- ---- Sets undead heroes ---- --------
      • Set Un_Hero[1] = Death Knight
      • Set Un_Hero[2] = Lich
      • Set Un_Hero[3] = Dreadlord
      • Set Un_Hero[4] = Crypt Lord
      • -------- ---- Sets night elf heroes ---- --------
      • Set NE_Hero[1] = Keeper of the Grove
      • Set NE_Hero[2] = Priestess of the Moon
      • Set NE_Hero[3] = Demon Hunter
      • Set NE_Hero[4] = Warden
This trigger fires after 0 second of game time and picks random hero for each race and player
  • Start
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching ((((Matching player) controller) Equal to User) or (((Matching player) controller) Equal to Computer))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Picked player)) Equal to Human
            • Then - Actions
              • Set Number = (Random integer number between 1 and Hu_MaxPick)
              • Unit - Create 1 Hu_Hero[Number] for (Picked player) at ((Picked player) start location) facing Default building facing degrees
              • Set Hu_Hero[Number] = Hu_Hero[Hu_MaxPick]
              • Set Hu_MaxPick = (Hu_MaxPick - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Picked player)) Equal to Orc
            • Then - Actions
              • Set Number = (Random integer number between 1 and Orc_MaxPick)
              • Unit - Create 1 Orc_Hero[Number] for (Picked player) at ((Picked player) start location) facing Default building facing degrees
              • Set Orc_Hero[Number] = Orc_Hero[Orc_MaxPick]
              • Set Orc_MaxPick = (Orc_MaxPick - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Picked player)) Equal to Undead
            • Then - Actions
              • Set Number = (Random integer number between 1 and Un_MaxPick)
              • Unit - Create 1 Un_Hero[Number] for (Picked player) at ((Picked player) start location) facing Default building facing degrees
              • Set Un_Hero[Number] = Un_Hero[Un_MaxPick]
              • Set Un_MaxPick = (Un_MaxPick - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Picked player)) Equal to Night Elf
            • Then - Actions
              • Set Number = (Random integer number between 1 and NE_MaxPick)
              • Unit - Create 1 NE_Hero[Number] for (Picked player) at ((Picked player) start location) facing Default building facing degrees
              • Set NE_Hero[Number] = NE_Hero[NE_MaxPick]
              • Set NE_MaxPick = (NE_MaxPick - 1)
            • Else - Actions
At the moment, it will work for up to 4 players of the same race, because in ini 4 heroes per race have been set.

Those "..._MaxPick" are integer variables
"Number" is integer variable
"..._Hero" is unit-type variable array
 
Last edited:
Level 28
Joined
Sep 26, 2009
Messages
2,520
It is quite easy, but setting up a hero list in the initialization trigger can be kind of annoying.
When you want to use it, just be sure that those ..._MaxPick integers have same value as the sum of heroes per that race - in my case I set up 4 heroes for that race, so I set that race's MaxPick to 4.

If the number is not same as amount of heroes for that race, then the second trigger may pick up nonexistant hero (=> creates no unit), or will not pick up some heroes from the list.
 
Status
Not open for further replies.
Top