From 642ff9a2281c9cbfc54bb077f180efbc2d44acd6 Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Sat, 13 May 2023 07:28:27 -0500 Subject: [PATCH] Fix early mech dismount leaving you armed (#2781) * Fix early mech dismount leaving you armed * refactor: use auto --------- Co-authored-by: scarf --- src/character.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/character.cpp b/src/character.cpp index 7622bbb9eda9..5d607a4a6fc2 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -994,13 +994,16 @@ void Character::mount_creature( monster &z ) guy.setpos( pnt ); } z.facing = facing; - add_msg_if_player( m_good, _( "You climb on the %s." ), z.get_name() ); - if( z.has_flag( MF_RIDEABLE_MECH ) ) { - if( !z.type->mech_weapon.is_empty() ) { - item mechwep = item( z.type->mech_weapon ); - wield( mechwep ); + // Make sure something didn't interrupt this process and knock the player off partway through! + if( has_effect( effect_riding ) ) { + add_msg_if_player( m_good, _( "You climb on the %s." ), z.get_name() ); + if( z.has_flag( MF_RIDEABLE_MECH ) ) { + if( !z.type->mech_weapon.is_empty() ) { + auto mechwep = item{ z.type->mech_weapon }; + wield( mechwep ); + } + add_msg_if_player( m_good, _( "You hear your %s whir to life." ), z.get_name() ); } - add_msg_if_player( m_good, _( "You hear your %s whir to life." ), z.get_name() ); } // some rideable mechs have night-vision recalc_sight_limits();