2018-01-14 02:12:09 +02:00
|
|
|
local swarmUtils = {}
|
2018-01-13 04:55:20 +02:00
|
|
|
-- imports
|
|
|
|
|
2018-02-05 02:07:25 +02:00
|
|
|
local droneUtils = require("utils/DroneUtils")
|
2018-01-21 09:42:47 +02:00
|
|
|
local biterUtils = require("utils/BiterUtils")
|
|
|
|
package.path = "../?.lua;" .. package.path
|
2018-01-13 04:55:20 +02:00
|
|
|
local mathUtils = require("libs/MathUtils")
|
2018-01-28 03:02:33 +02:00
|
|
|
local constants = require("libs/Constants")
|
2018-01-13 04:55:20 +02:00
|
|
|
|
|
|
|
-- imported functions
|
|
|
|
|
2018-01-14 02:12:09 +02:00
|
|
|
local gaussianRandomRangeRG = mathUtils.gaussianRandomRangeRG
|
2018-01-13 04:55:20 +02:00
|
|
|
|
2018-01-22 09:13:18 +02:00
|
|
|
local roundToNearest = mathUtils.roundToNearest
|
|
|
|
|
2018-01-13 04:55:20 +02:00
|
|
|
local mMax = math.max
|
2018-01-14 02:12:09 +02:00
|
|
|
local mMin = math.min
|
|
|
|
|
|
|
|
local mFloor = math.floor
|
2018-01-13 04:55:20 +02:00
|
|
|
|
|
|
|
local deepcopy = util.table.deepcopy
|
|
|
|
|
2018-02-06 03:50:36 +02:00
|
|
|
local TIER_UPGRADE_SET_5 = constants.TIER_UPGRADE_SET_5
|
|
|
|
local TIER_UPGRADE_SET_10 = constants.TIER_UPGRADE_SET_10
|
|
|
|
|
|
|
|
local TIER_NAMING_SET_10 = constants.TIER_NAMING_SET_10
|
|
|
|
local TIER_NAMING_SET_5 = constants.TIER_NAMING_SET_5
|
2018-01-28 03:02:33 +02:00
|
|
|
|
2018-01-14 02:12:09 +02:00
|
|
|
local xorRandom = mathUtils.xorRandom(settings.startup["rampant-enemySeed"].value)
|
|
|
|
|
2018-01-20 09:15:13 +02:00
|
|
|
local makeBiterCorpse = biterUtils.makeBiterCorpse
|
|
|
|
local makeUnitSpawnerCorpse = biterUtils.makeUnitSpawnerCorpse
|
|
|
|
local makeWormCorpse = biterUtils.makeWormCorpse
|
|
|
|
local makeSpitterCorpse = biterUtils.makeSpitterCorpse
|
|
|
|
|
2018-01-13 04:55:20 +02:00
|
|
|
local makeBiter = biterUtils.makeBiter
|
2018-02-05 02:07:25 +02:00
|
|
|
local makeDrone = droneUtils.makeDrone
|
2018-01-13 04:55:20 +02:00
|
|
|
local makeSpitter = biterUtils.makeSpitter
|
|
|
|
local makeWorm = biterUtils.makeWorm
|
|
|
|
local makeUnitSpawner = biterUtils.makeUnitSpawner
|
|
|
|
|
|
|
|
-- module code
|
|
|
|
|
2018-01-22 09:13:18 +02:00
|
|
|
local function unitSetToProbabilityTable(upgradeTable, unitSet)
|
2018-01-13 04:55:20 +02:00
|
|
|
local dividers = {}
|
|
|
|
|
|
|
|
for i=1,#unitSet do
|
|
|
|
dividers[i] = 1
|
|
|
|
end
|
|
|
|
|
2018-01-14 02:12:09 +02:00
|
|
|
if upgradeTable then
|
2018-02-03 09:47:46 +02:00
|
|
|
local points = #unitSet * 2
|
|
|
|
for _=1,points do
|
2018-01-28 03:02:33 +02:00
|
|
|
local index = mFloor(xorRandom() * #unitSet)+1
|
2018-01-18 09:15:10 +02:00
|
|
|
local upgrade = upgradeTable[index]
|
2018-01-13 04:55:20 +02:00
|
|
|
|
2018-01-18 09:15:10 +02:00
|
|
|
dividers[index] = dividers[index] + upgrade
|
2018-01-14 02:12:09 +02:00
|
|
|
end
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
2018-01-14 02:12:09 +02:00
|
|
|
|
2018-01-13 04:55:20 +02:00
|
|
|
local total = 0
|
|
|
|
for i=1,#dividers do
|
|
|
|
total = total + dividers[i]
|
|
|
|
end
|
|
|
|
|
|
|
|
local runningTotal = 0
|
|
|
|
for i=1,#dividers do
|
|
|
|
runningTotal = runningTotal + (dividers[i] / total)
|
|
|
|
dividers[i] = runningTotal
|
|
|
|
end
|
|
|
|
|
2018-01-14 02:12:09 +02:00
|
|
|
local stepUnit = 1 / (#unitSet[1] + 1)
|
|
|
|
|
2018-01-13 04:55:20 +02:00
|
|
|
local probabilityTable = {}
|
|
|
|
|
|
|
|
for i=1,#unitSet do
|
|
|
|
local result
|
|
|
|
if (i == 1) then
|
|
|
|
result = {
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
stepUnit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dividers[i],
|
|
|
|
0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif (i == #unitSet) then
|
|
|
|
result = {
|
|
|
|
{
|
|
|
|
dividers[i-2],
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
stepUnit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = {
|
|
|
|
{
|
|
|
|
((i - 2) > 0 and dividers[i-2]) or 0,
|
|
|
|
0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dividers[i-1],
|
|
|
|
stepUnit
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dividers[i],
|
|
|
|
0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
probabilityTable[i] = result
|
|
|
|
end
|
|
|
|
|
|
|
|
local result = {}
|
|
|
|
|
|
|
|
for i=1, #probabilityTable do
|
|
|
|
local probability = probabilityTable[i]
|
|
|
|
for x=1, #unitSet[i] do
|
|
|
|
result[#result+1] = {unitSet[i][x], probability}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
|
2018-05-19 22:16:16 +02:00
|
|
|
local function scaleAttributes (upgrade, entity)
|
|
|
|
if (upgrade.type == "attribute") then
|
|
|
|
if (entity.type == "biter") then
|
|
|
|
if (upgrade.name == "health") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitBiterHealthScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "movement") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitBiterSpeedScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "distancePerFrame") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitBiterSpeedScaler"].value
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif (entity.type == "spitter") then
|
|
|
|
if (upgrade.name == "health") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpitterHealthScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "movement") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpitterSpeedScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "distancePerFrame") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpitterSpeedScaler"].value
|
|
|
|
end
|
|
|
|
elseif (entity.type == "drone") then
|
|
|
|
if (upgrade.name == "health") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitDroneHealthScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "movement") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitDroneSpeedScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "distancePerFrame") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitDroneSpeedScaler"].value
|
|
|
|
end
|
|
|
|
elseif (entity.type == "spawner") then
|
|
|
|
if (upgrade.name == "health") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpawnerHealthScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "unitsOwned") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpawnerOwnedScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "unitsToSpawn") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpawnerSpawnScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "spawingCooldownStart") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpawnerRespawnScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "spawingCooldownEnd") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitSpawnerRespawnScaler"].value
|
|
|
|
end
|
|
|
|
elseif (entity.type == "worm") then
|
|
|
|
if (upgrade.name == "health") then
|
|
|
|
entity.attributes[upgrade.name] = entity.attributes[upgrade.name] * settings.startup["rampant-unitWormHealthScaler"].value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if (upgrade.type == "resistance") then
|
|
|
|
-- not asked for
|
|
|
|
end
|
|
|
|
if (upgrade.type == "attack") then
|
|
|
|
if (entity.type == "biter") then
|
|
|
|
if (upgrade.name == "damage") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitBiterDamageScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "range") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitBiterRangeScaler"].value
|
|
|
|
end
|
|
|
|
elseif (entity.type == "spitter") then
|
|
|
|
if (upgrade.name == "damage") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitSpitterDamageScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "stickerDamagePerTick") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitSpitterDamageScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "range") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitSpitterRangeScaler"].value
|
|
|
|
end
|
|
|
|
elseif (entity.type == "drone") then
|
|
|
|
if (upgrade.name == "damage") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitDroneDamageScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "range") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitDroneRangeScaler"].value
|
|
|
|
end
|
|
|
|
elseif (entity.type == "worm") then
|
|
|
|
if (upgrade.name == "damage") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitWormDamageScaler"].value
|
|
|
|
end
|
|
|
|
if (upgrade.name == "range") then
|
|
|
|
entity.attack[upgrade.name] = entity.attack[upgrade.name] * settings.startup["rampant-unitWormRangeScaler"].value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-22 09:13:18 +02:00
|
|
|
local function upgradeEntity(entity, upgradeTable, tier)
|
|
|
|
if upgradeTable then
|
|
|
|
for upgradeIndex=1, #upgradeTable do
|
|
|
|
local upgrade = upgradeTable[upgradeIndex]
|
2018-01-19 09:25:32 +02:00
|
|
|
|
2018-01-22 09:13:18 +02:00
|
|
|
if (upgrade.type == "attribute") then
|
|
|
|
if upgrade.mapping then
|
|
|
|
entity.attributes[upgrade.mapping] = upgrade[tier]
|
|
|
|
else
|
|
|
|
local adj = upgrade[tier]
|
|
|
|
local min = upgrade.min or adj * 0.70
|
|
|
|
local max = upgrade.max or adj * 1.30
|
|
|
|
if (adj < 0) then
|
|
|
|
local t = min
|
|
|
|
min = max
|
|
|
|
max = t
|
2018-01-19 09:25:32 +02:00
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
adj = roundToNearest(gaussianRandomRangeRG(adj, adj * 0.2, min, max, xorRandom), 0.001)
|
|
|
|
entity.attributes[upgrade.name] = (entity.attributes[upgrade.name] or 0) + adj
|
2018-01-19 09:25:32 +02:00
|
|
|
end
|
2018-05-19 22:16:16 +02:00
|
|
|
scaleAttributes(upgrade, entity)
|
2018-01-19 09:25:32 +02:00
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
if (upgrade.type == "resistance") then
|
|
|
|
local field = upgrade.name
|
|
|
|
if not entity.resistances[field] then
|
|
|
|
entity.resistances[field] = {}
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
local adj
|
|
|
|
if upgrade.decrease then
|
|
|
|
adj = upgrade.decrease[tier]
|
|
|
|
local min = upgrade.min or adj * 0.70
|
|
|
|
local max = upgrade.max or adj * 1.30
|
|
|
|
if (adj < 0) then
|
|
|
|
local t = min
|
|
|
|
min = max
|
|
|
|
max = t
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
adj = roundToNearest(gaussianRandomRangeRG(adj, adj * 0.2, min, max, xorRandom), 0.001)
|
|
|
|
entity.resistances[field].decrease = (entity.resistances[field].decrease or 0) + adj
|
|
|
|
end
|
|
|
|
if upgrade.percent then
|
|
|
|
adj = upgrade.percent[tier]
|
|
|
|
local min = upgrade.min or adj * 0.70
|
|
|
|
local max = upgrade.max or adj * 1.30
|
|
|
|
if (adj < 0) then
|
|
|
|
local t = min
|
|
|
|
min = max
|
|
|
|
max = t
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
adj = roundToNearest(gaussianRandomRangeRG(adj, adj * 0.2, min, max, xorRandom), 0.001)
|
|
|
|
entity.resistances[field].percent = mMin((entity.resistances[field].percent or 0) + adj, 100)
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
end
|
|
|
|
if (upgrade.type == "attack") then
|
|
|
|
if upgrade.mapping then
|
|
|
|
entity.attack[upgrade.mapping] = upgrade[tier]
|
|
|
|
else
|
|
|
|
local adj = upgrade[tier]
|
|
|
|
local min = upgrade.min or adj * 0.70
|
|
|
|
local max = upgrade.max or adj * 1.30
|
|
|
|
if (adj < 0) then
|
|
|
|
local t = min
|
|
|
|
min = max
|
|
|
|
max = t
|
2018-01-14 02:12:09 +02:00
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
adj = roundToNearest(gaussianRandomRangeRG(adj, adj * 0.2, min, max, xorRandom), 0.001)
|
|
|
|
entity.attack[upgrade.name] = (entity.attack[upgrade.name] or 0) + adj
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
2018-05-19 22:16:16 +02:00
|
|
|
scaleAttributes(upgrade, entity)
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
2018-01-14 02:12:09 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-19 09:25:32 +02:00
|
|
|
local function calculateRGBa(tint, tier)
|
|
|
|
local r = gaussianRandomRangeRG(tint.r, tint.r * 0.10 + (0.005 * tier), mMax(tint.r * 0.85 - (0.005 * tier), 0), mMin(tint.r * 1.15, 1), xorRandom)
|
|
|
|
local g = gaussianRandomRangeRG(tint.g, tint.g * 0.10 + (0.005 * tier), mMax(tint.g * 0.85 - (0.005 * tier), 0), mMin(tint.g * 1.15, 1), xorRandom)
|
|
|
|
local b = gaussianRandomRangeRG(tint.b, tint.b * 0.10 + (0.005 * tier), mMax(tint.b * 0.85 - (0.005 * tier), 0), mMin(tint.b * 1.15, 1), xorRandom)
|
|
|
|
local a = gaussianRandomRangeRG(tint.a, tint.a * 0.10 + (0.005 * tier), mMax(tint.a * 0.85 - (0.005 * tier), 0), mMin(tint.a * 1.15, 1), xorRandom)
|
|
|
|
|
|
|
|
return { r=r, g=g, b=b, a=a }
|
|
|
|
end
|
|
|
|
|
2018-01-14 02:12:09 +02:00
|
|
|
local function generateApperance(unit, tier)
|
2018-02-05 02:07:25 +02:00
|
|
|
local scale
|
|
|
|
|
|
|
|
if unit.scales then
|
|
|
|
local scaleValue = unit.scales[tier]
|
|
|
|
scale = gaussianRandomRangeRG(scaleValue, scaleValue * 0.12, scaleValue * 0.60, scaleValue * 1.40, xorRandom)
|
2018-01-13 04:55:20 +02:00
|
|
|
|
2018-02-05 02:07:25 +02:00
|
|
|
unit.scale = scale
|
|
|
|
unit.attributes.scale = scale
|
|
|
|
end
|
2018-01-20 09:15:13 +02:00
|
|
|
if unit.tint then
|
|
|
|
local tint = calculateRGBa(unit.tint, tier)
|
|
|
|
|
|
|
|
unit.attributes.tint = tint
|
|
|
|
|
|
|
|
if unit.attack then
|
2018-02-05 02:07:25 +02:00
|
|
|
if scale then
|
|
|
|
unit.attack.scale = scale
|
|
|
|
end
|
2018-01-20 09:15:13 +02:00
|
|
|
unit.attack.tint = tint
|
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
end
|
|
|
|
if unit.tint1 and unit.tint2 then
|
2018-01-19 09:25:32 +02:00
|
|
|
local tint1 = calculateRGBa(unit.tint1, tier)
|
|
|
|
local tint2 = calculateRGBa(unit.tint2, tier)
|
2018-01-14 02:12:09 +02:00
|
|
|
|
|
|
|
unit.attributes.tint1 = tint1
|
|
|
|
unit.attributes.tint2 = tint2
|
2018-01-22 09:13:18 +02:00
|
|
|
|
|
|
|
if unit.attack then
|
2018-02-05 02:07:25 +02:00
|
|
|
if scale then
|
|
|
|
unit.attack.scale = scale
|
|
|
|
end
|
2018-01-22 09:13:18 +02:00
|
|
|
unit.attack.tint1 = tint1
|
|
|
|
unit.attack.tint2 = tint2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if unit.attack then
|
2018-01-19 09:25:32 +02:00
|
|
|
if unit.pTint then
|
|
|
|
unit.attack.pTint = calculateRGBa(unit.pTint, tier)
|
|
|
|
end
|
2018-02-04 08:54:11 +02:00
|
|
|
if unit.lTint then
|
|
|
|
unit.attack.lTint = calculateRGBa(unit.lTint, tier)
|
|
|
|
end
|
2018-01-19 09:25:32 +02:00
|
|
|
if unit.sTint then
|
|
|
|
unit.attack.sTint = calculateRGBa(unit.sTint, tier)
|
|
|
|
end
|
|
|
|
if unit.smTint then
|
|
|
|
unit.attack.smTint = calculateRGBa(unit.smTint, tier)
|
|
|
|
end
|
2018-01-14 02:12:09 +02:00
|
|
|
end
|
|
|
|
end
|
2018-01-13 04:55:20 +02:00
|
|
|
|
2018-02-05 02:07:25 +02:00
|
|
|
function swarmUtils.buildUnits(template, attackGenerator, upgradeTable, variations, tiers)
|
2018-01-14 02:12:09 +02:00
|
|
|
local unitSet = {}
|
|
|
|
|
2018-01-28 03:02:33 +02:00
|
|
|
for tier=1, tiers do
|
2018-02-06 03:50:36 +02:00
|
|
|
local t = ((tiers == 5) and TIER_NAMING_SET_5[tier]) or TIER_NAMING_SET_10[tier]
|
|
|
|
local ut = ((tiers == 5) and TIER_UPGRADE_SET_5[tier]) or TIER_UPGRADE_SET_10[tier]
|
2018-01-14 02:12:09 +02:00
|
|
|
local result = {}
|
|
|
|
|
|
|
|
for i=1,variations do
|
|
|
|
local unit = deepcopy(template)
|
2018-01-20 09:15:13 +02:00
|
|
|
unit.name = unit.name .. "-v" .. i .. "-t" .. t
|
2018-02-05 05:24:28 +02:00
|
|
|
unit.attributes.tier = "-v" .. i .. "-t" .. t
|
2018-02-06 03:50:36 +02:00
|
|
|
generateApperance(unit, ut)
|
|
|
|
upgradeEntity(unit, upgradeTable, ut)
|
2018-01-14 02:12:09 +02:00
|
|
|
|
2018-01-19 09:25:32 +02:00
|
|
|
if unit.attackName then
|
2018-01-20 09:15:13 +02:00
|
|
|
unit.attack.name = unit.attackName .. "-v" .. i .. "-t" .. t
|
2018-01-19 09:25:32 +02:00
|
|
|
end
|
2018-01-29 03:51:24 +02:00
|
|
|
|
|
|
|
if unit.loot then
|
2018-02-06 03:50:36 +02:00
|
|
|
unit.attributes.loot = { unit.loot[ut] }
|
2018-05-19 22:16:16 +02:00
|
|
|
end
|
|
|
|
|
2018-01-13 04:55:20 +02:00
|
|
|
local entity
|
|
|
|
if (unit.type == "spitter") then
|
2018-01-20 09:15:13 +02:00
|
|
|
unit.attributes.corpse = makeSpitterCorpse(unit)
|
2018-01-13 04:55:20 +02:00
|
|
|
entity = makeSpitter(unit.name,
|
|
|
|
unit.attributes,
|
2018-02-10 09:18:41 +02:00
|
|
|
attackGenerator(unit.attack, unit.attributes),
|
2018-01-13 04:55:20 +02:00
|
|
|
unit.resistances)
|
|
|
|
elseif (unit.type == "biter") then
|
2018-01-20 09:15:13 +02:00
|
|
|
unit.attributes.corpse = makeBiterCorpse(unit)
|
2018-01-13 04:55:20 +02:00
|
|
|
entity = makeBiter(unit.name,
|
|
|
|
unit.attributes,
|
2018-02-10 09:18:41 +02:00
|
|
|
attackGenerator(unit.attack, unit.attributes),
|
2018-01-13 04:55:20 +02:00
|
|
|
unit.resistances)
|
2018-02-05 02:07:25 +02:00
|
|
|
elseif (unit.type == "drone") then
|
|
|
|
entity = makeDrone(unit.name,
|
|
|
|
unit.attributes,
|
|
|
|
unit.resistances,
|
|
|
|
attackGenerator(unit.attack),
|
2018-02-05 05:24:28 +02:00
|
|
|
unit.death(unit.attack, unit.attributes))
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
|
|
|
|
2018-02-01 06:01:28 +02:00
|
|
|
result[#result+1] = entity.name
|
2018-01-13 04:55:20 +02:00
|
|
|
|
|
|
|
data:extend({entity})
|
|
|
|
end
|
|
|
|
|
2018-02-01 06:01:28 +02:00
|
|
|
unitSet[#unitSet+1] = result
|
2018-01-13 04:55:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return unitSet
|
|
|
|
end
|
|
|
|
|
2018-01-18 09:15:10 +02:00
|
|
|
function swarmUtils.buildUnitSpawner(templates, upgradeTable, attackGenerator, variations, tiers)
|
2018-02-05 02:07:25 +02:00
|
|
|
local unitSet = swarmUtils.buildUnits(templates.unit,
|
|
|
|
attackGenerator,
|
|
|
|
upgradeTable.unit,
|
|
|
|
variations.unit,
|
|
|
|
tiers.unit)
|
|
|
|
|
|
|
|
for tier=1, tiers.unitSpawner do
|
2018-02-06 03:50:36 +02:00
|
|
|
local t = ((tiers.unitSpawner == 5) and TIER_NAMING_SET_5[tier]) or TIER_NAMING_SET_10[tier]
|
|
|
|
local ut = ((tiers.unitSpawner == 5) and TIER_UPGRADE_SET_5[tier]) or TIER_UPGRADE_SET_10[tier]
|
2018-01-15 01:10:56 +02:00
|
|
|
for i=1,variations.unitSpawner do
|
|
|
|
local unitSpawner = deepcopy(templates.unitSpawner)
|
2018-01-20 09:15:13 +02:00
|
|
|
unitSpawner.name = unitSpawner.name .. "-v" .. i .. "-t" .. t
|
2018-01-22 09:13:18 +02:00
|
|
|
local unitTable = unitSetToProbabilityTable(upgradeTable.probabilityTable,
|
2018-01-15 01:10:56 +02:00
|
|
|
unitSet)
|
2018-02-06 03:50:36 +02:00
|
|
|
generateApperance(unitSpawner, ut)
|
2018-05-19 22:16:16 +02:00
|
|
|
unitSpawner.type = "spawner"
|
2018-02-06 03:50:36 +02:00
|
|
|
upgradeEntity(unitSpawner, upgradeTable.unitSpawner, ut)
|
2018-01-13 04:55:20 +02:00
|
|
|
|
2018-01-29 03:51:24 +02:00
|
|
|
if unitSpawner.loot then
|
2018-02-06 03:50:36 +02:00
|
|
|
unitSpawner.attributes.loot = { unitSpawner.loot[ut] }
|
2018-01-29 03:51:24 +02:00
|
|
|
end
|
|
|
|
|
2018-01-19 09:25:32 +02:00
|
|
|
if unitSpawner.autoplace then
|
2018-02-06 03:50:36 +02:00
|
|
|
unitSpawner.attributes["autoplace"] = unitSpawner.autoplace[ut]
|
2018-01-19 09:25:32 +02:00
|
|
|
end
|
2018-01-20 09:15:13 +02:00
|
|
|
unitSpawner.attributes.corpse = makeUnitSpawnerCorpse(unitSpawner)
|
2018-01-13 04:55:20 +02:00
|
|
|
data:extend({
|
|
|
|
makeUnitSpawner(unitSpawner.name,
|
|
|
|
unitSpawner.attributes,
|
|
|
|
unitSpawner.resistances,
|
|
|
|
unitTable)
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-01-18 09:15:10 +02:00
|
|
|
function swarmUtils.buildWorm(template, upgradeTable, attackGenerator, variations, tiers)
|
2018-01-28 03:02:33 +02:00
|
|
|
for tier=1, tiers do
|
2018-02-06 03:50:36 +02:00
|
|
|
local t = ((tiers == 5) and TIER_NAMING_SET_5[tier]) or TIER_NAMING_SET_10[tier]
|
|
|
|
local ut = ((tiers == 5) and TIER_UPGRADE_SET_5[tier]) or TIER_UPGRADE_SET_10[tier]
|
2018-01-13 04:55:20 +02:00
|
|
|
for i=1,variations do
|
|
|
|
local worm = deepcopy(template)
|
2018-01-20 09:15:13 +02:00
|
|
|
worm.name = worm.name .. "-v" .. i .. "-t" .. t
|
2018-02-06 03:50:36 +02:00
|
|
|
generateApperance(worm, ut)
|
2018-05-19 22:16:16 +02:00
|
|
|
worm.type = "worm"
|
2018-02-06 03:50:36 +02:00
|
|
|
upgradeEntity(worm, upgradeTable, ut)
|
2018-01-19 09:25:32 +02:00
|
|
|
|
|
|
|
if worm.attackName then
|
2018-01-20 09:15:13 +02:00
|
|
|
worm.attack.name = worm.attackName .. "-v" .. i .. "-t" .. t
|
2018-01-19 09:25:32 +02:00
|
|
|
end
|
2018-01-29 03:51:24 +02:00
|
|
|
|
|
|
|
if worm.loot then
|
2018-02-06 03:50:36 +02:00
|
|
|
worm.attributes.loot = { worm.loot[ut] }
|
2018-01-29 03:51:24 +02:00
|
|
|
end
|
2018-01-19 09:25:32 +02:00
|
|
|
|
|
|
|
if worm.autoplace then
|
2018-02-06 03:50:36 +02:00
|
|
|
worm.attributes["autoplace"] = worm.autoplace[ut]
|
2018-01-19 09:25:32 +02:00
|
|
|
end
|
2018-01-20 09:15:13 +02:00
|
|
|
worm.attributes.corpse = makeWormCorpse(worm)
|
2018-01-13 04:55:20 +02:00
|
|
|
data:extend({
|
|
|
|
makeWorm(worm.name,
|
|
|
|
worm.attributes,
|
|
|
|
attackGenerator(worm.attack),
|
|
|
|
worm.resistances)
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-14 02:12:09 +02:00
|
|
|
return swarmUtils
|