Skip to content

[Discussion]: Power Cells, Fuel Tanks and other multi-shot ammo #376

Closed

Description

@sumghai

The following is a revival/continuation of an existing discussion that took place on the old CE repository.

CE ammo currently comes in the form of discrete cartridges, shells or rockets, which typically used by various historical and modern firearms used in the game. These items individually have fixed mass and bulk, which are decremented from a pawn's inventory as ammunition is consumed.

However, many sci-fi and exotic weapons should more appropriately use ammo items that hold multiple shots:

  • Energy weapons ([Discussion]: Directed energy/beam weapons #362) would typically use Power Cells and Batteries, whose mass and bulk remain constant during use
  • Flamethrowers would be supplied by a fuel tank, whose mass varies based on fuel capacity, but has a fixed bulk
  • A hypothetical type of fluid ammo contained inside a flexible bag, whose mass and bulk varies based on its content

Ideally, CE should implement power cells and fuel tanks as individual ammo items that contain multiple shots/fuel/power, while still being backwards compatible with the existing ammo system.

Features

  • Each cell/tank type ammo item holds multiple shots/fuel/power
  • Option to vary cell/tank bulk and mass based on remaining charge
  • Show remaining capacity when dropped as items:
    Ammo item capacity remaning display mockup
  • Scale ammo explosion size based on remaining charge (@perkinslr)
  • Varying stackability depending on capacity/state (@perkinslr)
    • Full or empty - full stack size, as defined for the cell/tank's ammo ThingDef
    • Partially-depleted - unstackable, so that they can be seen at a glance from the pawn's inventory; could also help with loadouts, where pawns will automatically restock with fully-charged cells/tanks when possible
  • Partially-depleted and empty cells/tanks should be rechargeable/refillable (@perkinslr)
    • Easiest approach would be two work bills - one to empty out partially-depleted cells/tanks, and another to fill empty cells/tanks (@sumghai)
    • Degradation after repeated recharges not practical (@N7Huntsman)

Prior Attempts

  • @sumghai bodged a hacky workaround for CP's DOOM weapons patches, where some sci-fi ammo items were defined as "fractions" of a complete power cell (e.g. a plasma power cell with a nominal mass and bulk of 0.3 kg and 1.5 respectively that holds 150 shots is instead divided into 150 "pieces"). While this was done for compatibility with the existing cartridge-based ammo system, it is unintuitive and breaks immersion as most players expect pawns to handle individual, whole power cells.
  • @Alicecomma did some development work towards supporting this feature, but work was paused during the transition to the 1.1 update. Additionally, the proposed changes and attempts to handle a general "consume X units of ammo to fire Y rounds" use-case isn't terribly intuitive to modders and patch authors.

Implementation

Existing and new statBases for CombatExtended.AmmoDef to support multi-shot ammo items:

Parameter Existing/New Description Allowed Values Default (if unspecified)
Mass Existing Nominal mass of a fully-loaded cell/tank Float: 0-? 1
Bulk Existing Nominal bulk of a fully-loaded cell/tank Float: 0-? 1
Capacity New Total capacity of a fully-loaded cell/tank Integer: 0-? ?
MassLostPerShot/
MassLostPerUnitConsumed
New How much mass the cell/tank decreases per shot Float: 0-? 0
BulkLostPerShot/
BulkLostPerUnitConsumed
New How much bulk the cell/tank decreases per shot Float: 0-? 0
DisplayAsPercentage New Whether to show remaining charge as a percentage Boolean:
true (shows %)
false (shows xxx/Capacity)
false
Rechargeable New Whether the cell/tank can be recharged once empty Boolean:
true (leaves behind empty cell/tank)
false (disappears from inventory)
false
Fuel New What item/resource to recharge empty cells/tanks of this type with ThingDefs (e.g. Chemfuel)
Non-tangible resources (Electricity, Plasma)
?

AmmoUser would also need to be modified to detect if the weapon's current ammo is of the cell/tank type, and consume it in the appropriate manner, while also displaying the capacity remaining in the pawn gizmo.

Activity

  1. added
    C#Requires a C# solution.
    DiscussionConcerns a discussion topic related to Combat Extended.
    on Nov 19, 2020
  2. perkinslr commented on Nov 24, 2020

    @perkinslr
    Contributor

    Partially depleted tanks and shells should probably not stack, but there should be a way (probably with a bench for cells) to combine partials.

    The sale price of cells should scale with their remaining charge.
    The explosion size of cells should scale with their remaining charge.

    One neat side-effect of this would be the future possibility of weapon magazines for conventional weapons too. Would help with the enormous bulk (but not mass) of PKM ammunition and similar.

    Also, for energy cells, being able to recharge them is probably a good idea. They probably should degrade with recharging, with their capacity shrinking so they must eventually be replaced.

  3. sumghai commented on Nov 25, 2020

    @sumghai
    ContributorAuthor

    Partially depleted tanks and shells should probably not stack

    Perhaps this could be implemented by dynamically-changing a cell/tank's thingDef?:

    • Full cells/tanks: stackLimit as per original thingDef
    • Partially-depleted cells/tanks: stackLimit = 1
    • Empty cells/tanks: stackLiimit as per original thingDef

    but there should be a way (probably with a bench for cells) to combine partials.

    The easiest way would probably be two bills - one to fully empty partials, and another to recharge/refill empty ones.

    The sale price of cells should scale with their remaining charge.

    I'm not sure about this one - I guess it depends on how easy/hard it is to refill/recharge the cells/tanks.

    The explosion size of cells should scale with their remaining charge.

    Agreed!

    One neat side-effect of this would be the future possibility of weapon magazines for conventional weapons too.

    This would be applicable with special calibers with fixed magazine size (e.g. PKM mags, M74 rockets in their customary 4-pack)

    Also, for energy cells, being able to recharge them is probably a good idea.

    Definitely!

    They probably should degrade with recharging, with their capacity shrinking so they must eventually be replaced.

    This will require a rethink of my current proposal, most likely requiring a standalone, explicit capacity parameter rather than inferring capacity from remaining mass/bulk (with the advantage that this is more transparent and user-intuitive to modders)

  4. N7Huntsman commented on Nov 25, 2020

    @N7Huntsman
    Contributor

    They probably should degrade with recharging, with their capacity shrinking so they must eventually be replaced.

    That strikes me as more hassle than it's probably worth, honestly--for instance, there's nothing with conventional weapons that impacts the effectiveness of the ammo based upon its condition.

  5. N7Huntsman commented on Nov 25, 2020

    @N7Huntsman
    Contributor

    One neat side-effect of this would be the future possibility of weapon magazines for conventional weapons too. Would help with the enormous bulk (but not mass) of PKM ammunition and similar.

    While it would certainly enable that, I definitely question the utility of going that direction. I don't see much benefit in having to manage magazines in addition to ammo--repacking magazines is really a level of detail we don't really need, I think.

  6. sumghai commented on Nov 25, 2020

    @sumghai
    ContributorAuthor

    @N7Huntsman @perkinslr - I've just rewritten the OP, please let me know if I'm missing anything.

    One neat side-effect of this would be the future possibility of weapon magazines for conventional weapons too. Would help with the enormous bulk (but not mass) of PKM ammunition and similar.

    While it would certainly enable that, I definitely question the utility of going that direction. I don't see much benefit in having to manage magazines in addition to ammo--repacking magazines is really a level of detail we don't really need, I think.

    I'm now sort of leaning towards Huntsman's thoughts on this - many weapons that share the same caliber often have different magazine sizes, so managing different magazines on top of the wide range of calibers probably makes for too much micromanagement.

  7. ghost locked and limited conversation to collaborators on Jul 15, 2021
  8. ghost closed this as completedon Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C#Requires a C# solution.DiscussionConcerns a discussion topic related to Combat Extended.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions