CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.26k stars 4.11k forks source link

Battery capacity reduction and `charges_per_use` parameter #76045

Open IdleSol opened 2 weeks ago

IdleSol commented 2 weeks ago

Is your feature request related to a problem? Please describe.

The capacity of the smallest battery is 2 units. The minimum value of the charges_per_use parameter is 1. (It can also be 0. For a value of 0.1, the game gave an error).

In fact, turning on any device that uses this battery consumes half of its capacity. In my opinion, it does not make sense.

Things are slightly better with light batteries. Turning on the device requires 1/16 of its charge.

Solution you would like.

Simple solution

Make it possible to use non integer numbers: 0.5, 0.1 and so on.

Complex way of solution

Add dimensions for the charges_per_use parameter. As well as for all related parameters. The problem is that charges_per_use uses “abstract” charges. If the store is a battery, it uses kJ. Or ml (?) of fuel, if it's gasoline. Or just the charge of an artifact. It probably applies somewhere else.

Describe alternatives you have considered.

No response

Additional context

An additional problem with some electronic devices. For example, a smartphone. Using 1 charge out of 40 to take a picture is fine. Using 1 charge to play music is a lot.

IdleSol commented 2 weeks ago
kevingranade commented 2 weeks ago

This is already implemented for ongoing power consumption as "power_draw". I don't think it handles per activation though.

Changing charges_per_use to accept decimals will not meaningfully help, "power_draw" needs to be expanded to cover per-activation.

Also until #75912 is done it will round up to the nearest charge anyway.

IdleSol commented 2 weeks ago

Maybe I'm misunderstanding something? Using a smartphone as an example.

We have a smartphone. https://github.com/CleverRaven/Cataclysm-DDA/blob/1ab5fb431716f987e807687d045332996f1eb3d0/data/json/items/tool/electronics.json#L632

It only has charges_per_use and a list of transformations. In particular, the transformation to: https://github.com/CleverRaven/Cataclysm-DDA/blob/1ab5fb431716f987e807687d045332996f1eb3d0/data/json/items/tool/electronics.json#L686

And already this version has the power_draw parameter.

When we turn on music, we spend 1 battery charge, after that we start spending 0.3 W per second.

Or turning on a smartphone is equivalent to 1 charge = 1000 J / 0.3 W = 3333 sec ~ 1 hour

Changing charges_per_use to accept decimals will not meaningfully help, "power_draw" needs to be expanded to cover per-activation.

There is an alternative, switch from kJ dimension to J dimension for battery charges. Then battery capacity in json files will increase 1000 times, consumption too. But if necessary, you can specify a smaller value and it will still be an integer.

To display the charge in the game itself, leave kJ.

So on the example of a smartphone: "battery": 40 -> "battery": 40 000 "charges_per_use": 1 -> "charges_per_use": 1000 or 100 or 10

kevingranade commented 2 weeks ago

The problem is under the hood a bunch of things are still using charges, which are 1kJ each. The work to make that be 1J per charge or support fractions of charges is about the same about of work that we need to switch things to use units::energy and the latter option is much, much prefferable. Basically there is not a simple fix for this, it needs to do the right thing with respect to the internals.