Pairs of random spawns

2»

Comments

  • MendaspMendasp I touch maps in inappropriate places Valencia, Spain Join Date: 2002-07-05 Member: 884Members, NS1 Playtester, Contributor, Constellation, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow, WC 2013 - Shadow, Retired Community Developer
    Updated for Build 216.
  • MendaspMendasp I touch maps in inappropriate places Valencia, Spain Join Date: 2002-07-05 Member: 884Members, NS1 Playtester, Contributor, Constellation, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow, WC 2013 - Shadow, Retired Community Developer
    Updated for Build 217.
  • MCMLXXXIVMCMLXXXIV Join Date: 2010-04-14 Member: 71400Members
    Hi Mendasp, do you mind if we integrate your code into the Combat mod? We have a need for close spawns on account of the two teams needing to be able to get to each other quickly :]

    We already have a solution that works in a similar way but it isn't quite as configurable for server operators as yours and only has spawn combos for tram...
  • MendaspMendasp I touch maps in inappropriate places Valencia, Spain Join Date: 2002-07-05 Member: 884Members, NS1 Playtester, Contributor, Constellation, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow, WC 2013 - Shadow, Retired Community Developer
  • MendaspMendasp I touch maps in inappropriate places Valencia, Spain Join Date: 2002-07-05 Member: 884Members, NS1 Playtester, Contributor, Constellation, NS2 Playtester, Squad Five Gold, NS2 Map Tester, Reinforced - Shadow, WC 2013 - Shadow, Retired Community Developer
    I'm not updating this anymore, but whoever wants to keep using it, it's as simple as finding this in NS2GameRules.lua

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->        // Reset teams (keep players on them)
            local team1TechPoint = self:ChooseTechPoint(techPoints, kTeam1Index)
            self.team1:ResetPreservePlayers(team1TechPoint)
            local team2TechPoint = self:ChooseTechPoint(techPoints, kTeam2Index)
            self.team2:ResetPreservePlayers(team2TechPoint)<!--c2--></div><!--ec2-->

    And replacing it with

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->        local team1TechPoint
            local team2TechPoint
            local file = io.open("maps/" .. Shared.GetMapName() .. ".txt", "r")
            if file then
                local customTechPoints = { }
                local t = json.decode(file:read("*all"), 1, nil)
                file:close()
                for i,v in pairs(t) do
                    for index, currentTechPoint in pairs(techPoints) do
                        if (v.name == currentTechPoint:GetLocationName()) then
                            table.insert(customTechPoints, currentTechPoint)
                            
                            // Modify the teams allowed to spawn here
                            if (v.team == "marines") then
                                currentTechPoint.allowedTeamNumber = 1
                            elseif (v.team == "aliens") then
                                currentTechPoint.allowedTeamNumber = 2
                            elseif (v.team == "both") then
                                currentTechPoint.allowedTeamNumber = 0
                            // If we don't understand the team, no teams can spawn here
                            else
                                currentTechPoint.allowedTeamNumber = 3
                            end
                            
                            // Assign the valid enemy spawns to the tech point
                            if (v.enemyspawns ~= nil) then
                                currentTechPoint.enemyspawns = v.enemyspawns
                            end
                        end
                    end
                end
          
                // Reset teams (keep players on them)
                team1TechPoint = self:ChooseTechPoint(customTechPoints, kTeam1Index)
                self.team1:ResetPreservePlayers(team1TechPoint)
                local validAlienSpawns = { }
                
                for index,currentTechPoint in pairs(customTechPoints) do
                    local teamNum = currentTechPoint:GetTeamNumberAllowed()
                    if (team1TechPoint.enemyspawns ~= nil and (teamNum == 0 or teamNum == 2)) then
                        for i,v in pairs(team1TechPoint.enemyspawns) do
                            if (v == currentTechPoint:GetLocationName()) then
                                table.insert(validAlienSpawns, currentTechPoint)
                            end
                        end
                    end    
                end

                local randomTechPointIndex = self.techPointRandomizer:random(1, #validAlienSpawns)
                team2TechPoint = validAlienSpawns[randomTechPointIndex]
                self.team2:ResetPreservePlayers(team2TechPoint)
                
            // If no file is found, go back to the default method    
            else
                Print("No custom spawns file was found, using default behavior")
                team1TechPoint = self:ChooseTechPoint(techPoints, kTeam1Index)
                self.team1:ResetPreservePlayers(team1TechPoint)
                team2TechPoint = self:ChooseTechPoint(techPoints, kTeam2Index)
                self.team2:ResetPreservePlayers(team2TechPoint)
            end<!--c2--></div><!--ec2-->

    The text files may not be usable (mineshaft for example) as the maps have changed, so you should adjust that too if you want to keep using this mod (if someone out there is using it!).
Sign In or Register to comment.