Skip to content

Commit

Permalink
Jsonize solar panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Nov 21, 2019
1 parent 32e0c35 commit 4549400
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
15 changes: 15 additions & 0 deletions data/json/items/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@
"flags": [ "PSEUDO", "PERPETUAL" ],
"fuel": { "energy": 1 }
},
{
"type": "GENERIC",
"//": "pseudo item, used as fuel type for CBMs that are sun-powered",
"id": "sunlight",
"symbol": "?",
"color": "white",
"name": "sun light",
"name_plural": "none",
"description": "seeing this is a bug",
"stackable": true,
"price": 0,
"volume": 0,
"flags": [ "PSEUDO", "PERPETUAL" ],
"fuel": { "energy": 1 }
},
{
"type": "GENERIC",
"//": "pseudo item, used as fuel type for CBMs that are metabolism-powered",
Expand Down
5 changes: 4 additions & 1 deletion data/mods/Aftershock/player/afs_bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"name": "Solar Panels",
"description": "Installed on your back is a set of retractable, reinforced solar panels resembling angular butterfly wings. When in direct sunlight, they will automatically deploy and slowly recharge your power level.",
"occupied_bodyparts": [ [ "TORSO", 10 ] ],
"flags": [ "BIONIC_POWER_SOURCE" ]
"fuel_options": [ "sunlight" ],
"fuel_efficiency": 1.0,
"time": 1,
"flags": [ "BIONIC_POWER_SOURCE", "BIONIC_TOGGLED" ]
},
{
"id": "afs_bio_precision_solderers",
Expand Down
11 changes: 10 additions & 1 deletion src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,15 @@ bool Character::burn_fuel( int b, bool start )
//in the menu
if( !start ) {
for( const itype_id &fuel : fuel_available ) {
const int fuel_energy = item( fuel ).fuel_energy();
const item &tmp_fuel = item( fuel );
const int fuel_energy = tmp_fuel.fuel_energy();

int current_fuel_stock;
if( is_metabolism_powered ) {
current_fuel_stock = std::max( 0.0f, get_stored_kcal() - 0.8f *
get_healthy_kcal() );
} else if( tmp_fuel.has_flag( "PERPETUAL" ) ) {
current_fuel_stock = 1;
} else {
current_fuel_stock = std::stoi( get_value( fuel ) );
}
Expand All @@ -887,6 +890,12 @@ bool Character::burn_fuel( int b, bool start )
const units::energy power_gain = kcal_consumed * 4184_J * fuel_efficiency;
mod_stored_kcal( -kcal_consumed );
mod_power_level( power_gain );
} else if( tmp_fuel.has_flag( "PERPETUAL" ) ) {
if( fuel == itype_id( "sunlight" ) ) {
const double modifier = g->natural_light_level( pos().z ) / default_daylight_level();
add_msg( std::to_string( fuel_energy * modifier * fuel_efficiency ) );
mod_power_level( units::from_kilojoule( fuel_energy ) * modifier * fuel_efficiency );
}
} else {
current_fuel_stock -= 1;
set_value( fuel, std::to_string( current_fuel_stock ) );
Expand Down
6 changes: 0 additions & 6 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2871,12 +2871,6 @@ void player::update_needs( int rate_multiplier )
mod_painkiller( -std::min( get_painkiller(), rate_multiplier ) );
}

if( g->is_in_sunlight( pos() ) ) {
if( has_bionic( bn_bio_solar ) ) {
mod_power_level( units::from_kilojoule( rate_multiplier * 25 ) );
}
}

// Huge folks take penalties for cramming themselves in vehicles
if( in_vehicle && ( has_trait( trait_HUGE ) || has_trait( trait_HUGE_OK ) ) ) {
vehicle *veh = veh_pointer_or_null( g->m.veh_at( pos() ) );
Expand Down

0 comments on commit 4549400

Please sign in to comment.