Skip to content

Commit

Permalink
see changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
veden committed May 26, 2020
1 parent e671966 commit f781d2e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
---------------------------------------------------------------------------------------------------
Version: 0.18.15
Date: 25. 4 2020
Bugfixes:
- Fixed score resources nil neighborChunk
- Fixed unit group gathering force and squad check

---------------------------------------------------------------------------------------------------
Version: 0.18.14
Date: 25. 4 2020
Expand Down
45 changes: 33 additions & 12 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ local function rebuildMap()
collision_mask = "player-layer",
type={"tree",
"simple-entity"}}

local sharedArea = {{0,0},{0,0}}
map.filteredEntitiesCliffQuery = { area=sharedArea, type="cliff", limit = 1 }
map.filteredTilesPathQuery = { area=sharedArea, collision_mask="water-tile", limit = 1 }
Expand Down Expand Up @@ -898,7 +898,7 @@ local function onSurfaceTileChange(event)
end
end
end
end
end
else
for i=1,#tiles do
local tile = tiles[i]
Expand Down Expand Up @@ -1058,7 +1058,7 @@ local function onUnitGroupCreated(event)
group.destroy()
return
end

local settler = mRandom() < 0.25 and
canMigrate(natives, group.surface) and
(natives.builderCount < natives.AI_MAX_BUILDER_COUNT)
Expand Down Expand Up @@ -1103,24 +1103,45 @@ end

local function onGroupFinishedGathering(event)
local group = event.group
if group.valid then
if group.valid and (group.force.name == "enemy") then
local unitNumber = group.group_number
if (group.surface.name == natives.activeSurface) then
local squad = natives.groupNumberToSquad[unitNumber]
if squad.settler then
if (natives.builderCount < natives.AI_MAX_BUILDER_COUNT) then
squadDispatch(map, group.surface, squad, unitNumber)
if squad then
if squad.settler then
if (natives.builderCount < natives.AI_MAX_BUILDER_COUNT) then
squadDispatch(map, group.surface, squad, unitNumber)
else
group.destroy()
natives.points = natives.points + AI_SETTLER_COST
end
else
group.destroy()
natives.points = natives.points + AI_SETTLER_COST
if (natives.squadCount < natives.AI_MAX_SQUAD_COUNT) then
squadDispatch(map, group.surface, squad, unitNumber)
else
group.destroy()
natives.points = natives.points + AI_SQUAD_COST
end
end
else
if (natives.squadCount < natives.AI_MAX_SQUAD_COUNT) then
squadDispatch(map, group.surface, squad, unitNumber)
else
local settler = mRandom() < 0.25 and
canMigrate(natives, group.surface) and
(natives.builderCount < natives.AI_MAX_BUILDER_COUNT)

if not settler and natives.squadCount > natives.AI_MAX_SQUAD_COUNT then
group.destroy()
natives.points = natives.points + AI_SQUAD_COST
return
end

squad = createSquad(nil, nil, group, settler)
natives.groupNumberToSquad[group.group_number] = squad
if settler then
natives.builderCount = natives.builderCount + 1
else
natives.squadCount = natives.squadCount + 1
end
squadDispatch(map, group.surface, squad, unitNumber)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "Rampant",
"factorio_version" : "0.18",
"version" : "0.18.14",
"version" : "0.18.15",
"title" : "Rampant",
"author" : "Veden",
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
Expand Down
2 changes: 1 addition & 1 deletion libs/MovementUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function movementUtils.scoreNeighborsForResource(chunk, neighborDirectionChunks,
end
end

if (chunk ~= -1) and (scoreFunction(chunk) > highestScore) then
if (chunk ~= -1) and (scoreFunction(map, chunk) > highestScore) then
return -1, -1
end

Expand Down

0 comments on commit f781d2e

Please sign in to comment.