1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

How to make original AI choose a specific first hero?

Discussion in 'World Editor Help Zone' started by DragoNite, Jul 6, 2019.

  1. DragoNite

    DragoNite

    Joined:
    Jun 29, 2019
    Messages:
    2
    Resources:
    0
    Resources:
    0
    I am trying to tinker with the Blizzard AI for melee map. Is there any way to make the AI go the same first hero every game (ie, Archmange for Human, Death Knight for UD)?
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,015
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I'm not familiar with AI, but @Nowow could probably answer this. I would bet that if you manually disable all other heroes for that computer player it would work. Just remember to re-enable the other heroes for the AI players after the AI has trained their first hero.
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Picked Player) controller equal to Computer
            • Race of (Picked Player) equal to Human
          • Then - Actions
            • Player - Make Paladin Unavailable for training/construction by (Picked player)
            • Player - Make Mountain King Unavailable for training/construction by (Picked player)
            • Player - Make Blood Mage Unavailable for training/construction by (Picked player)
          • Else - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Picked Player) controller equal to Computer
            • Race of (Picked Player) equal to Undead
          • Then - Actions
            • Player - Make Lich Unavailable for training/construction by (Picked player)
            • Player - Make Dreadlord Unavailable for training/construction by (Picked player)
            • Player - Make Crypt Lord Blood Mage Unavailable for training/construction by (Picked player)
          • Else - Actions
        • -------- etc ---------
     
  3. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    I bet you would prevent AI from making any heroes that way (unless it randomly picks the hero order which only enabled hero is the first one). Just open up the AI editor, go to the heroes tab and set the chance of hero order you want to 100 percent.
     
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,015
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Clearly setting an order in the AI editor is better, but I don't see any reason what you stated would be the case. The melee AI builds things it has access to and doesn't build things it doesn't. Enabling/disabling training units is like not meeting the requirements; the AI knows it can build a Tauren Totem when it has a Stronghold but not before. Melee AI is incentivized to build a hero; if you take away the other options it will do what it's left with reliably.
     
  5. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    I just tested your method just to make sure, and as expected its not working. Because the way AI chooses hero is it generates a set of random integers and determines the order of trained heroes from a fixed array by using these random integers. I think if all you need is change order of trained heroes, easiest way (that I know) is to import a custom common.ai file with changed PickMeleeHero function. It is included in attached map, all you need to do is import that common.ai to your melee map and change its path to common.ai in import editor. You can also further edit PickMeleeHero function if you want different your ai to train different heroes for different races.
     

    Attached Files:

  6. Nowow

    Nowow

    Joined:
    Jun 15, 2016
    Messages:
    431
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Yes (but you'll need to use JASS AI for that).

    Melee AI decides in what order to choose heroes at the start of the map, using the function called
    PickMeleeHero
    , called directly from the script. If you want to make sure to always choose the same heroes, find the melee AI script file you need, and replace
    PickMeleeHero
    with a function like:

    Code (vJASS):

    function PredefinedPickHeroes takes nothing returns nothing
        set hero_id = 'u001' //unit is for first hero here
        set hero_id2 = 'u002' // same for 2nd hero
        set hero_id3 = 'u003' // 3rd

        return hero_id
    endfunction
     


    Note that this will work for only one race. If you want it to work for all races change the function to take a race type argument, and choose heroes accordingly. You can see how it works for
    PickMeleeHero
    in this page.

    Incidentally, @Pyrogasm 's solution would work for normal units, but doesn't work for heroes, because the AI doesn't detect if the unit it wants to train is actually being trained. Also, the AI awaits for a hero to actually finish training to start creeping, so disabling the ability to train the first hero will make sure the AI is stuck forever.
     
  7. Death Adder

    Death Adder

    Joined:
    Nov 3, 2013
    Messages:
    886
    Resources:
    0
    Resources:
    0
    Umm I'm no expert on custom melee AI, but isn't this like what the entire "hero" section is about when you make one?

    wc3 ai hero pick order.PNG
     
  8. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    Why don't you test it? That does not affect the default race AIs of the game.