Skip to content

Commit

Permalink
Merge pull request #37594 from Night-Pryanik/allow-diving-and-surfacing
Browse files Browse the repository at this point in the history
Moved diving code before the check for terrain's "climbality"
  • Loading branch information
ZhilkinSerg authored Jan 31, 2020
2 parents f7667d6 + 1503af9 commit 2c8919d
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9931,6 +9931,33 @@ void game::vertical_move( int movez, bool force )
}
}

// > and < are used for diving underwater.
if( m.has_flag( "SWIMMABLE", u.pos() ) && m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) {
if( movez == -1 ) {
if( u.is_underwater() ) {
add_msg( m_info, _( "You are already underwater!" ) );
return;
}
if( u.worn_with_flag( "FLOTATION" ) ) {
add_msg( m_info, _( "You can't dive while wearing a flotation device." ) );
return;
}
u.set_underwater( true );
///\EFFECT_STR increases breath-holding capacity while diving
u.oxygen = 30 + 2 * u.str_cur;
add_msg( _( "You dive underwater!" ) );
} else {
if( u.swim_speed() < 500 || u.shoe_type_count( "swim_fins" ) ) {
u.set_underwater( false );
add_msg( _( "You surface." ) );
} else {
add_msg( m_info, _( "You try to surface but can't!" ) );
}
}
u.moves -= 100;
return;
}

// Force means we're going down, even if there's no staircase, etc.
bool climbing = false;
int move_cost = 100;
Expand Down Expand Up @@ -10042,33 +10069,6 @@ void game::vertical_move( int movez, bool force )
u.moves -= 100;
}

// > and < are used for diving underwater.
if( m.has_flag( "SWIMMABLE", u.pos() ) && m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) {
if( movez == -1 ) {
if( u.is_underwater() ) {
add_msg( m_info, _( "You are already underwater!" ) );
return;
}
if( u.worn_with_flag( "FLOTATION" ) ) {
add_msg( m_info, _( "You can't dive while wearing a flotation device." ) );
return;
}
u.set_underwater( true );
///\EFFECT_STR increases breath-holding capacity while diving
u.oxygen = 30 + 2 * u.str_cur;
add_msg( _( "You dive underwater!" ) );
} else {
if( u.swim_speed() < 500 || u.shoe_type_count( "swim_fins" ) ) {
u.set_underwater( false );
add_msg( _( "You surface." ) );
} else {
add_msg( m_info, _( "You try to surface but can't!" ) );
}
}
u.moves -= 100;
return;
}

// Shift the map up or down

std::unique_ptr<map> tmp_map_ptr;
Expand Down

0 comments on commit 2c8919d

Please sign in to comment.