Skip to content

Commit

Permalink
Merge remote-tracking branches 'origin/pr/37713' and 'origin/pr/37661'
Browse files Browse the repository at this point in the history
  • Loading branch information
codemime committed Feb 9, 2020
3 parents e55f98d + 33ca8a7 + 39d32cf commit 92a81b5
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 140 deletions.
226 changes: 113 additions & 113 deletions src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,13 +805,7 @@ bool player::eat( item &food, bool force )
add_effect( effect_foodpoison, food.poison * 30_minutes );
}

const bool spiritual = has_trait( trait_SPIRITUAL );
if( food.has_flag( flag_HIDDEN_HALLU ) ) {
if( spiritual ) {
add_morale( MORALE_FOOD_GOOD, 36, 72, 2_hours, 1_hours, false );
} else {
add_morale( MORALE_FOOD_GOOD, 18, 36, 1_hours, 30_minutes, false );
}
if( !has_effect( effect_hallu ) ) {
add_effect( effect_hallu, 6_hours );
}
Expand Down Expand Up @@ -839,28 +833,6 @@ bool player::eat( item &food, bool force )
} else {
add_msg_player_or_npc( _( "You eat your %s." ), _( "<npcname> eats a %s." ),
food.tname() );
if( !spoiled && !food.has_flag( flag_ALLERGEN_JUNK ) ) {
bool has_chair_nearby = false;
for( const tripoint &pt : g->m.points_in_radius( pos(), 1 ) ) {
if( g->m.has_flag_furn( flag_CAN_SIT, pt ) || g->m.has_flag( flag_CAN_SIT, pt ) ||
( g->m.veh_at( pt ) && ( g->m.veh_at( pt )->vehicle().has_part( "SEAT" ) ) ) ) {
has_chair_nearby = true;
}
}
if( has_chair_nearby && g->m.has_nearby_table( pos(), 1 ) ) {
if( has_trait( trait_TABLEMANNERS ) ) {
rem_morale( MORALE_ATE_WITHOUT_TABLE );
add_morale( MORALE_ATE_WITH_TABLE, 3, 3, 3_hours, 2_hours, true );
} else {
add_morale( MORALE_ATE_WITH_TABLE, 1, 1, 3_hours, 2_hours, true );
}
} else {
if( has_trait( trait_TABLEMANNERS ) ) {
rem_morale( MORALE_ATE_WITH_TABLE );
add_morale( MORALE_ATE_WITHOUT_TABLE, -2, -4, 3_hours, 2_hours, true );
}
}
}
}
}

Expand All @@ -873,44 +845,6 @@ bool player::eat( item &food, bool force )
mod_power_level( units::from_kilojoule( -abs( food.get_comestible_fun() ) ) );
}

if( food.has_flag( flag_CANNIBALISM ) ) {
// Sapiovores don't recognize humans as the same species.
// But let them possibly feel cool about eating sapient stuff - treat like psycho
// However, spiritual sapiovores should still recognize humans as having a soul or special for religious reasons
const bool cannibal = has_trait( trait_CANNIBAL );
const bool psycho = has_trait( trait_PSYCHOPATH );
const bool sapiovore = has_trait( trait_SAPIOVORE );
if( ( cannibal || sapiovore ) && psycho && spiritual ) {
add_msg_if_player( m_good,
_( "You feast upon the human flesh, and in doing so, devour their spirit." ) );
// You're not really consuming anything special; you just think you are.
add_morale( MORALE_CANNIBAL, 25, 300 );
} else if( cannibal && psycho ) {
add_msg_if_player( m_good, _( "You feast upon the human flesh." ) );
add_morale( MORALE_CANNIBAL, 15, 200 );
} else if( ( cannibal || sapiovore ) && spiritual ) {
add_msg_if_player( m_good, _( "You consume the sacred human flesh." ) );
// Boosted because you understand the philosophical implications of your actions, and YOU LIKE THEM.
add_morale( MORALE_CANNIBAL, 15, 200 );
} else if( cannibal ) {
add_msg_if_player( m_good, _( "You indulge your shameful hunger." ) );
add_morale( MORALE_CANNIBAL, 10, 50 );
} else if( ( psycho || sapiovore ) && spiritual ) {
add_msg_if_player( _( "You greedily devour the taboo meat." ) );
// Small bonus for violating a taboo.
add_morale( MORALE_CANNIBAL, 5, 50 );
} else if( psycho || sapiovore ) {
add_msg_if_player( _( "Meh. You've eaten worse." ) );
} else if( spiritual ) {
add_msg_if_player( m_bad,
_( "This is probably going to count against you if there's still an afterlife." ) );
add_morale( MORALE_CANNIBAL, -60, -400, 60_minutes, 30_minutes );
} else {
add_msg_if_player( m_bad, _( "You feel horrible for eating a person." ) );
add_morale( MORALE_CANNIBAL, -60, -400, 60_minutes, 30_minutes );
}
}

