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,697
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.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top