Repository navigation
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.
Activity
perkinslr commentedon Nov 24, 2020
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.
sumghai commentedon Nov 25, 2020
Perhaps this could be implemented by dynamically-changing a cell/tank's thingDef?:
stackLimitas per original thingDefstackLimit= 1stackLiimitas per original thingDefThe easiest way would probably be two bills - one to fully empty partials, and another to recharge/refill empty ones.
I'm not sure about this one - I guess it depends on how easy/hard it is to refill/recharge the cells/tanks.
Agreed!
This would be applicable with special calibers with fixed magazine size (e.g. PKM mags, M74 rockets in their customary 4-pack)
Definitely!
This will require a rethink of my current proposal, most likely requiring a standalone, explicit
capacityparameter rather than inferring capacity from remaining mass/bulk (with the advantage that this is more transparent and user-intuitive to modders)N7Huntsman commentedon Nov 25, 2020
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.
N7Huntsman commentedon Nov 25, 2020
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.
sumghai commentedon Nov 25, 2020
@N7Huntsman @perkinslr - I've just rewritten the OP, please let me know if I'm missing anything.
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.