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

(SOLVED) - Hero limit problem

Status
Not open for further replies.
Level 21
Joined
Apr 8, 2017
Messages
1,530
How to make 1 hero type limit, i can make like unlimited type of hero but i only want 1

Useless -> help with 1 hero limit

ovErs28.png


PLEASE HELP
 

Attachments

  • upload_2018-9-17_7-35-55.png
    upload_2018-9-17_7-35-55.png
    972.7 KB · Views: 81
Level 39
Joined
Feb 27, 2007
Messages
5,012
@Diegoit you need to be more specific. One per player or one per map? The trigger posted by Wildfire does 1 per map, but if you want one per player you will need to add your heroes to the Techtree - Dependency Eqivalents - Hero field in Gameplay Constants (make sure "use custom gameplay constants" is checked too). I don't think you'll also have to add your altars to the altar equivalency line, but it's possible you do.
 
Level 39
Joined
Feb 27, 2007
Messages
5,012
So it turns out that in nearly every thread where someone has this same question, a user invariably suggests Gameplay Constants + the melee limit heroes action. In this thread that person is, unfortunately, me. It seems logical, right? And why would the game make you do something else if the GPC field exists, right? Nope. Turns out this post by @BloodSoul finally made it clear what's going on (tbf I should have checked Blizzard.j myself but I didn't), which is the melee limit action internally does a Player - Limit training of <hero type> for <player> to <the GPC max number of each hero> loop for all the different base Melee heroes. Custom ones, obviously, it doesn't do that for. But it would REALLY make sense for it to have been a function that dynamically pulls all the rawcodes of heroes from the GPC list and adds them to that function. C'mon, Blizzard!

JASS:
function MeleeStartingHeroLimit takes nothing returns nothing
    local integer index

    set index = 0
    loop
        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

So ultimately you do also have to limit the heroes yourself with the trigger below. The custom heroes and your custom altars should still be added to the relevant GPC techtree equivalent list, though.

  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Player Group - Pick every player in (All Players) and do (Actions)
      • Loop - Actions
        • Player - Limit training of <your hero> to 1 for (picked player)
 
Status
Not open for further replies.
Top