Skip to content

Commit

Permalink
Merge pull request #36571 from Fris0uman/sweet_misc
Browse files Browse the repository at this point in the history
Miscellaneous fix for My Sweet Cataclysm
  • Loading branch information
kevingranade authored Dec 31, 2019
2 parents 55987e0 + 26ec5c8 commit 125ef83
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 58 deletions.
3 changes: 2 additions & 1 deletion data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2627,7 +2627,8 @@
"points": 2,
"description": "Your body is simply immune to diseases. You will never catch an ambient disease.",
"prereqs": [ "DISRESISTANT" ],
"category": [ "PLANT", "SLIME", "TROGLOBITE" ]
"category": [ "PLANT", "SLIME", "TROGLOBITE" ],
"flags": [ "NO_DISEASE" ]
},
{
"type": "mutation",
Expand Down
5 changes: 3 additions & 2 deletions data/mods/My_Sweet_Cataclysm/sweet_mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"ROBUST",
"CARNIVORE"
],
"can_only_eat": [ "junk", "sugar" ],
"can_only_eat": [ "junk", "sugar", "honey" ],
"can_only_heal_with": [ "caramel_ointement" ],
"description": "You are literally made of sugar.",
"vitamin_rates": [ [ "vitC", -900 ], [ "vitB", -900 ], [ "vitA", -900 ], [ "iron", -900 ], [ "calcium", -900 ] ],
Expand All @@ -41,6 +41,7 @@
"fat_to_max_hp": 0.1,
"allowed_category": [ "SUGAR" ],
"no_cbm_on_bp": [ "TORSO", "HEAD", "EYES", "MOUTH", "ARM_L", "ARM_R", "HAND_L", "HAND_R", "LEG_L", "LEG_R", "FOOT_L", "FOOT_R" ],
"armor": [ { "parts": "ALL", "cut": 10, "bash": 5 } ]
"armor": [ { "parts": "ALL", "cut": 10, "bash": 5 } ],
"flags": [ "NO_THIRST", "NO_DISEASE", "NO_RADIATION" ]
}
]
4 changes: 4 additions & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,10 @@ Also see `monster_attacks.json` for more special attacks, for example, impale an
- ```UNARMED_BONUS``` You get a bonus to unarmed bash and cut damage equal to unarmed_skill/2 up to 4.
- ```NEED_ACTIVE_TO_MELEE``` This mutation gives bonus to unarmed melee only if it's active.
- ```NO_DISEASE``` This mutation grants immunity to diseases.
- ```NO_THIRST``` Your thirst is not modified by food or drinks.
- ```NO_RADIATION``` This mutation grants immunity to radiations.
### Categories
Expand Down
2 changes: 1 addition & 1 deletion src/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ void avatar::reset_stats()
}

// Radiation
set_fake_effect_dur( effect_irradiated, 1_turns * radiation );
set_fake_effect_dur( effect_irradiated, 1_turns * get_rad() );
// Morale
const int morale = get_morale_level();
set_fake_effect_dur( effect_happy, 1_turns * morale );
Expand Down
10 changes: 5 additions & 5 deletions src/bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ bool player::activate_bionic( int b, bool eff_only )
std::vector<std::string> good;
std::vector<std::string> bad;

