Skip to content

Commit

Permalink
deployed v0.4.11
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranf committed Aug 17, 2021
1 parent f7fd556 commit 55fb50e
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 33 deletions.
12 changes: 11 additions & 1 deletion Changelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@ changes from 0.4.8 to 0.4.9:
- upgrading the version requirement of Unit Control (optional mod) to 3.10 for supporting the new API
- fixes to how the mod uses the new Unit Control API for raising unit events from known deployers.
- adding Guard Station to deployer supported for Unit Control
- reducing how/when the guard and assembler stations try to run logic when spawning units while Unit Control is active. Basically all droid processing is halted.
- reducing how/when the guard and assembler stations try to run logic when spawning units while Unit Control is active. Basically all droid processing is halted.

changes from 0.4.9 to 0.4.10:
- if unit control is active, don't run the runtime logic for assemblers squad management/merging/retreat and assembler-centric targetting,
and don't run the squad logic at all. This should help in-progress games which add unit control halfway through.
- added ai_settings to all droid units and flying units to try to prevent units from being deleted if they fail a command, and for them to attempt to spread out from eachother and not stack up.

changes from 0.4.10 to 0.4.11:
- added a for-each-force loop instead of specific forces, during init routine to set up each force
- added a handleOnScriptRaisedBuilt function for script-spawned entity event handling.
- adding migration file to help players who add mod after starting game to auto detect existing techs and unlock recipes properly for them.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Robot Army mod for Factorio V1.1+

## Version
0.4.9,
Known to be compatible with Factorio v1.1.37. Requires at least v1.1.1 due to mod script API changes and tech name changes.
0.4.11,
Known to be compatible with Factorio v1.1.37. Requires at least v1.1.5 due to mod script API changes and tech name changes.


## Description
Expand Down
11 changes: 5 additions & 6 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ function init_robotarmy()

--deal with player force as default set-up process
event = {} --event stub, to match function inputs
event.force = game.forces["player"]
handleForceCreated(event)
event.force = game.forces["enemy"]
handleForceCreated(event)
event.force = game.forces["neutral"]
handleForceCreated(event)
for _, v in pairs(game.forces) do
event.force = v
handleForceCreated(event)
end
LOGGER.log("Robot Army mod Init script finished...")
game.print("Robot Army mod Init completed!")
end
Expand All @@ -66,6 +64,7 @@ script.on_init(init_robotarmy)
script.on_event(defines.events.on_force_created, handleForceCreated)
script.on_event(defines.events.on_built_entity, handleOnBuiltEntity)
script.on_event(defines.events.on_robot_built_entity, handleOnRobotBuiltEntity)
script.on_event(defines.events.script_raised_built, handleOnScriptRaisedBuilt)

function playerSelectedArea(event)
reportSelectedUnits(event, false)
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": "robotarmy",
"version": "0.4.9",
"version": "0.4.11",
"title": "Robot Army",
"author": "Kyranzor",
"contact": "[email protected]",
Expand Down
55 changes: 55 additions & 0 deletions migrations/robotarmy_0.4.11.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require("config.config")
game.reload_script()


--ensure all force-specific tables and researches are handled/created
for i, force in pairs(game.forces) do
force.reset_recipes()
force.reset_technologies()

--force all of the known recipes to be enabled if the appropriate research is already done.
if force.technologies["military"].researched then
force.recipes["droid-rifle"].enabled=true
force.recipes["droid-rifle-deploy"].enabled=true
if(GRAB_ARTIFACTS == 1) then
force.recipes["loot-chest"].enabled=true
end
force.recipes["patrol-pole"].enabled=true
force.recipes["droid-guard-station"].enabled=true
force.recipes["droid-assembling-machine"].enabled=true
force.recipes["droid-pickup-tool"].enabled=true
force.recipes["droid-selection-tool"].enabled=true
force.recipes["droid-counter"].enabled=true
force.recipes["droid-settings"].enabled = true
end


if force.technologies["military-2"].researched then
force.recipes["droid-smg"].enabled=true
force.recipes["droid-smg-deploy"].enabled=true
force.recipes["droid-rocket"].enabled=true
force.recipes["droid-rocket-deploy"].enabled=true
force.recipes["droid-flame"].enabled=true
force.recipes["droid-flame-deploy"].enabled=true
end

