how du make this random system

D

dunpealx4

Guest
Code:
Setup Random Heros
    Events
        Map initialization
    Conditions
    Actions
        -------- Melee Init --------
        Melee Game - Use melee time of day (for all players)
        Melee Game - Limit Heroes to 1 per Hero-type (for all players)
        -------- Set up Random Hero Array --------
        Set RANDOM_HERO_ARRAY[1] = Paladin
        Set RANDOM_HERO_ARRAY[2] = Archmage
        Set RANDOM_HERO_ARRAY[3] = Mountain King
        Set RANDOM_HERO_ARRAY[4] = Blood Mage
        Set RANDOM_HERO_ARRAY[5] = Blademaster
        Set RANDOM_HERO_ARRAY[6] = Far Seer
        Set RANDOM_HERO_ARRAY[7] = Tauren Chieftan
        Set RANDOM_HERO_ARRAY[8] = Shadow Hunter
        Set RANDOM_HERO_ARRAY[9] = Death Knight
        Set RANDOM_HERO_ARRAY[10] = Lich
        Set RANDOM_HERO_ARRAY[11] = Dread Lord
        Set RANDOM_HERO_ARRAY[12] = Crypt Lord
        Set RANDOM_HERO_ARRAY[13] = Keeper of the Grove
        Set RANDOM_HERO_ARRAY[14] = Priestess of the Moon
        Set RANDOM_HERO_ARRAY[15] = Demon Hunter
        Set RANDOM_HERO_ARRAY[16] = Warden
        Set NUM_HEROES = 16

Code:
Random Hero
    Events
        Unit - A unit Sells a unit
    Conditions
        (Unit-type of (Sold unit)) Equal to [COLOR="Red"]Random Hero[/COLOR]
    Actions
        Unit - Create 1 RANDOM_HERO_ARRAY[(Random integer number between 1 and NUM_HEROES)] for (Owner of (Sold unit)) at ((Owner of (Sold unit)) start location) facing Default building facing degrees
        Unit - Remove (Sold unit) from the game

the red font, random hero, is a dummy unit(based unit is peasant).

this basic random system allow player to get a randomed hero, but player can have duplicated hero. how can i make a random system that once the hero has been picked(either by random or manual pick), other player can no longer get that hero? for instant, if i pick random and i got paladin, i want the paladin disappears on the tavern so other player cant pick him. also, no matter how many times a player picks random, he will not get a paladin. how can i do that? any hints?
 

Somatic

You can change this now in User CP.
Reaction score
84
Ok, Easy, Before creating the unit, Create another integer variable. Then assign a random number to it, give the player the "Random_Hero_ARRAY[Random_Var]"
Then Set
"Random_HERO_ARRAY[Random_Var]" to No unit
 

Darkchaoself

What is this i dont even
Reaction score
106
Well for random do
Code:
 Set RandomInteger= Random Number between 1 and 16
                Create one Random_hero_Array[RandomInteger] for (Owner of (Sold unit)) at ((Owner of (Sold unit)) start location) facing Default building facing degrees

Ahh, Somatic beat me.
 
D

dunpealx4

Guest
thanks ok, now i changed to this,

Code:
Setup Random Heros
    Events
        Map initialization
    Conditions
    Actions
        -------- Melee Init --------
        Melee Game - Use melee time of day (for all players)
        Melee Game - Limit Heroes to 1 per Hero-type (for all players)
        -------- Set up Random Hero Array --------
        Set RANDOM_HERO_ARRAY[1] = Paladin
        Set RANDOM_HERO_ARRAY[2] = Archmage
        Set RANDOM_HERO_ARRAY[3] = Mountain King
        Set RANDOM_HERO_ARRAY[4] = Blood Mage
        Set RANDOM_HERO_ARRAY[5] = Blademaster
        Set RANDOM_HERO_ARRAY[6] = Far Seer
        Set RANDOM_HERO_ARRAY[7] = Tauren Chieftan
        Set RANDOM_HERO_ARRAY[8] = Shadow Hunter
        Set RANDOM_HERO_ARRAY[9] = Death Knight
        Set RANDOM_HERO_ARRAY[10] = Lich
        Set RANDOM_HERO_ARRAY[11] = Dread Lord
        Set RANDOM_HERO_ARRAY[12] = Crypt Lord
        Set RANDOM_HERO_ARRAY[13] = Keeper of the Grove
        Set RANDOM_HERO_ARRAY[14] = Priestess of the Moon
        Set RANDOM_HERO_ARRAY[15] = Demon Hunter
        Set RANDOM_HERO_ARRAY[16] = Warden
        Set randominteger = (Random integer number between 1 and 16)

Code:
Random Hero
    Events
        Unit - A unit Sells a unit
    Conditions
        (Unit-type of (Sold unit)) Equal to Random Hero
    Actions
        Unit - Create 1 RANDOM_HERO_ARRAY[randominteger] for (Owner of (Sold unit)) at ((Owner of (Sold unit)) start location) facing Default building facing degrees
        Unit - Remove (Sold unit) from the game

now is this correct? randominteger is a variable, variable type-integer, no array, initial value=0 default.

also, if i dont want paladin available on the tavern anymore. and by picking random will not get him either any more. should i add this trigger like below? or the trigger above alone is fine.

Code:
hero limit
    Events
        Unit - A unit Sells a unit
    Conditions
        ((Unit-type of (Sold unit)) is A Hero) Equal to True
        (Unit-type of (Sold unit)) Equal to Paladin [COLOR="Red"]and so on[/COLOR].
    Actions
        Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Player - Make Paladin Unavailable for training/construction by (Picked player)
 

Somatic

You can change this now in User CP.
Reaction score
84
Yar, That will work to prevent any more Paladin from training.
 
D

dunpealx4

Guest
Code:
Setup Random Heros
    Events
        Map initialization
    Conditions
    Actions
        -------- Melee Init --------
        Melee Game - Use melee time of day (for all players)
        Melee Game - Limit Heroes to 1 per Hero-type (for all players)
        -------- Set up Random Hero Array --------
        Set RANDOM_HERO_ARRAY[1] = Paladin
        Set RANDOM_HERO_ARRAY[2] = Archmage
        Set RANDOM_HERO_ARRAY[3] = Mountain King
        Set RANDOM_HERO_ARRAY[4] = Blood Mage
        Set RANDOM_HERO_ARRAY[5] = Blademaster
        Set RANDOM_HERO_ARRAY[6] = Far Seer
        Set RANDOM_HERO_ARRAY[7] = Tauren Chieftan
        Set RANDOM_HERO_ARRAY[8] = Shadow Hunter
        Set RANDOM_HERO_ARRAY[9] = Death Knight
        Set RANDOM_HERO_ARRAY[10] = Lich
        Set RANDOM_HERO_ARRAY[11] = Dread Lord
        Set RANDOM_HERO_ARRAY[12] = Crypt Lord
        Set RANDOM_HERO_ARRAY[13] = Keeper of the Grove
        Set RANDOM_HERO_ARRAY[14] = Priestess of the Moon
        Set RANDOM_HERO_ARRAY[15] = Demon Hunter
        Set RANDOM_HERO_ARRAY[16] = Warden
        Set randominteger = (Random integer number between 1 and 16)

Code:
Random Hero
    Events
        Unit - A unit Sells a unit
    Conditions
        (Unit-type of (Sold unit)) Equal to Random Hero
    Actions
        Unit - Create 1 RANDOM_HERO_ARRAY[randominteger] for (Owner of (Sold unit)) at ((Owner of (Sold unit)) start location) facing Default building facing degrees
        Unit - Remove (Sold unit) from the game

Code:
hero limit
    Events
        Unit - A unit Sells a unit
    Conditions
        ((Unit-type of (Sold unit)) is A Hero) Equal to True
        Or - Any (Conditions) are true
            Conditions
                (Unit-type of (Sold unit)) Equal to Zeus
                (Unit-type of (Sold unit)) Equal to Paladin
                (Unit-type of (Sold unit)) Equal to Mountain King
                (Unit-type of (Sold unit)) Equal to Archmage
                (Unit-type of (Sold unit)) Equal to Blademaster
                (Unit-type of (Sold unit)) Equal to Far Seer
                (Unit-type of (Sold unit)) Equal to Tauren Chieftan
                (Unit-type of (Sold unit)) Equal to Shadow Hunter
                (Unit-type of (Sold unit)) Equal to Death Knight
                (Unit-type of (Sold unit)) Equal to Lich
                (Unit-type of (Sold unit)) Equal to Dread Lord
                (Unit-type of (Sold unit)) Equal to Blood Mage
                (Unit-type of (Sold unit)) Equal to Keeper of the Grove
                (Unit-type of (Sold unit)) Equal to Priestess of the Moon
                (Unit-type of (Sold unit)) Equal to Crypt Lord
                (Unit-type of (Sold unit)) Equal to Demon Hunter
                (Unit-type of (Sold unit)) Equal to Warden (frenzy)
    Actions
        Neutral Building - Remove (Unit-type of (Sold unit)) from (Selling unit)
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Picked player)