if( food.has_flag( flag_FUNGAL_VECTOR ) && !has_trait( trait_M_IMMUNE ) ) {
add_effect( effect_fungus, 1_turns, num_bp, true );
}
Expand All @@ -929,53 +863,6 @@ bool player::eat( item &food, bool force )
}
}

// Allergy check
const auto allergy = allergy_type( food );
if( allergy != MORALE_NULL ) {
add_msg_if_player( m_bad, _( "Yuck! How can anybody eat this stuff?" ) );
add_morale( allergy, -75, -400, 30_minutes, 24_minutes );
}
if( food.has_flag( flag_ALLERGEN_JUNK ) ) {
if( has_trait( trait_PROJUNK ) ) {
add_msg_if_player( m_good, _( "Mmm, junk food." ) );
add_morale( MORALE_SWEETTOOTH, 5, 30, 30_minutes, 24_minutes );
}
if( has_trait( trait_PROJUNK2 ) ) {
if( !one_in( 100 ) ) {
add_msg_if_player( m_good, _( "When life's got you down, there's always sugar." ) );
} else {
add_msg_if_player( m_good, _( "They may do what they must… you've already won." ) );
}
add_morale( MORALE_SWEETTOOTH, 10, 50, 1_hours, 50_minutes );
}
}
// Carnivores CAN eat junk food, but they won't like it much.
// Pizza-scraping happens in consume_effects.
if( has_trait( trait_CARNIVORE ) && food.has_flag( flag_ALLERGEN_JUNK ) &&
!food.has_flag( flag_CARNIVORE_OK ) ) {
add_msg_if_player( m_bad, _( "Your stomach begins gurgling and you feel bloated and ill." ) );
add_morale( MORALE_NO_DIGEST, -25, -125, 30_minutes, 24_minutes );
}
if( !spoiled && chew && has_trait( trait_SAPROPHAGE ) ) {
// It's OK to *drink* things that haven't rotted. Alternative is to ban water. D:
add_msg_if_player( m_bad, _( "Your stomach begins gurgling and you feel bloated and ill." ) );
add_morale( MORALE_NO_DIGEST, -75, -400, 30_minutes, 24_minutes );
}
if( food.has_flag( flag_URSINE_HONEY ) && ( !crossed_threshold() ||
has_trait( trait_THRESH_URSINE ) ) &&
mutation_category_level["URSINE"] > 40 ) {
// Need at least 5 bear mutations for effect to show, to filter out mutations in common with other categories
int honey_fun = has_trait( trait_THRESH_URSINE ) ?
std::min( mutation_category_level["URSINE"] / 8, 20 ) :
mutation_category_level["URSINE"] / 12;
if( honey_fun < 10 ) {
add_msg_if_player( m_good, _( "You find the sweet taste of honey surprisingly palatable." ) );
} else {
add_msg_if_player( m_good, _( "You feast upon the sweet honey." ) );
}
add_morale( MORALE_HONEY, honey_fun, 100 );
}

