Personal Weapon Equipment (Expanded)


Rebuilt from GunEquipment example mod and expanded to support multiple ammo categories and items. Artwork for equipment sprite/thumbnail by Silenteum (used with permission).

Content
19 hours ago
2.0
54
Combat Armor

Changelog

Version: 0.6.2
Date: 2025-09-03
  Changes:
    - Ammo functionality restored/confirmed using AutoGun: equipment now consumes magazines from character/vehicle inventories and reloads dynamically.
    - Generates equipment for bullet, rocket, cannon-shell, and railgun-dart ammo automatically.
Version: 0.6.3
Date: 2025-09-03
  Changes:
    - Separated turret families by ammo category (bullet/rocket/cannon-shell/railgun-dart).
    - Items now place family-specific 'no-magazine' equipment, ensuring the right ammo type is used.
    - Equipment names carry family suffixes so reload/unload swaps keep the turret type consistent.
    - Added locale names for the eight items as requested.
Version: 0.6.4
Date: 2025-09-03
  Bugfixes:
    - Fixed syntax error in equipment.lua (stray 'end' at file end).
Version: 0.6.5
Date: 2025-09-03
  Bugfixes:
    - Fixed item placement names for dual no-mag placeholders (order is '-equipment-dual-<family>').
Version: 0.6.6
Date: 2025-09-03
  Compatibility:
    - Railgun family is now conditional: only generated if ammo-category 'railgun-dart' exists.
    - Items, recipes, and tech effects for Railgun are also conditional to prevent missing-category errors.
Version: 0.6.7
Date: 2025-09-03
  UX:
    - Added distinct icons for Machine Gun / Rocket / Cannon items; Railgun uses dart icon when available.
  Content:
    - Ensured six base items (single + double for bullet, rocket, cannon) are always defined.
Version: 0.6.8
Date: 2025-09-03
  Bugfixes:
    - Fixed OnInit magazine discovery to recognize family-suffixed equipment (rocket/cannon/railgun).
    - Now correctly populates AutoGun.magazines for rockets and cannon shells (and railgun if present).
Version: 0.6.9
Date: 2025-09-03
  Bugfixes:
    - Reload step now uses family-suffixed reload equipment names.
    - Wrong-ammo attempts now safely skip and try next magazine (no accidental bullet loading).
Version: 0.7.0
Date: 2025-09-03
  Compatibility & Behavior:
    - Added category normalization: treats 'cannon-shell-magazine' as 'cannon-shell', and 'railgun-dart' as 'railgun'.
    - Generated equipment and placeholders now use normalized families (bullet/rocket/cannon-shell/railgun).
    - Items place family-correct no-mag equipment; railgun works with 'railgun' or 'railgun-dart' categories.
    - Whitelists added for OC's and vtk-cannon ammo; reload tries whitelisted ammo first per family.
    - Family-aware reload order prevents bullets from loading into rocket/cannon/railgun equipment.
Version: 0.7.1
Date: 2025-09-03
  Bugfixes:
    - Removed stray 'end' at end of equipment.lua causing <eof> expected syntax error.
Version: 0.7.2
Date: 2025-09-03
  UX:
    - Equipment now shows proper names: Personal Machine Gun / Rocket Launcher / Cannon / Railgun, with Double variants and Reloading/Empty states.
  Behavior:
    - Family suffix is enforced on all reload/swap paths so rockets feed only rocket launchers, etc.
Version: 0.7.3
Date: 2025-09-03
  Bugfixes:
    - ContinueLoading now correctly parses reload equipment with optional family suffix (e.g., '-rocket', '-cannon-shell').
    - Final loaded equipment name preserves both '-dual' and family suffix.
Version: 0.7.4
Date: 2025-09-03
  Bugfixes:
    - Rewrote ContinueLoading to a clean, family-aware version (no syntax errors; preserves -dual and family suffix).
Version: 0.7.5
Date: 2025-09-03
  UX:
    - Equipment now displays correct names (Personal Rocket Launcher / Cannon / Railgun, with Double and Reloading/Empty states).
  Behavior:
    - OnInit magazine discovery now normalizes categories (so vtk 'cannon-shell-magazine' and OC 'railgun-dart' get included).
