Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adds recipe to modify normal batteries to be used in vehicles. #39961

Closed

Conversation

Tamiore
Copy link
Contributor

@Tamiore Tamiore commented Apr 27, 2020

General idea, community input welcomed.

Summary

SUMMARY: Content "Adds recipe to modify normal batteries to be used in vehicles. "

Purpose of change

Allow for normal batteries to be used used in vehicles power grid (after some modifications).

Because sometimes (especially with wilderness scenarios) it may be impossible to find "proper" vehicle batteries, while you DO have access to several normal rechargeable batteries.

Describe the solution

Modify a battery with the same materials used in battery compartment mod to make the battery vehicle-compatible.

Describe alternatives you've considered

Add a vehicle part that (when installed) would allow for normal batteries to be installed without any modification.

Testing

Works ok locally (for the 1 recipe already added).

Additional context

So far I've added only a recipe for light battery (high-capacity).

This is a general template I can apply to all other types of rechargeable batteries.

However, at this point I'd like like to hear some input:

  • Any reason these kinds of recipes shouldn't be added at all?
  • Is there a better way to implement it?
  • Any way to discharge host battery before it's included into the "disassembly ingredients"?
  • Any other feedback in general.

@CountAlex
Copy link
Contributor

I think that that's a good idea but I'd suggest to make batteries you can install at least medium ones.
Car batteries are still not replaced with lithium (which are all rechargable batteries in game, I assume) due to three factors: price, dependence on temperature and high current requirment for starting engine. Lead/acid batteries handle those better in summ. Anyway, lithium car batteries exist but they are modified to answer those points.
Now, regarding minimal size - I think that light rechargable battery is something like 18650 - and it would go with a bang trying to start anything that is above maybe 1.0L and more powerful than chainsaw.

@Tamiore
Copy link
Contributor Author

Tamiore commented Apr 27, 2020

The problem with "minimal size" is that it will be rather weird and arbitrary limitation: the kind of "vehicle" you might be building may literally be just a solar panel or two powering a stereo system.
It still needs some battery to make it work, but there is no logical reason it can't be the smallest battery ever.
And there are countless other "vehicle" designs that don't even have an engine and simply need a battery to "buffer" power flow from generator (wind turbine, solar panel, etc) into an appliance.

P.S. Plus, the recipe does include a power converter being added to the battery. It's not unreasonable to assume it allows even a small battery to discharge without getting fried.

@CountAlex
Copy link
Contributor

That's a good point.
Maybe that can be fixed with some maximum "battery power" value assigned to battery parts VS power required to start engine, but this calls for separate PR.

@AlexMooney
Copy link
Contributor

Is there a better way to implement it?

My instinct would be to add an item ("Medium Battery Vehicle Adapter (123/500)") that holds a battery (with three versions; tiny & light, medium, and heavy) and that adapter can be installed and removed like any other vehicle battery when it's loaded with a battery. I have no idea if such a thing could be implemented without C++ changes, though.

I was just thinking about the same thing after #39772, because you need a vehicle battery around to charge anything using the solar panel / frame / battery charger "vehicle".

@Tamiore
Copy link
Contributor Author

Tamiore commented Apr 28, 2020

@AlexMooney
It's great that you've mentioned "adapters".
Because here's the deal: if we follow the pattern of all other battery adapters in the game, this new adapter should be installed not onto the battery, but onto the tool/appliance itself.
In this case — it should be a vehicle part that, once installed, allows for plugging/unplugging of appropriate "normal" batteries into the electrical grid in that vehicle tile.

Now, I pretty certain I can make that happen code-wise. Let's call it grid adapter for now.

However, this does effectively make such a part an analog of "proper" recharging station. Key differences would be:

  • grid adapter would only charge batteries when there is surplus power in the system
  • grid adapter would both charge and discharge batteries
  • grid adapter would potentially charge and discharge much faster
  • grid adapter would only accept one battery per vehicle tile (charging station can take however many can go into the storage space)
  • grid adapter makes battery vulnerable to being directly damaged (as they are now distinct part of the vehicle).

With that in mind: is that enough of a list of differences to be meaningfully distinct from charging station without rendering it obsolete?

@Tamiore
Copy link
Contributor Author

Tamiore commented Apr 28, 2020

One more consideration:
Vehicle grid adapter would allow for retention of charge when battery swapping.
Thus any character who starts with, say, a battery (from cell phone) would be able to swap this battery between multiply tools and appliances. Which adds a pretty interesting layer to resource management.

@AlexMooney
Copy link
Contributor

* `grid adapter` would only charge batteries when there is surplus power in the system
* `grid adapter` would both charge and discharge batteries

This is good; recharging stations remain useful to make sure your pile of spare batteries are always topped off. Grid adapter is still super useful for niche uses.