if( radiation > 0 ) {
if( get_rad() > 0 ) {
bad.push_back( _( "Irradiated" ) );
}

Expand Down Expand Up @@ -537,12 +537,12 @@ bool player::activate_bionic( int b, bool eff_only )
mod_power_level( bionics[bionic_id( "bio_lighter" )].power_activate );
}
} else if( bio.id == "bio_geiger" ) {
add_msg_if_player( m_info, _( "Your radiation level: %d" ), radiation );
add_msg_if_player( m_info, _( "Your radiation level: %d" ), get_rad() );
} else if( bio.id == "bio_radscrubber" ) {
if( radiation > 4 ) {
radiation -= 5;
if( get_rad() > 4 ) {
mod_rad( -5 );
} else {
radiation = 0;
set_rad( 0 );
}
} else if( bio.id == "bio_adrenaline" ) {
if( has_effect( effect_adrenaline ) ) {
Expand Down
25 changes: 23 additions & 2 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ Character::Character() :
thirst = 0;
fatigue = 0;
sleep_deprivation = 0;
radiation = 0;
set_rad( 0 );
tank_plut = 0;
reactor_plut = 0;
slow_rad = 0;
Expand Down Expand Up @@ -3367,7 +3367,10 @@ std::pair<std::string, nc_color> Character::get_fatigue_description() const

void Character::mod_thirst( int nthirst )
{
set_thirst( thirst + nthirst );
if( has_trait_flag( "NO_THIRST" ) ) {
return;
}
set_thirst( std::max( -100, thirst + nthirst ) );
}

void Character::set_thirst( int nthirst )
Expand Down Expand Up @@ -5297,6 +5300,24 @@ void Character::mod_stim( int mod )
stim += mod;
}

int Character::get_rad() const
{
return radiation;
}

void Character::set_rad( int new_rad )
{
radiation = new_rad;
}

void Character::mod_rad( int mod )
{
if( has_trait_flag( "NO_RADIATION" ) ) {
return;
}
set_rad( std::max( 0, get_rad() + mod ) );
}

int Character::get_stamina() const
{
return stamina;
Expand Down
7 changes: 6 additions & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,6 @@ class Character : public Creature, public visitable<Character>
std::list<consumption_event> consumption_history;

int oxygen;
int radiation;
int tank_plut;
int reactor_plut;
int slow_rad;
Expand Down Expand Up @@ -1375,6 +1374,10 @@ class Character : public Creature, public visitable<Character>
void set_stim( int new_stim );
void mod_stim( int mod );

int get_rad() const;
void set_rad( int new_rad );
void mod_rad( int mod );

int get_stamina() const;
int get_stamina_max() const;
void set_stamina( int new_stamina );
Expand Down Expand Up @@ -1701,6 +1704,8 @@ class Character : public Creature, public visitable<Character>
int stim;
int pkill;

int radiation;

scenttype_id type_of_scent;

struct weighted_int_list<std::string> melee_miss_reasons;
Expand Down
2 changes: 1 addition & 1 deletion src/computer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ void computer::activate_function( computer_action action )
print_newline();
}
print_error( _( "GEIGER COUNTER @ CONSOLE:… %s mSv/h." ), g->m.get_radiation( g->u.pos() ) );
print_error( _( "PERSONAL DOSIMETRY:… %s mSv." ), g->u.radiation );
print_error( _( "PERSONAL DOSIMETRY:… %s mSv." ), g->u.get_rad() );
print_newline();
query_any( _( "Press any key…" ) );
break;
Expand Down
6 changes: 3 additions & 3 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ void character_edit_menu()
uilist smenu;
smenu.addentry( 0, true, 'h', "%s: %d", _( "Health" ), p.get_healthy() );
smenu.addentry( 1, true, 'm', "%s: %d", _( "Health modifier" ), p.get_healthy_mod() );
smenu.addentry( 2, true, 'r', "%s: %d", _( "Radiation" ), p.radiation );
smenu.addentry( 2, true, 'r', "%s: %d", _( "Radiation" ), p.get_rad() );
smenu.query();
int value;
switch( smenu.ret ) {
Expand All @@ -748,8 +748,8 @@ void character_edit_menu()
}
break;
case 2:
if( query_int( value, _( "Set the value to? Currently: %d" ), p.radiation ) ) {
p.radiation = value;
if( query_int( value, _( "Set the value to? Currently: %d" ), p.get_rad() ) ) {
p.set_rad( value );
}
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11345,8 +11345,8 @@ void game::process_artifact( item &it, player &p )
break;

case AEP_PBLUE:
if( p.radiation > 0 ) {
p.radiation--;
if( p.get_rad() > 0 ) {
p.mod_rad( -1 );
}
break;

Expand Down Expand Up @@ -11487,7 +11487,7 @@ bool check_art_charge_req( item &it )
reqsmet = p.has_effect( effect_sleep );
break;
case( ACR_RAD ):
reqsmet = ( ( g->m.get_radiation( p.pos() ) > 0 ) || ( p.radiation > 0 ) );
reqsmet = ( ( g->m.get_radiation( p.pos() ) > 0 ) || ( p.get_rad() > 0 ) );
break;
case( ACR_WET ):
reqsmet = std::any_of( p.body_wetness.begin(), p.body_wetness.end(),
Expand Down
12 changes: 6 additions & 6 deletions src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ static void marloss_common( player &p, item &it, const trait_id &current_color )
iuse dummy;
dummy.purifier( &p, &it, false, p.pos() );
if( effect == 6 ) {
p.radiation = 0;
p.set_rad( 0 );
}
} else if( effect == 7 ) {

Expand Down Expand Up @@ -1397,7 +1397,7 @@ int iuse::mycus( player *p, item *it, bool t, const tripoint &pos )
p->add_msg_if_player( m_good, _( "You feel better all over." ) );
p->mod_painkiller( 30 );
this->purifier( p, it, t, pos ); // Clear out some of that goo you may have floating around
p->radiation = 0;
p->set_rad( 0 );
p->healall( 4 ); // Can't make you a whole new person, but not for lack of trying
p->add_msg_if_player( m_good,
_( "As it settles in, you feel ecstasy radiating through every part of your body…" ) );
Expand Down Expand Up @@ -3427,14 +3427,14 @@ int iuse::geiger( player *p, item *it, bool t, const tripoint &pos )
}
const tripoint &pnt = *pnt_;
if( pnt == g->u.pos() ) {
p->add_msg_if_player( m_info, _( "Your radiation level: %d mSv (%d mSv from items)" ), p->radiation,
p->add_msg_if_player( m_info, _( "Your radiation level: %d mSv (%d mSv from items)" ), p->get_rad(),
p->leak_level( "RADIOACTIVE" ) );
break;
}
if( npc *const person_ = g->critter_at<npc>( pnt ) ) {
npc &person = *person_;
p->add_msg_if_player( m_info, _( "%s's radiation level: %d mSv (%d mSv from items)" ),
person.name, person.radiation,
person.name, person.get_rad(),
person.leak_level( "RADIOACTIVE" ) );
}
break;
Expand Down Expand Up @@ -5819,12 +5819,12 @@ int iuse::radglove( player *p, item *it, bool, const tripoint & )
return 0;
} else {
p->add_msg_if_player( _( "You activate your radiation biomonitor." ) );
if( p->radiation >= 1 ) {
if( p->get_rad() >= 1 ) {
p->add_msg_if_player( m_warning, _( "You are currently irradiated." ) );
p->add_msg_player_or_say( m_info,
_( "Your radiation level: %d mSv." ),
_( "It says here that my radiation level is %d mSv." ),
p->radiation );
p->get_rad() );
} else {
p->add_msg_player_or_say( m_info,
_( "You are not currently irradiated." ),
Expand Down
6 changes: 3 additions & 3 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4319,13 +4319,13 @@ bool npc::complain()
}

// Radiation every 10 minutes
if( radiation > 90 ) {
if( get_rad() > 90 ) {
activate_bionic_by_id( bio_radscrubber );
std::string speech = _( "I'm suffering from radiation sickness…" );
if( complain_about( radiation_string, 10_minutes, speech, radiation > 150 ) ) {
if( complain_about( radiation_string, 10_minutes, speech, get_rad() > 150 ) ) {
return true;
}
} else if( !radiation ) {
} else if( !get_rad() ) {
deactivate_bionic_by_id( bio_radscrubber );
}

Expand Down
19 changes: 9 additions & 10 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2231,7 +2231,7 @@ void player::update_body( const time_point &from, const time_point &to )
reset_activity_level();
}
// Radiation kills health even at low doses
update_health( has_trait( trait_RADIOGENIC ) ? 0 : -radiation );
update_health( has_trait( trait_RADIOGENIC ) ? 0 : -get_rad() );
get_sick();
}

Expand Down Expand Up @@ -2274,8 +2274,7 @@ void player::update_stomach( const time_point &from, const time_point &to )
// Digest nutrients in guts, they will be distributed to needs levels
food_summary digested_to_body = guts.digest( *this, rates, five_mins, half_hours );
// Water from stomach skips guts and gets absorbed by body
set_thirst( std::max(
-100, get_thirst() - units::to_milliliter<int>( digested_to_guts.water ) / 5 ) );
mod_thirst( - units::to_milliliter<int>( digested_to_guts.water ) / 5 );
guts.ingest( digested_to_guts );
// Apply nutrients, unless this is an NPC and NO_NPC_FOOD is enabled.
if( !is_npc() || !get_option<bool>( "NO_NPC_FOOD" ) ) {
Expand Down Expand Up @@ -2342,7 +2341,7 @@ void player::update_stomach( const time_point &from, const time_point &to )
void player::get_sick()
{
// NPCs are too dumb to handle infections now
if( is_npc() || has_trait( trait_DISIMMUNE ) ) {
if( is_npc() || has_trait_flag( "NO_DISEASE" ) ) {
// In a shocking twist, disease immunity prevents diseases.
return;
}
Expand Down Expand Up @@ -2832,8 +2831,8 @@ void player::regen( int rate_multiplier )
}
}

if( radiation > 0 ) {
radiation = std::max( 0, radiation - roll_remainder( rate_multiplier / 50.0f ) );
if( get_rad() > 0 ) {
mod_rad( -roll_remainder( rate_multiplier / 50.0f ) );
}
}

Expand Down Expand Up @@ -2999,10 +2998,10 @@ void player::process_one_effect( effect &it, bool is_new )
if( val != 0 ) {
mod = 1;
if( is_new || it.activated( calendar::turn, "RAD", val, reduced, mod ) ) {
radiation += bound_mod_to_vals( radiation, val, it.get_max_val( "RAD", reduced ), 0 );
mod_rad( bound_mod_to_vals( get_rad(), val, it.get_max_val( "RAD", reduced ), 0 ) );
// Radiation can't go negative
if( radiation < 0 ) {
radiation = 0;
if( get_rad() < 0 ) {
set_rad( 0 );
}
}
}
Expand Down Expand Up @@ -6436,7 +6435,7 @@ void player::environmental_revert_effect()
set_stim( 0 );
set_pain( 0 );
set_painkiller( 0 );
radiation = 0;
set_rad( 0 );

recalc_sight_limits();
reset_encumbrance();
Expand Down
Loading

0 comments on commit 125ef83

Please sign in to comment.