Version: 0.7.6
Date: 2025-09-03
  Bugfixes:
    - When ammo has no reload_time (e.g., rockets/cannon shells), final equipment placement now includes both '-dual' and family suffix (e.g., '-rocket', '-cannon-shell').
    - Prevents fallback to bullet-type equipment in direct placement path.
Version: 0.7.7
Date: 2025-09-03
  Behavior:
    - OnInit now registers ALL ammo in supported families (bullet/rocket/cannon-shell/railgun), not just ones with DirectDamageType.
    - Prevents the 'bullet-only' behavior by ensuring rocket/cannon/railgun ammo are eligible during reload.
Version: 0.8.0
Date: 2025-09-03
  Major:
    - Split magazine lists per family (bullet/rocket/cannon-shell/railgun) and reload now only considers ammo from the same family.
    - Added separate control files for each turret type: AutoGun/mg.lua, rocket.lua, cannon.lua, railgun.lua.
  Fixes:
    - Eliminates fallback to bullet magazines when other families are present.
Version: 0.8.1
Date: 2025-09-03
  Bugfixes:
    - Fixed syntax error: removed an extra 'end' in AutoGun.Reload that caused parser failure.
Version: 0.8.2
Date: 2025-09-03
  Bugfixes:
    - Initialize and reset AutoGun.magazines_by_family to prevent nil errors and ensure family-only reload behavior.
Version: 0.8.3
Date: 2025-09-03
  Bugfixes:
    - Fixed equipment 'take_result' to return the correct base item (pwe-gun/rocket/cannon/railgun, incl. -dual variants) instead of the missing 'personal-turret-equipment' from the example mod.
Version: 0.8.4
Date: 2025-09-03
  Bugfixes:
    - Replaced remaining hardcoded 'take_result = "personal-turret-equipment"' with family-aware mapping.
Version: 0.8.5
Date: 2025-09-03
  Bugfixes:
    - Fixed railgun placeholder names: use '-railgun' when that category exists, otherwise '-railgun-dart'.
    - Simplified take_result mapping to avoid load-order issues (no data.raw checks in data stage).
Version: 0.8.6
Date: 2025-09-03
  Compatibility:
    - Use **vanilla railgun ammo** only. Railgun placeholders/items/tech are generated only if the 'railgun' category exists.
  Bugfixes:
    - Forced all equipment to set 'take_result' to the correct PWE item (no references to equipment names or example items).
Version: 0.8.7
Date: 2025-09-03
  Bugfixes:
    - Rewrote equipment.lua generate_turret to a clean, minimal implementation (fixed malformed table syntax).
    - Placeholders now generated only for available categories; Railgun uses vanilla 'railgun'.
Version: 0.8.8
Date: 2025-09-03
  Bugfixes:
    - Rewrote items.lua cleanly; defines pwe-* items per family with correct place_as_equipment_result.
    - Adds pwe-railgun items only when vanilla 'railgun' category exists (no railgun-dart).
Version: 0.8.9
Date: 2025-09-03
  Bugfixes:
    - Always define pwe-railgun and pwe-railgun-dual items so equipment take_result resolves regardless of load order.
Version: 0.8.10
Date: 2025-09-03
  Bugfixes:
    - Replaced missing '__base__/graphics/icons/railgun.png' with a safe base icon ('tank-cannon.png') for railgun items.
Version: 0.8.11
Date: 2025-09-03
  Bugfixes:
    - Fixed family parsing helpers (_pwe_family_suffix/_pwe_family/_pwe_suffix_for_equipment) so turrets correctly detect their ammo family (bullet/rocket/cannon-shell/railgun).
    - This restores reload for all families, including machine gun.
Version: 0.8.12
Date: 2025-09-03
  Bugfixes:
    - Removed stray duplicated lines in _pwe_family() that caused a syntax error at startup.
Version: 0.8.13
Date: 2025-09-03
  Bugfixes:
    - Removed corrupted duplicate lines after _pwe_family_suffix() that caused '<eof> expected near end' at startup.
