Skip to content

Commit 6042436

Browse files
cyril-orlovkyranf
andauthored
2.0 migration (#187)
* 2.0 compatibility upgrade * Update README.md * playtested and fixed a bunch of small things inc droid activity and settings modules also fixed up the timing between new commands for the squads, they were sitting idle for like 5-10 minutes between new commands. The sanity check time and multiplier was killing it. --------- Co-authored-by: kyranf <kyfindlater@gmail.com>
1 parent 7b31703 commit 6042436

29 files changed

+632
-597
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016-2021 Kyran Findlater
3+
Copyright (c) 2016-2024 Kyran Findlater
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Robot Army mod for Factorio V1.1+
1+
# Robot Army mod for Factorio V2.0+
22

33
## Version
4-
0.4.17,
5-
Known to be compatible with Factorio v1.1.42. Requires at least v1.1.38 due to mod script API features used.
4+
2.4.18,
5+
Known to be compatible with Factorio v2.0.23. Requires at least v2.0 due to mod script API features used.
66

77

88
## Description
@@ -17,14 +17,15 @@ The Factorio Forums thread can be found here: [Forum link](https://forums.factor
1717
Mod portal link here: [Mod Portal](https://mods.factorio.com/mods/kyranzor/robotarmy)
1818

1919
## Credits
20-
YuokiTani for the great models of the Droids
21-
Klonan for his Combat Units and permission to integrate the mod into mine, and his great work with the Unit Control mods
22-
Dauphin for his significant contributions to the codebase for squad AI and performance enhancements
23-
Earendel for inspiration and code examples for the RTS-style control of units from the AAI Programmable Vehicles mod.
24-
Felipe Bueno Aliski Alves for the Brazilian Portuguese translations
25-
Varoga for the russian translations
20+
* YuokiTani for the great models of the Droids
21+
* Klonan for his Combat Units and permission to integrate the mod into mine, and his great work with the Unit Control mods
22+
* Dauphin for his significant contributions to the codebase for squad AI and performance enhancements
23+
* Earendel for inspiration and code examples for the RTS-style control of units from the AAI Programmable Vehicles mod.
24+
* Felipe Bueno Aliski Alves for the Brazilian Portuguese translations
25+
* Varoga for the russian translations
26+
* cyril-orlov for the Factorio v2.0 migration work
2627

2728
## Donations
2829
If you are feeling generous or thankful for the work i've done, feel free to donate to me so I can bribe my wife with chocolate to help her put up with my late nights! Click the image below:
2930
[![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/KyranF)
30-
Or simply use this: [Donate](https://www.paypal.me/KyranF)
31+
Or simply use this: [Donate](https://www.paypal.me/KyranF)

changelog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 2.4.18
3+
Date: 2024.12.13
4+
Changes:
5+
- ported to support v2.0, thanks greatly to
6+
- changed target type to search&destroy for more direct fighting behaviours. can change target type back to 3 if you want.
7+
- reducing flame droid fire resist from 100% to 95%, so they can eventually kill eachother if they get into friendly fire or against other forces
8+
Bugfixes:
9+
- much better AI update rates which you can tune in the config.lua sanity-check seconds and distance multiplier.
10+
---------------------------------------------------------------------------------------------------
211
Version: 0.4.17
312
Date: 2022.06.06
413
Changes:

config/config.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ GUARD_STATION_GARRISON_SIZE = 10 -- limit to how many a guard station will spawn
2121
USE_TELEPORTATION_FIX = 1 --if player is not looking, teleport stuck droids back to their squad-mates so they can keep moving
2222
PLAYER_VIEW_RADIUS = 60 -- this is very simplistic, but it's a start. helps avoid having teleporting droids while the player is looking.
2323

24-
SANITY_CHECK_PERIOD_SECONDS = 120
25-
SANITY_CHECK_PATH_DISTANCE_DIV_FACTOR = 500 -- every extra 500 tiles should give us an extra SANITY_CHECK_PERIOD_SECONDS
24+
SANITY_CHECK_PERIOD_SECONDS = 10
25+
SANITY_CHECK_PATH_DISTANCE_DIV_FACTOR = 5000 -- every extra 500 tiles should give us an extra SANITY_CHECK_PERIOD_SECONDS
2626
PRINT_SQUAD_DEATH_MESSAGES = 1 --if you want it to tell you when squad x completely dies
2727
-- PRINT_SQUAD_MERGE_MESSAGES = 0
2828
ASSEMBLER_MERGE_TICKRATE = 180
@@ -31,7 +31,7 @@ SQUAD_UNITGROUP_FAILURE_DISTANCE_ESTIMATE = 40
3131
UG_FAILURE_RECENCY_TICKS = 300 --unit group command failure timeout
3232
MAX_CONSECUTIVE_UNITGROUP_FAILURES_BEFORE_RETREAT = 2 --how many times they totally fail before the squad disbands/retreats
3333

34-
GLOBAL_TARGETING_TYPE = 3 -- see targeting.lua for type options
34+
GLOBAL_TARGETING_TYPE = 1 -- see targeting.lua for type options
3535
DEFAULT_KEEP_RADIUS_CLEAR = 500 -- in tiles from nearest assembler to squad. squad will keep this area clear as priority, and then check hunt radius.
3636

3737
--CONFIG SETTINGS FOR THOSE WHO WANT TO SCALE THE DAMAGE AND HEALTH OF DROIDS

control.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,45 @@ require("stdlib/game")
1111

1212
LOGGER = Logger.new("robotarmy", "robot_army_logs", false, {log_ticks = false})
1313

14-
global.runOnce = false
14+
storage.runOnce = false
1515

1616
function init_robotarmy()
1717
LOGGER.log("Robot Army mod Init script running...")
1818

19-
if not global.Squads then
20-
global.Squads = {}
19+
if not storage.Squads then
20+
storage.Squads = {}
2121
end
2222

23-
if not global.uniqueSquadId then
24-
global.uniqueSquadId = {}
23+
if not storage.uniqueSquadId then
24+
storage.uniqueSquadId = {}
2525
end
2626

27-
if not global.DroidAssemblers then
28-
global.DroidAssemblers = {}
27+
if not storage.DroidAssemblers then
28+
storage.DroidAssemblers = {}
2929
end
3030

31-
if not global.droidCounters then
32-
global.droidCounters = {}
31+
if not storage.droidCounters then
32+
storage.droidCounters = {}
3333
end
3434

35-
if not global.lootChests then
36-
global.lootChests = {}
35+
if not storage.lootChests then
36+
storage.lootChests = {}
3737
end
3838

39-
if global.rallyBeacons then
40-
global.rallyBeacons = nil
39+
if storage.rallyBeacons then
40+
storage.rallyBeacons = nil
4141
end
4242

43-
if not global.droidGuardStations then
44-
global.droidGuardStations = {}
43+
if not storage.droidGuardStations then
44+
storage.droidGuardStations = {}
4545
end
4646

47-
if not global.updateTable then
48-
global.updateTable = {}
47+
if not storage.updateTable then
48+
storage.updateTable = {}
4949
end
5050

51-
if not global.units then
52-
global.units = {}
51+
if not storage.units then
52+
storage.units = {}
5353
end
5454

5555
--deal with player force as default set-up process

info.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "robotarmy",
3-
"version": "0.4.17",
3+
"version": "2.4.18",
44
"title": "Robot Army",
55
"author": "Kyranzor",
66
"contact": "kyranzor@gmail.com",
77
"homepage": "https://github.com/kyranf/robotarmyfactorio",
88
"description": "Manufacture and deploy automated robot soldiers to attack your foes and defend your factory!",
99
"dependencies": [
10-
"base >= 1.1.38",
10+
"base >= 2.0.0",
1111
"? Unit_Control >= 0.3.10"
1212
],
13-
"factorio_version": "1.1"
13+
"factorio_version": "2.0"
1414
}

locale/en/locale.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ patrol-pole=Droid Patrol Post
2525
droid-pickup-tool=Droid Pick-Up Tool
2626
droid-selection-tool=Droid Squad Command Tool
2727

28+
[recipe-name]
29+
droid-rifle-deploy=Deploy Clockwork Riflebot
30+
droid-smg-deploy=Deploy Battle Droid
31+
droid-rocket-deploy=Deploy Rocket Droid
32+
droid-flame-deploy=Deploy Flamebot
33+
terminator-deploy=Deploy Terminator
34+
defender-unit-deploy=Deploy Defender Robot Unit
35+
distractor-unit-deploy=Deploy Distractor Robot Unit
36+
destroyer-unit-deploy=Deploy Destroyer Robot Unit
37+
2838
[item-description]
2939
droid-rifle=Long range slow-reload rifle-equipped droid. Good in swarms.
3040
droid-smg=Battle Droid, mounted with sub-machine gun.

migrations/robotarmy_0.4.12.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require("prototypes.DroidUnitList")
33
require("robolib.util")
44
game.reload_script()
55

6-
if not global.units then global.units = {} end
6+
if not storage.units then storage.units = {} end
77

88
--prep list of names to check against for unit checking
99

@@ -30,9 +30,9 @@ for i, force_ in pairs(game.forces) do
3030
for _, unitFound in pairs(units) do
3131
if names[unitFound.name] then
3232
if unitFound.valid then
33-
if not global.units[unitFound.unit_number] then
33+
if not storage.units[unitFound.unit_number] then
3434

35-
global.units[unitFound.unit_number] = unitFound -- reference to the LuaEntity with a lookup via the unit number.
35+
storage.units[unitFound.unit_number] = unitFound -- reference to the LuaEntity with a lookup via the unit number.
3636
numUnitsAdded = numUnitsAdded + 1
3737
end
3838
end

prototypes/building.lua

Lines changed: 87 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -28,68 +28,74 @@ local droidAssembler = {
2828
fluid_boxes =
2929
{
3030
{
31+
volume=100,
3132
production_type = "input",
3233
pipe_picture = assembler2pipepictures(),
3334
pipe_covers = pipecoverspictures(),
3435
base_area = 10,
3536
base_level = -1,
3637
pipe_connections = {{
37-
type = "input",
38-
position = {0, -2}
38+
flow_direction = "input",
39+
direction=0,
40+
position = {0, -1.2}
3941
}}
4042
},
4143
{
44+
volume=100,
4245
production_type = "output",
4346
pipe_picture = assembler2pipepictures(),
4447
pipe_covers = pipecoverspictures(),
4548
base_area = 10,
4649
base_level = 1,
4750
pipe_connections = {{
48-
type = "output",
49-
position = {0, 2}
51+
flow_direction = "output",
52+
direction=8,
53+
position = {0, 1.2}
5054
}}
5155
},
52-
off_when_no_fluid_recipe = false
5356
},
57+
fluid_boxes_off_when_no_fluid_recipe = false,
5458
collision_box = {{-1.2, -1.2}, {1.2, 1.2}},
5559
selection_box = {{-1.5, -1.5}, {1.5, 1.5}},
56-
animation =
57-
{
58-
layers =
59-
{
60-
{
61-
filename = BUILPATH .. "droid-assembler.png",
62-
width = 156,
63-
height = 139,
64-
frame_count = 1,
65-
line_length = 1,
66-
hr_version = {
67-
filename = BUILPATH .. "hr-droid-assembler.png",
68-
width = 312,
69-
height = 278,
70-
frame_count = 1,
71-
line_length = 1,
72-
scale = 0.5,
73-
}
74-
},
75-
{
76-
filename = BUILPATH .. "droid-assembler-shadow.png",
77-
width = 156,
78-
height = 139,
79-
frame_count = 1,
80-
line_length = 1,
81-
draw_as_shadow = true,
82-
hr_version = {
83-
filename = BUILPATH .. "hr-droid-assembler-shadow.png",
84-
width = 312,
85-
height = 278,
86-
frame_count = 1,
87-
line_length = 1,
88-
draw_as_shadow = true,
89-
scale = 0.5,
90-
}
91-
}
92-
}
60+
graphics_set = {
61+
animation =
62+
{
63+
layers =
64+
{
65+
{
66+
filename = BUILPATH .. "droid-assembler.png",
67+
width = 156,
68+
height = 139,
69+
frame_count = 1,
70+
line_length = 1,
71+
hr_version = {
72+
filename = BUILPATH .. "hr-droid-assembler.png",
73+
width = 312,
74+
height = 278,
75+
frame_count = 1,
76+
line_length = 1,
77+
scale = 0.5,
78+
}
79+
},
80+
{
81+
filename = BUILPATH .. "droid-assembler-shadow.png",
82+
width = 156,
83+
height = 139,
84+
frame_count = 1,
85+
line_length = 1,
86+
draw_as_shadow = true,
87+
hr_version = {
88+
filename = BUILPATH .. "hr-droid-assembler-shadow.png",
89+
width = 312,
90+
height = 278,
91+
frame_count = 1,
92+
line_length = 1,
93+
draw_as_shadow = true,
94+
scale = 0.5,
95+
}
96+
}
97+
}
98+
}
9399
},
94100
open_sound = { filename = "__base__/sound/machine-open.ogg", volume = 0.85 },
95101
close_sound = { filename = "__base__/sound/machine-close.ogg", volume = 0.75 },
@@ -151,43 +157,45 @@ local guardStation = {
151157
},
152158
collision_box = {{-1.7, -1.7}, {1.7, 1.7}},
153159
selection_box = {{-2, -2}, {2, 2}},
154-
animation =
155-
{
156-
layers =
157-
{
158-
{
159-
filename = BUILPATH .. "guard-station.png",
160-
width = 208,
161-
height = 228,
162-
frame_count = 1,
163-
line_length = 1,
164-
hr_version = {
165-
filename = BUILPATH .. "hr-guard-station.png",
166-
width = 416,
167-
height = 456,
168-
frame_count = 1,
169-
line_length = 1,
170-
scale = 0.5,
171-
}
172-
},
173-
{
174-
filename = BUILPATH .. "guard-station-shadow.png",
175-
width = 208,
176-
height = 228,
177-
frame_count = 1,
178-
line_length = 1,
179-
draw_as_shadow = true,
180-
hr_version = {
181-
filename = BUILPATH .. "hr-guard-station-shadow.png",
182-
width = 416,
183-
height = 456,
184-
frame_count = 1,
185-
line_length = 1,
186-
draw_as_shadow = true,
187-
scale = 0.5,
188-
}
189-
}
190-
}
160+
graphics_set = {
161+
animation =
162+
{
163+
layers =
164+
{
165+
{
166+
filename = BUILPATH .. "guard-station.png",
167+
width = 208,
168+
height = 228,
169+
frame_count = 1,
170+
line_length = 1,
171+
hr_version = {
172+
filename = BUILPATH .. "hr-guard-station.png",
173+
width = 416,
174+
height = 456,
175+
frame_count = 1,
176+
line_length = 1,
177+
scale = 0.5,
178+
}
179+
},
180+
{
181+
filename = BUILPATH .. "guard-station-shadow.png",
182+
width = 208,
183+
height = 228,
184+
frame_count = 1,
185+
line_length = 1,
186+
draw_as_shadow = true,
187+
hr_version = {
188+
filename = BUILPATH .. "hr-guard-station-shadow.png",
189+
width = 416,
190+
height = 456,
191+
frame_count = 1,
192+
line_length = 1,
193+
draw_as_shadow = true,
194+
scale = 0.5,
195+
}
196+
}
197+
}
198+
}
191199
},
192200
open_sound = { filename = "__base__/sound/machine-open.ogg", volume = 0.85 },
193201
close_sound = { filename = "__base__/sound/machine-close.ogg", volume = 0.75 },

0 commit comments

Comments
 (0)