// Chance to become parasitised
if( !will_vomit && !( has_bionic( bio_digestion ) || has_trait( trait_PARAIMMUNE ) ) ) {
if( food.get_comestible()->parasites > 0 && !food.has_flag( flag_NO_PARASITES ) &&
Expand Down Expand Up @@ -1089,6 +976,119 @@ void Character::modify_morale( item &food, const int nutr )
add_morale( MORALE_FOOD_GOOD, fun.first, fun.second, morale_time, morale_time / 2, false,
food.type );
}

// Morale bonus for eating unspoiled food with char/table nearby
if( !food.rotten() && !food.has_flag( flag_ALLERGEN_JUNK ) ) {
if( g->m.has_nearby_chair( pos(), 1 ) && g->m.has_nearby_table( pos(), 1 ) ) {
if( has_trait( trait_TABLEMANNERS ) ) {
rem_morale( MORALE_ATE_WITHOUT_TABLE );
add_morale( MORALE_ATE_WITH_TABLE, 3, 3, 3_hours, 2_hours, true );
} else {
add_morale( MORALE_ATE_WITH_TABLE, 1, 1, 3_hours, 2_hours, true );
}
} else {
if( has_trait( trait_TABLEMANNERS ) ) {
rem_morale( MORALE_ATE_WITH_TABLE );
add_morale( MORALE_ATE_WITHOUT_TABLE, -2, -4, 3_hours, 2_hours, true );
}
}
}

if( food.has_flag( flag_HIDDEN_HALLU ) ) {
if( has_trait( trait_SPIRITUAL ) ) {
add_morale( MORALE_FOOD_GOOD, 36, 72, 2_hours, 1_hours, false );
} else {
add_morale( MORALE_FOOD_GOOD, 18, 36, 1_hours, 30_minutes, false );
}
}

if( food.has_flag( flag_CANNIBALISM ) ) {
// Sapiovores don't recognize humans as the same species.
// But let them possibly feel cool about eating sapient stuff - treat like psycho
// However, spiritual sapiovores should still recognize humans as having a soul or special for religious reasons
const bool cannibal = has_trait( trait_CANNIBAL );
const bool psycho = has_trait( trait_PSYCHOPATH );
const bool sapiovore = has_trait( trait_SAPIOVORE );
const bool spiritual = has_trait( trait_SPIRITUAL );
if( ( cannibal || sapiovore ) && psycho && spiritual ) {
add_msg_if_player( m_good,
_( "You feast upon the human flesh, and in doing so, devour their spirit." ) );
// You're not really consuming anything special; you just think you are.
add_morale( MORALE_CANNIBAL, 25, 300 );
} else if( cannibal && psycho ) {
add_msg_if_player( m_good, _( "You feast upon the human flesh." ) );
add_morale( MORALE_CANNIBAL, 15, 200 );
} else if( ( cannibal || sapiovore ) && spiritual ) {
add_msg_if_player( m_good, _( "You consume the sacred human flesh." ) );
// Boosted because you understand the philosophical implications of your actions, and YOU LIKE THEM.
add_morale( MORALE_CANNIBAL, 15, 200 );
} else if( cannibal ) {
add_msg_if_player( m_good, _( "You indulge your shameful hunger." ) );
add_morale( MORALE_CANNIBAL, 10, 50 );
} else if( ( psycho || sapiovore ) && spiritual ) {
add_msg_if_player( _( "You greedily devour the taboo meat." ) );
// Small bonus for violating a taboo.
add_morale( MORALE_CANNIBAL, 5, 50 );
} else if( psycho || sapiovore ) {
add_msg_if_player( _( "Meh. You've eaten worse." ) );
} else if( spiritual ) {
add_msg_if_player( m_bad,
_( "This is probably going to count against you if there's still an afterlife." ) );
add_morale( MORALE_CANNIBAL, -60, -400, 60_minutes, 30_minutes );
} else {
add_msg_if_player( m_bad, _( "You feel horrible for eating a person." ) );
add_morale( MORALE_CANNIBAL, -60, -400, 60_minutes, 30_minutes );
}
}

// Allergy check
const auto allergy = allergy_type( food );
if( allergy != MORALE_NULL ) {
add_msg_if_player( m_bad, _( "Yuck! How can anybody eat this stuff?" ) );
add_morale( allergy, -75, -400, 30_minutes, 24_minutes );
}
if( food.has_flag( flag_ALLERGEN_JUNK ) ) {
if( has_trait( trait_PROJUNK ) ) {
add_msg_if_player( m_good, _( "Mmm, junk food." ) );
add_morale( MORALE_SWEETTOOTH, 5, 30, 30_minutes, 24_minutes );
}
if( has_trait( trait_PROJUNK2 ) ) {
if( !one_in( 100 ) ) {
add_msg_if_player( m_good, _( "When life's got you down, there's always sugar." ) );
} else {
add_msg_if_player( m_good, _( "They may do what they must… you've already won." ) );
}
add_morale( MORALE_SWEETTOOTH, 10, 50, 1_hours, 50_minutes );
}
}
// Carnivores CAN eat junk food, but they won't like it much.
// Pizza-scraping happens in consume_effects.
if( has_trait( trait_CARNIVORE ) && food.has_flag( flag_ALLERGEN_JUNK ) &&
!food.has_flag( flag_CARNIVORE_OK ) ) {
add_msg_if_player( m_bad, _( "Your stomach begins gurgling and you feel bloated and ill." ) );
add_morale( MORALE_NO_DIGEST, -25, -125, 30_minutes, 24_minutes );
}
const bool chew = food.get_comestible()->comesttype == comesttype_FOOD ||
food.has_flag( flag_USE_EAT_VERB );
if( !food.rotten() && chew && has_trait( trait_SAPROPHAGE ) ) {
// It's OK to *drink* things that haven't rotted. Alternative is to ban water. D:
add_msg_if_player( m_bad, _( "Your stomach begins gurgling and you feel bloated and ill." ) );
add_morale( MORALE_NO_DIGEST, -75, -400, 30_minutes, 24_minutes );
}
if( food.has_flag( flag_URSINE_HONEY ) && ( !crossed_threshold() ||
has_trait( trait_THRESH_URSINE ) ) &&
mutation_category_level["URSINE"] > 40 ) {
// Need at least 5 bear mutations for effect to show, to filter out mutations in common with other categories
int honey_fun = has_trait( trait_THRESH_URSINE ) ?
std::min( mutation_category_level["URSINE"] / 8, 20 ) :
mutation_category_level["URSINE"] / 12;
if( honey_fun < 10 ) {
add_msg_if_player( m_good, _( "You find the sweet taste of honey surprisingly palatable." ) );
} else {
add_msg_if_player( m_good, _( "You feast upon the sweet honey." ) );
}
add_morale( MORALE_HONEY, honey_fun, 100 );
}
}

