Skip to content

Commit f9e5734

Browse files
committed
Dedupe schizophrenic symptom checks
1 parent 218dc92 commit f9e5734

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

src/activity_actor.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ static const efftype_id effect_sensor_stun( "sensor_stun" );
199199
static const efftype_id effect_sheared( "sheared" );
200200
static const efftype_id effect_sleep( "sleep" );
201201
static const efftype_id effect_tied( "tied" );
202-
static const efftype_id effect_took_thorazine( "took_thorazine" );
203202
static const efftype_id effect_worked_on( "worked_on" );
204203

205204
static const faction_id faction_your_followers( "your_followers" );
@@ -291,7 +290,6 @@ static const ter_str_id ter_t_underbrush_harvested_winter( "t_underbrush_harvest
291290

292291
static const trait_id trait_NUMB( "NUMB" );
293292
static const trait_id trait_PSYCHOPATH( "PSYCHOPATH" );
294-
static const trait_id trait_SCHIZOPHRENIC( "SCHIZOPHRENIC" );
295293

296294
static const vproto_id vehicle_prototype_none( "none" );
297295

@@ -1901,9 +1899,8 @@ bool read_activity_actor::player_read( avatar &you )
19011899
}
19021900
}
19031901

1904-
if( ( skill_level == islotbook->level || !skill_level.can_train() ) ||
1905-
( learner->has_trait( trait_SCHIZOPHRENIC ) && !learner->has_effect( effect_took_thorazine ) &&
1906-
one_in( 25 ) ) ) {
1902+
if( skill_level == islotbook->level || !skill_level.can_train() ||
1903+
learner->schizo_symptoms( 25 ) ) {
19071904
if( learner->is_avatar() ) {
19081905
add_msg( m_info, _( "You can no longer learn from %s." ), book->type_name() );
19091906
} else {
@@ -2042,9 +2039,7 @@ bool read_activity_actor::npc_read( npc &learner )
20422039
}
20432040

20442041
if( display_messages &&
2045-
( ( skill_level == islotbook->level || !skill_level.can_train() ) ||
2046-
( learner.has_trait( trait_SCHIZOPHRENIC ) && !learner.has_effect( effect_took_thorazine ) &&
2047-
one_in( 25 ) ) ) ) {
2042+
( skill_level == islotbook->level || !skill_level.can_train() || learner.schizo_symptoms( 25 ) ) ) {
20482043
add_msg( m_info, _( "%s can no longer learn from %s." ), learner.disp_name(),
20492044
book->type_name() );
20502045
}

src/character.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ static const efftype_id effect_stunned( "stunned" );
272272
static const efftype_id effect_subaquatic_sonar( "subaquatic_sonar" );
273273
static const efftype_id effect_tapeworm( "tapeworm" );
274274
static const efftype_id effect_tied( "tied" );
275+
static const efftype_id effect_took_thorazine( "took_thorazine" );
275276
static const efftype_id effect_transition_contacts( "transition_contacts" );
276277
static const efftype_id effect_winded( "winded" );
277278

@@ -475,6 +476,7 @@ static const trait_id trait_ROOTS2( "ROOTS2" );
475476
static const trait_id trait_ROOTS3( "ROOTS3" );
476477
static const trait_id trait_SAPIOVORE( "SAPIOVORE" );
477478
static const trait_id trait_SAVANT( "SAVANT" );
479+
static const trait_id trait_SCHIZOPHRENIC( "SCHIZOPHRENIC" );
478480
static const trait_id trait_SHELL2( "SHELL2" );
479481
static const trait_id trait_SHELL3( "SHELL3" );
480482
static const trait_id trait_SHOUT2( "SHOUT2" );
@@ -12167,6 +12169,11 @@ bool Character::empathizes_with_monster( const mtype_id &monster ) const
1216712169
return false;
1216812170
}
1216912171

12172+
bool Character::schizo_symptoms( int chance ) const
12173+
{
12174+
return has_trait( trait_SCHIZOPHRENIC ) && !has_effect( effect_took_thorazine ) && one_in( chance );
12175+
}
12176+
1217012177
bool Character::is_driving() const
1217112178
{
1217212179
map &here = get_map();

src/character.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,8 @@ class Character : public Creature, public visitable
14091409
bool empathizes_with_species( const species_id &species ) const;
14101410
/** Whether the character feels significant empathy for the given monster. HUMAN is empathized with by default */
14111411
bool empathizes_with_monster( const mtype_id &monster ) const;
1412+
/** Whether the character suffers schizophrenic symptoms, with odds 1 in chance */
1413+
bool schizo_symptoms( int chance = 1 ) const;
14121414

14131415
private:
14141416
// Cache if character has a flag on their mutations. It is cleared whenever my_mutations is modified.

src/consumption.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ static const efftype_id effect_nausea( "nausea" );
101101
static const efftype_id effect_paincysts( "paincysts" );
102102
static const efftype_id effect_poison( "poison" );
103103
static const efftype_id effect_tapeworm( "tapeworm" );
104-
static const efftype_id effect_took_thorazine( "took_thorazine" );
105104
static const efftype_id effect_visuals( "visuals" );
106105

107106
static const flag_id json_flag_ALLERGEN_CHEESE( "ALLERGEN_CHEESE" );
@@ -182,7 +181,6 @@ static const trait_id trait_PROJUNK2( "PROJUNK2" );
182181
static const trait_id trait_RUMINANT( "RUMINANT" );
183182
static const trait_id trait_SAPROPHAGE( "SAPROPHAGE" );
184183
static const trait_id trait_SAPROVORE( "SAPROVORE" );
185-
static const trait_id trait_SCHIZOPHRENIC( "SCHIZOPHRENIC" );
186184
static const trait_id trait_SLIMESPAWNER( "SLIMESPAWNER" );
187185
static const trait_id trait_SPIRITUAL( "SPIRITUAL" );
188186
static const trait_id trait_STIMBOOST( "STIMBOOST" );
@@ -1174,9 +1172,7 @@ static bool eat( item &food, Character &you, bool force )
11741172
you.add_msg_player_or_npc( _( "You assimilate your %s." ), _( "<npcname> assimilates a %s." ),
11751173
food.tname() );
11761174
} else if( drinkable ) {
1177-
if( you.has_trait( trait_SCHIZOPHRENIC ) &&
1178-
!you.has_effect( effect_took_thorazine ) && one_in( 50 ) && !spoiled && food.goes_bad() &&
1179-
you.is_avatar() ) {
1175+
if( you.is_avatar() && you.schizo_symptoms( 50 ) && !spoiled && food.goes_bad() ) {
11801176

11811177
add_msg( m_bad, _( "Ick, this %s (rotten) doesn't taste so good…" ), food.tname() );
11821178
add_msg( _( "You drink your %s (rotten)." ), food.tname() );
@@ -1185,9 +1181,7 @@ static bool eat( item &food, Character &you, bool force )
11851181
food.tname() );
11861182
}
11871183
} else if( chew ) {
1188-
if( you.has_trait( trait_SCHIZOPHRENIC ) &&
1189-
!you.has_effect( effect_took_thorazine ) && one_in( 50 ) && !spoiled && food.goes_bad() &&
1190-
you.is_avatar() ) {
1184+
if( you.is_avatar() && you.schizo_symptoms( 50 ) && !spoiled && food.goes_bad() ) {
11911185

11921186
add_msg( m_bad, _( "Ick, this %s (rotten) doesn't taste so good…" ), food.tname() );
11931187
add_msg( _( "You eat your %s (rotten)." ), food.tname() );

src/map.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ static const ter_str_id ter_t_window_alarm( "t_window_alarm" );
220220
static const ter_str_id ter_t_window_empty( "t_window_empty" );
221221
static const ter_str_id ter_t_window_no_curtains( "t_window_no_curtains" );
222222

223-
static const trait_id trait_SCHIZOPHRENIC( "SCHIZOPHRENIC" );
224-
225223
static const trap_str_id tr_unfinished_construction( "tr_unfinished_construction" );
226224

227225
#define dbg(x) DebugLog((x),D_MAP) << __FILE__ << ":" << __LINE__ << ": "
@@ -4723,8 +4721,8 @@ bool map::open_door( Creature const &u, const tripoint_bub_ms &p, const bool ins
47234721
"open_door", ter.id.str() );
47244722
ter_set( p, ter.open );
47254723

4726-
if( u.has_trait( trait_SCHIZOPHRENIC ) && u.is_avatar() &&
4727-
one_in( 50 ) && !ter.has_flag( ter_furn_flag::TFLAG_TRANSPARENT ) ) {
4724+
if( u.is_avatar() && u.as_avatar()->schizo_symptoms( 50 ) &&
4725+
!ter.has_flag( ter_furn_flag::TFLAG_TRANSPARENT ) ) {
47284726
tripoint_bub_ms mp = p + point_rel_ms( -2 * u.pos_bub().xy().raw() ) + tripoint_rel_ms{ 2 * p.x(), 2 * p.y(), p.z() };
47294727
g->spawn_hallucination( mp );
47304728
}

0 commit comments

Comments
 (0)