Skip to content

Commit

Permalink
radiation is private
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Dec 30, 2019
1 parent 94ed5ce commit 75681c3
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 31 deletions.
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
17 changes: 16 additions & 1 deletion 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 @@ -5300,6 +5300,21 @@ 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 )
{
radiation += 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
14 changes: 7 additions & 7 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 @@ -2831,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 ) {
set_rad( std::max( 0, get_rad() - roll_remainder( rate_multiplier / 50.0f ) ) );
}
}

Expand Down Expand Up @@ -2998,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 @@ -6435,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

0 comments on commit 75681c3

Please sign in to comment.