Skip to content

Commit 9efd9c8

Browse files
authored
Merge pull request #82256 from sparr/dedupe_schizo
2 parents 4c6c25e + f9e5734 commit 9efd9c8

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

@@ -1897,9 +1895,8 @@ bool read_activity_actor::player_read( avatar &you )
18971895
}
18981896
}
18991897

1900-
if( ( skill_level == islotbook->level || !skill_level.can_train() ) ||
1901-
( learner->has_trait( trait_SCHIZOPHRENIC ) && !learner->has_effect( effect_took_thorazine ) &&
1902-
one_in( 25 ) ) ) {
1898+
if( skill_level == islotbook->level || !skill_level.can_train() ||
1899+
learner->schizo_symptoms( 25 ) ) {
19031900
if( learner->is_avatar() ) {
19041901
add_msg( m_info, _( "You can no longer learn from %s." ), book->type_name() );
19051902
} else {
@@ -2038,9 +2035,7 @@ bool read_activity_actor::npc_read( npc &learner )
20382035
}
20392036

20402037
if( display_messages &&
2041-
( ( skill_level == islotbook->level || !skill_level.can_train() ) ||
2042-
( learner.has_trait( trait_SCHIZOPHRENIC ) && !learner.has_effect( effect_took_thorazine ) &&
2043-
one_in( 25 ) ) ) ) {
2038+
( skill_level == islotbook->level || !skill_level.can_train() || learner.schizo_symptoms( 25 ) ) ) {
20442039
add_msg( m_info, _( "%s can no longer learn from %s." ), learner.disp_name(),
20452040
book->type_name() );
20462041
}

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" );
@@ -12170,6 +12172,11 @@ bool Character::empathizes_with_monster( const mtype_id &monster ) const
1217012172
return false;
1217112173
}
1217212174

12175+
bool Character::schizo_symptoms( int chance ) const
12176+
{
12177+
return has_trait( trait_SCHIZOPHRENIC ) && !has_effect( effect_took_thorazine ) && one_in( chance );
12178+
}
12179+
1217312180
bool Character::is_driving() const
1217412181
{
1217512182
map &here = get_map();

src/character.h

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

14181420
private:
14191421
// 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
@@ -100,7 +100,6 @@ static const efftype_id effect_nausea( "nausea" );
100100
static const efftype_id effect_paincysts( "paincysts" );
101101
static const efftype_id effect_poison( "poison" );
102102
static const efftype_id effect_tapeworm( "tapeworm" );
103-
static const efftype_id effect_took_thorazine( "took_thorazine" );
104103
static const efftype_id effect_visuals( "visuals" );
105104

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

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

11911185
add_msg( m_bad, _( "Ick, this %s (rotten) doesn't taste so good…" ), food.tname() );
11921186
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
@@ -223,8 +223,6 @@ static const ter_str_id ter_t_window_alarm( "t_window_alarm" );
223223
static const ter_str_id ter_t_window_empty( "t_window_empty" );
224224
static const ter_str_id ter_t_window_no_curtains( "t_window_no_curtains" );
225225

226-
static const trait_id trait_SCHIZOPHRENIC( "SCHIZOPHRENIC" );
227-
228226
static const trap_str_id tr_unfinished_construction( "tr_unfinished_construction" );
229227

230228
#define dbg(x) DebugLog((x),D_MAP) << __FILE__ << ":" << __LINE__ << ": "
@@ -4774,8 +4772,8 @@ bool map::open_door( Creature const &u, const tripoint_bub_ms &p, const bool ins
47744772
"open_door", ter.id.str() );
47754773
ter_set( p, ter.open );
47764774

4777-
if( u.has_trait( trait_SCHIZOPHRENIC ) && u.is_avatar() &&
4778-
one_in( 50 ) && !ter.has_flag( ter_furn_flag::TFLAG_TRANSPARENT ) ) {
4775+
if( u.is_avatar() && u.as_avatar()->schizo_symptoms( 50 ) &&
4776+
!ter.has_flag( ter_furn_flag::TFLAG_TRANSPARENT ) ) {
47794777
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() };
47804778
g->spawn_hallucination( mp );
47814779
}

0 commit comments

Comments
 (0)