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

[CR] Removed penalties and base cost when calculating obtain_cost() for wielded item #33271

Merged
merged 4 commits into from
Apr 30, 2020
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
43 changes: 24 additions & 19 deletions src/item_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,30 +338,35 @@ class item_location::impl::item_on_person : public item_location::impl
obj = *target();
}

auto parents = who->parents( *target() );
if( !parents.empty() && who->is_worn( *parents.back() ) ) {
// if outermost parent item is worn status effects (e.g. GRABBED) are not applied
// holsters may also adjust the volume cost factor
if( who->is_armed() && &who->weapon == target() ) {
// no penalties because we already have this item in our hands
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, false, 0 );
} else {
auto parents = who->parents( *target() );
if( !parents.empty() && who->is_worn( *parents.back() ) ) {
// if outermost parent item is worn status effects (e.g. GRABBED) are not applied
// holsters may also adjust the volume cost factor

if( parents.back()->can_holster( obj, true ) ) {
auto ptr = dynamic_cast<const holster_actor *>
( parents.back()->type->get_use( "holster" )->get_actor_ptr() );
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, false, ptr->draw_cost );
if( parents.back()->can_holster( obj, true ) ) {
auto ptr = dynamic_cast<const holster_actor *>
( parents.back()->type->get_use( "holster" )->get_actor_ptr() );
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, false, ptr->draw_cost );

} else if( parents.back()->is_bandolier() ) {
auto ptr = dynamic_cast<const bandolier_actor *>
( parents.back()->type->get_use( "bandolier" )->get_actor_ptr() );
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, false, ptr->draw_cost );
} else if( parents.back()->is_bandolier() ) {
auto ptr = dynamic_cast<const bandolier_actor *>
( parents.back()->type->get_use( "bandolier" )->get_actor_ptr() );
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, false, ptr->draw_cost );

} else {
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, false,
INVENTORY_HANDLING_PENALTY / 2 );
}

} else {
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, false,
INVENTORY_HANDLING_PENALTY / 2 );
// it is more expensive to obtain items from the inventory
// TODO: calculate cost for searching in inventory proportional to item volume
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, true, INVENTORY_HANDLING_PENALTY );
}

} else {
// it is more expensive to obtain items from the inventory
// TODO: calculate cost for searching in inventory proportional to item volume
mv += dynamic_cast<player *>( who )->item_handling_cost( obj, true, INVENTORY_HANDLING_PENALTY );
}

if( &ch != who ) {
Expand Down