From 874343fa6a99635652050f87f08b3a6aaae6d97e Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Thu, 14 Feb 2019 18:55:40 -0800 Subject: [PATCH] see changelog --- Upgrade.lua | 12 ++++++++++++ changelog.txt | 6 ++++++ control.lua | 3 --- info.json | 2 +- libs/Constants.lua | 1 + libs/SquadAttack.lua | 7 ++----- libs/UnitGroupUtils.lua | 10 +++++----- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Upgrade.lua b/Upgrade.lua index 895604f..0dc92fc 100755 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -2,6 +2,7 @@ local upgrade = {} -- imports +local squadAttack = require("libs/SquadAttack") local constants = require("libs/Constants") local mathUtils = require("libs/MathUtils") @@ -16,6 +17,8 @@ local SQUAD_GUARDING = constants.SQUAD_GUARDING -- imported functions +local scoreAttackLocation = squadAttack.scoreAttackLocation + local roundToNearest = mathUtils.roundToNearest -- module code @@ -242,6 +245,15 @@ function upgrade.attempt(natives) game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.37") global.version = constants.VERSION_72 end + if (global.version < constants.VERSION_73) then + + for _,squad in pairs(natives.squads) do + squad.attackScoreFunction = scoreAttackLocation + end + + game.surfaces[natives.activeSurface].print("Rampant - Version 0.16.38") + global.version = constants.VERSION_73 + end return starting ~= global.version, natives end diff --git a/changelog.txt b/changelog.txt index 8ae4c35..cba9d94 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +--------------------------------------------------------------------------------------------------- +Version: 0.16.38 +Date: 2. 14. 2019 + Bugfixes: + - Fixed squad attack being nil due to timing delay in update + --------------------------------------------------------------------------------------------------- Version: 0.16.37 Date: 2. 10. 2019 diff --git a/control.lua b/control.lua index e320f3d..f32422b 100755 --- a/control.lua +++ b/control.lua @@ -393,10 +393,7 @@ script.on_nth_tick(INTERVAL_SCAN, scanMap(map, surface, natives, tick) - -- map.queueSpawners = processSpawnerChunks(map, surface, natives, tick) - map.chunkToPassScan = processScanChunks(map, surface) - end) script.on_nth_tick(INTERVAL_LOGIC, diff --git a/info.json b/info.json index 68d5210..a59a47e 100755 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name" : "Rampant", "factorio_version" : "0.16", - "version" : "0.16.37", + "version" : "0.16.38", "title" : "Rampant", "author" : "Veden", "homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445", diff --git a/libs/Constants.lua b/libs/Constants.lua index 53721c1..a9d6e83 100755 --- a/libs/Constants.lua +++ b/libs/Constants.lua @@ -22,6 +22,7 @@ constants.VERSION_44 = 44 constants.VERSION_51 = 51 constants.VERSION_57 = 57 constants.VERSION_72 = 72 +constants.VERSION_73 = 73 -- misc diff --git a/libs/SquadAttack.lua b/libs/SquadAttack.lua index 60e8427..b76d05f 100755 --- a/libs/SquadAttack.lua +++ b/libs/SquadAttack.lua @@ -40,8 +40,6 @@ local DEFINES_DISTRACTION_BY_ANYTHING = defines.distraction.by_anything local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK -local RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX = constants.RETREAT_MOVEMENT_PHEROMONE_LEVEL_MAX - -- imported functions local mRandom = math.random @@ -82,7 +80,7 @@ local function scoreSiegeLocation(squad, neighborChunk) return settle - lookupMovementPenalty(squad, neighborChunk) end -local function scoreAttackLocation(natives, squad, neighborChunk) +function squadAttack.scoreAttackLocation(natives, squad, neighborChunk) local damage if (neighborChunk[MOVEMENT_PHEROMONE] >= 0) then @@ -91,7 +89,6 @@ local function scoreAttackLocation(natives, squad, neighborChunk) damage = (neighborChunk[BASE_PHEROMONE] * (1 - (neighborChunk[MOVEMENT_PHEROMONE] / -natives.retreatThreshold))) + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER) end - -- (neighborChunk[BASE_PHEROMONE] ) + (neighborChunk[PLAYER_PHEROMONE] * PLAYER_PHEROMONE_MULTIPLER) return damage - lookupMovementPenalty(squad, neighborChunk) end @@ -263,7 +260,7 @@ function squadAttack.squadsBeginAttack(natives, players) if squad.kamikaze and (mRandom() < (kamikazeThreshold * 0.75)) then squad.attackScoreFunction = scoreAttackKamikazeLocation else - squad.attackScoreFunction = scoreAttackLocation + squad.attackScoreFunction = squadAttack.scoreAttackLocation end squad.status = SQUAD_RAIDING end diff --git a/libs/UnitGroupUtils.lua b/libs/UnitGroupUtils.lua index 225a13e..b986b7d 100755 --- a/libs/UnitGroupUtils.lua +++ b/libs/UnitGroupUtils.lua @@ -276,11 +276,11 @@ function unitGroupUtils.regroupSquads(natives, map) for x=1,#neighbors do local maybeMerge maybeMerge, memberCount, maxed = mergeGroups(getSquadsOnChunk(map, neighbors[x]), - squad, - group, - status, - squadPosition, - memberCount) + squad, + group, + status, + squadPosition, + memberCount) if maybeMerge then mergedSquads = true end