mirror of
https://github.com/veden/Rampant.git
synced 2024-12-26 20:54:12 +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.len = 1
|
||||
end
|
||||
if (global.version < 110) then
|
||||
global.version = 110
|
||||
if (global.version < 111) then
|
||||
global.version = 111
|
||||
|
||||
local gameSurfs
|
||||
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
|
||||
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
|
||||
if entity and entity.valid and (entity.surface.name == natives.activeSurface) then
|
||||
natives.rocketLaunched = natives.rocketLaunched + 1
|
||||
natives.points = natives.points + 2000
|
||||
natives.points = natives.points + 5000
|
||||
end
|
||||
end
|
||||
|
||||
@ -926,22 +926,29 @@ local function onUnitGroupCreated(event)
|
||||
end
|
||||
|
||||
local function onCommandDebugger(event)
|
||||
for i=1,natives.squads.len do
|
||||
if (natives.squads[i].group.valid) and (natives.squads[i].group.group_number == event.unit_number) then
|
||||
local msg
|
||||
if (event.result == defines.behavior_result.in_progress) then
|
||||
msg = "progress"
|
||||
elseif (event.result == defines.behavior_result.fail) then
|
||||
msg = "fail"
|
||||
elseif (event.result == defines.behavior_result.success) then
|
||||
msg = "success"
|
||||
elseif (event.result == defines.behavior_result.deleted) then
|
||||
msg = "deleted"
|
||||
end
|
||||
print(msg, event.unit_number)
|
||||
return
|
||||
end
|
||||
end
|
||||
-- for i=1,natives.squads.len do
|
||||
-- if (natives.squads[i].group.valid) and (natives.squads[i].group.group_number == event.unit_number) then
|
||||
-- local msg
|
||||
-- if (event.result == defines.behavior_result.in_progress) then
|
||||
-- msg = "progress"
|
||||
-- elseif (event.result == defines.behavior_result.fail) then
|
||||
-- msg = "fail"
|
||||
-- elseif (event.result == defines.behavior_result.success) then
|
||||
-- msg = "success"
|
||||
-- elseif (event.result == defines.behavior_result.deleted) then
|
||||
-- msg = "deleted"
|
||||
-- end
|
||||
-- print(msg, event.unit_number)
|
||||
-- return
|
||||
-- end
|
||||
-- end
|
||||
-- if not a then
|
||||
-- a = 0
|
||||
-- end
|
||||
-- a = a + 1
|
||||
-- if ((a % 50) == 0) then
|
||||
-- print("here", a)
|
||||
-- end
|
||||
end
|
||||
|
||||
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_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_rocket_launched, onRocketLaunch)
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "Rampant",
|
||||
"factorio_version" : "0.18",
|
||||
"version" : "0.18.11",
|
||||
"version" : "0.18.12",
|
||||
"title" : "Rampant",
|
||||
"author" : "Veden",
|
||||
"homepage" : "https://forums.factorio.com/viewtopic.php?f=94&t=31445",
|
||||
|
@ -53,21 +53,26 @@ function movementUtils.findMovementPositionDistort(surface, position)
|
||||
return distortPosition(pos, 8)
|
||||
end
|
||||
|
||||
function movementUtils.addMovementPenalty(units, chunk)
|
||||
if (chunk == -1) or (squadChunk == chunk) then
|
||||
function movementUtils.addMovementPenalty(squad, chunk)
|
||||
if (chunk == -1) or (squad.chunk == chunk) then
|
||||
return
|
||||
end
|
||||
local penalties = units.penalties
|
||||
local penalties = squad.penalties
|
||||
for i=1,#penalties do
|
||||
local penalty = penalties[i]
|
||||
if (penalty.c == chunk) then
|
||||
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
|
||||
end
|
||||
end
|
||||
if (#penalties == 7) then
|
||||
tableRemove(penalties, 7)
|
||||
end
|
||||
print(squad.group.group_number)
|
||||
tableInsert(penalties,
|
||||
1,
|
||||
{ v = MOVEMENT_PENALTY_AMOUNT,
|
||||
|
@ -145,7 +145,7 @@ local function settleMove(map, squad, surface)
|
||||
local cmd
|
||||
local position
|
||||
local position2
|
||||
|
||||
|
||||
if (distance >= squad.maxDistance) or ((getResourceGenerator(map, chunk) ~= 0) and (getNestCount(map, chunk) == 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
|
||||
|
||||
targetPosition.x = position.x
|
||||
targetPosition.y = position.y
|
||||
|
||||
targetPosition.y = position.y
|
||||
|
||||
cmd = map.settleCommand
|
||||
if squad.kamikaze then
|
||||
cmd.distraction = DEFINES_DISTRACTION_NONE
|
||||
@ -202,7 +202,7 @@ local function settleMove(map, squad, surface)
|
||||
position = findMovementPosition(surface, targetPosition)
|
||||
|
||||
local attackPlayerThreshold = natives.attackPlayerThreshold
|
||||
|
||||
|
||||
if not position then
|
||||
squad.cycles = 30
|
||||
cmd = map.wonderCommand
|
||||
@ -211,7 +211,7 @@ local function settleMove(map, squad, surface)
|
||||
else
|
||||
targetPosition.x = position.x
|
||||
targetPosition.y = position.y
|
||||
|
||||
|
||||
if (getPlayerBaseGenerator(map, attackChunk) ~= 0) or
|
||||
(attackChunk[PLAYER_PHEROMONE] >= attackPlayerThreshold)
|
||||
then
|
||||
@ -232,7 +232,7 @@ local function settleMove(map, squad, surface)
|
||||
end
|
||||
end
|
||||
|
||||
if (nextAttackChunk ~= -1) then
|
||||
if (nextAttackChunk ~= -1) then
|
||||
positionFromDirectionAndFlat(nextAttackDirection, targetPosition, targetPosition2)
|
||||
|
||||
position2 = findMovementPosition(surface, targetPosition2)
|
||||
@ -492,17 +492,17 @@ end
|
||||
function squadAttack.squadsBeginAttack(natives, surface)
|
||||
local squads = natives.squads
|
||||
local pendingAttack = natives.pendingAttack
|
||||
local pendingStealGroups = natives.pendingStealGroups
|
||||
local pendingStealGroups = natives.pendingStealGroups
|
||||
|
||||
local cmd = natives.map.retreatCommand
|
||||
|
||||
local x = 0
|
||||
|
||||
|
||||
for i=1, pendingStealGroups.len do
|
||||
local group = pendingStealGroups[i]
|
||||
if group and group.valid 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)
|
||||
pendingAttack.len = pendingAttack.len + 1
|
||||
pendingAttack[pendingAttack.len] = squad
|
||||
@ -519,12 +519,12 @@ function squadAttack.squadsBeginAttack(natives, surface)
|
||||
pendingStealGroups.len = x
|
||||
|
||||
x = 0
|
||||
|
||||
|
||||
for i=1,pendingAttack.len do
|
||||
local squad = pendingAttack[i]
|
||||
local group = squad.group
|
||||
if group and group.valid then
|
||||
local groupState = group.state
|
||||
local groupState = group.state
|
||||
if (groupState ~= DEFINES_GROUP_FINISHED) and (squad.cycles ~= 0) then
|
||||
squad.cycles = squad.cycles - 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.y = squadPosition.y
|
||||
end
|
||||
addSquadToChunk(map, chunk, newSquad)
|
||||
addMovementPenalty(newSquad, chunk)
|
||||
addSquadToChunk(map, chunk, newSquad)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user