if force.technologies["military-3"].researched then
force.recipes["terminator"].enabled=true
force.recipes["terminator-deploy"].enabled=true
end

if force.technologies["defender"].researched then
force.recipes["defender-unit"].enabled=true
force.recipes["defender-unit-deploy"].enabled=true
end

if force.technologies["distractor"].researched then
force.recipes["distractor-unit"].enabled=true
force.recipes["distractor-unit-deploy"].enabled=true
end
if force.technologies["destroyer"].researched then
force.recipes["destroyer-unit"].enabled=true
force.recipes["destroyer-unit-deploy"].enabled=true
end

end
28 changes: 19 additions & 9 deletions prototypes/defender-unit.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require("config.config")
data:extend({
{
type = "unit",
name = "defender-unit",
icon_size = 32,
icon = "__base__/graphics/icons/defender.png",
flags = {"placeable-player", "player-creation", "placeable-off-grid"},
subgroup="creatures",
has_belt_immunity = true,
max_health = 65 * HEALTH_SCALAR,
type = "unit",
name = "defender-unit",
icon_size = 32,
icon = "__base__/graphics/icons/defender.png",
flags = {"placeable-player", "player-creation", "placeable-off-grid"},
subgroup="creatures",
has_belt_immunity = true,
max_health = 65 * HEALTH_SCALAR,
minable = {hardness = 0.1, mining_time = 0.1, result = "defender-unit"},
alert_when_damaged = false,
order="b-b-a",
Expand All @@ -17,7 +17,12 @@ data:extend({
{
type = "physical",
decrease = 4,
}
},
{
type = "acid",
decrease = 1,
percent = 30
},
},
healing_per_tick = 0,
collision_box = nil,
Expand All @@ -26,6 +31,11 @@ data:extend({
sticker_box = {{-0.1, -0.1}, {0.1, 0.1}},
distraction_cooldown = 300,

ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},

attack_parameters =
{
Expand Down
16 changes: 13 additions & 3 deletions prototypes/destroyer-unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ data:extend({
{
{
type = "physical",
decrease = 4,
}
decrease = 8,
},
{
type = "acid",
decrease = 5,
percent = 70
},
},
healing_per_tick = 0,
collision_box = {{0, 0}, {0, 0}},
selection_box = {{-0.3, -0.3}, {0.3, 0.3}},
sticker_box = {{-0.1, -0.1}, {0.1, 0.1}},
distraction_cooldown = 300,


ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},

attack_parameters =
{
type = "beam",
Expand Down
14 changes: 12 additions & 2 deletions prototypes/distractor-unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ data:extend({
{
type = "physical",
decrease = 4,
}
},
{
type = "acid",
decrease = 1,
percent = 30
},
},
healing_per_tick = 0,
collision_box = {{0, 0}, {0, 0}},
selection_box = {{-0.3, -0.3}, {0.3, 0.3}},
sticker_box = {{-0.1, -0.1}, {0.1, 0.1}},
distraction_cooldown = 300,


ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},

attack_parameters =
{
Expand Down
29 changes: 27 additions & 2 deletions prototypes/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ local droid_smg =
vision_distance = 30,
radar_range = 1,
can_open_gates = true,
ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},
movement_speed = 0.11,
minable = {hardness = 0.1, mining_time = 0.1, result = "droid-smg"},
pollution_to_join_attack = 0.0,
Expand All @@ -144,9 +149,9 @@ local droid_smg =
decrease = 1,
percent = 30
},
{
{
type = "fire",
decrease = 5,
decrease = 5,
percent = 95
}
},
Expand Down Expand Up @@ -296,6 +301,11 @@ local droid_flame =
vision_distance = 30,
radar_range = 1,
can_open_gates = true,
ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},
movement_speed = 0.09,
minable = {hardness = 0.1, mining_time = 0.1, result = "droid-flame"},
pollution_to_join_attack = 0.0,
Expand Down Expand Up @@ -480,6 +490,11 @@ local droid_rifle =
vision_distance = 30,
radar_range = 1,
can_open_gates = true,
ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},
movement_speed = 0.08,
friendly_map_color = droidMapColour,
minable = {hardness = 0.1, mining_time = 0.1, result = "droid-rifle"},
Expand Down Expand Up @@ -659,6 +674,11 @@ local droid_rocket =
vision_distance = 30,
radar_range = 1,
can_open_gates = true,
ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},
friendly_map_color = droidMapColour,
movement_speed = 0.11,
minable = {hardness = 0.1, mining_time = 0.1, result = "droid-rocket"},
Expand Down Expand Up @@ -823,6 +843,11 @@ local terminator =
vision_distance = 30,
radar_range = 1,
can_open_gates = true,
ai_settings =
{
allow_destroy_when_commands_fail = false,
do_separation = true
},
movement_speed = 0.18,
minable = {hardness = 0.1, mining_time = 0.1, result = "terminator"},
pollution_to_join_attack = 0.0,
Expand Down
5 changes: 3 additions & 2 deletions prototypes/recipe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",re
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-guard-station"})
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-selection-tool"})
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-pickup-tool"})
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-counter"})
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-settings"})

table.insert(data.raw["technology"]["military-2"].effects,{type="unlock-recipe",recipe="droid-smg-deploy"})
table.insert(data.raw["technology"]["military-2"].effects,{type="unlock-recipe",recipe="droid-smg"})
Expand All @@ -351,8 +353,7 @@ table.insert(data.raw["technology"]["military-2"].effects,{type="unlock-recipe",
table.insert(data.raw["technology"]["military-3"].effects,{type="unlock-recipe",recipe="terminator-deploy"})
table.insert(data.raw["technology"]["military-3"].effects,{type="unlock-recipe",recipe="terminator"})

table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-counter"})
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-settings"})


table.insert(data.raw["technology"]["defender"].effects,{type="unlock-recipe", recipe="defender-unit"})
table.insert(data.raw["technology"]["defender"].effects,{type="unlock-recipe", recipe="defender-unit-deploy"})
Expand Down
2 changes: 1 addition & 1 deletion robolib/Squad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ function orderSquadToAttack(squad, position)
debugSquadOrder(squad, "*ATTACK*", position)
squad.unitGroup.set_command({type=defines.command.attack_area,
destination=position,
radius=50, distraction=defines.distraction.by_anything})
radius=2, distraction=defines.distraction.by_anything})
squad.command.state_changed_since_last_command = false
squad.command.tick = game.tick
squad.unitGroup.start_moving()
Expand Down
28 changes: 24 additions & 4 deletions robolib/eventhandlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,17 @@ function tickForces(forces, tick)
processDroidAssemblers(force)
processDroidGuardStations(force)
end
processDroidAssemblersForTick(force, tick)
processSquadUpdatesForTick(force.name, tick % 60 + 1)


if not game.active_mods["Unit_Control"] then
processDroidAssemblersForTick(force, tick)
processSquadUpdatesForTick(force.name, tick % 60 + 1)
updateSelectionCircles(force)
end
if tick % 1200 == 0 then
log_session_statistics(force)
end

updateSelectionCircles(force)


end
end
Expand Down Expand Up @@ -460,6 +463,23 @@ function handleOnRobotBuiltEntity(event)
end
end -- handleOnRobotBuiltEntity

function handleOnScriptRaisedBuilt(event)
local entity = event.entity
event.created_entity = event.entity
if(entity.name == "droid-assembling-machine") then
handleDroidAssemblerPlaced(event)
elseif(entity.name == "droid-guard-station") then
handleGuardStationPlaced(event)
elseif(entity.name == "droid-counter") then
handleBuiltDroidCounter(event)
elseif(entity.name == "droid-settings") then
handleBuiltDroidSettings(event)
elseif entity.name == "rally-beacon" then
handleBuiltRallyBeacon(event)
elseif entity.name == "loot-chest" then
handleBuiltLootChest(event)
end
end -- handleOnScriptRaisedBuilt

-- MAIN ENTRY POINT IN-GAME
-- during the on-tick event, lets check if we need to update squad AI, spawn droids from assemblers, or update bot counters, etc
Expand Down

0 comments on commit 55fb50e

Please sign in to comment.