Version: 0.8.14
Date: 2025-09-03
  Behavior change:
    - Simplified reload logic: no more temporary '-reload-<n>' equipment. When ammo is found, we swap to the ammo-specific equipment and consume 1 round immediately.
    - Strict family check remains; only ammo from the equipment's family is accepted.
Version: 0.9.0
Date: 2025-09-03
  Major:
    - Replaced AutoGun controller with a clean minimal loader:
      * Detects family from equipment name suffix (-bullet/-rocket/-cannon-shell/-railgun)
      * Finds compatible ammo in player inventories (whitelist + prototype fallback)
      * Swaps placeholder to the ammo-specific equipment and consumes 1 ammo
    - Removes reliance on '-reload-N' variants and corrupted legacy logic.
Version: 0.9.1
Date: 2025-09-03
  Compatibility:
    - Added no-op event handlers (OnEntityBuild/OnRobotBuild/OnEntityDied) to satisfy legacy hooks from control.lua.
Version: 0.9.2
Date: 2025-09-03
  Critical:
    - Call OnInit at proper times (on_init & on_configuration_changed) instead of first on_tick to ensure 'global' exists.
    - Clean on_tick loop: iterate connected players and run AutoGun.OnTick per player.
  Compatibility:
    - Added AutoGun.OnEntityEnded() no-op and wired legacy events safely.
Version: 0.9.3
Date: 2025-09-03
  Bugfixes:
    - Made AutoGun.OnInit() a no-op to avoid referencing 'global' during initialization.
Version: 0.9.4
Date: 2025-09-03
  Major:
    - Loaded equipment now copies the selected ammo's `ammo_type` (projectiles/beam/etc.) into `attack_parameters`.
      This makes turrets actually fire projectiles instead of only playing sounds.
  Notes:
    - Placeholders still use a no-op ammo_type; only loaded variants carry real actions.
Version: 0.9.5
Date: 2025-09-03
  Bugfixes:
    - Rewrote equipment.lua cleanly to remove corrupted ellipses and ensure valid Lua.
    - Loaded variants now set attack_parameters.ammo_type to a deepcopy of the ammo's ammo_type.
Version: 0.9.6
Date: 2025-09-03
  Bugfixes:
    - Restored `ammo_category = family` inside `attack_parameters` for all equipment (including placeholders),
      satisfying Factorio's requirement for a primary ammo category.
    - Loaded variants still deep-copy the ammo's `ammo_type` for correct projectiles/effects.
Version: 0.9.7
Date: 2025-09-03
  Balance:
    - Applied requested stats per family/dual:
      MG 2x2 R20 FR14; Dual MG 2x3 R22 FR28;
      Rocket 2x3 R28 FR4; Dual Rocket 3x4 R36 FR10;
      Cannon 4x4 R36 FR2; Dual Cannon 4x6 R40 FR6;
      Railgun 6x6 R50 low FR (~1/s) + large per-shot energy (2MJ);
      Dual Railgun 8x8 R60 FR +65% (~1.65/s) with 115% energy per shot (2.3MJ).
    - Railgun equipment now has larger energy buffers and inflow to support high per-shot costs.
  Internals:
    - Cooldowns are computed from fire rate (ticks = round(60 / rate), min 1).
Version: 0.9.8
Date: 2025-09-03
  Balance:
    - Rocket Launcher: 2 shots/sec; Dual: 4 shots/sec.
    - Cannon: 0.6 shots/sec; Dual: 1 shot/sec.
    - Railgun: 0.05 shots/sec; Dual: 0.1 shots/sec.
Version: 0.9.9
Date: 2025-09-03
  UX:
    - Inverted equipment width/height so layouts are wider than tall (e.g., Dual MG 3x2, Rocket 3x2, Dual Rocket 4x3, Dual Cannon 6x4).
Version: 1.0.4
Date: 2025-09-05
  - Converted to SMG-style scriptless equipment (static prototypes) with custom icons.
  - Ensured recipes/technology use correct Factorio 2.0 formats.
  - Preserved your balance stats, footprints, ranges, and energy behavior.
Version: 1.0.5
Date: 2025-09-05
  - Fixed equipment prototypes to set `take_result` to the correct item (e.g., bullet -> pwe-gun),
    preventing the 'item with name ... does not exist' load error.