mirror of
https://github.com/veden/Rampant.git
synced 2025-01-30 04:30:52 +02:00
fixed resource pheromone
This commit is contained in:
parent
76665ef603
commit
49a834285b
@ -334,6 +334,9 @@ function upgrade.attempt(natives)
|
||||
end
|
||||
end
|
||||
|
||||
natives.baseOrdering = {}
|
||||
natives.baseOrdering.len = 0
|
||||
|
||||
natives.pendingAttack.len = #natives.pendingAttack
|
||||
natives.squads.len = #natives.squads
|
||||
natives.maxOverflowPoints = AI_MAX_OVERFLOW_POINTS
|
||||
|
@ -259,6 +259,8 @@ local function rebuildMap()
|
||||
SENTINEL_IMPASSABLE_CHUNK
|
||||
}
|
||||
|
||||
map.mapOrdering = {}
|
||||
map.mapOrdering.len = 0
|
||||
map.enemiesToSquad = {}
|
||||
map.enemiesToSquad.len = 0
|
||||
map.chunkRemovals = {}
|
||||
|
@ -175,17 +175,20 @@ local mRandom = math.random
|
||||
|
||||
-- module code
|
||||
|
||||
local function nonRepeatingRandom(evoTable, rg)
|
||||
local ordering = {}
|
||||
local function nonRepeatingRandom(natives, evoTable, rg)
|
||||
local ordering = natives.baseOrdering
|
||||
local baseCount = 0
|
||||
for evo in pairs(evoTable) do
|
||||
ordering[#ordering+1] = evo
|
||||
baseCount = baseCount + 1
|
||||
ordering[baseCount] = evo
|
||||
end
|
||||
for i=#ordering,1,-1 do
|
||||
for i=baseCount,1,-1 do
|
||||
local s = rg(i)
|
||||
local t = ordering[i]
|
||||
ordering[i] = ordering[s]
|
||||
ordering[s] = t
|
||||
end
|
||||
ordering.len = baseCount
|
||||
return ordering
|
||||
end
|
||||
|
||||
@ -316,8 +319,9 @@ local function findBaseInitialAlignment(evoIndex, natives, evolutionTable)
|
||||
|
||||
local pickedEvo
|
||||
local alignment
|
||||
for i=1,#natives.evolutionTableAlignmentOrder do
|
||||
local evo = natives.evolutionTableAlignmentOrder[i]
|
||||
local alignmentTable = natives.evolutionTableAlignmentOrder
|
||||
for i=1,alignmentTable.len do
|
||||
local evo = alignmentTable[i]
|
||||
local entitySet = evolutionTable[evo]
|
||||
if (evo <= evoTop) and entitySet and (#entitySet > 0) then
|
||||
if not pickedEvo then
|
||||
@ -413,11 +417,11 @@ function baseUtils.upgradeEntity(entity, surface, baseAlignment, natives, evolut
|
||||
end
|
||||
|
||||
local function findMutation(natives, evolutionFactor)
|
||||
local shuffled = nonRepeatingRandom(natives.evolutionTableAlignment, natives.randomGenerator)
|
||||
local shuffled = nonRepeatingRandom(natives, natives.evolutionTableAlignment, natives.randomGenerator)
|
||||
local evoTable = natives.evolutionTableAlignment
|
||||
local alignment
|
||||
|
||||
for i=1,#shuffled do
|
||||
for i=1,shuffled.len do
|
||||
local evo = shuffled[i]
|
||||
if (evo <= evolutionFactor) then
|
||||
local alignmentSet = evoTable[evo]
|
||||
@ -655,7 +659,7 @@ function baseUtils.rebuildNativeTables(natives, surface, rg)
|
||||
natives.evolutionTableAlignment)
|
||||
end
|
||||
|
||||
natives.evolutionTableAlignmentOrder = nonRepeatingRandom(natives.evolutionTableAlignment, natives.randomGenerator)
|
||||
natives.evolutionTableAlignmentOrder = nonRepeatingRandom(natives, natives.evolutionTableAlignment, natives.randomGenerator)
|
||||
|
||||
if ENABLED_NE_UNITS then
|
||||
processNEUnitClass(natives, surface)
|
||||
|
@ -359,19 +359,19 @@ if constants.ENABLED_NE_UNITS then
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE] = 0.1
|
||||
|
||||
if settings.startup["NE_Blue_Spawners"].value then
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_BLUE] = 0.1
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_BLUE] = 0.1
|
||||
end
|
||||
if settings.startup["NE_Red_Spawners"].value then
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_RED] = 0.1
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_RED] = 0.1
|
||||
end
|
||||
if settings.startup["NE_Pink_Spawners"].value then
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_PINK] = 0.1
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_PINK] = 0.1
|
||||
end
|
||||
if settings.startup["NE_Green_Spawners"].value then
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_GREEN] = 0.1
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_GREEN] = 0.1
|
||||
end
|
||||
if settings.startup["NE_Yellow_Spawners"].value then
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_YELLOW] = 0.1
|
||||
constants.BASE_ALIGNMENT_EVOLUTION_BASELINE[constants.BASE_ALIGNMENT_NE_YELLOW] = 0.1
|
||||
end
|
||||
end
|
||||
|
||||
@ -599,8 +599,8 @@ local function buildTier(size, tiers)
|
||||
local step = (tierEnd - tierStart) / (size - 1)
|
||||
local i = tierStart
|
||||
for _=1,size do
|
||||
tiers[#tiers+1] = roundToNearest(i, 1)
|
||||
i = i + step
|
||||
tiers[#tiers+1] = roundToNearest(i, 1)
|
||||
i = i + step
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,17 +89,20 @@ local mRandom = math.random
|
||||
|
||||
-- module code
|
||||
|
||||
local function nonRepeatingRandom(players)
|
||||
local ordering = {}
|
||||
local function nonRepeatingRandom(map, players)
|
||||
local ordering = map.mapOrdering
|
||||
local playerCount = 0
|
||||
for _,player in pairs(players) do
|
||||
ordering[#ordering+1] = player.index
|
||||
playerCount = playerCount + 1
|
||||
ordering[playerCount] = player.index
|
||||
end
|
||||
for i=#ordering,1,-1 do
|
||||
for i=playerCount,1,-1 do
|
||||
local s = mRandom(i)
|
||||
local t = ordering[i]
|
||||
ordering[i] = ordering[s]
|
||||
ordering[s] = t
|
||||
end
|
||||
ordering.len = playerCount
|
||||
return ordering
|
||||
end
|
||||
|
||||
@ -181,7 +184,7 @@ end
|
||||
function mapProcessor.processPlayers(players, map, surface, natives, tick)
|
||||
-- put down player pheromone for player hunters
|
||||
-- randomize player order to ensure a single player isn't singled out
|
||||
local playerOrdering = nonRepeatingRandom(players)
|
||||
local playerOrdering = nonRepeatingRandom(map, players)
|
||||
|
||||
local roll = mRandom()
|
||||
|
||||
@ -192,7 +195,7 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
|
||||
local squads = allowingAttacks and (0.11 <= roll) and (roll <= 0.20) and (natives.points >= AI_SQUAD_COST)
|
||||
|
||||
-- not looping everyone because the cost is high enough already in multiplayer
|
||||
if (#playerOrdering > 0) then
|
||||
if (playerOrdering.len > 0) then
|
||||
local player = players[playerOrdering[1]]
|
||||
if validPlayer(player, natives) then
|
||||
local playerChunk = getChunkByPosition(map, player.character.position)
|
||||
@ -261,7 +264,7 @@ function mapProcessor.processPlayers(players, map, surface, natives, tick)
|
||||
end
|
||||
end
|
||||
|
||||
for i=1,#playerOrdering do
|
||||
for i=1,playerOrdering.len do
|
||||
local player = players[playerOrdering[i]]
|
||||
if validPlayer(player, natives) then
|
||||
local playerChunk = getChunkByPosition(map, player.character.position)
|
||||
|
@ -83,7 +83,9 @@ function pheromoneUtils.commitPheromone(map, chunk, staging, tick)
|
||||
chunk[BASE_PHEROMONE] = staging[BASE_PHEROMONE] + getPlayerBaseGenerator(map, chunk)
|
||||
chunk[PLAYER_PHEROMONE] = staging[PLAYER_PHEROMONE]
|
||||
if (resourceGenerator > 0) and (getEnemyStructureCount(map, chunk) == 0) then
|
||||
chunk[RESOURCE_PHEROMONE] = staging[RESOURCE_PHEROMONE] + (linearInterpolation(resourceGenerator, 15000, 20000))
|
||||
chunk[RESOURCE_PHEROMONE] = staging[RESOURCE_PHEROMONE] + (linearInterpolation(resourceGenerator, 15000, 20000))
|
||||
else
|
||||
chunk[RESOURCE_PHEROMONE] = staging[RESOURCE_PHEROMONE]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
||||
(define siteBox2 (new message%
|
||||
[parent panel]
|
||||
[label ""]
|
||||
[vert-margin 270]))
|
||||
[vert-margin 300]))
|
||||
|
||||
(new button%
|
||||
[parent mainFrame]
|
||||
|
Loading…
x
Reference in New Issue
Block a user