Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowed Snowstorms to happen - added snow wet and glare effects ( and fixed test_weather ) #27870

Merged
merged 8 commits into from Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion data/json/effects.json
Expand Up @@ -253,7 +253,7 @@
"id": "blind",
"name": [ "Blind" ],
"desc": [ "Range of Sight: 0. You cannot see anything." ],
"removes_effects": [ "glare", "darkness" ],
"removes_effects": [ "glare", "snow_glare", "darkness" ],
"apply_message": "You're blinded!",
"remove_message": "Your sight returns!",
"rating": "bad",
Expand Down Expand Up @@ -422,6 +422,15 @@
"rating": "bad",
"base_mods": { "per_mod": [ -1 ] }
},
{
"type": "effect_type",
"id": "snow_glare",
"name": [ "Snow glare" ],
"desc": [ "The sunlight is reflecting off the snow." ],
"apply_message": "The sunlight reflecting off the snow makes it hard to see.",
"rating": "bad",
"base_mods": { "per_mod": [ -1 ] }
},
{
"type": "effect_type",
"id": "laserlocked",
Expand Down
2 changes: 1 addition & 1 deletion doc/SOUNDPACKS.md
Expand Up @@ -98,4 +98,4 @@ Where id describes the id of the sound effect, and a list of variants separated
* `melee_hit <weapon> # note: use weapon id "null" for unarmed attacks`
* `fire_gun <weapon>`
* `reload <weapon>`
* `environment thunder_near|thunder_far|daytime|nighttime|indoors|indoors_rain|underground|WEATHER_DRIZZLE|WEATHER_RAINY|WEATHER_THUNDER|WEATHER_FLURRIES|WEATHER_SNOW`
* `environment thunder_near|thunder_far|daytime|nighttime|indoors|indoors_rain|underground|WEATHER_DRIZZLE|WEATHER_RAINY|WEATHER_THUNDER|WEATHER_FLURRIES|WEATHER_SNOW|WEATHER_SNOWSTORM`
3 changes: 3 additions & 0 deletions src/sounds.cpp
Expand Up @@ -520,6 +520,7 @@ void sfx::do_ambient()
17: Stamina 35%
18: Idle chainsaw
19: Chainsaw theme
20: Outdoor blizzard
Group Assignments:
1: SFX related to weather
2: SFX related to time of day
Expand Down Expand Up @@ -606,6 +607,8 @@ void sfx::do_ambient()
case WEATHER_SUNNY:
case WEATHER_CLOUDY:
case WEATHER_SNOWSTORM:
play_ambient_variant_sound( "environment", "WEATHER_SNOWSTORM", heard_volume, 20,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe WEATHER_SNOWSTORM would now play for sunny,cloudy and snowstorm weather. That's not your totally your fault though - previously WEATHER_SNOW would now play for sunny, cloudy and snow weather.

1000 );
case WEATHER_SNOW:
play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, 5,
1000 );
Expand Down
42 changes: 38 additions & 4 deletions src/weather.cpp
Expand Up @@ -23,6 +23,7 @@
#include "weather_gen.h"

const efftype_id effect_glare( "glare" );
const efftype_id effect_snow_glare( "snow_glare" );
const efftype_id effect_blind( "blind" );
const efftype_id effect_sleep( "sleep" );

Expand All @@ -48,10 +49,12 @@ static bool is_player_outside()
* Glare.
* Causes glare effect to player's eyes if they are not wearing applicable eye protection.
*/
void weather_effect::glare()

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() &&
!g->u.worn_with_flag( "SUN_GLASSES" ) && !g->u.is_blind() && snowglare == false &&
!g->u.has_bionic( bionic_id( "bio_sunglasses" ) ) ) {
if( !g->u.has_effect( effect_glare ) ) {
if( g->u.has_trait( trait_CEPH_VISION ) ) {
Expand All @@ -67,7 +70,25 @@ void weather_effect::glare()
}
}
}
if( is_player_outside() && !g->u.in_sleep_state() && season == WINTER &&
!g->u.worn_with_flag( "SUN_GLASSES" ) && !g->u.is_blind() && snowglare == true &&
!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 );
}
}
}
}

////// food vs weather

time_duration get_rot_since( const time_point &start, const time_point &end,
Expand Down Expand Up @@ -393,8 +414,11 @@ void generic_very_wet( bool acid )

void weather_effect::none() {}
void weather_effect::flurry() {}
void weather_effect::snow() {}
void weather_effect::snowstorm() {}

void weather_effect::sunny()
{
glare( false );
}

/**
* Wet.
Expand All @@ -414,6 +438,16 @@ void weather_effect::very_wet()
generic_very_wet( false );
}

void weather_effect::snow()
{
wet_player( 10 );
glare( true );
}

void weather_effect::snowstorm()
{
wet_player( 40 );
}
/**
* Thunder.
* Flavor messages. Very wet.
Expand Down
12 changes: 7 additions & 5 deletions src/weather.h
Expand Up @@ -52,8 +52,8 @@ enum weather_type : int {
WEATHER_ACID_DRIZZLE, //!< No real effects; warning of acid rain
WEATHER_ACID_RAIN, //!< Minor acid damage
WEATHER_FLURRIES, //!< Light snow
WEATHER_SNOW, //!< Medium snow
WEATHER_SNOWSTORM, //!< Heavy snow
WEATHER_SNOW, //!< Medium snow glare effects
WEATHER_SNOWSTORM, //!< Heavy snow glare effects, sight penalties
NUM_WEATHER_TYPES //!< Sentinel value
};

Expand Down Expand Up @@ -94,16 +94,18 @@ struct weather_printable {
namespace weather_effect
{
void none(); //!< Fallback weather.
void glare();
void glare( bool );
void wet();
void very_wet();
void thunder();
void lightning();
void light_acid();
void acid();
void flurry(); //!< Currently flurries have no additional effects.
void snow(); //!< Currently snow has no additional effects.
void snowstorm(); //!< Currently snowstorms have no additional effects.
void snow();
void sunny();
void snow_glare();
void snowstorm();
} //namespace weather_effect

struct weather_datum {
Expand Down
2 changes: 1 addition & 1 deletion src/weather_data.cpp
Expand Up @@ -56,7 +56,7 @@ weather_datum const weather_data( weather_type const type )
},
weather_datum {
translate_marker( "Sunny" ), c_light_cyan, 0, 1.0f, 2, 0, false,
&weather_effect::glare
&weather_effect::sunny
},
weather_datum {
translate_marker( "Cloudy" ), c_light_gray, 0, 1.0f, -20, 0, false,
Expand Down
15 changes: 9 additions & 6 deletions src/weather_gen.cpp
Expand Up @@ -144,7 +144,8 @@ weather_type weather_generator::get_weather_conditions( const w_point &w ) const
r = WEATHER_FLURRIES;
} else if( r > WEATHER_DRIZZLE ) {
r = WEATHER_SNOW;
} else if( r > WEATHER_THUNDER ) { // @todo: that is always false!
}
if( r == WEATHER_SNOW && w.pressure < 960 && w.windpower > 15 ) {
r = WEATHER_SNOWSTORM;
}
}
Expand Down Expand Up @@ -250,15 +251,17 @@ void weather_generator::test_weather() const
// WEATHERGEN.test_weather(); // Runs this test.
std::ofstream testfile;
testfile.open( "weather.output", std::ofstream::trunc );
testfile << "turn,temperature(F),humidity(%),pressure(mB)" << std::endl;
testfile << "turn;temperature(F);humidity(%);pressure(mB);weatherdesc;windspeed(mph);winddirection"
<< std::endl;

const time_point begin = calendar::turn;
const time_point end = begin + 2 * calendar::year_length();
for( time_point i = begin; i < end; i += 200_turns ) {
//@todo: a new random value for each call to get_weather? Is this really intended?
w_point w = get_weather( tripoint_zero, to_turn<int>( i ), rand() );
testfile << to_turn<int>( i ) << "," << w.temperature << "," << w.humidity << "," << w.pressure <<
std::endl;
w_point w = get_weather( tripoint_zero, to_turn<int>( i ), 1000 );
weather_type c = get_weather_conditions( w );
weather_datum wd = weather_data( c );
testfile << to_turn<int>( i ) << ";" << w.temperature << ";" << w.humidity << ";" << w.pressure <<
";" << wd.name << ";" << w.windpower << ";" << w.dirstring << std::endl;
}
}

Expand Down