Victory Conditions

ScatterScatter Join Date: 2012-09-02 Member: 157341Members, Squad Five Blue
Where do I look to change the victory conditions of the game. For example if I wanted the game to end once a team has reached x amount of tres, how would I go about doing that. I have been looking in NS2Gamerules.lua but struggling so far.

Any advice appreciated.

Comments

  • McGlaspieMcGlaspie www.team156.com Join Date: 2010-07-26 Member: 73044Members, Super Administrators, Forum Admins, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Reinforced - Onos, WC 2013 - Gold, Subnautica Playtester
    That's the file you need to be looking at. It has a method, CheckGameEnd or something like that.
    Warning: This class governs a LOT of the game, so tread carefully.
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited January 2014
    Little tipp:

    (I would do this with max 80 lines using the Shine Core/Lib.)

    Two things:
    Look at my roundlimiterplugin and how it ends a round: https://github.com/BrightPaul/NS2Stats.com/blob/develop/lua/shine/extensions/roundlimiter.lua

    Now instead of OnScore and Timebased you would need
    Shine.Hook.SetupClassHook("ResourceTower","CollectResources","OnTeamGetResources","PassivePost")
    
    and
    function Plugin:OnTeamGetResources(ResourceTower)
            local team = ResourceTower:GetTeam():GetTeamNumber()
            local amount = kTeamResourcePerTick
            teamres[team] = teamres[team] + amount
    
            if teamres[team] > self.Config.MaxTRes then self:EndRound() end
    end
    


  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    GetHasTeamWon() is also a good place to look, this is in Team.lua, or playing team.lua if i remember correctly, and enables you to set win conditions there without messing up the whole of the gamerules file. It is definitely the better option.

    NS2 checks GetHasTeamWon() already in the code, even though currently it is empty, so you just need to fill it up and it should work fine :D
  • ScatterScatter Join Date: 2012-09-02 Member: 157341Members, Squad Five Blue
    Ok thanks very much for the suggestions and the code provided, just trying to test it on a server.
Sign In or Register to comment.