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

Jsonize Cbm power generation #33302

Merged
merged 70 commits into from
Aug 20, 2019
Merged

Conversation

Fris0uman
Copy link
Contributor

@Fris0uman Fris0uman commented Aug 17, 2019

Summary

SUMMARY: Infrastructure "Jsonize Cbm power generation"

Purpose of change

Jsonize Cbm power generation, you can now specify what fuel a CBM can use, the efficiency of the conversion to bionic power and how many charges of fuel the CBM can hold.

Adresses part of #31495

Describe the solution

If player has bionic that can store fuel, it's added to the player fuel storage upon consumption.
Type and amount of fuel and CBM involved in storage are tracked using creature::value
When the bionic is activated we check if there is enought fuel for it to start and if there is enough room for more power to not waste fuel.
Every interval of time specified in "time" the bionic is active it adds fuel_energy * efficiency to the power storage.
The special case of muscle fuel is handled along side the code for joint torsion ratchet

Describe alternatives you've considered

Additional context

I did not remove the hardcoded bionic and did not move them to the unhardcoded system because it would break NPC usage of them.
Messing with the handling of CBMs by NPCs seems to be worth it's own PR.

This system allows for the creation of fuel storage CBM that could be alternative ways to store power.
(Which in turn could also allow mages to carry power without messing with their mana too much ...)

@ghost
Copy link

ghost commented Aug 17, 2019

you can now specify what fuel a CBM can use,

Does that include mana-powered bionics? OwO

@Fris0uman
Copy link
Contributor Author

No not mana, not without some more code.
It needs to have a fuel definition (cf fuel.json) and be available in item form so that you can load your bionic with it. Muscle is an exception, but muscle does have a fuel definition.

src/bionics.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Outdated Show resolved Hide resolved
src/bionics.cpp Outdated
@@ -2096,13 +2150,23 @@ int bionic::get_quality( const quality_id &quality ) const
return item( i.fake_item ).get_quality( quality );
}

bool bionic::is_muscle_powered() const
{
for( const itype_id fuel : this->info().fuel_opts ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for( const itype_id fuel : this->info().fuel_opts ) {
for( const itype_id &fuel : info().fuel_opts ) {

But better would be using std::find, or maybe change fuel_opts into a set and query it directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used std::find, I'm not too sure how to handle making fuel_opts a set

src/game.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added <Documentation> Design documents, internal info, guides and help. [C++] Changes (can be) made in C++. Previously named `Code` labels Aug 17, 2019
@ZhilkinSerg ZhilkinSerg merged commit 96b1c34 into CleverRaven:master Aug 20, 2019
@Fris0uman Fris0uman deleted the cbm_power branch August 20, 2019 21:00
@God-damnit-all
Copy link
Contributor

Why was the reversion to '2040 no mo' included? That seems like it would be out of this PR's scope.

@anothersimulacrum
Copy link
Member

The commits say it reverts it - it is not actually reverted

@God-damnit-all
Copy link
Contributor

Ah, my mistake.

misterprimus pushed a commit to misterprimus/Cataclysm-DDA that referenced this pull request Sep 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bionics CBM (Compact Bionic Modules) [C++] Changes (can be) made in C++. Previously named `Code` <Documentation> Design documents, internal info, guides and help. Items: Battery / UPS Electric power management [JSON] Changes (can be) made in JSON [Markdown] Markdown issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants