Skip to content

Commit

Permalink
Allowed throwing items while piloting mechs
Browse files Browse the repository at this point in the history
  • Loading branch information
Valiant committed Oct 28, 2024
1 parent ad8047d commit 0fcb6a8
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ void avatar_action::plthrow( avatar &you, item_location loc,
add_msg( m_info, _( "You lack the substance to affect anything." ) );
return;
}

bool in_mech = false;
if( you.is_mounted() ) {
monster *mons = get_player_character().mounted_creature.get();
if( mons->has_flag( mon_flag_RIDEABLE_MECH ) ) {
Expand All @@ -960,6 +962,7 @@ void avatar_action::plthrow( avatar &you, item_location loc,
mons->get_name() );
return;
}
in_mech = true;
}
}

Expand All @@ -973,10 +976,13 @@ void avatar_action::plthrow( avatar &you, item_location loc,
return;
}

const ret_val<void> ret = you.can_wield( *loc );
if( !ret.success() ) {
add_msg( m_info, "%s", ret.c_str() );
return;
// Bypass check for whether we can wield an item if we're inside a mech
if( !in_mech ) {
const ret_val<void> ret = you.can_wield( *loc );
if( !ret.success() ) {
add_msg( m_info, "%s", ret.c_str() );
return;
}
}

// make a copy and get the original.
Expand Down Expand Up @@ -1012,9 +1018,12 @@ void avatar_action::plthrow( avatar &you, item_location loc,
}
}
// you must wield the item to throw it
if( !you.is_wielding( *orig ) ) {
if( !you.wield( *orig ) ) {
return;
// if we're in the mech, let's assume the mech wields the item
if( !in_mech ) {
if( !you.is_wielding( *orig ) ) {
if( !you.wield( *orig ) ) {
return;
}
}
}

Expand All @@ -1028,7 +1037,7 @@ void avatar_action::plthrow( avatar &you, item_location loc,

g->temp_exit_fullscreen();

item_location weapon = you.get_wielded_item();
item_location weapon = in_mech ? loc : you.get_wielded_item();
target_handler::trajectory trajectory = target_handler::mode_throw( you, *weapon,
blind_throw_from_pos.has_value() );

Expand All @@ -1045,7 +1054,11 @@ void avatar_action::plthrow( avatar &you, item_location loc,
weapon->mod_charges( -1 );
thrown.charges = 1;
} else {
you.remove_weapon();
if( in_mech ) {
loc.remove_item();
} else {
you.remove_weapon();
}
}
you.throw_item( trajectory.back(), thrown, blind_throw_from_pos );
g->reenter_fullscreen();
Expand Down

0 comments on commit 0fcb6a8

Please sign in to comment.