Skip to content

Commit

Permalink
Merge pull request #74217 from Procyonae/RemoveExternMoraleTypes
Browse files Browse the repository at this point in the history
Remove extern morale_type ids
  • Loading branch information
Maleclypse authored Jun 10, 2024
2 parents 23e26e7 + ea83940 commit b7f634c
Show file tree
Hide file tree
Showing 44 changed files with 508 additions and 731 deletions.
2 changes: 1 addition & 1 deletion data/json/npcs/other/NPC_pizzaiolo.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"type": "talk_topic",
"id": "TALK_pizzaiolo_celebrate1",
"dynamic_line": "Mmm, delicious. You know, you are good friend, and a good cook. I'm glad that I'm with you at the day like this. Say, what do you think about me going with you? As you can see, my restaurant is thrashes, my house ruined, the only option left is to travel somewhere, and it's better if I do it with someone.",
"speaker_effect": { "effect": [ "morale_chat", { "npc_add_trait": "BGSS_pizzaiolo" } ] },
"speaker_effect": { "effect": [ "morale_chat_activity", { "npc_add_trait": "BGSS_pizzaiolo" } ] },
"responses": [
{ "text": "Sure, <name_g>. <end_talking>", "topic": "TALK_DONE", "effect": "follow" },
{
Expand Down
20 changes: 13 additions & 7 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ static const itype_id itype_water_clean( "water_clean" );

static const json_character_flag json_flag_SAFECRACK_NO_TOOL( "SAFECRACK_NO_TOOL" );

static const morale_type morale_book( "morale_book" );
static const morale_type morale_feeling_good( "morale_feeling_good" );
static const morale_type morale_haircut( "morale_haircut" );
static const morale_type morale_play_with_pet( "morale_play_with_pet" );
static const morale_type morale_shave( "morale_shave" );

static const move_mode_id move_mode_prone( "prone" );
static const move_mode_id move_mode_walk( "walk" );

Expand Down Expand Up @@ -1944,7 +1950,7 @@ bool read_activity_actor::player_read( avatar &you )
const int book_fun = learner->book_fun_for( *book, *learner );
if( book_fun != 0 ) {
// Fun bonus is no longer calculated here.
learner->add_morale( MORALE_BOOK,
learner->add_morale( morale_book,
book_fun * 5, book_fun * 15,
1_hours, 30_minutes, true,
book->type );
Expand Down Expand Up @@ -2100,7 +2106,7 @@ bool read_activity_actor::npc_read( npc &learner )
const int book_fun = learner.book_fun_for( *book, learner );
if( book_fun != 0 ) {
// Fun bonus is no longer calculated here.
learner.add_morale( MORALE_BOOK,
learner.add_morale( morale_book,
book_fun * 5, book_fun * 15,
1_hours, 30_minutes, true,
book->type );
Expand Down Expand Up @@ -3939,7 +3945,7 @@ void workout_activity_actor::do_turn( player_activity &act, Character &who )
// morale bonus kicks in gradually after 5 minutes of exercise
if( calendar::once_every( 2_minutes ) &&
( ( elapsed + act.moves_total - act.moves_left ) / 100 * 1_turns ) > 5_minutes ) {
who.add_morale( MORALE_FEELING_GOOD, intensity_modifier, 20, 6_hours, 30_minutes );
who.add_morale( morale_feeling_good, intensity_modifier, 20, 6_hours, 30_minutes );
}
if( calendar::once_every( 2_minutes ) ) {
add_msg_debug_if( who.is_avatar(), debugmode::DF_ACT_WORKOUT, who.activity_level_str() );
Expand Down Expand Up @@ -5651,7 +5657,7 @@ void meditate_activity_actor::start( player_activity &act, Character & )
void meditate_activity_actor::finish( player_activity &act, Character &who )
{
who.add_msg_if_player( m_good, _( "You pause to engage in spiritual contemplation." ) );
who.add_morale( MORALE_FEELING_GOOD, 5, 10 );
who.add_morale( morale_feeling_good, 5, 10 );
act.set_to_null();
}

Expand All @@ -5673,7 +5679,7 @@ void play_with_pet_activity_actor::start( player_activity &act, Character & )

void play_with_pet_activity_actor::finish( player_activity &act, Character &who )
{
who.add_morale( MORALE_PLAY_WITH_PET, rng( 3, 10 ), 10, 5_hours, 25_minutes );
who.add_morale( morale_play_with_pet, rng( 3, 10 ), 10, 5_hours, 25_minutes );

if( !playstr.empty() ) {
who.add_msg_if_player( m_good, playstr, pet_name );
Expand Down Expand Up @@ -6027,7 +6033,7 @@ void shave_activity_actor::start( player_activity &act, Character & )
void shave_activity_actor::finish( player_activity &act, Character &who )
{
who.add_msg_if_player( _( "You open up your kit and shave." ) );
who.add_morale( MORALE_SHAVE, 8, 8, 240_minutes, 3_minutes );
who.add_morale( morale_shave, 8, 8, 240_minutes, 3_minutes );
act.set_to_null();
}

Expand All @@ -6050,7 +6056,7 @@ void haircut_activity_actor::start( player_activity &act, Character & )
void haircut_activity_actor::finish( player_activity &act, Character &who )
{
who.add_msg_if_player( _( "You give your hair a trim." ) );
who.add_morale( MORALE_HAIRCUT, 3, 3, 480_minutes, 3_minutes );
who.add_morale( morale_haircut, 3, 3, 480_minutes, 3_minutes );
if( who.is_avatar() ) {
uilist amenu;
amenu.title = _( "Change what?" );
Expand Down
32 changes: 18 additions & 14 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
#include "messages.h"
#include "mongroup.h"
#include "monster.h"
#include "morale_types.h"
#include "mtype.h"
#include "npc.h"
#include "omdata.h"
Expand Down Expand Up @@ -226,6 +225,11 @@ static const json_character_flag json_flag_SOCIAL2( "SOCIAL2" );

static const mongroup_id GROUP_FISH( "GROUP_FISH" );

static const morale_type morale_butcher( "morale_butcher" );
static const morale_type morale_feeling_good( "morale_feeling_good" );
static const morale_type morale_game( "morale_game" );
static const morale_type morale_tree_communion( "morale_tree_communion" );

static const proficiency_id proficiency_prof_dissect_humans( "prof_dissect_humans" );

static const quality_id qual_BUTCHER( "BUTCHER" );
Expand Down Expand Up @@ -631,7 +635,7 @@ static void set_up_butchery( player_activity &act, Character &you, butcher_type
_( "You try to look away, but this gruesome image will stay on your mind for some time." ) );
break;
}
get_player_character().add_morale( MORALE_BUTCHER, -50, 0, 2_days, 3_hours );
get_player_character().add_morale( morale_butcher, -50, 0, 2_days, 3_hours );
} else {
//player has the dissect_humans prof, so they're familiar with dissection. reference this in their refusal to butcher
you.add_msg_if_player( m_good, _( "You were trained for autopsies, not butchery." ) );
Expand All @@ -640,7 +644,7 @@ static void set_up_butchery( player_activity &act, Character &you, butcher_type
}
} else {
//if not the avatar, don't ask, just do it and suffer without comment
you.add_morale( MORALE_BUTCHER, -50, 0, 2_days, 3_hours );
you.add_morale( morale_butcher, -50, 0, 2_days, 3_hours );
}
} else {
//this runs if the butcherer does NOT have prof_dissect_humans
Expand All @@ -659,7 +663,7 @@ static void set_up_butchery( player_activity &act, Character &you, butcher_type
_( "You try to look away, but this gruesome image will stay on your mind for some time." ) );
break;
}
get_player_character().add_morale( MORALE_BUTCHER, -50, 0, 2_days, 3_hours );
get_player_character().add_morale( morale_butcher, -50, 0, 2_days, 3_hours );
} else {
//player doesn't have dissect_humans, so just give a regular refusal to mess with the corpse
you.add_msg_if_player( m_good, _( "It needs a coffin, not a knife." ) );
Expand All @@ -668,7 +672,7 @@ static void set_up_butchery( player_activity &act, Character &you, butcher_type
}
} else {
//again, don't complain about it, or inform about it, just do it
you.add_morale( MORALE_BUTCHER, -50, 0, 2_days, 3_hours );
you.add_morale( morale_butcher, -50, 0, 2_days, 3_hours );
}
}
}
Expand Down Expand Up @@ -713,7 +717,7 @@ static void set_up_butchery( player_activity &act, Character &you, butcher_type
_( "The grim nature of your task deeply upsets you, leaving you feeling disgusted with yourself." ) );
break;
}
get_player_character().add_morale( MORALE_BUTCHER, -40, 0, 1_days, 2_hours );
get_player_character().add_morale( morale_butcher, -40, 0, 1_days, 2_hours );
} else {
//standard refusal to butcher
you.add_msg_if_player( m_good, _( "It needs a coffin, not a knife." ) );
Expand All @@ -722,7 +726,7 @@ static void set_up_butchery( player_activity &act, Character &you, butcher_type
}
} else {
//if we're not player and don't have dissect_humans, just add morale penalty.
you.add_morale( MORALE_BUTCHER, -40, 0, 1_days, 2_hours );
you.add_morale( morale_butcher, -40, 0, 1_days, 2_hours );
}
}
}
Expand Down Expand Up @@ -1686,7 +1690,7 @@ void activity_handlers::generic_game_turn_handler( player_activity *act, Charact
morale_max_bonus *= mod;
}
// Playing alone - 1 points/min, almost 2 hours to fill
you->add_morale( MORALE_GAME, morale_bonus, morale_max_bonus );
you->add_morale( morale_game, morale_bonus, morale_max_bonus );
}
}

