Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(content, port): port treetops and ability to climb trees from DDA #5167

Merged
merged 10 commits into from
Nov 15, 2024
164 changes: 107 additions & 57 deletions data/json/furniture_and_terrain/terrain-flora.json

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions data/json/furniture_and_terrain/terrain-roofs.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,45 @@
"sound_fail_vol": 4,
"bash_below": true
}
},
{
"type": "terrain",
"id": "t_treetop",
"name": "treetop",
"description": "The upper branches of a tree. There's just enough room to perch here.",
"symbol": "#",
"color": [ "light_green", "green", "yellow_yellow", "brown" ],
"move_cost": 8,
"flags": [ "TRANSPARENT", "FLAMMABLE_ASH", "UNSTABLE", "SINGLE_SUPPORT" ]
},
{
"type": "terrain",
"id": "t_treetop_evergreen",
"name": "treetop",
"description": "The upper branches of a tree. There's just enough room to perch here.",
"symbol": "#",
"color": [ "green" ],
"move_cost": 8,
"flags": [ "TRANSPARENT", "FLAMMABLE_ASH", "UNSTABLE", "SINGLE_SUPPORT" ]
},
{
"type": "terrain",
"id": "t_treetop_dead",
"name": "dead treetop",
"description": "The bare upper branches of a dead tree. There's just enough room to perch here.",
"symbol": "#",
"color": "brown",
"move_cost": 8,
"flags": [ "TRANSPARENT", "FLAMMABLE_ASH", "UNSTABLE", "SINGLE_SUPPORT" ]
},
{
"type": "terrain",
"id": "t_treetop_giant_fern",
"name": "giant fern top",
"description": "The top of some unearthly gigantic fern. There is enough room to perch up here, but only just.",
"symbol": "#",
"color": "red",
"move_cost": 8,
"flags": [ "TRANSPARENT", "FLAMMABLE_ASH", "UNSTABLE", "SINGLE_SUPPORT" ]
}
]
1 change: 1 addition & 0 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4018,6 +4018,7 @@ void activity_handlers::chop_tree_finish( player_activity *act, player *p )

here.ter_set( pos, t_stump );
p->add_msg_if_player( m_good, _( "You finish chopping down a tree." ) );
here.collapse_at( pos, false, true, false );
// sound of falling tree
sfx::play_variant_sound( "misc", "timber",
sfx::get_heard_volume( here.getlocal( act->placement ) ) );
Expand Down
1 change: 1 addition & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10015,6 +10015,7 @@ void game::vertical_move( int movez, bool force, bool peeking )
if( m.has_zlevels() && !force && movez == 1 && !m.has_flag( "GOES_UP", u.pos() ) &&
!u.is_underwater() ) {
// Climbing

if( m.has_floor_or_support( stairs ) ) {
add_msg( m_info, _( "You can't climb here - there's a ceiling above your head." ) );
return;
Expand Down
41 changes: 26 additions & 15 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2925,24 +2925,34 @@ int map::collapse_check( const tripoint &p )
// if there's support below, things are less likely to collapse
if( p.z > -OVERMAP_DEPTH ) {
const tripoint &pbelow = tripoint( p.xy(), p.z - 1 );
for( const tripoint &tbelow : points_in_radius( pbelow, 1 ) ) {
if( has_flag( TFLAG_SINGLE_SUPPORT, p ) ) {
if( has_flag( TFLAG_SUPPORTS_ROOF, pbelow ) ) {
num_supports += 1;
if( has_flag( TFLAG_WALL, pbelow ) ) {
num_supports += 2;
}
if( tbelow == pbelow ) {
num_supports += 2;
num_supports = 3;
} else {
num_supports = 0;
}
} else {
for( const tripoint &tbelow : points_in_radius( pbelow, 1 ) ) {
if( has_flag( TFLAG_SUPPORTS_ROOF, pbelow ) ) {
num_supports += 1;
if( has_flag( TFLAG_WALL, pbelow ) ) {
num_supports += 2;
}
if( tbelow == pbelow ) {
num_supports += 2;
}
}
}
}
}

for( const tripoint &t : points_in_radius( p, 1 ) ) {
if( has_flag( TFLAG_SINGLE_SUPPORT, p ) ) {
break;
}
if( p == t ) {
continue;
}

if( collapses ) {
if( has_flag( TFLAG_COLLAPSES, t ) ) {
num_supports++;
Expand Down Expand Up @@ -2997,13 +3007,14 @@ void map::collapse_at( const tripoint &p, const bool silent, const bool was_supp
if( p != t && ( has_flag( TFLAG_SUPPORTS_ROOF, t ) && has_flag( TFLAG_COLLAPSES, t ) ) ) {
collapse_at( t, silent );
}
// this tile used to support a roof, now it doesn't, which means there is only
// open air above us
if( zlevels ) {
ter_set( tz, t_open_air );
furn_set( tz, f_null );
propagate_suspension_check( tz );
}
}
// this tile used to support a roof, now it doesn't, which means there is only
// open air above us
if( zlevels ) {
const tripoint tabove( p.xy(), p.z + 1 );
ter_set( tabove, t_open_air );
furn_set( tabove, f_null );
propagate_suspension_check( tabove );
}
}
// it would be great to check if collapsing ceilings smashed through the floor, but
Expand Down
2 changes: 2 additions & 0 deletions src/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ static const std::unordered_map<std::string, ter_bitflags> ter_bitflags_map = {
{ "FRIDGE", TFLAG_FRIDGE }, // This is an active fridge.
{ "FREEZER", TFLAG_FREEZER }, // This is an active freezer.
{ "ELEVATOR", TFLAG_ELEVATOR }, // This is an elevator.
{ "SINGLE_SUPPORT", TFLAG_SINGLE_SUPPORT}, // This is only supported from below.
{ "CLIMB_ADJACENT", TFLAG_CLIMB_ADJACENT}, // This is climbable when player is adjancent to it.
}
};

Expand Down
3 changes: 2 additions & 1 deletion src/mapdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ enum ter_bitflags : int {
TFLAG_FRIDGE,
TFLAG_FREEZER,
TFLAG_ELEVATOR,

TFLAG_SINGLE_SUPPORT,
TFLAG_CLIMB_ADJACENT,
NUM_TERFLAGS
};

Expand Down
Loading