bolderbrush10 / SearchlightAssault

A lua mod adding searchlights to the game factorio
MIT License
0 stars 0 forks source link

Searchlights

Welcome:

-> The interesting & easy tweaks to make are in sl-defines.lua
-> The interesting behaviors are mostly in control-gestalt.lua

Uninstallation

If a turret is being range-boosted by a searchlight when this mod is uninstalled, it may be lost when the save is reloaded.

To avoid the risk of random turrets disappearing:

This will destroy all searchlights and hidden entities used by this mod, and prevent the loss of other turrets.

Features

Turret boost block list

In the event that another mod's turrets are incompatible with SearchlightAssault trying to boost their range, the block list can be used to prevent issues.

It is advised to add incompatible turrets to the blocklist before placing any searchlights nearby.

To add one or more turrets to the block list:

Note that changes made in the mod settings menu will be lost unless you save your game.

Some turrets may not be boostable to begin with, and are automatically ignored by this mod.

FAQ

Contact

You are welcome to contact me via email: bolderbrush10@gmail.com

If you have any feedback or footage featuring my mod, please share with me! I would love to know what people think.

Technical Details / Details for other Modders

Known Issues:

Terms

Gestalt

A gestalt is an aggregation of things which together are more capable than by the sum of their individual parts.

In this mod, a 'gestalt' refers to the collection of a Searchlight, the list of turrets it may range-boost, and several hidden entities which each are essential to making features work.

Turtle

The term "Turtle" is a reference to the rendering concept of some old, beginner-friendly programming languages (such as 'Logo', from 1960's).

The idea is to imagine a turtle with a marker held in its tail, and wherever this turtle goes, it leaves behind a line. You'd write a program specifiying distances & directions for the turtle to follow. And thus, you could control the turtle to control rendering a picture.

And in this mod, our turtle, instead of drawing a line, will help render a searchlight effect.

Primary issues inflating SLOC:

I enjoyed the challenge of making this mod with as few changes to the base game as possible, but this codebase would be drastically smaller if these issues weren't in place:

  1. Developers have stated that they won't allow modifying shooting range during runtime https://forums.factorio.com/viewtopic.php?f=221&t=101902
  2. No mechanism in the API to modify ammo max range during runtime
  3. API doesn't provide some info in on_player_setup_blueprint event for some blueprint use cases
  4. Unsophisticated technique to "fire" the searchlight effect when no enemies present by creating a dummy entity in a dummy force (turtle)
  5. No mechanism in the API to blacklist units from being attacked by artilery, capsule robots, etc (TargetMasks seems to only affect turrets)
  6. Vehicles don't count as an entity_with_force, so you can't set their shooting target to one manually, even though turrets can and do attack vehicles (One must detect the vehicle, then check for a driver inside it and target the driver)
  7. Command complete events don't fire right when a distraction occurs, you have to wait for the distraction to be over to know if your command was interrupted
  8. The mod editor doesn't fire events while creating / destroying from some tabs.
  9. Developers have repeatedly stated they won't do an OnCircuitConnected/Disconnected https://forums.factorio.com/viewtopic.php?p=369587#p369587 https://forums.factorio.com/viewtopic.php?p=509912#p509912
  10. Wires also don't trigger OnEntityCreated/Destroyed.

File Guide:

sl-defines.lua - miscellaneous static definitions such as turret range, colors, etc. Shared between most files.

control.lua - handles event registrations & filtering, calls behavior from the control-*.lua files
control-gestalt.lua - controls foe seeking behavior, range-boosting behavior, etc. Interacts with other control-* files
control-searchlight.lua - behaviors for the searchlight itself when created / alarms are raised, etc
control-tunion.lua - behaviors for range-boosting turrets
control-turtle.lua - behaviors for the dummy-entity that the searchlight "attacks" to render a light at surface locations
control-forces.lua - sets up the forces assigned to hidden entities and handles force migrations
control-gui.lua - Graphical User Interface controls, for displaying windows allowing control of searchlights to players
control-items.lua - converts items in blueprints to the base versions of boosted turrets
control-blocklist.lua - controls for filtering incompatible turrets per mod settings and remote interfaces
control-common.lua - data structures to be shared across control-* files and functions for maintaining them

sl-relation.lua - a simple matrix to help track relations between turrets, foes, and searchlights
sl-render.lua - displays the searchlight's search area
sl-util.lua - math functions, copying functions, and other miscellaneous functions

info.json - information to display in the mod portal webpage, plus version / mod dependency information
settings.lua - prototypes for the settings that can be configured for this mod
data.lua - lists which files the mod manager should read to build & modify prototypes
data-updates.lua - reads what turrets OTHER MODS have put into the game and generates extended-range versions of their prototypes (this allows a searchlight to "boost" any given turret's range). If another mod creates its own turrets in its own data-updates.lua or data-final-fixes.lua files, then searchlights are probably not going to be able to boost that mod's turrets.
data-final-fixes.lua - Double checks that any boosted turrets have the correct health, since other mods have been discovered to change vanilla turrets in data-updates. Generates extended-range versions of ammo prototypes, since other mods have been observed modifying vanilla ammo in data-updates. Also declares our own entities here, so other mods will stop messing with them.

Prototypes contain the definitions for a unit's graphics, animations, and stats (such as max health, range, and damage)

prototypes/sl-entities.lua - prototypes for the searchlight, hidden entities such as the turtle, etc prototypes/sl-datastage-entities.lua - prototypes for entites that rely on basegame entity data prototypes/sl-graphics.lua - pictures, lights, spirites, and animations
prototypes/sl-gui.lua - defines GUI styles for later use in control-gui.lua
prototypes/sl-shortcuts.lua - defines / modifies in game hotkeys (used to open the searchlight GUI)
prototypes/sl-signals.lua - virtual signals for refined control over searchlights
prototypes/sl-techItemRecipe.lua - details for how to research and craft a searchlight

compatability/* - Mod-specific compatability fixes & features
compatability/sl-compatability.lua - Collates various mod-specific calls into a handful of functions

locale/* - Translations of the various in-game strings displayed to the player

menu-simulations/* - Contains small demos that run during the game's main menu, on a random rotation

scenarios/* - The latest revision of the Prison Break game mode. Of note are the files _slsilobreak.py and _slprisonbreak.py, which contain scenario-specific logic, events, and win conditions.

Design Decisions & Discussion

Mod Interface Features / Issues to Request / Report

Stretch Goals

Map Editing:

Code:

Art: