Skip to content

Commit

Permalink
Move ethanol burner CBM to json (#35339)
Browse files Browse the repository at this point in the history
* remove special code for NPCs

* No magic energy from drinking alcohol

* update bio_ethanol to new system

* update talk_tags

* Apply suggestions from code review

Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com>
  • Loading branch information
2 people authored and ZhilkinSerg committed Nov 8, 2019
1 parent b0b890f commit 7afefd7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 33 deletions.
9 changes: 7 additions & 2 deletions data/json/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,14 @@
"id": "bio_ethanol",
"type": "bionic",
"name": "Ethanol Burner",
"description": "You burn alcohol as fuel in an extremely efficient reaction. However, you will still suffer the inebriating effects of the substance.",
"description": "You burn alcohol as fuel in an extremely efficient reaction.",
"occupied_bodyparts": [ [ "TORSO", 26 ] ],
"flags": [ "BIONIC_POWER_SOURCE", "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF" ]
"fuel_options": [ "chem_ethanol", "chem_methanol", "denat_alcohol" ],
"fuel_capacity": 500,
"fuel_efficiency": 0.5,
"exothermic_power_gen": true,
"time": 1,
"flags": [ "BIONIC_POWER_SOURCE", "BIONIC_NPC_USABLE", "BIONIC_SHOCKPROOF", "BIONIC_TOGGLED" ]
},
{
"id": "bio_evap",
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/bionics.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
"type": "BIONIC_ITEM",
"name": "Ethanol Burner CBM",
"looks_like": "bio_int_enhancer",
"description": "A reactor that burns alcohol as fuel in an extremely efficient reaction. However, the user will still suffer the inebriating effects of the substance.",
"description": "A reactor that burns alcohol as fuel in an extremely efficient reaction. It can store up to 500ml and accept ethanol, methanol and denatured aclohol as fuel.",
"price": 120000,
"difficulty": 4
},
Expand Down
10 changes: 4 additions & 6 deletions data/json/npcs/talk_tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1084,14 +1084,12 @@
{
"type": "snippet",
"category": "<need_booze>",
"//": "NPC complaint when they are low on CBM power and have an ethanol burner system. Additional versions should continue to specify that the NPC needs alcohol and they need them to recharge their power CBMs.",
"//": "NPC complaint when they are low on CBM power and have an ethanol burner system. Additional versions should continue to specify that the NPC needs ethanol or methanol and they need them to recharge their power CBMs.",
"text": [
"Pass me a beer, I need to power my ethanol burner.",
"Ethanol burners! The power source that's fun to recharge. Get me a drink, please!",
"Pass some ethanol, I need to power my ethanol burner.",
"Waiter! I need a refill, my ethanol burner is running out of charge!",
"I require ethanol-based drinks for my internal power supply. Anything on you?",
"Got any alcohol to spare? Need to recharge my drives. Mead, if you have any.",
"This ethanol-burning power supply is the best implant I ever got. Speaking of which, got some booze to top me off?"
"I require ethanol for my internal power supply. Anything on you?",
"Got any alcohol to spare? Need to recharge my drives. Methanol, would do."
]
},
{
Expand Down
11 changes: 0 additions & 11 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const mtype_id mon_player_blob( "mon_player_blob" );

const bionic_id bio_advreactor( "bio_advreactor" );
const bionic_id bio_digestion( "bio_digestion" );
const bionic_id bio_ethanol( "bio_ethanol" );
const bionic_id bio_furnace( "bio_furnace" );
const bionic_id bio_reactor( "bio_reactor" );
const bionic_id bio_taste_blocker( "bio_taste_blocker" );
Expand Down Expand Up @@ -813,16 +812,6 @@ bool player::eat( item &food, bool force )
use_charges( food.get_comestible()->tool, 1 );
}

if( has_bionic( bio_ethanol ) && food.type->can_use( "ALCOHOL" ) ) {
mod_power_level( units::from_kilojoule( rng( 50, 200 ) ) );
}
if( has_bionic( bio_ethanol ) && food.type->can_use( "ALCOHOL_WEAK" ) ) {
mod_power_level( units::from_kilojoule( rng( 25, 100 ) ) );
}
if( has_bionic( bio_ethanol ) && food.type->can_use( "ALCOHOL_STRONG" ) ) {
mod_power_level( units::from_kilojoule( rng( 75, 300 ) ) );
}

if( has_active_bionic( bio_taste_blocker ) ) {
mod_power_level( units::from_kilojoule( -abs( food.get_comestible()->fun ) ) );
}
Expand Down
20 changes: 7 additions & 13 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ namespace
{
const std::vector<bionic_id> power_cbms = { {
bio_advreactor,
bio_ethanol,
bio_furnace,
bio_reactor,
}
Expand Down Expand Up @@ -1711,8 +1710,15 @@ bool npc::recharge_cbm()
return true;
} else {
const std::vector<itype_id> fuel_op = bid->fuel_opts;
const bool need_alcohol = std::find( fuel_op.begin(), fuel_op.end(),
"chem_ethanol" ) != fuel_op.end() ||
std::find( fuel_op.begin(), fuel_op.end(), "chem_methanol" ) != fuel_op.end() ||
std::find( fuel_op.begin(), fuel_op.end(), "denat_alcohol" ) != fuel_op.end();

if( std::find( fuel_op.begin(), fuel_op.end(), "battery" ) != fuel_op.end() ) {
complain_about( "need_batteries", 3_hours, "<need_batteries>", false );
} else if( need_alcohol ) {
complain_about( "need_booze", 3_hours, "<need_booze>", false );
} else {
complain_about( "need_fuel", 3_hours, "<need_fuel>", false );
}
Expand All @@ -1732,18 +1738,6 @@ bool npc::recharge_cbm()
}
}

if( use_bionic_by_id( bio_ethanol ) ) {
const std::function<bool( const item & )> ethanol_filter = []( const item & it ) {
return it.type->can_use( "WEAK_ALCOHOL" ) || it.type->can_use( "ALCOHOL" ) ||
it.type->can_use( "STRONG_ALOCHOL" );
};
if( consume_cbm_items( ethanol_filter ) ) {
return true;
} else {
complain_about( "need_booze", 3_hours, "<need_booze>", false );
}
}

if( use_bionic_by_id( bio_reactor ) || use_bionic_by_id( bio_advreactor ) ) {
const std::function<bool( const item & )> reactor_filter = []( const item & it ) {
return it.is_ammo() && ( it.ammo_type() == plutonium ||
Expand Down

0 comments on commit 7afefd7

Please sign in to comment.