Random hero Trigger Help

Reflexar

New Member
Reaction score
12
In my map i want an -ar mode which will give all players one random hero.

The problem is that some players will recieve the same hero.
So how can i make an allrandom mode that can only give 1 hero of the same type, like in dota.


Rep will be given if you help me =)
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
The way they do that is given them 1 by 1, not at the same time. The way to do this is using an array of heroes, then removing the randomed hero. After that, the next player is randomed.
 

xmkiller

New Member
Reaction score
6
Code:
Set Random
    Events
        Time - Elapsed game time is 0.10 seconds
    Conditions
    Actions
        Set numberHeroes = 4
        Set randomCount = 4
        Set heroArray[1] = Beserker
        Set heroArray[2] = Mercenary
        Set heroArray[3] = Necromancer
        Set heroArray[4] = Torch
        For each (Integer A) from 1 to 4, do (Actions)
            Loop - Actions
                Set randomData[(Integer A)] = (Integer A)


Code:
Random
    Events
    Conditions
    Actions
        Set tempPoint = (Position of Castle 0025 <gen>)
        For each (Integer A) from 1 to 4, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Player((Integer A))) slot status) Equal to Is playing
                    Then - Actions
                        Set randomHero = (Random integer number between 1 and randomCount)
                        Set tempGroup = (Units in heroSelect <gen> matching ((Unit-type of (Matching unit)) Equal to heroArray[randomData[randomHero]]))
                        Unit Group - Pick every unit in tempGroup and do (Actions)
                            Loop - Actions
                                Unit - Remove (Picked unit) from the game
                        Custom script:   call DestroyGroup (udg_tempGroup)
                        Unit - Create 1 heroArray[randomData[randomHero]] for (Player((Integer A))) at tempPoint facing Default building facing degrees
                        Selection - Select (Last created unit) for (Player((Integer A)))
                        Camera - Pan camera for (Player((Integer A))) to (Position of (Last created unit)) over 0.10 seconds
                        Unit - Remove Hero Select  from (Last created unit)
                        Game - Display to (All players) for 9.00 seconds the text: (((tempColor[(Player number of (Owner of (Last created unit)))] + ((Name of (Owner of (Last created unit))) + |r)) +  has randomed ) + ((|c008080ff + (Name of (Last created unit))) + |r.))
                        Hero - Create Ankh of Reincarnation and give it to (Last created unit)
                        Hero - Create Potion of Healing and give it to (Last created unit)
                        Set bt[(Player number of (Owner of (Last created unit)))] = (Last created unit)
                        Set pickingTorch[(Player number of (Player((Integer A))))] = True
                        Set randomData[randomHero] = randomCount
                        Set randomCount = (randomCount - 1)
                    Else - Actions
        Wait 0.80 seconds
        Custom script:   call RemoveLocation (udg_tempPoint)
        Trigger - Turn off (This trigger)

This is what I use.

If anything confuses you feel free to ask.
 

Reflexar

New Member
Reaction score
12
So this can't give the same hero to two players ?

EDIT: If you can please write down that type of variables that is used in this trigger I'll "copy" this an then +rep u
 

xmkiller

New Member
Reaction score
6
numberHeroes INT = total number of heroes your map has
randomCount INT = number of heroes left
heroArray UNIT(array) = holds your heroes
randomData INT(array) = makes sure you don't pick same hero twice

All the other variables are related to my map so don't worrie about them.
 

Reflexar

New Member
Reaction score
12
This does not work. Please tell me what's wrong (it gives no hero at all)

Code:
Melee Initialization
    Events
        Map initialization
    Conditions
    Actions
        Set NumberHeroes = 4
        Set RandomCount = 4
        Set HeroArray[1] = Paladin
        Set HeroArray[2] = Blood Mage
        Set HeroArray[3] = Mountain King
        Set HeroArray[4] = Archmage
        For each (Integer A) from 1 to 4, do (Actions)
            Loop - Actions
                Set RandomData[(Integer A)] = (Integer A)

