Need to figure out why bases or displaying incorrectly

This commit is contained in:
Aaron Veden
2018-01-25 16:52:26 -08:00
parent a2a3344678
commit 80b4677dea
14 changed files with 9584 additions and 3494 deletions
+3 -2
View File
@@ -174,16 +174,17 @@ function upgrade.attempt(natives)
game.surfaces[1].print("Rampant - Version 0.16.3")
global.version = constants.VERSION_38
end
if (global.version < constants.VERSION_39) then
if (global.version < constants.VERSION_40) then
natives.evolutionTableUnitSpawner = {}
natives.evolutionTableWorm = {}
natives.evolutionTableAlignment = {}
natives.bases = {}
natives.baseIndex = 1
natives.baseIncrement = 0
game.surfaces[1].print("Rampant - Version 0.16.5")
global.version = constants.VERSION_39
global.version = constants.VERSION_40
end
return starting ~= global.version, natives
+18 -17
View File
@@ -211,23 +211,8 @@ local function rebuildMap()
map.chunkTick = roundToNearest(game.tick + INTERVAL_CHUNK, INTERVAL_CHUNK)
map.squadTick = roundToNearest(game.tick + INTERVAL_SQUAD, INTERVAL_SQUAD)
-- clear pending chunks, will be added when loop runs below
global.pendingChunks = {}
pendingChunks = global.pendingChunks
-- queue all current chunks that wont be generated during play
local surface = game.surfaces[1]
local tick = game.tick
for chunk in surface.get_chunks() do
onChunkGenerated({ tick = tick,
surface = surface,
area = { left_top = { x = chunk.x * 32,
y = chunk.y * 32 }}})
end
processPendingChunks(natives, map, surface, pendingChunks, tick, game.forces.enemy.evolution_factor)
end
local function onModSettingsChange(event)
@@ -287,7 +272,23 @@ local function onConfigChanged()
upgraded, natives = upgrade.attempt(natives)
if upgraded and onModSettingsChange(nil) then
rebuildMap()
rebuildNativeTables(natives, game.surfaces[1])
rebuildNativeTables(natives, game.surfaces[1], game.create_random_generator(natives.enemySeed))
-- clear pending chunks, will be added when loop runs below
global.pendingChunks = {}
pendingChunks = global.pendingChunks
-- queue all current chunks that wont be generated during play
local surface = game.surfaces[1]
local tick = game.tick
for chunk in surface.get_chunks() do
onChunkGenerated({ tick = tick,
surface = surface,
area = { left_top = { x = chunk.x * 32,
y = chunk.y * 32 }}})
end
processPendingChunks(natives, map, surface, pendingChunks, tick, game.forces.enemy.evolution_factor)
end
end
+1 -1
View File
@@ -15,7 +15,7 @@ if settings.startup["rampant-newEnemies"].value then
-- require("prototypes/Poison")
-- require("prototypes/Undying")
-- require("prototypes/Wasp")
-- require("prototypes/Laser")
require("prototypes/Laser")
for k, unitSpawner in pairs(data.raw["unit-spawner"]) do
if (unitSpawner.name ~= "biter-spawner") then
+81 -26
View File
@@ -60,6 +60,10 @@ local FAST_WORM_VARIATIONS = constants.FAST_WORM_VARIATIONS
local FAST_NEST_TIERS = constants.FAST_NEST_TIERS
local FAST_NEST_VARIATIONS = constants.FAST_NEST_VARIATIONS
local LASER_WORM_TIERS = constants.LASER_WORM_TIERS
local LASER_WORM_VARIATIONS = constants.LASER_WORM_VARIATIONS
local LASER_NEST_TIERS = constants.LASER_NEST_TIERS
local LASER_NEST_VARIATIONS = constants.LASER_NEST_VARIATIONS
local BASE_ALIGNMENT_NEUTRAL = constants.BASE_ALIGNMENT_NEUTRAL
local BASE_ALIGNMENT_ACID = constants.BASE_ALIGNMENT_ACID
@@ -70,6 +74,7 @@ local BASE_ALIGNMENT_NUCLEAR = constants.BASE_ALIGNMENT_NUCLEAR
local BASE_ALIGNMENT_INFERNO = constants.BASE_ALIGNMENT_INFERNO
local BASE_ALIGNMENT_FIRE = constants.BASE_ALIGNMENT_FIRE
local BASE_ALIGNMENT_FAST = constants.BASE_ALIGNMENT_FAST
local BASE_ALIGNMENT_LASER = constants.BASE_ALIGNMENT_LASER
local BASE_ALIGNMENT_TROLL = constants.BASE_ALIGNMENT_TROLL
local BASE_WORM_UPGRADE = constants.BASE_WORM_UPGRADE
@@ -80,6 +85,8 @@ local BASE_DISTANCE_THRESHOLD = constants.BASE_DISTANCE_THRESHOLD
local BASE_DISTANCE_LEVEL_BONUS = constants.BASE_DISTANCE_LEVEL_BONUS
local BASE_DISTANCE_TO_EVO_INDEX = constants.BASE_DISTANCE_TO_EVO_INDEX
local BASE_ALIGNMENT_EVOLUTION_BASELINE = constants.BASE_ALIGNMENT_EVOLUTION_BASELINE
local CHUNK_SIZE = constants.CHUNK_SIZE
local BASE_ALIGNMENT_PATHS = constants.BASE_ALIGNMENT_PATHS
@@ -96,6 +103,7 @@ local euclideanDistancePoints = mathUtils.euclideanDistancePoints
local roundToFloor = mathUtils.roundToFloor
local gaussianRandomRange = mathUtils.gaussianRandomRange
local gaussianRandomRangeRG = mathUtils.gaussianRandomRangeRG
local mFloor = math.floor
@@ -148,22 +156,56 @@ function baseUtils.findNearbyBase(map, chunk, chunkRadius)
return foundBase
end
local function findUpgrade(base, evoIndex, natives, evolutionTable)
local function findEntityUpgrade(base, evoIndex, natives, evolutionTable)
-- local used = { }
-- local alignments = base.alignments
-- local alignmentPick = base.alignments[mRandom(#base.alignments)]
local alignments = evolutionTable[base.alignment]
-- while alignmentPick do
-- used[alignmentPick] = true
local entity = nil
for evo=evoIndex, 0, -EVOLUTION_INCREMENTS do
local entitySet = alignments[roundToFloor(evo, EVOLUTION_INCREMENTS)]
if base.alignment ~= 1 then
print(serpent.dump(entitySet))
end
if entitySet and (#entitySet > 0) then
entity = entitySet[mRandom(#entitySet)]
if (mRandom() > 0.5) then
break
end
end
end
-- alignmentPick = nil
-- for x = #alignments, 1, -1 do
-- if not used[alignments[x]] then
-- alignmentPick = alignments[x]
-- break
-- end
-- end
-- end
return entity
end
local function findBaseInitialAlignment(evoIndex, natives, evolutionTable)
-- local used = { }
-- local alignments = base.alignments
-- local alignmentPick = base.alignments[mRandom(#base.alignments)]
local alignmentPick = base.alignment
-- while alignmentPick do
-- used[alignmentPick] = true
if not evolutionTable then
print(alignmentPick)
end
for evo=evoIndex, 0, -EVOLUTION_INCREMENTS do
local entitySet = evolutionTable[alignmentPick][evo]
local evoTop = roundToFloor(gaussianRandomRange(evoIndex, evoIndex * 0.2, 0, evoIndex), EVOLUTION_INCREMENTS)
for evo=evoTop, 0, -EVOLUTION_INCREMENTS do
local entitySet = evolutionTable[roundToFloor(evo, EVOLUTION_INCREMENTS)]
if entitySet and (#entitySet > 0) then
return entitySet[mRandom(#entitySet)]
end
@@ -197,9 +239,9 @@ function baseUtils.upgradeEntity(map, entity, surface, natives, evolutionFactor,
EVOLUTION_INCREMENTS)
local evoIndex = mMax(distance, roundToFloor(evolutionFactor, EVOLUTION_INCREMENTS))
local spawnerName = findUpgrade(base, evoIndex, natives, ((entityType == "unit-spawner") and natives.evolutionTableUnitSpawner) or natives.evolutionTableWorm)
local spawnerName = findEntityUpgrade(base, evoIndex, natives, ((entityType == "unit-spawner") and natives.evolutionTableUnitSpawner) or natives.evolutionTableWorm)
if spawnerName then
local newPosition = surface.find_non_colliding_position(spawnerName, position, CHUNK_SIZE, 4)
local newPosition = surface.find_non_colliding_position(spawnerName, position, CHUNK_SIZE, 1)
if newPosition then
entity = surface.create_entity({name = spawnerName, position = newPosition})
end
@@ -267,9 +309,8 @@ function baseUtils.createBase(map, natives, evolutionFactor, chunk, surface, tic
local distanceIndex = roundToFloor(mMin(1, distance * BASE_DISTANCE_TO_EVO_INDEX), EVOLUTION_INCREMENTS)
local evoIndex = mMax(distanceIndex, roundToFloor(evolutionFactor, EVOLUTION_INCREMENTS))
--local alignments = { BASE_ALIGNMENT_NEUTRAL }
local alignment = BASE_ALIGNMENT_NEUTRAL
local alignment = findBaseInitialAlignment(evoIndex, natives, natives.evolutionTableAlignment) or BASE_ALIGNMENT_NEUTRAL
local base = {
x = x,
@@ -306,6 +347,16 @@ local function fileEntity(baseAlignment, entity, evolutionTable)
aTable[#aTable+1] = entity.name
end
local function fileAlignment(baseAlignment, evolution, evolutionTable)
local evoRequirement = mFloor(evolution/EVOLUTION_INCREMENTS) * EVOLUTION_INCREMENTS
local eTable = evolutionTable[evoRequirement]
if not eTable then
eTable = {}
evolutionTable[evoRequirement] = eTable
end
eTable[#eTable+1] = baseAlignment
end
local function processUnitClass(biterVariation, biterTier, spitterVariation, spitterTier, wormVariation, wormTier, surface, natives, baseAlignment, baseAlignmentString)
local position = { x = 0, y = 0 }
@@ -341,13 +392,17 @@ local function processUnitClass(biterVariation, biterTier, spitterVariation, spi
end
end
function baseUtils.rebuildNativeTables(natives, surface)
function baseUtils.rebuildNativeTables(natives, surface, rg)
natives.evolutionTableUnitSpawner = {}
natives.evolutionTableWorm = {}
natives.evolutionTableAlignment = {}
-- todo fill out alignment evolution levels
natives.evolutionTableAlignment =
for alignment,evo in pairs(BASE_ALIGNMENT_EVOLUTION_BASELINE) do
fileAlignment(alignment,
gaussianRandomRangeRG(evo, evo * 0.2, evo * 0.5, evo * 1.5, rg),
natives.evolutionTableAlignment)
end
processUnitClass(NEUTRAL_NEST_VARIATIONS,
NEUTRAL_NEST_TIERS,
@@ -492,16 +547,16 @@ function baseUtils.rebuildNativeTables(natives, surface)
-- BASE_ALIGNMENT_POSION,
-- "posion")
-- processUnitClass(LASER_NEST_VARIATIONS,
-- LASER_NEST_TIERS,
-- LASER_NEST_VARIATIONS,
-- LASER_NEST_TIERS,
-- LASER_WORM_VARIATIONS,
-- LASER_WORM_TIERS,
-- surface,
-- natives,
-- BASE_ALIGNMENT_LASER,
-- "laser")
processUnitClass(LASER_NEST_VARIATIONS,
LASER_NEST_TIERS,
LASER_NEST_VARIATIONS,
LASER_NEST_TIERS,
LASER_WORM_VARIATIONS,
LASER_WORM_TIERS,
surface,
natives,
BASE_ALIGNMENT_LASER,
"laser")
-- processUnitClass(WASP_NEST_VARIATIONS,
-- WASP_NEST_TIERS,
-2
View File
@@ -281,8 +281,6 @@ function chunkUtils.initialScan(chunk, natives, surface, map, tick, evolutionFac
local base = findNearbyBase(map, chunk, BASE_SEARCH_RADIUS)
if base then
setChunkBase(map, chunk, base)
else
createBase(map, natives, evolutionFactor, chunk, surface, tick)
end
if (#nests > 0) then
for i = 1, #nests do
+22 -8
View File
@@ -17,7 +17,7 @@ constants.VERSION_27 = 27
constants.VERSION_28 = 28
constants.VERSION_33 = 33
constants.VERSION_38 = 38
constants.VERSION_39 = 39
constants.VERSION_40 = 40
-- misc
@@ -99,7 +99,7 @@ constants.AI_MAX_TEMPERAMENT_DURATION = 15
-- ai base
constants.BASE_DISTANCE_TO_EVO_INDEX = 1 / 20480
constants.BASE_DISTANCE_TO_EVO_INDEX = 1 / 5480
constants.BASE_SPAWNER_UPGRADE = 300
constants.BASE_WORM_UPGRADE = 250
@@ -149,24 +149,38 @@ suicidePath[constants.BASE_ALIGNMENT_NUCLEAR] = true
local firePath = {}
firePath[constants.BASE_ALIGNMENT_INFERNO] = true
local acidPath = {}
-- local acidPath = {}
-- acidPath[constants.BASE_ALIGNMENT_POSION] = true
-- acidPath[constants.BASE_ALIGNMENT_INFEST] = true
local decayingPath = {}
-- local decayingPath = {}
-- decayingPath[constants.BASE_ALIGNMENT_UNDYING] = true
local electricPath = {}
-- local electricPath = {}
-- electricPath[constants.BASE_ALIGNMENT_ENERGY_THIEF] = true
electricPath[constants.BASE_ALIGNMENT_LASER] = true
-- electricPath[constants.BASE_ALIGNMENT_LASER] = true
constants.BASE_ALIGNMENT_PATHS = {}
constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_NEUTRAL] = neutralPath
constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_FIRE] = firePath
constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_SUICIDE] = suicidePath
constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_ACID] = acidPath
-- constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_ACID] = acidPath
-- constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_DECAYING] = decayingPath
constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_ELECTRIC] = electricPath
-- constants.BASE_ALIGNMENT_PATHS[constants.BASE_ALIGNMENT_ELECTRIC] = electricPath
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE = {
[constants.BASE_ALIGNMENT_NEUTRAL] = 0,
[constants.BASE_ALIGNMENT_ACID] = 0.1,
[constants.BASE_ALIGNMENT_ELECTRIC] = 0.2,
[constants.BASE_ALIGNMENT_SUICIDE] = 0.3,
[constants.BASE_ALIGNMENT_PHYSICAL] = 0.4,
[constants.BASE_ALIGNMENT_LASER] = 0.4,
[constants.BASE_ALIGNMENT_FIRE] = 0.4,
[constants.BASE_ALIGNMENT_FAST] = 0.5,
[constants.BASE_ALIGNMENT_TROLL] = 0.5,
[constants.BASE_ALIGNMENT_INFERNO] = 0.6,
[constants.BASE_ALIGNMENT_NUCLEAR] = 0.7
}
-- ai retreat
+8005 -3401
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -615,7 +615,7 @@ buildUnitSpawner(
{
unit = {
{
{
type = "attribute",
name = "health",
[1] = 10,
@@ -625,9 +625,9 @@ buildUnitSpawner(
[5] = 750,
[6] = 1000,
[7] = 1500,
[8] = 1500,
[9] = 2500,
[10] = 4500
[8] = 2500,
[9] = 4500,
[10] = 7000
},
{
+10 -10
View File
@@ -76,19 +76,19 @@ buildUnitSpawner(
{
unit = {
{
{
type = "attribute",
name = "health",
[1] = 15,
[2] = 75,
[3] = 150,
[4] = 250,
[5] = 400,
[6] = 750,
[1] = 10,
[2] = 50,
[3] = 200,
[4] = 350,
[5] = 750,
[6] = 1000,
[7] = 1500,
[8] = 3000,
[9] = 5000,
[10] = 10000
[8] = 2500,
[9] = 4500,
[10] = 7000
},
{
+4 -6
View File
@@ -579,8 +579,7 @@ buildUnitSpawner(
{
unit = {
{
{
type = "attribute",
name = "health",
[1] = 10,
@@ -590,10 +589,9 @@ buildUnitSpawner(
[5] = 750,
[6] = 1000,
[7] = 1500,
[8] = 1500,
[9] = 2500,
[10] = 4500
[8] = 2500,
[9] = 4500,
[10] = 7000
},
{
+4 -4
View File
@@ -113,7 +113,7 @@ buildUnitSpawner(
{
unit = {
{
{
type = "attribute",
name = "health",
[1] = 10,
@@ -123,9 +123,9 @@ buildUnitSpawner(
[5] = 750,
[6] = 1000,
[7] = 1500,
[8] = 1500,
[9] = 2500,
[10] = 4500
[8] = 2500,
[9] = 4500,
[10] = 7000
},
{
+1421
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -28,7 +28,7 @@ local createAttackBall = acidBall.createAttackBall
local createStreamAttack = biterUtils.createStreamAttack
local createMeleeAttack = biterUtils.createMeleeAttack
makeSmokeSoft({name="neutral", softSmokeTint=makeColor(0.3, 0.75, 0.3, 0.1)})
local softSmoke = makeSmokeSoft({name="neutral", softSmokeTint=makeColor(0.3, 0.75, 0.3, 0.1)})
-- neutral biters
buildUnitSpawner(
@@ -76,7 +76,7 @@ buildUnitSpawner(
[9] = 0.5,
[10] = 0.5
},
tint = {r=1.0, g=1.0, b=1.0, a=1.0}
tint = {r=0.56, g=0.46, b=0.42, a=0.65}
}
},
@@ -510,7 +510,7 @@ buildUnitSpawner(
explosion = "blood-explosion-small"
},
attack = {
softSmokeName = "neutral-soft-smoke-rampant"
softSmokeName = softSmoke
},
resistances = {},
@@ -567,9 +567,9 @@ buildUnitSpawner(
[5] = 750,
[6] = 1000,
[7] = 1500,
[8] = 1500,
[9] = 2500,
[10] = 4500
[8] = 2500,
[9] = 4500,
[10] = 7000
},
{
@@ -1000,7 +1000,7 @@ buildWorm(
attributes = {},
attack = {
softSmokeName = "neutral-soft-smoke-rampant"
softSmokeName = softSmoke
},
resistances = {},
@@ -1023,7 +1023,7 @@ buildWorm(
},
{
{
{
type = "attribute",
name = "health",
[1] = 200,
@@ -1033,9 +1033,9 @@ buildWorm(
[5] = 900,
[6] = 1000,
[7] = 1500,
[8] = 2250,
[9] = 3000,
[10] = 5000
[8] = 3000,
[9] = 5000,
[10] = 9000
},
{
-2
View File
@@ -102,9 +102,7 @@ function generateLocal()
for t = 1, 10 do
local size = sizes[t]
for v = 1, 20 do
print("inferno-biter-v" .. v .. "-t" .. t .. "-rampant=" .. name .. " biter: " .. size .. " class")
print("inferno-spitter-v" .. v .. "-t" .. t .. "-rampant=" .. name .. " spitter: " .. size .. " class")
print("inferno-biter-nest-v" .. v .. "-t" .. t .. "-rampant=" .. name .. " biter nest: " .. size .. " class")
print("inferno-spitter-nest-v" .. v .. "-t" .. t .. "-rampant=" .. name .. " spitter nest: " .. size .. " class")
print("inferno-worm-v" .. v .. "-t" .. t .. "-rampant=" .. name .. " worm: " .. size .. " class")
end