Skip to content

Commit

Permalink
config adjustable loot chest and artifact grabbing added. fixed selec…
Browse files Browse the repository at this point in the history
…tion highlight bug when selecting new squad without de-sel old one first.
  • Loading branch information
kyranf committed Aug 5, 2017
1 parent ecfe475 commit 9c4db2e
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Changelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ Changes from 0.3.2 to 0.3.3:
- made hybrid targeting system default
- minor bug fix from dauphin for hybrid targeting
- bug fix for issue #102
- bug fix for when assemblers spawn too fast while squad moves away and stragglers wander instead of joining squad, casuing splintering and multiple failures
- bug fix for when assemblers spawn too fast while squad moves away and stragglers wander instead of joining squad, casuing splintering and multiple failures
- fixed select/deselect visual bug with the green stickers
- added config param (default off) to re-enable the Artifact collection for those playing with Bobs/Natural Evolution which still have artifacts to collect!
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 V0.15+

## Version
0.3.2,
Known to be compatible with Factorio v0.15.5
0.3.3,
Known to be compatible with Factorio v0.15.32


## Description
Expand Down
2 changes: 1 addition & 1 deletion config/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ DAMAGE_SCALAR = 1.0 -- scales base damage by this value. default is 1.0. 0.5 mak
ARTIFACT_GRAB_RADIUS = 30 --now obsolete, artifact grab script is not used now, as of Factorio 0.15+
GUARD_POLE_CONNECTION_RANGE = 30 -- this is for electrical connection range and therefore spacing of patrol poles, checking range is.


GRAB_ARTIFACTS = 0
2 changes: 2 additions & 0 deletions data.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require("config.config")
require("prototypes.droid-animations")
require("prototypes.item") -- any buildable or placable object/entity needs this
require("prototypes.building")
Expand All @@ -10,6 +11,7 @@ require("prototypes.destroyer-unit")
require("prototypes.distractor-unit")
require("prototypes.defender-unit")


--require("prototypes.DroidUnitList")


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.3.2",
"version": "0.3.3",
"title": "Robot Army",
"factorio_version": "0.15",
"author": "Kyran F",
Expand Down
6 changes: 5 additions & 1 deletion prototypes/recipe.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require("config.config")

data:extend(
{
{
Expand Down Expand Up @@ -340,7 +342,9 @@ data:extend(
-- deal with unlocking the recipes just piggy-backing on military research for now. most droids need more advanced research to build them anyway.
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-rifle"})
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-rifle-deploy"})
-- now obsolete table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="loot-chest"})
if(GRAB_ARTIFACTS == 1) then
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="loot-chest"})
end
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="patrol-pole"})
-- DISABLED DUE TO BUGGY BEHAVIOUR table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="rally-beacon"})
table.insert(data.raw["technology"]["military"].effects,{type="unlock-recipe",recipe="droid-assembling-machine"})
Expand Down
4 changes: 3 additions & 1 deletion robolib/SquadControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ function updateSquad(squad)
end

revealChunksBySquad(squad)
--grabArtifactsBySquad(squad) --disabled as of 0.15 where alien artifacts are no longer dropped!
if(GRAB_ARTIFACTS == 1) then
grabArtifactsBySquad(squad) --disabled as of 0.15 where alien artifacts are no longer dropped!
end
end
end

Expand Down
20 changes: 20 additions & 0 deletions robolib/eventhandlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,27 @@ function reportSelectedUnits(event, alt)
local squad = getClosestSquadToPos(global.Squads[player.force.name], clickPosition, SQUAD_CHECK_RANGE) --get nearest squad within SQUAD_CHECK_RANGE amount of tiles radius from click point.

if squad then

-- if there's a currently selected squad, deselect them!
--DESELECT LOGIC
if global.selected_squad and global.selected_squad[player.index] and global.selected_squad[player.index] ~= nil then
if global.Squads[player.force.name][global.selected_squad[player.index]] then --if the squad still exists, even though we have the ID still in selection
Game.print_all(string.format("De-selected Squad ID %d", global.selected_squad[player.index]) )
for _, member in pairs(global.Squads[player.force.name][global.selected_squad[player.index]].unitGroup.members) do
local unitBox = member.bounding_box
unitBox.left_top.x = unitBox.left_top.x - 0.1
unitBox.left_top.y = unitBox.left_top.y - 0.1
unitBox.right_bottom.x = unitBox.right_bottom.x + 0.1
unitBox.right_bottom.y = unitBox.right_bottom.y + 0.1

for _,e in pairs(member.surface.find_entities_filtered{type="sticker", area=unitBox}) do
e.destroy()
end
end
end
end


Game.print_all(string.format("Squad ID %d selected! Droids in squad: %d", squad.squadID, squad.numMembers) )
--Game.print_all(string.format("Tool %s Selected area! Player ID %d, box %d,%d and %d,%d, droids in squad %d ", event.item , event.player_index, area.left_top.x, area.left_top.y, area.right_bottom.x, area.right_bottom.y, squad.numMembers ) )

Expand Down
16 changes: 16 additions & 0 deletions robolib/onload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,23 @@ function bootstrap_migration_on_first_tick(event)
migrateForce(fkey, force)
end
end

--check if we have grab artifacts enabled - if we do, but it was added after the game started, and the force has military 1 researched
--then lets force the recipe to be enabled (because they have missed the usual trigger)
if(GRAB_ARTIFACTS == 1) then
for fkey, force in pairs(forces) do
if(force.technologies["military"].researched == true) then
force.recipes["loot-chest"].enabled = true
end
end
else -- else force-disable it if it's been disabled part-way through a game.
for fkey, force in pairs(forces) do
force.recipes["loot-chest"].enabled = false
end

end


-- substitute the 'normal' tick handler, and run it manually this time
script.on_event(defines.events.on_tick, handleTick)
handleTick(event)
Expand Down

0 comments on commit 9c4db2e

Please sign in to comment.