Announcement

Collapse
No announcement yet.

Use Recommended Player Count [Mutator]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Use Recommended Player Count [Mutator]

    Original Thread Request:
    • Request for a mutator that restricts the min/ max player counts to those set by the level designer (Use Map Bot Count)
    • As featured in UT2003/UT2004
    • Click image for larger version

Name:	BotsToMapDefault.jpg
Views:	1
Size:	95.0 KB
ID:	3253888
    • Set Ai/ Bot number to the default Map number, or Set Roster
    • For online purposes this would be good if it capped and sent additional players to spectate.


    • Preferably to be done by someone capable
    • Where should i start looking for the code for this?


    Reason:
    • I think it is important to adhere to the player count recommended by the level designer.
    • The Previous Unreal Tournament games had this feature and it makes a really big difference.
    • Personally i like to adhere strictly to this default number, i am aware not many other people do. Maybe this would/ would have helped.



    Mutator:
    • Post #2here for Mutator/ Source (see below)


    Thanks


    Credits to RattleSN4K3

    #2
    Start your game with the following option (command line):
    Code:
    ?bAutoNumBots=1
    Also to mention, if you start a game without the NumPlay option, it will also use the recommended player count.
    Another thing, AutoNumBots does not work if VsBots or NumPlay is set.

    If you would need a mutator, just begin with this:

    Code:
    // RecommendedPlayersMutator.uc
    // Description: Mutator which sets the desired player count to the value which is given by each map for Min- and Max-Player
    //              If players join after the player count is already reached, they will be switched to spectator automatically
    //
    // Credits: RattleSN4K3
    
    class RecommendedPlayersMutator extends UTMutator;
    
    var bool bAutoNumBotsSet;
    var int MapPlayerCount;
    
    function bool AllowBecomeActivePlayer(PlayerController P)
    {
        local bool ret;
        local int playercount;
    
        // Always call super.
        // If we don't call the super, AllowBecomeActivePlayer will not get called
        // for other mutators. Some mutators rely and this call
        ret = super.AllowBecomeActivePlayer(P);
    
        // Get total player count including travelling players
        playercount = WorldInfo.Game.GetNumPlayers(); // + WorldInfo.Game.NumBots;
    
        // only check if the map player count is already set
        // this might be the case for the initial listen server player
        if (bAutoNumBotsSet && playercount >= MapPlayerCount)
        {
            return false;
        }
        
        return ret;
    }
    
    
    function ModifyLogin(out string Portal, out string Options)
    {
        local int playercount;
    
        // Get total player count including travelling players
        playercount = WorldInfo.Game.GetNumPlayers();// + WorldInfo.Game.NumBots;
        
        // check if the player can only join spectator at the moment
        if (bAutoNumBotsSet && playercount >= MapPlayerCount)
        {
            // remove any forced specatator flag as user might join by "SpectatorOnly=0", which could be a exploit
            class'UTGame'.static.RemoveOption(Options, "SpectatorOnly");
    
            // add back the forced "SpectorOnly" flag
            Options $= "?SpectatorOnly=1";
        }
    
        super.ModifyLogin(Portal, Options);
    }
    
    
    function NotifyLogin(Controller NewPlayer)
    {
        local UTGame UTG;
        super.NotifyLogin(NewPlayer);
    
        UTG = UTGame(WorldInfo.Game);
        if (!bAutoNumBotsSet && UTG != none)
        {
            // only process once
            bAutoNumBotsSet = true;
    
            // remove options which might get in conflict with the workflow
            UTG.RemoveOption(WorldInfo.Game.ServerOptions, "NumPlay");
            UTG.RemoveOption(WorldInfo.Game.ServerOptions, "bAutoNumBots");
    
            // Add back the postive-value for the Auto-num-bots flag
            UTG.ServerOptions $= "?bAutoNumBots=1";
    
            // Update the desired player count which adds bots in the next timer event
            MapPlayerCount = UTG.LevelRecommendedPlayers(); // defaults to 1
            UTG.DesiredPlayerCount = MapPlayerCount;
        }
    }

    Comment


      #3
      Legend. Thank you for that. i had a look through the ut2003 code but couldn't find anything like this..
      i will see if i can make a slider for it and a UI Scene, that might be nice.

      • would you care to discuss your thoughts on this aspect of keeping the player count to the recommended count? (thinking about the new UT )
      • For me it's extremely important from both a gameplay and a level design aspect, it really makes a difference playing the UT Ladders with the correct player count.



      p.s. i compiled it and it does indeed work beautifully.

      Comment


        #4
        Originally posted by TKBS View Post
        would you care to discuss your thoughts on this aspect of keeping the player count to the recommended count? (thinking about the new UT )
        Should be takin into account for instant action games (singleplayer, bot matches). Restricting players from player if a desired player number is exceeded is a bad idea.

        Comment

        Working...
        X