Skip to content

Commit

Permalink
Move string consts out of several files (#38107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Feb 17, 2020
1 parent e36094d commit ab283d9
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 228 deletions.
104 changes: 26 additions & 78 deletions src/player_hardcoded_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mtype.h"
#include "stomach.h"
#include "teleport.h"
#include "cata_string_consts.h"

#if defined(TILES)
# if defined(_MSC_VER) && defined(USE_VCPKG)
Expand All @@ -38,59 +39,6 @@
#include <functional>
#include <algorithm>

static const mtype_id mon_dermatik_larva( "mon_dermatik_larva" );

static const efftype_id effect_adrenaline( "adrenaline" );
static const efftype_id effect_alarm_clock( "alarm_clock" );
static const efftype_id effect_antibiotic( "antibiotic" );
static const efftype_id effect_asthma( "asthma" );
static const efftype_id effect_attention( "attention" );
static const efftype_id effect_bite( "bite" );
static const efftype_id effect_bleed( "bleed" );
static const efftype_id effect_blind( "blind" );
static const efftype_id effect_bloodworms( "bloodworms" );
static const efftype_id effect_boomered( "boomered" );
static const efftype_id effect_brainworms( "brainworms" );
static const efftype_id effect_cold( "cold" );
static const efftype_id effect_datura( "datura" );
static const efftype_id effect_dermatik( "dermatik" );
static const efftype_id effect_disabled( "disabled" );
static const efftype_id effect_downed( "downed" );
static const efftype_id effect_evil( "evil" );
static const efftype_id effect_formication( "formication" );
static const efftype_id effect_frostbite( "frostbite" );
static const efftype_id effect_fungus( "fungus" );
static const efftype_id effect_grabbed( "grabbed" );
static const efftype_id effect_grabbing( "grabbing" );
static const efftype_id effect_hallu( "hallu" );
static const efftype_id effect_hot( "hot" );
static const efftype_id effect_infected( "infected" );
static const efftype_id effect_lying_down( "lying_down" );
static const efftype_id effect_mending( "mending" );
static const efftype_id effect_meth( "meth" );
static const efftype_id effect_motor_seizure( "motor_seizure" );
static const efftype_id effect_narcosis( "narcosis" );
static const efftype_id effect_onfire( "onfire" );
static const efftype_id effect_paincysts( "paincysts" );
static const efftype_id effect_panacea( "panacea" );
static const efftype_id effect_rat( "rat" );
static const efftype_id effect_recover( "recover" );
static const efftype_id effect_shakes( "shakes" );
static const efftype_id effect_sleep( "sleep" );
static const efftype_id effect_slept_through_alarm( "slept_through_alarm" );
static const efftype_id effect_spores( "spores" );
static const efftype_id effect_strong_antibiotic( "strong_antibiotic" );
static const efftype_id effect_stunned( "stunned" );
static const efftype_id effect_tapeworm( "tapeworm" );
static const efftype_id effect_teleglow( "teleglow" );
static const efftype_id effect_tetanus( "tetanus" );
static const efftype_id effect_toxin_buildup( "toxin_buildup" );
static const efftype_id effect_valium( "valium" );
static const efftype_id effect_visuals( "visuals" );
static const efftype_id effect_weak_antibiotic( "weak_antibiotic" );

const vitamin_id vitamin_iron( "iron" );

static void eff_fun_onfire( player &u, effect &it )
{
const int intense = it.get_intensity();
Expand All @@ -100,7 +48,7 @@ static void eff_fun_spores( player &u, effect &it )
{
// Equivalent to X in 150000 + health * 100
const int intense = it.get_intensity();
if( ( !u.has_trait( trait_id( "M_IMMUNE" ) ) ) && ( one_in( 100 ) &&
if( ( !u.has_trait( trait_M_IMMUNE ) ) && ( one_in( 100 ) &&
x_in_y( intense, 900 + u.get_healthy() * 0.6 ) ) ) {
u.add_effect( effect_fungus, 1_turns, num_bp, true );
}
Expand Down Expand Up @@ -214,7 +162,7 @@ static void eff_fun_bleed( player &u, effect &it )
// on the wound or otherwise suppressing the flow. (Kits contain either
// QuikClot or bandages per the recipe.)
const int intense = it.get_intensity();
if( one_in( 36 / intense ) && u.activity.id() != activity_id( "ACT_FIRSTAID" ) ) {
if( one_in( 36 / intense ) && u.activity.id() != ACT_FIRSTAID ) {
u.add_msg_player_or_npc( m_bad, _( "You lose some blood." ),
_( "<npcname> loses some blood." ) );
// Prolonged hemorrhage is a significant risk for developing anemia
Expand Down Expand Up @@ -566,7 +514,7 @@ void player::hardcoded_effects( effect &it )
g->m.make_rubble( dest, f_rubble_rock, true );
}
MonsterGroupResult spawn_details = MonsterGroupManager::GetResultFromGroup(
mongroup_id( "GROUP_NETHER" ) );
GROUP_NETHER );
g->place_critter_at( spawn_details.name, dest );
if( g->u.sees( dest ) ) {
g->cancel_activity_or_ignore_query( distraction_type::hostile_spotted,
Expand Down Expand Up @@ -666,7 +614,7 @@ void player::hardcoded_effects( effect &it )
g->m.make_rubble( dest, f_rubble_rock, true );
}
MonsterGroupResult spawn_details = MonsterGroupManager::GetResultFromGroup(
mongroup_id( "GROUP_NETHER" ) );
GROUP_NETHER );
g->place_critter_at( spawn_details.name, dest );
if( g->u.sees( dest ) ) {
g->cancel_activity_or_ignore_query( distraction_type::hostile_spotted,
Expand Down Expand Up @@ -718,7 +666,7 @@ void player::hardcoded_effects( effect &it )
}
}
if( one_in( 10000 ) ) {
if( !has_trait( trait_id( "M_IMMUNE" ) ) ) {
if( !has_trait( trait_M_IMMUNE ) ) {
add_effect( effect_fungus, 1_turns, num_bp, true );
} else {
add_msg_if_player( m_info, _( "We have many colonists awaiting passage." ) );
Expand Down Expand Up @@ -846,7 +794,7 @@ void player::hardcoded_effects( effect &it )
}

if( dur > 1800_minutes && one_in( 300 * 512 ) ) {
if( !has_trait( trait_id( "NOPAIN" ) ) ) {
if( !has_trait( trait_NOPAIN ) ) {
add_msg_if_player( m_bad,
_( "Your heart spasms painfully and stops, dragging you back to reality as you die." ) );
} else {
Expand Down Expand Up @@ -899,7 +847,7 @@ void player::hardcoded_effects( effect &it )
if( has_effect( effect_recover ) ) {
recover_factor -= get_effect_dur( effect_recover ) / 1_hours;
}
if( has_trait( trait_id( "INFRESIST" ) ) ) {
if( has_trait( trait_INFRESIST ) ) {
recover_factor += 200;
}
if( has_effect( effect_panacea ) ) {
Expand Down Expand Up @@ -951,7 +899,7 @@ void player::hardcoded_effects( effect &it )
if( has_effect( effect_recover ) ) {
recover_factor -= get_effect_dur( effect_recover ) / 1_hours;
}
if( has_trait( trait_id( "INFRESIST" ) ) ) {
if( has_trait( trait_INFRESIST ) ) {
recover_factor += 200;
}
if( has_effect( effect_panacea ) ) {
Expand Down Expand Up @@ -1045,10 +993,10 @@ void player::hardcoded_effects( effect &it )
g->weather.weather == WEATHER_FLURRIES
|| g->weather.weather == WEATHER_CLOUDY || g->weather.weather == WEATHER_SNOW;

if( calendar::once_every( 10_minutes ) && ( has_trait( trait_id( "CHLOROMORPH" ) ) ||
has_trait( trait_id( "M_SKIN3" ) ) || has_trait( trait_id( "WATERSLEEP" ) ) ) &&
if( calendar::once_every( 10_minutes ) && ( has_trait( trait_CHLOROMORPH ) ||
has_trait( trait_M_SKIN3 ) || has_trait( trait_WATERSLEEP ) ) &&
g->m.is_outside( pos() ) ) {
if( has_trait( trait_id( "CHLOROMORPH" ) ) ) {
if( has_trait( trait_CHLOROMORPH ) ) {
// Hunger and thirst fall before your Chloromorphic physiology!
if( g->natural_light_level( posz() ) >= 12 && compatible_weather_types ) {
if( get_hunger() >= -30 ) {
Expand All @@ -1061,7 +1009,7 @@ void player::hardcoded_effects( effect &it )
}
}
}
if( has_trait( trait_id( "M_SKIN3" ) ) ) {
if( has_trait( trait_M_SKIN3 ) ) {
// Spores happen!
if( g->m.has_flag_ter_or_furn( "FUNGUS", pos() ) ) {
if( get_fatigue() >= 0 ) {
Expand All @@ -1072,7 +1020,7 @@ void player::hardcoded_effects( effect &it )
}
}
}
if( has_trait( trait_id( "WATERSLEEP" ) ) ) {
if( has_trait( trait_WATERSLEEP ) ) {
mod_fatigue( -3 ); // Fish sleep less in water
}
}
Expand Down Expand Up @@ -1103,7 +1051,7 @@ void player::hardcoded_effects( effect &it )
add_msg_if_player( dream );
}
// Mycus folks upgrade in their sleep.
if( has_trait( trait_id( "THRESH_MYCUS" ) ) ) {
if( has_trait( trait_THRESH_MYCUS ) ) {
if( one_in( 8 ) ) {
mutate_category( "MYCUS" );
mod_stored_nutr( 10 );
Expand All @@ -1118,8 +1066,8 @@ void player::hardcoded_effects( effect &it )
int tirednessVal = rng( 5, 200 ) + rng( 0, abs( get_fatigue() * 2 * 5 ) );
if( !is_blind() && !has_effect( effect_narcosis ) ) {
if( !has_trait(
trait_id( "SEESLEEP" ) ) ) { // People who can see while sleeping are acclimated to the light.
if( has_trait( trait_id( "HEAVYSLEEPER2" ) ) && !has_trait( trait_id( "HIBERNATE" ) ) ) {
trait_SEESLEEP ) ) { // People who can see while sleeping are acclimated to the light.
if( has_trait( trait_HEAVYSLEEPER2 ) && !has_trait( trait_HIBERNATE ) ) {
// So you can too sleep through noon
if( ( tirednessVal * 1.25 ) < g->m.ambient_light_at( pos() ) && ( get_fatigue() < 10 ||
one_in( get_fatigue() / 2 ) ) ) {
Expand All @@ -1129,7 +1077,7 @@ void player::hardcoded_effects( effect &it )
woke_up = true;
}
// Ursine hibernators would likely do so indoors. Plants, though, might be in the sun.
} else if( has_trait( trait_id( "HIBERNATE" ) ) ) {
} else if( has_trait( trait_HIBERNATE ) ) {
if( ( tirednessVal * 5 ) < g->m.ambient_light_at( pos() ) && ( get_fatigue() < 10 ||
one_in( get_fatigue() / 2 ) ) ) {
add_msg_if_player( _( "It's too bright to sleep." ) );
Expand All @@ -1144,7 +1092,7 @@ void player::hardcoded_effects( effect &it )
it.set_duration( 0_turns );
woke_up = true;
}
} else if( has_active_mutation( trait_id( "SEESLEEP" ) ) ) {
} else if( has_active_mutation( trait_SEESLEEP ) ) {
Creature *hostile_critter = g->is_hostile_very_close();
if( hostile_critter != nullptr ) {
add_msg_if_player( _( "You see %s approaching!" ),
Expand Down Expand Up @@ -1186,7 +1134,7 @@ void player::hardcoded_effects( effect &it )
}
}
}
if( ( ( has_trait( trait_id( "SCHIZOPHRENIC" ) ) || has_artifact_with( AEP_SCHIZO ) ) &&
if( ( ( has_trait( trait_SCHIZOPHRENIC ) || has_artifact_with( AEP_SCHIZO ) ) &&
one_in( 43200 ) && is_player() ) ) {
if( one_in( 2 ) ) {
sound_hallu();
Expand Down Expand Up @@ -1221,7 +1169,7 @@ void player::hardcoded_effects( effect &it )
add_msg_if_player( _( "It looks like you woke up just before your alarm." ) );
remove_effect( effect_alarm_clock );
} else if( has_effect( effect_slept_through_alarm ) ) { // slept though the alarm.
if( has_bionic( bionic_id( "bio_watch" ) ) ) {
if( has_bionic( bio_watch ) ) {
add_msg_if_player( m_warning, _( "It looks like you've slept through your internal alarm…" ) );
} else {
add_msg_if_player( m_warning, _( "It looks like you've slept through the alarm…" ) );
Expand All @@ -1233,7 +1181,7 @@ void player::hardcoded_effects( effect &it )
} else if( id == effect_alarm_clock ) {
if( in_sleep_state() ) {
const bool asleep = has_effect( effect_sleep );
if( has_bionic( bionic_id( "bio_watch" ) ) ) {
if( has_bionic( bio_watch ) ) {
if( dur == 1_turns ) {
// Normal alarm is volume 12, tested against (2/3/6)d15 for
// normal/HEAVYSLEEPER/HEAVYSLEEPER2.
Expand All @@ -1244,11 +1192,11 @@ void player::hardcoded_effects( effect &it )
if( !asleep ) {
add_msg_if_player( _( "Your internal chronometer went off and you haven't slept a wink." ) );
activity.set_to_null();
} else if( ( !( has_trait( trait_id( "HEAVYSLEEPER" ) ) ||
has_trait( trait_id( "HEAVYSLEEPER2" ) ) ) &&
} else if( ( !( has_trait( trait_HEAVYSLEEPER ) ||
has_trait( trait_HEAVYSLEEPER2 ) ) &&
dice( 2, 15 ) < volume ) ||
( has_trait( trait_id( "HEAVYSLEEPER" ) ) && dice( 3, 15 ) < volume ) ||
( has_trait( trait_id( "HEAVYSLEEPER2" ) ) && dice( 6, 15 ) < volume ) ) {
( has_trait( trait_HEAVYSLEEPER ) && dice( 3, 15 ) < volume ) ||
( has_trait( trait_HEAVYSLEEPER2 ) && dice( 6, 15 ) < volume ) ) {
// Secure the flag before wake_up() clears the effect
bool slept_through = has_effect( effect_slept_through_alarm );
wake_up();
Expand Down
Loading

0 comments on commit ab283d9

Please sign in to comment.