cataclysmbnteam / Cataclysm-BN

Cataclysm: Bright Nights, A fork/variant of Cataclysm:DDA by CleverRaven.
https://docs.cataclysmbn.org
Other
681 stars 266 forks source link

Creating a new passive powergen CBM only works when the bionic is turned off #1361

Closed chaosvolt closed 1 year ago

chaosvolt commented 2 years ago

Describe the bug

Basically, the current examples of passive power generation all seem to rely on some hardcoded behavior to work properly. You can try to add a new passive power generation CBM that works purely via JSON, and it sorta works. However, these CBMs only respect passive_fuel_efficiency, not fuel_efficiency. This means that they will provide power generation when left off, as expected, but turning them on actually halts power generation entirely.

You could try to work around this by removing BIONIC_TOGGLED to prevent the player from turning the CBM on, but that doesn't work. Instead it lets you turn the CBM on anyway, bricking power generation as normal...but then doesn't allow you to turn the bionic back off afterward, leaving you stuck with a now-broken bionic.

Steps To Reproduce

Add the following JSON somewhere to test:

  {
    "type": "GENERIC",
    "//": "pseudo item, used as fuel type for atomic battery CBM",
    "id": "c_atomic_battery_power",
    "symbol": "?",
    "color": "white",
    "name": { "str": "Alphavoltaic Power", "str_pl": "none" },
    "description": "seeing this is a bug",
    "stackable": true,
    "volume": "0 ml",
    "material": [ "c_atomic_battery_power" ],
    "flags": [ "PSEUDO", "PERPETUAL" ]
  },
  {
    "id": "bio_atomic_battery",
    "type": "bionic",
    "name": { "str": "Atomic Battery" },
    "description": "Your body has been implanted with a compact, advanced plutonium-cell generator for military use.  A true atomic battery, using advanced materials to create a practical alphavoltaic power source.  It will provide 5 watts of power when turned off.  Turning it on is supposed to provide 50 watts of power, but will actually do nothing;.",
    "occupied_bodyparts": [ [ "torso", 20 ] ],
    "fuel_options": [ "c_atomic_battery_power" ],
    "passive_fuel_efficiency": 0.005,
    "fuel_efficiency": 0.05,
    "time": 1,
    "flags": [ "BIONIC_TOGGLED", "BIONIC_POWER_SOURCE", "BIONIC_SHOCKPROOF" ]
  },
  {
    "id": "bio_atomic_battery",
    "copy-from": "bionic_general",
    "type": "BIONIC_ITEM",
    "name": { "str": "Atomic Battery CBM" },
    "description": "An old form of non-thermal radioisotope generator, given new life and military applications using cutting-edge plutonium-catalyst developments.  Effectively a plutonium fuel cell converted into an alphavoltaic battery, with greater power output and longevity than older implants.  Its output is still very low at only 5 watts, but it is continuous unless deliberately interrupted by the provided disconnect system, making it a good supplement to a more intensive power generation method.",
    "price": "8000 USD",
    "difficulty": 8
  },

This is a modified version of the Atomic Battery bionic from Cataclysm++, with the "interrupter switch" hack stripped away so the power generation can be tested more directly.

  1. Load into a game with the above JSON added somewhere for testing.
  2. Spawn in and install some power storage and the above bionic using Debug Bionic Installation.
  3. Wait and observe that you're gaining 5 joules a turn.
  4. Turn the bionic on.
  5. Wait and observe power generation has stopped, instead of gaining 50 a turn like the JSON would suggest.

Expected behavior

  1. For JSON-defined bionics using perpetual fuel to correctly respect fuel_efficiency, allowing for you to turn them on for a different degree of power generation, or so you can have a powergen bionic that you have to turn on and suffer side effects via enchantment effects.
  2. Failing that, for powergen bionics to correctly refuse to be toggled on if they lack BIONIC_TOGGLED, allowing for passive powergen bionics to simply always run and not let you toggle them.

Screenshots

Versions and configuration

- OS: Windows
    - OS Version: 10.0 2004
- Game Version: 5dd2ae8 [64-bit]
- Graphics Version: Tiles
- Game Language:  []
- Mods loaded: [
    Bright Nights [dda],
    Arcana and Magic Items [Arcana],
    Cataclysm++ [Cata++],
    Elevated bridges [elevated_bridges],
    Medieval Mod Reborn [Medieval_Mod_Reborn],
    MST Extra [MST_Extra],
    Mining Mod [Mining_Mod],
    Fewer Farms [Fewer_Farms],
    Tankmod: Revived [Tankmod_Revived],
    No Fungal Monsters [No_Fungi],
    Disable NPC Needs [no_npc_food],
    Faster Stamina Regen [stamina_regen_buff],
    Manual Bionic Installation [manualbionicinstall],
    Nonperishable Overhaul [Nonperishable_Overhaul],
    Simplified Nutrition [novitamins],
    Dorf Life [Dorf_Life],
    DinoMod [DinoMod],
    No Hope [no_hope],
    Stats Through Skills [StatsThroughSkills]
]

Additional context

Rigging an active enchantment to constantly spam a spell every turn that restores some bionic power would technically do the trick too, but it feels like a drunken hack to me. Plus it won't work for power amounts less than 1 kJ.

Coolthulhu commented 1 year ago

Is this still happening? I recall a PR changing the behavior.

chaosvolt commented 1 year ago

Was fixed by https://github.com/cataclysmbnteam/Cataclysm-BN/pull/2291