Expand All @@ -1707,7 +1711,7 @@ void activity_handlers::generic_game_finish( player_activity *act, Character *yo
you->add_msg_if_player( m_good, _( "You won!" ) );
you->add_msg_if_npc( m_good, _( "<npcname> won!" ) );
}
you->add_morale( MORALE_GAME, 4 * mod );
you->add_morale( morale_game, 4 * mod );
}
act->set_to_null();
}
Expand Down Expand Up @@ -2202,13 +2206,13 @@ void activity_handlers::vibe_do_turn( player_activity *act, Character *you )
if( calendar::once_every( 1_minutes ) ) {
if( vibrator_item.ammo_remaining( you ) > 0 ) {
vibrator_item.ammo_consume( 1, you->pos(), you );
you->add_morale( MORALE_FEELING_GOOD, 3, 40 );
you->add_morale( morale_feeling_good, 3, 40 );
if( vibrator_item.ammo_remaining( you ) == 0 ) {
add_msg( m_info, _( "The %s runs out of batteries." ), vibrator_item.tname() );
}
} else {
//twenty minutes to fill
you->add_morale( MORALE_FEELING_GOOD, 1, 40 );
you->add_morale( morale_feeling_good, 1, 40 );
}
}
// Dead Tired: different kind of relaxation needed
Expand Down Expand Up @@ -3501,7 +3505,7 @@ void activity_handlers::fetch_do_turn( player_activity *act, Character *you )
void activity_handlers::vibe_finish( player_activity *act, Character *you )
{
you->add_msg_if_player( m_good, _( "You feel much better." ) );
you->add_morale( MORALE_FEELING_GOOD, 10, 40 );
you->add_morale( morale_feeling_good, 10, 40 );
act->set_to_null();
}

