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

Helicopter bugfixes : allow descending into open air while moving, and disallow roof teleporting #39275

Merged
merged 2 commits into from Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,7 +1848,7 @@ void Item_factory::load( islot_comestible &slot, const JsonObject &jo, const std
assign( jo, "spoils_in", slot.spoils, strict, 1_hours );
assign( jo, "cooks_like", slot.cooks_like, strict );
assign( jo, "smoking_result", slot.smoking_result, strict );

for( const JsonObject &jsobj : jo.get_array( "contamination" ) ) {
slot.contamination.emplace( diseasetype_id( jsobj.get_string( "disease" ) ),
jsobj.get_int( "probability" ) );
Expand Down
18 changes: 17 additions & 1 deletion src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,8 @@ bool vehicle::check_heli_descend( player &p )
debugmsg( "A vehicle is somehow flying without being an aircraft" );
return true;
}
int count = 0;
int air_count = 0;
for( const tripoint &pt : get_points( true ) ) {
tripoint below( pt.xy(), pt.z - 1 );
if( g->m.has_zlevels() && ( pt.z < -OVERMAP_DEPTH ||
Expand All @@ -993,8 +995,12 @@ bool vehicle::check_heli_descend( player &p )
_( "It would be unsafe to try and land when there are obstacles below you." ) );
return false;
}
if( g->m.has_flag_ter_or_furn( TFLAG_NO_FLOOR, below ) ) {
air_count++;
}
count++;
}
if( velocity > 0 ) {
if( velocity > 0 && air_count != count ) {
p.add_msg_if_player( m_bad, _( "It would be unsafe to try and land while you are moving." ) );
return false;
}
Expand All @@ -1012,6 +1018,16 @@ bool vehicle::check_heli_ascend( player &p )
p.add_msg_if_player( m_bad, _( "It would be unsafe to try and take off while you are moving." ) );
return false;
}
for( const tripoint &pt : get_points( true ) ) {
tripoint above( pt.xy(), pt.z + 1 );
const optional_vpart_position ovp = g->m.veh_at( above );
if( g->m.impassable_ter_furn( above ) || ovp || g->critter_at( above ) || !g->m.is_outside( pt ) ||
!g->m.is_outside( above ) ) {
p.add_msg_if_player( m_bad,
_( "It would be unsafe to try and ascend when there are obstacles above you." ) );
return false;
}
}
return true;
}

Expand Down