From b623b11b8b49218849cb760e78f51f03ac020fb2 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sat, 30 Nov 2024 14:50:06 +0000 Subject: [PATCH 01/18] Rip out tr_ledge hack --- data/core/traps.json | 19 -- .../terrain-floors-indoor.json | 1 - .../furniture_and_terrain/terrain-roofs.json | 3 - .../furniture_and_terrain/terrain-traps.json | 2 +- .../terrain-windows.json | 1 - src/activity_actor.cpp | 4 +- src/character.cpp | 7 +- src/construction.cpp | 9 +- src/game.cpp | 26 ++- src/iexamine.cpp | 7 +- src/map.cpp | 165 ++++++++++++++++-- src/map.h | 2 + src/submap.cpp | 5 +- src/trap.h | 1 - src/trapfunc.cpp | 136 --------------- 15 files changed, 172 insertions(+), 216 deletions(-) delete mode 100644 data/core/traps.json diff --git a/data/core/traps.json b/data/core/traps.json deleted file mode 100644 index bb3c9707c26ca..0000000000000 --- a/data/core/traps.json +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - "//": "We're always going to need a 'nothing here' tile, we currently use traps for this.", - "type": "trap", - "id": "tr_ledge", - "name": "ledge", - "color": "i_cyan", - "memorial_male": { "ctxt": "memorial_male", "str": "Fell down a ledge." }, - "memorial_female": { "ctxt": "memorial_female", "str": "Fell down a ledge." }, - "symbol": " ", - "visibility": 0, - "avoidance": 99999, - "difficulty": 99, - "action": "ledge", - "vehicle_data": { "is_falling": true }, - "trigger_message_u": "You fell down a ledge!", - "trigger_message_npc": " fell down a ledge!" - } -] diff --git a/data/json/furniture_and_terrain/terrain-floors-indoor.json b/data/json/furniture_and_terrain/terrain-floors-indoor.json index 4a14f7167b1c5..40b620ebca375 100644 --- a/data/json/furniture_and_terrain/terrain-floors-indoor.json +++ b/data/json/furniture_and_terrain/terrain-floors-indoor.json @@ -1723,7 +1723,6 @@ "looks_like": "t_open_air", "color": "i_cyan", "move_cost": 2, - "trap": "tr_ledge", "flags": [ "TRANSPARENT" ], "examine_action": "ledge" } diff --git a/data/json/furniture_and_terrain/terrain-roofs.json b/data/json/furniture_and_terrain/terrain-roofs.json index f07fd533a985a..84f41707b5992 100644 --- a/data/json/furniture_and_terrain/terrain-roofs.json +++ b/data/json/furniture_and_terrain/terrain-roofs.json @@ -8,7 +8,6 @@ "color": "i_cyan", "move_cost": 2, "roof": "t_flat_roof", - "trap": "tr_ledge", "flags": [ "TRANSPARENT", "NO_FLOOR", "EMPTY_SPACE" ], "examine_action": "ledge" }, @@ -20,7 +19,6 @@ "symbol": " ", "color": "i_cyan", "move_cost": 2, - "trap": "tr_ledge", "roof": "t_flat_roof", "examine_action": "ledge", "connect_groups": "INDOORFLOOR", @@ -34,7 +32,6 @@ "symbol": " ", "color": "i_cyan", "move_cost": 2, - "trap": "tr_ledge", "flags": [ "TRANSPARENT", "NO_FLOOR", "EMPTY_SPACE" ], "examine_action": "ledge" }, diff --git a/data/json/furniture_and_terrain/terrain-traps.json b/data/json/furniture_and_terrain/terrain-traps.json index a67c740900207..31accae770456 100644 --- a/data/json/furniture_and_terrain/terrain-traps.json +++ b/data/json/furniture_and_terrain/terrain-traps.json @@ -1,13 +1,13 @@ [ { "type": "terrain", + "//": "TODO: Remove", "id": "t_hole", "name": "empty space", "description": "An area of empty space.", "symbol": " ", "color": "black", "move_cost": 2, - "trap": "tr_ledge", "flags": [ "TRANSPARENT", "NO_FLOOR", "EMPTY_SPACE" ], "examine_action": "ledge" }, diff --git a/data/json/furniture_and_terrain/terrain-windows.json b/data/json/furniture_and_terrain/terrain-windows.json index 487cd823f2f73..5cde9a93af147 100644 --- a/data/json/furniture_and_terrain/terrain-windows.json +++ b/data/json/furniture_and_terrain/terrain-windows.json @@ -4384,7 +4384,6 @@ "symbol": "0", "color": "light_cyan", "move_cost": 2, - "trap": "tr_ledge", "coverage": 0, "examine_action": "ledge", "deconstruct": { "ter_set": "t_hole", "items": [ { "item": "2x4", "count": [ 3, 4 ] }, { "item": "nail", "charges": [ 12, 16 ] } ] }, diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index b56692c593fe0..c94c9d2f0e3de 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -285,8 +285,6 @@ static const ter_str_id ter_t_underbrush_harvested_winter( "t_underbrush_harvest static const trait_id trait_SCHIZOPHRENIC( "SCHIZOPHRENIC" ); -static const trap_str_id tr_ledge( "tr_ledge" ); - static const vproto_id vehicle_prototype_none( "none" ); static const zone_type_id zone_type_LOOT_IGNORE( "LOOT_IGNORE" ); @@ -1667,7 +1665,7 @@ void glide_activity_actor::do_turn( player_activity &act, Character &you ) } const tripoint_abs_ms newpos = you.get_location() + heading; const tripoint_bub_ms checknewpos = you.pos_bub() + heading; - if( get_map().tr_at( you.pos_bub() ) != tr_ledge || heading == tripoint_rel_ms::zero ) { + if( !get_map().is_open_air( you.pos_bub() ) || heading == tripoint_rel_ms::zero ) { you.add_msg_player_or_npc( m_good, _( "You come to a gentle landing." ), _( " comes to a gentle landing." ) ); diff --git a/src/character.cpp b/src/character.cpp index 64e59322931e7..e997ebe858d1c 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -481,8 +481,6 @@ static const trait_id trait_URSINE_EYE( "URSINE_EYE" ); static const trait_id trait_VISCOUS( "VISCOUS" ); static const trait_id trait_WATERSLEEP( "WATERSLEEP" ); -static const trap_str_id tr_ledge( "tr_ledge" ); - static const vitamin_id vitamin_calcium( "calcium" ); static const vitamin_id vitamin_iron( "iron" ); @@ -11050,8 +11048,9 @@ void Character::process_effects() void Character::gravity_check() { - if( get_map().tr_at( pos_bub() ) == tr_ledge && !has_effect_with_flag( json_flag_GLIDING ) ) { - get_map().tr_at( pos_bub() ).trigger( pos(), *this ); + map &here = get_map(); + if( here.is_open_air( pos_bub() ) && !has_effect_with_flag( json_flag_GLIDING ) ) { + here.ledge( pos(), this ); get_map().update_visibility_cache( pos_bub().z() ); } } diff --git a/src/construction.cpp b/src/construction.cpp index 42c1f92962c7b..f7232415231ca 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -147,7 +147,6 @@ static const trait_id trait_SPIRITUAL( "SPIRITUAL" ); static const trait_id trait_STOCKY_TROGLO( "STOCKY_TROGLO" ); static const trap_str_id tr_firewood_source( "tr_firewood_source" ); -static const trap_str_id tr_ledge( "tr_ledge" ); static const trap_str_id tr_practice_target( "tr_practice_target" ); static const vpart_id vpart_frame( "frame" ); @@ -1464,8 +1463,7 @@ bool construct::check_unblocked( const tripoint_bub_ms &p ) // first know how to handle constructing on top of an invisible trap! // Should also check for empty space rather than open air, when such a check exists. return !here.has_furn( p ) && - ( g->is_empty( p ) || here.ter( p ) == ter_t_open_air ) && ( here.tr_at( p ).is_null() || - here.tr_at( p ) == tr_ledge ) && + ( g->is_empty( p ) || here.ter( p ) == ter_t_open_air ) && ( here.tr_at( p ).is_null() ) && here.i_at( p ).empty() && !here.veh_at( p ); } @@ -1516,9 +1514,8 @@ bool construct::check_support_below( const tripoint_bub_ms &p ) // space tiles adjacent to passable tiles, so we can't just reject all traps outright, // but have to accept those. if( !( here.passable( p ) || here.has_flag( ter_furn_flag::TFLAG_LIQUID, p ) || - here.has_flag( ter_furn_flag::TFLAG_NO_FLOOR, p ) ) || - blocking_creature || here.has_furn( p ) || !( here.tr_at( p ).is_null() || - here.tr_at( p ).id == tr_ledge || here.tr_at( p ).has_flag( json_flag_PIT ) ) || + here.has_flag( ter_furn_flag::TFLAG_NO_FLOOR, p ) ) || blocking_creature || here.has_furn( p ) || + !( here.tr_at( p ).is_null() || here.tr_at( p ).has_flag( json_flag_PIT ) ) || !here.i_at( p ).empty() || here.veh_at( p ) ) { return false; } diff --git a/src/game.cpp b/src/game.cpp index 06209bdb5a22a..af514ccccd080 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -374,8 +374,6 @@ static const trait_id trait_VINES2( "VINES2" ); static const trait_id trait_VINES3( "VINES3" ); static const trait_id trait_WAYFARER( "WAYFARER" ); -static const trap_str_id tr_ledge( "tr_ledge" ); - static const zone_type_id zone_type_LOOT_CUSTOM( "LOOT_CUSTOM" ); static const zone_type_id zone_type_NO_AUTO_PICKUP( "NO_AUTO_PICKUP" ); @@ -10453,7 +10451,7 @@ bool game::prompt_dangerous_tile( const tripoint &dest_loc, !query_yn( _( "Really step into %s?" ), enumerate_as_string( *harmful_stuff ) ) ) { return false; } - if( !harmful_stuff->empty() && u.is_mounted() && m.tr_at( dest_loc ) == tr_ledge ) { + if( !harmful_stuff->empty() && u.is_mounted() && m.is_open_air( dest_loc ) ) { add_msg( m_warning, _( "Your %s refuses to move over that ledge!" ), u.mounted_creature->get_name() ); return false; @@ -10531,16 +10529,18 @@ std::vector game::get_dangerous_tile( const tripoint_bub_ms &dest_l } } - const trap &tr = m.tr_at( dest_loc ); - // HACK: Hack for now, later ledge should stop being a trap - if( tr == tr_ledge ) { + if( m.is_open_air( dest_loc ) ) { if( !veh_dest && !u.has_effect_with_flag( json_flag_LEVITATION ) ) { - harmful_stuff.push_back( tr.name() ); + harmful_stuff.push_back( "ledge" ); if( harmful_stuff.size() == max ) { return harmful_stuff; } } - } else if( tr.can_see( dest_loc, u ) && !tr.is_benign() && !veh_dest ) { + } + + const trap &tr = m.tr_at( dest_loc ); + + if( tr.can_see( dest_loc, u ) && !tr.is_benign() && !veh_dest ) { harmful_stuff.push_back( tr.name() ); if( harmful_stuff.size() == max ) { return harmful_stuff; @@ -12025,9 +12025,8 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo // Fall down to the ground - always on the last reached tile if( !m.has_flag( ter_furn_flag::TFLAG_SWIMMABLE, c->pos_bub() ) ) { - const trap &trap_under_creature = m.tr_at( c->pos_bub() ); // Didn't smash into a wall or a floor so only take the fall damage - if( thru && trap_under_creature == tr_ledge ) { + if( thru && m.is_open_air( c->pos_bub() ) ) { m.creature_on_trap( *c, false ); } else { // Fall on ground @@ -12516,8 +12515,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) here.invalidate_map_cache( here.get_abs_sub().z() ); // Upon force movement, traps can not be avoided. - if( !wall_cling && ( get_map().tr_at( u.pos_bub() ) == tr_ledge && - !u.has_effect( effect_gliding ) ) ) { + if( !wall_cling && ( get_map().is_open_air( u.pos_bub() ) && !u.has_effect( effect_gliding ) ) ) { here.creature_on_trap( u, !force ); } @@ -12598,7 +12596,7 @@ std::optional game::find_stairs( const map &mp, int z_after, const tri z_after ) ) ); tripoint_bub_ms omtile_align_end( omtile_align_start + point( omtilesz, omtilesz ) ); - if( get_map().tr_at( u.pos_bub() ) != tr_ledge ) { + if( !get_map().is_open_air( u.pos_bub() ) ) { for( const tripoint_bub_ms &dest : mp.points_in_rectangle( omtile_align_start, omtile_align_end ) ) { if( rl_dist( u.pos_bub(), dest ) <= best && @@ -12677,7 +12675,7 @@ std::optional game::find_or_make_stairs( map &mp, const int z_after, b return stairs; } - if( u.has_effect( effect_gliding ) && get_map().tr_at( u.pos_bub() ) == tr_ledge ) { + if( u.has_effect( effect_gliding ) && get_map().is_open_air( u.pos_bub() ) ) { return stairs; } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 35da4af1990f0..3b1f54cda30ba 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -301,7 +301,6 @@ static const trait_id trait_SHELL3( "SHELL3" ); static const trait_id trait_THRESH_MARLOSS( "THRESH_MARLOSS" ); static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" ); -static const trap_str_id tr_ledge( "tr_ledge" ); static const trap_str_id tr_telepad( "tr_telepad" ); // @TODO maybe make this a property of the item (depend on volume/type) @@ -4616,9 +4615,7 @@ void trap::examine( const tripoint &examp ) const } if( can_not_be_disarmed() ) { - if( id != tr_ledge ) { - add_msg( m_info, _( "That %s looks too dangerous to mess with. Best leave it alone." ), name() ); - } + add_msg( m_info, _( "That %s looks too dangerous to mess with. Best leave it alone." ), name() ); return; } @@ -5471,7 +5468,7 @@ void iexamine::ledge( Character &you, const tripoint_bub_ms &examp ) tripoint_bub_ms jump_target( you.posx() + 2 * sgn( examp.x() - you.posx() ), you.posy() + 2 * sgn( examp.y() - you.posy() ), you.posz() ); - bool jump_target_valid = ( here.ter( jump_target ).obj().trap != tr_ledge ); + bool jump_target_valid = !here.is_open_air( jump_target ); point_rel_ms jd( examp.xy() - you.pos_bub().xy() ); int jump_direction = 0; diff --git a/src/map.cpp b/src/map.cpp index 66c9808831a4e..5a7ae1dd5911c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -118,6 +118,8 @@ static const ammo_effect_str_id ammo_effect_PLASMA( "PLASMA" ); static const ammotype ammo_battery( "battery" ); +static const bionic_id bio_shock_absorber( "bio_shock_absorber" ); + static const damage_type_id damage_bash( "bash" ); static const efftype_id effect_boomered( "boomered" ); @@ -127,11 +129,15 @@ static const efftype_id effect_fake_flu( "fake_flu" ); static const efftype_id effect_gliding( "gliding" ); static const efftype_id effect_incorporeal( "incorporeal" ); static const efftype_id effect_pet( "pet" ); +static const efftype_id effect_slow_descent( "slow_descent" ); +static const efftype_id effect_strengthened_gravity( "strengthened_gravity" ); +static const efftype_id effect_weakened_gravity( "weakened_gravity" ); static const field_type_str_id field_fd_clairvoyant( "fd_clairvoyant" ); static const flag_id json_flag_AVATAR_ONLY( "AVATAR_ONLY" ); static const flag_id json_flag_LEVITATION( "LEVITATION" ); +static const flag_id json_flag_JETPACK( "JETPACK" ); static const flag_id json_flag_PRESERVE_SPAWN_OMT( "PRESERVE_SPAWN_OMT" ); static const flag_id json_flag_PROXIMITY( "PROXIMITY" ); static const flag_id json_flag_UNDODGEABLE( "UNDODGEABLE" ); @@ -147,6 +153,8 @@ static const item_group_id Item_spawn_data_default_zombie_items( "default_zombie static const itype_id itype_battery( "battery" ); static const itype_id itype_nail( "nail" ); +static const json_character_flag json_flag_WALL_CLING( "WALL_CLING" ); + static const material_id material_glass( "glass" ); static const mtype_id mon_zombie( "mon_zombie" ); @@ -211,7 +219,6 @@ static const ter_str_id ter_t_window_no_curtains( "t_window_no_curtains" ); static const trait_id trait_SCHIZOPHRENIC( "SCHIZOPHRENIC" ); -static const trap_str_id tr_ledge( "tr_ledge" ); static const trap_str_id tr_unfinished_construction( "tr_unfinished_construction" ); #define dbg(x) DebugLog((x),D_MAP) << __FILE__ << ":" << __LINE__ << ": " @@ -2340,15 +2347,7 @@ bool map::ter_set( const tripoint_bub_ms &p, const ter_id &new_terrain, bool avo } } - // HACK: Hack around ledges in traplocs or else it gets NASTY in z-level mode - if( old_t.trap != tr_null && old_t.trap != tr_ledge ) { - auto &traps = traplocs[old_t.trap.to_i()]; - const auto iter = std::find( traps.begin(), traps.end(), p ); - if( iter != traps.end() ) { - traps.erase( iter ); - } - } - if( new_t.trap != tr_null && new_t.trap != tr_ledge ) { + if( new_t.trap != tr_null ) { traplocs[new_t.trap.to_i()].push_back( p ); } if( !new_t.emissions.empty() ) { @@ -2689,7 +2688,7 @@ bool map::valid_move( const tripoint_bub_ms &from, const tripoint_bub_ms &to, // actually make a valid ledge drop location with zlevels on, this forces // at least one zlevel drop and if down_ter is impassable it's probably // inside a wall, we could workaround that further but it's unnecessary. - const bool up_is_ledge = tr_at( up_p ) == tr_ledge; + const bool up_is_ledge = is_open_air( up_p ); if( up_ter.movecost == 0 ) { // Unpassable tile @@ -9133,7 +9132,7 @@ void map::actualize( const tripoint_rel_sm &grid ) traplocs[trap_here.to_i()].push_back( pnt ); } const ter_t &ter = tmpsub->get_ter( p ).obj(); - if( ter.trap != tr_null && ter.trap != tr_ledge ) { + if( ter.trap != tr_null ) { traplocs[ter.trap.to_i()].push_back( pnt ); } @@ -10421,9 +10420,7 @@ void map::maybe_trigger_prox_trap( const tripoint_bub_ms &pos, Creature &c, if( tr.is_null() ) { return; } - if( tr == tr_ledge && c.has_effect_with_flag( json_flag_LEVITATION ) ) { - return; - } + //Don't trigger benign traps like cots and funnels if( tr.is_benign() ) { return; @@ -10449,15 +10446,147 @@ void map::maybe_trigger_prox_trap( const tripoint_bub_ms &pos, Creature &c, tr.trigger( pos.raw(), c ); } +// TODO: Should be moved to submap or Creature? +// TODO: Typify +// TODO: Rename to try_fall or similar, or maybe drop the return? +bool map::ledge( const tripoint &p, Creature *c ) +{ + if( c == nullptr ) { + return false; + } + monster *m = dynamic_cast( c ); + if( m != nullptr && m->flies() ) { + return false; + } + + if( c->has_effect_with_flag( json_flag_LEVITATION ) && !c->has_effect( effect_slow_descent ) ) { + return false; + } + + map &here = get_map(); + + int height = 0; + tripoint_bub_ms where( p ); + tripoint_bub_ms below( where + tripoint::below ); + creature_tracker &creatures = get_creature_tracker(); + while( here.valid_move( where, below, false, true ) ) { + where.z()--; + if( get_creature_tracker().creature_at( where ) != nullptr ) { + where.z()++; + break; + } + + below.z()--; + height++; + } + + if( height == 0 && c->is_avatar() ) { + // For now just special case player, NPCs don't "zedwalk" + Creature *critter = creatures.creature_at( below, true ); + if( critter == nullptr || !critter->is_monster() ) { + return false; + } + + std::vector valid; + for( const tripoint_bub_ms &pt : here.points_in_radius( below, 1 ) ) { + if( g->is_empty( pt ) ) { + valid.push_back( pt ); + } + } + + if( valid.empty() ) { + critter->setpos( c->pos() ); + add_msg( m_bad, _( "You fall down under %s!" ), critter->disp_name() ); + } else { + critter->setpos( random_entry( valid ) ); + } + + height++; + where.z()--; + } else if( height == 0 ) { + return false; + } + + c->add_msg_if_npc( _( " falls down a level!" ) ); + Character *you = dynamic_cast( c ); + if( you == nullptr ) { + c->setpos( where ); + if( c->get_size() == creature_size::tiny ) { + height = std::max( 0, height - 1 ); + } + if( c->has_effect( effect_weakened_gravity ) ) { + height = std::max( 0, height - 1 ); + } + if( c->has_effect( effect_strengthened_gravity ) ) { + height += 1; + } + c->impact( height * 10, where.raw() ); + return true; + } + + item jetpack = you->item_worn_with_flag( json_flag_JETPACK ); + + if( you->has_flag( json_flag_WALL_CLING ) && get_map().is_wall_adjacent( p ) ) { + you->add_msg_player_or_npc( _( "You attach yourself to the nearby wall." ), + _( " clings to the wall." ) ); + return false; + } + + if( you->is_avatar() ) { + add_msg( m_bad, n_gettext( "You fall down %d story!", "You fall down %d stories!", height ), + height ); + g->vertical_move( -height, true ); + } else { + you->setpos( where ); + } + if( you->get_size() == creature_size::tiny ) { + height = std::max( 0, height - 1 ); + } + if( you->has_effect( effect_weakened_gravity ) ) { + height = std::max( 0, height - 1 ); + } + if( you->has_effect( effect_strengthened_gravity ) ) { + height += 1; + } + if( you->can_fly() ) { + you->add_msg_player_or_npc( _( "You spread your wings to slow your fall." ), + _( " spreads their wings to slow their fall." ) ); + height = std::max( 0, height - 2 ); + } + if( you->has_active_bionic( bio_shock_absorber ) ) { + you->add_msg_if_player( m_info, + _( "You hit the ground hard, but your grav chute handles the impact admirably!" ) ); + } else if( !jetpack.is_null() ) { + if( jetpack.ammo_sufficient( you ) ) { + you->add_msg_player_or_npc( _( "You ignite your %s and use it to break the fall." ), + _( " uses their %s to break the fall." ), jetpack.tname() ); + jetpack.activation_consume( 1, you->pos(), you ); + } else { + you->add_msg_if_player( m_bad, + _( "You attempt to break the fall with your %s but it is out of fuel!" ), jetpack.tname() ); + you->impact( height * 30, where.raw() ); + + } + } else { + you->impact( height * 30, where.raw() ); + } + + if( here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, where ) ) { + you->set_underwater( true ); + g->water_affect_items( *you ); + you->add_msg_player_or_npc( _( "You dive into water." ), _( " dives into water." ) ); + } + + return true; +} + void map::maybe_trigger_trap( const tripoint_bub_ms &pos, Creature &c, const bool may_avoid ) const { const trap &tr = tr_at( pos ); if( tr.is_null() ) { return; } - if( tr == tr_ledge && c.has_effect_with_flag( json_flag_LEVITATION ) ) { - return; - } + //Don't trigger benign traps like cots and funnels if( tr.is_benign() ) { return; diff --git a/src/map.h b/src/map.h index 24de5e19ecf88..ec253155793e8 100644 --- a/src/map.h +++ b/src/map.h @@ -633,6 +633,8 @@ class map bool is_open_air( const tripoint & ) const; bool is_open_air( const tripoint_bub_ms &p ) const; + bool ledge( const tripoint &p, Creature *c ); + /** * Similar behavior to `move_cost()`, but ignores vehicles. */ diff --git a/src/submap.cpp b/src/submap.cpp index ee23b928ab08e..2849956535971 100644 --- a/src/submap.cpp +++ b/src/submap.cpp @@ -17,8 +17,6 @@ static furn_id f_null; static const furn_str_id furn_f_console( "f_console" ); -static const trap_str_id tr_ledge( "tr_ledge" ); - void maptile_soa::swap_soa_tile( const point_sm_ms &p1, const point_sm_ms &p2 ) { std::swap( ter[p1.x()][p1.y()], ter[p2.x()][p2.y()] ); @@ -196,8 +194,7 @@ bool submap::contains_vehicle( vehicle *veh ) bool submap::is_open_air( const point_sm_ms &p ) const { - const ter_id &t = get_ter( p ); - return t->trap == tr_ledge; + return get_ter( p ).obj().has_flag( ter_furn_flag::TFLAG_NO_FLOOR ); } void submap::rotate( int turns ) diff --git a/src/trap.h b/src/trap.h index f109d67e6f9b8..1d8528abee990 100644 --- a/src/trap.h +++ b/src/trap.h @@ -55,7 +55,6 @@ bool pit( const tripoint &p, Creature *c, item *i ); bool pit_spikes( const tripoint &p, Creature *c, item *i ); bool pit_glass( const tripoint &p, Creature *c, item *i ); bool lava( const tripoint &p, Creature *c, item *i ); -bool ledge( const tripoint &p, Creature *c, item *i ); bool boobytrap( const tripoint &p, Creature *c, item *i ); bool temple_flood( const tripoint &p, Creature *c, item *i ); bool temple_toggle( const tripoint &p, Creature *c, item *i ); diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 6add116c5c118..2855ebe68dce3 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -57,10 +57,7 @@ static const efftype_id effect_in_pit( "in_pit" ); static const efftype_id effect_lightsnare( "lightsnare" ); static const efftype_id effect_ridden( "ridden" ); static const efftype_id effect_slimed( "slimed" ); -static const efftype_id effect_slow_descent( "slow_descent" ); -static const efftype_id effect_strengthened_gravity( "strengthened_gravity" ); static const efftype_id effect_tetanus( "tetanus" ); -static const efftype_id effect_weakened_gravity( "weakened_gravity" ); static const flag_id json_flag_LEVITATION( "LEVITATION" ); static const flag_id json_flag_PROXIMITY( "PROXIMITY" ); @@ -72,7 +69,6 @@ static const itype_id itype_grenade_act( "grenade_act" ); static const itype_id itype_rope_30( "rope_30" ); static const json_character_flag json_flag_INFECTION_IMMUNE( "INFECTION_IMMUNE" ); -static const json_character_flag json_flag_WALL_CLING( "WALL_CLING" ); static const material_id material_kevlar( "kevlar" ); static const material_id material_steel( "steel" ); @@ -1307,137 +1303,6 @@ bool trapfunc::sinkhole( const tripoint &p, Creature *c, item *i ) return true; } -bool trapfunc::ledge( const tripoint &p, Creature *c, item * ) -{ - if( c == nullptr ) { - return false; - } - monster *m = dynamic_cast( c ); - if( m != nullptr && m->flies() ) { - return false; - } - - if( c->has_effect_with_flag( json_flag_LEVITATION ) && !c->has_effect( effect_slow_descent ) ) { - return false; - } - - map &here = get_map(); - - int height = 0; - tripoint_bub_ms where( p ); - tripoint_bub_ms below( where + tripoint::below ); - creature_tracker &creatures = get_creature_tracker(); - while( here.valid_move( where, below, false, true ) ) { - where.z()--; - if( get_creature_tracker().creature_at( where ) != nullptr ) { - where.z()++; - break; - } - - below.z()--; - height++; - } - - if( height == 0 && c->is_avatar() ) { - // For now just special case player, NPCs don't "zedwalk" - Creature *critter = creatures.creature_at( below, true ); - if( critter == nullptr || !critter->is_monster() ) { - return false; - } - - std::vector valid; - for( const tripoint_bub_ms &pt : here.points_in_radius( below, 1 ) ) { - if( g->is_empty( pt ) ) { - valid.push_back( pt ); - } - } - - if( valid.empty() ) { - critter->setpos( c->pos() ); - add_msg( m_bad, _( "You fall down under %s!" ), critter->disp_name() ); - } else { - critter->setpos( random_entry( valid ) ); - } - - height++; - where.z()--; - } else if( height == 0 ) { - return false; - } - - c->add_msg_if_npc( _( " falls down a level!" ) ); - Character *you = dynamic_cast( c ); - if( you == nullptr ) { - c->setpos( where ); - if( c->get_size() == creature_size::tiny ) { - height = std::max( 0, height - 1 ); - } - if( c->has_effect( effect_weakened_gravity ) ) { - height = std::max( 0, height - 1 ); - } - if( c->has_effect( effect_strengthened_gravity ) ) { - height += 1; - } - c->impact( height * 10, where.raw() ); - return true; - } - - item jetpack = you->item_worn_with_flag( STATIC( flag_id( "JETPACK" ) ) ); - - if( you->has_flag( json_flag_WALL_CLING ) && get_map().is_wall_adjacent( p ) ) { - you->add_msg_player_or_npc( _( "You attach yourself to the nearby wall." ), - _( " clings to the wall." ) ); - return false; - } - - if( you->is_avatar() ) { - add_msg( m_bad, n_gettext( "You fall down %d story!", "You fall down %d stories!", height ), - height ); - g->vertical_move( -height, true ); - } else { - you->setpos( where ); - } - if( you->get_size() == creature_size::tiny ) { - height = std::max( 0, height - 1 ); - } - if( you->has_effect( effect_weakened_gravity ) ) { - height = std::max( 0, height - 1 ); - } - if( you->has_effect( effect_strengthened_gravity ) ) { - height += 1; - } - if( you->can_fly() ) { - you->add_msg_player_or_npc( _( "You spread your wings to slow your fall." ), - _( " spreads their wings to slow their fall." ) ); - height = std::max( 0, height - 2 ); - } - if( you->has_active_bionic( bio_shock_absorber ) ) { - you->add_msg_if_player( m_info, - _( "You hit the ground hard, but your grav chute handles the impact admirably!" ) ); - } else if( !jetpack.is_null() ) { - if( jetpack.ammo_sufficient( you ) ) { - you->add_msg_player_or_npc( _( "You ignite your %s and use it to break the fall." ), - _( " uses their %s to break the fall." ), jetpack.tname() ); - jetpack.activation_consume( 1, you->pos_bub(), you ); - } else { - you->add_msg_if_player( m_bad, - _( "You attempt to break the fall with your %s but it is out of fuel!" ), jetpack.tname() ); - you->impact( height * 30, where.raw() ); - - } - } else { - you->impact( height * 30, where.raw() ); - } - - if( here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, where ) ) { - you->set_underwater( true ); - g->water_affect_items( *you ); - you->add_msg_player_or_npc( _( "You dive into water." ), _( " dives into water." ) ); - } - - return true; -} - bool trapfunc::temple_flood( const tripoint &p, Creature *c, item * ) { if( c == nullptr ) { @@ -1789,7 +1654,6 @@ const trap_function &trap_function_from_string( const std::string &function_name { "pit_spikes", trapfunc::pit_spikes }, { "pit_glass", trapfunc::pit_glass }, { "lava", trapfunc::lava }, - { "ledge", trapfunc::ledge }, { "boobytrap", trapfunc::boobytrap }, { "temple_flood", trapfunc::temple_flood }, { "temple_toggle", trapfunc::temple_toggle }, From 929db213c5de1c9e359540b3a0a97c52b7a64751 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:02:29 +0000 Subject: [PATCH 02/18] Make non Character creatures fall again --- src/character.h | 2 +- src/creature.cpp | 5 +++++ src/creature.h | 1 + src/map.cpp | 4 ---- src/monster.cpp | 8 ++++++++ src/monster.h | 1 + 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/character.h b/src/character.h index bca79ca5f3e90..4693c05935702 100644 --- a/src/character.h +++ b/src/character.h @@ -729,7 +729,7 @@ class Character : public Creature, public visitable public: - void gravity_check(); + void gravity_check() override; void stagger(); void mod_stat( const std::string &stat, float modifier ) override; diff --git a/src/creature.cpp b/src/creature.cpp index d102156bc51df..a21d3c2a6dec2 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -219,6 +219,7 @@ void Creature::setpos( const tripoint &p ) const tripoint_abs_ms old_loc = get_location(); set_pos_only( p ); on_move( old_loc ); + gravity_check(); } void Creature::setpos( const tripoint_bub_ms &p ) @@ -317,6 +318,10 @@ std::vector Creature::get_grammatical_genders() const return {}; } +void Creature::gravity_check() +{ +} + void Creature::normalize() { } diff --git a/src/creature.h b/src/creature.h index 048100ccd6665..f31c3ca6c5905 100644 --- a/src/creature.h +++ b/src/creature.h @@ -318,6 +318,7 @@ class Creature : public viewer inline int posz() const { return get_location().z(); } + virtual void gravity_check(); // TODO: Get rid of untyped overload void setpos( const tripoint &p ); void setpos( const tripoint_bub_ms &p ); diff --git a/src/map.cpp b/src/map.cpp index 5a7ae1dd5911c..c229ca0fada99 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -10454,10 +10454,6 @@ bool map::ledge( const tripoint &p, Creature *c ) if( c == nullptr ) { return false; } - monster *m = dynamic_cast( c ); - if( m != nullptr && m->flies() ) { - return false; - } if( c->has_effect_with_flag( json_flag_LEVITATION ) && !c->has_effect( effect_slow_descent ) ) { return false; diff --git a/src/monster.cpp b/src/monster.cpp index cdc9bb9d8ad92..f5324b3e03ef6 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -413,6 +413,14 @@ bool monster::can_upgrade() const return upgrades && get_option( "MONSTER_UPGRADE_FACTOR" ) > 0.0; } +void monster::gravity_check() +{ + map &here = get_map(); + if( here.is_open_air( pos_bub() ) && !flies() ) { + here.ledge( pos(), this ); + } +} + // For master special attack. void monster::hasten_upgrade() { diff --git a/src/monster.h b/src/monster.h index 29ec1e619e036..da11a096e5192 100644 --- a/src/monster.h +++ b/src/monster.h @@ -108,6 +108,7 @@ class monster : public Creature mfaction_id get_monster_faction() const override { return faction.id(); } + void gravity_check() override; void poly( const mtype_id &id ); bool can_upgrade() const; void hasten_upgrade(); From b40f44f46df49e416e6e0e8b4960248955f7689b Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:44:16 +0000 Subject: [PATCH 03/18] Typify and rename ledge -> try_fall --- src/character.cpp | 4 ++-- src/map.cpp | 12 ++++-------- src/map.h | 2 +- src/monster.cpp | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index e997ebe858d1c..92bab118704bc 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -11049,8 +11049,8 @@ void Character::process_effects() void Character::gravity_check() { map &here = get_map(); - if( here.is_open_air( pos_bub() ) && !has_effect_with_flag( json_flag_GLIDING ) ) { - here.ledge( pos(), this ); + if( here.is_open_air( pos_bub() ) && !has_effect_with_flag( json_flag_GLIDING ) && + here.try_fall( pos_bub(), this ) ) { get_map().update_visibility_cache( pos_bub().z() ); } } diff --git a/src/map.cpp b/src/map.cpp index c229ca0fada99..dd7978dadd985 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -10447,9 +10447,7 @@ void map::maybe_trigger_prox_trap( const tripoint_bub_ms &pos, Creature &c, } // TODO: Should be moved to submap or Creature? -// TODO: Typify -// TODO: Rename to try_fall or similar, or maybe drop the return? -bool map::ledge( const tripoint &p, Creature *c ) +bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) { if( c == nullptr ) { return false; @@ -10459,13 +10457,11 @@ bool map::ledge( const tripoint &p, Creature *c ) return false; } - map &here = get_map(); - int height = 0; tripoint_bub_ms where( p ); tripoint_bub_ms below( where + tripoint::below ); creature_tracker &creatures = get_creature_tracker(); - while( here.valid_move( where, below, false, true ) ) { + while( valid_move( where, below, false, true ) ) { where.z()--; if( get_creature_tracker().creature_at( where ) != nullptr ) { where.z()++; @@ -10484,7 +10480,7 @@ bool map::ledge( const tripoint &p, Creature *c ) } std::vector valid; - for( const tripoint_bub_ms &pt : here.points_in_radius( below, 1 ) ) { + for( const tripoint_bub_ms &pt : points_in_radius( below, 1 ) ) { if( g->is_empty( pt ) ) { valid.push_back( pt ); } @@ -10567,7 +10563,7 @@ bool map::ledge( const tripoint &p, Creature *c ) you->impact( height * 30, where.raw() ); } - if( here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, where ) ) { + if( has_flag( ter_furn_flag::TFLAG_DEEP_WATER, where ) ) { you->set_underwater( true ); g->water_affect_items( *you ); you->add_msg_player_or_npc( _( "You dive into water." ), _( " dives into water." ) ); diff --git a/src/map.h b/src/map.h index ec253155793e8..713fe53c4f64a 100644 --- a/src/map.h +++ b/src/map.h @@ -633,7 +633,7 @@ class map bool is_open_air( const tripoint & ) const; bool is_open_air( const tripoint_bub_ms &p ) const; - bool ledge( const tripoint &p, Creature *c ); + bool try_fall( const tripoint_bub_ms &p, Creature *c ); /** * Similar behavior to `move_cost()`, but ignores vehicles. diff --git a/src/monster.cpp b/src/monster.cpp index f5324b3e03ef6..ea9ea69f6e585 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -417,7 +417,7 @@ void monster::gravity_check() { map &here = get_map(); if( here.is_open_air( pos_bub() ) && !flies() ) { - here.ledge( pos(), this ); + here.try_fall( pos_bub(), this ); } } From a77201745d18bc9664809be88d39a73d9b2df242 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sat, 30 Nov 2024 16:45:38 +0000 Subject: [PATCH 04/18] Add tr_ledge obsoletion --- .../obsolete_traps.json | 7 ++++ doc/OBSOLETION_AND_MIGRATION.md | 38 ++++++++++++++++++- lang/string_extractor/parser.py | 1 + src/init.cpp | 3 ++ src/mapdata.h | 13 +++++++ src/savegame_json.cpp | 25 ++++++++++++ 6 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 data/json/obsoletion_and_migration_0.I/obsolete_traps.json diff --git a/data/json/obsoletion_and_migration_0.I/obsolete_traps.json b/data/json/obsoletion_and_migration_0.I/obsolete_traps.json new file mode 100644 index 0000000000000..c8185269dc433 --- /dev/null +++ b/data/json/obsoletion_and_migration_0.I/obsolete_traps.json @@ -0,0 +1,7 @@ +[ + { + "type": "trap_migration", + "from_trap": "tr_ledge", + "to_trap": "tr_null" + } +] diff --git a/doc/OBSOLETION_AND_MIGRATION.md b/doc/OBSOLETION_AND_MIGRATION.md index e02cad6d3aba5..2507fb2b8b135 100644 --- a/doc/OBSOLETION_AND_MIGRATION.md +++ b/doc/OBSOLETION_AND_MIGRATION.md @@ -164,6 +164,40 @@ Move multiple ids that don't need to be unique any more to a single id } ``` +# Trap migration + +Trap migration replaces the provided id as submaps are loaded. You can use `tr_null` with `to_trap` to remove the trap entirely without creating errors. + +```json +{ + "type": "trap_migration", // Mandatory. String. Must be "trap_migration" + "from_trap": "tr_old_trap", // Mandatory. String. Id of the trap to replace. + "to_trap": "tr_new_trap", // Mandatory. String. Id of the new trap to place. +}, +``` + +## Examples + +Migrate an id + +```json + { + "type": "trap_migration", + "from_trap": "tr_being_migrated_id", + "to_trap": "tr_new_id" + } +``` + +Errorlessly obsolete an id + +```json + { + "type": "trap_migration", + "from_trap": "tr_being_obsoleted_id", + "to_trap": "tr_null" + } +``` + # Field migration Field migration replaces the provided id as submaps are loaded. You can use `fd_null` with `to_field` to remove the field entirely without creating errors. @@ -171,8 +205,8 @@ Field migration replaces the provided id as submaps are loaded. You can use `fd_ ```json { "type": "field_type_migration", // Mandatory. String. Must be "field_type_migration" - "from_field": "t_old_field", // Mandatory. String. Id of the field to replace. - "to_field": "f_new_field", // Mandatory. String. Id of the new field to place. + "from_field": "fd_old_field", // Mandatory. String. Id of the field to replace. + "to_field": "fd_new_field", // Mandatory. String. Id of the new field to place. }, ``` diff --git a/lang/string_extractor/parser.py b/lang/string_extractor/parser.py index 55fa013f3171e..cedf106ff76fc 100644 --- a/lang/string_extractor/parser.py +++ b/lang/string_extractor/parser.py @@ -246,6 +246,7 @@ def dummy_parser(json, origin): "trait_group": dummy_parser, "trait_migration": dummy_parser, "trap": parse_trap, + "trap_migration": dummy_parser, "tool": parse_generic, "tool_armor": parse_generic, "tool_quality": parse_tool_quality, diff --git a/src/init.cpp b/src/init.cpp index 9b0007ac6ea48..cec7aacbeae98 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -345,6 +345,7 @@ void DynamicDataLoader::initialize() requirement_data::load_requirement( jo, string_id::NULL_ID(), true ); } ); add( "trap", &trap::load_trap ); + add( "trap_migration", &trap_migrations::load ); add( "AMMO", []( const JsonObject & jo, const std::string & src ) { item_controller->load_ammo( jo, src ); @@ -748,6 +749,7 @@ void DynamicDataLoader::unload_data() ter_furn_migrations::reset(); ter_furn_transform::reset(); trap::reset(); + trap_migrations::reset(); unload_talk_topics(); VehicleGroup::reset(); VehiclePlacement::reset(); @@ -935,6 +937,7 @@ void DynamicDataLoader::check_consistency() { _( "Start locations" ), &start_locations::check_consistency }, { _( "Ammunition types" ), &ammunition_type::check_consistency }, { _( "Traps" ), &trap::check_consistency }, + { _( "Trap migrations" ), &trap_migrations::check }, { _( "Bionics" ), &bionic_data::check_bionic_consistency }, { _( "Gates" ), &gates::check }, { _( "NPC classes" ), &npc_class::check_consistency }, diff --git a/src/mapdata.h b/src/mapdata.h index 5ce0cd1d08e4c..d0bfec3dbf551 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -746,6 +746,19 @@ class ter_furn_migrations static void check(); }; +class trap_migrations +{ + public: + /** Handler for loading "trap_migration" type of json object */ + static void load( const JsonObject &jo ); + + /** Clears migration list */ + static void reset(); + + /** Checks migrations */ + static void check(); +}; + class field_type_migrations { public: diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index f87d635107bc3..3d465e264bd44 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -4663,6 +4663,31 @@ void ter_furn_migrations::check() } } +static std::unordered_map tr_migrations; + +void trap_migrations::load( const JsonObject &jo ) +{ + trap_str_id from_trap; + trap_str_id to_trap; + mandatory( jo, false, "from_trap", from_trap ); + mandatory( jo, false, "to_trap", to_trap ); + tr_migrations.insert( std::make_pair( from_trap, to_trap ) ); +} + +void trap_migrations::reset() +{ + tr_migrations.clear(); +} + +void trap_migrations::check() +{ + for( const auto &migration : tr_migrations ) { + if( !migration.second.is_valid() ) { + debugmsg( "trap_migration specifies invalid to_trap id '%s'", migration.second.c_str() ); + } + } +} + static std::unordered_map field_migrations; void field_type_migrations::load( const JsonObject &jo ) From 2f0122a44285471bbd23c1b80263cd7c1d4a7590 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sun, 1 Dec 2024 13:09:47 +0000 Subject: [PATCH 05/18] Remove t_hole --- .../terrain-floors-indoor.json | 2 ++ .../terrain-highways.json | 6 ++-- .../furniture_and_terrain/terrain-roofs.json | 33 ++++++++++--------- .../furniture_and_terrain/terrain-traps.json | 12 ------- .../terrain-windows.json | 4 +-- .../terrain_vitrified.json | 2 +- data/json/mapgen/drive-in_theater.json | 2 +- data/json/mapgen/farm.json | 2 +- data/json/mapgen/farm_dairy_2.json | 2 +- .../isherwood_farms/farm_isherwood.json | 2 +- data/json/mapgen/lab_subway_vent_shaft.json | 2 +- data/json/mapgen/megastore.json | 2 +- .../mapgen/microlab/microlab_reactor.json | 2 +- data/json/mapgen/mine/mine_shaft.json | 2 +- .../mobile_home_park/mobile_home_park.json | 2 +- data/json/mapgen/private_resort.json | 2 +- .../json/mapgen_palettes/collapsed_tower.json | 2 +- .../convention_center_palette.json | 2 +- data/json/mapgen_palettes/robofachq.json | 2 +- .../migration_terrain.json | 7 ++++ .../Aftershock/maps/mapgen/map_palletes.json | 2 +- .../ter_fur_transform/ter_fur_transform.json | 4 +-- data/mods/Magiclysm/worldgen/mine_balrog.json | 4 +-- data/mods/No_Hope/Mapgen/necropolisB2.json | 2 +- .../mapgen_palettes/necropolis_palettes.json | 6 ++-- .../terrain-eruption.json | 9 ++++- .../ter_transforms/ierde_ter_transform.json | 2 +- src/computer_session.cpp | 6 ++-- src/construction.cpp | 3 +- 29 files changed, 67 insertions(+), 63 deletions(-) create mode 100644 data/json/obsoletion_and_migration_0.I/migration_terrain.json diff --git a/data/json/furniture_and_terrain/terrain-floors-indoor.json b/data/json/furniture_and_terrain/terrain-floors-indoor.json index 40b620ebca375..a19463fa835a1 100644 --- a/data/json/furniture_and_terrain/terrain-floors-indoor.json +++ b/data/json/furniture_and_terrain/terrain-floors-indoor.json @@ -1702,6 +1702,7 @@ "color": "white", "move_cost": 2, "connect_groups": "INDOORFLOOR", + "//": "TODO: Should break when you step on it if there's no supporting terrain below, might want some warning akin to examine_action ledge", "flags": [ "TRANSPARENT", "FLAMMABLE_ASH", "INDOORS", "NO_FLOOR" ], "bash": { "str_min": 1, @@ -1719,6 +1720,7 @@ "name": "open air", "description": "An area of open air.", "//": "Actually, this is a thin membrane of bullshit to keep wasp eggs levitating.", + "//1": "Why do we want eggs to levitate??", "symbol": " ", "looks_like": "t_open_air", "color": "i_cyan", diff --git a/data/json/furniture_and_terrain/terrain-highways.json b/data/json/furniture_and_terrain/terrain-highways.json index 6fbb5e472f7c8..6a474f0befad7 100644 --- a/data/json/furniture_and_terrain/terrain-highways.json +++ b/data/json/furniture_and_terrain/terrain-highways.json @@ -16,7 +16,7 @@ "str_max": 300, "sound": "concrete cracking and metal screeching!", "sound_fail": "whump!", - "ter_set": "t_hole", + "ter_set": "t_null", "items": [ { "item": "rock", "count": [ 4, 20 ] }, { "item": "rebar", "count": [ 10, 20 ] } ] } }, @@ -37,7 +37,7 @@ "str_max": 300, "sound": "concrete cracking and metal screeching!", "sound_fail": "whump!", - "ter_set": "t_hole", + "ter_set": "t_null", "items": [ { "item": "rock", "count": [ 4, 20 ] }, { "item": "rebar", "count": [ 10, 20 ] } ] } }, @@ -56,7 +56,7 @@ "str_max": 300, "sound": "concrete cracking and metal screeching!", "sound_fail": "whump!", - "ter_set": "t_hole", + "ter_set": "t_null", "items": [ { "item": "rock", "count": [ 4, 20 ] }, { "item": "rebar", "count": [ 10, 20 ] } ] } } diff --git a/data/json/furniture_and_terrain/terrain-roofs.json b/data/json/furniture_and_terrain/terrain-roofs.json index 84f41707b5992..2dbba863ac512 100644 --- a/data/json/furniture_and_terrain/terrain-roofs.json +++ b/data/json/furniture_and_terrain/terrain-roofs.json @@ -110,7 +110,7 @@ "color": "dark_gray", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT", "ROAD" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -122,7 +122,7 @@ "color": "dark_gray", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAMMABLE", "FLAT" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -134,7 +134,7 @@ "color": "green", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAMMABLE", "FLAT" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -146,7 +146,7 @@ "color": "yellow", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAMMABLE" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -158,7 +158,7 @@ "color": "light_gray", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT", "ROAD" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -170,7 +170,7 @@ "color": "white", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT", "FLAMMABLE" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -181,6 +181,7 @@ "looks_like": "t_linoleum_white", "color": "cyan", "move_cost": 2, + "//": "TODO: Should break when you step on it if there's no supporting terrain below, might want some warning akin to examine_action ledge", "flags": [ "TRANSPARENT", "TRANSPARENT_FLOOR" ], "bash": { "str_min": 3, @@ -201,7 +202,7 @@ "color": "brown", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT" ], - "bash": { "str_min": 100, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 100, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -230,7 +231,7 @@ "sound_fail": "slap!", "sound_vol": 8, "sound_fail_vol": 4, - "ter_set": "t_hole", + "ter_set": "t_null", "bash_below": false } }, @@ -252,7 +253,7 @@ "sound_fail": "slap!", "sound_vol": 15, "sound_fail_vol": 10, - "ter_set": "t_hole", + "ter_set": "t_null", "bash_below": false } }, @@ -266,7 +267,7 @@ "color": "dark_gray", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT", "ROAD" ], - "bash": { "str_min": 100, "str_max": 400, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 100, "str_max": 400, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -278,7 +279,7 @@ "color": "brown", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAMMABLE", "FLAT" ], - "bash": { "str_min": 50, "str_max": 400, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 50, "str_max": 400, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -290,7 +291,7 @@ "color": "brown", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAMMABLE_HARD", "FLAT" ], - "bash": { "str_min": 50, "str_max": 400, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 50, "str_max": 400, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -302,7 +303,7 @@ "color": "dark_gray", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT", "ROAD" ], - "bash": { "str_min": 200, "str_max": 500, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 200, "str_max": 500, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -326,7 +327,7 @@ "color": "green", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAMMABLE" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -337,7 +338,7 @@ "color": "red", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT", "ROAD" ], - "bash": { "str_min": 48, "str_max": 80, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 48, "str_max": 80, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", @@ -348,7 +349,7 @@ "color": "blue", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAMMABLE_HARD" ], - "bash": { "str_min": 1, "str_max": 8, "sound": "rrrrip!", "sound_fail": "slap!", "ter_set": "t_hole", "bash_below": false } + "bash": { "str_min": 1, "str_max": 8, "sound": "rrrrip!", "sound_fail": "slap!", "ter_set": "t_null", "bash_below": false } }, { "type": "terrain", diff --git a/data/json/furniture_and_terrain/terrain-traps.json b/data/json/furniture_and_terrain/terrain-traps.json index 31accae770456..72aa504afac9e 100644 --- a/data/json/furniture_and_terrain/terrain-traps.json +++ b/data/json/furniture_and_terrain/terrain-traps.json @@ -1,16 +1,4 @@ [ - { - "type": "terrain", - "//": "TODO: Remove", - "id": "t_hole", - "name": "empty space", - "description": "An area of empty space.", - "symbol": " ", - "color": "black", - "move_cost": 2, - "flags": [ "TRANSPARENT", "NO_FLOOR", "EMPTY_SPACE" ], - "examine_action": "ledge" - }, { "type": "terrain", "id": "t_pit_shallow", diff --git a/data/json/furniture_and_terrain/terrain-windows.json b/data/json/furniture_and_terrain/terrain-windows.json index 5cde9a93af147..6d319c59d640b 100644 --- a/data/json/furniture_and_terrain/terrain-windows.json +++ b/data/json/furniture_and_terrain/terrain-windows.json @@ -4386,7 +4386,7 @@ "move_cost": 2, "coverage": 0, "examine_action": "ledge", - "deconstruct": { "ter_set": "t_hole", "items": [ { "item": "2x4", "count": [ 3, 4 ] }, { "item": "nail", "charges": [ 12, 16 ] } ] }, + "deconstruct": { "ter_set": "t_null", "items": [ { "item": "2x4", "count": [ 3, 4 ] }, { "item": "nail", "charges": [ 12, 16 ] } ] }, "bash": { "str_min": 1, "str_max": 1, @@ -4394,7 +4394,7 @@ "sound_fail": "whack!", "sound_vol": 12, "sound_fail_vol": 8, - "ter_set": "t_hole", + "ter_set": "t_null", "items": [ { "item": "2x4", "count": [ 2, 4 ] } ] }, "flags": [ "TRANSPARENT", "NO_FLOOR", "FLAMMABLE" ] diff --git a/data/json/furniture_and_terrain/terrain_vitrified.json b/data/json/furniture_and_terrain/terrain_vitrified.json index 11dd95f5c3aad..362bba18989e4 100644 --- a/data/json/furniture_and_terrain/terrain_vitrified.json +++ b/data/json/furniture_and_terrain/terrain_vitrified.json @@ -555,7 +555,7 @@ "move_cost": 2, "connect_groups": "INDOORFLOOR", "flags": [ "SUPPORTS_ROOF", "TRANSPARENT", "INDOORS", "UNSTABLE" ], - "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": true } + "bash": { "str_min": 30, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_null", "bash_below": true } }, { "type": "terrain", diff --git a/data/json/mapgen/drive-in_theater.json b/data/json/mapgen/drive-in_theater.json index a053a169f6c35..706b7001b2e5a 100644 --- a/data/json/mapgen/drive-in_theater.json +++ b/data/json/mapgen/drive-in_theater.json @@ -327,7 +327,7 @@ } }, "terrain": { - "│": "t_hole", + "│": "t_open_air", ".": "t_region_groundcover", "V": "t_region_groundcover", "$": "t_region_groundcover", diff --git a/data/json/mapgen/farm.json b/data/json/mapgen/farm.json index ac1df049e6996..e5c6c3eac7664 100644 --- a/data/json/mapgen/farm.json +++ b/data/json/mapgen/farm.json @@ -81,7 +81,7 @@ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF " ], "palettes": [ "farm" ], - "terrain": { "│": "t_hole" }, + "terrain": { "│": "t_open_air" }, "place_item": [ { "item": "straw_pile", "x": [ 3, 5 ], "y": [ 5, 7 ], "amount": [ 0, 8 ] }, { "item": "cattlefodder", "x": [ 3, 5 ], "y": [ 5, 7 ], "amount": [ 0, 4 ] }, diff --git a/data/json/mapgen/farm_dairy_2.json b/data/json/mapgen/farm_dairy_2.json index caa326397a300..a765d07a87115 100644 --- a/data/json/mapgen/farm_dairy_2.json +++ b/data/json/mapgen/farm_dairy_2.json @@ -85,7 +85,7 @@ ], "sealed_item": { "#": { "item": { "item": "seed_corn", "chance": 100 }, "furniture": "f_plant_seedling" } }, "terrain": { - "│": "t_hole", + "│": "t_open_air", " ": [ [ "t_region_groundcover", 99 ], [ "t_region_shrub", 1 ] ], ",": [ [ "t_region_soil", 200 ], [ "t_region_groundcover", 5 ] ], ";": [ [ "t_dirtfloor_no_roof", 80 ], [ "t_region_soil", 20 ] ], diff --git a/data/json/mapgen/isherwood_farms/farm_isherwood.json b/data/json/mapgen/isherwood_farms/farm_isherwood.json index 8ff1139379951..106db85ddc046 100644 --- a/data/json/mapgen/isherwood_farms/farm_isherwood.json +++ b/data/json/mapgen/isherwood_farms/farm_isherwood.json @@ -94,7 +94,7 @@ "F F ", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF " ], - "terrain": { "│": "t_hole", "<": "t_ladder_up", ",": "t_woodchips" }, + "terrain": { "│": "t_open_air", "<": "t_ladder_up", ",": "t_woodchips" }, "place_item": [ { "item": "straw_pile", "x": [ 3, 5 ], "y": [ 5, 7 ], "amount": [ 0, 8 ] }, { "item": "cattlefodder", "x": [ 3, 5 ], "y": [ 5, 7 ], "amount": [ 0, 4 ] }, diff --git a/data/json/mapgen/lab_subway_vent_shaft.json b/data/json/mapgen/lab_subway_vent_shaft.json index 137568da2e404..29438b89958b8 100644 --- a/data/json/mapgen/lab_subway_vent_shaft.json +++ b/data/json/mapgen/lab_subway_vent_shaft.json @@ -10,7 +10,7 @@ ",": "t_region_groundcover_urban", ".": "t_metal_floor_no_roof", "=": "t_metal_ventilation_shutter", - "`": "t_hole", + "`": "t_open_air", "w": "t_bridge", "~": "t_water_pool_shallow", "<": "t_ladder_up", diff --git a/data/json/mapgen/megastore.json b/data/json/mapgen/megastore.json index 85daf2b1f9711..a8ae91849b24e 100644 --- a/data/json/mapgen/megastore.json +++ b/data/json/mapgen/megastore.json @@ -4,7 +4,7 @@ "id": "megastore", "palettes": [ "parametrized_highrise_walls_palette" ], "terrain": { - "│": "t_hole", + "│": "t_open_air", " ": "t_region_groundcover_urban", "_": "t_pavement", ",": "t_concrete", diff --git a/data/json/mapgen/microlab/microlab_reactor.json b/data/json/mapgen/microlab/microlab_reactor.json index 3ad32c5f6120b..187445b99c5ba 100644 --- a/data/json/mapgen/microlab/microlab_reactor.json +++ b/data/json/mapgen/microlab/microlab_reactor.json @@ -39,7 +39,7 @@ ], "palettes": [ "microlab_generic" ], "items": { "d": { "item": "cop_armory", "chance": 5 }, "l": { "item": "decontamination_room", "chance": 70 } }, - "terrain": { "-": "t_wall_metal", "`": "t_hole", "#": "t_rock", "G": "t_card_science", "g": "t_bridge", "A": "t_bridge" }, + "terrain": { "-": "t_wall_metal", "`": "t_open_air", "#": "t_rock", "G": "t_card_science", "g": "t_bridge", "A": "t_bridge" }, "furniture": { "A": "f_nuclear_fuel_cell" } } }, diff --git a/data/json/mapgen/mine/mine_shaft.json b/data/json/mapgen/mine/mine_shaft.json index d87abe134caaf..a48da477bb58d 100644 --- a/data/json/mapgen/mine/mine_shaft.json +++ b/data/json/mapgen/mine/mine_shaft.json @@ -31,7 +31,7 @@ " ", " " ], - "terrain": { "<": "t_ladder_up", ">": "t_ladder_down", "#": "t_grate", ".": "t_hole" } + "terrain": { "<": "t_ladder_up", ">": "t_ladder_down", "#": "t_grate", ".": "t_open_air" } } }, { diff --git a/data/json/mapgen/mobile_home_park/mobile_home_park.json b/data/json/mapgen/mobile_home_park/mobile_home_park.json index 7a37bd53e2b1f..8428309f953c5 100644 --- a/data/json/mapgen/mobile_home_park/mobile_home_park.json +++ b/data/json/mapgen/mobile_home_park/mobile_home_park.json @@ -178,7 +178,7 @@ { "vehicle": "parking_garage", "x": 17, "y": 12, "chance": 20, "rotation": 0 }, { "vehicle": "parking_garage", "x": 17, "y": 17, "chance": 20, "rotation": 0 } ], - "terrain": { "│": "t_hole", "b": "t_concrete", "Z": "t_sai_box" } + "terrain": { "│": "t_open_air", "b": "t_concrete", "Z": "t_sai_box" } } }, { diff --git a/data/json/mapgen/private_resort.json b/data/json/mapgen/private_resort.json index 710de6cc6c26f..19ae4ded69148 100644 --- a/data/json/mapgen/private_resort.json +++ b/data/json/mapgen/private_resort.json @@ -56,7 +56,7 @@ "││││││││││││││││││││││││|......................|||||||..cc...|||+||# F " ], "palettes": [ "p_resort_palette_main_floor" ], - "terrain": { "│": "t_hole", "L": "t_thconc_floor" }, + "terrain": { "│": "t_open_air", "L": "t_thconc_floor" }, "place_fields": [ { "field": "fd_bile", "x": [ 25, 46 ], "y": [ 5, 22 ], "repeat": [ 40, 60 ] } ], "items": { "N": [ diff --git a/data/json/mapgen_palettes/collapsed_tower.json b/data/json/mapgen_palettes/collapsed_tower.json index 518d975f132e3..c3f11f79cc797 100644 --- a/data/json/mapgen_palettes/collapsed_tower.json +++ b/data/json/mapgen_palettes/collapsed_tower.json @@ -26,7 +26,7 @@ "w": "t_door_c", "y": "t_pavement_y", "z": "t_region_shrub_decorative", - "`": "t_hole", + "`": "t_open_air", "{": "t_door_glass_c", "|": "t_concrete_wall", "~": "t_water_sh" diff --git a/data/json/mapgen_palettes/convention_center_palette.json b/data/json/mapgen_palettes/convention_center_palette.json index 71ef1dfa49be6..695d6cea281e2 100644 --- a/data/json/mapgen_palettes/convention_center_palette.json +++ b/data/json/mapgen_palettes/convention_center_palette.json @@ -13,7 +13,7 @@ } ], "terrain": { - "│": "t_hole", + "│": "t_open_air", "_": "t_concrete", "A": "t_concrete", "f": "t_chainfence", diff --git a/data/json/mapgen_palettes/robofachq.json b/data/json/mapgen_palettes/robofachq.json index 09952a7223c8c..b83f828611a74 100644 --- a/data/json/mapgen_palettes/robofachq.json +++ b/data/json/mapgen_palettes/robofachq.json @@ -22,7 +22,7 @@ "g": "t_bridge", "_": "t_pavement", "y": "t_pavement_y", - "`": "t_hole", + "`": "t_open_air", "<": "t_stairs_up", ">": "t_stairs_down", "0": "t_window_empty", diff --git a/data/json/obsoletion_and_migration_0.I/migration_terrain.json b/data/json/obsoletion_and_migration_0.I/migration_terrain.json new file mode 100644 index 0000000000000..4d0fb887e5303 --- /dev/null +++ b/data/json/obsoletion_and_migration_0.I/migration_terrain.json @@ -0,0 +1,7 @@ +[ + { + "type": "ter_furn_migration", + "from_ter": "t_hole", + "to_ter": "t_open_air" + } +] diff --git a/data/mods/Aftershock/maps/mapgen/map_palletes.json b/data/mods/Aftershock/maps/mapgen/map_palletes.json index 9c38f1f53d8f2..cb7ec146f7043 100644 --- a/data/mods/Aftershock/maps/mapgen/map_palletes.json +++ b/data/mods/Aftershock/maps/mapgen/map_palletes.json @@ -19,7 +19,7 @@ "g": "t_bridge", "_": "t_pavement", "y": "t_pavement_y", - "`": "t_hole", + "`": "t_open_air", "<": "t_stairs_up", ">": "t_stairs_down", "0": "t_window_empty", diff --git a/data/mods/Magiclysm/ter_fur_transform/ter_fur_transform.json b/data/mods/Magiclysm/ter_fur_transform/ter_fur_transform.json index 21784afc0a8a4..1c4d8f90ec361 100644 --- a/data/mods/Magiclysm/ter_fur_transform/ter_fur_transform.json +++ b/data/mods/Magiclysm/ter_fur_transform/ter_fur_transform.json @@ -3,7 +3,7 @@ "type": "ter_furn_transform", "id": "move_earth", "terrain": [ - { "result": "t_hole", "valid_terrain": [ "t_pit", "t_slope_down" ], "message": "The pit has deepened further." }, + { "result": "t_open_air", "valid_terrain": [ "t_pit", "t_slope_down" ], "message": "The pit has deepened further." }, { "result": "t_pit", "valid_terrain": [ @@ -71,7 +71,7 @@ }, { "result": "t_rock_floor", "valid_terrain": [ "t_rock" ], "message": "The rock crumbles to dust." }, { - "result": "t_hole", + "result": "t_open_air", "valid_terrain": [ "t_null" ], "message": "All the dust in the air here falls to the ground.", "message_good": false diff --git a/data/mods/Magiclysm/worldgen/mine_balrog.json b/data/mods/Magiclysm/worldgen/mine_balrog.json index 5f9343a14eadb..b4a54edbd19c4 100644 --- a/data/mods/Magiclysm/worldgen/mine_balrog.json +++ b/data/mods/Magiclysm/worldgen/mine_balrog.json @@ -194,7 +194,7 @@ "#": "t_rock", "<": "t_stairs_up", "$": "t_lava", - "~": "t_hole", + "~": "t_open_air", "x": "t_rock_wall", "+": "t_door_c" }, @@ -235,7 +235,7 @@ "~~~~~~~~~~~~~~~~~~~~~~~~", "~~~~~~~~~~~~~~~~~~~~~~~~" ], - "terrain": { "~": "t_hole" } + "terrain": { "~": "t_open_air" } } }, { diff --git a/data/mods/No_Hope/Mapgen/necropolisB2.json b/data/mods/No_Hope/Mapgen/necropolisB2.json index 00d1d5eaa8872..3aff348e31638 100644 --- a/data/mods/No_Hope/Mapgen/necropolisB2.json +++ b/data/mods/No_Hope/Mapgen/necropolisB2.json @@ -368,7 +368,7 @@ "|EE| |EE|.|/////|..........|---|G h6 G|..|k6k a 6k" ], "palettes": [ "necropolis_b2" ], - "terrain": { "R": "t_hole" }, + "terrain": { "R": "t_open_air" }, "place_monsters": [ { "monster": "GROUP_NECROPOLIS_VAULT2", "x": [ 6, 22 ], "y": [ 1, 20 ], "density": 0.05 }, { "monster": "GROUP_NECROPOLIS_VAULT2", "x": [ 6, 22 ], "y": [ 1, 20 ], "density": 0.25 }, diff --git a/data/mods/No_Hope/mapgen_palettes/necropolis_palettes.json b/data/mods/No_Hope/mapgen_palettes/necropolis_palettes.json index 8eea24ba408f7..55ebd90fb0957 100644 --- a/data/mods/No_Hope/mapgen_palettes/necropolis_palettes.json +++ b/data/mods/No_Hope/mapgen_palettes/necropolis_palettes.json @@ -84,7 +84,7 @@ "O": "t_floor", "P": "t_floor", "Q": "t_fence", - "R": "t_hole", + "R": "t_open_air", "S": "t_floor", "T": "t_region_tree", "V": "t_wall_glass", @@ -183,7 +183,7 @@ "H": "t_wall_glass", "I": "t_column", "L": "t_floor", - "R": "t_hole", + "R": "t_open_air", "S": "t_floor", "U": "t_floor", "V": "t_wall_glass", @@ -414,7 +414,7 @@ "N": "t_metal_floor", "O": "t_metal_floor", "P": "t_metal_floor", - "R": "t_hole", + "R": "t_open_air", "S": "t_metal_floor", "U": "t_metal_floor", "V": "t_wall_glass", diff --git a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json index e71582678db2e..a8c2fbf6efaa6 100644 --- a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json +++ b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json @@ -83,7 +83,14 @@ "color": "brown", "move_cost": 2, "flags": [ "TRANSPARENT", "FLAT" ], - "bash": { "str_min": 100, "str_max": 210, "sound": "crash!", "sound_fail": "whump!", "ter_set": "t_hole", "bash_below": false } + "bash": { + "str_min": 100, + "str_max": 210, + "sound": "crash!", + "sound_fail": "whump!", + "ter_set": "t_open_air", + "bash_below": false + } }, { "type": "terrain", diff --git a/data/mods/Xedra_Evolved/ter_transforms/ierde_ter_transform.json b/data/mods/Xedra_Evolved/ter_transforms/ierde_ter_transform.json index 1e1dabdb0a5e6..8a71e4e583b97 100644 --- a/data/mods/Xedra_Evolved/ter_transforms/ierde_ter_transform.json +++ b/data/mods/Xedra_Evolved/ter_transforms/ierde_ter_transform.json @@ -113,7 +113,7 @@ "terrain": [ { "result": "t_dirt", "valid_terrain": [ "t_soil" ], "message": "The solid earth sinks away." }, { "result": "t_pit", "valid_flags": [ "DIGGABLE" ], "message": "The ground opens up!" }, - { "result": "t_hole", "valid_terrain": [ "t_pit" ], "message": "The pit deepens!" } + { "result": "t_open_air", "valid_terrain": [ "t_pit" ], "message": "The pit deepens!" } ] }, { diff --git a/src/computer_session.cpp b/src/computer_session.cpp index e6d743ab281fb..8ca2fcd65c7e1 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -122,9 +122,9 @@ static const ter_str_id ter_t_floor_blue( "t_floor_blue" ); static const ter_str_id ter_t_floor_green( "t_floor_green" ); static const ter_str_id ter_t_floor_red( "t_floor_red" ); static const ter_str_id ter_t_grate( "t_grate" ); -static const ter_str_id ter_t_hole( "t_hole" ); static const ter_str_id ter_t_metal_floor( "t_metal_floor" ); static const ter_str_id ter_t_missile( "t_missile" ); +static const ter_str_id ter_t_open_air( "t_open_air" ); static const ter_str_id ter_t_rad_platform( "t_rad_platform" ); static const ter_str_id ter_t_radio_tower( "t_radio_tower" ); static const ter_str_id ter_t_reinforced_glass( "t_reinforced_glass" ); @@ -779,9 +779,9 @@ void computer_session::action_miss_launch() false ); if( level < 0 ) { - tmpmap.translate( ter_t_missile, ter_t_hole ); + tmpmap.translate( ter_t_missile, ter_t_open_air ); } else { - tmpmap.translate( ter_t_metal_floor, ter_t_hole ); + tmpmap.translate( ter_t_metal_floor, ter_t_open_air ); } tmpmap.save(); } diff --git a/src/construction.cpp b/src/construction.cpp index f7232415231ca..b9aa517fa4db9 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -124,7 +124,6 @@ static const skill_id skill_fabrication( "fabrication" ); static const ter_str_id ter_t_clay( "t_clay" ); static const ter_str_id ter_t_dirt( "t_dirt" ); -static const ter_str_id ter_t_hole( "t_hole" ); static const ter_str_id ter_t_ladder_up( "t_ladder_up" ); static const ter_str_id ter_t_lava( "t_lava" ); static const ter_str_id ter_t_open_air( "t_open_air" ); @@ -1870,7 +1869,7 @@ void construct::done_digormine_stair( const tripoint_bub_ms &p, bool dig, } else { add_msg( m_warning, _( "You just tunneled into lava!" ) ); get_event_bus().send(); - here.ter_set( p, ter_t_hole ); + here.ter_set( p, ter_t_open_air ); } return; From 6453bff2b13bcbfca10fd29ec0fd7f64c8d900a5 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sun, 1 Dec 2024 15:28:17 +0000 Subject: [PATCH 06/18] Fix climbing down triggering falling first resulting in you burying yourself --- src/creature.cpp | 10 ++++++---- src/creature.h | 4 ++-- src/game.cpp | 8 ++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/creature.cpp b/src/creature.cpp index a21d3c2a6dec2..1d69841e6557c 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -214,17 +214,19 @@ tripoint_bub_ms Creature::pos_bub() const return get_map().bub_from_abs( location ); } -void Creature::setpos( const tripoint &p ) +void Creature::setpos( const tripoint &p, const bool check_gravity/* = true*/ ) { const tripoint_abs_ms old_loc = get_location(); set_pos_only( p ); on_move( old_loc ); - gravity_check(); + if( check_gravity ) { + gravity_check(); + } } -void Creature::setpos( const tripoint_bub_ms &p ) +void Creature::setpos( const tripoint_bub_ms &p, const bool check_gravity/* = true*/ ) { - Creature::setpos( p.raw() ); + Creature::setpos( p.raw(), check_gravity ); } bool Creature::will_be_cramped_in_vehicle_tile( const tripoint_abs_ms &loc ) const diff --git a/src/creature.h b/src/creature.h index f31c3ca6c5905..9d74b0cb748da 100644 --- a/src/creature.h +++ b/src/creature.h @@ -320,8 +320,8 @@ class Creature : public viewer } virtual void gravity_check(); // TODO: Get rid of untyped overload - void setpos( const tripoint &p ); - void setpos( const tripoint_bub_ms &p ); + void setpos( const tripoint &p, const bool check_gravity = true ); + void setpos( const tripoint_bub_ms &p, const bool check_gravity = true ); /** Checks if the creature fits confortably into a given tile. */ bool will_be_cramped_in_vehicle_tile( const tripoint_abs_ms &loc ) const; diff --git a/src/game.cpp b/src/game.cpp index af514ccccd080..228a7292a150a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -12514,10 +12514,6 @@ void game::vertical_move( int movez, bool force, bool peeking ) } here.invalidate_map_cache( here.get_abs_sub().z() ); - // Upon force movement, traps can not be avoided. - if( !wall_cling && ( get_map().is_open_air( u.pos_bub() ) && !u.has_effect( effect_gliding ) ) ) { - here.creature_on_trap( u, !force ); - } u.recoil = MAX_RECOIL; @@ -13909,7 +13905,7 @@ void game::climb_down_using( const tripoint_bub_ms &examp, climbing_aid_id aid_i float weary_mult = 1.0f / you.exertion_adjusted_move_multiplier( ACTIVE_EXERCISE ); you.mod_moves( -to_moves( 1_seconds + 1_seconds * fall_mod ) * weary_mult ); - you.setpos( examp ); + you.setpos( examp, false ); // Pre-descent message. if( !aid.down.msg_before.empty() ) { @@ -13962,7 +13958,7 @@ void game::climb_down_using( const tripoint_bub_ms &examp, climbing_aid_id aid_i you.mod_thirst( aid.down.cost.thirst ); } - // vertical_move with force=true triggers traps (ie, fall) at the end of the move. + // vertical_move with force=true triggers traps at the end of the move. g->vertical_move( -descended_levels, true ); if( here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, you.pos_bub() ) ) { From 4f7c6b25ba709f57e60b7983c6688e6fa277c868 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:46:18 +0000 Subject: [PATCH 07/18] Update map.cpp --- src/map.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index dd7978dadd985..44dba47f14e38 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -10516,8 +10516,6 @@ bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) return true; } - item jetpack = you->item_worn_with_flag( json_flag_JETPACK ); - if( you->has_flag( json_flag_WALL_CLING ) && get_map().is_wall_adjacent( p ) ) { you->add_msg_player_or_npc( _( "You attach yourself to the nearby wall." ), _( " clings to the wall." ) ); @@ -10531,20 +10529,27 @@ bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) } else { you->setpos( where ); } + if( you->get_size() == creature_size::tiny ) { height = std::max( 0, height - 1 ); } + if( you->has_effect( effect_weakened_gravity ) ) { height = std::max( 0, height - 1 ); } + if( you->has_effect( effect_strengthened_gravity ) ) { height += 1; } + if( you->can_fly() ) { you->add_msg_player_or_npc( _( "You spread your wings to slow your fall." ), _( " spreads their wings to slow their fall." ) ); height = std::max( 0, height - 2 ); } + + item jetpack = you->item_worn_with_flag( json_flag_JETPACK ); + if( you->has_active_bionic( bio_shock_absorber ) ) { you->add_msg_if_player( m_info, _( "You hit the ground hard, but your grav chute handles the impact admirably!" ) ); @@ -10552,7 +10557,7 @@ bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) if( jetpack.ammo_sufficient( you ) ) { you->add_msg_player_or_npc( _( "You ignite your %s and use it to break the fall." ), _( " uses their %s to break the fall." ), jetpack.tname() ); - jetpack.activation_consume( 1, you->pos(), you ); + jetpack.activation_consume( 1, you->pos_bub(), you ); } else { you->add_msg_if_player( m_bad, _( "You attempt to break the fall with your %s but it is out of fuel!" ), jetpack.tname() ); From e4af39e502f1d87bd7a8a78e1459e24b9703acf7 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:44:17 +0000 Subject: [PATCH 08/18] Fix being grapple pulled off a roof sending you into the ground --- src/mattack_actors.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index 7e6421c1294e4..09f919b34976b 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -549,7 +549,8 @@ int melee_actor::do_grab( monster &z, Creature *target, bodypart_id bp_id ) cons } } - target->setpos( pt ); + // Don't try to fall mid pull + target->setpos( pt, false ); pull_range--; if( animate ) { g->invalidate_main_ui_adaptor(); From 02351619087c873246b352bcfb2781d3be307e5e Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:23:40 +0000 Subject: [PATCH 09/18] Fix spawned NPCs not falling until they move --- src/npc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/npc.cpp b/src/npc.cpp index 74751a2c6df8b..c591f46ac5d21 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -3294,6 +3294,7 @@ void npc::on_load() map &here = get_map(); // for spawned npcs + gravity_check(); if( here.has_flag( ter_furn_flag::TFLAG_UNSTABLE, pos_bub() ) && !here.has_vehicle_floor( pos_bub() ) ) { add_effect( effect_bouldering, 1_turns, true ); From 6d78f9630c087136546277b7897a04083724d0c7 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:25:04 +0000 Subject: [PATCH 10/18] Fix spawned monsters not falling until they move Not the most ideal looking spot for this but its the only place all the calls I could find filter down to --- src/game.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 228a7292a150a..3a9d2c9a036be 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5179,7 +5179,11 @@ monster *game::place_critter_around( const shared_ptr_fast &mon, return nullptr; } mon->spawn( *where ); - return critter_tracker->add( mon ) ? mon.get() : nullptr; + if( critter_tracker->add( mon ) ) { + mon->gravity_check(); + return mon.get(); + } + return nullptr; } monster *game::place_critter_within( const mtype_id &id, const tripoint_range &range ) @@ -5201,7 +5205,11 @@ monster *game::place_critter_within( const shared_ptr_fast &mon, return nullptr; } mon->spawn( *where ); - return critter_tracker->add( mon ) ? mon.get() : nullptr; + if( critter_tracker->add( mon ) ) { + mon->gravity_check(); + return mon.get(); + } + return nullptr; } size_t game::num_creatures() const From c27b944790f2f0ffc1221e2782c5e11cd8e33064 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:46:19 +0000 Subject: [PATCH 11/18] Fix a test expecting spawned NPCs to float --- tests/char_sight_test.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/char_sight_test.cpp b/tests/char_sight_test.cpp index 75ea99c443989..63c74dd73026d 100644 --- a/tests/char_sight_test.cpp +++ b/tests/char_sight_test.cpp @@ -118,7 +118,8 @@ TEST_CASE( "npc_light_and_fine_detail_vision_mod", "[character][npc][sight][ligh clear_map(); tripoint const u_shift = GENERATE( tripoint::zero, tripoint::above ); CAPTURE( u_shift ); - u.setpos( u.pos() + u_shift ); + // Allow player to float for purpose of purely testing this and not factoring in terrain potentially blocking vision etc + u.setpos( u.pos() + u_shift, false ); scoped_weather_override weather_clear( WEATHER_CLEAR ); time_point time_dst; @@ -136,11 +137,12 @@ TEST_CASE( "npc_light_and_fine_detail_vision_mod", "[character][npc][sight][ligh set_time( time_dst ); REQUIRE( u.fine_detail_vision_mod() == expected_vision ); SECTION( "NPC on same z-level" ) { - n.setpos( u.pos() + tripoint::east ); + // Allow NPC to float for purpose of purely testing this and not factoring in terrain potentially blocking vision etc + n.setpos( u.pos() + tripoint::east, false ); CHECK( n.fine_detail_vision_mod() == u.fine_detail_vision_mod() ); } SECTION( "NPC on a different z-level" ) { - n.setpos( u.pos() + tripoint::above ); + n.setpos( u.pos() + tripoint::above, false ); // light map is not calculated outside the player character's z-level // even if fov_3d_z_range > 0, and building light map on multiple levels // could be expensive, so make NPCs able to see things in this case to From 14b80cf5231f704a151b44b4b10ba41ff4bbac11 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 11 Dec 2024 20:02:21 +0000 Subject: [PATCH 12/18] Another test that expects floating to be fine --- tests/char_sight_test.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/char_sight_test.cpp b/tests/char_sight_test.cpp index 63c74dd73026d..804099df298f1 100644 --- a/tests/char_sight_test.cpp +++ b/tests/char_sight_test.cpp @@ -87,8 +87,9 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision SECTION( "midnight with a new moon" ) { // yes, surprisingly, we need to test for this calendar::turn = calendar::turn_zero; - tripoint const z_shift = GENERATE( tripoint::above, tripoint::zero ); - dummy.setpos( dummy.pos() + z_shift ); // This implicitly rebuilds the light map. + tripoint_rel_ms const z_shift = GENERATE( tripoint_rel_ms::above, tripoint_rel_ms::zero ); + // This implicitly rebuilds the light map but in a hacky way so we need to prevent the player falling + dummy.setpos( dummy.pos_bub() + z_shift, false ); CAPTURE( z_shift ); REQUIRE_FALSE( g->is_in_sunlight( dummy.pos() ) ); REQUIRE( here.ambient_light_at( dummy.pos_bub() ) == Approx( LIGHT_AMBIENT_MINIMAL ) ); @@ -96,7 +97,7 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision // 7.3 is LIGHT_AMBIENT_MINIMAL, a dark cloudy night, unlit indoors CHECK( dummy.fine_detail_vision_mod() == Approx( 7.3f ) ); - dummy.setpos( dummy.pos() - z_shift ); + dummy.setpos( dummy.pos_bub() - z_shift, false ); } SECTION( "blindfolded" ) { From 109fdcc4382954b9fb0e6ef367d2111ce835d516 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 12 Dec 2024 01:04:55 +0000 Subject: [PATCH 13/18] Appease our clang overlords --- src/creature.cpp | 4 ++-- src/creature.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/creature.cpp b/src/creature.cpp index 1d69841e6557c..43eae168cf28c 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -214,7 +214,7 @@ tripoint_bub_ms Creature::pos_bub() const return get_map().bub_from_abs( location ); } -void Creature::setpos( const tripoint &p, const bool check_gravity/* = true*/ ) +void Creature::setpos( const tripoint &p, bool check_gravity = true ) { const tripoint_abs_ms old_loc = get_location(); set_pos_only( p ); @@ -224,7 +224,7 @@ void Creature::setpos( const tripoint &p, const bool check_gravity/* = true*/ ) } } -void Creature::setpos( const tripoint_bub_ms &p, const bool check_gravity/* = true*/ ) +void Creature::setpos( const tripoint_bub_ms &p, bool check_gravity = true ) { Creature::setpos( p.raw(), check_gravity ); } diff --git a/src/creature.h b/src/creature.h index 9d74b0cb748da..559429f7484ae 100644 --- a/src/creature.h +++ b/src/creature.h @@ -320,8 +320,8 @@ class Creature : public viewer } virtual void gravity_check(); // TODO: Get rid of untyped overload - void setpos( const tripoint &p, const bool check_gravity = true ); - void setpos( const tripoint_bub_ms &p, const bool check_gravity = true ); + void setpos( const tripoint &p, bool check_gravity = true ); + void setpos( const tripoint_bub_ms &p, bool check_gravity = true ); /** Checks if the creature fits confortably into a given tile. */ bool will_be_cramped_in_vehicle_tile( const tripoint_abs_ms &loc ) const; From f4e44641a28ead7e4cc2ccd818f9d67f26e9c0b3 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:09:53 +0000 Subject: [PATCH 14/18] More appeasement --- src/construction.cpp | 2 +- src/creature.cpp | 4 ++-- src/game.cpp | 2 +- src/map.cpp | 4 ++-- src/map.h | 2 +- src/trapfunc.cpp | 1 - 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/construction.cpp b/src/construction.cpp index b9aa517fa4db9..739b440aeeee8 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1462,7 +1462,7 @@ bool construct::check_unblocked( const tripoint_bub_ms &p ) // first know how to handle constructing on top of an invisible trap! // Should also check for empty space rather than open air, when such a check exists. return !here.has_furn( p ) && - ( g->is_empty( p ) || here.ter( p ) == ter_t_open_air ) && ( here.tr_at( p ).is_null() ) && + ( g->is_empty( p ) || here.ter( p ) == ter_t_open_air ) && here.tr_at( p ).is_null() && here.i_at( p ).empty() && !here.veh_at( p ); } diff --git a/src/creature.cpp b/src/creature.cpp index 43eae168cf28c..cef506431ba71 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -214,7 +214,7 @@ tripoint_bub_ms Creature::pos_bub() const return get_map().bub_from_abs( location ); } -void Creature::setpos( const tripoint &p, bool check_gravity = true ) +void Creature::setpos( const tripoint &p, bool check_gravity/* = true*/ ) { const tripoint_abs_ms old_loc = get_location(); set_pos_only( p ); @@ -224,7 +224,7 @@ void Creature::setpos( const tripoint &p, bool check_gravity = true ) } } -void Creature::setpos( const tripoint_bub_ms &p, bool check_gravity = true ) +void Creature::setpos( const tripoint_bub_ms &p, bool check_gravity/* = true*/ ) { Creature::setpos( p.raw(), check_gravity ); } diff --git a/src/game.cpp b/src/game.cpp index 3a9d2c9a036be..a176f74b50e5c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -10539,7 +10539,7 @@ std::vector game::get_dangerous_tile( const tripoint_bub_ms &dest_l if( m.is_open_air( dest_loc ) ) { if( !veh_dest && !u.has_effect_with_flag( json_flag_LEVITATION ) ) { - harmful_stuff.push_back( "ledge" ); + harmful_stuff.emplace_back( "ledge" ); if( harmful_stuff.size() == max ) { return harmful_stuff; } diff --git a/src/map.cpp b/src/map.cpp index 44dba47f14e38..070750d811655 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -136,8 +136,8 @@ static const efftype_id effect_weakened_gravity( "weakened_gravity" ); static const field_type_str_id field_fd_clairvoyant( "fd_clairvoyant" ); static const flag_id json_flag_AVATAR_ONLY( "AVATAR_ONLY" ); -static const flag_id json_flag_LEVITATION( "LEVITATION" ); static const flag_id json_flag_JETPACK( "JETPACK" ); +static const flag_id json_flag_LEVITATION( "LEVITATION" ); static const flag_id json_flag_PRESERVE_SPAWN_OMT( "PRESERVE_SPAWN_OMT" ); static const flag_id json_flag_PROXIMITY( "PROXIMITY" ); static const flag_id json_flag_UNDODGEABLE( "UNDODGEABLE" ); @@ -10447,7 +10447,7 @@ void map::maybe_trigger_prox_trap( const tripoint_bub_ms &pos, Creature &c, } // TODO: Should be moved to submap or Creature? -bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) +bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) const { if( c == nullptr ) { return false; diff --git a/src/map.h b/src/map.h index 713fe53c4f64a..64babe471e00a 100644 --- a/src/map.h +++ b/src/map.h @@ -633,7 +633,7 @@ class map bool is_open_air( const tripoint & ) const; bool is_open_air( const tripoint_bub_ms &p ) const; - bool try_fall( const tripoint_bub_ms &p, Creature *c ); + bool try_fall( const tripoint_bub_ms &p, Creature *c ) const; /** * Similar behavior to `move_cost()`, but ignores vehicles. diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 2855ebe68dce3..221d2c87e8b40 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -59,7 +59,6 @@ static const efftype_id effect_ridden( "ridden" ); static const efftype_id effect_slimed( "slimed" ); static const efftype_id effect_tetanus( "tetanus" ); -static const flag_id json_flag_LEVITATION( "LEVITATION" ); static const flag_id json_flag_PROXIMITY( "PROXIMITY" ); static const flag_id json_flag_UNCONSUMED( "UNCONSUMED" ); From dc8ab174a8a88760e79e7fb26fe240434c8a0903 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:06:55 +0000 Subject: [PATCH 15/18] Did you know stashing changes for one branch on another by accident and forgetting about them is not great? --- src/character.cpp | 2 +- src/do_turn.cpp | 4 +--- src/game.cpp | 1 - src/iuse_actor.cpp | 1 - src/map.cpp | 31 ++++++++++++++++++++++++------- src/map.h | 7 ++++--- 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 92bab118704bc..ad74d5f9a7abe 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -11051,7 +11051,7 @@ void Character::gravity_check() map &here = get_map(); if( here.is_open_air( pos_bub() ) && !has_effect_with_flag( json_flag_GLIDING ) && here.try_fall( pos_bub(), this ) ) { - get_map().update_visibility_cache( pos_bub().z() ); + here.update_visibility_cache( pos_bub().z() ); } } diff --git a/src/do_turn.cpp b/src/do_turn.cpp index e2cef4622e979..7d32fcf20e083 100644 --- a/src/do_turn.cpp +++ b/src/do_turn.cpp @@ -488,9 +488,6 @@ bool do_turn() } } - // Make sure players cant defy gravity by standing still, Looney tunes style. - u.gravity_check(); - // If you're inside a wall or something and haven't been telefragged, let's get you out. if( ( m.impassable( u.pos_bub() ) && !m.impassable_field_at( u.pos_bub() ) ) && !m.has_flag( ter_furn_flag::TFLAG_CLIMBABLE, u.pos_bub() ) ) { @@ -557,6 +554,7 @@ bool do_turn() if( !u.has_effect( effect_sleep ) || g->uquit == QUIT_WATCH ) { if( u.get_moves() > 0 || g->uquit == QUIT_WATCH ) { while( u.get_moves() > 0 || g->uquit == QUIT_WATCH ) { + m.process_falling(); g->cleanup_dead(); g->mon_info_update(); // Process any new sounds the player caused during their turn. diff --git a/src/game.cpp b/src/game.cpp index a176f74b50e5c..1d4d676064c84 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -11749,7 +11749,6 @@ bool game::grabbed_furn_move( const tripoint_rel_ms &dp ) std::string danger_tile = enumerate_as_string( get_dangerous_tile( fdest ) ); add_msg( _( "You let go of the %1$s as it falls down the %2$s." ), furntype.name(), danger_tile ); u.grab( object_type::NONE ); - m.drop_furniture( fdest ); return true; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 67b64fa01336c..a7c7f17fb0428 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1202,7 +1202,6 @@ std::optional deploy_furn_actor::use( Character *p, item &it, } get_map().furn_set( suitable.value(), furn_type ); - get_map().drop_furniture( suitable.value() ); it.spill_contents( suitable.value() ); p->mod_moves( -to_moves( 2_seconds ) ); return 1; diff --git a/src/map.cpp b/src/map.cpp index 070750d811655..d8e2ac26b17c7 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2885,14 +2885,16 @@ bool map::has_vehicle_floor( const tripoint_bub_ms &p ) const void map::drop_everything( const tripoint_bub_ms &p ) { - if( has_floor_or_water( p ) ) { - return; - } + // Creature has their own gravity check + drop_creature( p ); - drop_furniture( p ); - drop_items( p ); - drop_vehicle( p ); - drop_fields( p ); + // TODO: Should be more nuance here, only low density items/furniture should float on water etc + if( !has_floor_or_water( p ) ) { + drop_furniture( p ); + drop_items( p ); + drop_vehicle( p ); + drop_fields( p ); + } } void map::drop_furniture( const tripoint_bub_ms &p ) @@ -3184,6 +3186,21 @@ void map::drop_fields( const tripoint_bub_ms &p ) } } +void map::drop_creature( const tripoint_bub_ms &p ) const +{ + monster *mon_at_p = get_creature_tracker().creature_at( p ); + if( mon_at_p ) { + mon_at_p->gravity_check(); + // Handle character potentially standing on monster ("zed walking") + drop_creature( p + tripoint_rel_ms::above ); + return; + } + Character *char_at_p = get_creature_tracker().creature_at( p ); + if( char_at_p ) { + char_at_p->gravity_check(); + } +} + void map::support_dirty( const tripoint_bub_ms &p ) { if( zlevels ) { diff --git a/src/map.h b/src/map.h index 64babe471e00a..4bd9282a633eb 100644 --- a/src/map.h +++ b/src/map.h @@ -1965,9 +1965,9 @@ class map // TODO: Get rid of untyped overload bool has_vehicle_floor( const tripoint &p ) const; bool has_vehicle_floor( const tripoint_bub_ms &p ) const; - + private: /** - * Handles map objects of given type (not creatures) falling down. + * Handles map objects of given type falling down. */ /*@{*/ void drop_everything( const tripoint_bub_ms &p ); @@ -1975,8 +1975,9 @@ class map void drop_items( const tripoint_bub_ms &p ); void drop_vehicle( const tripoint_bub_ms &p ); void drop_fields( const tripoint_bub_ms &p ); + void drop_creature( const tripoint_bub_ms &p ) const; /*@}*/ - + public: /** * Invoked @ref drop_everything on cached dirty tiles. */ From 44e654b5f1261059e7fddf250575114f34ec2986 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:31:54 +0000 Subject: [PATCH 16/18] More fixes --- src/character.cpp | 2 +- src/construction.cpp | 8 ++------ src/game.cpp | 3 ++- src/mattack_actors.cpp | 1 + src/monmove.cpp | 9 +++------ 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index d6a75c790b5cb..aa6e143c5e6ce 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -11038,7 +11038,7 @@ void Character::process_effects() void Character::gravity_check() { map &here = get_map(); - if( here.is_open_air( pos_bub() ) && !has_effect_with_flag( json_flag_GLIDING ) && + if( here.is_open_air( pos_bub() ) && !in_vehicle && !has_effect_with_flag( json_flag_GLIDING ) && here.try_fall( pos_bub(), this ) ) { here.update_visibility_cache( pos_bub().z() ); } diff --git a/src/construction.cpp b/src/construction.cpp index 135010bfa18b3..25cd465315f0c 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1509,14 +1509,10 @@ bool construct::check_support_below( const tripoint_bub_ms &p ) // with it, i.e. ledge, and various forms of pits. // - Check if there's nothing in the way. The "passable" check rejects tiles you can't // pass through, but we want air and water to be OK as well (that's what we want to bridge). - // - Apart from that, vehicles, items, creatures, and furniture also have to be absent. - // - Then we have traps, and, unfortunately, there are "ledge" traps on all the open - // space tiles adjacent to passable tiles, so we can't just reject all traps outright, - // but have to accept those. + // - Apart from that, vehicles, items, creatures, traps and furniture also have to be absent. if( !( here.passable( p ) || here.has_flag( ter_furn_flag::TFLAG_LIQUID, p ) || here.has_flag( ter_furn_flag::TFLAG_NO_FLOOR, p ) ) || blocking_creature || here.has_furn( p ) || - !( here.tr_at( p ).is_null() || here.tr_at( p ).has_flag( json_flag_PIT ) ) || - !here.i_at( p ).empty() || here.veh_at( p ) ) { + !here.tr_at( p ).is_null() || !here.i_at( p ).empty() || here.veh_at( p ) ) { return false; } // need two or more orthogonally adjacent supports at the Z level below diff --git a/src/game.cpp b/src/game.cpp index b87baa7a9c40d..26f01592470f3 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -13638,9 +13638,10 @@ bool game::slip_down( climb_maneuver maneuver, climbing_aid_id aid_id, if( slip >= 100 ) { add_msg( m_bad, _( "Climbing is impossible in your current state." ) ); } - // Check for traps if climbing UP or DOWN. Note that ledges (open air) count as traps. + // Check for traps and gravity if climbing up or down. if( maneuver != climb_maneuver::over_obstacle ) { m.creature_on_trap( u ); + u.gravity_check(); } return true; } diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index a2f45be47b2ad..44c8a3661f0b4 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -567,6 +567,7 @@ int melee_actor::do_grab( monster &z, Creature *target, bodypart_id bp_id ) cons } // The monster might drag a target that's not on it's z level // So if they leave them on open air, make them fall + target->gravity_check(); here.creature_on_trap( *target ); target->add_msg_player_or_npc( msg_type, grab_data.pull_msg_u, grab_data.pull_msg_npc, mon_name, diff --git a/src/monmove.cpp b/src/monmove.cpp index b5f58a05b36ec..f1a5e997a3dc4 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -887,12 +887,9 @@ void monster::move() nursebot_operate( dragged_foe ); // The monster can sometimes hang in air due to last fall being blocked - if( !flies() && !here.has_floor_or_water( pos_bub() ) && !here.has_vehicle_floor( pos_bub() ) && - !has_flag( json_flag_CANNOT_MOVE ) ) { - here.creature_on_trap( *this, false ); - if( is_dead() ) { - return; - } + gravity_check(); + if( is_dead() ) { + return; } // if the monster is in a deep water tile, it has a chance to drown From 8d3ce30de33abf905d1fd8462b630b0dafbfddba Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Mon, 16 Dec 2024 10:25:28 +0000 Subject: [PATCH 17/18] Appease our clang overlords --- src/construction.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/construction.cpp b/src/construction.cpp index 25cd465315f0c..bb3841e33a8b4 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -92,7 +92,6 @@ static const construction_str_id construction_constr_veh( "constr_veh" ); static const flag_id json_flag_FILTHY( "FILTHY" ); -static const flag_id json_flag_PIT( "PIT" ); static const furn_str_id furn_f_coffin_c( "f_coffin_c" ); static const furn_str_id furn_f_coffin_o( "f_coffin_o" ); From 10373910aaa983776c003725297211e0f4e3eb56 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:37:21 +0000 Subject: [PATCH 18/18] Fix some since typified stuff --- src/map.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 360546aa6ae01..7d644dfcb9bd4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -10476,7 +10476,7 @@ bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) const int height = 0; tripoint_bub_ms where( p ); - tripoint_bub_ms below( where + tripoint::below ); + tripoint_bub_ms below( where + tripoint_rel_ms::below ); creature_tracker &creatures = get_creature_tracker(); while( valid_move( where, below, false, true ) ) { where.z()--; @@ -10529,7 +10529,7 @@ bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) const if( c->has_effect( effect_strengthened_gravity ) ) { height += 1; } - c->impact( height * 10, where.raw() ); + c->impact( height * 10, where ); return true; } @@ -10578,11 +10578,11 @@ bool map::try_fall( const tripoint_bub_ms &p, Creature *c ) const } else { you->add_msg_if_player( m_bad, _( "You attempt to break the fall with your %s but it is out of fuel!" ), jetpack.tname() ); - you->impact( height * 30, where.raw() ); + you->impact( height * 30, where ); } } else { - you->impact( height * 30, where.raw() ); + you->impact( height * 30, where ); } if( has_flag( ter_furn_flag::TFLAG_DEEP_WATER, where ) ) {