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

Making a random race button

Status
Not open for further replies.
Level 12
Joined
Dec 11, 2014
Messages
662
[Solved] Making a random race button

  • Checkpoints
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RandomRace[1] = (Units of type Castle)
      • Set RandomRace[2] = (Units of type Necropolis)
      • Set RandomRace[3] = (Units of type Temple Of Tides)
      • Set RandomRace[4] = (Units of type Tree Stump)
      • Set RandomRace[5] = (Units of type Altar Of Heroes)
      • Set RandomRace[6] = (Units of type Heaven Portal)
      • Set RandomRace[7] = (Units of type Poisoned Spring)
      • Set RandomRace[8] = (Units of type Tree Of Life)
      • Set RandomRace[9] = (Units of type Dragon Nest)
      • Set RandomRace[8] = (Units of type Stronghold)
  • RedRandom
    • Events
      • Unit - Race Market 0000 <gen> Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Random Race
    • Actions
      • Unit - Remove (Sold unit) from the game
      • Unit - Replace (Triggering unit) with a (Unit-type of (Random unit from RandomRace[(Random integer number between 1 and 8)])) using The old unit's relative life and mana
When I press on the button the main building disappears... Why?
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
At map initialization you create a unit group consisting of certain unit-types in game (e.g. unit group 8 consists of all Tree of Life in game). If said unit-type is not in game or is removed, the second trigger will refer to Unit-type of (No unit), returning null. So you replace your building with no unit, making it just disappear.

This is really a bad way to do what you want imo. Not only does the "units of type X" action in unit group permanently leak, but you also create unit grous for no reason. What you need instead is to change "RandomRace" array from Unit Group to Unit-type.
 
Level 12
Joined
Dec 11, 2014
Messages
662
Thanks. I changed it, now it works.

  • RedRandom
    • Events
      • Unit - Race Market 0000 <gen> Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Random race
    • Actions
      • Unit - Remove (Sold unit) from the game
      • Unit - Replace (Triggering unit) with a RandomRace[(Random integer number between 1 and 11)] using The old unit's relative life and mana
      • Selection - Select (Last replaced unit) for Player 1 (Red)
  • Checkpoints
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RandomRace[1] = Castle
      • Set RandomRace[2] = Necropolis
      • Set RandomRace[3] = Temple Of Tides
      • Set RandomRace[4] = Tree Stump
      • Set RandomRace[5] = Animal Fury
      • Set RandomRace[6] = Altar Of Heroes
      • Set RandomRace[7] = Heaven Portal
      • Set RandomRace[8] = Tree Of Life
      • Set RandomRace[9] = Dragon Nest
      • Set RandomRace[10] = Stronghold
      • Set RandomRace[11] = Poisoned Spring
Any better ways to do it?
 
Level 12
Joined
Dec 11, 2014
Messages
662
Small problem. When I click on the Random Race icon, it replaced it randomly (which is working fine) ,the problem is there is still the Random icon in the new building, which, when clicked just disappears. Why?
Just tried again: this time it worked the second time ,giving me another building, weird.
 
Last edited:
Status
Not open for further replies.
Top