bool Character::consume_effects( item &food )
Expand Down
56 changes: 29 additions & 27 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3295,39 +3295,41 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
}

// list recipes you could use it in
itype_id tid;
if( contents.empty() ) { // use this item
tid = typeId();
} else { // use the contained item
tid = contents.front().typeId();
}
const std::set<const recipe *> &known_recipes = g->u.get_learned_recipes().of_component( tid );
if( !known_recipes.empty() && parts->test( iteminfo_parts::DESCRIPTION_APPLICABLE_RECIPES ) ) {
const inventory &inv = g->u.crafting_inventory();
if( parts->test( iteminfo_parts::DESCRIPTION_APPLICABLE_RECIPES ) ) {
itype_id tid = contents.empty() ? typeId() : contents.front().typeId();
const inventory &crafting_inv = g->u.crafting_inventory();
const recipe_subset available_recipe_subset = g->u.get_available_recipes( crafting_inv );
const std::set<const recipe *> &item_recipes = available_recipe_subset.of_component( tid );

if( known_recipes.size() > 24 ) {
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION",
_( "You know dozens of things you could craft with it." ) ) );
} else if( known_recipes.size() > 12 ) {
if( item_recipes.empty() ) {
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION",
_( "You could use it to craft various other things." ) ) );
_( "You know of nothing you could craft with it." ) ) );
} else {
const std::string recipes = enumerate_as_string( known_recipes.begin(), known_recipes.end(),
[ &inv ]( const recipe * r ) {
if( r->deduped_requirements().can_make_with_inventory(
inv, r->get_component_filter() ) ) {
return r->result_name();
} else {
return string_format( "<dark>%s</dark>", r->result_name() );
}
} );
if( !recipes.empty() ) {
if( item_recipes.size() > 24 ) {
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION",
_( "You know dozens of things you could craft with it." ) ) );
} else if( item_recipes.size() > 12 ) {
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION",
string_format( _( "You could use it to craft: %s" ),
recipes ) ) );
_( "You could use it to craft various other things." ) ) );
} else {
const std::string recipes = enumerate_as_string( item_recipes.begin(), item_recipes.end(),
[ &crafting_inv ]( const recipe * r ) {
if( r->deduped_requirements().can_make_with_inventory(
crafting_inv, r->get_component_filter() ) ) {
return r->result_name();
} else {
return string_format( "<dark>%s</dark>", r->result_name() );
}
} );
if( !recipes.empty() ) {
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION",
string_format( _( "You could use it to craft: %s" ),
recipes ) ) );
}
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2601,6 +2601,20 @@ bool map::has_nearby_table( const tripoint &p, int radius )
return false;
}

bool map::has_nearby_chair( const tripoint &p, int radius )
{
for( const tripoint &pt : points_in_radius( p, radius ) ) {
const optional_vpart_position vp = veh_at( pt );
if( has_flag( "CAN_SIT", pt ) ) {
return true;
}
if( vp && vp->vehicle().has_part( "SEAT" ) ) {
return true;
}
}
return false;
}

bool map::mop_spills( const tripoint &p )
{
bool retval = false;
Expand Down
4 changes: 4 additions & 0 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,10 @@ class map
* surface is nearby that could be used for crafting or eating.
*/
bool has_nearby_table( const tripoint &p, int radius = 1 );
/**
* Check whether a chair or vehicle seat is nearby.
*/
bool has_nearby_chair( const tripoint &p, int radius = 1 );
/**
* Check if creature can see some items at p. Includes:
* - check for items at this location (has_items(p))
Expand Down
Loading

0 comments on commit 92a81b5

Please sign in to comment.