How to make shuffle players?

Exide

I am amazingly focused right now!
Reaction score
448
Just move their units to the other side of the map, and change their alliances - so that their former friends become their foes, and the other way around.
Can't give you a trigger, since I don't know what your map looks like.
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Wait do you mean in the lobby or
when ingame (either at map init or some other time straight after map loaded)?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I want my map to have a shuffle players feature. Any ideas?

Well it depends on what a "shuffle players feature" is.

It could be that you add random players to two player groups, until there are none left to be shuffled, or it could be that your players all start off in random locations. You may want to explain a bit more here..
 

nardretor

New Member
Reaction score
6
Just like in DotA...

If Player 1 types (string), players of both teams will be shuffled...

My map has no big difference with dota... Taverns sell heroes... Circle of Power buys heroes... Both teams are the same... When you buy a hero, it will move instantly to the shops. If I used the shuffle players, will the triggers that moves heroes instantly from one region to another be randomed too? Because my triggers are..
-Hero owned by player 1, 2, 3, 4, 5 move instantly to <region>
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
Best way to do this would be to create to forces, force 1 and 2 then make a loop that based on a random number between 1 and 2 moves them to force 1 or 2. Then take all the members of force move them to base 1 and change them to treat each other as allies and force 2 as enemies. Do the same with force 2.
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
This trigger shuffles players in 2 equal teams (or as equal as possible, in case of uneven teams)

Trigger:
  • ShufflePlayers
    • Events
      • Player - Player 1 (Red) types a chat message containing -sp as An exact match
    • Conditions
    • Actions
      • Set ToShuffle = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
      • Set NumberOfPlayersPerTeam = ((Number of players in ToShuffle) / 2)
      • Player Group - Pick every player in ToShuffle and do (Actions)
        • Loop - Actions
          • Set ShuffleTeam = (Random integer number between 1 and 2)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ShuffleTeam Equal to 1
                  • (Number of players in ShuffleTeam2) Equal to NumberOfPlayersPerTeam
            • Then - Actions
              • Player Group - Add (Picked player) to ShuffleTeam1
              • Player Group - Remove (Picked player) from ToShuffle
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • ShuffleTeam Equal to 2
                  • (Number of players in ShuffleTeam1) Equal to NumberOfPlayersPerTeam
            • Then - Actions
              • Player Group - Add (Picked player) to ShuffleTeam2
              • Player Group - Remove (Picked player) from ToShuffle
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Number of players in ToShuffle) Greater than or equal to 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ShuffleTeam Equal to 1
                • Then - Actions
                  • Player Group - Add (Picked player) to ShuffleTeam1
                  • Player Group - Remove (Picked player) from ToShuffle
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ShuffleTeam Equal to 2
                • Then - Actions
                  • Player Group - Add (Picked player) to ShuffleTeam2
                  • Player Group - Remove (Picked player) from ToShuffle
                • Else - Actions
              • Player Group - Add (Picked player) to ShuffleTeam2
            • Else - Actions

