1
0
mirror of https://github.com/veden/Rampant.git synced 2025-02-05 13:14:51 +02:00

Fixed scanning around player

This commit is contained in:
Aaron Veden 2021-12-05 17:16:14 -08:00
parent 31a8bdfdad
commit 47e20864e1
No known key found for this signature in database
GPG Key ID: FF5990B1C6DD3F84
3 changed files with 34 additions and 28 deletions

View File

@ -13,6 +13,7 @@ Date: 23. 11. 2021
- Added minimum building cost upgrade check before base upgrade performs scanning
- Optimized energy thief faction
- Factorissimo, Space Exploration Orbits, asteroid belts, secret maps, starmap, AAI-signal, NiceFill, Blueprint lab surfaces are no longer processed
- Map processing around player now changes to the surface the player is standing on
Tweaks:
- Increase chance to upgrade an enemy structure from 5% to 30%
- New enemy regional bases that have two factions now do 75% on one faction and 25% on the faction for building and upgrading enemy structures
@ -47,6 +48,7 @@ Date: 23. 11. 2021
- Fixed kastorio creep code be spawned when the building failed to upgrade
- Potential desync fix in relation to reference comparison and deserialization
- Fixed squad attack move would not properly place warding pheromone on taken path
- Fixed players added to a chunk not taking player surface into account when
Framework:
- Fixed Rampant in-memory map visualization tool for debugging
- Added debug mod settings for showing enemy structures being upgraded in place

View File

@ -984,7 +984,7 @@ script.on_event(defines.events.on_tick,
end
cleanUpMapTables(map, tick)
elseif (pick == 1) then
processPlayers(gameRef.connected_players, map, tick)
processPlayers(gameRef.connected_players, universe, tick)
elseif (pick == 2) then
processMap(map, tick)
elseif (pick == 3) then

View File

@ -222,40 +222,40 @@ end
vs
the slower passive version processing the entire map in multiple passes.
--]]
function mapProcessor.processPlayers(players, map, tick)
function mapProcessor.processPlayers(players, universe, tick)
-- put down player pheromone for player hunters
-- randomize player order to ensure a single player isn't singled out
-- not looping everyone because the cost is high enough already in multiplayer
if (#players > 0) then
local player = players[map.random(#players)]
local player = players[universe.random(#players)]
if validPlayer(player) then
if player.surface.index ~= map.surface.index then
return
end
local allowingAttacks = canAttack(map)
local universe = map.universe
local playerChunk = getChunkByPosition(map, player.character.position)
local char = player.character
local map = universe.maps[char.surface.index]
if map then
local allowingAttacks = canAttack(map)
local playerChunk = getChunkByPosition(map, char.position)
if (playerChunk ~= -1) then
local vengence = allowingAttacks and
(map.points >= AI_VENGENCE_SQUAD_COST) and
((getEnemyStructureCount(map, playerChunk) > 0) or
(-getDeathGenerator(map, playerChunk) < -universe.retreatThreshold))
if (playerChunk ~= -1) then
local vengence = allowingAttacks and
(map.points >= AI_VENGENCE_SQUAD_COST) and
((getEnemyStructureCount(map, playerChunk) > 0) or
(-getDeathGenerator(map, playerChunk) < -universe.retreatThreshold))
for x=playerChunk.x - PROCESS_PLAYER_BOUND, playerChunk.x + PROCESS_PLAYER_BOUND, 32 do
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
local chunk = getChunkByXY(map, x, y)
for x=playerChunk.x - PROCESS_PLAYER_BOUND, playerChunk.x + PROCESS_PLAYER_BOUND, 32 do
for y=playerChunk.y - PROCESS_PLAYER_BOUND, playerChunk.y + PROCESS_PLAYER_BOUND, 32 do
local chunk = getChunkByXY(map, x, y)
if (chunk ~= -1) and (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
processPheromone(map, chunk, true)
if (chunk ~= -1) and (chunk[CHUNK_TICK] ~= tick) then
chunk[CHUNK_TICK] = tick
processPheromone(map, chunk, true)
if (getNestCount(map, chunk) > 0) then
processNestActiveness(map, chunk)
queueNestSpawners(map, chunk, tick)
if (getNestCount(map, chunk) > 0) then
processNestActiveness(map, chunk)
queueNestSpawners(map, chunk, tick)
if vengence then
map.vengenceQueue[chunk.id] = (map.vengenceQueue[chunk.id] or 0) + 1
if vengence then
map.vengenceQueue[chunk.id] = (map.vengenceQueue[chunk.id] or 0) + 1
end
end
end
end
@ -268,10 +268,14 @@ function mapProcessor.processPlayers(players, map, tick)
for i=1,#players do
local player = players[i]
if validPlayer(player) then
local playerChunk = getChunkByPosition(map, player.character.position)
local char = player.character
local map = universe.maps[char.surface.index]
if map then
local playerChunk = getChunkByPosition(map, char.position)
if (playerChunk ~= -1) then
addPlayerToChunk(map, playerChunk, player.name)
if (playerChunk ~= -1) then
addPlayerToChunk(map, playerChunk, player.name)
end
end
end
end