mirror of
https://github.com/veden/Rampant.git
synced 2024-12-26 20:54:12 +02:00
see changelog
This commit is contained in:
parent
78b8d52aca
commit
453525d987
@ -217,10 +217,12 @@ function upgrade.attempt(natives)
|
||||
game.surfaces[1].print("Rampant - Version 0.16.22")
|
||||
global.version = constants.VERSION_57
|
||||
end
|
||||
if (global.version < constants.VERSION_61) then
|
||||
if (global.version < constants.VERSION_62) then
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.26")
|
||||
global.version = constants.VERSION_61
|
||||
natives.activeSurface = 1
|
||||
|
||||
game.surfaces[1].print("Rampant - Version 0.16.27")
|
||||
global.version = constants.VERSION_62
|
||||
end
|
||||
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,3 +1,12 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.16.27
|
||||
Date: 5. 23. 2018
|
||||
Tweaks:
|
||||
- Changed spawner faction loot drops from green to orange.
|
||||
Improvements:
|
||||
- Changes to player accounting to enable multi player forces in a pvp scenario.
|
||||
- Check for battle_surface_1 & 2 used in pvp and store and use discovered surface index.
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 0.16.26
|
||||
Date: 5. 19. 2018
|
||||
|
31
control.lua
31
control.lua
@ -163,7 +163,7 @@ local function onChunkGenerated(event)
|
||||
end
|
||||
|
||||
local function rebuildMap()
|
||||
game.surfaces[1].print("Rampant - Reindexing chunks, please wait.")
|
||||
game.surfaces[natives.activeSurface].print("Rampant - Reindexing chunks, please wait.")
|
||||
-- clear old map processing Queue
|
||||
-- prevents queue adding duplicate chunks
|
||||
-- chunks are by key, so should overwrite old
|
||||
@ -218,7 +218,7 @@ local function rebuildMap()
|
||||
map.filteredEntitiesWormQuery = { area=map.area, force="enemy", type="turret" }
|
||||
map.filteredEntitiesSpawnerQueryLimited = { area=map.area2, force="enemy", type="unit-spawner" }
|
||||
map.filteredEntitiesWormQueryLimited = { area=map.area2, force="enemy", type="turret" }
|
||||
map.filteredEntitiesPlayerQuery = { area=map.area, force="player" }
|
||||
map.filteredEntitiesPlayerQuery = { area=map.area, force={"enemy", "neutral"}, inverted = "true" }
|
||||
map.canPlaceQuery = { name="", position={0,0} }
|
||||
map.filteredTilesQuery = { name=WATER_TILE_NAMES, area=map.area }
|
||||
|
||||
@ -305,6 +305,13 @@ local function onConfigChanged()
|
||||
local upgraded
|
||||
upgraded, natives = upgrade.attempt(natives)
|
||||
onModSettingsChange(nil)
|
||||
if (game.surfaces["battle_surface_2"]) then
|
||||
natives.activeSurface = game.surfaces["battle_surface_2"].index
|
||||
elseif (game.surfaces["battle_surface_1"]) then
|
||||
natives.activeSurface = game.surfaces["battle_surface_1"].index
|
||||
elseif (game.surfaces["battle_surface_1"]) then
|
||||
natives.activeSurface = game.surfaces["nauvis"].index
|
||||
end
|
||||
if upgraded then
|
||||
rebuildMap()
|
||||
|
||||
@ -313,7 +320,7 @@ local function onConfigChanged()
|
||||
pendingChunks = global.pendingChunks
|
||||
|
||||
-- queue all current chunks that wont be generated during play
|
||||
local surface = game.surfaces[1]
|
||||
local surface = game.surfaces[natives.activeSurface]
|
||||
local tick = game.tick
|
||||
for chunk in surface.get_chunks() do
|
||||
onChunkGenerated({ tick = tick,
|
||||
@ -325,7 +332,7 @@ local function onConfigChanged()
|
||||
processPendingChunks(natives, map, surface, pendingChunks, tick, game.forces.enemy.evolution_factor, true)
|
||||
end
|
||||
if natives.newEnemies then
|
||||
rebuildNativeTables(natives, game.surfaces[1], game.create_random_generator(natives.enemySeed))
|
||||
rebuildNativeTables(natives, game.surfaces[natives.activeSurface], game.create_random_generator(natives.enemySeed))
|
||||
end
|
||||
end
|
||||
|
||||
@ -334,7 +341,7 @@ script.on_nth_tick(INTERVAL_PROCESS,
|
||||
|
||||
local tick = event.tick
|
||||
local gameRef = game
|
||||
local surface = gameRef.surfaces[1]
|
||||
local surface = gameRef.surfaces[natives.activeSurface]
|
||||
|
||||
processPlayers(gameRef.players, map, surface, natives, tick)
|
||||
|
||||
@ -345,7 +352,7 @@ script.on_nth_tick(INTERVAL_SCAN,
|
||||
function (event)
|
||||
local tick = event.tick
|
||||
local gameRef = game
|
||||
local surface = gameRef.surfaces[1]
|
||||
local surface = gameRef.surfaces[natives.activeSurface]
|
||||
|
||||
processPendingChunks(natives, map, surface, pendingChunks, tick, gameRef.forces.enemy.evolution_factor)
|
||||
|
||||
@ -361,7 +368,7 @@ script.on_nth_tick(INTERVAL_LOGIC,
|
||||
function (event)
|
||||
local tick = event.tick
|
||||
local gameRef = game
|
||||
local surface = gameRef.surfaces[1]
|
||||
local surface = gameRef.surfaces[natives.activeSurface]
|
||||
|
||||
planning(natives,
|
||||
gameRef.forces.enemy.evolution_factor,
|
||||
@ -382,7 +389,7 @@ script.on_nth_tick(INTERVAL_SQUAD,
|
||||
regroupSquads(natives, map)
|
||||
|
||||
squadsBeginAttack(natives, gameRef.players)
|
||||
squadsDispatch(map, gameRef.surfaces[1], natives)
|
||||
squadsDispatch(map, gameRef.surfaces[natives.activeSurface], natives)
|
||||
|
||||
end)
|
||||
|
||||
@ -420,7 +427,7 @@ local function onDeath(event)
|
||||
-- drop death pheromone where unit died
|
||||
deathScent(chunk)
|
||||
|
||||
if event.force and (event.force.name == "player") and (chunk[MOVEMENT_PHEROMONE] < natives.retreatThreshold) then
|
||||
if event.force and (event.force.name ~= "enemy") and (chunk[MOVEMENT_PHEROMONE] < natives.retreatThreshold) then
|
||||
local tick = event.tick
|
||||
|
||||
local artilleryBlast = (cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret")))
|
||||
@ -441,7 +448,7 @@ local function onDeath(event)
|
||||
end
|
||||
end
|
||||
|
||||
elseif event.force and (event.force.name == "player") and (entity.type == "unit-spawner") or (entity.type == "turret") then
|
||||
elseif event.force and (event.force.name ~= "enemy") and ((entity.type == "unit-spawner") or (entity.type == "turret")) then
|
||||
local tick = event.tick
|
||||
|
||||
if (chunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||
@ -460,7 +467,7 @@ local function onDeath(event)
|
||||
(cause and ((cause.type == "artillery-wagon") or (cause.type == "artillery-turret"))))
|
||||
end
|
||||
end
|
||||
elseif (entity.force.name == "player") then
|
||||
elseif (entity.force.name ~= "enemy") then
|
||||
local creditNatives = false
|
||||
if (event.force ~= nil) and (event.force.name == "enemy") then
|
||||
creditNatives = true
|
||||
@ -502,7 +509,7 @@ end
|
||||
local function onSurfaceTileChange(event)
|
||||
local surfaceIndex = event.surface_index or (event.robot and event.robot.surface.index)
|
||||
if event.item and (event.item.name == "landfill") and (surfaceIndex == 1) then
|
||||
local surface = game.surfaces[1]
|
||||
local surface = game.surfaces[natives.activeSurface]
|
||||
local chunks = {}
|
||||
local tiles = event.tiles
|
||||
for i=1,#tiles do
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "Rampant",
|
||||
"factorio_version" : "0.16",
|
||||
"version" : "0.16.26",
|
||||
"version" : "0.16.27",
|
||||
"title" : "Rampant",
|
||||
"author" : "Veden",
|
||||
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
||||
|
@ -459,7 +459,7 @@ function chunkUtils.addRemovePlayerEntity(map, entity, natives, addObject, credi
|
||||
local leftTop, rightTop, leftBottom, rightBottom
|
||||
local entityValue
|
||||
|
||||
if (BUILDING_PHEROMONES[entity.type] ~= nil) and (entity.force.name == "player") then
|
||||
if (BUILDING_PHEROMONES[entity.type] ~= nil) and (entity.force.name ~= "enemy") then
|
||||
entityValue = BUILDING_PHEROMONES[entity.type]
|
||||
|
||||
leftTop, rightTop, leftBottom, rightBottom = getEntityOverlapChunks(map, entity)
|
||||
|
@ -21,7 +21,7 @@ constants.VERSION_41 = 41
|
||||
constants.VERSION_44 = 44
|
||||
constants.VERSION_51 = 51
|
||||
constants.VERSION_57 = 57
|
||||
constants.VERSION_61 = 61
|
||||
constants.VERSION_62 = 62
|
||||
|
||||
-- misc
|
||||
|
||||
|
@ -166,7 +166,7 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
|
||||
|
||||
for i=1,#playerOrdering do
|
||||
local player = players[playerOrdering[i]]
|
||||
if validPlayer(player) then
|
||||
if validPlayer(player, natives) then
|
||||
local playerChunk = getChunkByPosition(map, player.character.position)
|
||||
|
||||
if (playerChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||
@ -176,7 +176,7 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
|
||||
end
|
||||
for i=1,#playerOrdering do
|
||||
local player = players[playerOrdering[i]]
|
||||
if validPlayer(player) then
|
||||
if validPlayer(player, natives) then
|
||||
local playerChunk = getChunkByPosition(map, player.character.position)
|
||||
|
||||
if (playerChunk ~= SENTINEL_IMPASSABLE_CHUNK) then
|
||||
|
@ -10,13 +10,13 @@ local euclideanDistanceNamed = mathUtils.euclideanDistanceNamed
|
||||
|
||||
-- module code
|
||||
|
||||
function playerUtils.validPlayer(player)
|
||||
return player and player.valid and player.connected and player.character and player.character.valid and (player.character.surface.index == 1)
|
||||
function playerUtils.validPlayer(player, natives)
|
||||
return player and player.valid and player.connected and player.character and player.character.valid and (player.character.surface.index == natives.activeSurface)
|
||||
end
|
||||
|
||||
function playerUtils.playersWithinProximityToPosition(players, position, distance)
|
||||
function playerUtils.playersWithinProximityToPosition(players, position, distance, natives)
|
||||
for _,player in pairs(players) do
|
||||
if (player ~= nil) and player.connected and (player.character ~= nil) and player.character.valid and (player.character.surface.index == 1) then
|
||||
if (player ~= nil) and player.connected and (player.character ~= nil) and player.character.valid and (player.character.surface.index == natives.activeSurface) then
|
||||
if (euclideanDistanceNamed(player.character.position, position) < distance) then
|
||||
return true
|
||||
end
|
||||
|
@ -230,7 +230,7 @@ function squadAttack.squadsBeginAttack(natives, players)
|
||||
local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
|
||||
|
||||
local groupPosition = group.position
|
||||
if playersWithinProximityToPosition(players, groupPosition, 100) then
|
||||
if playersWithinProximityToPosition(players, groupPosition, 100, natives) then
|
||||
squad.frenzy = true
|
||||
squad.frenzyPosition.x = groupPosition.x
|
||||
squad.frenzyPosition.y = groupPosition.y
|
||||
|
@ -41,9 +41,9 @@ local makeWormAlienLootTable = biterUtils.makeWormAlienLootTable
|
||||
|
||||
function spawner.addFaction()
|
||||
|
||||
local biterLoot = makeUnitAlienLootTable("green")
|
||||
local spawnerLoot = makeSpawnerAlienLootTable("green")
|
||||
local wormLoot = makeWormAlienLootTable("green")
|
||||
local biterLoot = makeUnitAlienLootTable("orange")
|
||||
local spawnerLoot = makeSpawnerAlienLootTable("orange")
|
||||
local wormLoot = makeWormAlienLootTable("orange")
|
||||
|
||||
-- spawner
|
||||
buildUnits(
|
||||
|
28
tests.lua
28
tests.lua
@ -30,7 +30,7 @@ function tests.pheromoneLevels(size)
|
||||
for i=1,#chunk do
|
||||
str = str .. " " .. tostring(i) .. "/" .. tostring(chunk[i])
|
||||
end
|
||||
str = str .. " " .. "p/" .. game.surfaces[1].get_pollution(chunk) .. " " .. "n/" .. chunkPropertyUtils.getNestCount(global.map, chunk) .. " " .. "w/" .. chunkPropertyUtils.getWormCount(global.map, chunk)
|
||||
str = str .. " " .. "p/" .. game.surfaces[natives.activeSurface].get_pollution(chunk) .. " " .. "n/" .. chunkPropertyUtils.getNestCount(global.map, chunk) .. " " .. "w/" .. chunkPropertyUtils.getWormCount(global.map, chunk)
|
||||
if (chunk.x == playerChunkX) and (chunk.y == playerChunkY) then
|
||||
print("=============")
|
||||
print(chunk.x, chunk.y, str)
|
||||
@ -99,7 +99,7 @@ function tests.entitiesOnPlayerChunk()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
local entities = game.surfaces[1].find_entities_filtered({area={{chunkX, chunkY},
|
||||
local entities = game.surfaces[natives.activeSurface].find_entities_filtered({area={{chunkX, chunkY},
|
||||
{chunkX + constants.CHUNK_SIZE, chunkY + constants.CHUNK_SIZE}},
|
||||
force="player"})
|
||||
for i=1, #entities do
|
||||
@ -112,7 +112,7 @@ function tests.findNearestPlayerEnemy()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
local entity = game.surfaces[1].find_nearest_enemy({position={chunkX, chunkY},
|
||||
local entity = game.surfaces[natives.activeSurface].find_nearest_enemy({position={chunkX, chunkY},
|
||||
max_distance=constants.CHUNK_SIZE,
|
||||
force = "enemy"})
|
||||
if (entity ~= nil) then
|
||||
@ -141,7 +141,7 @@ function tests.fillableDirtTest()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
game.surfaces[1].set_tiles({{name="fillableDirt", position={chunkX-1, chunkY-1}},
|
||||
game.surfaces[natives.activeSurface].set_tiles({{name="fillableDirt", position={chunkX-1, chunkY-1}},
|
||||
{name="fillableDirt", position={chunkX, chunkY-1}},
|
||||
{name="fillableDirt", position={chunkX-1, chunkY}},
|
||||
{name="fillableDirt", position={chunkX, chunkY}}},
|
||||
@ -152,7 +152,7 @@ function tests.tunnelTest()
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
game.surfaces[1].create_entity({name="tunnel-entrance-rampant", position={chunkX, chunkY}})
|
||||
game.surfaces[natives.activeSurface].create_entity({name="tunnel-entrance-rampant", position={chunkX, chunkY}})
|
||||
end
|
||||
|
||||
function tests.createEnemy(x,d)
|
||||
@ -163,7 +163,7 @@ function tests.createEnemy(x,d)
|
||||
if d then
|
||||
a['direction'] = d
|
||||
end
|
||||
return game.surfaces[1].create_entity(a)
|
||||
return game.surfaces[natives.activeSurface].create_entity(a)
|
||||
end
|
||||
|
||||
function tests.registeredNest(x)
|
||||
@ -174,7 +174,7 @@ function tests.registeredNest(x)
|
||||
end
|
||||
|
||||
function tests.attackOrigin()
|
||||
local enemy = game.surfaces[1].find_nearest_enemy({position={0,0},
|
||||
local enemy = game.surfaces[natives.activeSurface].find_nearest_enemy({position={0,0},
|
||||
max_distance = 1000})
|
||||
if (enemy ~= nil) and enemy.valid then
|
||||
print(enemy, enemy.unit_number)
|
||||
@ -241,7 +241,7 @@ end
|
||||
|
||||
function tests.clearBases()
|
||||
|
||||
local surface = game.surfaces[1]
|
||||
local surface = game.surfaces[natives.activeSurface]
|
||||
for x=#global.natives.bases,1,-1 do
|
||||
local base = global.natives.bases[x]
|
||||
for c=1,#base.chunks do
|
||||
@ -302,7 +302,7 @@ function tests.showBaseGrid()
|
||||
elseif (pick == 3) then
|
||||
color = "water-green"
|
||||
end
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[1])
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[natives.activeSurface])
|
||||
end
|
||||
end
|
||||
|
||||
@ -318,7 +318,7 @@ function tests.showMovementGrid()
|
||||
elseif (chunk[constants.PASSABLE] == constants.CHUNK_EAST_WEST) then
|
||||
color = "water-green"
|
||||
end
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[1])
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[natives.activeSurface])
|
||||
end
|
||||
end
|
||||
|
||||
@ -334,7 +334,7 @@ function tests.colorResourcePoints()
|
||||
elseif (chunk[constants.NEST_COUNT] ~= 0) then
|
||||
color = "water-green"
|
||||
end
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[1])
|
||||
chunkUtils.colorChunk(chunk.x, chunk.y, color, game.surfaces[natives.activeSurface])
|
||||
end
|
||||
end
|
||||
|
||||
@ -342,7 +342,7 @@ function tests.entityStats(name, d)
|
||||
local playerPosition = game.players[1].position
|
||||
local chunkX = math.floor(playerPosition.x * 0.03125) * 32
|
||||
local chunkY = math.floor(playerPosition.y * 0.03125) * 32
|
||||
local a = game.surfaces[1].create_entity({name=name, position={chunkX, chunkY}})
|
||||
local a = game.surfaces[natives.activeSurface].create_entity({name=name, position={chunkX, chunkY}})
|
||||
if d then
|
||||
a['direction'] = d
|
||||
end
|
||||
@ -393,7 +393,7 @@ function tests.exportAiState()
|
||||
end
|
||||
|
||||
function tests.unitGroupBuild()
|
||||
local surface = game.surfaces[1]
|
||||
local surface = game.surfaces[natives.activeSurface]
|
||||
local group = surface.create_unit_group({position={-32, -32}})
|
||||
|
||||
for i=1,10 do
|
||||
@ -414,7 +414,7 @@ end
|
||||
|
||||
function tests.stepAdvanceTendrils()
|
||||
-- for _, base in pairs(global.natives.bases) do
|
||||
-- tendrilUtils.advanceTendrils(global.map, base, game.surfaces[1], {nil,nil,nil,nil,nil,nil,nil,nil})
|
||||
-- tendrilUtils.advanceTendrils(global.map, base, game.surfaces[natives.activeSurface], {nil,nil,nil,nil,nil,nil,nil,nil})
|
||||
-- end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user