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
  • No one is chatting at the moment.

      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