mirror of
https://github.com/veden/Rampant.git
synced 2024-12-28 21:08:22 +02:00
looking into command completion again
This commit is contained in:
parent
0021bab1c3
commit
921a93d053
@ -127,8 +127,8 @@ function upgrade.attempt(natives, setNewSurface, gameSurfaces)
|
|||||||
natives.pendingStealGroups = {}
|
natives.pendingStealGroups = {}
|
||||||
natives.pendingStealGroups.len = 1
|
natives.pendingStealGroups.len = 1
|
||||||
end
|
end
|
||||||
if (global.version < 110) then
|
if (global.version < 111) then
|
||||||
global.version = 110
|
global.version = 111
|
||||||
|
|
||||||
local gameSurfs
|
local gameSurfs
|
||||||
if not gameSurfaces then
|
if not gameSurfaces then
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
---------------------------------------------------------------------------------------------------
|
||||||
|
Version: 0.18.12
|
||||||
|
Date: 16. 4 2020
|
||||||
|
Tweaks:
|
||||||
|
- Changed ai credits per rocket launched to 5000
|
||||||
|
Bugfixes:
|
||||||
|
- fixed add movement penalty not using squad chunk
|
||||||
|
|
||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 0.18.11
|
Version: 0.18.11
|
||||||
Date: 13. 4 2020
|
Date: 13. 4 2020
|
||||||
|
43
control.lua
43
control.lua
@ -846,7 +846,7 @@ local function onRocketLaunch(event)
|
|||||||
local entity = event.rocket_silo or event.rocket
|
local entity = event.rocket_silo or event.rocket
|
||||||
if entity and entity.valid and (entity.surface.name == natives.activeSurface) then
|
if entity and entity.valid and (entity.surface.name == natives.activeSurface) then
|
||||||
natives.rocketLaunched = natives.rocketLaunched + 1
|
natives.rocketLaunched = natives.rocketLaunched + 1
|
||||||
natives.points = natives.points + 2000
|
natives.points = natives.points + 5000
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -926,22 +926,29 @@ local function onUnitGroupCreated(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function onCommandDebugger(event)
|
local function onCommandDebugger(event)
|
||||||
for i=1,natives.squads.len do
|
-- for i=1,natives.squads.len do
|
||||||
if (natives.squads[i].group.valid) and (natives.squads[i].group.group_number == event.unit_number) then
|
-- if (natives.squads[i].group.valid) and (natives.squads[i].group.group_number == event.unit_number) then
|
||||||
local msg
|
-- local msg
|
||||||
if (event.result == defines.behavior_result.in_progress) then
|
-- if (event.result == defines.behavior_result.in_progress) then
|
||||||
msg = "progress"
|
-- msg = "progress"
|
||||||
elseif (event.result == defines.behavior_result.fail) then
|
-- elseif (event.result == defines.behavior_result.fail) then
|
||||||
msg = "fail"
|
-- msg = "fail"
|
||||||
elseif (event.result == defines.behavior_result.success) then
|
-- elseif (event.result == defines.behavior_result.success) then
|
||||||
msg = "success"
|
-- msg = "success"
|
||||||
elseif (event.result == defines.behavior_result.deleted) then
|
-- elseif (event.result == defines.behavior_result.deleted) then
|
||||||
msg = "deleted"
|
-- msg = "deleted"
|
||||||
end
|
-- end
|
||||||
print(msg, event.unit_number)
|
-- print(msg, event.unit_number)
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
-- if not a then
|
||||||
|
-- a = 0
|
||||||
|
-- end
|
||||||
|
-- a = a + 1
|
||||||
|
-- if ((a % 50) == 0) then
|
||||||
|
-- print("here", a)
|
||||||
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onForceCreated(event)
|
local function onForceCreated(event)
|
||||||
@ -1118,7 +1125,7 @@ script.on_event({defines.events.on_built_entity,
|
|||||||
defines.events.script_raised_built,
|
defines.events.script_raised_built,
|
||||||
defines.events.script_raised_revive}, onBuild)
|
defines.events.script_raised_revive}, onBuild)
|
||||||
|
|
||||||
-- script.on_event(defines.events.on_ai_command_completed, onCommandDebugger)
|
script.on_event(defines.events.on_ai_command_completed, onCommandDebugger)
|
||||||
script.on_event(defines.events.on_entity_spawned, onEntitySpawned)
|
script.on_event(defines.events.on_entity_spawned, onEntitySpawned)
|
||||||
|
|
||||||
script.on_event(defines.events.on_rocket_launched, onRocketLaunch)
|
script.on_event(defines.events.on_rocket_launched, onRocketLaunch)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name" : "Rampant",
|
"name" : "Rampant",
|
||||||
"factorio_version" : "0.18",
|
"factorio_version" : "0.18",
|
||||||
"version" : "0.18.11",
|
"version" : "0.18.12",
|
||||||
"title" : "Rampant",
|
"title" : "Rampant",
|
||||||
"author" : "Veden",
|
"author" : "Veden",
|
||||||
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
||||||
|
@ -53,21 +53,26 @@ function movementUtils.findMovementPositionDistort(surface, position)
|
|||||||
return distortPosition(pos, 8)
|
return distortPosition(pos, 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
function movementUtils.addMovementPenalty(units, chunk)
|
function movementUtils.addMovementPenalty(squad, chunk)
|
||||||
if (chunk == -1) or (squadChunk == chunk) then
|
if (chunk == -1) or (squad.chunk == chunk) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local penalties = units.penalties
|
local penalties = squad.penalties
|
||||||
for i=1,#penalties do
|
for i=1,#penalties do
|
||||||
local penalty = penalties[i]
|
local penalty = penalties[i]
|
||||||
if (penalty.c == chunk) then
|
if (penalty.c == chunk) then
|
||||||
penalty.v = (2 * penalty.v) + MOVEMENT_PENALTY_AMOUNT
|
penalty.v = (2 * penalty.v) + MOVEMENT_PENALTY_AMOUNT
|
||||||
|
print(penalty.v)
|
||||||
|
if (penalty.v > MOVEMENT_PENALTY_AMOUNT * 5) then
|
||||||
|
print("erel", penalty, squad.group.group_number)
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (#penalties == 7) then
|
if (#penalties == 7) then
|
||||||
tableRemove(penalties, 7)
|
tableRemove(penalties, 7)
|
||||||
end
|
end
|
||||||
|
print(squad.group.group_number)
|
||||||
tableInsert(penalties,
|
tableInsert(penalties,
|
||||||
1,
|
1,
|
||||||
{ v = MOVEMENT_PENALTY_AMOUNT,
|
{ v = MOVEMENT_PENALTY_AMOUNT,
|
||||||
|
@ -145,7 +145,7 @@ local function settleMove(map, squad, surface)
|
|||||||
local cmd
|
local cmd
|
||||||
local position
|
local position
|
||||||
local position2
|
local position2
|
||||||
|
|
||||||
if (distance >= squad.maxDistance) or ((getResourceGenerator(map, chunk) ~= 0) and (getNestCount(map, chunk) == 0))
|
if (distance >= squad.maxDistance) or ((getResourceGenerator(map, chunk) ~= 0) and (getNestCount(map, chunk) == 0))
|
||||||
then
|
then
|
||||||
if not ((groupState == DEFINES_GROUP_FINISHED) or ((groupState == DEFINES_GROUP_GATHERING) and (squad.cycles <= 0))) then
|
if not ((groupState == DEFINES_GROUP_FINISHED) or ((groupState == DEFINES_GROUP_GATHERING) and (squad.cycles <= 0))) then
|
||||||
@ -159,8 +159,8 @@ local function settleMove(map, squad, surface)
|
|||||||
end
|
end
|
||||||
|
|
||||||
targetPosition.x = position.x
|
targetPosition.x = position.x
|
||||||
targetPosition.y = position.y
|
targetPosition.y = position.y
|
||||||
|
|
||||||
cmd = map.settleCommand
|
cmd = map.settleCommand
|
||||||
if squad.kamikaze then
|
if squad.kamikaze then
|
||||||
cmd.distraction = DEFINES_DISTRACTION_NONE
|
cmd.distraction = DEFINES_DISTRACTION_NONE
|
||||||
@ -202,7 +202,7 @@ local function settleMove(map, squad, surface)
|
|||||||
position = findMovementPosition(surface, targetPosition)
|
position = findMovementPosition(surface, targetPosition)
|
||||||
|
|
||||||
local attackPlayerThreshold = natives.attackPlayerThreshold
|
local attackPlayerThreshold = natives.attackPlayerThreshold
|
||||||
|
|
||||||
if not position then
|
if not position then
|
||||||
squad.cycles = 30
|
squad.cycles = 30
|
||||||
cmd = map.wonderCommand
|
cmd = map.wonderCommand
|
||||||
@ -211,7 +211,7 @@ local function settleMove(map, squad, surface)
|
|||||||
else
|
else
|
||||||
targetPosition.x = position.x
|
targetPosition.x = position.x
|
||||||
targetPosition.y = position.y
|
targetPosition.y = position.y
|
||||||
|
|
||||||
if (getPlayerBaseGenerator(map, attackChunk) ~= 0) or
|
if (getPlayerBaseGenerator(map, attackChunk) ~= 0) or
|
||||||
(attackChunk[PLAYER_PHEROMONE] >= attackPlayerThreshold)
|
(attackChunk[PLAYER_PHEROMONE] >= attackPlayerThreshold)
|
||||||
then
|
then
|
||||||
@ -232,7 +232,7 @@ local function settleMove(map, squad, surface)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (nextAttackChunk ~= -1) then
|
if (nextAttackChunk ~= -1) then
|
||||||
positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2)
|
positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2)
|
||||||
|
|
||||||
position2 = findMovementPosition(surface, targetPosition2)
|
position2 = findMovementPosition(surface, targetPosition2)
|
||||||
@ -492,17 +492,17 @@ end
|
|||||||
function squadAttack.squadsBeginAttack(natives, surface)
|
function squadAttack.squadsBeginAttack(natives, surface)
|
||||||
local squads = natives.squads
|
local squads = natives.squads
|
||||||
local pendingAttack = natives.pendingAttack
|
local pendingAttack = natives.pendingAttack
|
||||||
local pendingStealGroups = natives.pendingStealGroups
|
local pendingStealGroups = natives.pendingStealGroups
|
||||||
|
|
||||||
local cmd = natives.map.retreatCommand
|
local cmd = natives.map.retreatCommand
|
||||||
|
|
||||||
local x = 0
|
local x = 0
|
||||||
|
|
||||||
for i=1, pendingStealGroups.len do
|
for i=1, pendingStealGroups.len do
|
||||||
local group = pendingStealGroups[i]
|
local group = pendingStealGroups[i]
|
||||||
if group and group.valid then
|
if group and group.valid then
|
||||||
if (group.state ~= DEFINES_GROUP_GATHERING) then
|
if (group.state ~= DEFINES_GROUP_GATHERING) then
|
||||||
local settlers = canMigrate(natives, surface) and (mRandom() > 0.25)
|
local settlers = canMigrate(natives, surface) and (mRandom() > 0.25)
|
||||||
local squad = createSquad(group.position, surface, nil, settlers)
|
local squad = createSquad(group.position, surface, nil, settlers)
|
||||||
pendingAttack.len = pendingAttack.len + 1
|
pendingAttack.len = pendingAttack.len + 1
|
||||||
pendingAttack[pendingAttack.len] = squad
|
pendingAttack[pendingAttack.len] = squad
|
||||||
@ -519,12 +519,12 @@ function squadAttack.squadsBeginAttack(natives, surface)
|
|||||||
pendingStealGroups.len = x
|
pendingStealGroups.len = x
|
||||||
|
|
||||||
x = 0
|
x = 0
|
||||||
|
|
||||||
for i=1,pendingAttack.len do
|
for i=1,pendingAttack.len do
|
||||||
local squad = pendingAttack[i]
|
local squad = pendingAttack[i]
|
||||||
local group = squad.group
|
local group = squad.group
|
||||||
if group and group.valid then
|
if group and group.valid then
|
||||||
local groupState = group.state
|
local groupState = group.state
|
||||||
if (groupState ~= DEFINES_GROUP_FINISHED) and (squad.cycles ~= 0) then
|
if (groupState ~= DEFINES_GROUP_FINISHED) and (squad.cycles ~= 0) then
|
||||||
squad.cycles = squad.cycles - 1
|
squad.cycles = squad.cycles - 1
|
||||||
x = x + 1
|
x = x + 1
|
||||||
|
@ -146,8 +146,8 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, tick, radi
|
|||||||
newSquad.frenzyPosition.x = squadPosition.x
|
newSquad.frenzyPosition.x = squadPosition.x
|
||||||
newSquad.frenzyPosition.y = squadPosition.y
|
newSquad.frenzyPosition.y = squadPosition.y
|
||||||
end
|
end
|
||||||
addSquadToChunk(map, chunk, newSquad)
|
|
||||||
addMovementPenalty(newSquad, chunk)
|
addMovementPenalty(newSquad, chunk)
|
||||||
|
addSquadToChunk(map, chunk, newSquad)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user