Simple Mod: Resource Tickrate Scale based off Teamsize Ratios

ZdrytchXZdrytchX Australia Join Date: 2016-02-06 Member: 212662Members
edited January 2017 in Modding
Since I doubt UWE will actually be spitting out a patch anytime soon, nor do I think that the suggestion thread that they suggested me to make, has actually done anything so I just made a mod for it so server owners can utilise it.

Hex ID: 3280FEC5
Steam Page

copy/paste details:

This is a very simple patch for servers that scales the tickrate based off the ratio of the number of players on each team.

Example:
A team of 14 players vs a team of 10 players, with NS2's default 6 second wait period per tick, will receive one resource point per resource tower every 7 seconds, while the smaller team will only have to wait 5 seconds.

This means the smaller team, which generally happens to be smaller when they are losing, no longer suffers greatly on the NS2 "larger team bias" issue which often results in conceding every third game or so.

Hopefully this mod will give the smaller losing team a bit of HOPE so they at least, try a little bit more.

Because this isn't a kill for resource system, do not expect to be able to pull off a one-man army vs a team of 11 aliens like Spamo did in a video recording in the other thread.

The full code in raw to show its simplicity (edit: Spacing between certain lines and parts of functions added to 'conform to ns2 standards' and the apostrophe remove from "isn't" so syntax highlighting doesn't stuff up):
local lcommanderactiveworth = 1
--This variable is how many players worth is a commander. If its set to '1' then
--there is correct scaling.
--This means that the team with a commander will get a slight resource penalty
--when compared to a team without a commander if the value is > 1
--Recommended to be at least '1' else the team with a commander will get a bonus
--because the commander isnt counted as a player

function ResourceTower:OnUpdate(deltaTime)

    ScriptActor.OnUpdate(self, deltaTime)

    if self:GetIsCollecting() then

        if not self.timeLastCollected then

            self.timeLastCollected = Shared.GetTime()

        end

--Scale based on team player ratios
        local lourteam = self:GetTeam()
        local lenemyteam = GetGamerules():GetTeam1()
        local lourcommander = 0
        local lenemycommander = 0

--Find out if we have a commander or not, and add their worth to the player count
        if lourteam:GetCommander() then

            lourcommander = lcommanderactiveworth

        end

        if lenemyteam:GetCommander() then

            lenemycommander = lcommanderactiveworth

        end

--If we are humans enemy team must be aliens or else we are alien
        if lourteam == lenemyteam then

            lenemyteam = GetGamerules():GetTeam2()

        end

        local lteamratio =  math.sqrt((lourteam:GetNumPlayers() + lourcommander) / (lenemyteam:GetNumPlayers() + lenemycommander))

        local ResourceInterval = kResourceTowerResourceInterval * lteamratio

        if self.timeLastCollected + ResourceInterval < Shared.GetTime() then

            self:CollectResources()
            self.timeLastCollected = Shared.GetTime()

        end

    else

        self.timeLastCollected = nil

    end

end

Comments

  • BeigeAlertBeigeAlert Texas Join Date: 2013-08-08 Member: 186657Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, NS2 Map Tester, Reinforced - Diamond, Reinforced - Shadow, Subnautica Playtester, Pistachionauts
    ZdrytchX wrote: »
    Since I doubt UWE will actually be spitting out a patch anytime soon...

    Just immortalizing this.
  • antouantou France Join Date: 2016-07-24 Member: 220615Members
    Any plans to playtest this ? :smile:
    BeigeAlert wrote: »
    ZdrytchX wrote: »
    Since I doubt UWE will actually be spitting out a patch anytime soon...

    Just immortalizing this.
    *h y p e*
  • ZdrytchXZdrytchX Australia Join Date: 2016-02-06 Member: 212662Members
    edited January 2017
    I've edited the code above (but not the mod) and broken up the functions into a line space of their own to 'conform to ns2 standards' *cough cough*
    BeigeAlert wrote: »
    ZdrytchX wrote: »
    Since I doubt UWE will actually be spitting out a patch anytime soon...

    Just immortalizing this.

    This is how I get developers to do their work ;P

    It doesn't always work though.

    I've submitted like 5 bug notifications and basic information about 90+ different bugs for Gaijin Ent. to take note of 3 years ago, and they have only fixed one recently.

    I guess that's the plusses of small communities
Sign In or Register to comment.