-
Notifications
You must be signed in to change notification settings - Fork 328
[Discussion]: Power Cells, Fuel Tanks and other multi-shot ammo #376
Description
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:

- 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
- Full or empty - full stack size, as defined for the cell/tank's ammo
- 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.