From ddac9cedac3efef705325f5d692268c5e8c6fa39 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 13 May 2020 18:12:49 -0400 Subject: [PATCH 01/27] Re do of initial work. Starts misty mist exists, monsters spawn --- data/json/effects.json | 3 ++- data/json/monsters/mist.json | 43 ++++++++++++++++++++++++++++++++++++ data/json/snippets/mist.json | 18 +++++++++++++++ data/json/species.json | 5 +++++ src/animation.cpp | 22 ++++++++++-------- src/character.cpp | 6 ++--- src/monattack.cpp | 34 ++++++++++++++++++++++++++++ src/monattack.h | 2 ++ src/monstergenerator.cpp | 2 ++ src/sounds.cpp | 26 +++++++++++++--------- src/sounds.h | 1 + src/weather.cpp | 32 +++++++++++++++++++++++++++ src/weather.h | 9 ++++++++ src/weather_data.cpp | 7 +++++- src/weather_gen.cpp | 4 ++++ 15 files changed, 189 insertions(+), 25 deletions(-) create mode 100644 data/json/monsters/mist.json create mode 100644 data/json/snippets/mist.json diff --git a/data/json/effects.json b/data/json/effects.json index 401444703850e..76cf11e104cc1 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -1943,7 +1943,8 @@ }, { "type": "effect_type", - "id": "recently_coughed" + "id": "disrupted_sleep", + "max_duration": "48 h" }, { "type": "effect_type", diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json new file mode 100644 index 0000000000000..526a5e8c0c04c --- /dev/null +++ b/data/json/monsters/mist.json @@ -0,0 +1,43 @@ +[ + { + "id": "mon_mist_wraith", + "type": "MONSTER", + "name": { "str": "Mist wraith" }, + "description": "A wispy figure slightly more solid than the mist surrounding it.", + "default_faction": "MIST", + "species": [ "MIST" ], + "volume": "62500 ml", + "weight": "0 g", + "hp": 1, + "speed": 110, + "symbol": "X", + "color": "white", + "aggression": 75, + "morale": 100, + "melee_skill": 10, + "special_attacks": [ [ "DISSIPATE_DRAIN", 1 ] ], + "death_function": [ "DISAPPEAR" ], + "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] + }, + { + "id": "mon_mist_spectre", + "type": "MONSTER", + "name": { "str": "Mist spectre" }, + "description": "A menacing figure slightly more solid than the mist surrounding it.", + "default_faction": "MIST", + "bodytype": "human", + "species": [ "MIST" ], + "volume": "62500 ml", + "weight": "0 g", + "hp": 1, + "speed": 110, + "symbol": "@", + "color": "white", + "aggression": 100, + "morale": 100, + "melee_skill": 3, + "special_attacks": [ [ "DISSIPATE_NIGHTMARES", 1 ] ], + "death_function": [ "DISAPPEAR" ], + "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] + } +] diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json new file mode 100644 index 0000000000000..ffd7dbb6327a5 --- /dev/null +++ b/data/json/snippets/mist.json @@ -0,0 +1,18 @@ +[ + { + "type": "snippet", + "category": "mist_summon_wraith", + "text": [ + "You feel the mist react to you and a shape appears." + + ] + }, + { + "type": "snippet", + "category": "mist_summon_spectre", + "text": [ + "You see a shape form in the mist that reminds you of a creepy man that followed you when you were younger.", + "You see a shape form in the mist that reminds you of a teacher that hated you." + ] + } +] diff --git a/data/json/species.json b/data/json/species.json index 4b3fef2d02a05..db022652c84af 100644 --- a/data/json/species.json +++ b/data/json/species.json @@ -123,6 +123,11 @@ "id": "HUMAN", "description": "a human" }, + { + "type": "SPECIES", + "id": "MIST", + "description": "a slightly solid shape in the mist" + }, { "type": "SPECIES", "id": "UNKNOWN" diff --git a/src/animation.cpp b/src/animation.cpp index 54d9c6ab732e8..2699fbeee119e 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -20,10 +20,10 @@ #include "point.h" #if defined(TILES) -#include + #include -#include "cata_tiles.h" // all animation functions will be pushed out to a cata_tiles function in some manner -#include "sdltiles.h" + #include "cata_tiles.h" // all animation functions will be pushed out to a cata_tiles function in some manner + #include "sdltiles.h" #endif #include @@ -290,7 +290,7 @@ void explosion_handler::draw_custom_explosion( const tripoint &, // Start by getting rid of everything except current z-level std::map neighbors; -#if defined(TILES) + #if defined(TILES) if( !use_tiles ) { for( const auto &pr : all_area ) { const tripoint relative_point = relative_view_pos( g->u, pr.first ); @@ -309,14 +309,14 @@ void explosion_handler::draw_custom_explosion( const tripoint &, } } } -#else + #else for( const auto &pr : all_area ) { const tripoint relative_point = relative_view_pos( g->u, pr.first ); if( relative_point.z == 0 ) { neighbors[pr.first] = explosion_tile{ N_NO_NEIGHBORS, pr.second }; } } -#endif + #endif // Searches for a neighbor, sets the neighborhood flag on current point and on the neighbor const auto set_neighbors = [&]( const tripoint & pos, @@ -388,7 +388,7 @@ void explosion_handler::draw_custom_explosion( const tripoint &, layers.push_front( std::move( layer ) ); } -#if defined(TILES) + #if defined(TILES) if( !use_tiles ) { draw_custom_explosion_curses( *g, layers ); return; @@ -406,9 +406,9 @@ void explosion_handler::draw_custom_explosion( const tripoint &, } tilecontext->void_custom_explosion(); -#else + #else draw_custom_explosion_curses( *g, layers ); -#endif + #endif } namespace @@ -682,6 +682,7 @@ void game::draw_weather( const weather_printable &w ) static const std::string weather_acid_drop {"weather_acid_drop"}; static const std::string weather_rain_drop {"weather_rain_drop"}; static const std::string weather_snowflake {"weather_snowflake"}; + static const std::string weather_mist {"weather_mist"}; std::string weather_name; switch( w.wtype ) { @@ -704,6 +705,9 @@ void game::draw_weather( const weather_printable &w ) case WEATHER_SNOWSTORM: weather_name = weather_snowflake; break; + case WEATHER_MIST: + weather_name = weather_mist; + break; default: break; } diff --git a/src/character.cpp b/src/character.cpp index f8c6bd259030c..48439d8aa9ace 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -152,7 +152,7 @@ static const efftype_id effect_onfire( "onfire" ); static const efftype_id effect_pkill1( "pkill1" ); static const efftype_id effect_pkill2( "pkill2" ); static const efftype_id effect_pkill3( "pkill3" ); -static const efftype_id effect_recently_coughed( "recently_coughed" ); +static const efftype_id effect_disrupted_sleep( "disrupted_sleep" ); static const efftype_id effect_ridden( "ridden" ); static const efftype_id effect_riding( "riding" ); static const efftype_id effect_saddled( "monster_saddled" ); @@ -4778,7 +4778,7 @@ void Character::update_needs( int rate_multiplier ) sleep.set_duration( 1_turns ); mod_fatigue( -25 ); } else { - if( has_effect( effect_recently_coughed ) ) { + if( has_effect( effect_disrupted_sleep ) ) { recovered *= .5; } mod_fatigue( -recovered ); @@ -7764,7 +7764,7 @@ void Character::cough( bool harmful, int loudness ) moves -= 80; - add_effect( effect_recently_coughed, 5_minutes ); + add_effect( effect_disrupted_sleep, 5_minutes ); } void Character::wake_up() diff --git a/src/monattack.cpp b/src/monattack.cpp index f9f60fffa780f..363000702b96c 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -93,6 +93,7 @@ static const efftype_id effect_darkness( "darkness" ); static const efftype_id effect_dazed( "dazed" ); static const efftype_id effect_deaf( "deaf" ); static const efftype_id effect_dermatik( "dermatik" ); +static const efftype_id effect_disrupted_sleep( "disrupted_sleep" ); static const efftype_id effect_downed( "downed" ); static const efftype_id effect_dragging( "dragging" ); static const efftype_id effect_fearparalyze( "fearparalyze" ); @@ -5798,3 +5799,36 @@ bool mattack::speaker( monster *z ) SNIPPET.random_from_category( "speaker_warning" ).value_or( translation() ) ); return true; } + +bool mattack::dissipate_drain( monster *z ) +{ + Character *foe = static_cast( z->attack_target() ); + if( foe != nullptr && within_target_range( z, foe, 1 ) ) { + return false; + } + + foe->mod_fatigue( 50 ); + foe->mod_stamina( -50 ); + foe->add_msg_if_player( m_bad, + _( "The %s touches you and dissipates, taking a little of your strength with it." ), z->name() ); + + z->die( z ); + + return true; +} + +bool mattack::dissipate_nightmares( monster *z ) +{ + Character *foe = static_cast( z->attack_target() ); + if( foe != nullptr && within_target_range( z, foe, 1 ) ) { + return false; + } + + foe->add_effect( effect_disrupted_sleep, 8_hours ); + foe->add_msg_if_player( m_bad, + _( "The %s touches you and dissipates, leaving an unsettling feeling behind." ), z->name() ); + + z->die( z ); + + return true; +} diff --git a/src/monattack.h b/src/monattack.h index 3f9e344d9ed80..ab5ae0a112b09 100644 --- a/src/monattack.h +++ b/src/monattack.h @@ -69,6 +69,8 @@ bool tazer( monster *z ); bool flamethrower( monster *z ); bool searchlight( monster *z ); bool speaker( monster *z ); +bool dissipate_drain( monster *z ); +bool dissipate_nightmares( monster *z ); bool copbot( monster *z ); bool chickenbot( monster *z ); // Pick from tazer, M4, MGL bool multi_robot( monster *z ); // Tazer, flame, M4, MGL, or 120mm! diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 35fff35149eef..78d84d952b6da 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -615,6 +615,8 @@ void MonsterGenerator::init_attack() add_hardcoded_attack( "GRAB_DRAG", mattack::grab_drag ); add_hardcoded_attack( "DOOT", mattack::doot ); add_hardcoded_attack( "ZOMBIE_FUSE", mattack::zombie_fuse ); + add_hardcoded_attack( "DISSIPATE_DRAIN", mattack::dissipate_drain ); + add_hardcoded_attack( "DISSIPATE_NIGHTMARES", mattack::dissipate_nightmares ); } void MonsterGenerator::init_defense() diff --git a/src/sounds.cpp b/src/sounds.cpp index 22bb394f44809..11c5a70393316 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -48,17 +48,17 @@ #include "weather.h" #if defined(SDL_SOUND) -# if defined(_MSC_VER) && defined(USE_VCPKG) -# include -# else -# include -# endif -# include -# if defined(_WIN32) && !defined(_MSC_VER) -# include "mingw.thread.h" -# endif - -# define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " + #if defined(_MSC_VER) && defined(USE_VCPKG) + #include + #else + #include + #endif + #include + #if defined(_WIN32) && !defined(_MSC_VER) + #include "mingw.thread.h" + #endif + + #define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " #endif weather_type previous_weather; @@ -945,6 +945,10 @@ void sfx::do_ambient() play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, channel::outdoors_snow_env, 1000 ); break; + case WEATHER_MIST: + play_ambient_variant_sound( "environment", "WEATHER_MIST", heard_volume, channel::outdoors_mist, + 1000 ); + break; case WEATHER_NULL: case NUM_WEATHER_TYPES: // nothing here, those are pseudo-types, they should not be active at all. diff --git a/src/sounds.h b/src/sounds.h index 1420f41702410..2945ee8035b2a 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -102,6 +102,7 @@ enum class channel : int { outdoors_rain_env, outdoors_drizzle_env, outdoor_blizzard, + outdoors_mist, deafness_tone, danger_extreme_theme, danger_high_theme, diff --git a/src/weather.cpp b/src/weather.cpp index e264a8cd09df0..803775d2003a2 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -29,6 +29,7 @@ #include "rng.h" #include "sounds.h" #include "string_formatter.h" +#include "text_snippets.h" #include "translations.h" #include "trap.h" #include "units.h" @@ -42,6 +43,9 @@ static const efftype_id effect_glare( "glare" ); static const efftype_id effect_sleep( "sleep" ); static const efftype_id effect_snow_glare( "snow_glare" ); +static const mtype_id mon_mist_wraith( "mon_mist_wraith" ); +static const mtype_id mon_mist_spectre( "mon_mist_spectre" ); + static const trait_id trait_CEPH_VISION( "CEPH_VISION" ); static const trait_id trait_FEATHERS( "FEATHERS" ); @@ -455,6 +459,34 @@ void weather_effect::snowstorm() { wet_player( 40 ); } + +void weather_effect::mist() +{ + if( calendar::once_every( g->weather.mist_spawn_time ) && is_player_outside() ) { + int radius = 10; + mtype_id monster; + std::string category; + if( g->weather.mist_intensity < 5 ) { + monster = mon_mist_wraith; + category = "mist_summon_wraith"; + } else { + monster = mon_mist_spectre; + category = "mist_summon_spectre"; + } + if( g->place_critter_around( monster, g->u.pos() + tripoint( rng( -radius, radius ), + rng( -radius, radius ), 0 ), radius ) != nullptr ) { + g->u.add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( category ).value_or( translation() ) ); + } + } + + if( calendar::once_every( g->weather.mist_intensity_increase_time ) ) { + g->weather.mist_intensity++; + if( g->weather.mist_intensity > g->weather.mist_max_intensity ) { + g->weather.mist_intensity = 0; + } + } +} /** * Thunder. * Flavor messages. Very wet. diff --git a/src/weather.h b/src/weather.h index 5bb269e145e0d..fe734722fd760 100644 --- a/src/weather.h +++ b/src/weather.h @@ -55,6 +55,7 @@ enum weather_type : int { WEATHER_FLURRIES, //!< Light snow WEATHER_SNOW, //!< snow glare effects WEATHER_SNOWSTORM, //!< sight penalties + WEATHER_MIST, //!< spawns mist monsters NUM_WEATHER_TYPES //!< Sentinel value }; @@ -122,6 +123,7 @@ void flurry(); void snow(); void sunny(); void snowstorm(); +void mist(); } //namespace weather_effect using weather_effect_fn = void ( * )(); @@ -248,6 +250,13 @@ class weather_manager weather_type weather = weather_type::WEATHER_NULL; int winddirection = 0; int windspeed = 0; + + //Mist values + int mist_intensity = 1; + int mist_max_intensity = 10; + time_duration mist_intensity_increase_time = 10_seconds; + time_duration mist_spawn_time = 5_seconds; + // Cached weather data pimpl weather_precise; cata::optional wind_direction_override; diff --git a/src/weather_data.cpp b/src/weather_data.cpp index 0d0f8e7d76b62..7e81baf7d57c6 100644 --- a/src/weather_data.cpp +++ b/src/weather_data.cpp @@ -25,7 +25,8 @@ weather_animation_t get_weather_animation( weather_type const type ) {WEATHER_LIGHTNING, weather_animation_t {0.04f, c_light_blue, ','}}, {WEATHER_FLURRIES, weather_animation_t {0.01f, c_white, '.'}}, {WEATHER_SNOW, weather_animation_t {0.02f, c_white, ','}}, - {WEATHER_SNOWSTORM, weather_animation_t {0.04f, c_white, '*'}} + {WEATHER_SNOWSTORM, weather_animation_t {0.04f, c_white, '*'}}, + {WEATHER_MIST, weather_animation_t {0.8f, c_dark_gray, '#'}} }; const auto it = map.find( type ); @@ -105,6 +106,10 @@ static weather_result weather_data_internal( weather_type const type ) weather_datum { translate_marker( "Snowstorm" ), c_white, c_white_cyan, '%', 6, 1.2f, -30, 6, false, PRECIP_HEAVY, false, false, &weather_effect::snowstorm + }, + weather_datum { + translate_marker( "Mist" ), c_light_gray, c_dark_gray, '*', 12, 12.4f, -30, 0, true, + PRECIP_NONE, false, false, &weather_effect::mist } }}; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 4f14b12c1beba..05a0c85b1913a 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -8,6 +8,7 @@ #include #include "cata_utility.h" +#include "game.h" #include "game_constants.h" #include "json.h" #include "math_defines.h" @@ -182,6 +183,9 @@ weather_type weather_generator::get_weather_conditions( const tripoint &location weather_type weather_generator::get_weather_conditions( const w_point &w ) const { + if( g->weather.mist_intensity > 0 ) { + return WEATHER_MIST; + } weather_type r( WEATHER_CLEAR ); if( w.pressure > 1020 && w.humidity < 70 ) { r = WEATHER_SUNNY; From ce3fbd04e66ff1f32b78f8fcf273de55ac629417 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 13 May 2020 23:49:20 -0400 Subject: [PATCH 02/27] Fix monster placement --- data/json/snippets/mist.json | 6 ++++-- src/game.cpp | 4 ++-- src/game.h | 2 ++ src/monattack.cpp | 4 ++-- src/weather.cpp | 17 ++++++++++++++--- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json index ffd7dbb6327a5..8a869f5c7c1da 100644 --- a/data/json/snippets/mist.json +++ b/data/json/snippets/mist.json @@ -3,7 +3,8 @@ "type": "snippet", "category": "mist_summon_wraith", "text": [ - "You feel the mist react to you and a shape appears." + "You feel the mist react to you and a shape appears.", + "The mist reacts to you and a hazy figure condenses." ] }, @@ -12,7 +13,8 @@ "category": "mist_summon_spectre", "text": [ "You see a shape form in the mist that reminds you of a creepy man that followed you when you were younger.", - "You see a shape form in the mist that reminds you of a teacher that hated you." + "You see a shape form in the mist that reminds you of a teacher that hated you.", + "A shape forms in the mist and you could swear ." ] } ] diff --git a/src/game.cpp b/src/game.cpp index 0a8ea49ece338..c62123572879a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4803,7 +4803,7 @@ template player *game::critter_by_id( const character_id & ); template npc *game::critter_by_id( const character_id & ); template Creature *game::critter_by_id( const character_id & ); -static bool can_place_monster( const monster &mon, const tripoint &p ) +bool game::can_place_monster( const monster &mon, const tripoint &p ) { if( const monster *const critter = g->critter_at( p ) ) { // Creature_tracker handles this. The hallucination monster will simply vanish @@ -4823,7 +4823,7 @@ static cata::optional choose_where_to_place_monster( const monster &mo const tripoint_range &range ) { return random_point( range, [&]( const tripoint & p ) { - return can_place_monster( mon, p ); + return game::can_place_monster( mon, p ); } ); } diff --git a/src/game.h b/src/game.h index dc5d42d37c1e3..75a554e51bf21 100644 --- a/src/game.h +++ b/src/game.h @@ -288,6 +288,8 @@ class game template shared_ptr_fast shared_from( const T &critter ); + static bool can_place_monster( const monster &mon, const tripoint &p ); + /** * Adds critters to the reality bubble, creating them if necessary. * Functions taking a @p id parameter will construct a monster based on that id, diff --git a/src/monattack.cpp b/src/monattack.cpp index 363000702b96c..64d64f44bf027 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -5803,7 +5803,7 @@ bool mattack::speaker( monster *z ) bool mattack::dissipate_drain( monster *z ) { Character *foe = static_cast( z->attack_target() ); - if( foe != nullptr && within_target_range( z, foe, 1 ) ) { + if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } @@ -5820,7 +5820,7 @@ bool mattack::dissipate_drain( monster *z ) bool mattack::dissipate_nightmares( monster *z ) { Character *foe = static_cast( z->attack_target() ); - if( foe != nullptr && within_target_range( z, foe, 1 ) ) { + if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } diff --git a/src/weather.cpp b/src/weather.cpp index 803775d2003a2..8ffa265dd0bdd 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -463,7 +463,7 @@ void weather_effect::snowstorm() void weather_effect::mist() { if( calendar::once_every( g->weather.mist_spawn_time ) && is_player_outside() ) { - int radius = 10; + int radius = 3; mtype_id monster; std::string category; if( g->weather.mist_intensity < 5 ) { @@ -473,8 +473,19 @@ void weather_effect::mist() monster = mon_mist_spectre; category = "mist_summon_spectre"; } - if( g->place_critter_around( monster, g->u.pos() + tripoint( rng( -radius, radius ), - rng( -radius, radius ), 0 ), radius ) != nullptr ) { + + + tripoint target; + bool found_location = false; + for( int i = 0; i < 10 && !found_location; i++ ) { + target = g->u.pos() + tripoint( rng( -radius, radius ), + rng( -radius, radius ), 0 ); + if( game::can_place_monster( monster, target ) && g->m.is_outside( target ) ) { + found_location = true; + } + } + + if( found_location && g->place_critter_around( monster, target, 3 ) != nullptr ) { g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( category ).value_or( translation() ) ); } From 8ff2a234e01d6317079f4338b790142f21e79cc1 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Thu, 14 May 2020 20:18:51 -0400 Subject: [PATCH 03/27] Add another monster --- data/json/effects.json | 7 ++++++- data/json/monsters/mist.json | 23 ++++++++++++++++++++++- data/json/morale_types.json | 10 ++++++++++ data/json/snippets/mist.json | 35 +++++++++++++++++++++++++++++++++-- src/character.cpp | 8 ++++++++ src/monattack.cpp | 30 +++++++++++++++++++++++++++--- src/monattack.h | 1 + src/monstergenerator.cpp | 1 + src/weather.cpp | 23 ++++++++++++++++------- 9 files changed, 124 insertions(+), 14 deletions(-) diff --git a/data/json/effects.json b/data/json/effects.json index 76cf11e104cc1..eb55dc9802961 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -1944,7 +1944,12 @@ { "type": "effect_type", "id": "disrupted_sleep", - "max_duration": "48 h" + "max_duration": "72 h" + }, + { + "type": "effect_type", + "id": "nightmares", + "max_duration": "72 h" }, { "type": "effect_type", diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index 526a5e8c0c04c..8031464ba4164 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -31,7 +31,7 @@ "weight": "0 g", "hp": 1, "speed": 110, - "symbol": "@", + "symbol": "U", "color": "white", "aggression": 100, "morale": 100, @@ -39,5 +39,26 @@ "special_attacks": [ [ "DISSIPATE_NIGHTMARES", 1 ] ], "death_function": [ "DISAPPEAR" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] + }, + { + "id": "mon_mist_phantom", + "type": "MONSTER", + "name": { "str": "Mist phantom" }, + "description": "A shifting figure slightly more solid than the mist surrounding it.", + "default_faction": "MIST", + "bodytype": "human", + "species": [ "MIST" ], + "volume": "62500 ml", + "weight": "0 g", + "hp": 1, + "speed": 110, + "symbol": "W", + "color": "white", + "aggression": 100, + "morale": 100, + "melee_skill": 3, + "special_attacks": [ [ "DISSIPATE_FORCE_SCREAM", 1 ] ], + "death_function": [ "DISAPPEAR" ], + "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] } ] diff --git a/data/json/morale_types.json b/data/json/morale_types.json index ced01a7c072f5..d55eb4b4de821 100644 --- a/data/json/morale_types.json +++ b/data/json/morale_types.json @@ -383,5 +383,15 @@ "id": "morale_perm_debug", "type": "morale_type", "text": "Debug Morale" + }, + { + "id": "morale_traumatic_memory", + "type": "morale_type", + "text": "Relived a traumatic memory" + }, + { + "id": "morale_nightmare", + "type": "morale_type", + "text": "Had a vivid nightmare" } ] diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json index 8a869f5c7c1da..a8b719ec608e7 100644 --- a/data/json/snippets/mist.json +++ b/data/json/snippets/mist.json @@ -11,10 +11,41 @@ { "type": "snippet", "category": "mist_summon_spectre", + "text": [ + "You see a shape form in the mist that reminds you of a figure from a nightmare.", + "You see a shape form in the mist that reminds you of a dream monster." + ] + }, + { + "type": "snippet", + "category": "mist_summon_phantom", "text": [ "You see a shape form in the mist that reminds you of a creepy man that followed you when you were younger.", - "You see a shape form in the mist that reminds you of a teacher that hated you.", - "A shape forms in the mist and you could swear ." + "You see a shape form in the mist that reminds you of a teacher that hated you." + ] + }, + { + "type": "snippet", + "category": "mist_increase_intensity", + "text": [ + "The mist grows thicker.", + "The mist feels slightly stronger and more alive" + ] + }, + { + "type": "snippet", + "category": "mist_shouts", + "text": [ + "I'm sorry mommy!.", + "Stop sir that hurts." + ] + }, + { + "type": "snippet", + "category": "nightmares", + "text": [ + "You awaken from a nightmare about being eaten alive while your friends applaud.", + "You awaken from a nightmare about being naked in a the artic tundra and freezing to death." ] } ] diff --git a/src/character.cpp b/src/character.cpp index 48439d8aa9ace..ba88a7f02e3bc 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -147,6 +147,7 @@ static const efftype_id effect_masked_scent( "masked_scent" ); static const efftype_id effect_mending( "mending" ); static const efftype_id effect_narcosis( "narcosis" ); static const efftype_id effect_nausea( "nausea" ); +static const efftype_id effect_nightmares( "nightmares" ); static const efftype_id effect_no_sight( "no_sight" ); static const efftype_id effect_onfire( "onfire" ); static const efftype_id effect_pkill1( "pkill1" ); @@ -344,6 +345,8 @@ static const std::string flag_USE_UPS( "USE_UPS" ); static const mtype_id mon_player_blob( "mon_player_blob" ); static const mtype_id mon_shadow_snake( "mon_shadow_snake" ); +const morale_type MORALE_NIGHTMARE( "morale_nightmare" ); + namespace io { @@ -7784,6 +7787,11 @@ void Character::wake_up() get_effect( effect_alarm_clock ).set_duration( 0_turns ); } recalc_sight_limits(); + if( has_effect( effect_nightmares ) ) { + add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( "nightmares" ).value_or( translation() ) ); + add_morale( MORALE_NIGHTMARE, -5, -15, 30_minutes ); + } } int Character::get_shout_volume() const diff --git a/src/monattack.cpp b/src/monattack.cpp index 64d64f44bf027..7d7726554555f 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -106,6 +106,7 @@ static const efftype_id effect_grown_of_fuse( "grown_of_fuse" ); static const efftype_id effect_has_bag( "has_bag" ); static const efftype_id effect_infected( "infected" ); static const efftype_id effect_laserlocked( "laserlocked" ); +static const efftype_id effect_nightmares( "nightmares" ); static const efftype_id effect_onfire( "onfire" ); static const efftype_id effect_operating( "operating" ); static const efftype_id effect_paid( "paid" ); @@ -181,6 +182,8 @@ static const mtype_id mon_zombie_gasbag_impaler( "mon_zombie_gasbag_impaler" ); static const mtype_id mon_zombie_jackson( "mon_zombie_jackson" ); static const mtype_id mon_zombie_skeltal_minion( "mon_zombie_skeltal_minion" ); +const morale_type MORALE_TRAUMATIC_MEMORY( "morale_traumatic_memory" ); + static const bionic_id bio_uncanny_dodge( "bio_uncanny_dodge" ); // shared utility functions @@ -5802,7 +5805,7 @@ bool mattack::speaker( monster *z ) bool mattack::dissipate_drain( monster *z ) { - Character *foe = static_cast( z->attack_target() ); + Character *foe = dynamic_cast( z->attack_target() ); if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } @@ -5819,12 +5822,12 @@ bool mattack::dissipate_drain( monster *z ) bool mattack::dissipate_nightmares( monster *z ) { - Character *foe = static_cast( z->attack_target() ); + Character *foe = dynamic_cast( z->attack_target() ); if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } - foe->add_effect( effect_disrupted_sleep, 8_hours ); + foe->add_effect( effect_nightmares, 8_hours ); foe->add_msg_if_player( m_bad, _( "The %s touches you and dissipates, leaving an unsettling feeling behind." ), z->name() ); @@ -5832,3 +5835,24 @@ bool mattack::dissipate_nightmares( monster *z ) return true; } + +bool mattack::dissipate_force_scream( monster *z ) +{ + Character *foe = dynamic_cast( z->attack_target() ); + if( foe == nullptr || !is_adjacent( z, foe, false ) ) { + return false; + } + + foe->add_morale( MORALE_TRAUMATIC_MEMORY, -5, -15, 30_minutes ); + foe->add_msg_if_player( m_bad, + _( "The %s touches you and dissipates, and you feel a memory surfacing so intensly you have no choice but to scream in response." ), + z->name() ); + std::string shout_message = string_format( "%s", + SNIPPET.random_from_category( "mist_shouts" ).value_or( translation() ) ); + + foe->add_msg_if_player( m_info, "You hear yourself scream \"%s\"", shout_message ); + foe->shout( shout_message ); + z->die( z ); + + return true; +} diff --git a/src/monattack.h b/src/monattack.h index ab5ae0a112b09..88898ca5809b2 100644 --- a/src/monattack.h +++ b/src/monattack.h @@ -71,6 +71,7 @@ bool searchlight( monster *z ); bool speaker( monster *z ); bool dissipate_drain( monster *z ); bool dissipate_nightmares( monster *z ); +bool dissipate_force_scream( monster *z ); bool copbot( monster *z ); bool chickenbot( monster *z ); // Pick from tazer, M4, MGL bool multi_robot( monster *z ); // Tazer, flame, M4, MGL, or 120mm! diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 78d84d952b6da..938b4d9d2920a 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -617,6 +617,7 @@ void MonsterGenerator::init_attack() add_hardcoded_attack( "ZOMBIE_FUSE", mattack::zombie_fuse ); add_hardcoded_attack( "DISSIPATE_DRAIN", mattack::dissipate_drain ); add_hardcoded_attack( "DISSIPATE_NIGHTMARES", mattack::dissipate_nightmares ); + add_hardcoded_attack( "DISSIPATE_FORCE_SCREAM", mattack::dissipate_force_scream ); } void MonsterGenerator::init_defense() diff --git a/src/weather.cpp b/src/weather.cpp index 8ffa265dd0bdd..f5ab4d0b7356a 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -45,6 +45,7 @@ static const efftype_id effect_snow_glare( "snow_glare" ); static const mtype_id mon_mist_wraith( "mon_mist_wraith" ); static const mtype_id mon_mist_spectre( "mon_mist_spectre" ); +static const mtype_id mon_mist_phantom( "mon_mist_phantom" ); static const trait_id trait_CEPH_VISION( "CEPH_VISION" ); static const trait_id trait_FEATHERS( "FEATHERS" ); @@ -466,13 +467,16 @@ void weather_effect::mist() int radius = 3; mtype_id monster; std::string category; - if( g->weather.mist_intensity < 5 ) { - monster = mon_mist_wraith; - category = "mist_summon_wraith"; - } else { - monster = mon_mist_spectre; - category = "mist_summon_spectre"; - } + /* if( g->weather.mist_intensity < 2 ) { + monster = mon_mist_wraith; + category = "mist_summon_wraith"; + } else if( g->weather.mist_intensity < 4 ) {*/ + monster = mon_mist_spectre; + category = "mist_summon_spectre"; + /*} else { + monster = mon_mist_phantom; + category = "mist_summon_phantom"; + }*/ tripoint target; @@ -495,7 +499,12 @@ void weather_effect::mist() g->weather.mist_intensity++; if( g->weather.mist_intensity > g->weather.mist_max_intensity ) { g->weather.mist_intensity = 0; + g->u.add_msg_if_player( m_good, _( "The mist evaporates away like it was never there." ) ); + } else { + g->u.add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); } + } } /** From 551485201344d18126805b6f1dd70216fdd9e932 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Fri, 15 May 2020 18:39:00 -0400 Subject: [PATCH 04/27] Fixed monster placement --- data/json/monsters/mist.json | 6 ++--- data/json/snippets/mist.json | 19 +++++++++++--- src/weather.cpp | 51 ++++++++++++++++++++++-------------- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index 8031464ba4164..93c5ba38f5ef5 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -9,7 +9,7 @@ "volume": "62500 ml", "weight": "0 g", "hp": 1, - "speed": 110, + "speed": 70, "symbol": "X", "color": "white", "aggression": 75, @@ -30,7 +30,7 @@ "volume": "62500 ml", "weight": "0 g", "hp": 1, - "speed": 110, + "speed": 70, "symbol": "U", "color": "white", "aggression": 100, @@ -51,7 +51,7 @@ "volume": "62500 ml", "weight": "0 g", "hp": 1, - "speed": 110, + "speed": 70, "symbol": "W", "color": "white", "aggression": 100, diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json index a8b719ec608e7..f3d434458668e 100644 --- a/data/json/snippets/mist.json +++ b/data/json/snippets/mist.json @@ -28,16 +28,27 @@ "type": "snippet", "category": "mist_increase_intensity", "text": [ - "The mist grows thicker.", - "The mist feels slightly stronger and more alive" + "The mist thickens.", + "The mist feels slightly stronger and more alive." ] }, { "type": "snippet", "category": "mist_shouts", "text": [ - "I'm sorry mommy!.", - "Stop sir that hurts." + "I'm sorry mommy!", + "Please stop sir, that hurts!", + "Why? I tried my best!", + "No, please get up, please be ok!", + "Why would you lie about THAT?", + "I never loved you!", + "I only ever tolerated you!", + "That's why I never trusted you!", + "It's not fair!", + "Enjoy the funeral, you sicko!", + "Help!", + "Cmon I can still be fun, there's no need for that!", + "I can do better, I promise, please!" ] }, { diff --git a/src/weather.cpp b/src/weather.cpp index f5ab4d0b7356a..15902ee27e9f3 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -464,32 +464,39 @@ void weather_effect::snowstorm() void weather_effect::mist() { if( calendar::once_every( g->weather.mist_spawn_time ) && is_player_outside() ) { - int radius = 3; mtype_id monster; std::string category; - /* if( g->weather.mist_intensity < 2 ) { - monster = mon_mist_wraith; - category = "mist_summon_wraith"; - } else if( g->weather.mist_intensity < 4 ) {*/ - monster = mon_mist_spectre; - category = "mist_summon_spectre"; - /*} else { - monster = mon_mist_phantom; - category = "mist_summon_phantom"; - }*/ - + int rand = rng( 1, 3 ); + switch( rand ) { + case 1: + monster = mon_mist_wraith; + category = "mist_summon_wraith"; + break; + case 2: + monster = mon_mist_spectre; + category = "mist_summon_spectre"; + break; + case 3: + monster = mon_mist_phantom; + category = "mist_summon_phantom"; + break; + default: + debugmsg( "HUH?" ); + break; + } tripoint target; bool found_location = false; - for( int i = 0; i < 10 && !found_location; i++ ) { - target = g->u.pos() + tripoint( rng( -radius, radius ), - rng( -radius, radius ), 0 ); - if( game::can_place_monster( monster, target ) && g->m.is_outside( target ) ) { + int radius = 4; + for( int i = 0; i < 15 && !found_location; i++ ) { + target = g->u.pos() + tripoint( rng( -radius, radius ), rng( -radius, radius ), 0 ); + if( game::can_place_monster( monster, target ) && g->m.is_outside( target ) && + rl_dist( target, g->u.pos() ) > 2 ) { found_location = true; } } - if( found_location && g->place_critter_around( monster, target, 3 ) != nullptr ) { + if( found_location && g->place_critter_at( monster, target ) != nullptr ) { g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( category ).value_or( translation() ) ); } @@ -499,10 +506,14 @@ void weather_effect::mist() g->weather.mist_intensity++; if( g->weather.mist_intensity > g->weather.mist_max_intensity ) { g->weather.mist_intensity = 0; - g->u.add_msg_if_player( m_good, _( "The mist evaporates away like it was never there." ) ); + if( is_player_outside() ) { + g->u.add_msg_if_player( m_good, _( "The mist evaporates like it was never there." ) ); + } } else { - g->u.add_msg_if_player( m_bad, "%s", - SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); + if( is_player_outside() ) { + g->u.add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); + } } } From 0c938adcbc5401f9d06906bd93b9a430c752c5e5 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Tue, 19 May 2020 22:04:19 -0400 Subject: [PATCH 05/27] Added mist bag, enemy that summons mist --- data/json/monsters/mist.json | 27 ++++++++++++++++++++++++--- data/json/snippets/mist.json | 12 ++++++++++-- src/monattack.cpp | 20 ++++++++++++++------ src/monattack.h | 1 + src/mondeath.cpp | 23 +++++++++++++++++++++++ src/mondeath.h | 4 ++++ src/monstergenerator.cpp | 5 +++++ src/weather.h | 2 +- 8 files changed, 82 insertions(+), 12 deletions(-) diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index 93c5ba38f5ef5..c64b428662406 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -16,7 +16,7 @@ "morale": 100, "melee_skill": 10, "special_attacks": [ [ "DISSIPATE_DRAIN", 1 ] ], - "death_function": [ "DISAPPEAR" ], + "death_function": [ "DISSIPATE" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] }, { @@ -37,7 +37,7 @@ "morale": 100, "melee_skill": 3, "special_attacks": [ [ "DISSIPATE_NIGHTMARES", 1 ] ], - "death_function": [ "DISAPPEAR" ], + "death_function": [ "DISSIPATE" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] }, { @@ -58,7 +58,28 @@ "morale": 100, "melee_skill": 3, "special_attacks": [ [ "DISSIPATE_FORCE_SCREAM", 1 ] ], - "death_function": [ "DISAPPEAR" ], + "death_function": [ "DISSIPATE" ], + "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] + }, + { + "id": "mon_mist_bag", + "type": "MONSTER", + "name": { "str": "Mist bag" }, + "description": "A bag seemingly made of mist, it appears to be on the edge of bursting.", + "default_faction": "MIST", + "bodytype": "human", + "species": [ "MIST" ], + "volume": "62500 ml", + "weight": "0 g", + "hp": 1, + "speed": 70, + "symbol": "B", + "color": "white", + "aggression": 100, + "morale": 100, + "melee_skill": 3, + "special_attacks": [ [ "DISSIPATE", 1 ] ], + "death_function": [ "RELEASE_MIST" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] } ] diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json index f3d434458668e..ae9f42d32129a 100644 --- a/data/json/snippets/mist.json +++ b/data/json/snippets/mist.json @@ -12,7 +12,7 @@ "type": "snippet", "category": "mist_summon_spectre", "text": [ - "You see a shape form in the mist that reminds you of a figure from a nightmare.", + "A shape appears in the mist that reminds you of a figure from a nightmare.", "You see a shape form in the mist that reminds you of a dream monster." ] }, @@ -32,12 +32,20 @@ "The mist feels slightly stronger and more alive." ] }, + { + "type": "snippet", + "category": "mist_arrives", + "text": [ + "You blink and there is dense mist as far as you can see, which is much less than it used to be.", + "In an instant a thick mist descends upon the world, far too fast to be natural. Or are you finally losing it?." + ] + }, { "type": "snippet", "category": "mist_shouts", "text": [ "I'm sorry mommy!", - "Please stop sir, that hurts!", + "Please stop, that hurts!", "Why? I tried my best!", "No, please get up, please be ok!", "Why would you lie about THAT?", diff --git a/src/monattack.cpp b/src/monattack.cpp index 7d7726554555f..27b303e6affbf 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -5811,12 +5811,11 @@ bool mattack::dissipate_drain( monster *z ) } foe->mod_fatigue( 50 ); - foe->mod_stamina( -50 ); + foe->mod_stamina( -100 ); foe->add_msg_if_player( m_bad, - _( "The %s touches you and dissipates, taking a little of your strength with it." ), z->name() ); + _( "The %s touches you taking a little of your strength with it." ), z->name() ); z->die( z ); - return true; } @@ -5829,10 +5828,9 @@ bool mattack::dissipate_nightmares( monster *z ) foe->add_effect( effect_disrupted_sleep, 8_hours ); foe->add_effect( effect_nightmares, 8_hours ); foe->add_msg_if_player( m_bad, - _( "The %s touches you and dissipates, leaving an unsettling feeling behind." ), z->name() ); + _( "The %s touches you leaving an unsettling feeling behind." ), z->name() ); z->die( z ); - return true; } @@ -5845,7 +5843,7 @@ bool mattack::dissipate_force_scream( monster *z ) foe->add_morale( MORALE_TRAUMATIC_MEMORY, -5, -15, 30_minutes ); foe->add_msg_if_player( m_bad, - _( "The %s touches you and dissipates, and you feel a memory surfacing so intensly you have no choice but to scream in response." ), + _( "The %s touches you and you feel a memory surfacing so intensly you have no choice but to scream in response." ), z->name() ); std::string shout_message = string_format( "%s", SNIPPET.random_from_category( "mist_shouts" ).value_or( translation() ) ); @@ -5856,3 +5854,13 @@ bool mattack::dissipate_force_scream( monster *z ) return true; } + +bool mattack::dissipate( monster *z ) +{ + Character *foe = dynamic_cast( z->attack_target() ); + if( foe == nullptr || !is_adjacent( z, foe, false ) ) { + return false; + } + z->die( z ); + return true; +} diff --git a/src/monattack.h b/src/monattack.h index 88898ca5809b2..a759be85d536f 100644 --- a/src/monattack.h +++ b/src/monattack.h @@ -69,6 +69,7 @@ bool tazer( monster *z ); bool flamethrower( monster *z ); bool searchlight( monster *z ); bool speaker( monster *z ); +bool dissipate( monster *z ); bool dissipate_drain( monster *z ); bool dissipate_nightmares( monster *z ); bool dissipate_force_scream( monster *z ); diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 3e0d87a9d6c96..0404504a5614c 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -45,6 +45,7 @@ #include "sounds.h" #include "string_formatter.h" #include "string_id.h" +#include "text_snippets.h" #include "timed_event.h" #include "translations.h" #include "type_id.h" @@ -847,3 +848,25 @@ void mdeath::necro_boomer( monster &z ) } } } + +void mdeath::dissipate( monster &z ) +{ + if( g->u.sees( z ) ) { + add_msg( m_good, _( "The %s dissipates into mist." ), z.name() ); + } +} + +void mdeath::release_mist( monster &z ) +{ + + std::string burst = g->u.sees( z ) ? string_format( _( "The %s bursts open!" ), z.name() ) : ""; + if( g->weather.mist_intensity == 0 ) { + g->u.add_msg_if_player( m_bad, "%s %s", burst, + SNIPPET.random_from_category( "mist_arrives" ).value_or( translation() ) ); + } else { + g->u.add_msg_if_player( m_bad, "%s %s", burst, + SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); + } + g->weather.mist_intensity++; + g->weather.set_nextweather( calendar::turn ); +} diff --git a/src/mondeath.h b/src/mondeath.h index 79e289bbac656..7988c9de0b1ec 100644 --- a/src/mondeath.h +++ b/src/mondeath.h @@ -80,6 +80,10 @@ void fireball( monster &z ); void conflagration( monster &z ); // raises and then upgrades all zombies in a radius void necro_boomer( monster &z ); +//dissolves into mist leaving nothing +void dissipate( monster &z ); +//summons/strenthens the mist +void release_mist( monster &z ); // Game over! Defense mode void gameover( monster &z ); diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 938b4d9d2920a..038bb7a23f1f5 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -506,6 +506,10 @@ void MonsterGenerator::init_death() death_map["CONFLAGRATION"] = &mdeath::conflagration; // resurrect all zombies in the area and upgrade all zombies in the area death_map["NECRO_BOOMER"] = &mdeath::necro_boomer; + //dissipates into mist + death_map["DISSIPATE"] = &mdeath::dissipate; + //summons/strengthens the mist + death_map["RELEASE_MIST"] = &mdeath::release_mist; /* Currently Unimplemented */ // Screams loudly @@ -618,6 +622,7 @@ void MonsterGenerator::init_attack() add_hardcoded_attack( "DISSIPATE_DRAIN", mattack::dissipate_drain ); add_hardcoded_attack( "DISSIPATE_NIGHTMARES", mattack::dissipate_nightmares ); add_hardcoded_attack( "DISSIPATE_FORCE_SCREAM", mattack::dissipate_force_scream ); + add_hardcoded_attack( "DISSIPATE", mattack::dissipate ); } void MonsterGenerator::init_defense() diff --git a/src/weather.h b/src/weather.h index fe734722fd760..4ccac3052cc92 100644 --- a/src/weather.h +++ b/src/weather.h @@ -252,7 +252,7 @@ class weather_manager int windspeed = 0; //Mist values - int mist_intensity = 1; + int mist_intensity = 0; int mist_max_intensity = 10; time_duration mist_intensity_increase_time = 10_seconds; time_duration mist_spawn_time = 5_seconds; From cb9e413800feef6b2803244af7cf521d1a0984ff Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Tue, 26 May 2020 18:15:10 -0400 Subject: [PATCH 06/27] Add incorporeal and debug options --- data/json/effects.json | 8 ++- data/json/monsters/mist.json | 4 +- data/json/snippets/mist.json | 29 ++++++--- src/activity_item_handling.cpp | 4 +- src/animation.cpp | 22 ++++--- src/avatar_action.cpp | 4 +- src/character.cpp | 12 +++- src/character.h | 1 + src/debug_menu.cpp | 62 +++++++++++++++++- src/game.cpp | 2 +- src/iuse_actor.cpp | 9 +++ src/monattack.cpp | 31 ++++++--- src/monattack.h | 1 + src/mondeath.cpp | 13 +--- src/monstergenerator.cpp | 1 + src/options.cpp | 20 ++++++ src/player.cpp | 4 ++ src/sounds.cpp | 26 ++++---- src/suffer.cpp | 13 ++++ src/weather.cpp | 111 ++++++++++++++++++++------------- src/weather.h | 14 ++++- src/weather_data.cpp | 14 ++++- src/weather_gen.cpp | 9 ++- 23 files changed, 306 insertions(+), 108 deletions(-) diff --git a/data/json/effects.json b/data/json/effects.json index eb55dc9802961..b7f5bb0f05b28 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -1944,13 +1944,19 @@ { "type": "effect_type", "id": "disrupted_sleep", - "max_duration": "72 h" + "max_duration": "72 h" }, { "type": "effect_type", "id": "nightmares", "max_duration": "72 h" }, + { + "type": "effect_type", + "id": "incorporeal", + "name": [ "Incorporeal" ], + "desc": [ "You have as much substance as mist does." ] + }, { "type": "effect_type", "id": "ignore_fall_damage", diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index c64b428662406..7260260e1090e 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -36,7 +36,7 @@ "aggression": 100, "morale": 100, "melee_skill": 3, - "special_attacks": [ [ "DISSIPATE_NIGHTMARES", 1 ] ], + "special_attacks": [ [ "DISSIPATE_NIGHTMARES", 1 ], [ "DISSIPATE_FORCE_SCREAM", 1 ] ], "death_function": [ "DISSIPATE" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] }, @@ -57,7 +57,7 @@ "aggression": 100, "morale": 100, "melee_skill": 3, - "special_attacks": [ [ "DISSIPATE_FORCE_SCREAM", 1 ] ], + "special_attacks": [ [ "DISSIPATE_INCORPOREAL", 1 ] ], "death_function": [ "DISSIPATE" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] }, diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json index ae9f42d32129a..16a2ab4f083fb 100644 --- a/data/json/snippets/mist.json +++ b/data/json/snippets/mist.json @@ -5,14 +5,13 @@ "text": [ "You feel the mist react to you and a shape appears.", "The mist reacts to you and a hazy figure condenses." - ] }, { "type": "snippet", "category": "mist_summon_spectre", "text": [ - "A shape appears in the mist that reminds you of a figure from a nightmare.", + "A nightmarish shape appears in the mist.", "You see a shape form in the mist that reminds you of a dream monster." ] }, @@ -20,8 +19,8 @@ "type": "snippet", "category": "mist_summon_phantom", "text": [ - "You see a shape form in the mist that reminds you of a creepy man that followed you when you were younger.", - "You see a shape form in the mist that reminds you of a teacher that hated you." + "A shape forms in the mist reminiscent of your childhood bully.", + "A shape forms in the mist reminiscent you of a teacher that hated you." ] }, { @@ -39,14 +38,22 @@ "You blink and there is dense mist as far as you can see, which is much less than it used to be.", "In an instant a thick mist descends upon the world, far too fast to be natural. Or are you finally losing it?." ] + }, + { + "type": "snippet", + "category": "mist_leaves", + "text": [ + "The mist evaporates like it was never there.", + "In a heartbeat the mist is gone." + ] }, { "type": "snippet", "category": "mist_shouts", "text": [ "I'm sorry mommy!", - "Please stop, that hurts!", - "Why? I tried my best!", + "Please stop sir, that hurts!", + "Why? I tried my best!", "No, please get up, please be ok!", "Why would you lie about THAT?", "I never loved you!", @@ -56,7 +63,9 @@ "Enjoy the funeral, you sicko!", "Help!", "Cmon I can still be fun, there's no need for that!", - "I can do better, I promise, please!" + "I can do better, I promise, please!", + "I'm going to kill that son of a bitch!", + "That's no excuse!" ] }, { @@ -64,7 +73,11 @@ "category": "nightmares", "text": [ "You awaken from a nightmare about being eaten alive while your friends applaud.", - "You awaken from a nightmare about being naked in a the artic tundra and freezing to death." + "You awaken from a nightmare about being naked in a the artic tundra and freezing to death.", + "You awaken from a nightmare about an unseen predator slowly killing you.", + "You awaken from a nightmare about killing those you love with your bare hands.", + "You awaken from a nightmare about being finally judged for your ill deeds.", + "You awaken from a nightmare about the cataclysm not having happened and being stuck in an office job." ] } ] diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index e5f6a1eff9170..1f0346d47cfc4 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -88,6 +88,8 @@ static const activity_id ACT_TIDY_UP( "ACT_TIDY_UP" ); static const activity_id ACT_VEHICLE( "ACT_VEHICLE" ); static const activity_id ACT_VEHICLE_DECONSTRUCTION( "ACT_VEHICLE_DECONSTRUCTION" ); static const activity_id ACT_VEHICLE_REPAIR( "ACT_VEHICLE_REPAIR" ); + +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_pet( "pet" ); static const efftype_id effect_nausea( "nausea" ); @@ -2172,7 +2174,7 @@ static bool mine_activity( player &p, const tripoint &src_loc ) ( itm.type->can_use( "JACKHAMMER" ) && itm.ammo_sufficient() ); } ); if( mining_inv.empty() || p.is_mounted() || p.is_underwater() || g->m.veh_at( src_loc ) || - !g->m.has_flag( "MINEABLE", src_loc ) ) { + !g->m.has_flag( "MINEABLE", src_loc ) || p.has_effect( effect_incorporeal ) ) { return false; } item *chosen_item = nullptr; diff --git a/src/animation.cpp b/src/animation.cpp index 2699fbeee119e..d485836990c08 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -20,10 +20,10 @@ #include "point.h" #if defined(TILES) - #include +#include - #include "cata_tiles.h" // all animation functions will be pushed out to a cata_tiles function in some manner - #include "sdltiles.h" +#include "cata_tiles.h" // all animation functions will be pushed out to a cata_tiles function in some manner +#include "sdltiles.h" #endif #include @@ -290,7 +290,7 @@ void explosion_handler::draw_custom_explosion( const tripoint &, // Start by getting rid of everything except current z-level std::map neighbors; - #if defined(TILES) +#if defined(TILES) if( !use_tiles ) { for( const auto &pr : all_area ) { const tripoint relative_point = relative_view_pos( g->u, pr.first ); @@ -309,14 +309,14 @@ void explosion_handler::draw_custom_explosion( const tripoint &, } } } - #else +#else for( const auto &pr : all_area ) { const tripoint relative_point = relative_view_pos( g->u, pr.first ); if( relative_point.z == 0 ) { neighbors[pr.first] = explosion_tile{ N_NO_NEIGHBORS, pr.second }; } } - #endif +#endif // Searches for a neighbor, sets the neighborhood flag on current point and on the neighbor const auto set_neighbors = [&]( const tripoint & pos, @@ -388,7 +388,7 @@ void explosion_handler::draw_custom_explosion( const tripoint &, layers.push_front( std::move( layer ) ); } - #if defined(TILES) +#if defined(TILES) if( !use_tiles ) { draw_custom_explosion_curses( *g, layers ); return; @@ -406,9 +406,9 @@ void explosion_handler::draw_custom_explosion( const tripoint &, } tilecontext->void_custom_explosion(); - #else +#else draw_custom_explosion_curses( *g, layers ); - #endif +#endif } namespace @@ -705,7 +705,9 @@ void game::draw_weather( const weather_printable &w ) case WEATHER_SNOWSTORM: weather_name = weather_snowflake; break; - case WEATHER_MIST: + case WEATHER_LIGHT_MIST: + case WEATHER_MEDIUM_MIST: + case WEATHER_HEAVY_MIST: weather_name = weather_mist; break; default: diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 46387d0e54e5e..6397cb72917b8 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -62,6 +62,7 @@ static const activity_id ACT_AIM( "ACT_AIM" ); static const efftype_id effect_amigara( "amigara" ); static const efftype_id effect_glowing( "glowing" ); static const efftype_id effect_harnessed( "harnessed" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_onfire( "onfire" ); static const efftype_id effect_pet( "pet" ); static const efftype_id effect_relax_gas( "relax_gas" ); @@ -117,7 +118,8 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) if( m.has_flag( TFLAG_MINEABLE, dest_loc ) && g->mostseen == 0 && get_option( "AUTO_FEATURES" ) && get_option( "AUTO_MINING" ) && - !m.veh_at( dest_loc ) && !you.is_underwater() && !you.has_effect( effect_stunned ) && + !m.veh_at( dest_loc ) && !you.is_underwater() && !you.has_effect( effect_incorporeal ) && + !you.has_effect( effect_stunned ) && !is_riding ) { if( you.weapon.has_flag( flag_DIG_TOOL ) ) { if( you.weapon.type->can_use( "JACKHAMMER" ) && you.weapon.ammo_sufficient() ) { diff --git a/src/character.cpp b/src/character.cpp index ba88a7f02e3bc..8c6abbc37de22 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -137,13 +137,14 @@ static const efftype_id effect_heavysnare( "heavysnare" ); static const efftype_id effect_hot( "hot" ); static const efftype_id effect_hot_speed( "hot_speed" ); static const efftype_id effect_in_pit( "in_pit" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_infected( "infected" ); static const efftype_id effect_jetinjector( "jetinjector" ); static const efftype_id effect_lack_sleep( "lack_sleep" ); static const efftype_id effect_lightsnare( "lightsnare" ); static const efftype_id effect_lying_down( "lying_down" ); -static const efftype_id effect_melatonin_supplements( "melatonin" ); static const efftype_id effect_masked_scent( "masked_scent" ); +static const efftype_id effect_melatonin_supplements( "melatonin" ); static const efftype_id effect_mending( "mending" ); static const efftype_id effect_narcosis( "narcosis" ); static const efftype_id effect_nausea( "nausea" ); @@ -2856,6 +2857,11 @@ bool Character::can_pickWeight( const item &it, bool safe ) const bool Character::can_use( const item &it, const item &context ) const { + if( has_effect( effect_incorporeal ) ) { + add_msg_player_or_npc( m_bad, _( "You can't use anything while incorporeal." ), + _( " can't use anything while incorporeal." ) ); + return false; + } const auto &ctx = !context.is_null() ? context : it; if( !meets_requirements( it, ctx ) ) { @@ -2881,6 +2887,10 @@ bool Character::can_use( const item &it, const item &context ) const ret_val Character::can_wear( const item &it, bool with_equip_change ) const { + if( has_effect( effect_incorporeal ) ) { + return ret_val::make_failure( _( "You can't wear anything while incorporeal." ) ); + } + if( !it.is_armor() ) { return ret_val::make_failure( _( "Putting on a %s would be tricky." ), it.tname() ); } diff --git a/src/character.h b/src/character.h index c15962949a712..07f1c0f112af7 100644 --- a/src/character.h +++ b/src/character.h @@ -2271,6 +2271,7 @@ class Character : public Creature, public visitable void suffer_in_sunlight(); void suffer_from_albinism(); void suffer_from_other_mutations(); + void suffer_item_dropping(); void suffer_from_radiation(); void suffer_from_bad_bionics(); void suffer_from_artifacts(); diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 4c34d0cd6b9de..d7e9f6f61318b 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -169,7 +169,8 @@ enum debug_menu_index { DEBUG_LEARN_SPELLS, DEBUG_LEVEL_SPELLS, DEBUG_TEST_MAP_EXTRA_DISTRIBUTION, - DEBUG_NESTED_MAPGEN + DEBUG_NESTED_MAPGEN, + DEBUG_MIST }; class mission_debug @@ -292,6 +293,7 @@ static int map_uilist() { uilist_entry( DEBUG_CHANGE_WEATHER, true, 'w', _( "Change weather" ) ) }, { uilist_entry( DEBUG_WIND_DIRECTION, true, 'd', _( "Change wind direction" ) ) }, { uilist_entry( DEBUG_WIND_SPEED, true, 's', _( "Change wind speed" ) ) }, + { uilist_entry( DEBUG_MIST, true, 'i', _( "Change Mist" ) ) }, { uilist_entry( DEBUG_KILL_MONS, true, 'K', _( "Kill all monsters" ) ) }, { uilist_entry( DEBUG_CHANGE_TIME, true, 't', _( "Change time" ) ) }, { uilist_entry( DEBUG_OM_EDITOR, true, 'O', _( "Overmap editor" ) ) }, @@ -1406,6 +1408,64 @@ void debug() } break; + case DEBUG_MIST: { + uilist smenu; + smenu.addentry( 0, true, 'i', "%s: %d", _( "Intensity" ), g->weather.mist_intensity ); + smenu.addentry( 1, true, 'm', "%s: %d", _( "Min Intensity" ), g->weather.mist_min_intensity ); + smenu.addentry( 2, true, 'x', "%s: %d", _( "Max Intensity" ), g->weather.mist_max_intensity ); + smenu.addentry( 3, true, 's', "%s: %d", _( "Mist Scaling" ), g->weather.mist_scaling ); + smenu.addentry( 4, true, 't', "%s: %s", _( "Intensity Increase Time" ), + to_seconds( g->weather.mist_intensity_increase_time ) ); + smenu.addentry( 5, true, 'w', "%s: %s", _( "Spawn Time" ), + to_seconds( g->weather.mist_spawn_time ) ); + + smenu.query(); + int value; + switch( smenu.ret ) { + case 0: + if( query_int( value, _( "Set Intensity to? Currently: %d" ), g->weather.mist_intensity ) ) { + g->weather.mist_intensity = value; + } + break; + + case 1: + if( query_int( value, _( "Set Min Intensity to? Currently: %d" ), + g->weather.mist_min_intensity ) ) { + g->weather.mist_min_intensity = value; + } + break; + + case 2: + if( query_int( value, _( "Set Max Intensity to? Currently: %d" ), + g->weather.mist_max_intensity ) ) { + g->weather.mist_max_intensity = value; + } + break; + + case 3: + if( query_int( value, _( "Set Mist Scaling to? Currently: %d" ), g->weather.mist_scaling ) ) { + g->weather.mist_scaling = value; + } + break; + + case 4: + if( query_int( value, _( "Set Intensity Increase Time to? Currently: %d" ), + to_seconds( g->weather.mist_intensity_increase_time ) ) ) { + g->weather.mist_intensity_increase_time = time_duration::from_seconds( value ); + } + break; + case 5: + if( query_int( value, _( "Set Spawn Time to? Currently: %d" ), + to_seconds( g->weather.mist_spawn_time ) ) ) { + g->weather.mist_spawn_time = time_duration::from_seconds( value ); + } + default: + break; + } + } + g->weather.set_nextweather( calendar::turn ); + break; + case DEBUG_KILL_MONS: { for( monster &critter : g->all_monsters() ) { // Use the normal death functions, useful for testing death diff --git a/src/game.cpp b/src/game.cpp index c62123572879a..93e0ab6587b09 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -4839,8 +4839,8 @@ monster *game::place_critter_at( const shared_ptr_fast &mon, const trip monster *game::place_critter_around( const mtype_id &id, const tripoint ¢er, const int radius ) { - // TODO: change this into an assert, it must never happen. if( id.is_null() ) { + debugmsg( "Tried to place null critter." ); return nullptr; } return place_critter_around( make_shared_fast( id ), center, radius ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 39d6ca1cb2d7f..71a68bd6cf6ae 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -98,6 +98,7 @@ static const efftype_id effect_bite( "bite" ); static const efftype_id effect_bleed( "bleed" ); static const efftype_id effect_disinfected( "disinfected" ); static const efftype_id effect_downed( "downed" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_infected( "infected" ); static const efftype_id effect_music( "music" ); static const efftype_id effect_playing_instrument( "playing_instrument" ); @@ -2544,6 +2545,14 @@ void repair_item_actor::load( const JsonObject &obj ) bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool print_msg ) const { + if( p.has_effect( effect_incorporeal ) ) { + if( print_msg ) { + p.add_msg_player_or_npc( m_bad, _( "You can't do that while incorporeal." ), + _( " can't do that while incorporeal." ) ); + } + return false; + } + if( p.is_underwater() ) { if( print_msg ) { p.add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); diff --git a/src/monattack.cpp b/src/monattack.cpp index 27b303e6affbf..3d6d89cf26838 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -104,6 +104,7 @@ static const efftype_id effect_grabbed( "grabbed" ); static const efftype_id effect_grabbing( "grabbing" ); static const efftype_id effect_grown_of_fuse( "grown_of_fuse" ); static const efftype_id effect_has_bag( "has_bag" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_infected( "infected" ); static const efftype_id effect_laserlocked( "laserlocked" ); static const efftype_id effect_nightmares( "nightmares" ); @@ -5810,10 +5811,10 @@ bool mattack::dissipate_drain( monster *z ) return false; } - foe->mod_fatigue( 50 ); - foe->mod_stamina( -100 ); + foe->mod_fatigue( 100 ); + foe->mod_stamina( -200 ); foe->add_msg_if_player( m_bad, - _( "The %s touches you taking a little of your strength with it." ), z->name() ); + _( "The %s takes a little of your strength." ), z->name() ); z->die( z ); return true; @@ -5825,10 +5826,10 @@ bool mattack::dissipate_nightmares( monster *z ) if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } - foe->add_effect( effect_disrupted_sleep, 8_hours ); - foe->add_effect( effect_nightmares, 8_hours ); + foe->add_effect( effect_disrupted_sleep, 12_hours ); + foe->add_effect( effect_nightmares, 12_hours ); foe->add_msg_if_player( m_bad, - _( "The %s touches you leaving an unsettling feeling behind." ), z->name() ); + _( "The %s leaves an unsettling feeling behind." ), z->name() ); z->die( z ); return true; @@ -5841,9 +5842,9 @@ bool mattack::dissipate_force_scream( monster *z ) return false; } - foe->add_morale( MORALE_TRAUMATIC_MEMORY, -5, -15, 30_minutes ); + foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, 1_hours ); foe->add_msg_if_player( m_bad, - _( "The %s touches you and you feel a memory surfacing so intensly you have no choice but to scream in response." ), + _( "The %s surfaces an intense memory, that feels like your own." ), z->name() ); std::string shout_message = string_format( "%s", SNIPPET.random_from_category( "mist_shouts" ).value_or( translation() ) ); @@ -5855,6 +5856,20 @@ bool mattack::dissipate_force_scream( monster *z ) return true; } +bool mattack::dissipate_incorporeal( monster *z ) +{ + Character *foe = dynamic_cast( z->attack_target() ); + if( foe == nullptr || !is_adjacent( z, foe, false ) ) { + return false; + } + foe->add_effect( effect_incorporeal, 3_seconds ); + foe->add_msg_if_player( m_bad, + _( "The %s robs you of your form briefly." ), z->name() ); + + z->die( z ); + return true; +} + bool mattack::dissipate( monster *z ) { Character *foe = dynamic_cast( z->attack_target() ); diff --git a/src/monattack.h b/src/monattack.h index a759be85d536f..43c3eec9750e1 100644 --- a/src/monattack.h +++ b/src/monattack.h @@ -73,6 +73,7 @@ bool dissipate( monster *z ); bool dissipate_drain( monster *z ); bool dissipate_nightmares( monster *z ); bool dissipate_force_scream( monster *z ); +bool dissipate_incorporeal( monster *z ); bool copbot( monster *z ); bool chickenbot( monster *z ); // Pick from tazer, M4, MGL bool multi_robot( monster *z ); // Tazer, flame, M4, MGL, or 120mm! diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 0404504a5614c..d9ca6007b3d1e 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -858,15 +858,6 @@ void mdeath::dissipate( monster &z ) void mdeath::release_mist( monster &z ) { - - std::string burst = g->u.sees( z ) ? string_format( _( "The %s bursts open!" ), z.name() ) : ""; - if( g->weather.mist_intensity == 0 ) { - g->u.add_msg_if_player( m_bad, "%s %s", burst, - SNIPPET.random_from_category( "mist_arrives" ).value_or( translation() ) ); - } else { - g->u.add_msg_if_player( m_bad, "%s %s", burst, - SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); - } - g->weather.mist_intensity++; - g->weather.set_nextweather( calendar::turn ); + add_msg( g->u.sees( z ) ? string_format( _( "The %s bursts open!" ), z.name() ) : "" ); + g->weather.increase_mist_intensity(); } diff --git a/src/monstergenerator.cpp b/src/monstergenerator.cpp index 038bb7a23f1f5..d57d8ebd7d949 100644 --- a/src/monstergenerator.cpp +++ b/src/monstergenerator.cpp @@ -622,6 +622,7 @@ void MonsterGenerator::init_attack() add_hardcoded_attack( "DISSIPATE_DRAIN", mattack::dissipate_drain ); add_hardcoded_attack( "DISSIPATE_NIGHTMARES", mattack::dissipate_nightmares ); add_hardcoded_attack( "DISSIPATE_FORCE_SCREAM", mattack::dissipate_force_scream ); + add_hardcoded_attack( "DISSIPATE_INCORPOREAL", mattack::dissipate_incorporeal ); add_hardcoded_attack( "DISSIPATE", mattack::dissipate ); } diff --git a/src/options.cpp b/src/options.cpp index b7401efed26f6..6385acbeb099f 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2186,6 +2186,26 @@ void options_manager::add_options_world_default() { { "any", translate_marker( "Any" ) }, { "multi_pool", translate_marker( "Multi-pool only" ) }, { "no_freeform", translate_marker( "No freeform" ) } }, "any" ); + + add_empty_line(); + + add( "MIST_ACTIVE", "world_default", translate_marker( "Mist active." ), + translate_marker( "Mist is active and will challenge player." ), + false + ); + + add( "MIST_SCALING", "world_default", translate_marker( "Mist scaling." ), + translate_marker( "Determines how fast the mist increases strength." ), + 0, 5, 0 + ); + + add( "MIST_TIME_BETWEEN", "world_default", translate_marker( "Mist time between apperances." ), + translate_marker( "Determines how frequently the mist appears." ), + 1, 50, 7 + ); + + get_option( "MIST_SCALING" ).setPrerequisite( "MIST" ); + get_option( "MIST_TIME_BETWEEN" ).setPrerequisite( "MIST" ); } void options_manager::add_options_android() diff --git a/src/player.cpp b/src/player.cpp index de5a3ed1605ea..69668b1d2155f 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -103,6 +103,7 @@ static const efftype_id effect_earphones( "earphones" ); static const efftype_id effect_fungus( "fungus" ); static const efftype_id effect_grabbed( "grabbed" ); static const efftype_id effect_grabbing( "grabbing" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_infected( "infected" ); static const efftype_id effect_masked_scent( "masked_scent" ); static const efftype_id effect_mending( "mending" ); @@ -2513,6 +2514,9 @@ item::reload_option player::select_ammo( const item &base, bool prompt, bool emp ret_val player::can_wield( const item &it ) const { + if( has_effect( effect_incorporeal ) ) { + return ret_val::make_failure( _( "You can't wield anything while incorporeal." ) ); + } if( it.made_of_from_type( LIQUID ) ) { return ret_val::make_failure( _( "Can't wield spilt liquids." ) ); } diff --git a/src/sounds.cpp b/src/sounds.cpp index 11c5a70393316..467ff3fe940e0 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -48,17 +48,17 @@ #include "weather.h" #if defined(SDL_SOUND) - #if defined(_MSC_VER) && defined(USE_VCPKG) - #include - #else - #include - #endif - #include - #if defined(_WIN32) && !defined(_MSC_VER) - #include "mingw.thread.h" - #endif - - #define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " +#if defined(_MSC_VER) && defined(USE_VCPKG) +#include +#else +#include +#endif +#include +#if defined(_WIN32) && !defined(_MSC_VER) +#include "mingw.thread.h" +#endif + +#define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " #endif weather_type previous_weather; @@ -945,7 +945,9 @@ void sfx::do_ambient() play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, channel::outdoors_snow_env, 1000 ); break; - case WEATHER_MIST: + case WEATHER_LIGHT_MIST: + case WEATHER_MEDIUM_MIST: + case WEATHER_HEAVY_MIST: play_ambient_variant_sound( "environment", "WEATHER_MIST", heard_volume, channel::outdoors_mist, 1000 ); break; diff --git a/src/suffer.cpp b/src/suffer.cpp index f7d161aac34bf..d18c7c5a2627a 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -12,6 +12,7 @@ #include #include +#include "activity_handlers.h" #include "addiction.h" #include "avatar.h" #include "bodypart.h" @@ -88,6 +89,7 @@ static const efftype_id effect_drunk( "drunk" ); static const efftype_id effect_formication( "formication" ); static const efftype_id effect_glowy_led( "glowy_led" ); static const efftype_id effect_hallu( "hallu" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_iodine( "iodine" ); static const efftype_id effect_masked_scent( "masked_scent" ); static const efftype_id effect_mending( "mending" ); @@ -873,7 +875,17 @@ void Character::suffer_from_albinism() } } } +void Character::suffer_item_dropping() +{ + if( has_effect( effect_incorporeal ) ) { + std::vector tmp = inv_dump(); + for( auto i : tmp ) { + put_into_vehicle_or_drop( *this, item_drop_reason::tumbling, { *i } ); + i_rem( i ); + } + } +} void Character::suffer_from_other_mutations() { if( has_trait( trait_SHARKTEETH ) && one_turn_in( 24_hours ) ) { @@ -1460,6 +1472,7 @@ void Character::suffer() } suffer_in_sunlight(); + suffer_item_dropping(); suffer_from_other_mutations(); suffer_from_artifacts(); suffer_from_radiation(); diff --git a/src/weather.cpp b/src/weather.cpp index 15902ee27e9f3..71beedad4be1f 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -464,58 +464,51 @@ void weather_effect::snowstorm() void weather_effect::mist() { if( calendar::once_every( g->weather.mist_spawn_time ) && is_player_outside() ) { - mtype_id monster; - std::string category; - int rand = rng( 1, 3 ); - switch( rand ) { - case 1: - monster = mon_mist_wraith; - category = "mist_summon_wraith"; - break; - case 2: - monster = mon_mist_spectre; - category = "mist_summon_spectre"; - break; - case 3: - monster = mon_mist_phantom; - category = "mist_summon_phantom"; - break; - default: - debugmsg( "HUH?" ); - break; - } - - tripoint target; - bool found_location = false; - int radius = 4; - for( int i = 0; i < 15 && !found_location; i++ ) { - target = g->u.pos() + tripoint( rng( -radius, radius ), rng( -radius, radius ), 0 ); - if( game::can_place_monster( monster, target ) && g->m.is_outside( target ) && - rl_dist( target, g->u.pos() ) > 2 ) { - found_location = true; + for( int monsters_spawned = 0; monsters_spawned < g->weather.mist_intensity / 5; + monsters_spawned++ ) { + mtype_id monster; + std::string category; + int mist_type = std::min( 3, g->weather.mist_intensity / 10 ); + int rand = rng( 1, mist_type ); + switch( rand ) { + case 1: + monster = mon_mist_wraith; + category = "mist_summon_wraith"; + break; + case 2: + monster = mon_mist_spectre; + category = "mist_summon_spectre"; + break; + case 3: + monster = mon_mist_phantom; + category = "mist_summon_phantom"; + break; + default: + debugmsg( "HUH?" ); + break; } - } - - if( found_location && g->place_critter_at( monster, target ) != nullptr ) { - g->u.add_msg_if_player( m_bad, "%s", - SNIPPET.random_from_category( category ).value_or( translation() ) ); - } - } - if( calendar::once_every( g->weather.mist_intensity_increase_time ) ) { - g->weather.mist_intensity++; - if( g->weather.mist_intensity > g->weather.mist_max_intensity ) { - g->weather.mist_intensity = 0; - if( is_player_outside() ) { - g->u.add_msg_if_player( m_good, _( "The mist evaporates like it was never there." ) ); + tripoint target; + bool found_location = false; + int radius = 6 - mist_type; + for( int attempts = 0; attempts < 15; attempts++ ) { + target = g->u.pos() + tripoint( rng( -radius, radius ), rng( -radius, radius ), 0 ); + if( game::can_place_monster( monster, target ) && g->m.is_outside( target ) && + rl_dist( target, g->u.pos() ) > 2 ) { + found_location = true; + break; + } } - } else { - if( is_player_outside() ) { + + if( found_location && g->place_critter_at( monster, target ) != nullptr ) { g->u.add_msg_if_player( m_bad, "%s", - SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); + SNIPPET.random_from_category( category ).value_or( translation() ) ); } } + } + if( calendar::once_every( g->weather.mist_intensity_increase_time ) ) { + g->weather.increase_mist_intensity(); } } /** @@ -1119,4 +1112,32 @@ void weather_manager::clear_temp_cache() temperature_cache.clear(); } +void weather_manager::increase_mist_intensity() +{ + if( !get_option( "MIST_ACTIVE" ) ) { + return; + } + + if( mist_intensity <= mist_min_intensity ) { + mist_intensity = mist_min_intensity; + g->u.add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( "mist_arrives" ).value_or( translation() ) ); + } else if( mist_intensity < mist_max_intensity ) { + mist_intensity++; + if( is_player_outside() ) { + g->u.add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); + } + } else { + mist_intensity = 0; + mist_min_intensity += mist_scaling; + mist_max_intensity += mist_scaling; + if( is_player_outside() ) { + g->u.add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( "mist_leaves" ).value_or( translation() ) ); + g->u.add_msg_if_player( m_good, _( "The mist evaporates like it was never there." ) ); + } + } + set_nextweather( calendar::turn ); +} ///@} diff --git a/src/weather.h b/src/weather.h index 4ccac3052cc92..0ffa697cfda0f 100644 --- a/src/weather.h +++ b/src/weather.h @@ -2,13 +2,14 @@ #ifndef CATA_SRC_WEATHER_H #define CATA_SRC_WEATHER_H +#include "calendar.h" #include "color.h" #include "optional.h" +#include "options.h" #include "pimpl.h" #include "point.h" #include "type_id.h" #include "weather_gen.h" -#include "calendar.h" /** * @name BODYTEMP @@ -55,7 +56,9 @@ enum weather_type : int { WEATHER_FLURRIES, //!< Light snow WEATHER_SNOW, //!< snow glare effects WEATHER_SNOWSTORM, //!< sight penalties - WEATHER_MIST, //!< spawns mist monsters + WEATHER_LIGHT_MIST, //!< spawns mist monsters, sight penalties + WEATHER_MEDIUM_MIST, //!< spawns mist monsters, sight penalties + WEATHER_HEAVY_MIST, //!< spawns mist monsters, sight penalties NUM_WEATHER_TYPES //!< Sentinel value }; @@ -236,6 +239,8 @@ weather_type current_weather( const tripoint &location, int incident_sunlight( weather_type wtype, const time_point &t = calendar::turn ); +void begin_mist(); + class weather_manager { public: @@ -253,7 +258,10 @@ class weather_manager //Mist values int mist_intensity = 0; + int mist_min_intensity = 1; int mist_max_intensity = 10; + int mist_scaling = get_option( "MIST_SCALING" ); + time_duration mist_intensity_increase_time = 10_seconds; time_duration mist_spawn_time = 5_seconds; @@ -271,6 +279,8 @@ class weather_manager // Returns outdoor or indoor temperature of given location (in absolute (@ref map::getabs)) int get_temperature( const tripoint &location ); void clear_temp_cache(); + //increases mist intensity or begins it at min intensity if not started + void increase_mist_intensity(); }; #endif // CATA_SRC_WEATHER_H diff --git a/src/weather_data.cpp b/src/weather_data.cpp index 7e81baf7d57c6..8b297b0befb0a 100644 --- a/src/weather_data.cpp +++ b/src/weather_data.cpp @@ -26,7 +26,9 @@ weather_animation_t get_weather_animation( weather_type const type ) {WEATHER_FLURRIES, weather_animation_t {0.01f, c_white, '.'}}, {WEATHER_SNOW, weather_animation_t {0.02f, c_white, ','}}, {WEATHER_SNOWSTORM, weather_animation_t {0.04f, c_white, '*'}}, - {WEATHER_MIST, weather_animation_t {0.8f, c_dark_gray, '#'}} + {WEATHER_LIGHT_MIST, weather_animation_t {0.4f, c_light_gray, '#'}}, + {WEATHER_MEDIUM_MIST, weather_animation_t {0.6f, c_dark_gray, '#'}}, + {WEATHER_HEAVY_MIST, weather_animation_t {0.8f, c_dark_gray, '#'}} }; const auto it = map.find( type ); @@ -108,7 +110,15 @@ static weather_result weather_data_internal( weather_type const type ) PRECIP_HEAVY, false, false, &weather_effect::snowstorm }, weather_datum { - translate_marker( "Mist" ), c_light_gray, c_dark_gray, '*', 12, 12.4f, -30, 0, true, + translate_marker( "Mist" ), c_light_gray, c_dark_gray, '*', 3, 3.0f, -15, 0, true, + PRECIP_NONE, false, false, &weather_effect::mist + }, + weather_datum { + translate_marker( "Heavy Mist" ), c_light_gray, c_dark_gray, '*', 8, 8.0f, -30, 0, true, + PRECIP_NONE, false, false, &weather_effect::mist + }, + weather_datum { + translate_marker( "Thick and Heavy Mist" ), c_light_gray, c_dark_gray, '*', 12, 12.4f, -50, 0, true, PRECIP_NONE, false, false, &weather_effect::mist } }}; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 05a0c85b1913a..ea7a9e4929b42 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -183,9 +183,14 @@ weather_type weather_generator::get_weather_conditions( const tripoint &location weather_type weather_generator::get_weather_conditions( const w_point &w ) const { - if( g->weather.mist_intensity > 0 ) { - return WEATHER_MIST; + if( g->weather.mist_intensity > 0 && g->weather.mist_intensity <= 10 ) { + return WEATHER_LIGHT_MIST; + } else if( g->weather.mist_intensity > 10 && g->weather.mist_intensity <= 20 ) { + return WEATHER_MEDIUM_MIST; + } else if( g->weather.mist_intensity > 20 ) { + return WEATHER_HEAVY_MIST; } + weather_type r( WEATHER_CLEAR ); if( w.pressure > 1020 && w.humidity < 70 ) { r = WEATHER_SUNNY; From 586cf333214449b6d0486770e0602ab1b6ccee74 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Tue, 26 May 2020 18:45:46 -0400 Subject: [PATCH 07/27] Fix crash on start --- src/options.cpp | 4 ++-- src/weather.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/options.cpp b/src/options.cpp index 6385acbeb099f..37b122835e6a8 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2204,8 +2204,8 @@ void options_manager::add_options_world_default() 1, 50, 7 ); - get_option( "MIST_SCALING" ).setPrerequisite( "MIST" ); - get_option( "MIST_TIME_BETWEEN" ).setPrerequisite( "MIST" ); + get_option( "MIST_SCALING" ).setPrerequisite( "MIST_ACTIVE" ); + get_option( "MIST_TIME_BETWEEN" ).setPrerequisite( "MIST_ACTIVE" ); } void options_manager::add_options_android() diff --git a/src/weather.h b/src/weather.h index 0ffa697cfda0f..6d33514ff8246 100644 --- a/src/weather.h +++ b/src/weather.h @@ -239,8 +239,6 @@ weather_type current_weather( const tripoint &location, int incident_sunlight( weather_type wtype, const time_point &t = calendar::turn ); -void begin_mist(); - class weather_manager { public: From df6c9e95b5ad58a498a5728ef4411daf13bbd7eb Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 27 May 2020 23:31:51 -0400 Subject: [PATCH 08/27] Fixed options, broke up mist into 3 strengths and added hallucinations --- src/animation.cpp | 6 +-- src/debug_menu.cpp | 23 ++++++---- src/game.cpp | 18 ++++++-- src/game.h | 1 + src/options.cpp | 2 +- src/sounds.cpp | 6 +-- src/weather.cpp | 100 ++++++++++++++++++++++++++++++++----------- src/weather.h | 14 +++--- src/weather_data.cpp | 10 ++--- src/weather_gen.cpp | 14 +++--- 10 files changed, 134 insertions(+), 60 deletions(-) diff --git a/src/animation.cpp b/src/animation.cpp index d485836990c08..2997ea7b47a88 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -705,9 +705,9 @@ void game::draw_weather( const weather_printable &w ) case WEATHER_SNOWSTORM: weather_name = weather_snowflake; break; - case WEATHER_LIGHT_MIST: - case WEATHER_MEDIUM_MIST: - case WEATHER_HEAVY_MIST: + case WEATHER_MIST: + case WEATHER_THICK_MIST: + case WEATHER_STIFLING_MIST: weather_name = weather_mist; break; default: diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index d7e9f6f61318b..baec79262ff86 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1414,51 +1414,58 @@ void debug() smenu.addentry( 1, true, 'm', "%s: %d", _( "Min Intensity" ), g->weather.mist_min_intensity ); smenu.addentry( 2, true, 'x', "%s: %d", _( "Max Intensity" ), g->weather.mist_max_intensity ); smenu.addentry( 3, true, 's', "%s: %d", _( "Mist Scaling" ), g->weather.mist_scaling ); - smenu.addentry( 4, true, 't', "%s: %s", _( "Intensity Increase Time" ), + smenu.addentry( 4, true, 't', "%s: %d", _( "Intensity Increase Time" ), to_seconds( g->weather.mist_intensity_increase_time ) ); - smenu.addentry( 5, true, 'w', "%s: %s", _( "Spawn Time" ), + smenu.addentry( 5, true, 'w', "%s: %d", _( "Spawn Time" ), to_seconds( g->weather.mist_spawn_time ) ); + smenu.addentry( 6, true, 'w', "%s: %s", _( "Next Instance" ), + to_string( g->weather.mist_next_instance ) ); smenu.query(); int value; switch( smenu.ret ) { case 0: - if( query_int( value, _( "Set Intensity to? Currently: %d" ), g->weather.mist_intensity ) ) { + if( query_int( value, _( "Set intensity to? Currently: %d" ), g->weather.mist_intensity ) ) { g->weather.mist_intensity = value; } break; case 1: - if( query_int( value, _( "Set Min Intensity to? Currently: %d" ), + if( query_int( value, _( "Set min intensity to? Currently: %d" ), g->weather.mist_min_intensity ) ) { g->weather.mist_min_intensity = value; } break; case 2: - if( query_int( value, _( "Set Max Intensity to? Currently: %d" ), + if( query_int( value, _( "Set max intensity to? Currently: %d" ), g->weather.mist_max_intensity ) ) { g->weather.mist_max_intensity = value; } break; case 3: - if( query_int( value, _( "Set Mist Scaling to? Currently: %d" ), g->weather.mist_scaling ) ) { + if( query_int( value, _( "Set mist scaling to? Currently: %d" ), g->weather.mist_scaling ) ) { g->weather.mist_scaling = value; } break; case 4: - if( query_int( value, _( "Set Intensity Increase Time to? Currently: %d" ), + if( query_int( value, _( "Set intensity increase time to? Currently: %d" ), to_seconds( g->weather.mist_intensity_increase_time ) ) ) { g->weather.mist_intensity_increase_time = time_duration::from_seconds( value ); } break; case 5: - if( query_int( value, _( "Set Spawn Time to? Currently: %d" ), + if( query_int( value, _( "Set spawn time to? Currently: %d" ), to_seconds( g->weather.mist_spawn_time ) ) ) { g->weather.mist_spawn_time = time_duration::from_seconds( value ); } + case 6: + if( query_int( value, _( "Set next instance to how many minutes in future? Currently: %s" ), + to_string( g->weather.mist_next_instance - calendar::turn ) ) ) { + g->weather.mist_next_instance = calendar::turn + time_duration::from_minutes( value ); + } default: break; } diff --git a/src/game.cpp b/src/game.cpp index 93e0ab6587b09..898d959d22c7d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -701,7 +701,7 @@ bool game::start_game() seed = rng_bits(); new_game = true; start_calendar(); - weather.nextweather = calendar::turn; + safe_mode = ( get_option( "SAFEMODE" ) ? SAFE_MODE_ON : SAFE_MODE_OFF ); mostseen = 0; // ...and mostseen is 0, we haven't seen any monsters yet. get_safemode().load_global(); @@ -751,8 +751,9 @@ bool game::start_game() u.moves = 0; u.process_turn(); // process_turn adds the initial move points u.set_stamina( u.get_stamina_max() ); - weather.temperature = SPRING_TEMPERATURE; - weather.update_weather(); + + weather.initialize(); + u.next_climate_control_check = calendar::before_time_starts; // Force recheck at startup u.last_climate_control_ret = false; @@ -4930,7 +4931,16 @@ bool game::spawn_hallucination( const tripoint &p ) } } - const mtype_id &mt = MonsterGenerator::generator().get_valid_hallucination(); + return spawn_hallucination( p, MonsterGenerator::generator().get_valid_hallucination() ); +} +/** + * Attempts to spawn a hallucination at given location. + * Returns false if the hallucination couldn't be spawned for whatever reason, such as + * a monster already in the target square. + * @return Whether or not a hallucination was successfully spawned. + */ +bool game::spawn_hallucination( const tripoint &p, mtype_id &mt ) +{ const shared_ptr_fast phantasm = make_shared_fast( mt ); phantasm->hallucination = true; phantasm->spawn( p ); diff --git a/src/game.h b/src/game.h index 75a554e51bf21..736f04881dcb5 100644 --- a/src/game.h +++ b/src/game.h @@ -336,6 +336,7 @@ class game void clear_zombies(); /** Spawns a hallucination at a determined position. */ bool spawn_hallucination( const tripoint &p ); + bool spawn_hallucination( const tripoint &p, mtype_id &mt ); /** Swaps positions of two creatures */ bool swap_critters( Creature &, Creature & ); diff --git a/src/options.cpp b/src/options.cpp index 37b122835e6a8..959c4f33bfbd7 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2196,7 +2196,7 @@ void options_manager::add_options_world_default() add( "MIST_SCALING", "world_default", translate_marker( "Mist scaling." ), translate_marker( "Determines how fast the mist increases strength." ), - 0, 5, 0 + 0, 5, 1 ); add( "MIST_TIME_BETWEEN", "world_default", translate_marker( "Mist time between apperances." ), diff --git a/src/sounds.cpp b/src/sounds.cpp index 467ff3fe940e0..1c89b6ebcc5c1 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -945,9 +945,9 @@ void sfx::do_ambient() play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, channel::outdoors_snow_env, 1000 ); break; - case WEATHER_LIGHT_MIST: - case WEATHER_MEDIUM_MIST: - case WEATHER_HEAVY_MIST: + case WEATHER_MIST: + case WEATHER_THICK_MIST: + case WEATHER_STIFLING_MIST: play_ambient_variant_sound( "environment", "WEATHER_MIST", heard_volume, channel::outdoors_mist, 1000 ); break; diff --git a/src/weather.cpp b/src/weather.cpp index 71beedad4be1f..ac69824374c9c 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -11,6 +11,7 @@ #include "bodypart.h" #include "calendar.h" #include "cata_utility.h" +#include "character.h" #include "colony.h" #include "coordinate_conversions.h" #include "enums.h" @@ -22,6 +23,7 @@ #include "map.h" #include "math_defines.h" #include "messages.h" +//#include "monster.h" #include "options.h" #include "overmap.h" #include "overmapbuffer.h" @@ -50,6 +52,9 @@ static const mtype_id mon_mist_phantom( "mon_mist_phantom" ); static const trait_id trait_CEPH_VISION( "CEPH_VISION" ); static const trait_id trait_FEATHERS( "FEATHERS" ); +static const species_id species_MIST( "MIST" ); +static const species_id species_HUMAN( "HUMAN" ); + static const std::string flag_SUN_GLASSES( "SUN_GLASSES" ); /** @@ -57,9 +62,9 @@ static const std::string flag_SUN_GLASSES( "SUN_GLASSES" ); * @{ */ -static bool is_player_outside() +static bool is_creature_outside( const Creature &target ) { - return g->m.is_outside( point( g->u.posx(), g->u.posy() ) ) && g->get_levz() >= 0; + return g->m.is_outside( point( target.posx(), target.posy() ) ) && g->get_levz() >= 0; } #define THUNDER_CHANCE 50 @@ -73,7 +78,7 @@ static bool is_player_outside() void weather_effect::glare( sun_intensity intensity ) { //General prepequisites for glare - if( !is_player_outside() || !g->is_in_sunlight( g->u.pos() ) || g->u.in_sleep_state() || + if( !is_creature_outside( g->u ) || !g->is_in_sunlight( g->u.pos() ) || g->u.in_sleep_state() || g->u.worn_with_flag( flag_SUN_GLASSES ) || g->u.has_bionic( bio_sunglasses ) || g->u.is_blind() ) { @@ -379,7 +384,7 @@ static void fill_water_collectors( int mmPerHour, bool acid ) */ static void wet_player( int amount ) { - if( !is_player_outside() || + if( !is_creature_outside( g->u ) || g->u.has_trait( trait_FEATHERS ) || g->u.weapon.has_flag( "RAIN_PROTECT" ) || ( !one_in( 50 ) && g->u.worn_with_flag( "RAINPROOF" ) ) ) { @@ -463,44 +468,69 @@ void weather_effect::snowstorm() void weather_effect::mist() { - if( calendar::once_every( g->weather.mist_spawn_time ) && is_player_outside() ) { - for( int monsters_spawned = 0; monsters_spawned < g->weather.mist_intensity / 5; - monsters_spawned++ ) { - mtype_id monster; + Character &target_character = g->u;//todo npcs, also + if( calendar::once_every( g->weather.mist_spawn_time ) && + is_creature_outside( target_character ) ) { + int monsters_to_spawn = std::max( 1, g->weather.mist_intensity / 5 ); + for( int monsters_spawned = 0; monsters_spawned < monsters_to_spawn; monsters_spawned++ ) { + mtype_id monster_id; std::string category; + bool is_hallucination = false; int mist_type = std::min( 3, g->weather.mist_intensity / 10 ); - int rand = rng( 1, mist_type ); + int rand = ( 1, 4 ); switch( rand ) { case 1: - monster = mon_mist_wraith; + monster_id = mon_mist_wraith; category = "mist_summon_wraith"; break; case 2: - monster = mon_mist_spectre; + monster_id = mon_mist_spectre; category = "mist_summon_spectre"; break; case 3: - monster = mon_mist_phantom; + monster_id = mon_mist_phantom; category = "mist_summon_phantom"; break; + case 4: { + Creature *copy = g->get_creature_if( [&target_character]( const Creature & critter ) -> bool { + bool in_mist = is_creature_outside( critter ); + bool not_self = target_character.pos() != critter.pos(); + bool in_range = std::round( rl_dist_exact( target_character.pos(), critter.pos() ) ) <= 30; + bool valid_species = !critter.in_species( species_MIST ); + bool valid_target = target_character.attitude_to( critter ) == Creature::Attitude::A_HOSTILE; + + return in_mist && not_self && in_range && valid_species && valid_target; + } ); + monster *copy_monster = dynamic_cast( copy ); + if( copy_monster != nullptr ) { + monster_id = copy_monster->type->id; + is_hallucination = true; + } else { + monster_id = mon_mist_wraith; + category = "mist_summon_wraith"; + } + break; + } default: debugmsg( "HUH?" ); break; } - tripoint target; + tripoint target_point; bool found_location = false; int radius = 6 - mist_type; for( int attempts = 0; attempts < 15; attempts++ ) { - target = g->u.pos() + tripoint( rng( -radius, radius ), rng( -radius, radius ), 0 ); - if( game::can_place_monster( monster, target ) && g->m.is_outside( target ) && - rl_dist( target, g->u.pos() ) > 2 ) { + target_point = g->u.pos() + tripoint( rng( -radius, radius ), rng( -radius, radius ), 0 ); + if( game::can_place_monster( monster_id, target_point ) && g->m.is_outside( target_point ) && + rl_dist( target_point, g->u.pos() ) > 2 ) { found_location = true; break; } } - - if( found_location && g->place_critter_at( monster, target ) != nullptr ) { + if( found_location && is_hallucination ) { + g->u.add_msg_if_player( m_bad, "Hallucinate!" ); + g->spawn_hallucination( target_point, monster_id ); + } else if( found_location && g->place_critter_at( monster_id, target_point ) != nullptr ) { g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( category ).value_or( translation() ) ); } @@ -558,7 +588,7 @@ void weather_effect::lightning() */ void weather_effect::light_acid() { - if( calendar::once_every( 1_minutes ) && is_player_outside() ) { + if( calendar::once_every( 1_minutes ) && is_creature_outside( g->u ) ) { 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 { @@ -585,7 +615,7 @@ void weather_effect::light_acid() */ void weather_effect::acid() { - if( calendar::once_every( 2_turns ) && is_player_outside() ) { + if( calendar::once_every( 2_turns ) && is_creature_outside( g->u ) ) { if( g->u.weapon.has_flag( "RAIN_PROTECT" ) && one_in( 4 ) ) { add_msg( _( "Your umbrella protects you from the acid rain." ) ); } else { @@ -1027,6 +1057,15 @@ weather_manager::weather_manager() weather = WEATHER_CLEAR; } +void weather_manager::initialize() +{ + nextweather = calendar::turn; + set_next_mist_time(); + mist_scaling = get_option( "MIST_SCALING" ); + temperature = SPRING_TEMPERATURE; + update_weather(); +} + const weather_generator &weather_manager::get_cur_weather_gen() const { const overmap &om = g->get_cur_om(); @@ -1036,6 +1075,11 @@ const weather_generator &weather_manager::get_cur_weather_gen() const void weather_manager::update_weather() { + if( calendar::turn > mist_next_instance ) { + increase_mist_intensity(); + set_next_mist_time(); + } + w_point &w = *weather_precise; winddirection = wind_direction_override ? *wind_direction_override : w.winddirection; windspeed = windspeed_override ? *windspeed_override : w.windpower; @@ -1112,19 +1156,26 @@ void weather_manager::clear_temp_cache() temperature_cache.clear(); } +void weather_manager::set_next_mist_time() +{ + int days = get_option( "MIST_TIME_BETWEEN" ); + mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, + 1.5 * days ) ) + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); +} + void weather_manager::increase_mist_intensity() { if( !get_option( "MIST_ACTIVE" ) ) { return; } - if( mist_intensity <= mist_min_intensity ) { + if( mist_intensity < mist_min_intensity ) { mist_intensity = mist_min_intensity; g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( "mist_arrives" ).value_or( translation() ) ); } else if( mist_intensity < mist_max_intensity ) { mist_intensity++; - if( is_player_outside() ) { + if( is_creature_outside( g->u ) ) { g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( "mist_increase_intensity" ).value_or( translation() ) ); } @@ -1132,12 +1183,11 @@ void weather_manager::increase_mist_intensity() mist_intensity = 0; mist_min_intensity += mist_scaling; mist_max_intensity += mist_scaling; - if( is_player_outside() ) { + if( is_creature_outside( g->u ) ) { g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( "mist_leaves" ).value_or( translation() ) ); - g->u.add_msg_if_player( m_good, _( "The mist evaporates like it was never there." ) ); } } - set_nextweather( calendar::turn ); + nextweather = calendar::turn; } ///@} diff --git a/src/weather.h b/src/weather.h index 6d33514ff8246..28980df7fb5db 100644 --- a/src/weather.h +++ b/src/weather.h @@ -56,9 +56,9 @@ enum weather_type : int { WEATHER_FLURRIES, //!< Light snow WEATHER_SNOW, //!< snow glare effects WEATHER_SNOWSTORM, //!< sight penalties - WEATHER_LIGHT_MIST, //!< spawns mist monsters, sight penalties - WEATHER_MEDIUM_MIST, //!< spawns mist monsters, sight penalties - WEATHER_HEAVY_MIST, //!< spawns mist monsters, sight penalties + WEATHER_MIST, //!< spawns mist monsters, sight penalties + WEATHER_THICK_MIST, //!< spawns mist monsters, sight penalties + WEATHER_STIFLING_MIST, //!< spawns mist monsters, sight penalties NUM_WEATHER_TYPES //!< Sentinel value }; @@ -243,6 +243,7 @@ class weather_manager { public: weather_manager(); + void initialize(); const weather_generator &get_cur_weather_gen() const; // Updates the temperature and weather patten void update_weather(); @@ -258,10 +259,12 @@ class weather_manager int mist_intensity = 0; int mist_min_intensity = 1; int mist_max_intensity = 10; - int mist_scaling = get_option( "MIST_SCALING" ); - + int mist_scaling = 1; + time_point mist_next_instance = calendar::turn; time_duration mist_intensity_increase_time = 10_seconds; time_duration mist_spawn_time = 5_seconds; + int mist_thick_threshold = 10; + int mist_stifling_threshold = 20; // Cached weather data pimpl weather_precise; @@ -277,6 +280,7 @@ class weather_manager // Returns outdoor or indoor temperature of given location (in absolute (@ref map::getabs)) int get_temperature( const tripoint &location ); void clear_temp_cache(); + void set_next_mist_time(); //increases mist intensity or begins it at min intensity if not started void increase_mist_intensity(); }; diff --git a/src/weather_data.cpp b/src/weather_data.cpp index 8b297b0befb0a..32a9cf7e3b9d0 100644 --- a/src/weather_data.cpp +++ b/src/weather_data.cpp @@ -26,9 +26,9 @@ weather_animation_t get_weather_animation( weather_type const type ) {WEATHER_FLURRIES, weather_animation_t {0.01f, c_white, '.'}}, {WEATHER_SNOW, weather_animation_t {0.02f, c_white, ','}}, {WEATHER_SNOWSTORM, weather_animation_t {0.04f, c_white, '*'}}, - {WEATHER_LIGHT_MIST, weather_animation_t {0.4f, c_light_gray, '#'}}, - {WEATHER_MEDIUM_MIST, weather_animation_t {0.6f, c_dark_gray, '#'}}, - {WEATHER_HEAVY_MIST, weather_animation_t {0.8f, c_dark_gray, '#'}} + {WEATHER_MIST, weather_animation_t {0.4f, c_light_gray, '#'}}, + {WEATHER_THICK_MIST, weather_animation_t {0.6f, c_dark_gray, '#'}}, + {WEATHER_STIFLING_MIST, weather_animation_t {0.8f, c_dark_gray, '#'}} }; const auto it = map.find( type ); @@ -114,11 +114,11 @@ static weather_result weather_data_internal( weather_type const type ) PRECIP_NONE, false, false, &weather_effect::mist }, weather_datum { - translate_marker( "Heavy Mist" ), c_light_gray, c_dark_gray, '*', 8, 8.0f, -30, 0, true, + translate_marker( "Thick Mist" ), c_light_gray, c_dark_gray, '*', 8, 8.0f, -30, 0, true, PRECIP_NONE, false, false, &weather_effect::mist }, weather_datum { - translate_marker( "Thick and Heavy Mist" ), c_light_gray, c_dark_gray, '*', 12, 12.4f, -50, 0, true, + translate_marker( "Stifling Mist" ), c_light_gray, c_dark_gray, '*', 12, 12.4f, -50, 0, true, PRECIP_NONE, false, false, &weather_effect::mist } }}; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index ea7a9e4929b42..7c8c7cca74595 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -183,12 +183,14 @@ weather_type weather_generator::get_weather_conditions( const tripoint &location weather_type weather_generator::get_weather_conditions( const w_point &w ) const { - if( g->weather.mist_intensity > 0 && g->weather.mist_intensity <= 10 ) { - return WEATHER_LIGHT_MIST; - } else if( g->weather.mist_intensity > 10 && g->weather.mist_intensity <= 20 ) { - return WEATHER_MEDIUM_MIST; - } else if( g->weather.mist_intensity > 20 ) { - return WEATHER_HEAVY_MIST; + if( g->weather.mist_intensity > 0 && + g->weather.mist_intensity <= g->weather.mist_thick_threshold ) { + return WEATHER_MIST; + } else if( g->weather.mist_intensity > g->weather.mist_thick_threshold && + g->weather.mist_intensity <= g->weather.mist_stifling_threshold ) { + return WEATHER_THICK_MIST; + } else if( g->weather.mist_intensity > g->weather.mist_stifling_threshold ) { + return WEATHER_STIFLING_MIST; } weather_type r( WEATHER_CLEAR ); From ca41221ede920bb9513806a1952fc96ebd2365f5 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Mon, 1 Jun 2020 22:38:29 -0400 Subject: [PATCH 09/27] Touch ups --- data/json/monsters/mist.json | 6 +-- src/avatar_action.cpp | 3 ++ src/character.cpp | 9 ++-- src/debug_menu.cpp | 30 ++++-------- src/handle_action.cpp | 29 ++++++++++++ src/iexamine.cpp | 7 +++ src/melee.cpp | 5 ++ src/monattack.cpp | 16 ++----- src/options.cpp | 20 ++++++-- src/player.cpp | 3 +- src/savegame.cpp | 14 ++++++ src/suffer.cpp | 11 +++-- src/weather.cpp | 89 ++++++++++++++++++++++++------------ src/weather.h | 24 +++++++--- src/weather_gen.cpp | 19 ++++---- 15 files changed, 193 insertions(+), 92 deletions(-) diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index 7260260e1090e..05c59daae9382 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -9,7 +9,7 @@ "volume": "62500 ml", "weight": "0 g", "hp": 1, - "speed": 70, + "speed": 110, "symbol": "X", "color": "white", "aggression": 75, @@ -30,7 +30,7 @@ "volume": "62500 ml", "weight": "0 g", "hp": 1, - "speed": 70, + "speed": 110, "symbol": "U", "color": "white", "aggression": 100, @@ -51,7 +51,7 @@ "volume": "62500 ml", "weight": "0 g", "hp": 1, - "speed": 70, + "speed": 110, "symbol": "W", "color": "white", "aggression": 100, diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 6397cb72917b8..c635443d37648 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -1090,6 +1090,9 @@ void avatar_action::plthrow( avatar &you, item_location loc, if( you.has_active_mutation( trait_SHELL2 ) ) { add_msg( m_info, _( "You can't effectively throw while you're in your shell." ) ); return; + } else if( you.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); + return; } if( you.is_mounted() ) { monster *mons = g->u.mounted_creature.get(); diff --git a/src/character.cpp b/src/character.cpp index 8c6abbc37de22..05ad6aac6662d 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -6242,7 +6242,7 @@ nc_color Character::symbol_color() const bool Character::is_immune_field( const field_type_id &fid ) const { // Obviously this makes us invincible - if( has_trait( trait_DEBUG_NODMG ) ) { + if( has_trait( trait_DEBUG_NODMG ) || has_effect( effect_incorporeal ) ) { return true; } // Check to see if we are immune @@ -8481,7 +8481,7 @@ void Character::on_hit( Creature *source, bodypart_id /*bp_hit*/, */ void Character::apply_damage( Creature *source, bodypart_id hurt, int dam, const bool bypass_med ) { - if( is_dead_state() || has_trait( trait_DEBUG_NODMG ) ) { + if( is_dead_state() || has_trait( trait_DEBUG_NODMG ) || has_effect( effect_incorporeal ) ) { // don't do any more damage if we're already dead // Or if we're debugging and don't want to die return; @@ -8533,7 +8533,7 @@ void Character::apply_damage( Creature *source, bodypart_id hurt, int dam, const dealt_damage_instance Character::deal_damage( Creature *source, bodypart_id bp, const damage_instance &d ) { - if( has_trait( trait_DEBUG_NODMG ) ) { + if( has_trait( trait_DEBUG_NODMG ) || has_effect( effect_incorporeal ) ) { return dealt_damage_instance(); } @@ -8778,7 +8778,8 @@ void Character::healall( int dam ) void Character::hurtall( int dam, Creature *source, bool disturb /*= true*/ ) { - if( is_dead_state() || has_trait( trait_DEBUG_NODMG ) || dam <= 0 ) { + if( is_dead_state() || has_trait( trait_DEBUG_NODMG ) || has_effect( effect_incorporeal ) || + dam <= 0 ) { return; } diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index baec79262ff86..08debd2b1e653 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1411,8 +1411,7 @@ void debug() case DEBUG_MIST: { uilist smenu; smenu.addentry( 0, true, 'i', "%s: %d", _( "Intensity" ), g->weather.mist_intensity ); - smenu.addentry( 1, true, 'm', "%s: %d", _( "Min Intensity" ), g->weather.mist_min_intensity ); - smenu.addentry( 2, true, 'x', "%s: %d", _( "Max Intensity" ), g->weather.mist_max_intensity ); + smenu.addentry( 1, true, 'm', "%s: %d", _( "Mist Instances" ), g->weather.mist_instances ); smenu.addentry( 3, true, 's', "%s: %d", _( "Mist Scaling" ), g->weather.mist_scaling ); smenu.addentry( 4, true, 't', "%s: %d", _( "Intensity Increase Time" ), to_seconds( g->weather.mist_intensity_increase_time ) ); @@ -1429,40 +1428,31 @@ void debug() g->weather.mist_intensity = value; } break; - case 1: - if( query_int( value, _( "Set min intensity to? Currently: %d" ), - g->weather.mist_min_intensity ) ) { - g->weather.mist_min_intensity = value; - } - break; - - case 2: - if( query_int( value, _( "Set max intensity to? Currently: %d" ), - g->weather.mist_max_intensity ) ) { - g->weather.mist_max_intensity = value; + if( query_int( value, _( "Set mist instances to? Currently: %d" ), + g->weather.mist_instances ) ) { + g->weather.mist_instances = value; } break; - case 3: if( query_int( value, _( "Set mist scaling to? Currently: %d" ), g->weather.mist_scaling ) ) { g->weather.mist_scaling = value; } break; - case 4: - if( query_int( value, _( "Set intensity increase time to? Currently: %d" ), - to_seconds( g->weather.mist_intensity_increase_time ) ) ) { + if( query_int( value, _( "Set intensity increase time to how many seconds? Currently: %d" ), + to_string( g->weather.mist_intensity_increase_time ) ) ) { g->weather.mist_intensity_increase_time = time_duration::from_seconds( value ); } break; case 5: - if( query_int( value, _( "Set spawn time to? Currently: %d" ), - to_seconds( g->weather.mist_spawn_time ) ) ) { + if( query_int( value, _( "Set spawn time to how many seconds? Currently: %d" ), + to_string( g->weather.mist_spawn_time ) ) ) { g->weather.mist_spawn_time = time_duration::from_seconds( value ); } + break; case 6: - if( query_int( value, _( "Set next instance to how many minutes in future? Currently: %s" ), + if( query_int( value, _( "Set next instance to minutes in future? Currently: %s" ), to_string( g->weather.mist_next_instance - calendar::turn ) ) ) { g->weather.mist_next_instance = calendar::turn + time_duration::from_minutes( value ); } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index e90c8bb94d384..1f34a7eca2eeb 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -93,6 +93,7 @@ static const activity_id ACT_WAIT_STAMINA( "ACT_WAIT_STAMINA" ); static const activity_id ACT_WAIT_WEATHER( "ACT_WAIT_WEATHER" ); static const efftype_id effect_alarm_clock( "alarm_clock" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_laserlocked( "laserlocked" ); static const efftype_id effect_relax_gas( "relax_gas" ); @@ -1828,6 +1829,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't open things while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't open things while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { open(); } @@ -1841,6 +1844,8 @@ bool game::handle_action() if( !mon->has_flag( MF_RIDEABLE_MECH ) ) { add_msg( m_info, _( "You can't close things while you're riding." ) ); } + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else if( mouse_target ) { doors::close_door( m, u, *mouse_target ); } else { @@ -1853,6 +1858,8 @@ bool game::handle_action() handbrake(); } else if( u.has_active_mutation( trait_SHELL2 ) ) { add_msg( m_info, _( "You can't smash things while you're in your shell." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { smash(); } @@ -1873,6 +1880,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't move mass quantities while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't move mass quantities while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { create_advanced_inv(); } @@ -1883,6 +1892,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't pick anything up while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else if( mouse_target ) { pickup( *mouse_target ); } else { @@ -1893,6 +1904,8 @@ bool game::handle_action() case ACTION_PICKUP_FEET: if( u.has_active_mutation( trait_SHELL2 ) ) { add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { pickup_feet(); } @@ -1913,6 +1926,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't haul things while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't haul things while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { haul(); } @@ -1923,6 +1938,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't butcher while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't butcher while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { butcher(); } @@ -2104,6 +2121,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't craft while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't craft while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { u.craft(); } @@ -2114,6 +2133,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't craft while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't craft while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { u.recraft(); } @@ -2124,6 +2145,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't craft while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't craft while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { u.long_craft(); } @@ -2134,6 +2157,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't disassemble items while driving." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't disassemble items while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { u.disassemble(); refresh_all(); @@ -2147,6 +2172,8 @@ bool game::handle_action() add_msg( m_info, _( "You can't construct while you're in your shell." ) ); } else if( u.is_mounted() ) { add_msg( m_info, _( "You can't construct while you're riding." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { construction_menu( false ); } @@ -2169,6 +2196,8 @@ bool game::handle_action() u.dismount(); } else if( u.has_trait( trait_WAYFARER ) ) { add_msg( m_info, _( "You refuse to take control of this vehicle." ) ); + } else if( u.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { control_vehicle(); } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 61ab6b01939f2..fe3af418e337a 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -101,6 +101,7 @@ static const activity_id ACT_FORAGE( "ACT_FORAGE" ); static const activity_id ACT_PLANT_SEED( "ACT_PLANT_SEED" ); static const efftype_id effect_earphones( "earphones" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_mending( "mending" ); static const efftype_id effect_pkill2( "pkill2" ); static const efftype_id effect_sleep( "sleep" ); @@ -5649,6 +5650,8 @@ void iexamine::workbench_internal( player &p, const tripoint &examp, case start_craft: { if( p.has_active_mutation( trait_SHELL2 ) ) { p.add_msg_if_player( m_info, _( "You can't craft while you're in your shell." ) ); + } else if( p.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { p.craft( examp ); } @@ -5657,6 +5660,8 @@ void iexamine::workbench_internal( player &p, const tripoint &examp, case repeat_craft: { if( p.has_active_mutation( trait_SHELL2 ) ) { p.add_msg_if_player( m_info, _( "You can't craft while you're in your shell." ) ); + } else if( p.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { p.recraft( examp ); } @@ -5665,6 +5670,8 @@ void iexamine::workbench_internal( player &p, const tripoint &examp, case start_long_craft: { if( p.has_active_mutation( trait_SHELL2 ) ) { p.add_msg_if_player( m_info, _( "You can't craft while you're in your shell." ) ); + } else if( p.has_effect( effect_incorporeal ) ) { + add_msg( m_info, _( "You lack the substance to affect anything." ) ); } else { p.long_craft( examp ); } diff --git a/src/melee.cpp b/src/melee.cpp index 547e9fcd76ea8..bde200970562a 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -86,6 +86,7 @@ static const efftype_id effect_grabbed( "grabbed" ); static const efftype_id effect_grabbing( "grabbing" ); static const efftype_id effect_heavysnare( "heavysnare" ); static const efftype_id effect_hit_by_player( "hit_by_player" ); +static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_lightsnare( "lightsnare" ); static const efftype_id effect_narcosis( "narcosis" ); static const efftype_id effect_poison( "poison" ); @@ -388,7 +389,11 @@ void Character::melee_attack( Creature &t, bool allow_special ) void Character::melee_attack( Creature &t, bool allow_special, const matec_id &force_technique, bool allow_unarmed ) { + if( has_effect( effect_incorporeal ) ) { + add_msg_if_player( m_info, _( "You lack the substance to affect anything." ) ); + } melee::melee_stats.attack_count += 1; + int hit_spread = t.deal_melee_attack( this, hit_roll() ); if( !t.is_player() ) { // TODO: Per-NPC tracking? Right now monster hit by either npc or player will draw aggro... diff --git a/src/monattack.cpp b/src/monattack.cpp index 3d6d89cf26838..e223d63a59504 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -5810,13 +5810,11 @@ bool mattack::dissipate_drain( monster *z ) if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } - + z->die( z ); foe->mod_fatigue( 100 ); foe->mod_stamina( -200 ); foe->add_msg_if_player( m_bad, _( "The %s takes a little of your strength." ), z->name() ); - - z->die( z ); return true; } @@ -5826,12 +5824,11 @@ bool mattack::dissipate_nightmares( monster *z ) if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } + z->die( z ); foe->add_effect( effect_disrupted_sleep, 12_hours ); foe->add_effect( effect_nightmares, 12_hours ); foe->add_msg_if_player( m_bad, _( "The %s leaves an unsettling feeling behind." ), z->name() ); - - z->die( z ); return true; } @@ -5841,7 +5838,7 @@ bool mattack::dissipate_force_scream( monster *z ) if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } - + z->die( z ); foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, 1_hours ); foe->add_msg_if_player( m_bad, _( "The %s surfaces an intense memory, that feels like your own." ), @@ -5851,8 +5848,6 @@ bool mattack::dissipate_force_scream( monster *z ) foe->add_msg_if_player( m_info, "You hear yourself scream \"%s\"", shout_message ); foe->shout( shout_message ); - z->die( z ); - return true; } @@ -5862,11 +5857,10 @@ bool mattack::dissipate_incorporeal( monster *z ) if( foe == nullptr || !is_adjacent( z, foe, false ) ) { return false; } + z->die( z ); foe->add_effect( effect_incorporeal, 3_seconds ); foe->add_msg_if_player( m_bad, - _( "The %s robs you of your form briefly." ), z->name() ); - - z->die( z ); + _( "The %s robs you of your form." ), z->name() ); return true; } diff --git a/src/options.cpp b/src/options.cpp index 959c4f33bfbd7..727b88a42f499 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2196,16 +2196,28 @@ void options_manager::add_options_world_default() add( "MIST_SCALING", "world_default", translate_marker( "Mist scaling." ), translate_marker( "Determines how fast the mist increases strength." ), - 0, 5, 1 + 0.0, 10.0, 1.0, 0.1 ); - add( "MIST_TIME_BETWEEN", "world_default", translate_marker( "Mist time between apperances." ), - translate_marker( "Determines how frequently the mist appears." ), + add( "MIST_INSTANCE_TIME", "world_default", translate_marker( "Mist time between apperances." ), + translate_marker( "Average number of days between mist apperances." ), 1, 50, 7 ); + add( "MIST_SPAWN_TIME", "world_default", translate_marker( "Mist time between spawns." ), + translate_marker( "Average number of seconds between mist spawns." ), + 1, 3600, 60 + ); + + add( "MIST_LENGTH", "world_default", translate_marker( "Length mist appears for." ), + translate_marker( "Average number of hours mist lasts." ), + 1, 50, 5 + ); + get_option( "MIST_SCALING" ).setPrerequisite( "MIST_ACTIVE" ); - get_option( "MIST_TIME_BETWEEN" ).setPrerequisite( "MIST_ACTIVE" ); + get_option( "MIST_INSTANCE_TIME" ).setPrerequisite( "MIST_ACTIVE" ); + get_option( "MIST_LENGTH" ).setPrerequisite( "MIST_ACTIVE" ); + get_option( "MIST_SPAWN_TIME" ).setPrerequisite( "MIST_ACTIVE" ); } void options_manager::add_options_android() diff --git a/src/player.cpp b/src/player.cpp index 69668b1d2155f..6ed48e516395a 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1087,7 +1087,8 @@ int player::get_num_crafting_helpers( int max ) const bool player::immune_to( const bodypart_id &bp, damage_unit dam ) const { - if( has_trait( trait_DEBUG_NODMG ) || is_immune_damage( dam.type ) ) { + if( has_trait( trait_DEBUG_NODMG ) || is_immune_damage( dam.type ) || + has_effect( effect_incorporeal ) ) { return true; } diff --git a/src/savegame.cpp b/src/savegame.cpp index 7d8379d11c98d..c0f57213ba3a7 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -1656,6 +1656,13 @@ void game::unserialize_master( std::istream &fin ) } else if( name == "weather" ) { JsonObject w = jsin.get_object(); w.read( "lightning", weather.lightning_active ); + w.read( "mist_intensity", weather.mist_intensity ); + w.read( "mist_intensity_increase_per_instance", weather.mist_intensity_increase_per_instance ); + w.read( "mist_instances", weather.mist_instances ); + w.read( "mist_next_instance", weather.mist_next_instance ); + w.read( "mist_intensity_increase_time", weather.mist_intensity_increase_time ); + w.read( "mist_thick_threshold", weather.mist_thick_threshold ); + w.read( "mist_stifling_threshold", weather.mist_stifling_threshold ); } else { // silently ignore anything else jsin.skip_value(); @@ -1694,6 +1701,13 @@ void game::serialize_master( std::ostream &fout ) json.member( "weather" ); json.start_object(); json.member( "lightning", weather.lightning_active ); + json.member( "mist_intensity", weather.mist_intensity ); + json.member( "mist_intensity_increase_per_instance", weather.mist_intensity_increase_per_instance ); + json.member( "mist_instances", weather.mist_instances ); + json.member( "mist_next_instance", weather.mist_next_instance ); + json.member( "mist_intensity_increase_time", weather.mist_intensity_increase_time ); + json.member( "mist_thick_threshold", weather.mist_thick_threshold ); + json.member( "mist_stifling_threshold", weather.mist_stifling_threshold ); json.end_object(); json.end_object(); diff --git a/src/suffer.cpp b/src/suffer.cpp index d18c7c5a2627a..ffc2ddb49cf68 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -878,12 +878,15 @@ void Character::suffer_from_albinism() void Character::suffer_item_dropping() { if( has_effect( effect_incorporeal ) ) { - std::vector tmp = inv_dump(); - for( auto i : tmp ) { - put_into_vehicle_or_drop( *this, item_drop_reason::tumbling, { *i } ); + std::vector dump = inv_dump(); + std::list tumble_items; + for( item *dump_item : dump ) { + tumble_items.push_back( *dump_item ); + } + put_into_vehicle_or_drop( *this, item_drop_reason::tumbling, tumble_items ); + for( auto i : dump ) { i_rem( i ); } - } } void Character::suffer_from_other_mutations() diff --git a/src/weather.cpp b/src/weather.cpp index ac69824374c9c..48b91eaa1f8bd 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -23,7 +23,6 @@ #include "map.h" #include "math_defines.h" #include "messages.h" -//#include "monster.h" #include "options.h" #include "overmap.h" #include "overmapbuffer.h" @@ -471,27 +470,27 @@ void weather_effect::mist() Character &target_character = g->u;//todo npcs, also if( calendar::once_every( g->weather.mist_spawn_time ) && is_creature_outside( target_character ) ) { + int mist_type = 0; + if( g->weather.mist_intensity > 0 && + g->weather.mist_intensity <= g->weather.mist_thick_threshold ) { + mist_type = 1; + } else if( g->weather.mist_intensity > g->weather.mist_thick_threshold && + g->weather.mist_intensity <= g->weather.mist_stifling_threshold ) { + mist_type = 2; + } else if( g->weather.mist_intensity > g->weather.mist_stifling_threshold ) { + mist_type = 3; + } + int monsters_to_spawn = std::max( 1, g->weather.mist_intensity / 5 ); for( int monsters_spawned = 0; monsters_spawned < monsters_to_spawn; monsters_spawned++ ) { - mtype_id monster_id; - std::string category; + mtype_id monster_id = mon_mist_wraith; + std::string category = "mist_summon_wraith"; bool is_hallucination = false; - int mist_type = std::min( 3, g->weather.mist_intensity / 10 ); - int rand = ( 1, 4 ); + + int rand = ( 0, mist_type ); switch( rand ) { - case 1: - monster_id = mon_mist_wraith; - category = "mist_summon_wraith"; - break; - case 2: - monster_id = mon_mist_spectre; - category = "mist_summon_spectre"; - break; - case 3: - monster_id = mon_mist_phantom; - category = "mist_summon_phantom"; - break; - case 4: { + case 0: { + //grab a random nearby outdoor non mist hostile creature to create a hallucination of Creature *copy = g->get_creature_if( [&target_character]( const Creature & critter ) -> bool { bool in_mist = is_creature_outside( critter ); bool not_self = target_character.pos() != critter.pos(); @@ -505,14 +504,23 @@ void weather_effect::mist() if( copy_monster != nullptr ) { monster_id = copy_monster->type->id; is_hallucination = true; - } else { - monster_id = mon_mist_wraith; - category = "mist_summon_wraith"; } break; } + case 1: + monster_id = mon_mist_wraith; + category = "mist_summon_wraith"; + break; + case 2: + monster_id = mon_mist_spectre; + category = "mist_summon_spectre"; + break; + case 3: + monster_id = mon_mist_phantom; + category = "mist_summon_phantom"; + break; default: - debugmsg( "HUH?" ); + debugmsg( "Random numbers gone wrong!" ); break; } @@ -528,7 +536,6 @@ void weather_effect::mist() } } if( found_location && is_hallucination ) { - g->u.add_msg_if_player( m_bad, "Hallucinate!" ); g->spawn_hallucination( target_point, monster_id ); } else if( found_location && g->place_critter_at( monster_id, target_point ) != nullptr ) { g->u.add_msg_if_player( m_bad, "%s", @@ -537,6 +544,7 @@ void weather_effect::mist() } } + if( calendar::once_every( g->weather.mist_intensity_increase_time ) ) { g->weather.increase_mist_intensity(); } @@ -1060,8 +1068,10 @@ weather_manager::weather_manager() void weather_manager::initialize() { nextweather = calendar::turn; + set_mist_length(); set_next_mist_time(); - mist_scaling = get_option( "MIST_SCALING" ); + set_mist_spawn_time(); + mist_scaling = get_option( "MIST_SCALING" ); temperature = SPRING_TEMPERATURE; update_weather(); } @@ -1158,9 +1168,24 @@ void weather_manager::clear_temp_cache() void weather_manager::set_next_mist_time() { - int days = get_option( "MIST_TIME_BETWEEN" ); - mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, - 1.5 * days ) ) + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); + int days = get_option( "MIST_INSTANCE_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); + mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, 1.5 * days ) ) + + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); +} + +void weather_manager::set_mist_spawn_time() +{ + int seconds = get_option( "MIST_SPAWN_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); + mist_spawn_time = time_duration::from_seconds( rng( .5 * seconds, 1.5 * seconds ) ); +} + +//calculates the total mist length then breaks that into pieces +void weather_manager::set_mist_length() +{ + int hours = get_option( "MIST_LENGTH" ) + ( mist_scaling * ( mist_instances / 5 ) ); + mist_intensity_increase_time = ( time_duration::from_hours( rng( .7 * hours, 1.3 * hours ) ) + + time_duration::from_seconds( rng( 0, to_seconds( 1_hours ) ) ) ) + / mist_intensity_increase_per_instance; } void weather_manager::increase_mist_intensity() @@ -1169,8 +1194,15 @@ void weather_manager::increase_mist_intensity() return; } + int mist_min_intensity = 1 + ( mist_scaling * mist_instances ); + int mist_max_intensity = 1 + mist_intensity_increase_per_instance + ( mist_scaling * + mist_instances ); + if( mist_intensity < mist_min_intensity ) { mist_intensity = mist_min_intensity; + set_mist_length(); + set_next_mist_time(); + set_mist_spawn_time(); g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( "mist_arrives" ).value_or( translation() ) ); } else if( mist_intensity < mist_max_intensity ) { @@ -1181,9 +1213,8 @@ void weather_manager::increase_mist_intensity() } } else { mist_intensity = 0; - mist_min_intensity += mist_scaling; - mist_max_intensity += mist_scaling; if( is_creature_outside( g->u ) ) { + mist_instances++; g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( "mist_leaves" ).value_or( translation() ) ); } diff --git a/src/weather.h b/src/weather.h index 28980df7fb5db..d0f8fec02ac52 100644 --- a/src/weather.h +++ b/src/weather.h @@ -255,15 +255,23 @@ class weather_manager int winddirection = 0; int windspeed = 0; - //Mist values + //current power of mist int mist_intensity = 0; - int mist_min_intensity = 1; - int mist_max_intensity = 10; - int mist_scaling = 1; - time_point mist_next_instance = calendar::turn; - time_duration mist_intensity_increase_time = 10_seconds; - time_duration mist_spawn_time = 5_seconds; + //how fast/often mist increases + float mist_scaling = 1; + //amount mist intensity increases before ending + int mist_intensity_increase_per_instance = 10; + //number of times the mist has happened, scales mist difficulty + int mist_instances = 0; + //next time mist will appear + time_point mist_next_instance = calendar::turn;//next time mist will appear + //time between mist intensity increases, changes every instance + time_duration mist_intensity_increase_time = 10_minutes; + //time between monster spawns, changes every instance + time_duration mist_spawn_time = 5_minutes; + //the intensity at which mist switches to thick int mist_thick_threshold = 10; + //the intensity at which mist switches to stifling int mist_stifling_threshold = 20; // Cached weather data @@ -281,6 +289,8 @@ class weather_manager int get_temperature( const tripoint &location ); void clear_temp_cache(); void set_next_mist_time(); + void set_mist_spawn_time(); + void set_mist_length(); //increases mist intensity or begins it at min intensity if not started void increase_mist_intensity(); }; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 7c8c7cca74595..33dc07939e811 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -183,16 +183,17 @@ weather_type weather_generator::get_weather_conditions( const tripoint &location weather_type weather_generator::get_weather_conditions( const w_point &w ) const { - if( g->weather.mist_intensity > 0 && - g->weather.mist_intensity <= g->weather.mist_thick_threshold ) { - return WEATHER_MIST; - } else if( g->weather.mist_intensity > g->weather.mist_thick_threshold && - g->weather.mist_intensity <= g->weather.mist_stifling_threshold ) { - return WEATHER_THICK_MIST; - } else if( g->weather.mist_intensity > g->weather.mist_stifling_threshold ) { - return WEATHER_STIFLING_MIST; + if( get_option( "MIST_ACTIVE" ) ) { + if( g->weather.mist_intensity > 0 && + g->weather.mist_intensity <= g->weather.mist_thick_threshold ) { + return WEATHER_MIST; + } else if( g->weather.mist_intensity > g->weather.mist_thick_threshold && + g->weather.mist_intensity <= g->weather.mist_stifling_threshold ) { + return WEATHER_THICK_MIST; + } else if( g->weather.mist_intensity > g->weather.mist_stifling_threshold ) { + return WEATHER_STIFLING_MIST; + } } - weather_type r( WEATHER_CLEAR ); if( w.pressure > 1020 && w.humidity < 70 ) { r = WEATHER_SUNNY; From 8e567ef969246a94159494665bc9e88a6334ddc6 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Tue, 2 Jun 2020 09:00:54 -0400 Subject: [PATCH 10/27] Update mist faction --- data/json/monster_factions.json | 5 +++++ data/json/monsters/mist.json | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/data/json/monster_factions.json b/data/json/monster_factions.json index 70a1991aad9d6..3586c1caeceff 100644 --- a/data/json/monster_factions.json +++ b/data/json/monster_factions.json @@ -201,5 +201,10 @@ "type": "MONSTER_FACTION", "name": "triffid", "base_faction": "plant" + }, + { + "type": "MONSTER_FACTION", + "name": "mist", + "neutral": [ "animal", "insect", "blob", "zombie", "zombie_aquatic","plant", "bot", "blob", "nether", "jabberwock" ] } ] diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index 05c59daae9382..eb72d857ba88a 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -4,7 +4,7 @@ "type": "MONSTER", "name": { "str": "Mist wraith" }, "description": "A wispy figure slightly more solid than the mist surrounding it.", - "default_faction": "MIST", + "default_faction": "mist", "species": [ "MIST" ], "volume": "62500 ml", "weight": "0 g", @@ -24,7 +24,7 @@ "type": "MONSTER", "name": { "str": "Mist spectre" }, "description": "A menacing figure slightly more solid than the mist surrounding it.", - "default_faction": "MIST", + "default_faction": "mist", "bodytype": "human", "species": [ "MIST" ], "volume": "62500 ml", @@ -45,7 +45,7 @@ "type": "MONSTER", "name": { "str": "Mist phantom" }, "description": "A shifting figure slightly more solid than the mist surrounding it.", - "default_faction": "MIST", + "default_faction": "mist", "bodytype": "human", "species": [ "MIST" ], "volume": "62500 ml", @@ -66,7 +66,7 @@ "type": "MONSTER", "name": { "str": "Mist bag" }, "description": "A bag seemingly made of mist, it appears to be on the edge of bursting.", - "default_faction": "MIST", + "default_faction": "mist", "bodytype": "human", "species": [ "MIST" ], "volume": "62500 ml", From 8df740c9c3656e17ccb15c8f4dfab877e933ecff Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Tue, 2 Jun 2020 09:04:20 -0400 Subject: [PATCH 11/27] Fix indent --- src/sounds.cpp | 228 ++++++++++++++++++++++++------------------------- 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/src/sounds.cpp b/src/sounds.cpp index 1c89b6ebcc5c1..35fde2c12d819 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -48,17 +48,17 @@ #include "weather.h" #if defined(SDL_SOUND) -#if defined(_MSC_VER) && defined(USE_VCPKG) -#include -#else -#include -#endif -#include -#if defined(_WIN32) && !defined(_MSC_VER) -#include "mingw.thread.h" -#endif - -#define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " + #if defined(_MSC_VER) && defined(USE_VCPKG) + #include + #else + #include + #endif + #include + #if defined(_WIN32) && !defined(_MSC_VER) + #include "mingw.thread.h" + #endif + + #define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " #endif weather_type previous_weather; @@ -245,7 +245,7 @@ static std::vector cluster_sounds( std::vector( centroid_iter->x ), static_cast( centroid_iter->y ), static_cast( centroid_iter->z ) }; const int dist = sound_distance( sound_event_pair.first, centroid_pos ); @@ -334,44 +334,44 @@ static bool describe_sound( sounds::sound_t category, bool from_player_position { if( from_player_position ) { switch( category ) { - case sounds::sound_t::_LAST: - debugmsg( "ERROR: Incorrect sound category" ); - return false; - case sounds::sound_t::background: - case sounds::sound_t::weather: - case sounds::sound_t::music: - // detailed music descriptions are printed in iuse::play_music - case sounds::sound_t::movement: - case sounds::sound_t::activity: - case sounds::sound_t::destructive_activity: - case sounds::sound_t::combat: - case sounds::sound_t::alert: - case sounds::sound_t::order: - case sounds::sound_t::speech: - return false; - case sounds::sound_t::electronic_speech: - case sounds::sound_t::alarm: - return true; + case sounds::sound_t::_LAST: + debugmsg( "ERROR: Incorrect sound category" ); + return false; + case sounds::sound_t::background: + case sounds::sound_t::weather: + case sounds::sound_t::music: + // detailed music descriptions are printed in iuse::play_music + case sounds::sound_t::movement: + case sounds::sound_t::activity: + case sounds::sound_t::destructive_activity: + case sounds::sound_t::combat: + case sounds::sound_t::alert: + case sounds::sound_t::order: + case sounds::sound_t::speech: + return false; + case sounds::sound_t::electronic_speech: + case sounds::sound_t::alarm: + return true; } } else { switch( category ) { - case sounds::sound_t::background: - case sounds::sound_t::weather: - case sounds::sound_t::music: - case sounds::sound_t::movement: - case sounds::sound_t::activity: - case sounds::sound_t::destructive_activity: - return one_in( 100 ); - case sounds::sound_t::speech: - case sounds::sound_t::electronic_speech: - case sounds::sound_t::alarm: - case sounds::sound_t::combat: - case sounds::sound_t::alert: - case sounds::sound_t::order: - return true; - case sounds::sound_t::_LAST: - debugmsg( "ERROR: Incorrect sound category" ); - return false; + case sounds::sound_t::background: + case sounds::sound_t::weather: + case sounds::sound_t::music: + case sounds::sound_t::movement: + case sounds::sound_t::activity: + case sounds::sound_t::destructive_activity: + return one_in( 100 ); + case sounds::sound_t::speech: + case sounds::sound_t::electronic_speech: + case sounds::sound_t::alarm: + case sounds::sound_t::combat: + case sounds::sound_t::alert: + case sounds::sound_t::order: + return true; + case sounds::sound_t::_LAST: + debugmsg( "ERROR: Incorrect sound category" ); + return false; } } return true; @@ -441,9 +441,9 @@ void sounds::process_sound_markers( player *p ) if( p->has_effect( effect_sleep ) ) { if( ( ( !( p->has_trait( trait_HEAVYSLEEPER ) || p->has_trait( trait_HEAVYSLEEPER2 ) ) && dice( 2, 15 ) < heard_volume ) || - ( p->has_trait( trait_HEAVYSLEEPER ) && dice( 3, 15 ) < heard_volume ) || - ( p->has_trait( trait_HEAVYSLEEPER2 ) && dice( 6, 15 ) < heard_volume ) ) && - !p->has_effect( effect_narcosis ) ) { + ( p->has_trait( trait_HEAVYSLEEPER ) && dice( 3, 15 ) < heard_volume ) || + ( p->has_trait( trait_HEAVYSLEEPER2 ) && dice( 6, 15 ) < heard_volume ) ) && + !p->has_effect( effect_narcosis ) ) { //Not kidding about sleep-through-firefight p->wake_up(); add_msg( m_warning, _( "Something is making noise." ) ); @@ -463,7 +463,7 @@ void sounds::process_sound_markers( player *p ) // don't print our own noise or things without descriptions if( !sound.ambient && ( pos != p->pos() ) && !g->m.pl_sees( pos, distance_to_sound ) ) { if( !p->activity.is_distraction_ignored( distraction_type::noise ) && - !get_safemode().is_sound_safe( sound.description, distance_to_sound ) ) { + !get_safemode().is_sound_safe( sound.description, distance_to_sound ) ) { const std::string query = string_format( _( "Heard %s!" ), description ); g->cancel_activity_or_ignore_query( distraction_type::noise, query ); } @@ -487,7 +487,7 @@ void sounds::process_sound_markers( player *p ) } if( !p->has_effect( effect_sleep ) && p->has_effect( effect_alarm_clock ) && - !p->has_bionic( bionic_id( "bio_watch" ) ) ) { + !p->has_bionic( bionic_id( "bio_watch" ) ) ) { // if we don't have effect_sleep but we're in_sleep_state, either // we were trying to fall asleep for so long our alarm is now going // off or something disturbed us while trying to sleep @@ -723,7 +723,7 @@ void sfx::do_vehicle_engine_sfx() current_gear = 6; } if( veh->has_engine_type( fuel_type_muscle, true ) || - veh->has_engine_type( fuel_type_wind, true ) ) { + veh->has_engine_type( fuel_type_wind, true ) ) { current_gear = previous_gear; } @@ -783,8 +783,8 @@ void sfx::do_vehicle_exterior_engine_sfx() for( wrapped_vehicle vehicle : vehs ) { if( vehicle.v->vehicle_noise > 0 && - vehicle.v->vehicle_noise - - sound_distance( g->u.pos(), vehicle.v->global_pos3() ) > noise_factor ) { + vehicle.v->vehicle_noise - + sound_distance( g->u.pos(), vehicle.v->global_pos3() ) > noise_factor ) { noise_factor = vehicle.v->vehicle_noise - sound_distance( g->u.pos(), vehicle.v->global_pos3() ); veh = vehicle.v; @@ -862,7 +862,7 @@ void sfx::do_ambient() const bool weather_changed = g->weather.weather != previous_weather; // Step in at night time / we are not indoors if( is_night( calendar::turn ) && !is_sheltered && - !is_channel_playing( channel::nighttime_outdoors_env ) && !is_deaf ) { + !is_channel_playing( channel::nighttime_outdoors_env ) && !is_deaf ) { fade_audio_group( group::time_of_day, 1000 ); play_ambient_variant_sound( "environment", "nighttime", heard_volume, channel::nighttime_outdoors_env, 1000 ); @@ -875,8 +875,8 @@ void sfx::do_ambient() } // We are underground if( ( is_underground && !is_channel_playing( channel::underground_env ) && - !is_deaf ) || ( is_underground && - weather_changed && !is_deaf ) ) { + !is_deaf ) || ( is_underground && + weather_changed && !is_deaf ) ) { fade_audio_group( group::weather, 1000 ); fade_audio_group( group::time_of_day, 1000 ); play_ambient_variant_sound( "environment", "underground", heard_volume, channel::underground_env, @@ -892,69 +892,69 @@ void sfx::do_ambient() } // We are indoors and it is also raining if( g->weather.weather >= WEATHER_DRIZZLE && g->weather.weather <= WEATHER_ACID_RAIN && - !is_underground - && is_sheltered && !is_channel_playing( channel::indoors_rain_env ) ) { + !is_underground + && is_sheltered && !is_channel_playing( channel::indoors_rain_env ) ) { play_ambient_variant_sound( "environment", "indoors_rain", heard_volume, channel::indoors_rain_env, 1000 ); } if( ( !is_sheltered && g->weather.weather != WEATHER_CLEAR && !is_deaf && - !is_channel_playing( channel::outdoors_snow_env ) && - !is_channel_playing( channel::outdoors_flurry_env ) && - !is_channel_playing( channel::outdoors_thunderstorm_env ) && - !is_channel_playing( channel::outdoors_rain_env ) && - !is_channel_playing( channel::outdoors_drizzle_env ) && - !is_channel_playing( channel::outdoor_blizzard ) ) - || ( !is_sheltered && - weather_changed && !is_deaf ) ) { + !is_channel_playing( channel::outdoors_snow_env ) && + !is_channel_playing( channel::outdoors_flurry_env ) && + !is_channel_playing( channel::outdoors_thunderstorm_env ) && + !is_channel_playing( channel::outdoors_rain_env ) && + !is_channel_playing( channel::outdoors_drizzle_env ) && + !is_channel_playing( channel::outdoor_blizzard ) ) + || ( !is_sheltered && + weather_changed && !is_deaf ) ) { fade_audio_group( group::weather, 1000 ); // We are outside and there is precipitation switch( g->weather.weather ) { - case WEATHER_ACID_DRIZZLE: - case WEATHER_DRIZZLE: - case WEATHER_LIGHT_DRIZZLE: - play_ambient_variant_sound( "environment", "WEATHER_DRIZZLE", heard_volume, - channel::outdoors_drizzle_env, - 1000 ); - break; - case WEATHER_RAINY: - play_ambient_variant_sound( "environment", "WEATHER_RAINY", heard_volume, - channel::outdoors_rain_env, - 1000 ); - break; - case WEATHER_ACID_RAIN: - case WEATHER_THUNDER: - case WEATHER_LIGHTNING: - play_ambient_variant_sound( "environment", "WEATHER_THUNDER", heard_volume, - channel::outdoors_thunderstorm_env, - 1000 ); - break; - case WEATHER_FLURRIES: - play_ambient_variant_sound( "environment", "WEATHER_FLURRIES", heard_volume, - channel::outdoors_flurry_env, - 1000 ); - break; - case WEATHER_CLEAR: - case WEATHER_SUNNY: - case WEATHER_CLOUDY: - case WEATHER_SNOWSTORM: - play_ambient_variant_sound( "environment", "WEATHER_SNOWSTORM", heard_volume, - channel::outdoor_blizzard, - 1000 ); - break; - case WEATHER_SNOW: - play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, channel::outdoors_snow_env, - 1000 ); - break; - case WEATHER_MIST: - case WEATHER_THICK_MIST: - case WEATHER_STIFLING_MIST: - play_ambient_variant_sound( "environment", "WEATHER_MIST", heard_volume, channel::outdoors_mist, - 1000 ); - break; - case WEATHER_NULL: - case NUM_WEATHER_TYPES: - // nothing here, those are pseudo-types, they should not be active at all. - break; + case WEATHER_ACID_DRIZZLE: + case WEATHER_DRIZZLE: + case WEATHER_LIGHT_DRIZZLE: + play_ambient_variant_sound( "environment", "WEATHER_DRIZZLE", heard_volume, + channel::outdoors_drizzle_env, + 1000 ); + break; + case WEATHER_RAINY: + play_ambient_variant_sound( "environment", "WEATHER_RAINY", heard_volume, + channel::outdoors_rain_env, + 1000 ); + break; + case WEATHER_ACID_RAIN: + case WEATHER_THUNDER: + case WEATHER_LIGHTNING: + play_ambient_variant_sound( "environment", "WEATHER_THUNDER", heard_volume, + channel::outdoors_thunderstorm_env, + 1000 ); + break; + case WEATHER_FLURRIES: + play_ambient_variant_sound( "environment", "WEATHER_FLURRIES", heard_volume, + channel::outdoors_flurry_env, + 1000 ); + break; + case WEATHER_CLEAR: + case WEATHER_SUNNY: + case WEATHER_CLOUDY: + case WEATHER_SNOWSTORM: + play_ambient_variant_sound( "environment", "WEATHER_SNOWSTORM", heard_volume, + channel::outdoor_blizzard, + 1000 ); + break; + case WEATHER_SNOW: + play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, channel::outdoors_snow_env, + 1000 ); + break; + case WEATHER_MIST: + case WEATHER_THICK_MIST: + case WEATHER_STIFLING_MIST: + play_ambient_variant_sound( "environment", "WEATHER_MIST", heard_volume, channel::outdoors_mist, + 1000 ); + break; + case WEATHER_NULL: + case NUM_WEATHER_TYPES: + // nothing here, those are pseudo-types, they should not be active at all. + break; } } // Keep track of weather to compare for next iteration From 006c3d07a491c75702ae7a099ff44bfa11ef0351 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Tue, 2 Jun 2020 09:09:19 -0400 Subject: [PATCH 12/27] Fix indent --- src/sounds.cpp | 206 ++++++++++++++++++++++++------------------------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/src/sounds.cpp b/src/sounds.cpp index 35fde2c12d819..fa0ad27739877 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -245,7 +245,7 @@ static std::vector cluster_sounds( std::vector( centroid_iter->x ), static_cast( centroid_iter->y ), static_cast( centroid_iter->z ) }; const int dist = sound_distance( sound_event_pair.first, centroid_pos ); @@ -334,44 +334,44 @@ static bool describe_sound( sounds::sound_t category, bool from_player_position { if( from_player_position ) { switch( category ) { - case sounds::sound_t::_LAST: - debugmsg( "ERROR: Incorrect sound category" ); - return false; - case sounds::sound_t::background: - case sounds::sound_t::weather: - case sounds::sound_t::music: - // detailed music descriptions are printed in iuse::play_music - case sounds::sound_t::movement: - case sounds::sound_t::activity: - case sounds::sound_t::destructive_activity: - case sounds::sound_t::combat: - case sounds::sound_t::alert: - case sounds::sound_t::order: - case sounds::sound_t::speech: - return false; - case sounds::sound_t::electronic_speech: - case sounds::sound_t::alarm: - return true; + case sounds::sound_t::_LAST: + debugmsg( "ERROR: Incorrect sound category" ); + return false; + case sounds::sound_t::background: + case sounds::sound_t::weather: + case sounds::sound_t::music: + // detailed music descriptions are printed in iuse::play_music + case sounds::sound_t::movement: + case sounds::sound_t::activity: + case sounds::sound_t::destructive_activity: + case sounds::sound_t::combat: + case sounds::sound_t::alert: + case sounds::sound_t::order: + case sounds::sound_t::speech: + return false; + case sounds::sound_t::electronic_speech: + case sounds::sound_t::alarm: + return true; } } else { switch( category ) { - case sounds::sound_t::background: - case sounds::sound_t::weather: - case sounds::sound_t::music: - case sounds::sound_t::movement: - case sounds::sound_t::activity: - case sounds::sound_t::destructive_activity: - return one_in( 100 ); - case sounds::sound_t::speech: - case sounds::sound_t::electronic_speech: - case sounds::sound_t::alarm: - case sounds::sound_t::combat: - case sounds::sound_t::alert: - case sounds::sound_t::order: - return true; - case sounds::sound_t::_LAST: - debugmsg( "ERROR: Incorrect sound category" ); - return false; + case sounds::sound_t::background: + case sounds::sound_t::weather: + case sounds::sound_t::music: + case sounds::sound_t::movement: + case sounds::sound_t::activity: + case sounds::sound_t::destructive_activity: + return one_in( 100 ); + case sounds::sound_t::speech: + case sounds::sound_t::electronic_speech: + case sounds::sound_t::alarm: + case sounds::sound_t::combat: + case sounds::sound_t::alert: + case sounds::sound_t::order: + return true; + case sounds::sound_t::_LAST: + debugmsg( "ERROR: Incorrect sound category" ); + return false; } } return true; @@ -441,9 +441,9 @@ void sounds::process_sound_markers( player *p ) if( p->has_effect( effect_sleep ) ) { if( ( ( !( p->has_trait( trait_HEAVYSLEEPER ) || p->has_trait( trait_HEAVYSLEEPER2 ) ) && dice( 2, 15 ) < heard_volume ) || - ( p->has_trait( trait_HEAVYSLEEPER ) && dice( 3, 15 ) < heard_volume ) || - ( p->has_trait( trait_HEAVYSLEEPER2 ) && dice( 6, 15 ) < heard_volume ) ) && - !p->has_effect( effect_narcosis ) ) { + ( p->has_trait( trait_HEAVYSLEEPER ) && dice( 3, 15 ) < heard_volume ) || + ( p->has_trait( trait_HEAVYSLEEPER2 ) && dice( 6, 15 ) < heard_volume ) ) && + !p->has_effect( effect_narcosis ) ) { //Not kidding about sleep-through-firefight p->wake_up(); add_msg( m_warning, _( "Something is making noise." ) ); @@ -463,7 +463,7 @@ void sounds::process_sound_markers( player *p ) // don't print our own noise or things without descriptions if( !sound.ambient && ( pos != p->pos() ) && !g->m.pl_sees( pos, distance_to_sound ) ) { if( !p->activity.is_distraction_ignored( distraction_type::noise ) && - !get_safemode().is_sound_safe( sound.description, distance_to_sound ) ) { + !get_safemode().is_sound_safe( sound.description, distance_to_sound ) ) { const std::string query = string_format( _( "Heard %s!" ), description ); g->cancel_activity_or_ignore_query( distraction_type::noise, query ); } @@ -487,7 +487,7 @@ void sounds::process_sound_markers( player *p ) } if( !p->has_effect( effect_sleep ) && p->has_effect( effect_alarm_clock ) && - !p->has_bionic( bionic_id( "bio_watch" ) ) ) { + !p->has_bionic( bionic_id( "bio_watch" ) ) ) { // if we don't have effect_sleep but we're in_sleep_state, either // we were trying to fall asleep for so long our alarm is now going // off or something disturbed us while trying to sleep @@ -723,7 +723,7 @@ void sfx::do_vehicle_engine_sfx() current_gear = 6; } if( veh->has_engine_type( fuel_type_muscle, true ) || - veh->has_engine_type( fuel_type_wind, true ) ) { + veh->has_engine_type( fuel_type_wind, true ) ) { current_gear = previous_gear; } @@ -783,8 +783,8 @@ void sfx::do_vehicle_exterior_engine_sfx() for( wrapped_vehicle vehicle : vehs ) { if( vehicle.v->vehicle_noise > 0 && - vehicle.v->vehicle_noise - - sound_distance( g->u.pos(), vehicle.v->global_pos3() ) > noise_factor ) { + vehicle.v->vehicle_noise - + sound_distance( g->u.pos(), vehicle.v->global_pos3() ) > noise_factor ) { noise_factor = vehicle.v->vehicle_noise - sound_distance( g->u.pos(), vehicle.v->global_pos3() ); veh = vehicle.v; @@ -862,7 +862,7 @@ void sfx::do_ambient() const bool weather_changed = g->weather.weather != previous_weather; // Step in at night time / we are not indoors if( is_night( calendar::turn ) && !is_sheltered && - !is_channel_playing( channel::nighttime_outdoors_env ) && !is_deaf ) { + !is_channel_playing( channel::nighttime_outdoors_env ) && !is_deaf ) { fade_audio_group( group::time_of_day, 1000 ); play_ambient_variant_sound( "environment", "nighttime", heard_volume, channel::nighttime_outdoors_env, 1000 ); @@ -875,8 +875,8 @@ void sfx::do_ambient() } // We are underground if( ( is_underground && !is_channel_playing( channel::underground_env ) && - !is_deaf ) || ( is_underground && - weather_changed && !is_deaf ) ) { + !is_deaf ) || ( is_underground && + weather_changed && !is_deaf ) ) { fade_audio_group( group::weather, 1000 ); fade_audio_group( group::time_of_day, 1000 ); play_ambient_variant_sound( "environment", "underground", heard_volume, channel::underground_env, @@ -892,69 +892,69 @@ void sfx::do_ambient() } // We are indoors and it is also raining if( g->weather.weather >= WEATHER_DRIZZLE && g->weather.weather <= WEATHER_ACID_RAIN && - !is_underground - && is_sheltered && !is_channel_playing( channel::indoors_rain_env ) ) { + !is_underground + && is_sheltered && !is_channel_playing( channel::indoors_rain_env ) ) { play_ambient_variant_sound( "environment", "indoors_rain", heard_volume, channel::indoors_rain_env, 1000 ); } if( ( !is_sheltered && g->weather.weather != WEATHER_CLEAR && !is_deaf && - !is_channel_playing( channel::outdoors_snow_env ) && - !is_channel_playing( channel::outdoors_flurry_env ) && - !is_channel_playing( channel::outdoors_thunderstorm_env ) && - !is_channel_playing( channel::outdoors_rain_env ) && - !is_channel_playing( channel::outdoors_drizzle_env ) && - !is_channel_playing( channel::outdoor_blizzard ) ) - || ( !is_sheltered && - weather_changed && !is_deaf ) ) { + !is_channel_playing( channel::outdoors_snow_env ) && + !is_channel_playing( channel::outdoors_flurry_env ) && + !is_channel_playing( channel::outdoors_thunderstorm_env ) && + !is_channel_playing( channel::outdoors_rain_env ) && + !is_channel_playing( channel::outdoors_drizzle_env ) && + !is_channel_playing( channel::outdoor_blizzard ) ) + || ( !is_sheltered && + weather_changed && !is_deaf ) ) { fade_audio_group( group::weather, 1000 ); // We are outside and there is precipitation switch( g->weather.weather ) { - case WEATHER_ACID_DRIZZLE: - case WEATHER_DRIZZLE: - case WEATHER_LIGHT_DRIZZLE: - play_ambient_variant_sound( "environment", "WEATHER_DRIZZLE", heard_volume, - channel::outdoors_drizzle_env, - 1000 ); - break; - case WEATHER_RAINY: - play_ambient_variant_sound( "environment", "WEATHER_RAINY", heard_volume, - channel::outdoors_rain_env, - 1000 ); - break; - case WEATHER_ACID_RAIN: - case WEATHER_THUNDER: - case WEATHER_LIGHTNING: - play_ambient_variant_sound( "environment", "WEATHER_THUNDER", heard_volume, - channel::outdoors_thunderstorm_env, - 1000 ); - break; - case WEATHER_FLURRIES: - play_ambient_variant_sound( "environment", "WEATHER_FLURRIES", heard_volume, - channel::outdoors_flurry_env, - 1000 ); - break; - case WEATHER_CLEAR: - case WEATHER_SUNNY: - case WEATHER_CLOUDY: - case WEATHER_SNOWSTORM: - play_ambient_variant_sound( "environment", "WEATHER_SNOWSTORM", heard_volume, - channel::outdoor_blizzard, - 1000 ); - break; - case WEATHER_SNOW: - play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, channel::outdoors_snow_env, - 1000 ); - break; - case WEATHER_MIST: - case WEATHER_THICK_MIST: - case WEATHER_STIFLING_MIST: - play_ambient_variant_sound( "environment", "WEATHER_MIST", heard_volume, channel::outdoors_mist, - 1000 ); - break; - case WEATHER_NULL: - case NUM_WEATHER_TYPES: - // nothing here, those are pseudo-types, they should not be active at all. - break; + case WEATHER_ACID_DRIZZLE: + case WEATHER_DRIZZLE: + case WEATHER_LIGHT_DRIZZLE: + play_ambient_variant_sound( "environment", "WEATHER_DRIZZLE", heard_volume, + channel::outdoors_drizzle_env, + 1000 ); + break; + case WEATHER_RAINY: + play_ambient_variant_sound( "environment", "WEATHER_RAINY", heard_volume, + channel::outdoors_rain_env, + 1000 ); + break; + case WEATHER_ACID_RAIN: + case WEATHER_THUNDER: + case WEATHER_LIGHTNING: + play_ambient_variant_sound( "environment", "WEATHER_THUNDER", heard_volume, + channel::outdoors_thunderstorm_env, + 1000 ); + break; + case WEATHER_FLURRIES: + play_ambient_variant_sound( "environment", "WEATHER_FLURRIES", heard_volume, + channel::outdoors_flurry_env, + 1000 ); + break; + case WEATHER_CLEAR: + case WEATHER_SUNNY: + case WEATHER_CLOUDY: + case WEATHER_SNOWSTORM: + play_ambient_variant_sound( "environment", "WEATHER_SNOWSTORM", heard_volume, + channel::outdoor_blizzard, + 1000 ); + break; + case WEATHER_SNOW: + play_ambient_variant_sound( "environment", "WEATHER_SNOW", heard_volume, channel::outdoors_snow_env, + 1000 ); + break; + case WEATHER_MIST: + case WEATHER_THICK_MIST: + case WEATHER_STIFLING_MIST: + play_ambient_variant_sound( "environment", "WEATHER_MIST", heard_volume, channel::outdoors_mist, + 1000 ); + break; + case WEATHER_NULL: + case NUM_WEATHER_TYPES: + // nothing here, those are pseudo-types, they should not be active at all. + break; } } // Keep track of weather to compare for next iteration From fb8db0a5975c07bb80b452eda132dad565b4e2ac Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 20:27:34 -0400 Subject: [PATCH 13/27] A little balancing --- .../Cataclysm-lib-vcpkg-static.vcxproj | 815 +++++++++++++++--- .../Cataclysm-test-vcpkg-static.vcxproj | 120 ++- msvc-full-features/JsonFormatter.vcxproj | 6 +- src/debug_menu.cpp | 8 +- src/monattack.cpp | 24 +- src/weather.cpp | 8 +- src/weather.h | 2 - 7 files changed, 840 insertions(+), 143 deletions(-) diff --git a/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj b/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj index 92612114ddb80..4d6d59b3bc6c3 100644 --- a/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj +++ b/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj @@ -1,137 +1,710 @@ - - - Debug - x64 - - - Debug - Win32 - - - Release - x64 - - - Release - Win32 - - + + + Debug + x64 + + + Debug + Win32 + + + Release + x64 + + + Release + Win32 + + 16.0 {0009BB11-11AD-4C14-A5FC-D882A942C00B} Win32Proj CataclysmLib 10.0 - x86-windows-static - x64-windows-static + x86-windows-static + x64-windows-static - - StaticLibrary - v142 - MultiByte + StaticLibrary + v142 + MultiByte - true + true - false - false + false + false - - - - - - - - - - $(ProjectName)-$(Configuration)-$(Platform) - .lib - $(SolutionDir)..\ - $(SolutionDir)$(ProjectName)\$(Configuration)\$(Platform)\ - - - true - - - false - - - - Level1 - Use - true - false - true - false - ProgramDatabase - 4819;4146;26495;26444;26451;4068 - stdafx.h - /bigobj /utf-8 %(AdditionalOptions) - _SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_CONSOLE;SDL_SOUND;TILES;SDL_BUILDING_LIBRARY;LOCALIZE;USE_VCPKG;%(PreprocessorDefinitions) - stdcpp14 - ..\src;%(AdditionalIncludeDirectories) - - - Windows - true - Default - true - /LTCG:OFF %(AdditionalOptions) - winmm.lib;imm32.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies) - - - prebuild.cmd - Get version string - - - true - - - - - Disabled - false - false - _DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - MaxSpeed - true - true - NDEBUG;%(PreprocessorDefinitions) - DebugFastLink - MultiThreaded - - - true - true - - - - - WIN32;%(PreprocessorDefinitions) - - - - - - - - - - Create - - - - - - + + + + + + + + + $(ProjectName)-$(Configuration)-$(Platform) + .lib + $(SolutionDir)..\ + $(SolutionDir)$(ProjectName)\$(Configuration)\$(Platform)\ + + + true + + + false + + + + Level1 + Use + true + false + true + false + ProgramDatabase + 4819;4146;26495;26444;26451;4068 + stdafx.h + /bigobj /utf-8 %(AdditionalOptions) + _SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_CONSOLE;SDL_SOUND;TILES;SDL_BUILDING_LIBRARY;LOCALIZE;USE_VCPKG;%(PreprocessorDefinitions) + stdcpp14 + ..\src;%(AdditionalIncludeDirectories) + + + Windows + true + Default + true + /LTCG:OFF %(AdditionalOptions) + winmm.lib;imm32.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies) + + + prebuild.cmd + Get version string + + + true + + + + + Disabled + false + false + _DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + MaxSpeed + true + true + NDEBUG;%(PreprocessorDefinitions) + DebugFastLink + MultiThreaded + + + true + true + + + + + WIN32;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + + + + + + \ No newline at end of file diff --git a/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj b/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj index 389d881705f5a..2599f292eb873 100644 --- a/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj +++ b/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj @@ -120,12 +120,128 @@ - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create diff --git a/msvc-full-features/JsonFormatter.vcxproj b/msvc-full-features/JsonFormatter.vcxproj index bf31ec6133545..5648a2b1bd89a 100644 --- a/msvc-full-features/JsonFormatter.vcxproj +++ b/msvc-full-features/JsonFormatter.vcxproj @@ -121,12 +121,12 @@ - + - + Create @@ -139,4 +139,4 @@ - + \ No newline at end of file diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 08debd2b1e653..f139949f719d8 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -106,7 +106,7 @@ extern std::mapweather.mist_intensity ); smenu.addentry( 1, true, 'm', "%s: %d", _( "Mist Instances" ), g->weather.mist_instances ); - smenu.addentry( 3, true, 's', "%s: %d", _( "Mist Scaling" ), g->weather.mist_scaling ); smenu.addentry( 4, true, 't', "%s: %d", _( "Intensity Increase Time" ), to_seconds( g->weather.mist_intensity_increase_time ) ); smenu.addentry( 5, true, 'w', "%s: %d", _( "Spawn Time" ), @@ -1434,11 +1433,6 @@ void debug() g->weather.mist_instances = value; } break; - case 3: - if( query_int( value, _( "Set mist scaling to? Currently: %d" ), g->weather.mist_scaling ) ) { - g->weather.mist_scaling = value; - } - break; case 4: if( query_int( value, _( "Set intensity increase time to how many seconds? Currently: %d" ), to_string( g->weather.mist_intensity_increase_time ) ) ) { diff --git a/src/monattack.cpp b/src/monattack.cpp index e223d63a59504..11a3d9030b7a2 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -5811,8 +5811,12 @@ bool mattack::dissipate_drain( monster *z ) return false; } z->die( z ); - foe->mod_fatigue( 100 ); - foe->mod_stamina( -200 ); + + float mist_scaling = get_option( "MIST_SCALING" ); + int fatigue_drain_amount = 25 + ( mist_scaling * g->weather.mist_instances ); + int stamina_drain_amount = 500 + ( 50 * mist_scaling * g->weather.mist_instances ); + foe->mod_fatigue( fatigue_drain_amount ); + foe->mod_stamina( -stamina_drain_amount ); foe->add_msg_if_player( m_bad, _( "The %s takes a little of your strength." ), z->name() ); return true; @@ -5825,8 +5829,12 @@ bool mattack::dissipate_nightmares( monster *z ) return false; } z->die( z ); - foe->add_effect( effect_disrupted_sleep, 12_hours ); - foe->add_effect( effect_nightmares, 12_hours ); + + float mist_scaling = get_option( "MIST_SCALING" ); + time_duration effect_length = 10_hours + ( 5 * time_duration::from_minutes( mist_scaling * + g->weather.mist_instances ) ); + foe->add_effect( effect_disrupted_sleep, effect_length ); + foe->add_effect( effect_nightmares, effect_length ); foe->add_msg_if_player( m_bad, _( "The %s leaves an unsettling feeling behind." ), z->name() ); return true; @@ -5839,7 +5847,10 @@ bool mattack::dissipate_force_scream( monster *z ) return false; } z->die( z ); - foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, 1_hours ); + float mist_scaling = get_option( "MIST_SCALING" ); + time_duration effect_length = 1_hours + time_duration::from_minutes( mist_scaling * + g->weather.mist_instances ); + foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, effect_length ); foe->add_msg_if_player( m_bad, _( "The %s surfaces an intense memory, that feels like your own." ), z->name() ); @@ -5858,6 +5869,9 @@ bool mattack::dissipate_incorporeal( monster *z ) return false; } z->die( z ); + float mist_scaling = get_option( "MIST_SCALING" ); + time_duration effect_length = 2_seconds + ( .1 * time_duration::from_seconds( mist_scaling * + g->weather.mist_instances ) ); foe->add_effect( effect_incorporeal, 3_seconds ); foe->add_msg_if_player( m_bad, _( "The %s robs you of your form." ), z->name() ); diff --git a/src/weather.cpp b/src/weather.cpp index 48b91eaa1f8bd..96e5a70f604fe 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -487,7 +487,7 @@ void weather_effect::mist() std::string category = "mist_summon_wraith"; bool is_hallucination = false; - int rand = ( 0, mist_type ); + int rand = rng( 0, mist_type ); switch( rand ) { case 0: { //grab a random nearby outdoor non mist hostile creature to create a hallucination of @@ -1071,7 +1071,6 @@ void weather_manager::initialize() set_mist_length(); set_next_mist_time(); set_mist_spawn_time(); - mist_scaling = get_option( "MIST_SCALING" ); temperature = SPRING_TEMPERATURE; update_weather(); } @@ -1168,6 +1167,7 @@ void weather_manager::clear_temp_cache() void weather_manager::set_next_mist_time() { + float mist_scaling = get_option( "MIST_SCALING" ); int days = get_option( "MIST_INSTANCE_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, 1.5 * days ) ) + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); @@ -1175,6 +1175,7 @@ void weather_manager::set_next_mist_time() void weather_manager::set_mist_spawn_time() { + float mist_scaling = get_option( "MIST_SCALING" ); int seconds = get_option( "MIST_SPAWN_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); mist_spawn_time = time_duration::from_seconds( rng( .5 * seconds, 1.5 * seconds ) ); } @@ -1182,6 +1183,7 @@ void weather_manager::set_mist_spawn_time() //calculates the total mist length then breaks that into pieces void weather_manager::set_mist_length() { + float mist_scaling = get_option( "MIST_SCALING" ); int hours = get_option( "MIST_LENGTH" ) + ( mist_scaling * ( mist_instances / 5 ) ); mist_intensity_increase_time = ( time_duration::from_hours( rng( .7 * hours, 1.3 * hours ) ) + time_duration::from_seconds( rng( 0, to_seconds( 1_hours ) ) ) ) @@ -1193,7 +1195,7 @@ void weather_manager::increase_mist_intensity() if( !get_option( "MIST_ACTIVE" ) ) { return; } - + float mist_scaling = get_option( "MIST_SCALING" ); int mist_min_intensity = 1 + ( mist_scaling * mist_instances ); int mist_max_intensity = 1 + mist_intensity_increase_per_instance + ( mist_scaling * mist_instances ); diff --git a/src/weather.h b/src/weather.h index d0f8fec02ac52..66e6c8055321f 100644 --- a/src/weather.h +++ b/src/weather.h @@ -257,8 +257,6 @@ class weather_manager //current power of mist int mist_intensity = 0; - //how fast/often mist increases - float mist_scaling = 1; //amount mist intensity increases before ending int mist_intensity_increase_per_instance = 10; //number of times the mist has happened, scales mist difficulty From f86ec0e7ba3e0c1d42426836c75f6f100f3c914d Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 20:31:59 -0400 Subject: [PATCH 14/27] Revert "A little balancing" This reverts commit fb8db0a5975c07bb80b452eda132dad565b4e2ac. --- .../Cataclysm-lib-vcpkg-static.vcxproj | 815 +++--------------- .../Cataclysm-test-vcpkg-static.vcxproj | 120 +-- msvc-full-features/JsonFormatter.vcxproj | 6 +- src/debug_menu.cpp | 8 +- src/monattack.cpp | 24 +- src/weather.cpp | 8 +- src/weather.h | 2 + 7 files changed, 143 insertions(+), 840 deletions(-) diff --git a/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj b/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj index 4d6d59b3bc6c3..92612114ddb80 100644 --- a/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj +++ b/msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj @@ -1,710 +1,137 @@ - - - Debug - x64 - - - Debug - Win32 - - - Release - x64 - - - Release - Win32 - - + + + Debug + x64 + + + Debug + Win32 + + + Release + x64 + + + Release + Win32 + + 16.0 {0009BB11-11AD-4C14-A5FC-D882A942C00B} Win32Proj CataclysmLib 10.0 - x86-windows-static - x64-windows-static + x86-windows-static + x64-windows-static + - StaticLibrary - v142 - MultiByte + StaticLibrary + v142 + MultiByte - true + true - false - false + false + false - - - - - - - - - $(ProjectName)-$(Configuration)-$(Platform) - .lib - $(SolutionDir)..\ - $(SolutionDir)$(ProjectName)\$(Configuration)\$(Platform)\ - - - true - - - false - - - - Level1 - Use - true - false - true - false - ProgramDatabase - 4819;4146;26495;26444;26451;4068 - stdafx.h - /bigobj /utf-8 %(AdditionalOptions) - _SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_CONSOLE;SDL_SOUND;TILES;SDL_BUILDING_LIBRARY;LOCALIZE;USE_VCPKG;%(PreprocessorDefinitions) - stdcpp14 - ..\src;%(AdditionalIncludeDirectories) - - - Windows - true - Default - true - /LTCG:OFF %(AdditionalOptions) - winmm.lib;imm32.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies) - - - prebuild.cmd - Get version string - - - true - - - - - Disabled - false - false - _DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - MaxSpeed - true - true - NDEBUG;%(PreprocessorDefinitions) - DebugFastLink - MultiThreaded - - - true - true - - - - - WIN32;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - - - - \ No newline at end of file + + + + + + + + + + $(ProjectName)-$(Configuration)-$(Platform) + .lib + $(SolutionDir)..\ + $(SolutionDir)$(ProjectName)\$(Configuration)\$(Platform)\ + + + true + + + false + + + + Level1 + Use + true + false + true + false + ProgramDatabase + 4819;4146;26495;26444;26451;4068 + stdafx.h + /bigobj /utf-8 %(AdditionalOptions) + _SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_CONSOLE;SDL_SOUND;TILES;SDL_BUILDING_LIBRARY;LOCALIZE;USE_VCPKG;%(PreprocessorDefinitions) + stdcpp14 + ..\src;%(AdditionalIncludeDirectories) + + + Windows + true + Default + true + /LTCG:OFF %(AdditionalOptions) + winmm.lib;imm32.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;setupapi.lib;%(AdditionalDependencies) + + + prebuild.cmd + Get version string + + + true + + + + + Disabled + false + false + _DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + MaxSpeed + true + true + NDEBUG;%(PreprocessorDefinitions) + DebugFastLink + MultiThreaded + + + true + true + + + + + WIN32;%(PreprocessorDefinitions) + + + + + + + + + + Create + + + + + + diff --git a/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj b/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj index 2599f292eb873..389d881705f5a 100644 --- a/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj +++ b/msvc-full-features/Cataclysm-test-vcpkg-static.vcxproj @@ -120,128 +120,12 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Create diff --git a/msvc-full-features/JsonFormatter.vcxproj b/msvc-full-features/JsonFormatter.vcxproj index 5648a2b1bd89a..bf31ec6133545 100644 --- a/msvc-full-features/JsonFormatter.vcxproj +++ b/msvc-full-features/JsonFormatter.vcxproj @@ -121,12 +121,12 @@ - + + - Create @@ -139,4 +139,4 @@ - \ No newline at end of file + diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index f139949f719d8..08debd2b1e653 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -106,7 +106,7 @@ extern std::mapweather.mist_intensity ); smenu.addentry( 1, true, 'm', "%s: %d", _( "Mist Instances" ), g->weather.mist_instances ); + smenu.addentry( 3, true, 's', "%s: %d", _( "Mist Scaling" ), g->weather.mist_scaling ); smenu.addentry( 4, true, 't', "%s: %d", _( "Intensity Increase Time" ), to_seconds( g->weather.mist_intensity_increase_time ) ); smenu.addentry( 5, true, 'w', "%s: %d", _( "Spawn Time" ), @@ -1433,6 +1434,11 @@ void debug() g->weather.mist_instances = value; } break; + case 3: + if( query_int( value, _( "Set mist scaling to? Currently: %d" ), g->weather.mist_scaling ) ) { + g->weather.mist_scaling = value; + } + break; case 4: if( query_int( value, _( "Set intensity increase time to how many seconds? Currently: %d" ), to_string( g->weather.mist_intensity_increase_time ) ) ) { diff --git a/src/monattack.cpp b/src/monattack.cpp index 11a3d9030b7a2..e223d63a59504 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -5811,12 +5811,8 @@ bool mattack::dissipate_drain( monster *z ) return false; } z->die( z ); - - float mist_scaling = get_option( "MIST_SCALING" ); - int fatigue_drain_amount = 25 + ( mist_scaling * g->weather.mist_instances ); - int stamina_drain_amount = 500 + ( 50 * mist_scaling * g->weather.mist_instances ); - foe->mod_fatigue( fatigue_drain_amount ); - foe->mod_stamina( -stamina_drain_amount ); + foe->mod_fatigue( 100 ); + foe->mod_stamina( -200 ); foe->add_msg_if_player( m_bad, _( "The %s takes a little of your strength." ), z->name() ); return true; @@ -5829,12 +5825,8 @@ bool mattack::dissipate_nightmares( monster *z ) return false; } z->die( z ); - - float mist_scaling = get_option( "MIST_SCALING" ); - time_duration effect_length = 10_hours + ( 5 * time_duration::from_minutes( mist_scaling * - g->weather.mist_instances ) ); - foe->add_effect( effect_disrupted_sleep, effect_length ); - foe->add_effect( effect_nightmares, effect_length ); + foe->add_effect( effect_disrupted_sleep, 12_hours ); + foe->add_effect( effect_nightmares, 12_hours ); foe->add_msg_if_player( m_bad, _( "The %s leaves an unsettling feeling behind." ), z->name() ); return true; @@ -5847,10 +5839,7 @@ bool mattack::dissipate_force_scream( monster *z ) return false; } z->die( z ); - float mist_scaling = get_option( "MIST_SCALING" ); - time_duration effect_length = 1_hours + time_duration::from_minutes( mist_scaling * - g->weather.mist_instances ); - foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, effect_length ); + foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, 1_hours ); foe->add_msg_if_player( m_bad, _( "The %s surfaces an intense memory, that feels like your own." ), z->name() ); @@ -5869,9 +5858,6 @@ bool mattack::dissipate_incorporeal( monster *z ) return false; } z->die( z ); - float mist_scaling = get_option( "MIST_SCALING" ); - time_duration effect_length = 2_seconds + ( .1 * time_duration::from_seconds( mist_scaling * - g->weather.mist_instances ) ); foe->add_effect( effect_incorporeal, 3_seconds ); foe->add_msg_if_player( m_bad, _( "The %s robs you of your form." ), z->name() ); diff --git a/src/weather.cpp b/src/weather.cpp index 96e5a70f604fe..48b91eaa1f8bd 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -487,7 +487,7 @@ void weather_effect::mist() std::string category = "mist_summon_wraith"; bool is_hallucination = false; - int rand = rng( 0, mist_type ); + int rand = ( 0, mist_type ); switch( rand ) { case 0: { //grab a random nearby outdoor non mist hostile creature to create a hallucination of @@ -1071,6 +1071,7 @@ void weather_manager::initialize() set_mist_length(); set_next_mist_time(); set_mist_spawn_time(); + mist_scaling = get_option( "MIST_SCALING" ); temperature = SPRING_TEMPERATURE; update_weather(); } @@ -1167,7 +1168,6 @@ void weather_manager::clear_temp_cache() void weather_manager::set_next_mist_time() { - float mist_scaling = get_option( "MIST_SCALING" ); int days = get_option( "MIST_INSTANCE_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, 1.5 * days ) ) + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); @@ -1175,7 +1175,6 @@ void weather_manager::set_next_mist_time() void weather_manager::set_mist_spawn_time() { - float mist_scaling = get_option( "MIST_SCALING" ); int seconds = get_option( "MIST_SPAWN_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); mist_spawn_time = time_duration::from_seconds( rng( .5 * seconds, 1.5 * seconds ) ); } @@ -1183,7 +1182,6 @@ void weather_manager::set_mist_spawn_time() //calculates the total mist length then breaks that into pieces void weather_manager::set_mist_length() { - float mist_scaling = get_option( "MIST_SCALING" ); int hours = get_option( "MIST_LENGTH" ) + ( mist_scaling * ( mist_instances / 5 ) ); mist_intensity_increase_time = ( time_duration::from_hours( rng( .7 * hours, 1.3 * hours ) ) + time_duration::from_seconds( rng( 0, to_seconds( 1_hours ) ) ) ) @@ -1195,7 +1193,7 @@ void weather_manager::increase_mist_intensity() if( !get_option( "MIST_ACTIVE" ) ) { return; } - float mist_scaling = get_option( "MIST_SCALING" ); + int mist_min_intensity = 1 + ( mist_scaling * mist_instances ); int mist_max_intensity = 1 + mist_intensity_increase_per_instance + ( mist_scaling * mist_instances ); diff --git a/src/weather.h b/src/weather.h index 66e6c8055321f..d0f8fec02ac52 100644 --- a/src/weather.h +++ b/src/weather.h @@ -257,6 +257,8 @@ class weather_manager //current power of mist int mist_intensity = 0; + //how fast/often mist increases + float mist_scaling = 1; //amount mist intensity increases before ending int mist_intensity_increase_per_instance = 10; //number of times the mist has happened, scales mist difficulty From 206f8ea2dbedd1b5145ba8c180663c8532d7ed52 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 20:52:42 -0400 Subject: [PATCH 15/27] Redone changes --- src/debug_menu.cpp | 8 +------- src/monattack.cpp | 27 +++++++++++++++++++++------ src/weather.cpp | 7 +++++-- src/weather.h | 2 -- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 08debd2b1e653..f139949f719d8 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -106,7 +106,7 @@ extern std::mapweather.mist_intensity ); smenu.addentry( 1, true, 'm', "%s: %d", _( "Mist Instances" ), g->weather.mist_instances ); - smenu.addentry( 3, true, 's', "%s: %d", _( "Mist Scaling" ), g->weather.mist_scaling ); smenu.addentry( 4, true, 't', "%s: %d", _( "Intensity Increase Time" ), to_seconds( g->weather.mist_intensity_increase_time ) ); smenu.addentry( 5, true, 'w', "%s: %d", _( "Spawn Time" ), @@ -1434,11 +1433,6 @@ void debug() g->weather.mist_instances = value; } break; - case 3: - if( query_int( value, _( "Set mist scaling to? Currently: %d" ), g->weather.mist_scaling ) ) { - g->weather.mist_scaling = value; - } - break; case 4: if( query_int( value, _( "Set intensity increase time to how many seconds? Currently: %d" ), to_string( g->weather.mist_intensity_increase_time ) ) ) { diff --git a/src/monattack.cpp b/src/monattack.cpp index e223d63a59504..0b12732e4bbdc 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -5811,8 +5811,12 @@ bool mattack::dissipate_drain( monster *z ) return false; } z->die( z ); - foe->mod_fatigue( 100 ); - foe->mod_stamina( -200 ); + + float mist_scaling = get_option( "MIST_SCALING" ); + int fatigue_drain_amount = 25 + ( mist_scaling * g->weather.mist_instances ); + int stamina_drain_amount = 500 + ( 50 * mist_scaling * g->weather.mist_instances ); + foe->mod_fatigue( fatigue_drain_amount ); + foe->mod_stamina( -stamina_drain_amount ); foe->add_msg_if_player( m_bad, _( "The %s takes a little of your strength." ), z->name() ); return true; @@ -5825,8 +5829,12 @@ bool mattack::dissipate_nightmares( monster *z ) return false; } z->die( z ); - foe->add_effect( effect_disrupted_sleep, 12_hours ); - foe->add_effect( effect_nightmares, 12_hours ); + + float mist_scaling = get_option( "MIST_SCALING" ); + time_duration effect_length = 10_hours + ( 5 * time_duration::from_minutes( mist_scaling * + g->weather.mist_instances ) ); + foe->add_effect( effect_disrupted_sleep, effect_length ); + foe->add_effect( effect_nightmares, effect_length ); foe->add_msg_if_player( m_bad, _( "The %s leaves an unsettling feeling behind." ), z->name() ); return true; @@ -5839,7 +5847,11 @@ bool mattack::dissipate_force_scream( monster *z ) return false; } z->die( z ); - foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, 1_hours ); + + float mist_scaling = get_option( "MIST_SCALING" ); + time_duration effect_length = 1_hours + time_duration::from_minutes( mist_scaling * + g->weather.mist_instances ); + foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, effect_length ); foe->add_msg_if_player( m_bad, _( "The %s surfaces an intense memory, that feels like your own." ), z->name() ); @@ -5858,7 +5870,10 @@ bool mattack::dissipate_incorporeal( monster *z ) return false; } z->die( z ); - foe->add_effect( effect_incorporeal, 3_seconds ); + + float mist_scaling = get_option( "MIST_SCALING" ); + time_duration effect_length = 2_seconds + ( .1 * time_duration::from_seconds( mist_scaling * + g->weather.mist_instances ) ); foe->add_msg_if_player( m_bad, _( "The %s robs you of your form." ), z->name() ); return true; diff --git a/src/weather.cpp b/src/weather.cpp index 48b91eaa1f8bd..56edce881174d 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -487,7 +487,7 @@ void weather_effect::mist() std::string category = "mist_summon_wraith"; bool is_hallucination = false; - int rand = ( 0, mist_type ); + int rand = rng( 0, mist_type ); switch( rand ) { case 0: { //grab a random nearby outdoor non mist hostile creature to create a hallucination of @@ -1071,7 +1071,6 @@ void weather_manager::initialize() set_mist_length(); set_next_mist_time(); set_mist_spawn_time(); - mist_scaling = get_option( "MIST_SCALING" ); temperature = SPRING_TEMPERATURE; update_weather(); } @@ -1168,6 +1167,7 @@ void weather_manager::clear_temp_cache() void weather_manager::set_next_mist_time() { + float mist_scaling = get_option( "MIST_SCALING" ); int days = get_option( "MIST_INSTANCE_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, 1.5 * days ) ) + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); @@ -1175,6 +1175,7 @@ void weather_manager::set_next_mist_time() void weather_manager::set_mist_spawn_time() { + float mist_scaling = get_option( "MIST_SCALING" ); int seconds = get_option( "MIST_SPAWN_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); mist_spawn_time = time_duration::from_seconds( rng( .5 * seconds, 1.5 * seconds ) ); } @@ -1182,6 +1183,7 @@ void weather_manager::set_mist_spawn_time() //calculates the total mist length then breaks that into pieces void weather_manager::set_mist_length() { + float mist_scaling = get_option( "MIST_SCALING" ); int hours = get_option( "MIST_LENGTH" ) + ( mist_scaling * ( mist_instances / 5 ) ); mist_intensity_increase_time = ( time_duration::from_hours( rng( .7 * hours, 1.3 * hours ) ) + time_duration::from_seconds( rng( 0, to_seconds( 1_hours ) ) ) ) @@ -1194,6 +1196,7 @@ void weather_manager::increase_mist_intensity() return; } + float mist_scaling = get_option( "MIST_SCALING" ); int mist_min_intensity = 1 + ( mist_scaling * mist_instances ); int mist_max_intensity = 1 + mist_intensity_increase_per_instance + ( mist_scaling * mist_instances ); diff --git a/src/weather.h b/src/weather.h index d0f8fec02ac52..66e6c8055321f 100644 --- a/src/weather.h +++ b/src/weather.h @@ -257,8 +257,6 @@ class weather_manager //current power of mist int mist_intensity = 0; - //how fast/often mist increases - float mist_scaling = 1; //amount mist intensity increases before ending int mist_intensity_increase_per_instance = 10; //number of times the mist has happened, scales mist difficulty From 23d94b6706c882068509a0606d8f18949eca909c Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 22:15:05 -0400 Subject: [PATCH 16/27] Lint --- data/json/monsters/mist.json | 25 ++++++++------- data/json/snippets/mist.json | 59 +++++++++++++++--------------------- src/mondeath.cpp | 1 - 3 files changed, 36 insertions(+), 49 deletions(-) diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index eb72d857ba88a..d65c7e00430a3 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -3,7 +3,7 @@ "id": "mon_mist_wraith", "type": "MONSTER", "name": { "str": "Mist wraith" }, - "description": "A wispy figure slightly more solid than the mist surrounding it.", + "description": "A wispy figure slightly more solid than the mist surrounding it. It's form is constantly shifting and never distinct.", "default_faction": "mist", "species": [ "MIST" ], "volume": "62500 ml", @@ -12,10 +12,10 @@ "speed": 110, "symbol": "X", "color": "white", - "aggression": 75, + "aggression": 100, "morale": 100, - "melee_skill": 10, - "special_attacks": [ [ "DISSIPATE_DRAIN", 1 ] ], + "dodge": 8, + "special_attacks": [ [ "DISSIPATE_DRAIN", 1 ] ], "death_function": [ "DISSIPATE" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] }, @@ -23,7 +23,7 @@ "id": "mon_mist_spectre", "type": "MONSTER", "name": { "str": "Mist spectre" }, - "description": "A menacing figure slightly more solid than the mist surrounding it.", + "description": "A menacing figure slightly more solid than the mist surrounding it. It's shape brings back painful memories.", "default_faction": "mist", "bodytype": "human", "species": [ "MIST" ], @@ -35,8 +35,8 @@ "color": "white", "aggression": 100, "morale": 100, - "melee_skill": 3, - "special_attacks": [ [ "DISSIPATE_NIGHTMARES", 1 ], [ "DISSIPATE_FORCE_SCREAM", 1 ] ], + "dodge": 9, + "special_attacks": [ [ "DISSIPATE_NIGHTMARES", 1 ], [ "DISSIPATE_FORCE_SCREAM", 1 ] ], "death_function": [ "DISSIPATE" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] }, @@ -44,7 +44,7 @@ "id": "mon_mist_phantom", "type": "MONSTER", "name": { "str": "Mist phantom" }, - "description": "A shifting figure slightly more solid than the mist surrounding it.", + "description": "A hollow figure no more solid than the mist surrounding it.", "default_faction": "mist", "bodytype": "human", "species": [ "MIST" ], @@ -56,12 +56,12 @@ "color": "white", "aggression": 100, "morale": 100, - "melee_skill": 3, - "special_attacks": [ [ "DISSIPATE_INCORPOREAL", 1 ] ], + "dodge": 10, + "special_attacks": [ [ "DISSIPATE_INCORPOREAL", 1 ] ], "death_function": [ "DISSIPATE" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] }, - { + { "id": "mon_mist_bag", "type": "MONSTER", "name": { "str": "Mist bag" }, @@ -77,8 +77,7 @@ "color": "white", "aggression": 100, "morale": 100, - "melee_skill": 3, - "special_attacks": [ [ "DISSIPATE", 1 ] ], + "special_attacks": [ [ "DISSIPATE", 1 ] ], "death_function": [ "RELEASE_MIST" ], "flags": [ "FLIES", "NO_BREATHE", "SEES", "HEARS" ] } diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json index 16a2ab4f083fb..9e6d56b503387 100644 --- a/data/json/snippets/mist.json +++ b/data/json/snippets/mist.json @@ -2,34 +2,26 @@ { "type": "snippet", "category": "mist_summon_wraith", - "text": [ - "You feel the mist react to you and a shape appears.", - "The mist reacts to you and a hazy figure condenses." - ] + "text": [ "You feel the mist react to you and a vague shape appears.", "The mist reacts to you and a hazy figure condenses." ] }, { "type": "snippet", "category": "mist_summon_spectre", - "text": [ - "A nightmarish shape appears in the mist.", - "You see a shape form in the mist that reminds you of a dream monster." - ] + "text": [ "A nightmarish shape appears in the mist.", "A shape forms in the mist reminding you of your lastest nightmare." ] }, { "type": "snippet", "category": "mist_summon_phantom", "text": [ "A shape forms in the mist reminiscent of your childhood bully.", - "A shape forms in the mist reminiscent you of a teacher that hated you." + "A shape forms in the mist reminiscent you of a teacher that hated you.", + "A shape forms in the mist reminiscent you of a friend that betrayed you." ] }, { "type": "snippet", "category": "mist_increase_intensity", - "text": [ - "The mist thickens.", - "The mist feels slightly stronger and more alive." - ] + "text": [ "The mist thickens.", "The mist feels slightly stronger and more alive." ] }, { "type": "snippet", @@ -39,13 +31,10 @@ "In an instant a thick mist descends upon the world, far too fast to be natural. Or are you finally losing it?." ] }, - { + { "type": "snippet", "category": "mist_leaves", - "text": [ - "The mist evaporates like it was never there.", - "In a heartbeat the mist is gone." - ] + "text": [ "The mist evaporates like it was never there.", "In a heartbeat the mist is gone." ] }, { "type": "snippet", @@ -53,19 +42,19 @@ "text": [ "I'm sorry mommy!", "Please stop sir, that hurts!", - "Why? I tried my best!", - "No, please get up, please be ok!", - "Why would you lie about THAT?", - "I never loved you!", - "I only ever tolerated you!", - "That's why I never trusted you!", - "It's not fair!", - "Enjoy the funeral, you sicko!", - "Help!", - "Cmon I can still be fun, there's no need for that!", - "I can do better, I promise, please!", - "I'm going to kill that son of a bitch!", - "That's no excuse!" + "Why? I tried my best!", + "No, please get up, please be ok!", + "Why would you lie about THAT?", + "I never loved you!", + "I only ever tolerated you!", + "That's why I never trusted you!", + "It's not fair!", + "Enjoy the funeral, you sicko!", + "Help!", + "Cmon I can still be fun, there's no need for that!", + "I can do better, I promise, please!", + "I'm going to kill that son of a bitch!", + "That's no excuse!" ] }, { @@ -74,10 +63,10 @@ "text": [ "You awaken from a nightmare about being eaten alive while your friends applaud.", "You awaken from a nightmare about being naked in a the artic tundra and freezing to death.", - "You awaken from a nightmare about an unseen predator slowly killing you.", - "You awaken from a nightmare about killing those you love with your bare hands.", - "You awaken from a nightmare about being finally judged for your ill deeds.", - "You awaken from a nightmare about the cataclysm not having happened and being stuck in an office job." + "You awaken from a nightmare about an unseen predator slowly killing you.", + "You awaken from a nightmare about killing those you love with your bare hands.", + "You awaken from a nightmare about being finally judged for your ill deeds.", + "You awaken from a nightmare about the cataclysm not having happened and being stuck in an office job." ] } ] diff --git a/src/mondeath.cpp b/src/mondeath.cpp index d9ca6007b3d1e..88d1582ca7b68 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -45,7 +45,6 @@ #include "sounds.h" #include "string_formatter.h" #include "string_id.h" -#include "text_snippets.h" #include "timed_event.h" #include "translations.h" #include "type_id.h" From 23d1f3b6066579123d505617272c693db48ed972 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 22:21:56 -0400 Subject: [PATCH 17/27] Lint --- data/json/monster_factions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/monster_factions.json b/data/json/monster_factions.json index 3586c1caeceff..2543e8afc4e4d 100644 --- a/data/json/monster_factions.json +++ b/data/json/monster_factions.json @@ -205,6 +205,6 @@ { "type": "MONSTER_FACTION", "name": "mist", - "neutral": [ "animal", "insect", "blob", "zombie", "zombie_aquatic","plant", "bot", "blob", "nether", "jabberwock" ] + "neutral": [ "animal", "insect", "blob", "zombie", "zombie_aquatic", "plant", "bot", "blob", "nether", "jabberwock" ] } ] From cec091d7ae7690353007bfe474b45b7c52575281 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 22:23:23 -0400 Subject: [PATCH 18/27] Astyle --- src/debug_menu.cpp | 2 +- src/player.cpp | 220 ++++++++++++++++++++++----------------------- src/sounds.cpp | 22 ++--- 3 files changed, 122 insertions(+), 122 deletions(-) diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 923506baec94c..dff3d1738885d 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -106,7 +106,7 @@ extern std::map - #else - #include - #endif - #include - #if defined(_WIN32) && !defined(_MSC_VER) - #include "mingw.thread.h" - #endif - - #define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " +#if defined(_MSC_VER) && defined(USE_VCPKG) +#include +#else +#include +#endif +#include +#if defined(_WIN32) && !defined(_MSC_VER) +#include "mingw.thread.h" +#endif + +#define dbg(x) DebugLog((x),D_SDL) << __FILE__ << ":" << __LINE__ << ": " #endif weather_type previous_weather; From 3ff368ad853702802c4f2fb25db459da3807c3bb Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 22:31:43 -0400 Subject: [PATCH 19/27] Lint --- data/json/effects.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/json/effects.json b/data/json/effects.json index d4a0a58514747..8d33bd2580a88 100644 --- a/data/json/effects.json +++ b/data/json/effects.json @@ -1970,10 +1970,10 @@ "id": "disrupted_sleep", "max_duration": "72 h" }, - { + { "type": "effect_type", "id": "nightmares", - "max_duration": "72 h" + "max_duration": "72 h" }, { "type": "effect_type", From f9f7e06364e83c4d9421f24914bca19c599e6d5f Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 22:49:45 -0400 Subject: [PATCH 20/27] Build fixes --- src/game.cpp | 24 +++--- src/game.h | 2 +- src/player.cpp | 220 ++++++++++++++++++++++++------------------------- 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index e1acc122cb5ed..8ef4f69d8038a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -164,19 +164,19 @@ class computer; class inventory; #if defined(TILES) -#include "cata_tiles.h" + #include "cata_tiles.h" #endif // TILES #if !(defined(_WIN32) || defined(TILES)) -#include -#include + #include + #include #endif #if defined(_WIN32) -#if 1 // HACK: Hack to prevent reordering of #include "platform_win.h" by IWYU -# include "platform_win.h" -#endif -# include + #if 1 // HACK: Hack to prevent reordering of #include "platform_win.h" by IWYU + #include "platform_win.h" + #endif + #include #endif #define dbg(x) DebugLog((x),D_GAME) << __FILE__ << ":" << __LINE__ << ": " @@ -453,9 +453,9 @@ void game::load_data_from_dir( const std::string &path, const std::string &src, #define MINIMAP_WIDTH 7 #if !(defined(_WIN32) || defined(TILES)) -// in ncurses_def.cpp -void check_encoding(); -void ensure_term_size(); + // in ncurses_def.cpp + void check_encoding(); + void ensure_term_size(); #endif void game::init_ui( const bool resized ) @@ -5010,7 +5010,7 @@ bool game::spawn_hallucination( const tripoint &p ) * a monster already in the target square. * @return Whether or not a hallucination was successfully spawned. */ -bool game::spawn_hallucination( const tripoint &p, mtype_id &mt ) +bool game::spawn_hallucination( const tripoint &p, const mtype_id &mt ) { const shared_ptr_fast phantasm = make_shared_fast( mt ); phantasm->hallucination = true; @@ -7192,7 +7192,7 @@ static void centerlistview( const tripoint &active_item_position, int ui_width ) } #if defined(TILES) -#define MAXIMUM_ZOOM_LEVEL 4 + #define MAXIMUM_ZOOM_LEVEL 4 #endif void game::zoom_out() { diff --git a/src/game.h b/src/game.h index 21c7ac68e55c5..54248c0937d53 100644 --- a/src/game.h +++ b/src/game.h @@ -349,7 +349,7 @@ class game void clear_zombies(); /** Spawns a hallucination at a determined position. */ bool spawn_hallucination( const tripoint &p ); - bool spawn_hallucination( const tripoint &p, mtype_id &mt ); + bool spawn_hallucination( const tripoint &p, const mtype_id &mt ); /** Swaps positions of two creatures */ bool swap_critters( Creature &, Creature & ); diff --git a/src/player.cpp b/src/player.cpp index a39b280caf962..b386e179d6333 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -96,112 +96,112 @@ static const efftype_id effect_darkness( "darkness" ); static const efftype_id effect_dermatik( "dermatik" ); static const efftype_id effect_downed( "downed" ); static const efftype_id effect_fungus( "fungus" ); -static const efftype_id effect_incorporeal( "incorporeal" - static const efftype_id effect_infected( "infected" ); - static const efftype_id effect_masked_scent( "masked_scent" ); - static const efftype_id effect_meth( "meth" ); - static const efftype_id effect_narcosis( "narcosis" ); - static const efftype_id effect_nausea( "nausea" ); - static const efftype_id effect_onfire( "onfire" ); - static const efftype_id effect_paincysts( "paincysts" ); - static const efftype_id effect_recover( "recover" ); - static const efftype_id effect_sleep( "sleep" ); - static const efftype_id effect_stunned( "stunned" ); - static const efftype_id effect_tapeworm( "tapeworm" ); - static const efftype_id effect_weed_high( "weed_high" ); - - static const itype_id itype_adv_UPS_off( "adv_UPS_off" ); - static const itype_id itype_battery( "battery" ); - static const itype_id itype_brass_catcher( "brass_catcher" ); - static const itype_id itype_cookbook_human( "cookbook_human" ); - static const itype_id itype_large_repairkit( "large_repairkit" ); - static const itype_id itype_plut_cell( "plut_cell" ); - static const itype_id itype_small_repairkit( "small_repairkit" ); - static const itype_id itype_UPS( "UPS" ); - static const itype_id itype_UPS_off( "UPS_off" ); - - static const trait_id trait_ACIDBLOOD( "ACIDBLOOD" ); - static const trait_id trait_DEBUG_NODMG( "DEBUG_NODMG" ); - static const trait_id trait_CANNIBAL( "CANNIBAL" ); - static const trait_id trait_CENOBITE( "CENOBITE" ); - static const trait_id trait_CF_HAIR( "CF_HAIR" ); - static const trait_id trait_CHITIN_FUR( "CHITIN_FUR" ); - static const trait_id trait_CHITIN_FUR2( "CHITIN_FUR2" ); - static const trait_id trait_CHITIN_FUR3( "CHITIN_FUR3" ); - static const trait_id trait_CHLOROMORPH( "CHLOROMORPH" ); - static const trait_id trait_CLUMSY( "CLUMSY" ); - static const trait_id trait_COLDBLOOD4( "COLDBLOOD4" ); - static const trait_id trait_DEBUG_BIONIC_POWER( "DEBUG_BIONIC_POWER" ); - static const trait_id trait_DEBUG_HS( "DEBUG_HS" ); - static const trait_id trait_DEFT( "DEFT" ); - static const trait_id trait_EASYSLEEPER( "EASYSLEEPER" ); - static const trait_id trait_EASYSLEEPER2( "EASYSLEEPER2" ); - static const trait_id trait_EATHEALTH( "EATHEALTH" ); - static const trait_id trait_FAT( "FAT" ); - static const trait_id trait_FELINE_FUR( "FELINE_FUR" ); - static const trait_id trait_FUR( "FUR" ); - static const trait_id trait_HATES_BOOKS( "HATES_BOOKS" ); - static const trait_id trait_HUGE( "HUGE" ); - static const trait_id trait_HUGE_OK( "HUGE_OK" ); - static const trait_id trait_INFIMMUNE( "INFIMMUNE" ); - static const trait_id trait_INSOMNIA( "INSOMNIA" ); - static const trait_id trait_INT_SLIME( "INT_SLIME" ); - static const trait_id trait_LARGE( "LARGE" ); - static const trait_id trait_LARGE_OK( "LARGE_OK" ); - static const trait_id trait_LIGHTFUR( "LIGHTFUR" ); - static const trait_id trait_LIGHTSTEP( "LIGHTSTEP" ); - static const trait_id trait_LOVES_BOOKS( "LOVES_BOOKS" ); - static const trait_id trait_LUPINE_FUR( "LUPINE_FUR" ); - static const trait_id trait_M_IMMUNE( "M_IMMUNE" ); - static const trait_id trait_M_SKIN3( "M_SKIN3" ); - static const trait_id trait_MORE_PAIN( "MORE_PAIN" ); - static const trait_id trait_MORE_PAIN2( "MORE_PAIN2" ); - static const trait_id trait_MORE_PAIN3( "MORE_PAIN3" ); - static const trait_id trait_NAUSEA( "NAUSEA" ); - static const trait_id trait_NOMAD( "NOMAD" ); - static const trait_id trait_NOMAD2( "NOMAD2" ); - static const trait_id trait_NOMAD3( "NOMAD3" ); - static const trait_id trait_NOPAIN( "NOPAIN" ); - static const trait_id trait_PACIFIST( "PACIFIST" ); - static const trait_id trait_PAINRESIST( "PAINRESIST" ); - static const trait_id trait_PAINRESIST_TROGLO( "PAINRESIST_TROGLO" ); - static const trait_id trait_PARAIMMUNE( "PARAIMMUNE" ); - static const trait_id trait_PARKOUR( "PARKOUR" ); - static const trait_id trait_PER_SLIME_OK( "PER_SLIME_OK" ); - static const trait_id trait_PROF_SKATER( "PROF_SKATER" ); - static const trait_id trait_PSYCHOPATH( "PSYCHOPATH" ); - static const trait_id trait_QUILLS( "QUILLS" ); - static const trait_id trait_SAPIOVORE( "SAPIOVORE" ); - static const trait_id trait_SAVANT( "SAVANT" ); - static const trait_id trait_SHELL2( "SHELL2" ); - static const trait_id trait_SLIMY( "SLIMY" ); - static const trait_id trait_SPINES( "SPINES" ); - static const trait_id trait_SPIRITUAL( "SPIRITUAL" ); - static const trait_id trait_STRONGSTOMACH( "STRONGSTOMACH" ); - static const trait_id trait_SUNLIGHT_DEPENDENT( "SUNLIGHT_DEPENDENT" ); - static const trait_id trait_THORNS( "THORNS" ); - static const trait_id trait_THRESH_SPIDER( "THRESH_SPIDER" ); - static const trait_id trait_URSINE_FUR( "URSINE_FUR" ); - static const trait_id trait_VOMITOUS( "VOMITOUS" ); - static const trait_id trait_WATERSLEEP( "WATERSLEEP" ); - static const trait_id trait_WEAKSTOMACH( "WEAKSTOMACH" ); - static const trait_id trait_WEB_SPINNER( "WEB_SPINNER" ); - static const trait_id trait_WEB_WALKER( "WEB_WALKER" ); - static const trait_id trait_WEB_WEAVER( "WEB_WEAVER" ); - - static const std::string flag_SPLINT( "SPLINT" ); - - static const skill_id skill_dodge( "dodge" ); - static const skill_id skill_gun( "gun" ); - static const skill_id skill_swimming( "swimming" ); - - static const bionic_id bio_cqb( "bio_cqb" ); - static const bionic_id bio_ground_sonar( "bio_ground_sonar" ); - static const bionic_id bio_soporific( "bio_soporific" ); - static const bionic_id bio_speed( "bio_speed" ); - static const bionic_id bio_uncanny_dodge( "bio_uncanny_dodge" ); - - stat_mod player::get_pain_penalty() const +static const efftype_id effect_incorporeal( "incorporeal" ); +static const efftype_id effect_infected( "infected" ); +static const efftype_id effect_masked_scent( "masked_scent" ); +static const efftype_id effect_meth( "meth" ); +static const efftype_id effect_narcosis( "narcosis" ); +static const efftype_id effect_nausea( "nausea" ); +static const efftype_id effect_onfire( "onfire" ); +static const efftype_id effect_paincysts( "paincysts" ); +static const efftype_id effect_recover( "recover" ); +static const efftype_id effect_sleep( "sleep" ); +static const efftype_id effect_stunned( "stunned" ); +static const efftype_id effect_tapeworm( "tapeworm" ); +static const efftype_id effect_weed_high( "weed_high" ); + +static const itype_id itype_adv_UPS_off( "adv_UPS_off" ); +static const itype_id itype_battery( "battery" ); +static const itype_id itype_brass_catcher( "brass_catcher" ); +static const itype_id itype_cookbook_human( "cookbook_human" ); +static const itype_id itype_large_repairkit( "large_repairkit" ); +static const itype_id itype_plut_cell( "plut_cell" ); +static const itype_id itype_small_repairkit( "small_repairkit" ); +static const itype_id itype_UPS( "UPS" ); +static const itype_id itype_UPS_off( "UPS_off" ); + +static const trait_id trait_ACIDBLOOD( "ACIDBLOOD" ); +static const trait_id trait_DEBUG_NODMG( "DEBUG_NODMG" ); +static const trait_id trait_CANNIBAL( "CANNIBAL" ); +static const trait_id trait_CENOBITE( "CENOBITE" ); +static const trait_id trait_CF_HAIR( "CF_HAIR" ); +static const trait_id trait_CHITIN_FUR( "CHITIN_FUR" ); +static const trait_id trait_CHITIN_FUR2( "CHITIN_FUR2" ); +static const trait_id trait_CHITIN_FUR3( "CHITIN_FUR3" ); +static const trait_id trait_CHLOROMORPH( "CHLOROMORPH" ); +static const trait_id trait_CLUMSY( "CLUMSY" ); +static const trait_id trait_COLDBLOOD4( "COLDBLOOD4" ); +static const trait_id trait_DEBUG_BIONIC_POWER( "DEBUG_BIONIC_POWER" ); +static const trait_id trait_DEBUG_HS( "DEBUG_HS" ); +static const trait_id trait_DEFT( "DEFT" ); +static const trait_id trait_EASYSLEEPER( "EASYSLEEPER" ); +static const trait_id trait_EASYSLEEPER2( "EASYSLEEPER2" ); +static const trait_id trait_EATHEALTH( "EATHEALTH" ); +static const trait_id trait_FAT( "FAT" ); +static const trait_id trait_FELINE_FUR( "FELINE_FUR" ); +static const trait_id trait_FUR( "FUR" ); +static const trait_id trait_HATES_BOOKS( "HATES_BOOKS" ); +static const trait_id trait_HUGE( "HUGE" ); +static const trait_id trait_HUGE_OK( "HUGE_OK" ); +static const trait_id trait_INFIMMUNE( "INFIMMUNE" ); +static const trait_id trait_INSOMNIA( "INSOMNIA" ); +static const trait_id trait_INT_SLIME( "INT_SLIME" ); +static const trait_id trait_LARGE( "LARGE" ); +static const trait_id trait_LARGE_OK( "LARGE_OK" ); +static const trait_id trait_LIGHTFUR( "LIGHTFUR" ); +static const trait_id trait_LIGHTSTEP( "LIGHTSTEP" ); +static const trait_id trait_LOVES_BOOKS( "LOVES_BOOKS" ); +static const trait_id trait_LUPINE_FUR( "LUPINE_FUR" ); +static const trait_id trait_M_IMMUNE( "M_IMMUNE" ); +static const trait_id trait_M_SKIN3( "M_SKIN3" ); +static const trait_id trait_MORE_PAIN( "MORE_PAIN" ); +static const trait_id trait_MORE_PAIN2( "MORE_PAIN2" ); +static const trait_id trait_MORE_PAIN3( "MORE_PAIN3" ); +static const trait_id trait_NAUSEA( "NAUSEA" ); +static const trait_id trait_NOMAD( "NOMAD" ); +static const trait_id trait_NOMAD2( "NOMAD2" ); +static const trait_id trait_NOMAD3( "NOMAD3" ); +static const trait_id trait_NOPAIN( "NOPAIN" ); +static const trait_id trait_PACIFIST( "PACIFIST" ); +static const trait_id trait_PAINRESIST( "PAINRESIST" ); +static const trait_id trait_PAINRESIST_TROGLO( "PAINRESIST_TROGLO" ); +static const trait_id trait_PARAIMMUNE( "PARAIMMUNE" ); +static const trait_id trait_PARKOUR( "PARKOUR" ); +static const trait_id trait_PER_SLIME_OK( "PER_SLIME_OK" ); +static const trait_id trait_PROF_SKATER( "PROF_SKATER" ); +static const trait_id trait_PSYCHOPATH( "PSYCHOPATH" ); +static const trait_id trait_QUILLS( "QUILLS" ); +static const trait_id trait_SAPIOVORE( "SAPIOVORE" ); +static const trait_id trait_SAVANT( "SAVANT" ); +static const trait_id trait_SHELL2( "SHELL2" ); +static const trait_id trait_SLIMY( "SLIMY" ); +static const trait_id trait_SPINES( "SPINES" ); +static const trait_id trait_SPIRITUAL( "SPIRITUAL" ); +static const trait_id trait_STRONGSTOMACH( "STRONGSTOMACH" ); +static const trait_id trait_SUNLIGHT_DEPENDENT( "SUNLIGHT_DEPENDENT" ); +static const trait_id trait_THORNS( "THORNS" ); +static const trait_id trait_THRESH_SPIDER( "THRESH_SPIDER" ); +static const trait_id trait_URSINE_FUR( "URSINE_FUR" ); +static const trait_id trait_VOMITOUS( "VOMITOUS" ); +static const trait_id trait_WATERSLEEP( "WATERSLEEP" ); +static const trait_id trait_WEAKSTOMACH( "WEAKSTOMACH" ); +static const trait_id trait_WEB_SPINNER( "WEB_SPINNER" ); +static const trait_id trait_WEB_WALKER( "WEB_WALKER" ); +static const trait_id trait_WEB_WEAVER( "WEB_WEAVER" ); + +static const std::string flag_SPLINT( "SPLINT" ); + +static const skill_id skill_dodge( "dodge" ); +static const skill_id skill_gun( "gun" ); +static const skill_id skill_swimming( "swimming" ); + +static const bionic_id bio_cqb( "bio_cqb" ); +static const bionic_id bio_ground_sonar( "bio_ground_sonar" ); +static const bionic_id bio_soporific( "bio_soporific" ); +static const bionic_id bio_speed( "bio_speed" ); +static const bionic_id bio_uncanny_dodge( "bio_uncanny_dodge" ); + +stat_mod player::get_pain_penalty() const { stat_mod ret; int pain = get_perceived_pain(); @@ -283,10 +283,10 @@ player::player() } player::~player() = default; - player::player( player && ) = default; - player & player::operator=( player && ) = default; +player::player( player && ) = default; +player &player::operator=( player && ) = default; - void player::normalize() +void player::normalize() { Character::normalize(); @@ -3484,7 +3484,7 @@ bool player::studied_all_recipes( const itype &book ) const return true; } -const recipe_subset & player::get_learned_recipes() const +const recipe_subset &player::get_learned_recipes() const { // Cache validity check if( *_skills != *valid_autolearn_skills ) { From 6a6cb7cbebae2ea08907b1776d19c137504c23d8 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Wed, 3 Jun 2020 22:58:02 -0400 Subject: [PATCH 21/27] Astyle --- src/game.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 8ef4f69d8038a..39377494a9ce0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -164,19 +164,19 @@ class computer; class inventory; #if defined(TILES) - #include "cata_tiles.h" +#include "cata_tiles.h" #endif // TILES #if !(defined(_WIN32) || defined(TILES)) - #include - #include +#include +#include #endif #if defined(_WIN32) - #if 1 // HACK: Hack to prevent reordering of #include "platform_win.h" by IWYU - #include "platform_win.h" - #endif - #include +#if 1 // HACK: Hack to prevent reordering of #include "platform_win.h" by IWYU +#include "platform_win.h" +#endif +#include #endif #define dbg(x) DebugLog((x),D_GAME) << __FILE__ << ":" << __LINE__ << ": " @@ -453,9 +453,9 @@ void game::load_data_from_dir( const std::string &path, const std::string &src, #define MINIMAP_WIDTH 7 #if !(defined(_WIN32) || defined(TILES)) - // in ncurses_def.cpp - void check_encoding(); - void ensure_term_size(); +// in ncurses_def.cpp +void check_encoding(); +void ensure_term_size(); #endif void game::init_ui( const bool resized ) @@ -7192,7 +7192,7 @@ static void centerlistview( const tripoint &active_item_position, int ui_width ) } #if defined(TILES) - #define MAXIMUM_ZOOM_LEVEL 4 +#define MAXIMUM_ZOOM_LEVEL 4 #endif void game::zoom_out() { From 9c75987bd33e48dcadb0cdc613796d1109b31b9c Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Mon, 8 Jun 2020 18:06:41 -0400 Subject: [PATCH 22/27] Jsonize weather spawns --- data/json/monsters/mist.json | 4 +- data/json/regional_map_settings.json | 46 ++++++- data/json/snippets/mist.json | 21 +-- doc/REGION_SETTINGS.md | 73 ++++++++++- src/debug_menu.cpp | 16 +-- src/game.cpp | 1 + src/monattack.cpp | 21 ++- src/options.cpp | 29 ---- src/savegame.cpp | 6 - src/weather.cpp | 189 +++++++++++++-------------- src/weather.h | 14 +- src/weather_gen.cpp | 34 ++++- src/weather_gen.h | 29 +++- 13 files changed, 284 insertions(+), 199 deletions(-) diff --git a/data/json/monsters/mist.json b/data/json/monsters/mist.json index d65c7e00430a3..e2404a2d9800d 100644 --- a/data/json/monsters/mist.json +++ b/data/json/monsters/mist.json @@ -3,7 +3,7 @@ "id": "mon_mist_wraith", "type": "MONSTER", "name": { "str": "Mist wraith" }, - "description": "A wispy figure slightly more solid than the mist surrounding it. It's form is constantly shifting and never distinct.", + "description": "A wispy figure slightly more solid than the mist surrounding it. Its form is constantly shifting and never distinct.", "default_faction": "mist", "species": [ "MIST" ], "volume": "62500 ml", @@ -23,7 +23,7 @@ "id": "mon_mist_spectre", "type": "MONSTER", "name": { "str": "Mist spectre" }, - "description": "A menacing figure slightly more solid than the mist surrounding it. It's shape brings back painful memories.", + "description": "A menacing figure slightly more solid than the mist surrounding it. Its shape brings back painful memories.", "default_faction": "mist", "bodytype": "human", "species": [ "MIST" ], diff --git a/data/json/regional_map_settings.json b/data/json/regional_map_settings.json index 50459927e0842..dabe5cb21b348 100644 --- a/data/json/regional_map_settings.json +++ b/data/json/regional_map_settings.json @@ -916,7 +916,51 @@ "base_acid": 0.0, "base_wind": 3.4, "base_wind_distrib_peaks": 80, - "base_wind_season_variation": 50 + "base_wind_season_variation": 50, + "mist": { + "mist_active": true, + "mist_scaling": 1.0, + "mist_frequency": 7, + "mist_length": 8, + "mist_increases_per": 10, + "mist_thick_threshold": 10, + "mist_stifling_threshold": 20 + }, + "weather_spawn": [ + { + "index": 14, + "hallucinations": true, + "spawns": [ "mon_mist_wraith" ], + "time_between_spawns": 60, + "chance_to_spawn": 75, + "max_spawns": 2, + "max_radius": 8, + "min_radius": 5, + "message": "You feel the mist react to you and shapes form." + }, + { + "index": 15, + "hallucinations": true, + "spawns": [ "mon_mist_wraith", "mon_mist_spectre" ], + "time_between_spawns": 50, + "chance_to_spawn": 75, + "max_spawns": 2, + "max_radius": 6, + "min_radius": 4, + "message": "The mist reacts to you and nightmarish shapes form." + }, + { + "index": 16, + "hallucinations": true, + "spawns": [ "mon_mist_wraith", "mon_mist_spectre", "mon_mist_phantom" ], + "time_between_spawns": 40, + "chance_to_spawn": 75, + "max_spawns": 3, + "max_radius": 4, + "min_radius": 3, + "message": "The mist reflects your darkest thoughts and shapes form." + } + ] }, "overmap_feature_flag_settings": { "clear_blacklist": false, "blacklist": [ ], "clear_whitelist": false, "whitelist": [ ] } } diff --git a/data/json/snippets/mist.json b/data/json/snippets/mist.json index 9e6d56b503387..f1404555a1cda 100644 --- a/data/json/snippets/mist.json +++ b/data/json/snippets/mist.json @@ -1,23 +1,4 @@ [ - { - "type": "snippet", - "category": "mist_summon_wraith", - "text": [ "You feel the mist react to you and a vague shape appears.", "The mist reacts to you and a hazy figure condenses." ] - }, - { - "type": "snippet", - "category": "mist_summon_spectre", - "text": [ "A nightmarish shape appears in the mist.", "A shape forms in the mist reminding you of your lastest nightmare." ] - }, - { - "type": "snippet", - "category": "mist_summon_phantom", - "text": [ - "A shape forms in the mist reminiscent of your childhood bully.", - "A shape forms in the mist reminiscent you of a teacher that hated you.", - "A shape forms in the mist reminiscent you of a friend that betrayed you." - ] - }, { "type": "snippet", "category": "mist_increase_intensity", @@ -62,7 +43,7 @@ "category": "nightmares", "text": [ "You awaken from a nightmare about being eaten alive while your friends applaud.", - "You awaken from a nightmare about being naked in a the artic tundra and freezing to death.", + "You awaken from a nightmare about being naked in a the arctic tundra and freezing to death.", "You awaken from a nightmare about an unseen predator slowly killing you.", "You awaken from a nightmare about killing those you love with your bare hands.", "You awaken from a nightmare about being finally judged for your ill deeds.", diff --git a/doc/REGION_SETTINGS.md b/doc/REGION_SETTINGS.md index 4781f29931c00..ead00f6e96223 100644 --- a/doc/REGION_SETTINGS.md +++ b/doc/REGION_SETTINGS.md @@ -494,7 +494,8 @@ The **weather** section defines the base weather attributes used for the region. | `base_wind` | Base wind for the region in mph units. Roughly the yearly average. | | `base_wind_distrib_peaks` | How high the wind peaks can go. Higher values produce windier days. | | `base_wind_season_variation` | How the wind varies with season. Lower values produce more variation | - +| `mist` | Section defining mist, if this is missing mist is disabled +| `weather_spawn` | Section defining if monsters will spawn in weather | ### Example ```json @@ -512,6 +513,76 @@ The **weather** section defines the base weather attributes used for the region. } ``` +## Mist + +The **mist** section defines the base mist attributes used for the region. + +### Fields + +| Identifier | Description | +| ------------------------------ | --------------------------------------------------------------------- | +| `mist_active` | bool defining if the mist is enabled | +| `mist_scaling` | float that affects how fast the mist grows more powerful with each appearance, at 0 the mist will not grow stronger each time | +| `mist_frequency` | the average number of days between mist appearances, the actual value is random between .5 and 1.5 this value minus scaling effects | +| `mist_length` | the average number of hours the mist will last, the actual value is random between .7 and 1.3 this plus mist scaling effects | +| `mist_increases_per` | the number of times the mist will increase its intensity per instance | +| `mist_thick_threshold` | the intensity at which the mist will become thick instead of regular | + +### Example + +```json +{ + "mist": { + "mist_active": true, + "mist_scaling": 1.5, + "mist_frequency": 3, + "mist_length": 12, + "mist_increases_per": 10, + "mist_thick_threshold": 10, + "mist_stifling_threshold": 20 + }, +} +``` + + +## Weather Spawn + +The **weather_spawn** section defines creatures that will spawn in weather. + +### Fields + +| Identifier | Description | +| ------------------------------ | --------------------------------------------------------------------- | +| `index` | the index of the weather in the enum weather_type found in weather.h | +| `hallucinations` | bool determining whether the weather should spawn hallucinations for nearby creatures, if true this will be treated as another spawn | +| `spawns` | an array of the monster_ids of every monster you want to spawn, one will be chosen at random every spawn | +| `time_between_spawns` | the number of seconds between monster spawns | +| `chance_to_spawn` | the percent chance a monster will spawn for each spawn attempt in max_spawns | +| `max_spawns` | the maximum number of monsters/hallucinations that will spawn | +| `max_radius` | the maximum distance monsters/hallucinations will spawn from the target | +| `min_radius` | the closest distance monsters/hallucinations will spawn to the target | +| `message` | Message to be displayed if at least one non hallucination spawns | + +### Example + +```json +{ + "weather_spawn": [ + { + "index": 14, + "hallucinations": true, + "spawns": [ "mon_mist_wraith" ], + "seconds_between_spawns": 60, + "chance_to_spawn": 75, + "max_spawns": 2, + "max_radius": 8, + "min_radius": 4, + "message": "You feel the mist react to you and shapes form." + } + ] +} +``` + ## Overmap Feature Flag Settings The **overmap_feature_flag_settings** section defines operations that operate on the flags assigned to overmap features. diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index dff3d1738885d..371f586616387 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1413,11 +1413,9 @@ void debug() uilist smenu; smenu.addentry( 0, true, 'i', "%s: %d", _( "Intensity" ), g->weather.mist_intensity ); smenu.addentry( 1, true, 'm', "%s: %d", _( "Mist Instances" ), g->weather.mist_instances ); - smenu.addentry( 4, true, 't', "%s: %d", _( "Intensity Increase Time" ), + smenu.addentry( 2, true, 't', "%s: %d", _( "Intensity Increase Time" ), to_seconds( g->weather.mist_intensity_increase_time ) ); - smenu.addentry( 5, true, 'w', "%s: %d", _( "Spawn Time" ), - to_seconds( g->weather.mist_spawn_time ) ); - smenu.addentry( 6, true, 'w', "%s: %s", _( "Next Instance" ), + smenu.addentry( 3, true, 'w', "%s: %s", _( "Next Instance" ), to_string( g->weather.mist_next_instance ) ); smenu.query(); @@ -1434,19 +1432,13 @@ void debug() g->weather.mist_instances = value; } break; - case 4: + case 2: if( query_int( value, _( "Set intensity increase time to how many seconds? Currently: %d" ), to_string( g->weather.mist_intensity_increase_time ) ) ) { g->weather.mist_intensity_increase_time = time_duration::from_seconds( value ); } break; - case 5: - if( query_int( value, _( "Set spawn time to how many seconds? Currently: %d" ), - to_string( g->weather.mist_spawn_time ) ) ) { - g->weather.mist_spawn_time = time_duration::from_seconds( value ); - } - break; - case 6: + case 3: if( query_int( value, _( "Set next instance to minutes in future? Currently: %s" ), to_string( g->weather.mist_next_instance - calendar::turn ) ) ) { g->weather.mist_next_instance = calendar::turn + time_duration::from_minutes( value ); diff --git a/src/game.cpp b/src/game.cpp index 39377494a9ce0..15908e957f9dc 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1563,6 +1563,7 @@ bool game::do_turn() if( get_levz() >= 0 && !u.is_underwater() ) { do_rain( weather.weather ); + handle_weather_summoning( weather.weather ); weather::effect( weather.weather )(); } diff --git a/src/monattack.cpp b/src/monattack.cpp index 04b16eb8497a9..7949336da12dc 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -5840,9 +5840,10 @@ bool mattack::dissipate_drain( monster *z ) } z->die( z ); - float mist_scaling = get_option( "MIST_SCALING" ); + float mist_scaling = g->weather.get_cur_weather_gen().mist_scaling; int fatigue_drain_amount = 25 + ( mist_scaling * g->weather.mist_instances ); - int stamina_drain_amount = 500 + ( 50 * mist_scaling * g->weather.mist_instances ); + int stamina_drain_amount = 500 + ( 50 * mist_scaling * + g->weather.mist_instances ); foe->mod_fatigue( fatigue_drain_amount ); foe->mod_stamina( -stamina_drain_amount ); foe->add_msg_if_player( m_bad, @@ -5858,9 +5859,8 @@ bool mattack::dissipate_nightmares( monster *z ) } z->die( z ); - float mist_scaling = get_option( "MIST_SCALING" ); - time_duration effect_length = 10_hours + ( 5 * time_duration::from_minutes( mist_scaling * - g->weather.mist_instances ) ); + time_duration effect_length = 10_hours + ( 5 * time_duration::from_minutes( + g->weather.get_cur_weather_gen().mist_scaling * g->weather.mist_instances ) ); foe->add_effect( effect_disrupted_sleep, effect_length ); foe->add_effect( effect_nightmares, effect_length ); foe->add_msg_if_player( m_bad, @@ -5876,9 +5876,8 @@ bool mattack::dissipate_force_scream( monster *z ) } z->die( z ); - float mist_scaling = get_option( "MIST_SCALING" ); - time_duration effect_length = 1_hours + time_duration::from_minutes( mist_scaling * - g->weather.mist_instances ); + time_duration effect_length = 1_hours + time_duration::from_minutes( + g->weather.get_cur_weather_gen().mist_scaling * g->weather.mist_instances ); foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, effect_length ); foe->add_msg_if_player( m_bad, _( "The %s surfaces an intense memory, that feels like your own." ), @@ -5899,9 +5898,9 @@ bool mattack::dissipate_incorporeal( monster *z ) } z->die( z ); - float mist_scaling = get_option( "MIST_SCALING" ); - time_duration effect_length = 2_seconds + ( .1 * time_duration::from_seconds( mist_scaling * - g->weather.mist_instances ) ); + time_duration effect_length = 2_seconds + ( .1 * time_duration::from_seconds( + g->weather.get_cur_weather_gen().mist_scaling * g->weather.mist_instances ) ); + foe->add_effect( effect_incorporeal, effect_length ); foe->add_msg_if_player( m_bad, _( "The %s robs you of your form." ), z->name() ); return true; diff --git a/src/options.cpp b/src/options.cpp index 03e23c4a4ff37..f79bb6ff1c621 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2160,35 +2160,6 @@ void options_manager::add_options_world_default() add_empty_line(); - add( "MIST_ACTIVE", "world_default", translate_marker( "Mist active." ), - translate_marker( "Mist is active and will challenge player." ), - false - ); - - add( "MIST_SCALING", "world_default", translate_marker( "Mist scaling." ), - translate_marker( "Determines how fast the mist increases strength." ), - 0.0, 10.0, 1.0, 0.1 - ); - - add( "MIST_INSTANCE_TIME", "world_default", translate_marker( "Mist time between apperances." ), - translate_marker( "Average number of days between mist apperances." ), - 1, 50, 7 - ); - - add( "MIST_SPAWN_TIME", "world_default", translate_marker( "Mist time between spawns." ), - translate_marker( "Average number of seconds between mist spawns." ), - 1, 3600, 60 - ); - - add( "MIST_LENGTH", "world_default", translate_marker( "Length mist appears for." ), - translate_marker( "Average number of hours mist lasts." ), - 1, 50, 5 - ); - - get_option( "MIST_SCALING" ).setPrerequisite( "MIST_ACTIVE" ); - get_option( "MIST_INSTANCE_TIME" ).setPrerequisite( "MIST_ACTIVE" ); - get_option( "MIST_LENGTH" ).setPrerequisite( "MIST_ACTIVE" ); - get_option( "MIST_SPAWN_TIME" ).setPrerequisite( "MIST_ACTIVE" ); } void options_manager::add_options_debug() diff --git a/src/savegame.cpp b/src/savegame.cpp index eccdd69817271..64ba3224affcb 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -1657,12 +1657,9 @@ void game::unserialize_master( std::istream &fin ) JsonObject w = jsin.get_object(); w.read( "lightning", weather.lightning_active ); w.read( "mist_intensity", weather.mist_intensity ); - w.read( "mist_intensity_increase_per_instance", weather.mist_intensity_increase_per_instance ); w.read( "mist_instances", weather.mist_instances ); w.read( "mist_next_instance", weather.mist_next_instance ); w.read( "mist_intensity_increase_time", weather.mist_intensity_increase_time ); - w.read( "mist_thick_threshold", weather.mist_thick_threshold ); - w.read( "mist_stifling_threshold", weather.mist_stifling_threshold ); } else { // silently ignore anything else jsin.skip_value(); @@ -1702,12 +1699,9 @@ void game::serialize_master( std::ostream &fout ) json.start_object(); json.member( "lightning", weather.lightning_active ); json.member( "mist_intensity", weather.mist_intensity ); - json.member( "mist_intensity_increase_per_instance", weather.mist_intensity_increase_per_instance ); json.member( "mist_instances", weather.mist_instances ); json.member( "mist_next_instance", weather.mist_next_instance ); json.member( "mist_intensity_increase_time", weather.mist_intensity_increase_time ); - json.member( "mist_thick_threshold", weather.mist_thick_threshold ); - json.member( "mist_stifling_threshold", weather.mist_stifling_threshold ); json.end_object(); json.end_object(); diff --git a/src/weather.cpp b/src/weather.cpp index 29e13af38dc05..360f35b3dd3fd 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -448,6 +448,80 @@ void do_rain( weather_type const w ) wet_player( wetness ); } +void handle_weather_summoning( weather_type const w ) +{ + const weather_generator &weather_gen = g->weather.get_cur_weather_gen(); + Character &target_character = g->u;//todo npcs, also + bool creature_spawned = false; + std::map::const_iterator current_weather_spawn_info = + weather_gen.weather_spawn_info.find( w ); + //first make sure we have spawn info for this weather + if( current_weather_spawn_info != weather_gen.weather_spawn_info.end() ) { + //only spawn based on the specified time gap and while the target is in the weather + if( calendar::once_every( current_weather_spawn_info->second.time_between_spawns ) && + is_creature_outside( target_character ) ) { + mtype_id monster_id; + //loop through a number of times equal to the max spawns to give us enough spawn chances + for( int monsters_spawned = 0; monsters_spawned < current_weather_spawn_info->second.max_spawns; + monsters_spawned++ ) { + bool is_hallucination = false; + //check if we pass the spawn chance + if( rng( 1, 100 ) <= current_weather_spawn_info->second.chance_to_spawn ) { + //handle choosing hallucinations if they are enabled and choose a random spawn to create + int lower_bound = ( current_weather_spawn_info->second.hallucinations ) ? -1 : 0; + int monster_index = rng( lower_bound, current_weather_spawn_info->second.spawns.size() - 1 ); + if( monster_index == -1 ) { + //grab a random nearby outdoor non mist hostile creature to create a hallucination of + Creature *copy = g->get_creature_if( [&target_character]( const Creature & critter ) -> bool { + bool in_mist = is_creature_outside( critter ); + bool not_self = target_character.pos() != critter.pos(); + bool in_range = std::round( rl_dist_exact( target_character.pos(), critter.pos() ) ) <= 30; + bool valid_species = !critter.in_species( species_MIST ); + bool valid_target = target_character.attitude_to( critter ) == Creature::Attitude::A_HOSTILE; + return in_mist && not_self && in_range && valid_species && valid_target; + } ); + monster *copy_monster = dynamic_cast( copy ); + if( copy_monster != nullptr ) { + monster_id = copy_monster->type->id; + is_hallucination = true; + } + } + //we already have a monster if its a hallucination, otherwise grab one now + if( !is_hallucination ) { + if( monster_index == -1 ) { + //we couldn't find a creature to copy so choose a spawn randomly again + monster_index = rng( 0, current_weather_spawn_info->second.spawns.size() - 1 ); + } + monster_id = mtype_id( current_weather_spawn_info->second.spawns[monster_index] ); + } + + tripoint target_point; + bool found_location = false; + int radius = current_weather_spawn_info->second.max_radius; + //find a legal outdoor place to spawn based on the specified radius, + //rather than try to be smart we just try a bunch of random points and use the first one that works, it none do then no spawn + for( int attempts = 0; attempts < 15; attempts++ ) { + target_point = g->u.pos() + tripoint( rng( -radius, radius ), rng( -radius, radius ), 0 ); + if( game::can_place_monster( monster_id, target_point ) && g->m.is_outside( target_point ) && + rl_dist( target_point, g->u.pos() ) > current_weather_spawn_info->second.min_radius ) { + found_location = true; + break; + } + } + + if( found_location && is_hallucination ) { + g->spawn_hallucination( target_point, monster_id ); + } else if( found_location && g->place_critter_at( monster_id, target_point ) != nullptr ) { + creature_spawned = true; + } + } + } + if( creature_spawned ) { + g->u.add_msg_if_player( m_bad, "%s", current_weather_spawn_info->second.message ); + } + } + } +} void weather_effect::none() { glare( sun_intensity::normal ); @@ -471,84 +545,6 @@ void weather_effect::snowstorm() void weather_effect::mist() { - Character &target_character = g->u;//todo npcs, also - if( calendar::once_every( g->weather.mist_spawn_time ) && - is_creature_outside( target_character ) ) { - int mist_type = 0; - if( g->weather.mist_intensity > 0 && - g->weather.mist_intensity <= g->weather.mist_thick_threshold ) { - mist_type = 1; - } else if( g->weather.mist_intensity > g->weather.mist_thick_threshold && - g->weather.mist_intensity <= g->weather.mist_stifling_threshold ) { - mist_type = 2; - } else if( g->weather.mist_intensity > g->weather.mist_stifling_threshold ) { - mist_type = 3; - } - - int monsters_to_spawn = std::max( 1, g->weather.mist_intensity / 5 ); - for( int monsters_spawned = 0; monsters_spawned < monsters_to_spawn; monsters_spawned++ ) { - mtype_id monster_id = mon_mist_wraith; - std::string category = "mist_summon_wraith"; - bool is_hallucination = false; - - int rand = rng( 0, mist_type ); - switch( rand ) { - case 0: { - //grab a random nearby outdoor non mist hostile creature to create a hallucination of - Creature *copy = g->get_creature_if( [&target_character]( const Creature & critter ) -> bool { - bool in_mist = is_creature_outside( critter ); - bool not_self = target_character.pos() != critter.pos(); - bool in_range = std::round( rl_dist_exact( target_character.pos(), critter.pos() ) ) <= 30; - bool valid_species = !critter.in_species( species_MIST ); - bool valid_target = target_character.attitude_to( critter ) == Creature::Attitude::A_HOSTILE; - - return in_mist && not_self && in_range && valid_species && valid_target; - } ); - monster *copy_monster = dynamic_cast( copy ); - if( copy_monster != nullptr ) { - monster_id = copy_monster->type->id; - is_hallucination = true; - } - break; - } - case 1: - monster_id = mon_mist_wraith; - category = "mist_summon_wraith"; - break; - case 2: - monster_id = mon_mist_spectre; - category = "mist_summon_spectre"; - break; - case 3: - monster_id = mon_mist_phantom; - category = "mist_summon_phantom"; - break; - default: - debugmsg( "Random numbers gone wrong!" ); - break; - } - - tripoint target_point; - bool found_location = false; - int radius = 6 - mist_type; - for( int attempts = 0; attempts < 15; attempts++ ) { - target_point = g->u.pos() + tripoint( rng( -radius, radius ), rng( -radius, radius ), 0 ); - if( game::can_place_monster( monster_id, target_point ) && g->m.is_outside( target_point ) && - rl_dist( target_point, g->u.pos() ) > 2 ) { - found_location = true; - break; - } - } - if( found_location && is_hallucination ) { - g->spawn_hallucination( target_point, monster_id ); - } else if( found_location && g->place_critter_at( monster_id, target_point ) != nullptr ) { - g->u.add_msg_if_player( m_bad, "%s", - SNIPPET.random_from_category( category ).value_or( translation() ) ); - } - } - } - - if( calendar::once_every( g->weather.mist_intensity_increase_time ) ) { g->weather.increase_mist_intensity(); } @@ -1074,7 +1070,6 @@ void weather_manager::initialize() nextweather = calendar::turn; set_mist_length(); set_next_mist_time(); - set_mist_spawn_time(); temperature = SPRING_TEMPERATURE; update_weather(); } @@ -1171,47 +1166,41 @@ void weather_manager::clear_temp_cache() void weather_manager::set_next_mist_time() { - float mist_scaling = get_option( "MIST_SCALING" ); - int days = get_option( "MIST_INSTANCE_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); + const weather_generator &weather_gen = get_cur_weather_gen(); + int days = weather_gen.mist_frequency - ( weather_gen.mist_scaling * ( mist_instances / 30 ) ); mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, 1.5 * days ) ) + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); } -void weather_manager::set_mist_spawn_time() -{ - float mist_scaling = get_option( "MIST_SCALING" ); - int seconds = get_option( "MIST_SPAWN_TIME" ) - ( mist_scaling * ( mist_instances / 10 ) ); - mist_spawn_time = time_duration::from_seconds( rng( .5 * seconds, 1.5 * seconds ) ); -} - //calculates the total mist length then breaks that into pieces void weather_manager::set_mist_length() { - float mist_scaling = get_option( "MIST_SCALING" ); - int hours = get_option( "MIST_LENGTH" ) + ( mist_scaling * ( mist_instances / 5 ) ); + const weather_generator &weather_gen = get_cur_weather_gen(); + int hours = weather_gen.mist_length + ( weather_gen.mist_scaling * ( mist_instances / 5 ) ); mist_intensity_increase_time = ( time_duration::from_hours( rng( .7 * hours, 1.3 * hours ) ) + time_duration::from_seconds( rng( 0, to_seconds( 1_hours ) ) ) ) - / mist_intensity_increase_per_instance; + / weather_gen.mist_increases_per; } void weather_manager::increase_mist_intensity() { - if( !get_option( "MIST_ACTIVE" ) ) { + const weather_generator &weather_gen = get_cur_weather_gen(); + if( !weather_gen.mist_active ) { return; } - float mist_scaling = get_option( "MIST_SCALING" ); - int mist_min_intensity = 1 + ( mist_scaling * mist_instances ); - int mist_max_intensity = 1 + mist_intensity_increase_per_instance + ( mist_scaling * - mist_instances ); + int mist_min_intensity = 1 + ( weather_gen.mist_scaling * mist_instances ); + int mist_max_intensity = 1 + weather_gen.mist_increases_per + + ( weather_gen.mist_scaling * mist_instances ); if( mist_intensity < mist_min_intensity ) { mist_intensity = mist_min_intensity; set_mist_length(); set_next_mist_time(); - set_mist_spawn_time(); - g->u.add_msg_if_player( m_bad, "%s", - SNIPPET.random_from_category( "mist_arrives" ).value_or( translation() ) ); + if( is_creature_outside( g->u ) ) { + g->u.add_msg_if_player( m_bad, "%s", + SNIPPET.random_from_category( "mist_arrives" ).value_or( translation() ) ); + } } else if( mist_intensity < mist_max_intensity ) { mist_intensity++; if( is_creature_outside( g->u ) ) { @@ -1220,8 +1209,8 @@ void weather_manager::increase_mist_intensity() } } else { mist_intensity = 0; + mist_instances++; if( is_creature_outside( g->u ) ) { - mist_instances++; g->u.add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( "mist_leaves" ).value_or( translation() ) ); } diff --git a/src/weather.h b/src/weather.h index 66e6c8055321f..49f78d0defff6 100644 --- a/src/weather.h +++ b/src/weather.h @@ -56,9 +56,9 @@ enum weather_type : int { WEATHER_FLURRIES, //!< Light snow WEATHER_SNOW, //!< snow glare effects WEATHER_SNOWSTORM, //!< sight penalties - WEATHER_MIST, //!< spawns mist monsters, sight penalties + WEATHER_MIST, //!< spawns mist monsters, sight penalties WEATHER_THICK_MIST, //!< spawns mist monsters, sight penalties - WEATHER_STIFLING_MIST, //!< spawns mist monsters, sight penalties + WEATHER_STIFLING_MIST,//!< spawns mist monsters, sight penalties NUM_WEATHER_TYPES //!< Sentinel value }; @@ -71,6 +71,7 @@ enum precip_class : int { double precip_mm_per_hour( precip_class p ); void do_rain( weather_type w ); +void handle_weather_summoning( weather_type w ); /** * Weather animation class. @@ -257,20 +258,12 @@ class weather_manager //current power of mist int mist_intensity = 0; - //amount mist intensity increases before ending - int mist_intensity_increase_per_instance = 10; //number of times the mist has happened, scales mist difficulty int mist_instances = 0; //next time mist will appear time_point mist_next_instance = calendar::turn;//next time mist will appear //time between mist intensity increases, changes every instance time_duration mist_intensity_increase_time = 10_minutes; - //time between monster spawns, changes every instance - time_duration mist_spawn_time = 5_minutes; - //the intensity at which mist switches to thick - int mist_thick_threshold = 10; - //the intensity at which mist switches to stifling - int mist_stifling_threshold = 20; // Cached weather data pimpl weather_precise; @@ -287,7 +280,6 @@ class weather_manager int get_temperature( const tripoint &location ); void clear_temp_cache(); void set_next_mist_time(); - void set_mist_spawn_time(); void set_mist_length(); //increases mist intensity or begins it at min intensity if not started void increase_mist_intensity(); diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 33dc07939e811..fada0caf5243b 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -183,14 +183,14 @@ weather_type weather_generator::get_weather_conditions( const tripoint &location weather_type weather_generator::get_weather_conditions( const w_point &w ) const { - if( get_option( "MIST_ACTIVE" ) ) { + if( mist_active ) { if( g->weather.mist_intensity > 0 && - g->weather.mist_intensity <= g->weather.mist_thick_threshold ) { + g->weather.mist_intensity <= mist_thick_threshold ) { return WEATHER_MIST; - } else if( g->weather.mist_intensity > g->weather.mist_thick_threshold && - g->weather.mist_intensity <= g->weather.mist_stifling_threshold ) { + } else if( g->weather.mist_intensity > mist_thick_threshold && + g->weather.mist_intensity <= mist_stifling_threshold ) { return WEATHER_THICK_MIST; - } else if( g->weather.mist_intensity > g->weather.mist_stifling_threshold ) { + } else if( g->weather.mist_intensity > mist_stifling_threshold ) { return WEATHER_STIFLING_MIST; } } @@ -348,5 +348,29 @@ weather_generator weather_generator::load( const JsonObject &jo ) ret.summer_humidity_manual_mod = jo.get_int( "summer_humidity_manual_mod", 0 ); ret.autumn_humidity_manual_mod = jo.get_int( "autumn_humidity_manual_mod", 0 ); ret.winter_humidity_manual_mod = jo.get_int( "winter_humidity_manual_mod", 0 ); + + const JsonObject mist = jo.get_object( "mist" ); + ret.mist_active = mist.get_bool( "mist_active", false ); + ret.mist_scaling = mist.get_float( "mist_scaling", 1.0 ); + ret.mist_frequency = mist.get_int( "mist_frequency", 7 ); + ret.mist_increases_per = mist.get_int( "mist_increases_per", 10 ); + ret.mist_thick_threshold = mist.get_int( "mist_thick_threshold", 10 ); + ret.mist_stifling_threshold = mist.get_int( "mist_stifling_threshold", 20 ); + ret.mist_length = mist.get_int( "mist_length", 8 ); + + for( const JsonObject info : jo.get_array( "weather_spawn" ) ) { + int index = info.get_int( "index" ); + ret.weather_spawn_info[index] = { + info.get_bool( "hallucinations", false ), + info.get_string_array( "spawns" ), + time_duration::from_seconds( info.get_int( "time_between_spawns", 60 ) ), + info.get_int( "chance_to_spawn", 100 ), + info.get_int( "max_spawns", 1 ), + info.get_int( "max_radius", 10 ), + info.get_int( "min_radius", 1 ), + _( info.get_string( "message", "" ) ) + }; + } + return ret; } diff --git a/src/weather_gen.h b/src/weather_gen.h index 9b269ec82cced..43f79f16d5d0a 100644 --- a/src/weather_gen.h +++ b/src/weather_gen.h @@ -3,7 +3,7 @@ #define CATA_SRC_WEATHER_GEN_H #include - +#include #include "calendar.h" struct tripoint; @@ -21,6 +21,17 @@ struct w_point { bool acidic = false; }; +struct weather_spawn_info { + bool hallucinations; + std::vector spawns; + time_duration time_between_spawns; + int chance_to_spawn; + int max_spawns; + int max_radius; + int min_radius; + std::string message; +}; + class weather_generator { public: @@ -46,6 +57,22 @@ class weather_generator //How much the wind folows seasonal variation ( lower means more change ) int base_wind_season_variation = 0; static int current_winddir; + //what monsters to spawn for the weather + std::map weather_spawn_info; + //Regional settings can disable mist in a region + bool mist_active = true; + //increase mist difficulty + float mist_scaling = 1.0; + //average number of days between mist + int mist_frequency = 7; + //number of hours on average the mist lasts + int mist_length = 7; + //amount mist intensity increases before ending + int mist_increases_per = 10; + //the intensity at which mist switches to thick + int mist_thick_threshold = 10; + //the intensity at which mist switches to stifling + int mist_stifling_threshold = 20; weather_generator(); From e0aa19e28043962e92c2e4a9cd21fb47d08317c8 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Mon, 8 Jun 2020 18:10:38 -0400 Subject: [PATCH 23/27] Fix name issue --- src/weather.cpp | 4 ++-- src/weather_gen.cpp | 2 +- src/weather_gen.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/weather.cpp b/src/weather.cpp index 360f35b3dd3fd..0da3e9027b208 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -454,9 +454,9 @@ void handle_weather_summoning( weather_type const w ) Character &target_character = g->u;//todo npcs, also bool creature_spawned = false; std::map::const_iterator current_weather_spawn_info = - weather_gen.weather_spawn_info.find( w ); + weather_gen.weather_spawn_info_map.find( w ); //first make sure we have spawn info for this weather - if( current_weather_spawn_info != weather_gen.weather_spawn_info.end() ) { + if( current_weather_spawn_info != weather_gen.weather_spawn_info_map.end() ) { //only spawn based on the specified time gap and while the target is in the weather if( calendar::once_every( current_weather_spawn_info->second.time_between_spawns ) && is_creature_outside( target_character ) ) { diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index fada0caf5243b..144796bb82ce2 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -360,7 +360,7 @@ weather_generator weather_generator::load( const JsonObject &jo ) for( const JsonObject info : jo.get_array( "weather_spawn" ) ) { int index = info.get_int( "index" ); - ret.weather_spawn_info[index] = { + ret.weather_spawn_info_map[index] = { info.get_bool( "hallucinations", false ), info.get_string_array( "spawns" ), time_duration::from_seconds( info.get_int( "time_between_spawns", 60 ) ), diff --git a/src/weather_gen.h b/src/weather_gen.h index 43f79f16d5d0a..841ff6da81068 100644 --- a/src/weather_gen.h +++ b/src/weather_gen.h @@ -58,7 +58,7 @@ class weather_generator int base_wind_season_variation = 0; static int current_winddir; //what monsters to spawn for the weather - std::map weather_spawn_info; + std::map weather_spawn_info_map; //Regional settings can disable mist in a region bool mist_active = true; //increase mist difficulty From 210f5c174bd1fe1432de9a8080b61e30d4bc5744 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Mon, 8 Jun 2020 18:14:39 -0400 Subject: [PATCH 24/27] Linted json --- data/json/regional_map_settings.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/json/regional_map_settings.json b/data/json/regional_map_settings.json index dabe5cb21b348..09772bf1f8061 100644 --- a/data/json/regional_map_settings.json +++ b/data/json/regional_map_settings.json @@ -930,7 +930,7 @@ { "index": 14, "hallucinations": true, - "spawns": [ "mon_mist_wraith" ], + "spawns": [ "mon_mist_wraith" ], "time_between_spawns": 60, "chance_to_spawn": 75, "max_spawns": 2, @@ -941,18 +941,18 @@ { "index": 15, "hallucinations": true, - "spawns": [ "mon_mist_wraith", "mon_mist_spectre" ], + "spawns": [ "mon_mist_wraith", "mon_mist_spectre" ], "time_between_spawns": 50, "chance_to_spawn": 75, "max_spawns": 2, "max_radius": 6, "min_radius": 4, - "message": "The mist reacts to you and nightmarish shapes form." + "message": "The mist reacts to you and nightmarish shapes form." }, { "index": 16, "hallucinations": true, - "spawns": [ "mon_mist_wraith", "mon_mist_spectre", "mon_mist_phantom" ], + "spawns": [ "mon_mist_wraith", "mon_mist_spectre", "mon_mist_phantom" ], "time_between_spawns": 40, "chance_to_spawn": 75, "max_spawns": 3, From 55cdbc4e82e44af479d648b78733639074621341 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Mon, 8 Jun 2020 19:06:17 -0400 Subject: [PATCH 25/27] Build fix --- src/weather_gen.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/weather_gen.h b/src/weather_gen.h index 841ff6da81068..2fbaa2989d6b1 100644 --- a/src/weather_gen.h +++ b/src/weather_gen.h @@ -4,6 +4,7 @@ #include #include +#include #include "calendar.h" struct tripoint; From e8d36fe29d9d8be164195edb4d3255f57976f221 Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Mon, 8 Jun 2020 20:55:16 -0400 Subject: [PATCH 26/27] Appease clang --- src/character.cpp | 4 ++-- src/monattack.cpp | 4 ++-- src/weather.cpp | 6 +++--- src/weather_gen.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index fbadbd4014009..a71581ae8f8b8 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -368,7 +368,7 @@ static const std::string flag_USE_UPS( "USE_UPS" ); static const mtype_id mon_player_blob( "mon_player_blob" ); static const mtype_id mon_shadow_snake( "mon_shadow_snake" ); -const morale_type MORALE_NIGHTMARE( "morale_nightmare" ); +const morale_type morale_nightmare( "morale_nightmare" ); namespace io { @@ -7889,7 +7889,7 @@ void Character::wake_up() if( has_effect( effect_nightmares ) ) { add_msg_if_player( m_bad, "%s", SNIPPET.random_from_category( "nightmares" ).value_or( translation() ) ); - add_morale( MORALE_NIGHTMARE, -5, -15, 30_minutes ); + add_morale( morale_nightmare, -5, -15, 30_minutes ); } } diff --git a/src/monattack.cpp b/src/monattack.cpp index 7949336da12dc..25e723ef3cc64 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -205,7 +205,7 @@ static const mtype_id mon_zombie_gasbag_impaler( "mon_zombie_gasbag_impaler" ); static const mtype_id mon_zombie_jackson( "mon_zombie_jackson" ); static const mtype_id mon_zombie_skeltal_minion( "mon_zombie_skeltal_minion" ); -const morale_type MORALE_TRAUMATIC_MEMORY( "morale_traumatic_memory" ); +const morale_type morale_traumatic_memory( "morale_traumatic_memory" ); static const bionic_id bio_uncanny_dodge( "bio_uncanny_dodge" ); @@ -5878,7 +5878,7 @@ bool mattack::dissipate_force_scream( monster *z ) time_duration effect_length = 1_hours + time_duration::from_minutes( g->weather.get_cur_weather_gen().mist_scaling * g->weather.mist_instances ); - foe->add_morale( MORALE_TRAUMATIC_MEMORY, -10, -15, effect_length ); + foe->add_morale( morale_traumatic_memory, -10, -15, effect_length ); foe->add_msg_if_player( m_bad, _( "The %s surfaces an intense memory, that feels like your own." ), z->name() ); diff --git a/src/weather.cpp b/src/weather.cpp index 0da3e9027b208..f764d2039eb1a 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -517,7 +517,7 @@ void handle_weather_summoning( weather_type const w ) } } if( creature_spawned ) { - g->u.add_msg_if_player( m_bad, "%s", current_weather_spawn_info->second.message ); + g->u.add_msg_if_player( m_bad, _( current_weather_spawn_info->second.message ) ); } } } @@ -1167,7 +1167,7 @@ void weather_manager::clear_temp_cache() void weather_manager::set_next_mist_time() { const weather_generator &weather_gen = get_cur_weather_gen(); - int days = weather_gen.mist_frequency - ( weather_gen.mist_scaling * ( mist_instances / 30 ) ); + float days = weather_gen.mist_frequency - ( weather_gen.mist_scaling * ( mist_instances / 30.0 ) ); mist_next_instance = calendar::turn + time_duration::from_days( rng( .5 * days, 1.5 * days ) ) + time_duration::from_seconds( rng( 0, to_seconds( 24_hours ) ) ); } @@ -1176,7 +1176,7 @@ void weather_manager::set_next_mist_time() void weather_manager::set_mist_length() { const weather_generator &weather_gen = get_cur_weather_gen(); - int hours = weather_gen.mist_length + ( weather_gen.mist_scaling * ( mist_instances / 5 ) ); + float hours = weather_gen.mist_length + ( weather_gen.mist_scaling * ( mist_instances / 5.0 ) ); mist_intensity_increase_time = ( time_duration::from_hours( rng( .7 * hours, 1.3 * hours ) ) + time_duration::from_seconds( rng( 0, to_seconds( 1_hours ) ) ) ) / weather_gen.mist_increases_per; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 144796bb82ce2..7328a4ebfaf73 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -368,7 +368,7 @@ weather_generator weather_generator::load( const JsonObject &jo ) info.get_int( "max_spawns", 1 ), info.get_int( "max_radius", 10 ), info.get_int( "min_radius", 1 ), - _( info.get_string( "message", "" ) ) + info.get_string( "message", "" ) }; } From 042fb6d8f8534943dfc97e43e1da6e8412c5630b Mon Sep 17 00:00:00 2001 From: Ramza13 <52087122+Ramza13@users.noreply.github.com> Date: Tue, 9 Jun 2020 08:25:45 -0400 Subject: [PATCH 27/27] Fix clang --- src/character.cpp | 2 +- src/monattack.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index a71581ae8f8b8..655db3d8eeaa9 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -368,7 +368,7 @@ static const std::string flag_USE_UPS( "USE_UPS" ); static const mtype_id mon_player_blob( "mon_player_blob" ); static const mtype_id mon_shadow_snake( "mon_shadow_snake" ); -const morale_type morale_nightmare( "morale_nightmare" ); +static const morale_type morale_nightmare( "morale_nightmare" ); namespace io { diff --git a/src/monattack.cpp b/src/monattack.cpp index 25e723ef3cc64..8e4fdbe5ab3c8 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -205,7 +205,7 @@ static const mtype_id mon_zombie_gasbag_impaler( "mon_zombie_gasbag_impaler" ); static const mtype_id mon_zombie_jackson( "mon_zombie_jackson" ); static const mtype_id mon_zombie_skeltal_minion( "mon_zombie_skeltal_minion" ); -const morale_type morale_traumatic_memory( "morale_traumatic_memory" ); +static const morale_type morale_traumatic_memory( "morale_traumatic_memory" ); static const bionic_id bio_uncanny_dodge( "bio_uncanny_dodge" );