void weather_effect::glare( bool snowglare ) { season_type season = season_of_year( calendar::turn ); if( is_player_outside() && g->is_in_sunlight( g->u.pos() ) && !g->u.in_sleep_state() && !g->u.worn_with_flag( "SUN_GLASSES" ) && !g->u.is_blind() && !snowglare && !g->u.has_bionic( bionic_id( "bio_sunglasses" ) ) ) { if( !g->u.has_effect( effect_glare ) ) { if( g->u.has_trait( trait_CEPH_VISION ) ) { g->u.add_env_effect( effect_glare, bp_eyes, 2, 4_turns ); } else { g->u.add_env_effect( effect_glare, bp_eyes, 2, 2_turns ); } } else { if( g->u.has_trait( trait_CEPH_VISION ) ) { g->u.add_env_effect( effect_glare, bp_eyes, 2, 2_turns ); } else { g->u.add_env_effect( effect_glare, bp_eyes, 2, 1_turns ); } } } if( is_player_outside() && !g->u.in_sleep_state() && season == WINTER && !g->u.worn_with_flag( "SUN_GLASSES" ) && !g->u.is_blind() && snowglare && !g->u.has_bionic( bionic_id( "bio_sunglasses" ) ) ) { if( !g->u.has_effect( effect_snow_glare ) ) { if( g->u.has_trait( trait_CEPH_VISION ) ) { g->u.add_env_effect( effect_snow_glare, bp_eyes, 2, 4_turns ); } else { g->u.add_env_effect( effect_snow_glare, bp_eyes, 2, 2_turns ); } } else { if( g->u.has_trait( trait_CEPH_VISION ) ) { g->u.add_env_effect( effect_snow_glare, bp_eyes, 2, 2_turns ); } else { g->u.add_env_effect( effect_snow_glare, bp_eyes, 2, 1_turns ); } } } }
/** * Glare. * Causes glare effect to player's eyes if they are not wearing applicable eye protection. */ void weather_effect::glare() { if( is_player_outside() && g->is_in_sunlight( g->u.pos() ) && !g->u.in_sleep_state() && !g->u.worn_with_flag( "SUN_GLASSES" ) && !g->u.is_blind() && !g->u.has_bionic( bionic_id( "bio_sunglasses" ) ) ) { if( !g->u.has_effect( effect_glare ) ) { if( g->u.has_trait( trait_CEPH_VISION ) ) { g->u.add_env_effect( effect_glare, bp_eyes, 2, 4_turns ); } else { g->u.add_env_effect( effect_glare, bp_eyes, 2, 2_turns ); } } else { if( g->u.has_trait( trait_CEPH_VISION ) ) { g->u.add_env_effect( effect_glare, bp_eyes, 2, 2_turns ); } else { g->u.add_env_effect( effect_glare, bp_eyes, 2, 1_turns ); } } } }
/** * Acid rain. * Causes major pain. Damages non acid-proof mobs. Very wet (acid). */ void weather_effect::acid() { if( calendar::once_every( 2_turns ) && is_player_outside() ) { if( g->u.weapon.has_flag( "RAIN_PROTECT" ) && one_in( 4 ) ) { add_msg( _( "Your umbrella protects you from the acid rain." ) ); } else { if( g->u.worn_with_flag( "RAINPROOF" ) && one_in( 2 ) ) { add_msg( _( "Your clothing protects you from the acid rain." ) ); } else { bool has_helmet = false; if( g->u.is_wearing_power_armor( &has_helmet ) && ( has_helmet || !one_in( 2 ) ) ) { add_msg( _( "Your power armor protects you from the acid rain." ) ); } else { add_msg( m_bad, _( "The acid rain burns!" ) ); if( one_in( 2 ) && ( g->u.get_pain() < 100 ) ) { g->u.mod_pain( rng( 1, 5 ) ); } } } } } generic_very_wet( true ); }
/** * Acid drizzle. * Causes minor pain only. */ void weather_effect::light_acid() { generic_wet( true ); if( calendar::once_every( 1_minutes ) && is_player_outside() ) { if( g->u.weapon.has_flag( "RAIN_PROTECT" ) && !one_in( 3 ) ) { add_msg( _( "Your %s protects you from the acidic drizzle." ), g->u.weapon.tname() ); } else { if( g->u.worn_with_flag( "RAINPROOF" ) && !one_in( 4 ) ) { add_msg( _( "Your clothing protects you from the acidic drizzle." ) ); } else { bool has_helmet = false; if( g->u.is_wearing_power_armor( &has_helmet ) && ( has_helmet || !one_in( 4 ) ) ) { add_msg( _( "Your power armor protects you from the acidic drizzle." ) ); } else { add_msg( m_warning, _( "The acid rain stings, but is mostly harmless for now..." ) ); if( one_in( 10 ) && ( g->u.get_pain() < 10 ) ) { g->u.mod_pain( 1 ); } } } } } }
/** * Main routine for wet effects caused by weather. * Drenching the player is applied after checks against worn and held items. * * The warmth of armor is considered when determining how much drench happens per tick. * * Note that this is not the only place where drenching can happen. * For example, moving or swimming into water tiles will also cause drenching. * @see fill_water_collectors * @see map::decay_fields_and_scent * @see player::drench */ void wet_player( int amount ) { if( !is_player_outside() || g->u.has_trait( trait_FEATHERS ) || g->u.weapon.has_flag( "RAIN_PROTECT" ) || ( !one_in( 50 ) && g->u.worn_with_flag( "RAINPROOF" ) ) ) { return; } if( rng( 0, 100 - amount + g->u.warmth( bp_torso ) * 4 / 5 + g->u.warmth( bp_head ) / 5 ) > 10 ) { // Thick clothing slows down (but doesn't cap) soaking return; } const auto &wet = g->u.body_wetness; const auto &capacity = g->u.drench_capacity; body_part_set drenched_parts{ { bp_torso, bp_arm_l, bp_arm_r, bp_head } }; if( wet[bp_torso] * 100 >= capacity[bp_torso] * 50 ) { // Once upper body is 50%+ drenched, start soaking the legs too drenched_parts |= { { bp_leg_l, bp_leg_r } }; } g->u.drench( amount, drenched_parts, false ); }