Can we have unit limits inherited when players leave? Currently, if somebody has a unit limit of 500, and leaves the game, that unit capacity is gone forever.
Trying to do 2v7 when you have a 1000 unit limit and they have 3500 is disheartening

Moderator: Moderators
Yep, was thinking the same.Silentwings wrote: A neat way to get around the problem of deciding who a dead players unit limit should be allocated to would be to just split it evenly amongst remaining teammates everytime someone dies.
Code: Select all
function gadget:GetInfo()
return {
name = "Group limit gadget",
desc = "Allows having a unit limit that adds up multiple units",
author = "KDR_11k (David Becker)",
date = "2007-09-11",
license = "none yet",
layer = 300,
enabled = true
}
end
if (gadgetHandler:IsSyncedCode()) then
--SYNCED
local teamGroupCount = {} --Number of units of a given group owned by a given team
local spDestroyUnit = Spring.DestroyUnit
local resources
local unitCost
local capacity
local resCount
local min = math.min
local groupUnits={}
local groupLimit={}
local group = {} --unit ID -> group
function gadget:Initialize()
asdf = include("gamedata/configs/grouplimit_Defs.lua") --imports groupUnits and groupLimit
groupUnits=asdf.groups
groupLimit=asdf.limits
resources = GG.resources
unitCost = GG.unitCost
capacity = GG.capacities
resCount = GG.resCount
GG.groupUnits = groupUnits
_G.groupUnits = groupUnits
_G.groupLimit = groupLimit
if groupUnits ~=nil then
--convert unit name strings to id numbers
for unit,groupN in pairs(groupUnits) do
if (UnitDefNames[unit]) then
group[UnitDefNames[unit].id] = groupN
-- Spring.Echo("Unit "..unit..", id "..UnitDefNames[unit].id.." has been added to group "..groupN)
else
Spring.Echo("GroupLimit: "..unit.." is not a valid unit")
end
end
end
if groupLimit ~=nil then
--init all teams' owned units to 0
for _,team in ipairs(Spring.GetTeamList()) do
teamGroupCount[team]={}
-- Spring.Echo("Team "..team)
for group,_ in pairs(groupLimit) do
-- Spring.Echo("Group "..group)
teamGroupCount[team][group]=0
end
end
end
-- Spring.Echo(group)
-- for a,b in pairs(groupLimit) do
-- Spring.Echo(a.." - "..b)
-- end
-- for a,b in pairs(teamGroupCount[0]) do
-- Spring.Echo(a.." - "..b)
-- end
end
function gadget:AllowUnitCreation(ud, builder, builderteam, x,y,z)
if (group[ud]) then
-- Spring.Echo("Unit is "..group[ud])
if (teamGroupCount[builderteam][group[ud] ] >= groupLimit[group[ud] ]) then
if(not Spring.GetUnitStates(builder)["repeat"]) then
Spring.SendMessageToTeam(builderteam,"Group limit for group '"..group[ud].."' reached")
end
return false
else
return true
end
end
return true
end
function gadget:UnitCreated(u, ud, team, builder)
-- Spring.Echo(team.." "..ud)
if(group[ud]) then
-- Spring.Echo("Team: "..team.." Count: "..teamGroupCount[team][group[ud] ])
-- if adding me would exceed the grouplimit I want you to kill me and refund my monitary cost.
-- Spring.Echo("---------------------------------------------")
-- Spring.Echo(resCount,team,u, ud, group[ud],teamGroupCount[team][group[ud] ])
-- Spring.Echo("conditional:", (teamGroupCount[team][group[ud] ] + 1 ), groupLimit[group[ud] ])
if ((teamGroupCount[team][group[ud] ] + 1 ) > groupLimit[group[ud] ]) then
-- Spring.Echo("deleted unit")
spDestroyUnit(u, false, true)
for i = 1, resCount do
resources[team][i] = min(resources[team][i] + (unitCost[ud][i] or 0), capacity[team][i])
end
end
teamGroupCount[team][group[ud] ] = teamGroupCount[team][group[ud] ] + 1
end
end
function gadget:UnitDestroyed(unit, ud, team, attacker, adef, ateam)
if(group[ud]) then
--Spring.Echo("Team: "..team.." Count: "..teamGroupCount[team][group[ud] ])
teamGroupCount[team][group[ud] ] = teamGroupCount[team][group[ud] ] - 1
end
end
function gadget:UnitTaken(unit, ud, team, newTeam)
if(group[ud]) then
-- Spring.Echo("Team: "..team.." Count: "..teamGroupCount[team][group[ud] ])
teamGroupCount[team][group[ud] ] = teamGroupCount[team][group[ud] ] - 1
end
end
function gadget:UnitGiven(unit, ud, team, oldTeam)
if(group[ud]) then
-- Spring.Echo("Team: "..team.." Count: "..teamGroupCount[team][group[ud] ])
teamGroupCount[team][group[ud] ] = teamGroupCount[team][group[ud] ] + 1
end
end
function gadget:AllowUnitTransfer(unit, ud, team, newTeam)
if (group[ud] and teamGroupCount[newTeam][group[ud] ] >= groupLimit[group[ud] ]) then
-- Spring.Echo("That team cannot have any more "..group[ud])
return false
else
return true
end
end
else
--UNSYNCED
end
lol.Jazcash wrote:Unit limit should be tied to an AllyTeam!
Use it in a sentence. Preferably in the context of something normal like football or tennis.Jazcash wrote:Unit limit should be tied to an AllyTeam!
I don't recognise that definition. For me you could just as well use something like scissors instead, it is just as logical as allyteam.Google_Frog wrote:Jools what is a team? I don't know if you know the accepted definition for working with spring.
Quite stupid to stick to traditional terminology considering Spring is not like any "normal" sport (because multiple players can control the same set of units) and therefore it _has_ to use its own definitions. Unless of course you'd like to change the rules of football so that multiple groups (teams) of 11 people (units) can fight as one force (allyteam) in a match, and then allow each group to have one or more coaches (players) directing it at the same time. You're not that crazy though, right? (Or you could create a "communism" game-mode letting every player in any team control every last unit built by any other friendly team of players and sharing all resources, which would somewhat let you preserve the old definition of "team", but you can probably guess why and how that could fail.)Jools wrote: I don't recognise that definition
Jools wrote:For starters, unit limit should be tied to team and not player.
NOJazcash wrote:Unit limit should be tied to an AllyTeam!
Sorry, should've made it clear that I wasn't stating my opinion, just demonstrating my abundance of knowledge about Players, Teams and AllyTeamssmoth wrote:Jools wrote:For starters, unit limit should be tied to team and not player.NOJazcash wrote:Unit limit should be tied to an AllyTeam!
and all the more reason unit limits should be lua. If they are lua game specific options/rules a gadget can be altered to handle either scenario. while not forcing any of this goofy nonsense on games that do not desire it. Please consider you requests more responsibly.