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

Status
Not open for further replies.
Level 7
Joined
Feb 23, 2020
Messages
253
Why is this trigger not working?

Thanks in advance!

  • Selection
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Random Hero
    • Actions
      • Unit - Create 1 RandomHero[(Random integer number between 1 and HeroNumbers)] for (Owner of (Sold unit)) at (Center of Hero Respawn <gen>) facing Default building facing degrees
      • Unit - Remove (Sold unit) from the game
 
Level 12
Joined
Feb 5, 2018
Messages
521
Have you tried not removing the sold unit from the game?
The way I see it, if the unit is created it is instantly removed.
 
Level 12
Joined
Feb 5, 2018
Messages
521
Store unit-types at map initialization

  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ---This is where we store the available Heroes--- --------
      • -------- HeroType = Unit-Type Variable with IndexArray --------
      • Set VariableSet HeroType[1] = Paladin
      • Set VariableSet HeroType[2] = Archmage
      • Set VariableSet HeroType[3] = Mountain King
      • Set VariableSet HeroType[4] = Blood Mage
      • Set VariableSet HeroType[5] = Far Seer
      • Set VariableSet HeroType[6] = Warden
Random Hero Selection Trigger
  • Random Hero Selection
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to RandomHero
    • Actions
      • Unit - Create 1 HeroType[(Random integer number between 1 and 6)] for (Owner of (Buying unit)) at (Center of (Playable map area)) facing Default building facing degrees
Here it is better to use buying unit.
If player 1 red is the owner of buying unit, the hero will be created for him.
If player 2 blue is the owner of buying unit, the hero will be created for him.
And so on.

And the random integer number is always between 1 and MaxHeroTypes, so in this case it is 6.
Tested and this works. :)
Hope this helps!
 
Level 7
Joined
Feb 23, 2020
Messages
253
Store unit-types at map initialization

  • Map Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ---This is where we store the available Heroes--- --------
      • -------- HeroType = Unit-Type Variable with IndexArray --------
      • Set VariableSet HeroType[1] = Paladin
      • Set VariableSet HeroType[2] = Archmage
      • Set VariableSet HeroType[3] = Mountain King
      • Set VariableSet HeroType[4] = Blood Mage
      • Set VariableSet HeroType[5] = Far Seer
      • Set VariableSet HeroType[6] = Warden
Random Hero Selection Trigger
  • Random Hero Selection
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to RandomHero
    • Actions
      • Unit - Create 1 HeroType[(Random integer number between 1 and 6)] for (Owner of (Buying unit)) at (Center of (Playable map area)) facing Default building facing degrees
Here it is better to use buying unit.
If player 1 red is the owner of buying unit, the hero will be created for him.
If player 2 blue is the owner of buying unit, the hero will be created for him.
And so on.

And the random integer number is always between 1 and MaxHeroTypes, so in this case it is 6.
Tested and this works. :)
Hope this helps!

I dont get it... I've done the exact same thing, but still does not work, could it be because of the dummy? :(
Edit: Maybe i should note they should be picked from an altar?

  • wet
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet HeroType[1] = Paladin
      • Set VariableSet HeroType[2] = Archmage
      • Set VariableSet HeroType[3] = Mountain King
      • Set VariableSet HeroType[4] = Blood Mage
  • rth
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Random Hero
    • Actions
      • Unit - Create 1 HeroType[(Random integer number between 1 and 4)] for (Owner of (Buying unit)) at (Center of (Playable map area)) facing Default building facing degrees
 
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
521
I used a Mercenary Camp. Any neutral unit should do it.
You can then change the appearance of the unit to whatever in object editor.

The unit needs to be sold, not trained.
 
Level 7
Joined
Feb 23, 2020
Messages
253
I used a Mercenary Camp. Any neutral unit should do it.
You can then change the appearance of the unit to whatever in object editor.

The unit needs to be sold, not trained.
Aah, then that's the problem, is it necessary for it to be trained? Cause i tried to change the event and condition to trained unit but that did not work either

Edit: I made it work, thank god.

Thank you very much for your help! :)
 
Status
Not open for further replies.
Top