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

Throwing items while piloting mechs (with the mech's assist) #77403

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
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
Loading