Expand Down Expand Up @@ -3793,9 +3797,9 @@ void activity_handlers::tree_communion_do_turn( player_activity *act, Character
tripoint_abs_omt tpt = q.front();
if( overmap_buffer.reveal( tpt, 3, filter ) ) {
if( you->has_trait( trait_SPIRITUAL ) ) {
you->add_morale( MORALE_TREE_COMMUNION, 2, 30, 8_hours, 6_hours );
you->add_morale( morale_tree_communion, 2, 30, 8_hours, 6_hours );
} else {
you->add_morale( MORALE_TREE_COMMUNION, 1, 15, 2_hours, 1_hours );
you->add_morale( morale_tree_communion, 1, 15, 2_hours, 1_hours );
}
if( one_in( 128 ) ) {
if( one_in( 256 ) ) {
Expand Down
29 changes: 18 additions & 11 deletions src/addiction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@
#include "generic_factory.h"
#include "init.h"
#include "json_error.h"
#include "morale_types.h"
#include "rng.h"
#include "talker.h"
#include "text_snippets.h"

static const efftype_id effect_hallu( "hallu" );
static const efftype_id effect_shakes( "shakes" );

static const morale_type morale_craving_alcohol( "morale_craving_alcohol" );
static const morale_type morale_craving_cocaine( "morale_craving_cocaine" );
static const morale_type morale_craving_crack( "morale_craving_crack" );
static const morale_type morale_craving_diazepam( "morale_craving_diazepam" );
static const morale_type morale_craving_nicotine( "morale_craving_nicotine" );
static const morale_type morale_craving_opiate( "morale_craving_opiate" );
static const morale_type morale_craving_speed( "morale_craving_speed" );

namespace
{

Expand Down Expand Up @@ -71,8 +78,8 @@ static bool alcohol_diazepam_add( Character &u, int in, bool is_alcohol )
static time_point last_dia_dream = calendar::turn_zero;
const bool recent_dream = ( is_alcohol && ( calendar::turn - last_alc_dream < 2_hours ) ) ||
( !is_alcohol && ( calendar::turn - last_dia_dream < 2_hours ) );
const morale_type morale_type = is_alcohol ? MORALE_CRAVING_ALCOHOL :
MORALE_CRAVING_DIAZEPAM;
const morale_type morale_type = is_alcohol ? morale_craving_alcohol :
morale_craving_diazepam;
bool ret = false;
u.mod_per_bonus( -1 );
u.mod_int_bonus( -1 );
Expand Down Expand Up @@ -130,8 +137,8 @@ static bool crack_coke_add( Character &u, int in, int stim, bool is_crack )
!is_crack ?
( u.in_sleep_state() ? "addict_coke_asleep" : "addict_coke_awake" ) :
( u.in_sleep_state() ? "addict_crack_asleep" : "addict_crack_awake" );
const morale_type morale_type = !is_crack ? MORALE_CRAVING_COCAINE :
MORALE_CRAVING_CRACK;
const morale_type morale_type = !is_crack ? morale_craving_cocaine :
morale_craving_crack;
bool ret = false;
auto run_addict_eff = [&ret, &morale_type]( Character & u, int in, bool is_crack,
const std::string & snippet ) {
Expand Down Expand Up @@ -180,7 +187,7 @@ static bool nicotine_effect( Character &u, addiction &add )
( u.in_sleep_state() ? "addict_nicotine_strong_asleep" : "addict_nicotine_strong_awake" );
u.add_msg_if_player( m_warning,
SNIPPET.random_from_category( msg ).value_or( translation() ).translated() );
u.add_morale( MORALE_CRAVING_NICOTINE, -15, -3 * in );
u.add_morale( morale_craving_nicotine, -15, -3 * in );
if( one_in( 800 - 50 * in ) ) {
u.mod_sleepiness( 1 );
}
Expand Down Expand Up @@ -236,7 +243,7 @@ static bool opiate_effect( Character &u, addiction &add )
u.in_sleep_state() ? "addict_opiate_mild_asleep" : "addict_opiate_mild_awake";
u.add_msg_if_player( m_bad,
SNIPPET.random_from_category( msg ).value_or( translation() ).translated() );
u.add_morale( MORALE_CRAVING_OPIATE, -40, -10 * in );
u.add_morale( morale_craving_opiate, -40, -10 * in );
u.add_effect( effect_shakes, 2_minutes + in * 30_seconds );
} else if( one_in( 20 ) && dice( 2, 30 ) < in &&
( !u.in_sleep_state() || calendar::turn - last_dream > 2_hours ) ) {
Expand All @@ -247,7 +254,7 @@ static bool opiate_effect( Character &u, addiction &add )
u.in_sleep_state() ? "addict_opiate_strong_asleep" : "addict_opiate_strong_awake";
u.add_msg_if_player( m_bad,
SNIPPET.random_from_category( msg ).value_or( translation() ).translated() );
u.add_morale( MORALE_CRAVING_OPIATE, -30, -10 * in );
u.add_morale( morale_craving_opiate, -30, -10 * in );
} else if( one_in( 50 ) && dice( 3, 50 ) < in ) {
u.vomit();
}
Expand Down Expand Up @@ -278,7 +285,7 @@ static bool amphetamine_effect( Character &u, addiction &add )
u.in_sleep_state() ? "addict_amphetamine_mild_asleep" : "addict_amphetamine_mild_awake";
u.add_msg_if_player( m_warning,
SNIPPET.random_from_category( msg ).value_or( translation() ).translated() );
u.add_morale( MORALE_CRAVING_SPEED, -25, -20 * in );
u.add_morale( morale_craving_speed, -25, -20 * in );
ret = true;
} else if( one_in( 10 ) && dice( 2, 80 ) < in &&
( !u.in_sleep_state() || calendar::turn - last_dream > 2_hours ) ) {
Expand All @@ -289,7 +296,7 @@ static bool amphetamine_effect( Character &u, addiction &add )
u.in_sleep_state() ? "addict_amphetamine_strong_asleep" : "addict_amphetamine_strong_awake";
u.add_msg_if_player( m_warning,
SNIPPET.random_from_category( msg ).value_or( translation() ).translated() );
u.add_morale( MORALE_CRAVING_SPEED, -25, -20 * in );
u.add_morale( morale_craving_speed, -25, -20 * in );
u.add_effect( effect_shakes, in * 2_minutes );
ret = true;
} else if( one_in( 50 ) && dice( 2, 100 ) < in &&
Expand Down Expand Up @@ -359,7 +366,7 @@ void add_type::load( const JsonObject &jo, const std::string_view )
mandatory( jo, was_loaded, "name", _name );
mandatory( jo, was_loaded, "type_name", _type_name );
mandatory( jo, was_loaded, "description", _desc );
optional( jo, was_loaded, "craving_morale", _craving_morale, MORALE_NULL );
optional( jo, was_loaded, "craving_morale", _craving_morale, morale_type::NULL_ID() );
optional( jo, was_loaded, "effect_on_condition", _effect );
optional( jo, was_loaded, "builtin", _builtin );
}
Expand Down
18 changes: 11 additions & 7 deletions src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#include "messages.h"
#include "mission.h"
#include "morale.h"
#include "morale_types.h"
#include "move_mode.h"
#include "mutation.h"
#include "npc.h"
Expand Down Expand Up @@ -117,13 +116,18 @@ static const json_character_flag json_flag_ALARMCLOCK( "ALARMCLOCK" );
static const json_character_flag json_flag_PAIN_IMMUNE( "PAIN_IMMUNE" );
static const json_character_flag json_flag_WEBBED_HANDS( "WEBBED_HANDS" );

static const mfaction_str_id monfaction_player( "player" );

static const morale_type morale_food_good( "morale_food_good" );
static const morale_type morale_food_hot( "morale_food_hot" );
static const morale_type morale_honey( "morale_honey" );
static const morale_type morale_vomited( "morale_vomited" );

static const move_mode_id move_mode_crouch( "crouch" );
static const move_mode_id move_mode_prone( "prone" );
static const move_mode_id move_mode_run( "run" );
static const move_mode_id move_mode_walk( "walk" );

static const string_id<monfaction> monfaction_player( "player" );

static const ter_str_id ter_t_dirt( "t_dirt" );
static const ter_str_id ter_t_dirtmound( "t_dirtmound" );
static const ter_str_id ter_t_floor( "t_floor" );
Expand Down Expand Up @@ -870,12 +874,12 @@ void avatar::vomit()
{
if( stomach.contains() != 0_ml ) {
// Remove all joy from previously eaten food and apply the penalty
rem_morale( MORALE_FOOD_GOOD );
rem_morale( MORALE_FOOD_HOT );
rem_morale( morale_food_good );
rem_morale( morale_food_hot );
// bears must suffer too
rem_morale( MORALE_HONEY );
rem_morale( morale_honey );
// 1.5 times longer
add_morale( MORALE_VOMITED, -2 * units::to_milliliter( stomach.contains() / 50 ), -40, 90_minutes,
add_morale( morale_vomited, -2 * units::to_milliliter( stomach.contains() / 50 ), -40, 90_minutes,
45_minutes, false );

} else {
Expand Down
Loading

0 comments on commit b7f634c

Please sign in to comment.