* `grid adapter` would potentially charge and discharge much faster

Someday the vehicle power grid will need to account for power instead of only energy. For now, I don't think it's a problem.

* `grid adapter` would only accept one battery per vehicle tile (charging station can take however many can go into the storage space)
* `grid adapter` makes battery vulnerable to being directly damaged (as they are now distinct part of the vehicle).

It should also take ~1 minute of vehicle interaction to install or remove a vehicle battery, to model making very careful electrical contact and attaching heat sinks to the soon-to-be-abused battery. There will be meme potential about running a firetruck off of a watch battery, but I'm okay with that.

With that in mind: is that enough of a list of differences to be meaningfully distinct from charging station without rendering it obsolete?

I think so; the charging station fills up all batteries in a pile and you can load and unload it as fast as you can drop and pick up. The adapter isn't something you're going to want to use to recharge your batteries, but it's a substitute for vehicle batteries (which are normally very abundant) for niche situations and might be preferable for many folding vehicles.

One more complication is the existence of disposable batteries. Are you planning to allow loading one into a grid adapter? If so, it might be tricky to change the vehicle code to disallow putting energy back into said battery. If not, it will feel strange to not be able to use a disposable battery to run your stereo.

@Tamiore
Copy link
Contributor Author

Tamiore commented Apr 28, 2020

One more complication is the existence of disposable batteries. Are you planning to allow loading one into a grid adapter?

Not initially. For exactly reasons you specified.

If not, it will feel strange to not be able to use a disposable battery to run your stereo.

Technically true, but (luckily) disposable batteries are actually pretty rare.
I mean, 80% -ish of professions start with a cell phone with rechargeable battery. So a scenario where it's your only battery are quite likely to occur. Not the case with disposable batteries.

@mlangsdorf mlangsdorf changed the title [WIP] Vehicle compatibility for normal batteries. [WIP] Adds recipe to modify normal batteries to be used in vehicles. Apr 30, 2020
@mlangsdorf mlangsdorf added Items: Battery / UPS Electric power management Vehicles Vehicles, parts, mechanics & interactions labels Apr 30, 2020
@Tamiore
Copy link
Contributor Author

Tamiore commented May 2, 2020

Changed it from being multiply recipes (on per-battery basics) to one universal battery adapter.

However, there are a few problems/questions I've encountered:

  • Where exactly are FLAGS defined? I want to create a "CONSUMER_BATTERY_MOUNT" flag — conceptually same as "BATTERY_MOUNT", but for this adapter and consumer electronics batteries.
  • How do I disallow repairing the battery when it's installed into the vehicle? "NO_REPAIR" flag on the vehicle part does nothing...

@AlexMooney
Copy link
Contributor

Changed it from being multiply recipes (on per-battery basics) to one universal battery adapter.
👍

However, there are a few problems/questions I've encountered:

  • Where exactly are FLAGS defined? I want to create a "CONSUMER_BATTERY_MOUNT" flag — conceptually same as "BATTERY_MOUNT", but for this adapter and consumer electronics batteries.

Looks like here:

{
"id": "NEEDS_BATTERY_MOUNT",
"type": "json_flag",
"context": [ "vehicle_part" ],
"requires_flag": "BATTERY_MOUNT"
},

and then add a line here:

Cataclysm-DDA/src/vehicle.cpp

Lines 1913 to 1914 in 789d3b2

remove_dependent_part( "SEAT", "SEATBELT" );
remove_dependent_part( "BATTERY_MOUNT", "NEEDS_BATTERY_MOUNT" );

  • How do I disallow repairing the battery when it's installed into the vehicle? "NO_REPAIR" flag on the vehicle part does nothing...

I think NO_REPAIR is for items and not installed vehicle parts. I am guessing you can change your vehicleparts json for light_plus_battery_cell to have this:

    "requirements": {
      "repair": {}
    }

and that will clear repairing. That said, I don't see any examples of the repair being made to be empty on an item. Maybe you should just make it repairable as a normal battery, to save key presses of uninstalling, fixing, & installing.

@AlexMooney
Copy link
Contributor

@Tamiore are you just busy with other things, or you got stuck somewhere? I'm able to help out if you need it.

@Tamiore
Copy link
Contributor Author

Tamiore commented May 13, 2020

@AlexMooney Everything's good, just lots of work last few weeks, haven't had much time to code for this PR.
Thanks for the offer, appreciate it.

@stale
Copy link

stale bot commented Jun 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

@stale stale bot added the stale Closed for lack of activity, but still valid. label Jun 12, 2020
@ZhilkinSerg
Copy link
Contributor

Feel free to resolve conflicts and reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Items: Battery / UPS Electric power management stale Closed for lack of activity, but still valid. Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants