From dd1534db932e0a1bf28da3a0ea32c46d31c15eb9 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Sun, 9 Apr 2023 12:50:24 +0200 Subject: [PATCH 01/11] initial commit --- data/json/weather_type.json | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index def0900b16d6f..47d22245c48e4 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -270,6 +270,76 @@ ] } }, + { + "id": "mist", + "type": "weather_type", + "name": "Mist", + "color": "light_gray", + "map_color": "dark_gray_white", + "sym": "~", + "ranged_penalty": 3, + "sight_penalty": 1.2, + "light_modifier": -20, + "sun_multiplier": 0.3, + "sound_attn": 0, + "dangerous": false, + "precip": "light", + "rains": false, + "sound_category": "silent", + "priority": 30, + "required_weathers": [ "clear" ], + "condition": { + "and": [ + { "compare_num": [ { "weather": "humidity" }, ">=", { "const": 95 } ] }, + { "compare_num": [ { "weather": "windpower" }, ">=", { "const": 11 } ] }, + { "compare_num": [ { "weather": "windpower" }, "<", { "const": 0 } ] }, + { "compare_num": [ { "global_val": "var", "var_name": "temp_drop_rate" }, ">", { "const": 0 } ] } + ] + } + }, + { + "id": "fog", + "type": "weather_type", + "name": "Fog", + "color": "light_gray", + "map_color": "dark_gray_white", + "sym": "~", + "ranged_penalty": 7, + "sight_penalty": 1.5, + "light_modifier": -40, + "sun_multiplier": 0.3, + "sound_attn": 0, + "dangerous": false, + "precip": "heavy", + "rains": false, + "sound_category": "silent", + "priority": 30, + "required_weathers": [ "mist" ], + "condition": { + "and": [ + { "compare_num": [ { "weather": "humidity" }, ">=", { "const": 95 } ] }, + { "compare_num": [ { "weather": "windpower" }, ">=", { "const": 11 } ] }, + { "compare_num": [ { "weather": "windpower" }, "<", { "const": 0 } ] }, + { "compare_num": [ { "global_val": "var", "var_name": "temp_drop_rate" }, ">", { "const": 1 } ] } + ] + } + }, + { + "type": "effect_on_condition", + "id": "EOC_CALCULATE_TEMP_DROP_RATE", + "recurrence": [ "15 minutes", "20 minutes" ], + "//": "we compare the temperature of previous calculation with current temperature, to check how big the temperature drop, then save the current temperature to use in the next check", + "effect": [ + { + "math": [ + "global_val('var', 'var': 'temp_drop_rate')", + "=", + "global_val('var', 'var': 'temp_drop_rate') - weather('temperature')" + ] + }, + { "arithmetic": [ { "global_val": "var", "var_name": "previous_temp" }, "=", { "weather": "temperature" } ] } + ] + }, { "id": "early_portal_storm", "type": "weather_type", From e27e88ef21f4bfe4787da6079208d19f7c9e40b2 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Sun, 9 Apr 2023 14:10:36 +0200 Subject: [PATCH 02/11] no message --- data/json/weather_type.json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index 157f04967d3b9..cf3db2d4c0f49 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -286,7 +286,6 @@ "rains": false, "sound_category": "silent", "priority": 30, - "required_weathers": [ "clear" ], "condition": { "and": [ { "compare_num": [ { "weather": "humidity" }, ">=", { "const": 95 } ] }, @@ -312,7 +311,7 @@ "precip": "heavy", "rains": false, "sound_category": "silent", - "priority": 30, + "priority": 1, "required_weathers": [ "mist" ], "condition": { "and": [ @@ -326,14 +325,16 @@ { "type": "effect_on_condition", "id": "EOC_CALCULATE_TEMP_DROP_RATE", - "recurrence": [ "15 minutes", "20 minutes" ], + "recurrence": [ "30 minutes", "60 minutes" ], "//": "we compare the temperature of previous calculation with current temperature, to check how big the temperature drop, then save the current temperature to use in the next check", "effect": [ { - "math": [ - "global_val('var', 'var': 'temp_drop_rate')", + "arithmetic": [ + { "global_val": "var", "var_name": "temp_drop_rate" }, "=", - "global_val('var', 'var': 'temp_drop_rate') - weather('temperature')" + { + "arithmetic": [ { "global_val": "var", "var_name": "previous_temp" }, "-", { "weather": "temperature" } ] + } ] }, { "arithmetic": [ { "global_val": "var", "var_name": "previous_temp" }, "=", { "weather": "temperature" } ] } @@ -359,7 +360,7 @@ "tiles_animation": "weather_portal_storm", "weather_animation": { "factor": 0.01, "color": "red", "sym": "*" }, "sound_category": "portal_storm", - "priority": 120, + "priority": 1, "condition": { "compare_num": [ { "global_val": "var", "var_name": "cause_early_portal_storm" }, "=", { "const": 1 } ] } }, { From 6a81b8c7d032f310af7a747fe8c06cbe44270fd9 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Fri, 14 Apr 2023 20:32:58 +0200 Subject: [PATCH 03/11] improve calculations, currently uses test values --- data/json/weather_type.json | 37 +++++++++---------- .../Xedra_Evolved/enchantments/armor.json | 1 - 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index cf3db2d4c0f49..579fb87bb61f8 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -285,13 +285,12 @@ "precip": "light", "rains": false, "sound_category": "silent", - "priority": 30, + "priority": 1000, "condition": { "and": [ - { "compare_num": [ { "weather": "humidity" }, ">=", { "const": 95 } ] }, - { "compare_num": [ { "weather": "windpower" }, ">=", { "const": 11 } ] }, - { "compare_num": [ { "weather": "windpower" }, "<", { "const": 0 } ] }, - { "compare_num": [ { "global_val": "var", "var_name": "temp_drop_rate" }, ">", { "const": 0 } ] } + { "math": [ "u_val( 'weather:windpower' )", ">", "12" ] }, + { "math": [ "u_val( 'weather:windpower' )", "<", "0" ] }, + { "math": [ "dew_point_factor", "<", "35" ] } ] } }, @@ -311,33 +310,33 @@ "precip": "heavy", "rains": false, "sound_category": "silent", - "priority": 1, + "priority": 1000, "required_weathers": [ "mist" ], "condition": { "and": [ - { "compare_num": [ { "weather": "humidity" }, ">=", { "const": 95 } ] }, - { "compare_num": [ { "weather": "windpower" }, ">=", { "const": 11 } ] }, - { "compare_num": [ { "weather": "windpower" }, "<", { "const": 0 } ] }, - { "compare_num": [ { "global_val": "var", "var_name": "temp_drop_rate" }, ">", { "const": 1 } ] } + { "math": [ "u_val( 'weather:windpower' )", ">", "12" ] }, + { "math": [ "u_val( 'weather:windpower' )", "<", "0" ] }, + { "math": [ "dew_point_factor", "<=", "2.5" ] } ] } }, { "type": "effect_on_condition", - "id": "EOC_CALCULATE_TEMP_DROP_RATE", - "recurrence": [ "30 minutes", "60 minutes" ], - "//": "we compare the temperature of previous calculation with current temperature, to check how big the temperature drop, then save the current temperature to use in the next check", + "id": "EOC_DEW_POINT_FACTOR", + "recurrence": [ "15 minutes", "30 minutes" ], + "//": "First and second math calculate the dew point, the third calculate how close the weather to the point it can form a fog", + "//2": "dew_point_factor is a difference between actual temperature and the dew point. the closer it gets to zero, the bigger probability to cause a mist or dew, starting somewhere from 2,5 centigrade or 5 fahrenheit, to zero", "effect": [ { - "arithmetic": [ - { "global_val": "var", "var_name": "temp_drop_rate" }, + "math": [ + "dprhx", "=", - { - "arithmetic": [ { "global_val": "var", "var_name": "previous_temp" }, "-", { "weather": "temperature" } ] - } + "log ( u_val( 'weather:humidity' ) / 100 ) + 17.625 * u_val( 'weather:temperature' ) / ( 469.5 + u_val( 'weather:temperature' ) )" ] }, - { "arithmetic": [ { "global_val": "var", "var_name": "previous_temp" }, "=", { "weather": "temperature" } ] } + { "math": [ "dew_point", "=", "469.5 * dprhx / ( 17.625 - dprhx )" ] }, + { "math": [ "dew_point_factor", "=", "u_val('weather: temperature') - ( dew_point )" ] }, + { "u_message": "dew_point_factor: ,\n", "type": "debug" } ] }, { diff --git a/data/mods/Xedra_Evolved/enchantments/armor.json b/data/mods/Xedra_Evolved/enchantments/armor.json index 918ef7431d41f..209e803daa4e2 100644 --- a/data/mods/Xedra_Evolved/enchantments/armor.json +++ b/data/mods/Xedra_Evolved/enchantments/armor.json @@ -74,7 +74,6 @@ "id": "DECREASE_BERSERKER", "recurrence": "25 s", "effect": [ - { "u_message": "BERSERK -1.", "type": "debug" }, { "arithmetic": [ { "global_val": "var", "var_name": "BERSERKER" }, "--" ], "min": 0 } ] } From 93590e94c0c58d55c20a7f4f7cac1acc5c5c4c27 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Fri, 14 Apr 2023 20:35:05 +0200 Subject: [PATCH 04/11] oops --- data/json/weather_type.json | 2 +- data/mods/Xedra_Evolved/enchantments/armor.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index 579fb87bb61f8..cff18f7e56367 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -359,7 +359,7 @@ "tiles_animation": "weather_portal_storm", "weather_animation": { "factor": 0.01, "color": "red", "sym": "*" }, "sound_category": "portal_storm", - "priority": 1, + "priority": 120, "condition": { "compare_num": [ { "global_val": "var", "var_name": "cause_early_portal_storm" }, "=", { "const": 1 } ] } }, { diff --git a/data/mods/Xedra_Evolved/enchantments/armor.json b/data/mods/Xedra_Evolved/enchantments/armor.json index 209e803daa4e2..918ef7431d41f 100644 --- a/data/mods/Xedra_Evolved/enchantments/armor.json +++ b/data/mods/Xedra_Evolved/enchantments/armor.json @@ -74,6 +74,7 @@ "id": "DECREASE_BERSERKER", "recurrence": "25 s", "effect": [ + { "u_message": "BERSERK -1.", "type": "debug" }, { "arithmetic": [ { "global_val": "var", "var_name": "BERSERKER" }, "--" ], "min": 0 } ] } From 7e10babf745cc620faa05778adac3c99802d1bab Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Fri, 14 Apr 2023 22:00:55 +0200 Subject: [PATCH 05/11] no message --- data/json/weather_type.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index cff18f7e56367..f664c8286640a 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -285,7 +285,7 @@ "precip": "light", "rains": false, "sound_category": "silent", - "priority": 1000, + "priority": 40, "condition": { "and": [ { "math": [ "u_val( 'weather:windpower' )", ">", "12" ] }, @@ -310,7 +310,7 @@ "precip": "heavy", "rains": false, "sound_category": "silent", - "priority": 1000, + "priority": 40, "required_weathers": [ "mist" ], "condition": { "and": [ From 12229897c07a2764f94bb735e0376a9331d70fa4 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Fri, 14 Apr 2023 22:02:12 +0200 Subject: [PATCH 06/11] no message --- data/json/weather_type.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index f664c8286640a..0bd1390f6b21a 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -290,7 +290,7 @@ "and": [ { "math": [ "u_val( 'weather:windpower' )", ">", "12" ] }, { "math": [ "u_val( 'weather:windpower' )", "<", "0" ] }, - { "math": [ "dew_point_factor", "<", "35" ] } + { "math": [ "dew_point_factor", "<", "5" ] } ] } }, From 66f5e073eaa90ba0d984df7e9a351c1f7e42eb63 Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Fri, 14 Apr 2023 22:51:28 +0200 Subject: [PATCH 07/11] fixing the wrong values, remove debug message --- data/json/weather_type.json | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index 0bd1390f6b21a..a948fd8ca454b 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -277,7 +277,7 @@ "map_color": "dark_gray_white", "sym": "~", "ranged_penalty": 3, - "sight_penalty": 1.2, + "sight_penalty": 1.3, "light_modifier": -20, "sun_multiplier": 0.3, "sound_attn": 0, @@ -285,11 +285,11 @@ "precip": "light", "rains": false, "sound_category": "silent", - "priority": 40, + "priority": 20, "condition": { "and": [ - { "math": [ "u_val( 'weather:windpower' )", ">", "12" ] }, - { "math": [ "u_val( 'weather:windpower' )", "<", "0" ] }, + { "math": [ "u_val( 'weather:windpower' )", "<", "12" ] }, + { "math": [ "u_val( 'weather:windpower' )", ">", "0" ] }, { "math": [ "dew_point_factor", "<", "5" ] } ] } @@ -302,7 +302,7 @@ "map_color": "dark_gray_white", "sym": "~", "ranged_penalty": 7, - "sight_penalty": 1.5, + "sight_penalty": 1.7, "light_modifier": -40, "sun_multiplier": 0.3, "sound_attn": 0, @@ -310,12 +310,12 @@ "precip": "heavy", "rains": false, "sound_category": "silent", - "priority": 40, + "priority": 20, "required_weathers": [ "mist" ], "condition": { "and": [ - { "math": [ "u_val( 'weather:windpower' )", ">", "12" ] }, - { "math": [ "u_val( 'weather:windpower' )", "<", "0" ] }, + { "math": [ "u_val( 'weather:windpower' )", "<", "12" ] }, + { "math": [ "u_val( 'weather:windpower' )", ">", "0" ] }, { "math": [ "dew_point_factor", "<=", "2.5" ] } ] } @@ -335,8 +335,7 @@ ] }, { "math": [ "dew_point", "=", "469.5 * dprhx / ( 17.625 - dprhx )" ] }, - { "math": [ "dew_point_factor", "=", "u_val('weather: temperature') - ( dew_point )" ] }, - { "u_message": "dew_point_factor: ,\n", "type": "debug" } + { "math": [ "dew_point_factor", "=", "u_val('weather: temperature') - ( dew_point )" ] } ] }, { From b2beeac67eb8187f4bdd75626d8a4da544d52ef7 Mon Sep 17 00:00:00 2001 From: andrei Date: Sat, 15 Apr 2023 00:21:15 +0300 Subject: [PATCH 08/11] tests: override weather in tests that need clear vision --- tests/bionics_test.cpp | 2 ++ tests/char_sight_test.cpp | 4 ++++ tests/vision_test.cpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/tests/bionics_test.cpp b/tests/bionics_test.cpp index 23026a3f1bc06..b8dae5fcc40d0 100644 --- a/tests/bionics_test.cpp +++ b/tests/bionics_test.cpp @@ -13,6 +13,7 @@ #include "item_pocket.h" #include "map_helpers.h" #include "npc.h" +#include "options_helpers.h" #include "pimpl.h" #include "player_helpers.h" #include "ret_val.h" @@ -537,6 +538,7 @@ TEST_CASE( "fueled bionics", "[bionics] [item]" ) // Midday for solar test clear_map(); g->reset_light_level(); + scoped_weather_override weather_clear( WEATHER_CLEAR ); calendar::turn = calendar::turn_zero + 12_hours; REQUIRE( g->is_in_sunlight( dummy.pos() ) ); diff --git a/tests/char_sight_test.cpp b/tests/char_sight_test.cpp index c6055f95c09be..42d923201495c 100644 --- a/tests/char_sight_test.cpp +++ b/tests/char_sight_test.cpp @@ -10,6 +10,7 @@ #include "lightmap.h" #include "map.h" #include "map_helpers.h" +#include "options_helpers.h" #include "player_helpers.h" #include "type_id.h" @@ -55,6 +56,7 @@ TEST_CASE( "light and fine_detail_vision_mod", "[character][sight][light][vision clear_avatar(); clear_map(); g->reset_light_level(); + scoped_weather_override weather_clear( WEATHER_CLEAR ); SECTION( "full daylight" ) { // Set clock to noon @@ -117,6 +119,7 @@ TEST_CASE( "character sight limits", "[character][sight][vision]" ) clear_avatar(); clear_map(); g->reset_light_level(); + scoped_weather_override weather_clear( WEATHER_CLEAR ); GIVEN( "it is midnight with a new moon" ) { calendar::turn = calendar::turn_zero; @@ -212,6 +215,7 @@ TEST_CASE( "ursine vision", "[character][ursine][vision]" ) clear_avatar(); clear_map(); g->reset_light_level(); + scoped_weather_override weather_clear( WEATHER_CLEAR ); float light_here = 0.0f; diff --git a/tests/vision_test.cpp b/tests/vision_test.cpp index 2d63da3cdc441..51c1ecd30c558 100644 --- a/tests/vision_test.cpp +++ b/tests/vision_test.cpp @@ -19,6 +19,7 @@ #include "map_test_case.h" #include "mapdata.h" #include "mtype.h" +#include "options_helpers.h" #include "point.h" #include "type_id.h" #include "units.h" @@ -148,6 +149,7 @@ struct vision_test_case { const time_point &time ) : setup( setup ), expected_results( expectedResults ), time( time ) {} void test_all() const { + scoped_weather_override weather_clear( WEATHER_CLEAR ); Character &player_character = get_player_character(); g->place_player( tripoint( 60, 60, 0 ) ); player_character.worn.clear(); // Remove any light-emitting clothing From aecaf108ad075a27a34a9f248909a278e8e7d75c Mon Sep 17 00:00:00 2001 From: Anton Simakov <67688115+GuardianDll@users.noreply.github.com> Date: Sun, 16 Apr 2023 13:12:32 +0200 Subject: [PATCH 09/11] Andrei's fix of vision test --- tests/vision_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/vision_test.cpp b/tests/vision_test.cpp index 51c1ecd30c558..e5239c6f64eee 100644 --- a/tests/vision_test.cpp +++ b/tests/vision_test.cpp @@ -149,7 +149,6 @@ struct vision_test_case { const time_point &time ) : setup( setup ), expected_results( expectedResults ), time( time ) {} void test_all() const { - scoped_weather_override weather_clear( WEATHER_CLEAR ); Character &player_character = get_player_character(); g->place_player( tripoint( 60, 60, 0 ) ); player_character.worn.clear(); // Remove any light-emitting clothing @@ -159,6 +158,7 @@ struct vision_test_case { player_character.clear_moncams(); clear_map( -2, OVERMAP_HEIGHT ); g->reset_light_level(); + scoped_weather_override weather_clear( WEATHER_CLEAR ); REQUIRE( !player_character.is_blind() ); REQUIRE( !player_character.in_sleep_state() ); @@ -541,11 +541,11 @@ TEST_CASE( "vision_junction_reciprocity", "[vision][reciprocity]" ) player_in_junction ? std::vector{ "u# ", - "-- Z", + "---Z", }: std::vector{ "z# ", - "-- u", + "---u", }, player_in_junction ? std::vector{ From be4f70f98f22b6d4845638af8296b92edc6aa39f Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Thu, 20 Apr 2023 21:33:21 +0200 Subject: [PATCH 10/11] vision_junction_reciprocity fix --- tests/vision_test.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tests/vision_test.cpp b/tests/vision_test.cpp index e5239c6f64eee..f7caaceec17c5 100644 --- a/tests/vision_test.cpp +++ b/tests/vision_test.cpp @@ -536,25 +536,34 @@ TEST_CASE( "vision_single_tile_skylight", "[shadowcasting][vision]" ) TEST_CASE( "vision_junction_reciprocity", "[vision][reciprocity]" ) { bool player_in_junction = GENERATE( true, false ); + CAPTURE( player_in_junction ); vision_test_case t { player_in_junction ? std::vector{ - "u# ", - "---Z", + "### ", + "#u####", + "#---z#", + "######", }: std::vector{ - "z# ", - "---u", + "### ", + "#z####", + "#---u#", + "######", }, player_in_junction ? std::vector{ - "4466", - "4446", + "444666", + "444666", + "444466", + "444466", }: std::vector{ - "4444", - "4444", + "666666", + "444444", + "444444", + "444444", }, day_time }; @@ -562,14 +571,14 @@ TEST_CASE( "vision_junction_reciprocity", "[vision][reciprocity]" ) monster *zombie = nullptr; tile_predicate spawn_zombie = [&]( map_test_case::tile tile ) { zombie = g->place_critter_at( mon_zombie, tile.p ); + get_map().ter_set( tile.p + tripoint_above, ter_t_flat_roof ); return true; }; t.set_up_tiles = - ifchar( 'C', spawn_moncam ) || - ifchar( 'Z', spawn_zombie ) || ifchar( 'z', spawn_zombie ) || t.set_up_tiles; + t.flags.headlamp = true; t.test_all(); if( player_in_junction ) { From 8c673175cee2210a4ff3324ceaf7b9529178813f Mon Sep 17 00:00:00 2001 From: GuardianDll Date: Thu, 20 Apr 2023 21:34:26 +0200 Subject: [PATCH 11/11] weather realism test fix --- data/json/weather_type.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/json/weather_type.json b/data/json/weather_type.json index a948fd8ca454b..df4aea49bde8b 100644 --- a/data/json/weather_type.json +++ b/data/json/weather_type.json @@ -282,10 +282,11 @@ "sun_multiplier": 0.3, "sound_attn": 0, "dangerous": false, - "precip": "light", + "precip": "none", "rains": false, "sound_category": "silent", "priority": 20, + "required_weathers": [ "clear", "sunny" ], "condition": { "and": [ { "math": [ "u_val( 'weather:windpower' )", "<", "12" ] }, @@ -307,7 +308,7 @@ "sun_multiplier": 0.3, "sound_attn": 0, "dangerous": false, - "precip": "heavy", + "precip": "none", "rains": false, "sound_category": "silent", "priority": 20,