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

Reworks and Reintroduced Micro Reactor & Radiation Scrubber CBM's #2663

Merged
merged 11 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,36 @@
"time": 1,
"flags": [ "BIONIC_TOGGLED", "BIONIC_POWER_SOURCE", "BIONIC_NPC_USABLE" ]
},
{
"id": "bio_reactor",
"type": "bionic",
"name": { "str": "Micro Reactor" },
"description": "This stripped down mini-reactor generates impressive amounts of bionic power but slowly irradiates the user.",
"occupied_bodyparts": [ [ "torso", 55 ] ],
"encumbrance": [ [ "torso", 5 ] ],
"fuel_options": [ "plut_cell" ],
"fuel_capacity": 10000,
"fuel_efficiency": 1,
"fuel_multiplier": 2500,
"time": 1,
"flags": [ "BIONIC_TOGGLED", "BIONIC_POWER_SOURCE", "BIONIC_NPC_USABLE" ],
"available_upgrades": [ "bio_advreactor" ]
},
{
"id": "bio_advreactor",
"type": "bionic",
"name": { "str": "Advanced Micro Reactor" },
"description": "This stripped down mini-reactor has been heavily modified and is more efficient and safer than the base model.",
"occupied_bodyparts": [ [ "torso", 55 ] ],
"encumbrance": [ [ "torso", 5 ] ],
"fuel_options": [ "plut_cell" ],
"fuel_capacity": 12000,
"fuel_efficiency": 1.25,
"fuel_multiplier": 3000,
"time": 1,
"flags": [ "BIONIC_TOGGLED", "BIONIC_POWER_SOURCE", "BIONIC_NPC_USABLE" ],
"upgraded_bionic": "bio_reactor"
},
{
"id": "bio_syringe",
"type": "bionic",
Expand Down
10 changes: 7 additions & 3 deletions data/json/itemgroups/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
[ "afs_bio_missiles", 10 ],
[ "afs_bio_linguistic_coprocessor", 10 ],
[ "afs_bio_dopamine_stimulators", 10 ],
[ "bio_blaster", 5 ]
[ "bio_blaster", 5 ],
[ "bio_reactor", 10 ]
]
},
{
Expand Down Expand Up @@ -358,7 +359,8 @@
[ "bio_ods", 10 ],
[ "bio_weight", 15 ],
[ "afs_bio_missiles", 10 ],
[ "afs_bio_dopamine_stimulators", 15 ]
[ "afs_bio_dopamine_stimulators", 15 ],
[ "bio_reactor", 10 ]
]
},
{
Expand Down Expand Up @@ -418,7 +420,9 @@
[ "bio_teleport", 4 ],
[ "bio_probability_travel", 4 ],
[ "afs_bio_linguistic_coprocessor", 10 ],
[ "afs_bio_dopamine_stimulators", 10 ]
[ "afs_bio_dopamine_stimulators", 10 ],
[ "bio_reactor", 10 ],
[ "bio_reactor_upgrade", 10 ]
]
},
{
Expand Down
29 changes: 29 additions & 0 deletions data/json/items/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,35 @@
"weight": "600 g",
"difficulty": 7
},
{
"id": "bio_reactor",
"copy-from": "bionic_general_npc_usable",
"type": "BIONIC_ITEM",
"name": { "str": "Internal Microreactor CBM" },
"description": "This stripped down mini-reactor will generate impressive amounts of bionic power, but may not be the safest thing to install. Once active, it cannot be shut down and will slowly contaminate the user's body with radiation.",
"price": 900000,
"difficulty": 11
},
{
"id": "bio_advreactor",
"copy-from": "bionic_general_npc_usable",
"type": "BIONIC_ITEM",
"name": { "str": "Advanced Microreactor CBM" },
"description": "This module upgrades a pre-installed microreactor with enhanced maximum yield and limited automatic radiation scrubbing capabilities.",
"price": 900000,
"difficulty": 13
},
{
"id": "bio_reactor_upgrade",
"bionic_id": "bio_advreactor",
"copy-from": "bionic_general_npc_usable",
"type": "BIONIC_ITEM",
"name": { "str": "Microreactor Upgrade CBM" },
"description": "A kit for upgrading a pre-installed microreactor with enhanced maximum yield and limited automatic radiation scrubbing capabilities.",
"price": 250000,
"difficulty": 11,
"is_upgrade": true
},
{
"id": "bio_recycler",
"copy-from": "bionic_general_npc_usable",
Expand Down
39 changes: 0 additions & 39 deletions data/json/obsoletion/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,45 +421,6 @@
"relative": { "reload": 2 },
"magazines": [ [ "flammable", [ "aux_pressurized_tank", "pressurized_tank" ] ] ]
},
{
"id": "bio_advreactor",
"copy-from": "bionic_general_npc_usable",
"type": "BIONIC_ITEM",
"name": { "str": "Advanced Microreactor CBM" },
"description": "This module upgrades a pre-installed microreactor with enhanced maximum yield and limited automatic radiation scrubbing capabilities.",
"price": 900000,
"difficulty": 13
},
{
"id": "bio_plut_filter",
"copy-from": "bionic_general_npc_usable",
"type": "BIONIC_ITEM",
"name": { "str": "Plutonium Filter CBM" },
"description": "A system of tanks and filters that are connected to a microreactor to extract plutonium from radioactive slurry.",
"price": 60000,
"weight": "1000 g",
"difficulty": 6
},
{
"id": "bio_reactor",
"copy-from": "bionic_general_npc_usable",
"type": "BIONIC_ITEM",
"name": { "str": "Internal Microreactor CBM" },
"description": "This stripped down mini-reactor will generate impressive amounts of bionic power, but may not be the safest thing to install. Once active, it cannot be shut down and will slowly contaminate the user's body with radiation.",
"price": 900000,
"difficulty": 11
},
{
"id": "bio_reactor_upgrade",
"bionic_id": "bio_advreactor",
"copy-from": "bionic_general_npc_usable",
"type": "BIONIC_ITEM",
"name": { "str": "Microreactor Upgrade CBM" },
"description": "A kit for upgrading a pre-installed microreactor with enhanced maximum yield and limited automatic radiation scrubbing capabilities.",
"price": 250000,
"difficulty": 11,
"is_upgrade": true
},
{
"id": "v29_cheap",
"type": "GUN",
Expand Down
39 changes: 0 additions & 39 deletions data/json/obsoletion/uncategorized.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,4 @@
[
{
"id": "bio_advreactor",
"type": "bionic",
"name": { "str": "Advanced Microreactor System" },
"description": "This stripped down mini-reactor is more efficient and safer than the base model due to integrated radiation cleansers. There is no way to shut it down once active, but you can toggle additional fuel intake.",
"occupied_bodyparts": [ [ "torso", 55 ] ],
"flags": [ "BIONIC_POWER_SOURCE", "BIONIC_TOGGLED", "BIONIC_NPC_USABLE" ],
"included_bionics": [ "bio_plutdump" ],
"upgraded_bionic": "bio_reactor"
},
{
"id": "bio_plut_filter",
"type": "bionic",
"name": { "str": "Plutonium Filter" },
"description": "This set of tanks and filters allows you to extract plutonium from radioactive slurry.",
"occupied_bodyparts": [ [ "torso", 10 ] ],
"flags": [ "BIONIC_TOGGLED", "BIONIC_NPC_USABLE" ],
"act_cost": 1,
"react_cost": 1,
"time": 12
},
{
"id": "bio_plutdump",
"type": "bionic",
"name": { "str": "Plutonium Purger" },
"included": true,
"description": "Triggers an emergency reactor fuel purge that ejects all fuel from your reactor.",
"act_cost": 1
},
{
"id": "bio_reactor",
"type": "bionic",
"name": { "str": "Microreactor System" },
"description": "This stripped down mini-reactor generates impressive amounts of bionic power. There is no way to shut it down, but you can toggle additional fuel intake. Irradiates your body when active.",
"occupied_bodyparts": [ [ "torso", 55 ] ],
"flags": [ "BIONIC_POWER_SOURCE", "BIONIC_TOGGLED", "BIONIC_NPC_USABLE" ],
"available_upgrades": [ "bio_advreactor" ],
"included_bionics": [ "bio_plutdump" ]
},
{
"id": "bio_furnace",
"type": "bionic",
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_INFO.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ This section describes each json file and their contents. Each json has their ow
| is_remote_fueled | (_optional_) If true this bionic allows you to plug your power banks to an external power source (solar backpack, UPS, vehicle etc) via a cable. (default: `false`)
| fuel_capacity | (_optional_) Volume of fuel this bionic can store.
| fuel_efficiency | (_optional_) Fraction of fuel energy converted into power. (default: `0`)
| fuel_multiplier | (_optional_) Multiplies the amount of fuel when loading into the bionic (default: `1`)
| passive_fuel_efficiency | (_optional_) Fraction of fuel energy passively converted into power. Useful for CBM using PERPETUAL fuel like `muscle`, `wind` or `sun_light`. (default: `0`)
| exothermic_power_gen | (_optional_) If true this bionic emits heat when producing power. (default: `false`)
| coverage_power_gen_penalty | (_optional_) Fraction of coverage diminishing fuel_efficiency. Float between 0.0 and 1.0. (default: `nullopt`)
Expand Down
1 change: 1 addition & 0 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ void bionic_data::load( const JsonObject &jsobj, const std::string src )
assign( jsobj, "fuel_options", fuel_opts, strict );
assign( jsobj, "fuel_capacity", fuel_capacity, strict, 0 );
assign( jsobj, "fuel_efficiency", fuel_efficiency, strict, 0.0f );
assign( jsobj, "fuel_multiplier", fuel_multiplier, strict, 0 );
assign( jsobj, "passive_fuel_efficiency", passive_fuel_efficiency, strict, 0.0f );
assign( jsobj, "coverage_power_gen_penalty", coverage_power_gen_penalty, strict );
assign( jsobj, "exothermic_power_gen", exothermic_power_gen, strict );
Expand Down
2 changes: 2 additions & 0 deletions src/bionics.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ struct bionic_data {
int fuel_capacity = 0;
/**Fraction of fuel energy converted to bionic power*/
float fuel_efficiency = 0.0f;
/**Multiplies the amount of fuel when loading into the bionic storage*/
int fuel_multiplier = 1;
/**Fraction of fuel energy passively converted to bionic power*/
float passive_fuel_efficiency = 0.0f;
/**Fraction of coverage diminishing fuel_efficiency*/
Expand Down
10 changes: 7 additions & 3 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,17 +1388,21 @@ bool Character::fuel_bionic_with( item &it )
}

const bionic_id bio = get_most_efficient_bionic( get_bionic_fueled_with( it ) );

const int loadable = std::min( it.charges, get_fuel_capacity( it.typeId() ) );
const std::string str_loaded = get_value( it.typeId().str() );

const int fuel_multiplier = get_bionic_state( bio ).info().fuel_multiplier;

int loadable = std::min( it.charges * fuel_multiplier, get_fuel_capacity( it.typeId() ) );
int loaded = 0;

if( !str_loaded.empty() ) {
loaded = std::stoi( str_loaded );
}

const std::string new_charge = std::to_string( loadable + loaded );

it.charges -= loadable;
loadable = std::ceil( loadable / fuel_multiplier );
it.charges -= std::ceil( loadable / fuel_multiplier );
// Type and amount of fuel
set_value( it.typeId().str(), new_charge );
update_fuel_storage( it.typeId() );
Expand Down
87 changes: 11 additions & 76 deletions src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include "units.h"
#include "weather.h"

static const bionic_id bio_advreactor( "bio_advreactor" );
static const bionic_id bio_dis_acid( "bio_dis_acid" );
static const bionic_id bio_dis_shock( "bio_dis_shock" );
static const bionic_id bio_drain( "bio_drain" );
Expand All @@ -70,6 +69,8 @@ static const bionic_id bio_noise( "bio_noise" );
static const bionic_id bio_plut_filter( "bio_plut_filter" );
static const bionic_id bio_power_weakness( "bio_power_weakness" );
static const bionic_id bio_reactor( "bio_reactor" );
static const bionic_id bio_advreactor( "bio_advreactor" );
static const bionic_id bio_radscrubber( "bio_radscrubber" );
static const bionic_id bio_shakes( "bio_shakes" );
static const bionic_id bio_sleepy( "bio_sleepy" );
static const bionic_id bio_spasm( "bio_spasm" );
Expand Down Expand Up @@ -1146,82 +1147,16 @@ void Character::suffer_from_radiation()
if( get_rad() > 200 && calendar::once_every( 10_minutes ) && x_in_y( get_rad(), 1000 ) ) {
hurtall( 1, nullptr );
mod_rad( -5 );
}
}
MrLostman marked this conversation as resolved.
Show resolved Hide resolved

if( !reactor_plut && !tank_plut && !slow_rad ) {
return;
}
// Microreactor CBM and supporting bionics
if( has_bionic( bio_reactor ) || has_bionic( bio_advreactor ) ) {
//first do the filtering of plutonium from storage to reactor
if( tank_plut > 0 ) {
int plut_trans;
if( has_active_bionic( bio_plut_filter ) ) {
plut_trans = tank_plut * 0.025;
} else {
plut_trans = tank_plut * 0.005;
}
if( plut_trans < 1 ) {
plut_trans = 1;
}
tank_plut -= plut_trans;
reactor_plut += plut_trans;
}
//leaking radiation, reactor is unshielded, but still better than a simple tank
slow_rad += ( ( tank_plut * 0.1 ) + ( reactor_plut * 0.01 ) );
//begin power generation
if( reactor_plut > 0 ) {
int power_gen = 0;
if( has_bionic( bio_advreactor ) ) {
if( ( reactor_plut * 0.05 ) > 2000 ) {
power_gen = 2000;
} else {
power_gen = reactor_plut * 0.05;
if( power_gen < 1 ) {
power_gen = 1;
}
}
slow_rad += ( power_gen * 3 );
while( slow_rad >= 50 ) {
if( power_gen >= 1 ) {
slow_rad -= 50;
power_gen -= 1;
reactor_plut -= 1;
} else {
break;
}
}
} else if( has_bionic( bio_reactor ) ) {
if( ( reactor_plut * 0.025 ) > 500 ) {
power_gen = 500;
} else {
power_gen = reactor_plut * 0.025;
if( power_gen < 1 ) {
power_gen = 1;
}
}
slow_rad += ( power_gen * 3 );
}
reactor_plut -= power_gen;
while( power_gen >= 250 ) {
apply_damage( nullptr, bodypart_id( "torso" ), 1 );
mod_pain( 1 );
add_msg_if_player( m_bad,
_( "Your chest burns as your power systems overload!" ) );
mod_power_level( 50_kJ );
power_gen -= 60; // ten units of power lost due to short-circuiting into you
}
mod_power_level( units::from_kilojoule( power_gen ) );
}
} else {
slow_rad += ( reactor_plut + tank_plut ) * 40;
//plutonium in body without any kind of container. Not good at all.
reactor_plut *= 0.6;
tank_plut *= 0.6;
}
while( slow_rad >= 1000 ) {
mod_rad( 1 );
slow_rad -= 1000;
// Microreactor CBM Radiation
int rad_mod = 0;
rad_mod += has_bionic( bio_reactor ) ? 3;
rad_mod += has_bionic( bio_advreactor ) ? 2;
rad_mod += has_bionic( bio_radscrubber ) ? -1;

if( rad_mod > 1 && calendar::once_every( 60_minutes ) ) {
mod_rad( rad_mod );
}
}

Expand Down