Code:
All Random
    Events
        Player - Player 1 (Red) types a chat message containing -ar as An exact match
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Player((Integer A))) controller) Equal to User
                    Then - Actions
                        Set NumberHeroes = (Random integer number between 1 and RandomCount)
                        Unit - Create 1 HeroArray[RandomData[NumberHeroes]] for (Picked player) at ((Picked player) start location) facing Default building facing degrees
                        Set RandomData[NumberHeroes] = RandomCount
                        Set RandomCount = (RandomCount - 1)
                    Else - Actions

Please tell me what's wrong xmkiller :p

Sry double post =(
 

DrEvil

FCRI Associate!
Reaction score
111
wrong

This does not work. Please tell me what's wrong (it gives no hero at all)

Code:
Melee Initialization
    Events
        Map initialization
    Conditions
    Actions
        Set NumberHeroes = 4
        Set RandomCount = 4
        Set HeroArray[1] = Paladin
        Set HeroArray[2] = Blood Mage
        Set HeroArray[3] = Mountain King
        Set HeroArray[4] = Archmage
        For each (Integer A) from 1 to 4, do (Actions)
            Loop - Actions
                Set RandomData[(Integer A)] = (Integer A)

Code:
All Random
    Events
        Player - Player 1 (Red) types a chat message containing -ar as An exact match
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Player((Integer A))) controller) Equal to User
                    Then - Actions
                        Set NumberHeroes = (Random integer number between 1 and RandomCount)
                        Unit - Create 1 HeroArray[RandomData[NumberHeroes]] for [B](Picked player) at ((Picked player) start location)[/B] facing Default building facing degrees
                        Set RandomData[NumberHeroes] = RandomCount
                        Set RandomCount = (RandomCount - 1)
                    Else - Actions

Sry double post =(

There is no picked player
its player(integer A)
 

Reflexar

New Member
Reaction score
12
They can still get the same hero ! =/
Edit:
Lol fixed testing settings now it works :p

And btw, it freezes for like 2 sec when i type -Ar.

How can i make so that they'll recieve the hero one by one?
first p1 then p2 then p3.......
 

DrEvil

FCRI Associate!
Reaction score
111
Hey xmkiller

I tested your system in my map but some computers get the same hero as me

What is wrong?

I did exactly as you said .

How does it work all in all ?
 

Reflexar

New Member
Reaction score
12
I tested your system in my map but some computers get the same hero as me

Yeh i noticed that 2 computers gets the same hero :S

here's the code:

Code:
All Random
    Events
        Player - Player 1 (Red) types a chat message containing -ar as An exact match
    Conditions
    Actions
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Player((Integer A))) controller) Equal to User
                        ((Player((Integer A))) slot status) Equal to Is playing
                    Then - Actions
                        Set NumberHeroes = (Random integer number between 1 and RandomCount)
                        Unit - Create 1 HeroArray[RandomData[NumberHeroes]] for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees
                        Game - Display to (All enemies of (Player((Integer A)))) for 20.00 seconds the text: (Temp_Colour[(Integer A)] + (((Name of (Player((Integer A)))) + |r) + ( Has Randomed  + (Name of (Last created unit)))))
                        Set RandomData[NumberHeroes] = RandomCount
                        Set RandomCount = (RandomCount - 1)
                        Wait 0.50 seconds
                    Else - Actions

Code:
Init All Random
    Events
        Map initialization
    Conditions
    Actions
        Set NumberHeroes = 10
        Set RandomCount = 10
        Set HeroArray[1] = Paladin
        Set HeroArray[2] = Archmage
        Set HeroArray[3] = Mountain King
        Set HeroArray[4] = Blood Mage
        Set HeroArray[5] = Blademaster
        Set HeroArray[6] = Far Seer
        Set HeroArray[7] = Tauren Chieftain
        Set HeroArray[8] = Shadow Hunter
        Set HeroArray[9] = Death Knight
        Set HeroArray[10] = Lich
        For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Set RandomData[(Integer A)] = (Integer A)
 

The Helper

Necromancy Power over 9000
Staff member
Reaction score
1,701
Need more help with this? Check out The Hive Workshop!

#1 Warcraft 3 Reforged Modding Community
The Hive Workshop is the largest Warcraft III community since 2004 with over 100k users, centered around map making, modeling, custom games, programming & art.

www.hiveworkshop.com


That is the absolute BEST resource for Warcraft 3 World Editor Help in 2023 and beyond. Everyone that was here is there.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top