Skip to content

Commit

Permalink
[CR] Removed penalties and base cost when calculating obtain_cost() f…
Browse files Browse the repository at this point in the history
…or wielded item (#33271)
  • Loading branch information
Raschert0 authored Apr 30, 2020
1 parent a67e503 commit 6592a39
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions src/item_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,30 +341,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

0 comments on commit 6592a39

Please sign in to comment.