well, this is what i did. for hero limit, it works fine. if you pick a hero, that hero is gone from the tavern. but for the random system. it doesnt work. let say i pick random and got paladin, paladin is still for sale on the tavern. Also, everytime i press random hero, i get the same hero over and over. if i press it 10 times, i get 10 same heroes. what did i miss?
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Code:
Random Hero
    Events
        Unit - A unit Sells a unit
    Conditions
        (Unit-type of (Sold unit)) Equal to Random Hero
    Actions
        Unit - Create 1 RANDOM_HERO_ARRAY[random integer  from 1 to 16] for (Owner of (Sold unit)) at ((Owner of (Sold unit)) start location) facing Default building facing degrees
        Unit - Remove (Sold unit) from the game

Change it to this. What you have done is setting the varaible randominteger to a random number once. From that moment on it stood the same all the time. Also, delete the varaible randominteger. You dont need it anymore.
 
E

errik

Guest
Im trying to make the program create random units with aid from your codes here. But it really doesnt work. Feels like it's the randomfunction in world edit thats wrong.

I just became member on this site for this now so i dont know how to insert code in that fancy way you guys do, but here it is anyway :p
maybe you could see whats wrong with it...

-----

Code:
Random
    Events
        Map initialization
    Conditions
    Actions
        Set Random_Monster_Array[1] = Rat (lvl 1)
        Set Random_Monster_Array[2] = Big Rat (lvl 2)
        Set Random_Monster_Array[3] = Skeleton Warrior (lvl 3)
        Set Random_Monster_Array[4] = Skeleton Archer (lvl 3)
        Set Random_Monster_Array[5] = Skeleton Mage (lvl 3)
        Set Random_Monster_Array[6] = Outlaw Wizard (lvl 3)
        Set Random_Monster_Array[7] = Ghost

Code:
    Events
        Unit - A unit enters spawn2 <gen>
    Conditions
    Actions
        Set RandomInteger = (Random integer number between 1 and 7)
        Unit - Create 1 Random_Monster_Array[RandomInteger] for Player 1 (Red) at (Center of spawn2 <gen>) facing Default building facing degrees
        Trigger - Turn off (This trigger)
-----

What happens is that every time I test the map it always spawns a Skeleton Archer. If I remove the last Action "Trigger - Turn off (This trigger)". It spawns an Archer the first time, but seems to be working every time after that.

Any ideas? :]
 

rax_7

New Member
Reaction score
1
if you read what serius saids, you need to remove the randominteger. so you make the trigger like this

Unit - Create 1 Random_Monster_Array[Random number between 1 and 7] for Player 1 (Red) at (Center of spawn2 <gen>)

but some odd reason, i did test dunpeal's trigger, i did what serius told you. but i still get duplicated hero.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> it always spawns a ...

Using "test map"?

If yes:
Menu: File / Preferences / Test map, uncheck "fixed random seed".


To prevent duplicates, you need to remove those that are already taken from your array.
 
E

errik

Guest
ACEHEART!
thank you very much!
it works now =) thanks thanks thanks :p
 

rax_7

New Member
Reaction score
1
"To prevent duplicates, you need to remove those that are already taken from your array."

i always wonder how you can make a trigger like that. you dont have to make the full triggerm but can you show me how?

also, Using "test map"?

If yes:
Menu: File / Preferences / Test map, uncheck "fixed random seed".

is this only work on testing map? what happen in a real game?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Set Array[1] = Hero 1
Set Array[2] = Hero 2
Set Array[3] = Hero 3
Set Array[4] = Hero 4
Set HeroCount = 4


When you need one:
Set TempInteger = Random between 1 and HeroCount
Unit - Create 1 array[TempInteger] for <someone> at <somewhere>

The magic removal part:
Set Array[TempInteger] = Array[HeroCount]
Set HeroCount = HeroCount - 1



As for that "random seed", it only "works" with "test map".
The idea is to be able to perfectly repeat some "random" events while testing...
Or so I guess.
Either way, when playing your map normally, or on bnet, the "seed" is always random.

On a related note:
If random fails to meet your expectations, it is random indeed.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top