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

Only One (Trigger)

Status
Not open for further replies.
Level 3
Joined
Sep 27, 2015
Messages
42
Hi!

Am trying to make a trigger to limit the recruitment of a certain hero to one for all players. What I mean by this is that the hero is available normally to anyone with the right building, but as soon as one player trains him, it is unavailable to anyone else, and the player that trained the hero can only revive him and not train a second.

How can I do this?
 
Level 10
Joined
Apr 4, 2010
Messages
509
  • Paladin Limit
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Paladin
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Make Paladin Unavailable for training/construction by (Player((Integer A)))
You might want to add this in the beginning too
  • For each (Integer A) from 1 to 12, do (Actions)
    • Loop - Actions
      • Player - Limit training of Paladin to 1 for (Player((Integer A)))
But I think Heroes are already limited to 1 of each type.
 
Level 3
Joined
Sep 27, 2015
Messages
42
I can't seem to find these options in the trigger list. I've ended up with...

Do action for each IntergerA 1 to 12, do (Player limit - training of UNIT to 0 for Player1)

Can halp please? ;_;
 
Level 3
Joined
Nov 22, 2014
Messages
50
I can't seem to find these options in the trigger list. I've ended up with...

Do action for each IntergerA 1 to 12, do (Player limit - training of UNIT to 0 for Player1)

Can halp please? ;_;

Under player: Player - Set Training/Construction Availability Of Unit.

Don't set it just for player 1 but for every player.
For each integer 1 - 12 ->
Player - Limit training of Paladin to 1 for (Player((Integer A)))

Basically what Dee Boo said..
 

Ardenian

A

Ardenian

It is 'Convert Player Index to ...'
As player number you set the variable or the Integer you used in the loop
 
Level 10
Joined
Apr 4, 2010
Messages
509
attachment.php
 

Attachments

  • Help.gif
    Help.gif
    982 KB · Views: 266
Level 3
Joined
Sep 27, 2015
Messages
42
Thanks Dee, that helps a lot. Am having trouble with something else though now...

This is my string -

Do Action for each (intergerA) from 1 to 12 make UNIT unavailable for Player(intergerA)

I can't find the 'loop actions' options or the 'For Each intergerA from 1 to 12 do Actions.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
But I think Heroes are already limited to 1 of each type.

Uhm... I recommend you to take a look at the Melee Initializations of the Trigger editor when you just created a new map.
Convert it into custom text and look at the stuff inside the BJs until you only have natives left.
JASS:
call MeleeStartingHeroLimit(  )
// ->
function MeleeStartingHeroLimit takes nothing returns nothing
    local integer index

    set index = 0
    loop
        // max heroes per player
        call SetPlayerMaxHeroesAllowed(bj_MELEE_HERO_LIMIT, Player(index))

        // each player is restricted to a limit per hero type as well
        call ReducePlayerTechMaxAllowed(Player(index), 'Hamg', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Hmkg', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Hpal', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Hblm', bj_MELEE_HERO_TYPE_LIMIT)

        call ReducePlayerTechMaxAllowed(Player(index), 'Obla', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Ofar', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Otch', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Oshd', bj_MELEE_HERO_TYPE_LIMIT)

        call ReducePlayerTechMaxAllowed(Player(index), 'Edem', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Ekee', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Emoo', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Ewar', bj_MELEE_HERO_TYPE_LIMIT)

        call ReducePlayerTechMaxAllowed(Player(index), 'Udea', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Udre', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Ulic', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Ucrl', bj_MELEE_HERO_TYPE_LIMIT)

        call ReducePlayerTechMaxAllowed(Player(index), 'Npbm', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Nbrn', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Nngs', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Nplh', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Nbst', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Nalc', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Ntin', bj_MELEE_HERO_TYPE_LIMIT)
        call ReducePlayerTechMaxAllowed(Player(index), 'Nfir', bj_MELEE_HERO_TYPE_LIMIT)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYERS
    endloop
endfunction
Which means this:
  • Actions
    • For each (Integer index) from 1 to 12, do (Actions)
      • Loop - Actions
        • Player - Limit training of Heroes to 3 for (Player(index))
        • Player - Limit training of Archmage to 1 for (Player(index))
        • Player - Limit training of Mountain King to 1 for (Player(index))
        • Player - Limit training of Paladin to 1 for (Player(index))
        • Player - Limit training of Blood Mage to 1 for (Player(index))
(for every single hero including neutrals)

@RyanAvx
There are two things that you might want.
1: Limit training of <MyHero> to 1 for each player.
2: Limit training of <MyHero> to 1 for the entire map.

The first one is easy to make and is literally the same as above... however slightly different:
  • MyTrigger
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of MyHero to 1 for (Picked player)
The second one may need some testing when you train the unit and before you finished it, another player starts training the unit.
That may mean two of those heroes after all.
But maybe it works without problems :D
  • MyTrigger
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Dummy - Must disable unit?
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Make (Trained unit-type) Unavailable for training/construction by (Picked player)
You can understand what you need as conditions.

I also recommend you to use the Player Group one instead but maybe you need the for loop later though.
The multiple actions is a different action, so you remove your current for loop and create a new one where it says "and do multiple actions" (there are a total of 6 for loops).
One hint though... ALWAYS USE MULTIPLE ACTIONS!
 
Status
Not open for further replies.
Top