From 826ab0d56100cf80f11a4f751aa1be8f7e7ba256 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 9 Nov 2024 04:28:26 +0100 Subject: [PATCH] Made tree tops burn and more collapse on wall loss (#77605) * Made tree tops burn and more collapse on wall loss * Demanded changes --- src/map.cpp | 44 +++++++++++++++----------------------------- src/map_field.cpp | 20 ++++---------------- 2 files changed, 19 insertions(+), 45 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 29cd7063596d3..e4ec4f51e21c6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3930,7 +3930,7 @@ int map::collapse_check( const tripoint_bub_ms &p ) const int num_supports = p.z() == OVERMAP_DEPTH ? 0 : -5; // if there's support below, things are less likely to collapse if( p.z() > -OVERMAP_DEPTH ) { - const tripoint_bub_ms &pbelow = tripoint_bub_ms( p.xy(), p.z() - 1 ); + const tripoint_bub_ms &pbelow = p + tripoint_below; for( const tripoint_bub_ms &tbelow : points_in_radius( pbelow, 1 ) ) { if( has_flag( ter_furn_flag::TFLAG_SUPPORTS_ROOF, tbelow ) ) { num_supports += 1; @@ -3975,7 +3975,8 @@ void map::collapse_at( const tripoint_bub_ms &p, const bool silent, const bool w const bool destroy_pos ) { const bool supports = was_supporting || has_flag( ter_furn_flag::TFLAG_SUPPORTS_ROOF, p ); - const bool wall = was_supporting || has_flag( ter_furn_flag::TFLAG_WALL, p ); + const bool wall_tree = was_supporting || has_flag( ter_furn_flag::TFLAG_WALL, p ) || + has_flag( ter_furn_flag::TFLAG_TREE, p ); // don't bash again if the caller already bashed here if( destroy_pos ) { destroy( p, silent ); @@ -3988,34 +3989,19 @@ void map::collapse_at( const tripoint_bub_ms &p, const bool silent, const bool w if( supports && !still_supports ) { for( const tripoint_bub_ms &t : points_in_radius( p, 1 ) ) { // If z-levels are off, tz == t, so we end up skipping a lot of stuff to avoid bugs. - const tripoint_bub_ms &tz = tripoint_bub_ms( t.xy(), t.z() + 1 ); - // if nothing above us had the chance of collapsing, move on - if( !one_in( collapse_check( tz ) ) ) { - continue; - } - // if a wall collapses, walls without support from below risk collapsing and - //propagate the collapse upwards - if( zlevels && wall && p == t && has_flag( ter_furn_flag::TFLAG_WALL, tz ) ) { + const tripoint_bub_ms &tz = t + tripoint_above; + const bool collapse_above = one_in( collapse_check( tz ) ); + + if( zlevels && wall_tree && collapse_above ) { collapse_at( tz, silent ); - } - // floors without support from below risk collapsing into open air and can propagate - // the collapse horizontally but not vertically - if( p != t && ( has_flag( ter_furn_flag::TFLAG_SUPPORTS_ROOF, t ) && - has_flag( ter_furn_flag::TFLAG_COLLAPSES, t ) ) ) { - collapse_at( t, silent ); - } - // this tile used to support a roof, now it doesn't, which means there is only - // open air above us - if( zlevels ) { - // ensure that the layer below this one is not a wall, otherwise you have a ledge dropping onto - // a wall which doesn't make sense. - if( !has_flag( ter_furn_flag::TFLAG_WALL, t ) ) { - furn_set( tz, furn_str_id::NULL_ID() ); - ter_set( tz, ter_t_open_air ); - Creature *critter = get_creature_tracker().creature_at( tz ); - if( critter != nullptr ) { - creature_on_trap( *critter ); - } + + // this tile used to support a roof, now it doesn't, which means there is only + // open air above us + furn_set( tz, furn_str_id::NULL_ID() ); + ter_set( tz, ter_t_open_air ); + Creature *critter = get_creature_tracker().creature_at( tz ); + if( critter != nullptr ) { + creature_on_trap( *critter ); } } } diff --git a/src/map_field.cpp b/src/map_field.cpp index d6a48f51b4fe3..2e3370a9f7505 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -98,9 +98,7 @@ static const material_id material_veggy( "veggy" ); static const species_id species_FUNGUS( "FUNGUS" ); static const ter_str_id ter_t_dirt( "t_dirt" ); -static const ter_str_id ter_t_open_air( "t_open_air" ); static const ter_str_id ter_t_pit( "t_pit" ); -static const ter_str_id ter_t_rock_floor( "t_rock_floor" ); static const trait_id trait_ACIDPROOF( "ACIDPROOF" ); static const trait_id trait_GASTROPOD_FOOT( "GASTROPOD_FOOT" ); @@ -1116,19 +1114,8 @@ void field_processor_fd_fire( const tripoint &p, field_entry &cur, field_proc_da smoke += static_cast( windpower / 5 ); if( cur.get_field_intensity() > 1 && one_in( 200 - cur.get_field_intensity() * 50 ) ) { + here.bash( p, 999, false, true, true ); here.spawn_item( p, "ash", 1, rng( 10, 1000 ) ); - if( p.z > 0 ) { - // We're in the air. Need to invalidate the furniture otherwise it'll cause problems - here.furn_set( p, furn_str_id::NULL_ID() ); - here.ter_set( p, ter_t_open_air ); - } else if( p.z < -1 ) { - // We're deep underground, in bedrock. Whatever terrain was here is burned to the ground, leaving only the carved out rock (including ceiling) - here.ter_set( p, ter_t_rock_floor ); - } else { - // Need to invalidate the furniture otherwise it'll cause problems when supporting terrain collapses - here.furn_set( p, furn_str_id::NULL_ID() ); - here.ter_set( p, ter_t_dirt ); - } } } else if( frn.has_flag( ter_furn_flag::TFLAG_FLAMMABLE_ASH ) ) { @@ -1310,8 +1297,9 @@ void field_processor_fd_fire( const tripoint &p, field_entry &cur, field_proc_da // Consume adjacent fuel / terrain / webs to spread. // Allow raging fires (and only raging fires) to spread up // Spreading down is achieved by wrecking the walls/floor and then falling - if( cur.get_field_intensity() == 3 && p.z < OVERMAP_HEIGHT ) { - const tripoint_bub_ms dst_p = tripoint_bub_ms( p.x, p.y, p.z + 1 ); + if( ( cur.get_field_intensity() == 3 || + here.ter( p ).obj().has_flag( ter_furn_flag::TFLAG_TREE ) ) && p.z < OVERMAP_HEIGHT ) { + const tripoint_bub_ms dst_p = tripoint_bub_ms( p + tripoint_above ); // Let it burn through the floor maptile dst = here.maptile_at_internal( dst_p ); const ter_t &dst_ter = dst.get_ter_t();