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...
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!).
Comments
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...
<!--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!).