From 85c85c4eb2aeedd9a1742620a97745d0dd90f1cb Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Fri, 19 Jul 2019 12:00:01 +0300 Subject: [PATCH 1/4] Unhardcoded field gas spreading --- data/json/field_type.json | 42 +++++++++++++++++++++++++++++++++++++++ src/field.h | 4 ++++ src/field_type.cpp | 2 ++ src/field_type.h | 2 ++ src/map_field.cpp | 37 ++++++++++------------------------ 5 files changed, 60 insertions(+), 27 deletions(-) diff --git a/data/json/field_type.json b/data/json/field_type.json index 298bbefae08cb..6e4fd14c3dbee 100644 --- a/data/json/field_type.json +++ b/data/json/field_type.json @@ -187,6 +187,8 @@ "decay_amount_factor": 5, "gas_absorption_factor": 12, "dirty_transparency_cache": true, + "percent_spread": 10, + "outdoor_age_speedup": "0 turns", "immunity_data": { "body_part_env_resistance": [ [ "MOUTH", 12 ] ] }, "priority": 8, "half_life": "2 minutes", @@ -206,6 +208,8 @@ ], "decay_amount_factor": 5, "gas_absorption_factor": 15, + "percent_spread": 30, + "outdoor_age_speedup": "3 minutes", "dirty_transparency_cache": true, "has_fume": true, "immunity_data": { "body_part_env_resistance": [ [ "MOUTH", 15 ] ] }, @@ -226,6 +230,8 @@ ], "decay_amount_factor": 5, "gas_absorption_factor": 15, + "percent_spread": 10, + "outdoor_age_speedup": "0 turns", "dirty_transparency_cache": true, "has_fume": true, "immunity_data": { "body_part_env_resistance": [ [ "MOUTH", 15 ] ] }, @@ -245,6 +251,8 @@ { "name": "thick radioactive gas", "color": "green", "transparent": false } ], "decay_amount_factor": 5, + "percent_spread": 15, + "outdoor_age_speedup": "1 minutes", "dirty_transparency_cache": true, "has_fume": true, "priority": 8, @@ -489,6 +497,8 @@ { "name": "thick tobacco smoke", "color": "dark_gray" } ], "decay_amount_factor": 5, + "percent_spread": 250, + "outdoor_age_speedup": "6 minutes", "dirty_transparency_cache": true, "priority": 8, "half_life": "35 minutes", @@ -506,6 +516,8 @@ { "name": "thick pot smoke", "color": "dark_gray" } ], "decay_amount_factor": 5, + "percent_spread": 200, + "outdoor_age_speedup": "6 minutes", "dirty_transparency_cache": true, "priority": 8, "half_life": "325 turns", @@ -523,6 +535,8 @@ { "name": "thick crack smoke", "color": "dark_gray" } ], "decay_amount_factor": 5, + "percent_spread": 175, + "outdoor_age_speedup": "8 minutes", "dirty_transparency_cache": true, "priority": 8, "half_life": "225 turns", @@ -540,6 +554,8 @@ { "name": "thick meth smoke", "color": "dark_gray" } ], "decay_amount_factor": 5, + "percent_spread": 175, + "outdoor_age_speedup": "7 minutes", "dirty_transparency_cache": true, "priority": 8, "half_life": "275 turns", @@ -556,6 +572,8 @@ { "name": "swarm of bees", "color": "light_gray" }, { "name": "angry swarm of bees", "color": "dark_gray" } ], + "percent_spread": 5, + "outdoor_age_speedup": "0 turns", "dirty_transparency_cache": true, "priority": 8, "half_life": "100 minutes", @@ -577,6 +595,8 @@ "translucency": 0 } ], + "percent_spread": 66, + "outdoor_age_speedup": "4 minutes", "dirty_transparency_cache": true, "has_fire": true, "priority": 8, @@ -596,6 +616,8 @@ ], "decay_amount_factor": 5, "gas_absorption_factor": 15, + "percent_spread": 15, + "outdoor_age_speedup": "5 minutes", "dirty_transparency_cache": true, "has_fume": true, "immunity_data": { "body_part_env_resistance": [ [ "MOUTH", 15 ] ] }, @@ -616,6 +638,8 @@ ], "decay_amount_factor": 5, "gas_absorption_factor": 15, + "percent_spread": 13, + "outdoor_age_speedup": "5 turns", "dirty_transparency_cache": true, "has_fume": true, "immunity_data": { "traits": [ "M_IMMUNE" ], "body_part_env_resistance": [ [ "MOUTH", 15 ], [ "EYES", 15 ] ] }, @@ -635,6 +659,8 @@ { "color": "cyan", "convection_temperature_mod": -6 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -650,6 +676,8 @@ { "color": "cyan", "convection_temperature_mod": -20 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -665,6 +693,8 @@ { "color": "cyan", "convection_temperature_mod": -70 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -680,6 +710,8 @@ { "color": "cyan", "convection_temperature_mod": -160 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -695,6 +727,8 @@ { "color": "red", "convection_temperature_mod": 10 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -710,6 +744,8 @@ { "color": "red", "convection_temperature_mod": 20 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -725,6 +761,8 @@ { "color": "red", "convection_temperature_mod": 70 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -740,6 +778,8 @@ { "color": "red", "convection_temperature_mod": 160 } ], "decay_amount_factor": 5, + "percent_spread": 100, + "outdoor_age_speedup": "100 minutes", "priority": -1, "half_life": "50 minutes", "phase": "gas", @@ -755,6 +795,8 @@ { "name": "thick fungicidal gas", "color": "dark_gray", "transparent": false } ], "decay_amount_factor": 5, + "percent_spread": 120, + "outdoor_age_speedup": "1 minutes", "dirty_transparency_cache": true, "has_fume": true, "priority": 8, diff --git a/src/field.h b/src/field.h index 14315d7b23620..36c0753433c63 100644 --- a/src/field.h +++ b/src/field.h @@ -74,6 +74,10 @@ class field_entry return is_alive; } + bool gas_can_spread() { + return is_field_alive() && type.obj().phase == GAS && type.obj().percent_spread > 0; + } + time_duration get_underwater_age_speedup() const { return type.obj().underwater_age_speedup; } diff --git a/src/field_type.cpp b/src/field_type.cpp index 2f6a8b5f9da69..c14d09af393bd 100644 --- a/src/field_type.cpp +++ b/src/field_type.cpp @@ -102,7 +102,9 @@ void field_type::load( JsonObject &jo, const std::string & ) jao.get_string( 0 ) ), jao.get_int( 1 ) ) ); } optional( jo, was_loaded, "underwater_age_speedup", underwater_age_speedup, 0_turns ); + optional( jo, was_loaded, "outdoor_age_speedup", outdoor_age_speedup, 0_turns ); optional( jo, was_loaded, "decay_amount_factor", decay_amount_factor, 0 ); + optional( jo, was_loaded, "percent_spread", percent_spread, 0 ); optional( jo, was_loaded, "apply_slime_factor", apply_slime_factor, 0 ); optional( jo, was_loaded, "gas_absorption_factor", gas_absorption_factor, 0 ); optional( jo, was_loaded, "is_splattering", is_splattering, false ); diff --git a/src/field_type.h b/src/field_type.h index 75163e2f29e0c..f1fb26f40b2be 100644 --- a/src/field_type.h +++ b/src/field_type.h @@ -50,7 +50,9 @@ struct field_type { std::vector intensity_levels; time_duration underwater_age_speedup = 0_turns; + time_duration outdoor_age_speedup = 0_turns; int decay_amount_factor = 0; + int percent_spread = 0; int apply_slime_factor = 0; int gas_absorption_factor = 0; bool is_splattering = false; diff --git a/src/map_field.cpp b/src/map_field.cpp index 5ca6bfd46ab1d..3722b2d000d31 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -939,29 +939,24 @@ bool map::process_fields_in_submap( submap *const current_submap, create_hot_air( p, cur.get_field_intensity() ); } } - if( curtype == fd_smoke || curtype == fd_tear_gas ) { - spread_gas( cur, p, 10, 0_turns, sblk ); - } - if( curtype == fd_relax_gas ) { - spread_gas( cur, p, 15, 5_minutes, sblk ); + + // Spread gaseous fields + if( cur.gas_can_spread() ) { + const int gas_percent_spread = curtype.obj().percent_spread; + if( gas_percent_spread > 0 ) { + const time_duration outdoor_age_speedup = curtype.obj().outdoor_age_speedup; + spread_gas( cur, p, gas_percent_spread, outdoor_age_speedup, sblk ); + } } + if( curtype == fd_fungal_haze ) { - spread_gas( cur, p, 13, 5_turns, sblk ); if( one_in( 10 - 2 * cur.get_field_intensity() ) ) { // Haze'd terrain fungal_effects( *g, g->m ).spread_fungus( p ); } } - if( curtype == fd_toxic_gas ) { - spread_gas( cur, p, 30, 3_minutes, sblk ); - } - if( curtype == fd_cigsmoke ) { - spread_gas( cur, p, 250, 6_minutes, sblk ); - } if( curtype == fd_weedsmoke ) { - spread_gas( cur, p, 200, 6_minutes, sblk ); - if( one_in( 20 ) ) { if( npc *const np = g->critter_at( p ) ) { np->complain_about( "weed_smell", 10_minutes, "" ); @@ -971,16 +966,14 @@ bool map::process_fields_in_submap( submap *const current_submap, } if( curtype == fd_methsmoke ) { - spread_gas( cur, p, 175, 7_minutes, sblk ); if( one_in( 20 ) ) { if( npc *const np = g->critter_at( p ) ) { np->complain_about( "meth_smell", 30_minutes, "" ); } } } - if( curtype == fd_cracksmoke ) { - spread_gas( cur, p, 175, 8_minutes, sblk ); + if( curtype == fd_cracksmoke ) { if( one_in( 20 ) ) { if( npc *const np = g->critter_at( p ) ) { np->complain_about( "crack_smell", 30_minutes, "" ); @@ -990,16 +983,8 @@ bool map::process_fields_in_submap( submap *const current_submap, if( curtype == fd_nuke_gas ) { int extra_radiation = rng( 0, cur.get_field_intensity() ); adjust_radiation( p, extra_radiation ); - spread_gas( cur, p, 15, 1_minutes, sblk ); break; } - if( curtype == fd_cold_air1 || curtype == fd_cold_air2 || - curtype == fd_cold_air3 || curtype == fd_cold_air4 || - curtype == fd_hot_air1 || curtype == fd_hot_air2 || - curtype == fd_hot_air3 || curtype == fd_hot_air4 ) { - // No transparency cache wrecking here! - spread_gas( cur, p, 100, 100_minutes, sblk ); - } if( curtype == fd_gas_vent ) { for( const tripoint &pnt : points_in_radius( p, cur.get_field_intensity() - 1 ) ) { field &wandering_field = get_field( pnt ); @@ -1285,7 +1270,6 @@ bool map::process_fields_in_submap( submap *const current_submap, add_field( dst, fd_fire, 1 ); } - spread_gas( cur, p, 66, 4_minutes, sblk ); create_hot_air( p, cur.get_field_intensity() ); } if( curtype == fd_rubble ) { @@ -1293,7 +1277,6 @@ bool map::process_fields_in_submap( submap *const current_submap, make_rubble( p ); } if( curtype == fd_fungicidal_gas ) { - spread_gas( cur, p, 120, 1_minutes, sblk ); // Check the terrain and replace it accordingly to simulate the fungus dieing off const ter_t &ter = map_tile.get_ter_t(); const furn_t &frn = map_tile.get_furn_t(); From 18c2b86f74ae66529e9407754d68da02f8f3f1fa Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Fri, 19 Jul 2019 12:25:13 +0300 Subject: [PATCH 2/4] Unhardcoded npc complaints regarding fields --- data/json/field_type.json | 3 +++ src/field_type.cpp | 14 ++++++++++++++ src/field_type.h | 3 +++ src/map_field.cpp | 30 +++++++++--------------------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/data/json/field_type.json b/data/json/field_type.json index 6e4fd14c3dbee..a5cfc8a467d5e 100644 --- a/data/json/field_type.json +++ b/data/json/field_type.json @@ -515,6 +515,7 @@ { "name": "pot smoke", "color": "light_gray" }, { "name": "thick pot smoke", "color": "dark_gray" } ], + "npc_complain": { "chance": 20, "issue": "weed_smell", "duration": "10 minutes", "speech": "" }, "decay_amount_factor": 5, "percent_spread": 200, "outdoor_age_speedup": "6 minutes", @@ -534,6 +535,7 @@ { "name": "crack smoke", "color": "light_gray" }, { "name": "thick crack smoke", "color": "dark_gray" } ], + "npc_complain": { "chance": 20, "issue": "crack_smell", "duration": "30 minutes", "speech": "" }, "decay_amount_factor": 5, "percent_spread": 175, "outdoor_age_speedup": "8 minutes", @@ -553,6 +555,7 @@ { "name": "meth smoke", "color": "light_gray" }, { "name": "thick meth smoke", "color": "dark_gray" } ], + "npc_complain": { "chance": 20, "issue": "meth_smell", "duration": "30 minutes", "speech": "" }, "decay_amount_factor": 5, "percent_spread": 175, "outdoor_age_speedup": "7 minutes", diff --git a/src/field_type.cpp b/src/field_type.cpp index c14d09af393bd..9e94d977dcb34 100644 --- a/src/field_type.cpp +++ b/src/field_type.cpp @@ -90,6 +90,20 @@ void field_type::load( JsonObject &jo, const std::string & ) fallback_intensity_level.convection_temperature_mod ); intensity_levels.emplace_back( intensity_level ); } + + if( jo.has_object( "npc_complain" ) ) { + JsonObject joc = jo.get_object( "npc_complain" ); + int chance; + std::string issue; + time_duration duration; + std::string speech; + optional( joc, was_loaded, "chance", chance, 0 ); + optional( joc, was_loaded, "issue", issue ); + optional( joc, was_loaded, "duration", duration, 0_turns ); + optional( joc, was_loaded, "speech", speech ); + npc_complain_data = std::make_tuple( chance, issue, duration, speech ); + } + JsonObject jid = jo.get_object( "immunity_data" ); JsonArray jidt = jid.get_array( "traits" ); while( jidt.has_more() ) { diff --git a/src/field_type.h b/src/field_type.h index f1fb26f40b2be..10870e3d1c043 100644 --- a/src/field_type.h +++ b/src/field_type.h @@ -62,6 +62,9 @@ struct field_type { bool has_elec = false; bool has_fume = false; + // chance, issue, duration, speech + std::tuple npc_complain_data; + std::vector immunity_data_traits; std::vector> immunity_data_body_part_env_resistance; diff --git a/src/map_field.cpp b/src/map_field.cpp index 3722b2d000d31..68c0a4e266b73 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -956,30 +956,18 @@ bool map::process_fields_in_submap( submap *const current_submap, } } - if( curtype == fd_weedsmoke ) { - if( one_in( 20 ) ) { - if( npc *const np = g->critter_at( p ) ) { - np->complain_about( "weed_smell", 10_minutes, "" ); - } + // Process npc complaints + const std::tuple &npc_complain_data = + curtype.obj().npc_complain_data; + const int chance = std::get<0>( npc_complain_data ); + if( chance > 0 && one_in( chance ) ) { + if( npc *const np = g->critter_at( p ) ) { + np->complain_about( std::get<1>( npc_complain_data ), + std::get<2>( npc_complain_data ), + std::get<3>( npc_complain_data ) ); } - } - if( curtype == fd_methsmoke ) { - if( one_in( 20 ) ) { - if( npc *const np = g->critter_at( p ) ) { - np->complain_about( "meth_smell", 30_minutes, "" ); - } - } - } - - if( curtype == fd_cracksmoke ) { - if( one_in( 20 ) ) { - if( npc *const np = g->critter_at( p ) ) { - np->complain_about( "crack_smell", 30_minutes, "" ); - } - } - } if( curtype == fd_nuke_gas ) { int extra_radiation = rng( 0, cur.get_field_intensity() ); adjust_radiation( p, extra_radiation ); From d11a04ec9d6c4f9b1ed6805cada6c1c211fa5c5f Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Fri, 19 Jul 2019 12:33:24 +0300 Subject: [PATCH 3/4] Unhardcoded extra radiation from fields --- data/json/field_type.json | 6 +++--- src/field.cpp | 10 ++++++++++ src/field.h | 3 +++ src/field_type.cpp | 4 ++++ src/field_type.h | 8 ++++++++ src/map_field.cpp | 7 ++++--- 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/data/json/field_type.json b/data/json/field_type.json index a5cfc8a467d5e..88ddefcf03584 100644 --- a/data/json/field_type.json +++ b/data/json/field_type.json @@ -246,9 +246,9 @@ "type": "field_type", "legacy_enum_id": 15, "intensity_levels": [ - { "name": "hazy cloud", "sym": "8", "dangerous": true, "translucency": 10 }, - { "name": "radioactive gas", "color": "light_green" }, - { "name": "thick radioactive gas", "color": "green", "transparent": false } + { "name": "hazy cloud", "sym": "8", "dangerous": true, "translucency": 10, "extra_radiation_max": 1 }, + { "name": "radioactive gas", "color": "light_green", "extra_radiation_max": 2 }, + { "name": "thick radioactive gas", "color": "green", "transparent": false, "extra_radiation_max": 3 } ], "decay_amount_factor": 5, "percent_spread": 15, diff --git a/src/field.cpp b/src/field.cpp index d5093140ca657..f4098e940c056 100644 --- a/src/field.cpp +++ b/src/field.cpp @@ -10,6 +10,16 @@ int field_entry::move_cost() const return type.obj().get_move_cost( intensity - 1 ); } +int field_entry::extra_radiation_min() const +{ + return type.obj().get_extra_radiation_min( intensity - 1 ); +} + +int field_entry::extra_radiation_max() const +{ + return type.obj().get_extra_radiation_max( intensity - 1 ); +} + float field_entry::light_emitted() const { return type.obj().get_light_emitted( intensity - 1 ); diff --git a/src/field.h b/src/field.h index 36c0753433c63..94e81ba36c3e4 100644 --- a/src/field.h +++ b/src/field.h @@ -27,6 +27,9 @@ class field_entry //returns the move cost of this field int move_cost() const; + int extra_radiation_min() const; + int extra_radiation_max() const; + float light_emitted() const; float translucency() const; bool is_transparent() const; diff --git a/src/field_type.cpp b/src/field_type.cpp index 9e94d977dcb34..f16cc533f43f8 100644 --- a/src/field_type.cpp +++ b/src/field_type.cpp @@ -82,6 +82,10 @@ void field_type::load( JsonObject &jo, const std::string & ) fallback_intensity_level.dangerous ); optional( jao, was_loaded, "move_cost", intensity_level.move_cost, fallback_intensity_level.move_cost ); + optional( jao, was_loaded, "extra_radiation_min", intensity_level.extra_radiation_min, + fallback_intensity_level.extra_radiation_min ); + optional( jao, was_loaded, "extra_radiation_max", intensity_level.extra_radiation_max, + fallback_intensity_level.extra_radiation_max ); optional( jao, was_loaded, "light_emitted", intensity_level.light_emitted, fallback_intensity_level.light_emitted ); optional( jao, was_loaded, "translucency", intensity_level.translucency, diff --git a/src/field_type.h b/src/field_type.h index 10870e3d1c043..5fdd940852e22 100644 --- a/src/field_type.h +++ b/src/field_type.h @@ -29,6 +29,8 @@ struct field_intensity_level { bool dangerous = false; bool transparent = true; int move_cost = 0; + int extra_radiation_min = 0; + int extra_radiation_max = 0; float light_emitted = 0.0f; float translucency = 0.0f; int convection_temperature_mod = 0.0f; @@ -97,6 +99,12 @@ struct field_type { int get_move_cost( int level = 0 ) const { return intensity_levels[level].move_cost; } + int get_extra_radiation_min( int level = 0 ) const { + return intensity_levels[level].extra_radiation_min; + } + int get_extra_radiation_max( int level = 0 ) const { + return intensity_levels[level].extra_radiation_max; + } float get_light_emitted( int level = 0 ) const { return intensity_levels[level].light_emitted; } diff --git a/src/map_field.cpp b/src/map_field.cpp index 68c0a4e266b73..f4f6cad5aabeb 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -968,11 +968,12 @@ bool map::process_fields_in_submap( submap *const current_submap, } } - if( curtype == fd_nuke_gas ) { - int extra_radiation = rng( 0, cur.get_field_intensity() ); + // Apply radition + if( cur.extra_radiation_max() > 0 ) { + int extra_radiation = rng( cur.extra_radiation_min(), cur.extra_radiation_max() ); adjust_radiation( p, extra_radiation ); - break; } + if( curtype == fd_gas_vent ) { for( const tripoint &pnt : points_in_radius( p, cur.get_field_intensity() - 1 ) ) { field &wandering_field = get_field( pnt ); From d8d3933069c0a2c300ed4497e1d0e949f7b694a6 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Fri, 19 Jul 2019 12:52:57 +0300 Subject: [PATCH 4/4] Unhardcoded wandering fields from vents --- data/json/field_type.json | 2 ++ src/field_type.cpp | 8 ++++++++ src/field_type.h | 5 +++++ src/map_field.cpp | 18 ++++-------------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/data/json/field_type.json b/data/json/field_type.json index 88ddefcf03584..3051ae0189bd3 100644 --- a/data/json/field_type.json +++ b/data/json/field_type.json @@ -266,6 +266,7 @@ "type": "field_type", "legacy_enum_id": 16, "intensity_levels": [ { "name": "gas vent" } ], + "wandering_field": "fd_toxic_gas", "gas_absorption_factor": 15, "dirty_transparency_cache": true, "immunity_data": { "body_part_env_resistance": [ [ "MOUTH", 15 ] ] }, @@ -813,6 +814,7 @@ "type": "field_type", "legacy_enum_id": 50, "intensity_levels": [ { "name": "smoke vent", "dangerous": true } ], + "wandering_field": "fd_smoke", "gas_absorption_factor": 15, "dirty_transparency_cache": true, "has_fume": true, diff --git a/src/field_type.cpp b/src/field_type.cpp index f16cc533f43f8..b7c8b1788483f 100644 --- a/src/field_type.cpp +++ b/src/field_type.cpp @@ -139,6 +139,13 @@ void field_type::load( JsonObject &jo, const std::string & ) optional( jo, was_loaded, "accelerated_decay", accelerated_decay, false ); optional( jo, was_loaded, "display_items", display_items, true ); optional( jo, was_loaded, "display_field", display_field, false ); + optional( jo, was_loaded, "wandering_field_id", wandering_field_id, "fd_null" ); +} + +void field_type::finalize() +{ + wandering_field = field_type_id( wandering_field_id ); + wandering_field_id.empty(); } void field_type::check() const @@ -168,6 +175,7 @@ void field_types::load( JsonObject &jo, const std::string &src ) void field_types::finalize_all() { set_field_type_ids(); + all_field_types.finalize(); } void field_types::check_consistency() diff --git a/src/field_type.h b/src/field_type.h index 5fdd940852e22..3a38913c70a8e 100644 --- a/src/field_type.h +++ b/src/field_type.h @@ -39,6 +39,7 @@ struct field_intensity_level { struct field_type { public: void load( JsonObject &jo, const std::string &src ); + void finalize(); void check() const; public: @@ -46,6 +47,9 @@ struct field_type { field_type_str_id id; bool was_loaded = false; + // Used only during loading + std::string wandering_field_id = "fd_null"; + public: int legacy_enum_id = -1; @@ -76,6 +80,7 @@ struct field_type { bool accelerated_decay = false; bool display_items = true; bool display_field = false; + field_type_id wandering_field; public: std::string get_name( int level = 0 ) const { diff --git a/src/map_field.cpp b/src/map_field.cpp index f4f6cad5aabeb..180fda339f14e 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -974,25 +974,15 @@ bool map::process_fields_in_submap( submap *const current_submap, adjust_radiation( p, extra_radiation ); } - if( curtype == fd_gas_vent ) { + // Apply wandering fields from vents + if( curtype.obj().wandering_field.is_valid() ) { for( const tripoint &pnt : points_in_radius( p, cur.get_field_intensity() - 1 ) ) { field &wandering_field = get_field( pnt ); - tmpfld = wandering_field.find_field( fd_toxic_gas ); + tmpfld = wandering_field.find_field( curtype.obj().wandering_field ); if( tmpfld && tmpfld->get_field_intensity() < cur.get_field_intensity() ) { tmpfld->set_field_intensity( tmpfld->get_field_intensity() + 1 ); } else { - add_field( pnt, fd_toxic_gas, cur.get_field_intensity() ); - } - } - } - if( curtype == fd_smoke_vent ) { - for( const tripoint &pnt : points_in_radius( p, cur.get_field_intensity() - 1 ) ) { - field &wandering_field = get_field( pnt ); - tmpfld = wandering_field.find_field( fd_smoke ); - if( tmpfld && tmpfld->get_field_intensity() < cur.get_field_intensity() ) { - tmpfld->set_field_intensity( tmpfld->get_field_intensity() + 1 ); - } else { - add_field( pnt, fd_smoke, cur.get_field_intensity() ); + add_field( pnt, curtype.obj().wandering_field, cur.get_field_intensity() ); } } }