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

Random Hero for AI

Status
Not open for further replies.
Level 3
Joined
Feb 18, 2017
Messages
31
Hey guys its me again,

i have some trouble with my AI trigger's. I couldnt find a way to give my AI controlled player's a random hero.

Altough i tried a few things.

For example: i made a unit-type variable and let the computer select with a random integer. This had 2 problems: the computer always selected the same unit and i could select the same hero. I didnt know how to remove it from the tavern or remove the hero that the AI picked from the tavern.

I tried some crazy stuff with region but that was way too crazy to handle.

I also could not find a tutorial that would explain what i need. THe tutorials i find were about picking random heroes for all players and so on.

I basicly need a trigger that picks a random hero for AI and then blocks the hero for other players and the other way around. So that AI doesnt pick the hero i just picked.

I would be very glad if someone could help me with this.
 
Level 3
Joined
Feb 18, 2017
Messages
31
At this point i have 13 different heroes but the computer should only select from 4 different heroes if that is what you mean.
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
This had 2 problems: the computer always selected the same unit and i could select the same hero.

This is the way to go. There is a function to disable/remove heroes from a tavern. I dont know the name however so you need to search for it.

He always gets the same hero because thats how the random number generator works. It burns random numbers and gets new ones whenever you do specific things. So when you test the map in world editor, you basically do the same thing every time and the random number will always be the same. When you try your map in warcraft, your random number generator will work fine and give you a random hero everytime.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
I'm not sure yet if this is exactly what you want.
  • Trigger limit hero
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • Player - Limit training of Heroes to 1 for (Owner of (Sold unit))
      • Player - Limit training of (Unit-type of (Sold unit)) to 0 for Player 12 (Brown)
the Neutral Building - Remove unit-type from player doesn't seem to be working, at least on heroes, so I used this, the first action limits the heroes for the player who bought it, the second makes the other player not able to buy that hero, assuming that "player 12" is the computer AI, you can change that however you like.
 
Status
Not open for further replies.
Top