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

How to make original AI choose a specific first hero?

Status
Not open for further replies.
Level 1
Joined
Jun 29, 2019
Messages
2
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)?
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
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 ---------
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
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.
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
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).
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.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
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.
 

Attachments

  • AI Hero Train.w3x
    39.4 KB · Views: 85
Level 12
Joined
Jun 15, 2016
Messages
472
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:

JASS:
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.
 
Level 12
Joined
Nov 3, 2013
Messages
989
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
 
Status
Not open for further replies.
Top