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

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
I need help about something. I putted 3 triggers here. Each trigger selects and transports the Hero. Now what i need: Let's say Player Red selects Ghost Lord, and it's now hero for Player Red. Now how can I make for Triggers: Lightning Destroyer and Death Bringer not to work for Player Red if he tries to select them, and he already has a hero?
I want those 2 triggers to be disabled for Player Red because he has already selected his hero. Answer fast plz, I have much more to do :D, my map is kinda hard to do...
I hope you guys will understand what I want :)

  • Ghost Lord
    • 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
    • Conditions
      • (Triggering unit) Equal to Ghost Lord 0069 <gen>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroBoolean[1] Equal to True
        • Then - Actions
          • Set ReturnFromMission = (Center of Return from Mission <gen>)
          • Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at ReturnFromMission facing 360.00 degrees
          • Item - Create |cFFFFFF00Ankh of Reincarnation at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Healing at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Mana at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Special Effect - Create a special effect attached to the overhead of Ghost Lord 0069 <gen> using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Unit - Remove Ghost Lord 0069 <gen> from the game
          • Custom script: call RemoveLocation(udg_ReturnFromMission)
        • Else - Actions
          • Set HeroBoolean[1] = True
  • Lightning Destroyer
    • 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
    • Conditions
      • (Triggering unit) Equal to Lightning Destroyer 0070 <gen>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroBoolean[2] Equal to True
        • Then - Actions
          • Set ReturnFromMission = (Center of Return from Mission <gen>)
          • Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at ReturnFromMission facing 360.00 degrees
          • Item - Create |cFFFFFF00Ankh of Reincarnation at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Healing at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Mana at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Special Effect - Create a special effect attached to the overhead of Lightning Destroyer 0070 <gen> using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Unit - Remove Lightning Destroyer 0070 <gen> from the game
          • Custom script: call RemoveLocation(udg_ReturnFromMission)
        • Else - Actions
          • Set HeroBoolean[2] = True
  • Death Bringer
    • 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
    • Conditions
      • (Triggering unit) Equal to Death Bringer 0071 <gen>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroBoolean[3] Equal to True
        • Then - Actions
          • Set ReturnFromMission = (Center of Return from Mission <gen>)
          • Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at ReturnFromMission facing 360.00 degrees
          • Item - Create |cFFFFFF00Ankh of Reincarnation at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Healing at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Mana at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Special Effect - Create a special effect attached to the overhead of Death Bringer 0071 <gen> using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Unit - Remove Death Bringer 0071 <gen> from the game
          • Custom script: call RemoveLocation(udg_ReturnFromMission)
        • Else - Actions
          • Set HeroBoolean[3] = True
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Make a boolean array and check it. When any of those units is selected, first check whether, for instance PlayerAlreadyHasHero[Player number of (Triggering Player)] is false. If it is, continue and set it to true, otherwise stop and dont create the hero
 
Level 18
Joined
May 11, 2012
Messages
2,103
like this?

  • Ghost Lord
    • 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
    • Conditions
      • (Triggering unit) Equal to Ghost Lord 0069 <gen>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HeroBoolean[1] Equal to True
          • PlayerHasHeroBoolean[(Player number of (Triggering player))] Equal to False
        • Then - Actions
          • Set ReturnFromMission = (Center of Return from Mission <gen>)
          • Unit - Create 1 (Unit-type of (Triggering unit)) for (Triggering player) at ReturnFromMission facing 360.00 degrees
          • Item - Create |cFFFFFF00Ankh of Reincarnation at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Healing at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Item - Create |cFFFFFF00Potion of Mana at (Center of (Playable map area))
          • Hero - Give (Last created item) to (Last created unit)
          • Special Effect - Create a special effect attached to the overhead of Ghost Lord 0069 <gen> using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
          • Unit - Remove Ghost Lord 0069 <gen> from the game
          • Custom script: call RemoveLocation(udg_ReturnFromMission)
        • Else - Actions
          • Set HeroBoolean[1] = True
          • Set PlayerHasHeroBoolean[(Player number of (Triggering player))] = True
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
  • Set PlayerHasHeroBoolean[(Player number of (Triggering player))] = True
This has to be under
  • Then - Actions
Also, you can put the actions of all of these triggers into one - notice how they all have exactly the same events?
Make an If/Then/Else that checks if triggering unit is Ghost Lord, and then put the contents of the Ghost Lord trigger into there, then you can make a similar If/Then/Else for each hero.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I'm going to whip up a quick system for you.

The basics:
unit array where
unit[1] = ghost lord
unit[2] = paladin
etc
unit group that contains all unchosen heroes (so that a player cant choose a hero another player chose)
a boolean array that you have already to check if a player has chosen yet

Then for the selection trigger, i loop through all the heroes to see if it's the one selected.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
No problem, I had fun :)

Here's the trigger:
  • SHS Select
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • shs_PlayerChosen[(Player number of (Triggering player))] Equal to False
      • ((Triggering unit) is in shs_AvailableHeroes) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to shs_PlayerCurrentSelection[(Player number of (Triggering player))]
        • Then - Actions
          • For each (Integer B) from 1 to shs_HeroId, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Triggering unit) Equal to shs_HeroUnit[(Integer B)]
                • Then - Actions
                  • Unit - Change ownership of (Triggering unit) to (Triggering player) and Change color
                  • Unit - Move (Triggering unit) instantly to (Center of Region 000 <gen>)
                  • Unit Group - Remove (Triggering unit) from shs_AvailableHeroes
                  • Hero - Create Ankh of Reincarnation and give it to (Triggering unit)
                  • Hero - Create Potion of Greater Healing and give it to (Triggering unit)
                  • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Camera - Pan camera for (Triggering player) to (Position of (Triggering unit)) over 0.00 seconds
                  • Set shs_PlayerChosen[(Player number of (Triggering player))] = True
                • Else - Actions
        • Else - Actions
          • Set shs_PlayerCurrentSelection[(Player number of (Triggering player))] = (Triggering unit)
(you have to make events for the rest of the players, and remove the memory leak)

And here is the configuration trigger:
  • SHS Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set shs_HeroId = (shs_HeroId + 1)
      • Set shs_HeroUnit[shs_HeroId] = Paladin 0000 <gen>
      • Set shs_HeroId = (shs_HeroId + 1)
      • Set shs_HeroUnit[shs_HeroId] = Archmage 0001 <gen>
      • Set shs_HeroId = (shs_HeroId + 1)
      • Set shs_HeroUnit[shs_HeroId] = Mountain King 0002 <gen>
      • Set shs_HeroId = (shs_HeroId + 1)
      • Set shs_HeroUnit[shs_HeroId] = Blood Mage 0003 <gen>
      • -------- ----- --------
      • For each (Integer A) from 1 to shs_HeroId, do (Actions)
        • Loop - Actions
          • Unit Group - Add shs_HeroUnit[(Integer A)] to shs_AvailableHeroes
All you have to do is replace Paladin, Archmage, etc with your heroes. To add more, copy and paste the two lines:
  • Set shs_HeroId = (shs_HeroId + 1)
  • Set shs_HeroUnit[shs_HeroId] = Blood Mage 0003 <gen>
And set it to the next hero.
 

Attachments

  • SimpleHeroSelection001.w3x
    18.1 KB · Views: 47
Status
Not open for further replies.
Top