Skip to content

Commit

Permalink
added nil checks to scav_spawner_defense (#4260)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruwetuin authored Jan 31, 2025
1 parent f05da80 commit 2c2a0f0
Showing 1 changed file with 42 additions and 32 deletions.
74 changes: 42 additions & 32 deletions luarules/gadgets/scav_spawner_defense.lua
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,14 @@ if gadgetHandler:IsSyncedCode() then
squad = { count .. " " .. scavType }
for i, sString in pairs(squad) do
local nEnd, _ = string.find(sString, " ")
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter, attackNearestEnemy = attackNearestEnemy })
if nEnd then
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter, attackNearestEnemy = attackNearestEnemy })
end
end
end
end
Expand Down Expand Up @@ -785,12 +787,14 @@ if gadgetHandler:IsSyncedCode() then
if squad then
for i, sString in pairs(squad.units) do
local nEnd, _ = string.find(sString, " ")
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter, attackNearestEnemy = attackNearestEnemy })
if nEnd then
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter, attackNearestEnemy = attackNearestEnemy })
end
end
end
end
Expand All @@ -815,12 +819,14 @@ if gadgetHandler:IsSyncedCode() then
if squad then
for i, sString in pairs(squad.units) do
local nEnd, _ = string.find(sString, " ")
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter })
if nEnd then
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter })
end
end
end
end
Expand Down Expand Up @@ -1313,13 +1319,15 @@ if gadgetHandler:IsSyncedCode() then
if squad then
for i, sString in pairs(squad.units) do
local nEnd, _ = string.find(sString, " ")
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter })
cCount = cCount + 1
if nEnd then
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter })
cCount = cCount + 1
end
end
end
end
Expand All @@ -1344,13 +1352,15 @@ if gadgetHandler:IsSyncedCode() then
if squad then
for i, sString in pairs(squad.units) do
local nEnd, _ = string.find(sString, " ")
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter })
cCount = cCount + 1
if nEnd then
local unitNumber = mRandom(1, string.sub(sString, 1, (nEnd - 1)))
local scavName = string.sub(sString, (nEnd + 1))
for j = 1, unitNumber, 1 do
if mRandom() <= config.spawnChance or j == 1 then
squadCounter = squadCounter + 1
table.insert(spawnQueue, { burrow = burrowID, unitName = scavName, team = scavTeamID, squadID = squadCounter })
cCount = cCount + 1
end
end
end
end
Expand Down

0 comments on commit 2c2a0f0

Please sign in to comment.