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

Backport: Fix: weariness makes hauling faster instead of slower; set weariness tracker in debug #77242

Open
wants to merge 3 commits into
base: 0.H-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
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
75 changes: 38 additions & 37 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2113,49 +2113,50 @@ void move_items_activity_actor::do_turn( player_activity &act, Character &who )
}

// Check that we can pick it up.
if( target->made_of_from_type( phase_id::SOLID ) ) {
// Spill out any invalid contents first
target.overflow();
if( !target->made_of_from_type( phase_id::SOLID ) ) {
continue;
}
// Spill out any invalid contents first
target.overflow();

item &leftovers = *target;
// Make a copy to be put in the destination location
item newit = leftovers;
item &leftovers = *target;
// Make a copy to be put in the destination location
item newit = leftovers;

if( newit.is_owned_by( who, true ) ) {
newit.set_owner( who );
} else {
continue;
}
if( newit.is_owned_by( who, true ) ) {
newit.set_owner( who );
} else {
continue;
}

// Handle charges, quantity == 0 means move all
if( quantity != 0 && newit.count_by_charges() ) {
newit.charges = std::min( newit.charges, quantity );
leftovers.charges -= quantity;
} else {
leftovers.charges = 0;
}
// Handle charges, quantity == 0 means move all
if( quantity != 0 && newit.count_by_charges() ) {
newit.charges = std::min( newit.charges, quantity );
leftovers.charges -= quantity;
} else {
leftovers.charges = 0;
}

// This is for hauling across zlevels, remove when going up and down stairs
// is no longer teleportation
const tripoint_bub_ms src = target.pos_bub();
const int distance = src.z() == dest.z() ? std::max( rl_dist( src, dest ), 1 ) : 1;
// Yuck, I'm sticking weariness scaling based on activity level here
const float weary_mult = who.exertion_adjusted_move_multiplier( exertion_level() );
who.mod_moves( -Pickup::cost_to_move_item( who, newit ) * distance * weary_mult );
if( to_vehicle ) {
put_into_vehicle_or_drop( who, item_drop_reason::deliberate, { newit }, dest );
} else {
std::vector<item_location> dropped_items = drop_on_map( who, item_drop_reason::deliberate, { newit },
dest );
if( hauling_mode ) {
who.haul_list.insert( who.haul_list.end(), dropped_items.begin(), dropped_items.end() );
}
}
// If we picked up a whole stack, remove the leftover item
if( leftovers.charges <= 0 ) {
target.remove_item();
// This is for hauling across zlevels, remove when going up and down stairs
// is no longer teleportation
const tripoint_bub_ms src = target.pos_bub();
const int distance = src.z() == dest.z() ? std::max( rl_dist( src, dest ), 1 ) : 1;
// Yuck, I'm sticking weariness scaling based on activity level here
const float weary_mult = who.exertion_adjusted_move_multiplier( exertion_level() );
who.mod_moves( -Pickup::cost_to_move_item( who, newit ) * distance / weary_mult );
if( to_vehicle ) {
put_into_vehicle_or_drop( who, item_drop_reason::deliberate, { newit }, dest );
} else {
std::vector<item_location> dropped_items = drop_on_map( who, item_drop_reason::deliberate, { newit },
dest );
if( hauling_mode ) {
who.haul_list.insert( who.haul_list.end(), dropped_items.begin(), dropped_items.end() );
}
}
// If we picked up a whole stack, remove the leftover item
if( leftovers.charges <= 0 ) {
target.remove_item();
}
}

if( target_items.empty() ) {
Expand Down
10 changes: 10 additions & 0 deletions src/activity_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ void activity_tracker::weary_clear()
low_activity_ticks = 0.0f;
}

int activity_tracker::debug_get_tracker() const
{
return tracker;
}

void activity_tracker::debug_set_tracker( int new_tracker )
{
tracker = new_tracker;
}

void activity_tracker::set_intake( int ncal )
{
intake = ncal;
Expand Down
2 changes: 2 additions & 0 deletions src/activity_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class activity_tracker
void try_reduce_weariness( int bmr, float fatigue_mod, float fatigue_regen_mod );
void calorie_adjust( int ncal );
void weary_clear();
int debug_get_tracker() const;
void debug_set_tracker( int new_tracker );
void set_intake( int ncal );
std::string debug_weary_info() const;

Expand Down
8 changes: 8 additions & 0 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,8 @@ static void character_edit_needs_menu( Character &you )
smenu.addentry( 5, true, 'f', "%s: %d", _( "Fatigue" ), you.get_fatigue() );
smenu.addentry( 6, true, 'd', "%s: %d", _( "Sleep Deprivation" ), you.get_sleep_deprivation() );
smenu.addentry( 7, true, 'w', "%s: %d", _( "Weariness" ), you.weariness() );
smenu.addentry( 10, true, 'W', "%s: %d", _( "Weariness tracker" ),
you.activity_history.debug_get_tracker() );
smenu.addentry( 8, true, 'a', _( "Reset all basic needs" ) );
smenu.addentry( 9, true, 'e', _( "Empty stomach and guts" ) );

Expand Down Expand Up @@ -1579,6 +1581,12 @@ static void character_edit_needs_menu( Character &you )
you.activity_history.weary_clear();
}
break;
case 10:
if( query_int( value, _( "Set weariness tracker to? Currently: %d" ),
you.activity_history.debug_get_tracker() ) ) {
you.activity_history.debug_set_tracker( value );
}
break;
case 8:
you.initialize_stomach_contents();
you.set_hunger( 0 );
Expand Down
Loading