Alternatively, if you don't feel like/don't know how to do this trigger, you can just copy this into your map:
(I know its converted GUI, didn't feel like making it complicated.....)

JASS:
function Trig_ShufflePlayers_Func002002001001 takes nothing returns boolean
    return ( GetPlayerController(GetFilterPlayer()) == MAP_CONTROL_USER )
endfunction

function Trig_ShufflePlayers_Func002002001002 takes nothing returns boolean
    return ( GetPlayerSlotState(GetFilterPlayer()) == PLAYER_SLOT_STATE_PLAYING )
endfunction

function Trig_ShufflePlayers_Func002002001 takes nothing returns boolean
    return GetBooleanAnd( Trig_ShufflePlayers_Func002002001001(), Trig_ShufflePlayers_Func002002001002() )
endfunction

function Trig_ShufflePlayers_Func004Func002Func003C takes nothing returns boolean
    if ( ( udg_ShuffleTeam == 1 ) ) then
        return true
    endif
    if ( ( CountPlayersInForceBJ(udg_ShuffleTeam2) == udg_NumberOfPlayersPerTeam ) ) then
        return true
    endif
    return false
endfunction

function Trig_ShufflePlayers_Func004Func002C takes nothing returns boolean
    if ( not Trig_ShufflePlayers_Func004Func002Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_ShufflePlayers_Func004Func003Func003C takes nothing returns boolean
    if ( ( udg_ShuffleTeam == 2 ) ) then
        return true
    endif
    if ( ( CountPlayersInForceBJ(udg_ShuffleTeam1) == udg_NumberOfPlayersPerTeam ) ) then
        return true
    endif
    return false
endfunction

function Trig_ShufflePlayers_Func004Func003C takes nothing returns boolean
    if ( not Trig_ShufflePlayers_Func004Func003Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_ShufflePlayers_Func004Func004Func001Func003C takes nothing returns boolean
    if ( ( udg_ShuffleTeam == 1 ) ) then
        return true
    endif
    return false
endfunction

function Trig_ShufflePlayers_Func004Func004Func001C takes nothing returns boolean
    if ( not Trig_ShufflePlayers_Func004Func004Func001Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_ShufflePlayers_Func004Func004Func002Func003C takes nothing returns boolean
    if ( ( udg_ShuffleTeam == 2 ) ) then
        return true
    endif
    return false
endfunction

function Trig_ShufflePlayers_Func004Func004Func002C takes nothing returns boolean
    if ( not Trig_ShufflePlayers_Func004Func004Func002Func003C() ) then
        return false
    endif
    return true
endfunction

function Trig_ShufflePlayers_Func004Func004Func004C takes nothing returns boolean
    if ( ( CountPlayersInForceBJ(udg_ToShuffle) &gt;= 1 ) ) then
        return true
    endif
    return false
endfunction

function Trig_ShufflePlayers_Func004Func004C takes nothing returns boolean
    if ( not Trig_ShufflePlayers_Func004Func004Func004C() ) then
        return false
    endif
    return true
endfunction

function Trig_ShufflePlayers_Func004A takes nothing returns nothing
    set udg_ShuffleTeam = GetRandomInt(1, 2)
    if ( Trig_ShufflePlayers_Func004Func002C() ) then
        call ForceAddPlayerSimple( GetEnumPlayer(), udg_ShuffleTeam1 )
        call ForceRemovePlayerSimple( GetEnumPlayer(), udg_ToShuffle )
    else
    endif
    if ( Trig_ShufflePlayers_Func004Func003C() ) then
        call ForceAddPlayerSimple( GetEnumPlayer(), udg_ShuffleTeam2 )
        call ForceRemovePlayerSimple( GetEnumPlayer(), udg_ToShuffle )
    else
    endif
    if ( Trig_ShufflePlayers_Func004Func004C() ) then
        if ( Trig_ShufflePlayers_Func004Func004Func001C() ) then
            call ForceAddPlayerSimple( GetEnumPlayer(), udg_ShuffleTeam1 )
            call ForceRemovePlayerSimple( GetEnumPlayer(), udg_ToShuffle )
        else
        endif
        if ( Trig_ShufflePlayers_Func004Func004Func002C() ) then
            call ForceAddPlayerSimple( GetEnumPlayer(), udg_ShuffleTeam2 )
            call ForceRemovePlayerSimple( GetEnumPlayer(), udg_ToShuffle )
        else
        endif
        call ForceAddPlayerSimple( GetEnumPlayer(), udg_ShuffleTeam2 )
    else
    endif
endfunction

function Trig_ShufflePlayers_Actions takes nothing returns nothing
    set udg_ToShuffle = GetPlayersMatching(Condition(function Trig_ShufflePlayers_Func002002001))
    set udg_NumberOfPlayersPerTeam = ( CountPlayersInForceBJ(udg_ToShuffle) / 2 )
    call ForForce( udg_ToShuffle, function Trig_ShufflePlayers_Func004A )
endfunction

//===========================================================================
function InitTrig_ShufflePlayers takes nothing returns nothing
    set gg_trg_ShufflePlayers = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_ShufflePlayers, Player(0), &quot;-sp&quot;, true )
    call TriggerAddAction( gg_trg_ShufflePlayers, function Trig_ShufflePlayers_Actions )
endfunction
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
NumberOfPlayersPerTeam - Integer
ShuffleTeam - Integer
ShuffleTeam1 - Player Group
ShuffleTeam2 - Player Group (you can use an array too :p)
ToShuffle - Player Group

---
Also I forgot, that trigger i posted only splits the players into 2 group
Add alliance actions after to make it work ^^
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Amazingly long...

Here's a shorter version:
Code:
Set Players = All players matching (((Matching player) slot status) equal to Is playing) and (((Matching player) controller) equal to User) (or whatever players you need here)
Player group - Clear Teams[1]
Player group - Clear Teams[2]
Set CurrentTeam = 1
For each Integer A from 1 to (Number of players in Players) and do
    Set Player = Random player from Players
    Player group - Add Player to Teams[CurrentTeam]
    Player group - Remove Player from Players
    Set CurrentTeam = 3 - CurrentTeam

Players: variable of type player group
Teams: variable of type player group, with a check in array,
CurrentTeam: of type integer
Player: of type player
 

velnias

New Member
Reaction score
13
stop double posting, edit ur last post..

yes it will work.
just add event player red display -sp
 
General chit-chat
Help Users
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top