1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Making a random race button

Discussion in 'World Editor Help Zone' started by DaneTheBeast, Oct 10, 2015.

  1. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    [Solved] Making a random race button

    Triggers
    • 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: Oct 24, 2015
  2. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    2,004
    Resources:
    0
    Resources:
    0
    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.
     
  3. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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?
     
  4. Nichilus

    Nichilus

    Joined:
    Sep 26, 2009
    Messages:
    2,004
    Resources:
    0
    Resources:
    0
    I don't think so.
     
  5. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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: Oct 10, 2015
  6. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,638
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Do you use spellbooks?
     
  7. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    No, the button is in a building. It has 11 different Upgrades, and one Random Race button. When I use the upgrades, the button stays there, allowing 2 different builders
     
  8. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    608
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Last edited: Oct 24, 2015