diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 860863597ee44..c203b6452e966 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -498,7 +498,7 @@ bool aim_activity_actor::load_RAS_weapon() int sta_percent = ( 100 * you.get_stamina() ) / you.get_stamina_max(); reload_time += ( sta_percent < 25 ) ? ( ( 25 - sta_percent ) * 2 ) : 0; - you.moves -= reload_time; + you.mod_moves( -reload_time ); return true; } @@ -513,7 +513,7 @@ void aim_activity_actor::unload_RAS_weapon() gun_mode gun = weapon->gun_current_mode(); if( gun->has_flag( flag_RELOAD_AND_SHOOT ) ) { - int moves_before_unload = you.moves; + int moves_before_unload = you.get_moves(); // Note: this code works only for avatar item_location loc = item_location( you, gun.target ); @@ -521,7 +521,7 @@ void aim_activity_actor::unload_RAS_weapon() // Give back time for unloading as essentially nothing has been done. if( first_turn ) { - you.moves = moves_before_unload; + you.set_moves( moves_before_unload ); } } } @@ -550,17 +550,17 @@ void autodrive_activity_actor::start( player_activity &, Character &who ) void autodrive_activity_actor::do_turn( player_activity &act, Character &who ) { if( who.in_vehicle && who.controlling_vehicle && player_vehicle ) { - if( who.moves <= 0 ) { + if( who.get_moves() <= 0 ) { // out of moves? the driver's not doing anything this turn // (but the vehicle will continue moving) return; } switch( player_vehicle->do_autodrive( who ) ) { case autodrive_result::ok: - if( who.moves > 0 ) { + if( who.get_moves() > 0 ) { // if do_autodrive() didn't eat up all our moves, end the turn // equivalent to player pressing the "pause" button - who.moves = 0; + who.set_moves( 0 ); } sounds::reset_markers(); break; @@ -1598,7 +1598,7 @@ void glide_activity_actor::do_turn( player_activity &act, Character &you ) g->vertical_move( -1, false, false ); moved_tiles = 0; } - you.moves -= 50; + you.mod_moves( -you.get_speed() * 0.5 ); get_map().update_visibility_cache( you.pos().z ); get_map().update_visibility_cache( you.pos().x ); get_map().update_visibility_cache( you.pos().y ); @@ -2295,7 +2295,7 @@ void move_items_activity_actor::do_turn( player_activity &act, Character &who ) { const tripoint_bub_ms dest = relative_destination + who.pos_bub(); - while( who.moves > 0 && !target_items.empty() ) { + while( who.get_moves() > 0 && !target_items.empty() ) { item_location target = std::move( target_items.back() ); const int quantity = quantities.back(); target_items.pop_back(); @@ -4074,7 +4074,7 @@ static std::list obtain_activity_items( std::vectorcount(), true ), 1 ); } - if( !who.is_npc() && who.moves <= 0 && consumed_moves > 0 ) { + if( !who.is_npc() && who.get_moves() <= 0 && consumed_moves > 0 ) { break; } @@ -5988,7 +5988,7 @@ bool avatar_action::check_stealing( Character &who, item &weapon ) void wield_activity_actor::do_turn( player_activity &, Character &who ) { - if( who.moves > 0 ) { + if( who.get_moves() > 0 ) { if( target_item ) { // Make copies so the original remains untouched if wielding fails item newit = *target_item; @@ -6050,7 +6050,7 @@ std::unique_ptr wield_activity_actor::deserialize( JsonValue &js void wear_activity_actor::do_turn( player_activity &, Character &who ) { // ACT_WEAR has item_location targets, and int quantities - while( who.moves > 0 && !target_items.empty() ) { + while( who.get_moves() > 0 && !target_items.empty() ) { item_location target = std::move( target_items.back() ); int quantity = quantities.back(); target_items.pop_back(); @@ -7239,7 +7239,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you ) move_item( you, *contained, contained->count(), src_loc, src_loc, this_veh, this_part ); it->first->remove_item( *contained ); } - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { return; } } @@ -7269,7 +7269,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you ) } } } - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { return; } } @@ -7279,7 +7279,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you ) move_item( you, *contained, contained->count(), src_loc, src_loc, this_veh, this_part ); it->first->remove_item( *contained ); } - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { return; } } @@ -7292,7 +7292,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you ) continue; } you.gunmod_remove( *it->first, *mod ); - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { return; } } @@ -7303,7 +7303,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you ) while( !it->first->get_contents().get_added_pockets().empty() ) { item removed = it->first->get_contents().remove_pocket( 0 ); move_item( you, removed, 1, src_loc, src_loc, this_veh, this_part ); - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { return; } } @@ -7315,7 +7315,7 @@ void unload_loot_activity_actor::do_turn( player_activity &act, Character &you ) return; } - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { return; } } diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 0d8f6114af9eb..85430a0dbdd7d 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1773,12 +1773,12 @@ void activity_handlers::pulp_do_turn( player_activity *act, Character *you ) moves += 100 / std::max( 0.25f, stamina_ratio ) * you->exertion_adjusted_move_multiplier( act->exertion_level() ); if( stamina_ratio < 0.33 || you->is_npc() ) { - you->moves = std::min( 0, you->moves - moves ); + you->set_moves( std::min( 0, you->get_moves() - moves ) ); return; } - if( moves >= you->moves ) { + if( moves >= you->get_moves() ) { // Enough for this turn; - you->moves -= moves; + you->mod_moves( -moves ); return; } } @@ -1902,7 +1902,7 @@ void activity_handlers::start_fire_do_turn( player_activity *act, Character *you return; } - you->mod_moves( -you->moves ); + you->mod_moves( -you->get_moves() ); const firestarter_actor *actor = dynamic_cast( usef->get_actor_ptr() ); const float light = actor->light_mod( you->pos() ); act->moves_left -= light * 100; @@ -2935,12 +2935,12 @@ void activity_handlers::repair_item_do_turn( player_activity *act, Character *yo { // Moves are decremented based on a combination of speed and good vision (not in the dark, farsighted, etc) const float exertion_mult = you->exertion_adjusted_move_multiplier( act->exertion_level() ); - const int effective_moves = you->moves / ( you->fine_detail_vision_mod() * exertion_mult ); + const int effective_moves = you->get_moves() / ( you->fine_detail_vision_mod() * exertion_mult ); if( effective_moves <= act->moves_left ) { act->moves_left -= effective_moves; - you->moves = 0; + you->set_moves( 0 ); } else { - you->moves -= act->moves_left * you->fine_detail_vision_mod(); + you->mod_moves( -act->moves_left * you->fine_detail_vision_mod() ); act->moves_left = 0; } } @@ -3525,7 +3525,7 @@ static void perform_zone_activity_turn( // we are at destination already /* Perform action */ tile_action( *you, tile_loc ); - if( you->moves <= 0 ) { + if( you->get_moves() <= 0 ) { return; } } diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index 0eb63affcd346..4abd4e24b44b6 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -2350,7 +2350,7 @@ void activity_on_turn_move_loot( player_activity &act, Character &you ) break; } } - if( you.moves <= 0 || move_and_reset ) { + if( you.get_moves() <= 0 || move_and_reset ) { return; } } @@ -3190,7 +3190,7 @@ bool generic_multi_activity_handler( player_activity &act, Character &you, bool continue; } if( !check_only ) { - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { // Restart activity and break from cycle. you.assign_activity( activity_to_restore ); return true; @@ -3229,7 +3229,7 @@ bool generic_multi_activity_handler( player_activity &act, Character &you, bool } } if( !check_only ) { - if( you.moves <= 0 ) { + if( you.get_moves() <= 0 ) { // Restart activity and break from cycle. you.assign_activity( activity_to_restore ); you.activity_vehicle_part_index = -1; diff --git a/src/addiction.cpp b/src/addiction.cpp index 0a35f6061b030..faa8ee3ff90d9 100644 --- a/src/addiction.cpp +++ b/src/addiction.cpp @@ -292,7 +292,7 @@ static bool amphetamine_effect( Character &u, addiction &add ) u.in_sleep_state() ? "addict_amphetamine_paralysis_asleep" : "addict_amphetamine_paralysis_awake"; u.add_msg_if_player( m_warning, SNIPPET.random_from_category( msg ).value_or( translation() ).translated() ); - u.moves -= ( u.in_sleep_state() ? 6000 : 300 ); + u.mod_moves( -( u.in_sleep_state() ? 6000 : 300 ) ); u.wake_up(); ret = true; } else if( !u.has_effect( effect_hallu ) && one_in( 20 ) && 8 + dice( 2, 80 ) < in ) { diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index aee941f0131dc..ad7c7c70d311f 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -1832,7 +1832,7 @@ void advanced_inventory::display() } while( !exit ) { - if( player_character.moves < 0 ) { + if( player_character.get_moves() < 0 ) { do_return_entry(); return; } diff --git a/src/armor_layers.cpp b/src/armor_layers.cpp index b16105fa9c8c7..909bbd380cc8a 100644 --- a/src/armor_layers.cpp +++ b/src/armor_layers.cpp @@ -914,7 +914,7 @@ void outfit::sort_armor( Character &guy ) while( !exit ) { if( guy.is_avatar() ) { // Totally hoisted this from advanced_inv - if( player_character.moves < 0 ) { + if( player_character.get_moves() < 0 ) { do_return_entry(); return; } diff --git a/src/avatar.cpp b/src/avatar.cpp index 56bb85ca06f1c..f84ab64bf4b84 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -1425,7 +1425,7 @@ bool avatar::wield( item &target, const int obtain_cost ) } add_msg_debug( debugmode::DF_AVATAR, "wielding took %d moves", mv ); - moves -= mv; + mod_moves( -mv ); if( has_item( target ) ) { item removed = i_rem( &target ); @@ -1528,7 +1528,7 @@ bool avatar::invoke_item( item *used, const std::string &method, const tripoint int pre_obtain_moves ) { if( pre_obtain_moves == -1 ) { - pre_obtain_moves = moves; + pre_obtain_moves = get_moves(); } return Character::invoke_item( used, method, pt, pre_obtain_moves ); } diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index f45aae902d3e1..a6174423f8529 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -328,7 +328,8 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) } if( !you.move_effects( attacking ) ) { - you.moves -= 100; + // move_effects determined we could not move, waste all moves + you.set_moves( 0 ); return false; } @@ -438,7 +439,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) if( you.is_auto_moving() ) { you.clear_destination(); } - you.moves -= 20; + you.mod_moves( -you.get_speed() * 0.2 ); return false; } } @@ -474,7 +475,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) && you.is_walking() && !veh_closed_door && m.open_door( you, dest_loc, !m.is_outside( you.pos() ) ) ) { - you.moves -= 100; + you.mod_moves( -you.get_speed() ); you.add_msg_if_player( _( "You open the %s." ), door_name ); // if auto move is on, continue moving next turn if( you.is_auto_moving() ) { @@ -501,7 +502,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) //~ %1$s - vehicle name, %2$s - part name you.add_msg_if_player( _( "You open the %1$s's %2$s." ), veh1->name, door_name ); } - you.moves -= 100; + you.mod_moves( -you.get_speed() ); // if auto move is on, continue moving next turn if( you.is_auto_moving() ) { you.defer_move( dest_loc ); @@ -510,7 +511,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) } if( m.furn( dest_loc ) != f_safe_c && m.open_door( you, dest_loc, !m.is_outside( you.pos() ) ) ) { - you.moves -= 100; + you.mod_moves( -you.get_speed() ); if( veh1 != nullptr ) { //~ %1$s - vehicle name, %2$s - part name you.add_msg_if_player( _( "You open the %1$s's %2$s." ), veh1->name, door_name ); @@ -530,7 +531,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d ) add_msg( _( "You bump into the %s!" ), m.obstacle_name( dest_loc ) ); // Only lose movement if we're blind if( waste_moves ) { - you.moves -= 100; + you.mod_moves( -you.get_speed() ); } } else if( m.ter( dest_loc ) == t_door_locked || m.ter( dest_loc ) == t_door_locked_peep || m.ter( dest_loc ) == t_door_locked_alarm || m.ter( dest_loc ) == t_door_locked_interior ) { @@ -590,7 +591,8 @@ bool avatar_action::ramp_move( avatar &you, map &m, const tripoint &dest_loc ) move( you, m, tripoint( dp.xy(), 1 ) ); // We can't just take the result of the above function here if( you.pos() != old_pos ) { - you.moves -= 50 + ( aligned_ramps ? 0 : 50 ); + const double total_move_cost = aligned_ramps ? 0.5 : 1.0; + you.mod_moves( -you.get_speed() * total_move_cost ); } return true; @@ -660,7 +662,7 @@ void avatar_action::swim( map &m, avatar &you, const tripoint &p ) if( m.veh_at( you.pos() ).part_with_feature( VPFLAG_BOARDABLE, true ) ) { m.board_vehicle( you.pos(), &you ); } - you.moves -= ( movecost > 200 ? 200 : movecost ) * ( trigdist && diagonal ? M_SQRT2 : 1 ); + you.mod_moves( -( ( movecost > 200 ? 200 : movecost ) * ( trigdist && diagonal ? M_SQRT2 : 1 ) ) ); you.inv->rust_iron_items(); if( !you.is_mounted() ) { @@ -1128,7 +1130,7 @@ void avatar_action::use_item( avatar &you, item_location &loc, std::string const item_pocket *parent_pocket = nullptr; bool on_person = true; - int pre_obtain_moves = you.moves; + int pre_obtain_moves = you.get_moves(); if( loc->has_flag( flag_ALLOWS_REMOTE_USE ) || you.is_worn( *loc ) ) { use_in_place = true; // Activate holster on map only if hands are free. @@ -1155,7 +1157,7 @@ void avatar_action::use_item( avatar &you, item_location &loc, std::string const parent_pocket->on_contents_changed(); } if( pre_obtain_moves == -1 ) { - pre_obtain_moves = you.moves; + pre_obtain_moves = you.get_moves(); } if( !loc ) { you.add_msg_if_player( _( "Couldn't pick up the %s." ), name ); diff --git a/src/character.cpp b/src/character.cpp index 9eaef5aa514dc..31850124df883 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1818,7 +1818,7 @@ void Character::forced_dismount() if( activity ) { cancel_activity(); } - moves -= 150; + mod_moves( -get_speed() * 1.5 ); } void Character::dismount() @@ -7167,7 +7167,7 @@ bool Character::invoke_item( item *used, const std::string &method, const tripoi ammo_rem ), it_name, ammo_rem, ammo_req ); } - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); return false; } @@ -7175,14 +7175,14 @@ bool Character::invoke_item( item *used, const std::string &method, const tripoi if( actually_used == nullptr ) { debugmsg( "Tried to invoke a method %s on item %s, which doesn't have this method", method.c_str(), used->tname() ); - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); return false; } std::optional charges_used = actually_used->type->invoke( this, *actually_used, pt, method ); if( !charges_used.has_value() ) { - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); return false; } @@ -7354,7 +7354,7 @@ void Character::cough( bool harmful, int loudness ) sounds::sound( pos(), loudness, sounds::sound_t::speech, _( "a hacking cough." ), false, "misc", "cough" ); - moves -= 80; + mod_moves( -get_speed() * 0.8 ); add_effect( effect_disrupted_sleep, 5_minutes ); } @@ -11734,7 +11734,7 @@ bool Character::unload( item_location &loc, bool bypass_activity, return false; } // Eject magazine consuming half as much time as required to insert it - this->moves -= this->item_reload_cost( *target, *target->magazine_current(), -1 ) / 2; + this->mod_moves( -this->item_reload_cost( *target, *target->magazine_current(), -1 ) / 2 ); target->remove_items_with( [&target]( const item & e ) { return target->magazine_current() == &e; @@ -11762,7 +11762,7 @@ bool Character::unload( item_location &loc, bool bypass_activity, } // If successful remove appropriate qty of ammo consuming half as much time as required to load it - this->moves -= this->item_reload_cost( *target, ammo, qty ) / 2; + this->mod_moves( -this->item_reload_cost( *target, ammo, qty ) / 2 ); target->ammo_set( target->ammo_current(), target->ammo_remaining() - qty ); } else if( target->has_flag( flag_BRASS_CATCHER ) ) { @@ -12929,7 +12929,7 @@ bool Character::wield_contents( item &container, item *internal_item, bool penal inv->update_cache_with_item( weapon ); last_item = weapon.typeId(); - moves -= mv; + mod_moves( -mv ); weapon.on_wield( *this ); @@ -12943,7 +12943,7 @@ bool Character::wield_contents( item &container, item *internal_item, bool penal void Character::store( item &container, item &put, bool penalties, int base_cost, pocket_type pk_type, bool check_best_pkt ) { - moves -= item_store_cost( put, container, penalties, base_cost ); + mod_moves( -item_store_cost( put, container, penalties, base_cost ) ); if( check_best_pkt && pk_type == pocket_type::CONTAINER && container.get_all_contained_pockets().size() > 1 ) { // Bypass pocket settings (assuming the item is manually stored) @@ -12966,8 +12966,8 @@ void Character::store( item_pocket *pocket, item &put, bool penalties, int base_ if( !!pkt_best && pocket->better_pocket( *pkt_best, put, true ) ) { pocket = pkt_best; } - moves -= std::max( item_store_cost( put, null_item_reference(), penalties, base_cost ), - pocket->obtain_cost( put ) ); + mod_moves( -std::max( item_store_cost( put, null_item_reference(), penalties, base_cost ), + pocket->obtain_cost( put ) ) ); ret_val result = pocket->insert_item( i_rem( &put ) ); result.value()->on_pickup( *this ); calc_encumbrance(); @@ -12995,11 +12995,11 @@ void Character::use( item_location loc, int pre_obtain_moves, std::string const // if -1 is passed in we don't want to change moves at all if( pre_obtain_moves == -1 ) { - pre_obtain_moves = moves; + pre_obtain_moves = get_moves(); } if( !loc ) { add_msg( m_info, _( "You do not have that item." ) ); - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); return; } @@ -13009,7 +13009,7 @@ void Character::use( item_location loc, int pre_obtain_moves, std::string const if( used.is_tool() ) { if( !used.type->has_use() ) { add_msg_if_player( _( "You can't do anything interesting with your %s." ), used.tname() ); - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); return; } invoke_item( &used, method, loc.position(), pre_obtain_moves ); @@ -13022,20 +13022,20 @@ void Character::use( item_location loc, int pre_obtain_moves, std::string const if( used.is_medication() && !can_use_heal_item( used ) ) { add_msg_if_player( m_bad, _( "Your biology is not compatible with that healing item." ) ); - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); return; } if( avatar *u = as_avatar() ) { const ret_val ret = u->will_eat( used, true ); if( !ret.success() ) { - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); return; } u->assign_activity( consume_activity_actor( loc ) ); } else { const time_duration &consume_time = get_consume_time( used ); - moves -= to_moves( consume_time ); + mod_moves( -to_moves( consume_time ) ); consume( loc ); } } else if( used.is_book() ) { @@ -13061,7 +13061,7 @@ void Character::use( item_location loc, int pre_obtain_moves, std::string const } else { add_msg( m_info, _( "You can't do anything interesting with your %s." ), used.tname() ); } - moves = pre_obtain_moves; + set_moves( pre_obtain_moves ); } } @@ -13161,7 +13161,7 @@ bodypart_id Character::most_staunchable_bp( int &max_staunch ) void Character::pause() { - moves = 0; + set_moves( 0 ); recoil = MAX_RECOIL; map &here = get_map(); diff --git a/src/character_attire.cpp b/src/character_attire.cpp index 7bbc95fbccc22..20291b17bcde4 100644 --- a/src/character_attire.cpp +++ b/src/character_attire.cpp @@ -310,7 +310,7 @@ std::optional::iterator> outfit::wear_item( Character &guy, cons _( " puts on their %s." ), to_wear.tname() ); } - guy.moves -= guy.item_wear_cost( to_wear ); + guy.mod_moves( -guy.item_wear_cost( to_wear ) ); for( const bodypart_id &bp : guy.get_all_body_parts() ) { if( to_wear.covers( bp ) && guy.encumb( bp ) >= 40 && !quiet ) { diff --git a/src/character_inventory.cpp b/src/character_inventory.cpp index 5d80fece9fb20..252fb7ad8502c 100644 --- a/src/character_inventory.cpp +++ b/src/character_inventory.cpp @@ -708,7 +708,7 @@ bool Character::dispose_item( item_location &&obj, const std::string &prompt ) return false; } - moves -= item_handling_cost( *obj ); + mod_moves( -item_handling_cost( *obj ) ); this->i_add( *obj, true, &*obj, &*obj ); obj.remove_item(); return true; diff --git a/src/computer_session.cpp b/src/computer_session.cpp index 1db66962fdf37..63299c8b3867a 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -238,7 +238,8 @@ bool computer_session::hack_attempt( Character &you, int Security ) const Security += ( comp.alerts * 2 ); } - you.moves -= 10 * ( 5 + Security * 2 ) / std::max( 1, hack_skill + 1 ); + you.mod_moves( -( 10 * ( 5 + Security * 2 ) / std::max( 1, hack_skill + 1 ) ) ); + int player_roll = round( you.get_greater_skill_or_knowledge_level( skill_computer ) ); //this relates to the success of the roll for hacking - the practical skill covers the time. ///\EFFECT_INT <8 randomly penalizes hack attempts, 50% of the time @@ -385,7 +386,7 @@ void computer_session::activate_function( computer_action action ) const auto it = computer_action_functions.find( action ); if( it != computer_action_functions.end() ) { // Token move cost for any action, if an action takes longer decrement moves further. - get_player_character().moves -= 30; + get_player_character().mod_moves( -to_moves( 1_seconds ) * 0.3 ); ( this->*( it->second ) )(); } } @@ -461,7 +462,7 @@ void computer_session::action_toll() void computer_session::action_sample() { - get_player_character().moves -= 30; + get_player_character().mod_moves( -to_moves( 1_seconds ) * 0.3 ); map &here = get_map(); for( const tripoint &p : here.points_on_zlevel() ) { if( here.ter( p ) != t_sewage_pump ) { @@ -589,7 +590,7 @@ void computer_session::action_research() if( !log.has_value() ) { log = to_translation( "No data found." ); } else { - get_player_character().moves -= 70; + get_player_character().mod_moves( -to_moves( 1_seconds ) * 0.7 ); } print_text( "%s", log.value() ); @@ -607,7 +608,7 @@ void computer_session::action_research() void computer_session::action_radio_archive() { - get_player_character().moves -= 300; + get_player_character().mod_moves( -to_moves( 3_seconds ) ); sfx::fade_audio_channel( sfx::channel::radio, 100 ); sfx::play_ambient_variant_sound( "radio", "inaudible_chatter", 100, sfx::channel::radio, 2000 ); @@ -625,7 +626,7 @@ void computer_session::action_radio_archive() void computer_session::action_maps() { Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); const tripoint_abs_omt center = player_character.global_omt_location(); overmap_buffer.reveal( center.xy(), 40, 0 ); query_any( @@ -637,7 +638,7 @@ void computer_session::action_maps() void computer_session::action_map_sewer() { Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); const tripoint_abs_omt center = player_character.global_omt_location(); for( int i = -60; i <= 60; i++ ) { for( int j = -60; j <= 60; j++ ) { @@ -656,7 +657,7 @@ void computer_session::action_map_sewer() void computer_session::action_map_subway() { Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); const tripoint_abs_omt center = player_character.global_omt_location(); for( int i = -60; i <= 60; i++ ) { for( int j = -60; j <= 60; j++ ) { @@ -747,7 +748,7 @@ void computer_session::action_miss_launch() void computer_session::action_list_bionics() { - get_player_character().moves -= 30; + get_player_character().mod_moves( -to_moves( 1_seconds ) * 0.3 ); std::vector names; int more = 0; map &here = get_map(); @@ -854,7 +855,7 @@ void computer_session::action_amigara_log() get_timed_events().add( timed_event_type::AMIGARA_WHISPERS, calendar::turn + 5_minutes ); Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); reset_terminal(); point_abs_sm abs_sub = get_map().get_abs_sub().xy(); print_line( _( "NEPower Mine%s Log" ), abs_sub.to_string() ); @@ -863,7 +864,7 @@ void computer_session::action_amigara_log() if( !query_bool( _( "Continue reading?" ) ) ) { return; } - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); reset_terminal(); print_line( _( "NEPower Mine%s Log" ), abs_sub.to_string() ); print_text( "%s", SNIPPET.random_from_category( "amigara2" ).value_or( translation() ) ); @@ -871,7 +872,7 @@ void computer_session::action_amigara_log() if( !query_bool( _( "Continue reading?" ) ) ) { return; } - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); reset_terminal(); print_line( _( "NEPower Mine%s Log" ), abs_sub.to_string() ); print_text( "%s", SNIPPET.random_from_category( "amigara3" ).value_or( translation() ) ); @@ -892,7 +893,7 @@ void computer_session::action_amigara_log() if( !query_bool( _( "Continue reading?" ) ) ) { return; } - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); reset_terminal(); tripoint_abs_sm abs_loc = get_map().get_abs_sub(); print_line( _( "SITE %d%d%d\n" @@ -982,7 +983,7 @@ void computer_session::action_download_software() debugmsg( _( "Computer couldn't find its mission!" ) ); return; } - get_player_character().moves -= 30; + get_player_character().mod_moves( -to_moves( 1_seconds ) * 0.3 ); item software( miss->get_item_id(), calendar::turn_zero ); software.mission_id = comp.mission_id; usb->clear_items(); @@ -997,7 +998,7 @@ void computer_session::action_download_software() void computer_session::action_blood_anal() { Character &player_character = get_player_character(); - player_character.moves -= 70; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.7 ); map &here = get_map(); for( const tripoint &dest : here.points_in_radius( player_character.pos(), 2 ) ) { if( here.furn( dest ) == furn_f_centrifuge ) { @@ -1045,7 +1046,7 @@ void computer_session::action_blood_anal() void computer_session::action_data_anal() { Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); map &here = get_map(); for( const tripoint &dest : here.points_in_radius( player_character.pos(), 2 ) ) { if( here.ter( dest ) == t_floor_blue ) { @@ -1272,7 +1273,7 @@ void computer_session::action_srcf_elevator() void computer_session::action_irradiator() { Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); bool error = false; bool platform_exists = false; map &here = get_map(); @@ -1282,7 +1283,7 @@ void computer_session::action_irradiator() if( here.i_at( dest ).empty() ) { print_error( _( "ERROR: Processing platform empty." ) ); } else { - player_character.moves -= 300; + player_character.mod_moves( -to_moves( 3_seconds ) ); for( auto it = here.i_at( dest ).begin(); it != here.i_at( dest ).end(); ++it ) { // actual food processing if( !it->rotten() ) { @@ -1351,7 +1352,7 @@ void computer_session::action_irradiator() void computer_session::action_geiger() { Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); tripoint platform; bool source_exists = false; int sum_rads = 0; @@ -1394,7 +1395,7 @@ void computer_session::action_geiger() void computer_session::action_conveyor() { Character &player_character = get_player_character(); - player_character.moves -= 300; + player_character.mod_moves( -to_moves( 3_seconds ) ); tripoint loading; // red tile = loading bay tripoint unloading; // green tile = unloading bay tripoint platform; // radiation platform = middle point @@ -1448,7 +1449,7 @@ void computer_session::action_conveyor() void computer_session::action_shutters() { Character &player_character = get_player_character(); - player_character.moves -= 300; + player_character.mod_moves( -to_moves( 3_seconds ) ); get_map().translate_radius( t_reinforced_glass_shutter_open, t_reinforced_glass_shutter, 8.0, player_character.pos(), true, true ); @@ -1460,7 +1461,7 @@ void computer_session::action_extract_rad_source() { Character &player_character = get_player_character(); if( query_yn( _( "Operation irreversible. Extract radioactive material?" ) ) ) { - player_character.moves -= 300; + player_character.mod_moves( -to_moves( 3_seconds ) ); tripoint platform; bool p_exists = false; map &here = get_map(); @@ -1486,7 +1487,7 @@ void computer_session::action_extract_rad_source() void computer_session::action_deactivate_shock_vent() { Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); bool has_vent = false; map &here = get_map(); for( const tripoint &dest : here.points_in_radius( player_character.pos(), 10 ) ) { diff --git a/src/creature.h b/src/creature.h index ad8f4951684d7..a56dd7ab96339 100644 --- a/src/creature.h +++ b/src/creature.h @@ -936,7 +936,6 @@ class Creature : public viewer /** Returns a set of points we do not want to path through. */ virtual std::unordered_set get_path_avoid() const = 0; - int moves; bool underwater; void draw( const catacurses::window &w, const point &origin, bool inverted ) const; void draw( const catacurses::window &w, const tripoint &origin, bool inverted ) const; @@ -1188,6 +1187,8 @@ class Creature : public viewer void set_summoner( character_id summoner ); Creature *get_summoner() const; protected: + // How many moves do we have to work with + int moves; Creature *killer; // whoever killed us. this should be NULL unless we are dead void set_killer( Creature *killer ); std::optional lifespan_end = std::nullopt; diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 80dd2d7e91b92..f2c7cfc2a9564 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -3454,7 +3454,7 @@ void debug() case debug_menu_index::QUIT_NOSAVE: if( query_yn( _( "Quit without saving? This may cause issues such as duplicated or missing items and vehicles!" ) ) ) { - player_character.moves = 0; + player_character.set_moves( 0 ); g->uquit = QUIT_NOSAVED; } break; diff --git a/src/do_turn.cpp b/src/do_turn.cpp index 73a085e12a8a3..65241b19d2f22 100644 --- a/src/do_turn.cpp +++ b/src/do_turn.cpp @@ -265,14 +265,14 @@ void monmove() critter.try_biosignature(); critter.try_reproduce(); } - while( critter.moves > 0 && !critter.is_dead() && !critter.has_effect( effect_ridden ) ) { + while( critter.get_moves() > 0 && !critter.is_dead() && !critter.has_effect( effect_ridden ) ) { critter.made_footstep = false; // Controlled critters don't make their own plans if( !critter.has_effect( effect_controlled ) ) { // Formulate a path to follow critter.plan(); } else { - critter.moves = 0; + critter.set_moves( 0 ); break; } critter.move(); // Move one square, possibly hit u @@ -306,7 +306,7 @@ void monmove() for( npc &guy : g->all_npcs() ) { int turns = 0; int real_count = 0; - const int count_limit = std::max( 10, guy.moves / 64 ); + const int count_limit = std::max( 10, guy.get_moves() / 64 ); if( guy.is_mounted() ) { guy.check_mount_is_spooked(); } @@ -315,11 +315,11 @@ void monmove() guy.process_turn(); } while( !guy.is_dead() && ( !guy.in_sleep_state() || guy.activity.id() == ACT_OPERATION ) && - guy.moves > 0 && turns < 10 ) { - const int moves = guy.moves; + guy.get_moves() > 0 && turns < 10 ) { + const int moves = guy.get_moves(); const bool has_destination = guy.has_destination_activity(); guy.move(); - if( moves == guy.moves ) { + if( moves == guy.get_moves() ) { // Count every time we exit npc::move() without spending any moves. real_count++; if( has_destination == guy.has_destination_activity() || real_count > count_limit ) { @@ -490,7 +490,7 @@ bool do_turn() g->reset_light_level(); g->perhaps_add_random_npc( /* ignore_spawn_timers_and_rates = */ false ); - while( u.moves > 0 && u.activity ) { + while( u.get_moves() > 0 && u.activity ) { u.activity.do_turn( u ); } // FIXME: hack needed due to the legacy code in advanced_inventory::move_all_items() @@ -515,8 +515,8 @@ bool do_turn() } if( !u.has_effect( effect_sleep ) || g->uquit == QUIT_WATCH ) { - if( u.moves > 0 || g->uquit == QUIT_WATCH ) { - while( u.moves > 0 || g->uquit == QUIT_WATCH ) { + if( u.get_moves() > 0 || g->uquit == QUIT_WATCH ) { + while( u.get_moves() > 0 || g->uquit == QUIT_WATCH ) { g->cleanup_dead(); g->mon_info_update(); // Process any new sounds the player caused during their turn. @@ -550,7 +550,7 @@ bool do_turn() if( g->uquit == QUIT_WATCH ) { break; } - while( u.moves > 0 && u.activity ) { + while( u.get_moves() > 0 && u.activity ) { u.activity.do_turn( u ); } } @@ -636,7 +636,7 @@ bool do_turn() } g->mon_info_update(); u.process_turn(); - if( u.moves < 0 && get_option( "FORCE_REDRAW" ) ) { + if( u.get_moves() < 0 && get_option( "FORCE_REDRAW" ) ) { ui_manager::redraw(); refresh_display(); } diff --git a/src/game.cpp b/src/game.cpp index d223564acb1df..e420bdfc96f79 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -913,7 +913,7 @@ bool game::start_game() overmap_buffer.reveal( city_center_omt, city_size ); } - u.moves = 0; + u.set_moves( 0 ); u.process_turn(); // process_turn adds the initial move points u.set_stamina( u.get_stamina_max() ); weather.temperature = SPRING_TEMPERATURE; @@ -2703,7 +2703,7 @@ bool game::is_game_over() } if( uquit == QUIT_WATCH ) { // deny player movement and dodging - u.moves = 0; + u.set_moves( 0 ); // prevent pain from updating u.set_pain( 0 ); // prevent dodging @@ -5615,7 +5615,7 @@ void game::exam_appliance( vehicle &veh, const point &c ) { player_activity act = veh_app_interact::run( veh, c ); if( act ) { - u.moves = 0; + u.set_moves( 0 ); u.assign_activity( act ); } } @@ -5628,7 +5628,7 @@ void game::exam_vehicle( vehicle &veh, const point &c ) } player_activity act = veh_interact::run( veh, c ); if( act ) { - u.moves = 0; + u.set_moves( 0 ); u.assign_activity( act ); } } @@ -5790,7 +5790,7 @@ void game::moving_vehicle_dismount( const tripoint &dest_loc ) const units::angle d = ray.dir(); add_msg( _( "You dive from the %s." ), veh->name ); m.unboard_vehicle( u.pos() ); - u.moves -= 200; + u.mod_moves( -to_moves( 2_seconds ) ); // Dive three tiles in the direction of tox and toy fling_creature( &u, d, 30, true, true ); // Hit the ground according to vehicle speed @@ -6344,7 +6344,7 @@ void game::peek() void game::peek( const tripoint &p ) { - u.moves -= 200; + u.mod_moves( -u.get_speed() * 2 ); tripoint prev = u.pos(); u.setpos( p ); const bool is_same_pos = u.pos() == prev; @@ -10568,7 +10568,7 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool return false; } bool diag = trigdist && u.posx() != dest_loc.x && u.posy() != dest_loc.y; - const int previous_moves = u.moves; + const int previous_moves = u.get_moves(); if( u.is_mounted() ) { auto *crit = u.mounted_creature.get(); if( !crit->has_flag( mon_flag_RIDEABLE_MECH ) && @@ -10582,10 +10582,10 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool } const double base_moves = u.run_cost( mcost, diag ) * 100.0 / crit->get_speed(); const double encumb_moves = u.get_weight() / 4800.0_gram; - u.moves -= static_cast( std::ceil( base_moves + encumb_moves ) ); + u.mod_moves( -static_cast( std::ceil( base_moves + encumb_moves ) ) ); crit->use_mech_power( u.current_movement_mode()->mech_power_use() ); } else { - u.moves -= u.run_cost( mcost, diag ); + u.mod_moves( -u.run_cost( mcost, diag ) ); /** TODO: This should really use the mounted creatures stamina, if mounted. @@ -10594,10 +10594,10 @@ bool game::walk_move( const tripoint &dest_loc, const bool via_ramp, const bool */ if( grabbed_vehicle == nullptr || grabbed_vehicle->wheelcache.empty() ) { //Burn normal amount of stamina if no vehicle grabbed or vehicle lacks wheels - u.burn_move_stamina( previous_moves - u.moves ); + u.burn_move_stamina( previous_moves - u.get_moves() ); } else { //Burn half as much stamina if vehicle has wheels, without changing move time - u.burn_move_stamina( 0.50 * ( previous_moves - u.moves ) ); + u.burn_move_stamina( 0.50 * ( previous_moves - u.get_moves() ) ); } } // Max out recoil & reset aim point @@ -11211,7 +11211,7 @@ bool game::phasing_move( const tripoint &dest_loc, const bool via_ramp ) add_msg( _( "You quantum tunnel through the %d-tile wide barrier!" ), tunneldist ); //tunneling costs 250 bionic power per impassable tile u.mod_power_level( -( tunneldist * trigger_cost ) ); - u.moves -= 100; //tunneling costs 100 moves + u.mod_moves( -to_moves( 1_seconds ) ); //tunneling takes exactly one second u.setpos( dest ); if( m.veh_at( u.pos() ).part_with_feature( "BOARDABLE", true ) ) { @@ -11969,7 +11969,8 @@ void game::vertical_move( int movez, bool force, bool peeking ) } if( !u.move_effects( false ) && !force ) { - u.moves -= 100; + // move_effects determined we could not move, waste all moves + u.set_moves( 0 ); return; } @@ -12102,7 +12103,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) crit->use_mech_power( u.current_movement_mode()->mech_power_use() + 1_kJ ); } } else { - u.moves -= move_cost; + u.mod_moves( -move_cost ); u.burn_energy_all( -move_cost ); } @@ -12161,7 +12162,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) } if( player_displace ) { u.setpos( *displace ); - u.moves -= 20; + u.mod_moves( -to_moves( 1_seconds ) * 0.2 );; add_msg( _( "You push past %s blocking the way." ), crit_name ); } } @@ -12950,7 +12951,7 @@ void game::quickload() moves_since_last_save = 0; last_save_timestamp = std::time( nullptr ); - u.moves = 0; + u.set_moves( 0 ); uquit = QUIT_NOSAVED; main_menu::queued_world_to_load = world_name; @@ -13431,7 +13432,8 @@ void game::climb_down_using( const tripoint &examp, climbing_aid_id aid_id, bool // If player is grabbed, trapped, or somehow otherwise movement-impeded, first try to break free if( !you.move_effects( false ) ) { - you.moves -= 100; + // move_effects determined we could not move, waste all moves + you.set_moves( 0 ); return; } @@ -13561,7 +13563,7 @@ void game::climb_down_using( const tripoint &examp, climbing_aid_id aid_id, bool you.set_activity_level( ACTIVE_EXERCISE ); float weary_mult = 1.0f / you.exertion_adjusted_move_multiplier( ACTIVE_EXERCISE ); - you.moves -= to_moves( 1_seconds + 1_seconds * fall_mod ) * weary_mult; + you.mod_moves( -to_moves( 1_seconds + 1_seconds * fall_mod ) * weary_mult ); you.setpos( examp ); // Pre-descent message. diff --git a/src/grab.cpp b/src/grab.cpp index 8be8d3005ace1..cdfe5b36ce3c9 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -112,22 +112,22 @@ bool game::grabbed_veh_move( const tripoint &dp ) if( str_req <= str ) { //calculate exertion factor and movement penalty ///\EFFECT_STR increases speed of dragging vehicles - u.moves -= 400 * str_req / std::max( 1, str ); + u.mod_moves( -to_moves( 4_seconds ) * str_req / std::max( 1, str ) ); ///\EFFECT_STR decreases stamina cost of dragging vehicles u.burn_energy_all( -200 * str_req / std::max( 1, str ) ); const int ex = dice( 1, 6 ) - 1 + str_req; if( ex > str + 1 ) { // Pain and movement penalty if exertion exceeds character strength add_msg( m_bad, _( "You strain yourself to move the %s!" ), grabbed_vehicle->name ); - u.moves -= 200; + u.mod_moves( -to_moves( 2_seconds ) ); u.mod_pain( 1 ); } else if( ex >= str ) { // Movement is slow if exertion nearly equals character strength add_msg( _( "It takes some time to move the %s." ), grabbed_vehicle->name ); - u.moves -= 200; + u.mod_moves( -to_moves( 2_seconds ) ); } } else { - u.moves -= 100; + u.mod_moves( -to_moves( 1_seconds ) ); add_msg( m_bad, _( "You lack the strength to move the %s." ), grabbed_vehicle->name ); return true; } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 4bc112705dfb8..c297ab5fc57aa 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -469,7 +469,7 @@ static void rcdrive( const point &d ) tripoint src( c ); //~ Sound of moving a remote controlled car sounds::sound( src, 6, sounds::sound_t::movement, _( "zzz…" ), true, "misc", "rc_car_drives" ); - player_character.moves -= 50; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.5 ); here.i_rem( src, rc_car ); car_location_string.clear(); car_location_string << dest.x << ' ' << dest.y << ' ' << dest.z; @@ -576,14 +576,14 @@ static void open() const tripoint openp = *openp_; map &here = get_map(); - player_character.moves -= 100; + player_character.mod_moves( -to_moves( 1_seconds ) ); // Is a vehicle part here? if( const optional_vpart_position vp = here.veh_at( openp ) ) { vehicle *const veh = &vp->vehicle(); // Check for potential thievery, and restore moves if action is canceled if( !veh->handle_potential_theft( player_character ) ) { - player_character.moves += 100; + player_character.mod_moves( to_moves( 1_seconds ) ); return; } // Check if vehicle has a part here that can be opened @@ -605,7 +605,7 @@ static void open() int outside_openable = veh->next_part_to_open( vp->part_index(), true ); if( outside_openable == -1 ) { add_msg( m_info, _( "That %s can only be opened from the inside." ), part_name ); - player_character.moves += 100; + player_character.mod_moves( to_moves( 1_seconds ) ); } else { veh->open_all_at( openable ); //~ %1$s - vehicle name, %2$s - part name @@ -623,7 +623,7 @@ static void open() add_msg( m_info, _( "That %s is already open." ), name ); } } - player_character.moves += 100; + player_character.mod_moves( to_moves( 1_seconds ) ); } return; } @@ -640,11 +640,11 @@ static void open() } else if( tid.obj().close ) { // if the following message appears unexpectedly, the prior check was for t_door_o add_msg( m_info, _( "That door is already open." ) ); - player_character.moves += 100; + player_character.mod_moves( to_moves( 1_seconds ) ); return; } add_msg( m_info, _( "No door there." ) ); - player_character.moves += 100; + player_character.mod_moves( to_moves( 1_seconds ) ); } } @@ -1001,7 +1001,7 @@ static void smash() } } } - player_character.moves -= move_cost * weary_mult; + player_character.mod_moves( -move_cost * weary_mult ); player_character.recoil = MAX_RECOIL; if( bash_result.success ) { @@ -1326,7 +1326,7 @@ static void sleep() } } - player_character.moves = 0; + player_character.set_moves( 0 ); player_character.try_to_sleep( try_sleep_dur ); } @@ -2641,7 +2641,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, case ACTION_SUICIDE: if( query_yn( _( "Abandon this character?" ) ) ) { if( query_yn( _( "This will kill your character. Continue?" ) ) ) { - player_character.moves = 0; + player_character.set_moves( 0 ); player_character.place_corpse(); uquit = QUIT_SUICIDE; } @@ -2651,7 +2651,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, case ACTION_SAVE: if( query_yn( _( "Save and quit?" ) ) ) { if( save() ) { - player_character.moves = 0; + player_character.set_moves( 0 ); uquit = QUIT_SAVED; } } @@ -3101,7 +3101,7 @@ bool game::handle_action() // This has no action unless we're in a special game mode. gamemode->pre_action( act ); - int before_action_moves = player_character.moves; + int before_action_moves = player_character.get_moves(); // These actions are allowed while deathcam is active. Registered in game::get_player_input if( uquit == QUIT_WATCH || !player_character.is_dead_state() ) { @@ -3120,9 +3120,9 @@ bool game::handle_action() gamemode->post_action( act ); player_character.movecounter = ( !player_character.is_dead_state() ? ( before_action_moves - - player_character.moves ) : 0 ); + player_character.get_moves() ) : 0 ); dbg( D_INFO ) << string_format( "%s: [%d] %d - %d = %d", action_ident( act ), to_turn( calendar::turn ), before_action_moves, player_character.movecounter, - player_character.moves ); + player_character.get_moves() ); return !player_character.is_dead_state(); } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 9b0e89947e89e..fed39ce2b5f08 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -740,7 +740,7 @@ class atm_menu } } - you.moves -= to_moves( 5_seconds ); + you.mod_moves( -to_moves( 5_seconds ) ); } //! Prompt for an integral value clamped to [0, max]. @@ -769,7 +769,7 @@ class atm_menu card.ammo_set( card.ammo_default(), 0 ); you.i_add( card ); you.cash -= 1000; - you.moves -= to_moves( 5_seconds ); + you.mod_moves( -to_moves( 5_seconds ) ); finish_interaction(); return true; @@ -795,7 +795,7 @@ class atm_menu add_msg( m_info, _( "You deposit %s into your account." ), format_money( amount ) ); you.use_charges( itype_cash_card, amount ); you.cash += amount; - you.moves -= to_moves( 10_seconds ); + you.mod_moves( -to_moves( 10_seconds ) ); finish_interaction(); return true; @@ -847,7 +847,7 @@ class atm_menu //dst->charges += amount; you.cash -= amount - remaining; - you.moves -= to_moves( 10_seconds ); + you.mod_moves( -to_moves( 10_seconds ) ); finish_interaction(); return true; @@ -891,7 +891,7 @@ class atm_menu return false; } // Feeding a bill into the machine takes at least one turn - you.moves -= std::max( 100, you.moves ); + you.mod_moves( -std::max( 100, you.get_moves() ) ); int value = units::to_cent( cash_item->type->price ); value *= 0.99; // subtract fee if( value > dst->ammo_capacity( ammo_money ) - dst->ammo_remaining() ) { @@ -933,7 +933,7 @@ class atm_menu if( i == dst || i->ammo_remaining() <= 0 || i->typeId() != itype_cash_card ) { continue; } - if( you.moves < 0 ) { + if( you.get_moves() < 0 ) { // Money from `*i` could be transferred, but we're out of moves, schedule it for // the next turn. Putting this here makes sure there will be something to be // done next turn. @@ -948,7 +948,7 @@ class atm_menu } dst->ammo_set( dst->ammo_default(), i->ammo_remaining() + dst->ammo_remaining() ); i->ammo_set( i->ammo_default(), 0 ); - you.moves -= 10; + you.mod_moves( -to_moves( 1_seconds ) * 0.1 ); } return true; @@ -1124,7 +1124,7 @@ void iexamine::vending( Character &you, const tripoint &examp ) if( !used_machine ) { used_machine = true; - you.moves -= moves_cost; + you.mod_moves( -moves_cost ); } money -= iprice; @@ -1463,7 +1463,7 @@ void iexamine::chainfence( Character &you, const tripoint &examp ) { // If player is grabbed, trapped, or somehow otherwise movement-impeded, first try to break free if( !you.move_effects( false ) ) { - you.moves -= 100; + you.mod_moves( -to_moves( 1_seconds ) ); return; } @@ -1518,7 +1518,7 @@ void iexamine::chainfence( Character &you, const tripoint &examp ) } else { move_cost = you.has_trait( trait_BADKNEES ) ? 800 : 400; if( g->slip_down( game::climb_maneuver::over_obstacle, climbing_aid_furn_CLIMBABLE ) ) { - you.moves -= move_cost; + you.mod_moves( -move_cost ); return; } } @@ -1531,7 +1531,7 @@ void iexamine::chainfence( Character &you, const tripoint &examp ) move_cost /= you.get_modifier( character_modifier_obstacle_climb_mod ); add_msg_debug( debugmode::DF_IEXAMINE, "Final move cost %d", move_cost ); - you.moves -= move_cost; + you.mod_moves( -move_cost ); if( you.in_vehicle ) { here.unboard_vehicle( you.pos() ); } @@ -1566,7 +1566,7 @@ void iexamine::bars( Character &you, const tripoint &examp ) none( you, examp ); return; } - you.moves -= to_moves( 2_seconds ); + you.mod_moves( -to_moves( 2_seconds ) ); add_msg( _( "You slide right between the bars." ) ); you.setpos( examp ); } @@ -1728,7 +1728,7 @@ void iexamine::safe( Character &you, const tripoint &examp ) has_cracking_tool = has_cracking_tool || you.cache_has_item_with( flag_SAFECRACK ); if( !has_cracking_tool ) { - you.moves -= to_moves( 10_seconds ); + you.mod_moves( -to_moves( 10_seconds ) ); // Assume a 3 digit 100-number code. Many safes allow adjacent + 1 dial locations to match, // so 1/20^3, or 1/8,000 odds. // Additionally, safes can be left-handed or right-handed, doubling the problem space. @@ -2046,7 +2046,7 @@ void iexamine::fswitch( Character &you, const tripoint &examp ) return; } ter_id terid = here.ter( examp ); - you.moves -= to_moves( 1_seconds ); + you.mod_moves( -to_moves( 1_seconds ) ); tripoint tmp; tmp.z = examp.z; for( tmp.y = examp.y; tmp.y <= examp.y + 5; tmp.y++ ) { @@ -2221,7 +2221,7 @@ void iexamine::flower_poppy( Character &you, const tripoint &examp ) add_msg( m_bad, _( "Your legs are covered in the poppy's roots!" ) ); you.apply_damage( nullptr, bodypart_id( "leg_l" ), 4 ); you.apply_damage( nullptr, bodypart_id( "leg_r" ), 4 ); - you.moves -= 50; + you.mod_moves( -to_moves( 1_seconds ) * 0.5 ); } here.furn_set( examp, f_null ); @@ -2390,7 +2390,8 @@ void iexamine::flower_marloss( Character &you, const tripoint &examp ) here.furnname( examp ) ) ) { return; } - you.moves -= to_moves( 30_seconds ); // Takes 30 seconds + you.mod_moves( -to_moves + ( 30_seconds ) ); // Takes 30 seconds, more or less if faster/slower than 100 speed add_msg( m_bad, _( "This flower tastes very wrong…" ) ); // If you can drink flowers, you're post-thresh and the Mycus does not want you. you.add_effect( effect_teleglow, 10_minutes ); @@ -2413,7 +2414,7 @@ void iexamine::fungus( Character &you, const tripoint &examp ) add_msg( _( "The %s crumbles into spores!" ), here.furnname( examp ) ); fungal_effects().create_spores( examp, &you ); here.furn_set( examp, f_null ); - you.moves -= 50; + you.mod_moves( -to_moves( 1_seconds ) * 0.5 ); } /** @@ -3562,7 +3563,7 @@ void iexamine::fvat_empty( Character &you, const tripoint &examp ) here.i_clear( examp ); //This is needed to bypass NOITEM here.add_item( examp, brew ); - you.moves -= to_moves( 20_seconds ); + you.mod_moves( -to_moves( 20_seconds ) ); if( !vat_full ) { ferment = query_yn( _( "Start fermenting cycle?" ) ); } @@ -3642,7 +3643,7 @@ void iexamine::fvat_full( Character &you, const tripoint &examp ) } } - you.moves -= to_moves( 5_seconds ); + you.mod_moves( -to_moves( 5_seconds ) ); you.practice( skill_cooking, std::min( to_minutes( brew_time ) / 10, 100 ) ); } @@ -3784,7 +3785,7 @@ void iexamine::keg( Character &you, const tripoint &examp ) add_msg( _( "You fill the %1$s with %2$s." ), keg_name, item::nname( drink_type ) ); } - you.moves -= to_moves( 10_seconds ); + you.mod_moves( -to_moves( 10_seconds ) ); here.i_clear( examp ); here.add_item( examp, drink ); return; @@ -3849,7 +3850,7 @@ void iexamine::keg( Character &you, const tripoint &examp ) pour_into_keg( examp, tmp ); you.use_charges( drink.typeId(), charges_held - tmp.charges ); add_msg( _( "You fill the %1$s with %2$s." ), keg_name, drink_nname ); - you.moves -= to_moves( 10_seconds ); + you.mod_moves( -to_moves( 10_seconds ) ); return; } @@ -3947,7 +3948,7 @@ void iexamine::tree_hickory( Character &you, const tripoint &examp ) calendar::turn ); here.ter_set( examp, t_tree_hickory_dead ); /** @EFFECT_SURVIVAL speeds up hickory root digging */ - you.moves -= to_moves( 20_seconds ) / ( you.get_skill_level( skill_survival ) + 1 ) + 100; + you.mod_moves( -to_moves( 20_seconds ) / ( you.get_skill_level( skill_survival ) + 1 ) + 100 ); } if( !auto_forage && !digging_up && you.is_avatar() ) { @@ -4521,7 +4522,7 @@ void iexamine::curtains( Character &you, const tripoint &examp ) here.spawn_item( you.pos(), itype_sheet, 2, 0, calendar::turn ); here.spawn_item( you.pos(), itype_stick, 1, 0, calendar::turn ); here.spawn_item( you.pos(), itype_string_36, 1, 0, calendar::turn ); - you.moves -= to_moves( 10_seconds ); + you.mod_moves( -to_moves( 10_seconds ) ); you.add_msg_if_player( _( "You tear the curtains and curtain rod off the windowframe." ) ); } else { you.add_msg_if_player( _( "Never mind." ) ); @@ -4945,7 +4946,7 @@ void iexamine::pay_gas( Character &you, const tripoint &examp ) you.use_charges( itype_cash_card, cost ); add_msg( m_info, _( "Your cash cards now hold %s." ), format_money( money ) ); - you.moves -= to_moves( 5_seconds ); + you.mod_moves( -to_moves( 5_seconds ) ); return; } @@ -4989,7 +4990,7 @@ void iexamine::pay_gas( Character &you, const tripoint &examp ) } add_msg( m_info, _( "Your cash cards now hold %s." ), format_money( you.charges_of( itype_cash_card ) ) ); - you.moves -= to_moves( 5_seconds ); + you.mod_moves( -to_moves( 5_seconds ) ); return; } } @@ -5061,7 +5062,7 @@ void iexamine::ledge( Character &you, const tripoint &examp ) case ledge_jump_across: { // If player is grabbed, trapped, or somehow otherwise movement-impeded, first try to break free if( !you.move_effects( false ) ) { - you.moves -= 100; + you.mod_moves( -to_moves( 1_seconds ) ); return; } @@ -5116,7 +5117,7 @@ void iexamine::ledge( Character &you, const tripoint &examp ) /*case ledge_cling_down: { // If player is grabbed, trapped, or somehow otherwise movement-impeded, first try to break free if( !you.move_effects( false ) ) { - you.moves -= 100; + you.mod_moves( -to_moves( 1_seconds ) ); return; } @@ -5137,7 +5138,7 @@ void iexamine::ledge( Character &you, const tripoint &examp ) case ledge_glide: { // If player is grabbed, trapped, or somehow otherwise movement-impeded, first try to break free if( !you.move_effects( false ) ) { - you.moves -= 100; + you.mod_moves( -to_moves( 1_seconds ) ); return; } // The carried weight check here is redundant, but we do it anyway for better player feedback @@ -5176,7 +5177,7 @@ void iexamine::ledge( Character &you, const tripoint &examp ) } case ledge_fall_down: { if( query_yn( _( "Climbing might be safer. Really fall from the ledge?" ) ) ) { - you.moves -= 100; + you.mod_moves( -to_moves( 1_seconds ) ); // If player is grabbed, trapped, or somehow otherwise movement-impeded, first try to break free if( !you.move_effects( false ) ) { return; @@ -5562,7 +5563,7 @@ void iexamine::autodoc( Character &you, const tripoint &examp ) continue; } broken_limbs_count++; - patient.moves -= 500; + patient.mod_moves( -to_moves( 5_seconds ) ); // TODO: fail here if unable to perform the action, i.e. can't wear more, trait mismatch. int quantity = 1; if( part == bodypart_id( "arm_l" ) || part == bodypart_id( "arm_r" ) ) { @@ -5661,12 +5662,12 @@ void iexamine::autodoc( Character &you, const tripoint &examp ) patient.get_part_hp_max( bp_healed ) - patient.get_part_hp_cur( bp_healed ) ); } } - patient.moves -= 500; + patient.mod_moves( -to_moves( 5_seconds ) ); break; } case RAD_AWAY: { - patient.moves -= 500; + patient.mod_moves( -to_moves( 5_seconds ) ); patient.add_msg_player_or_npc( m_info, _( "The Autodoc scanned you and detected a radiation level of %d mSv." ), _( "The Autodoc scanned and detected a radiation level of %d mSv." ), @@ -5691,7 +5692,7 @@ void iexamine::autodoc( Character &you, const tripoint &examp ) } case BLOOD_ANALYSIS: { - patient.moves -= 500; + patient.mod_moves( -to_moves( 5_seconds ) ); patient.conduct_blood_analysis(); patient.add_msg_player_or_npc( m_info, _( "The Autodoc analyzed your blood." ), diff --git a/src/item.cpp b/src/item.cpp index 245b555e585d6..775a996ec4031 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -6535,7 +6535,7 @@ int item::on_wield_cost( const Character &you ) const void item::on_wield( Character &you ) { int wield_cost = on_wield_cost( you ); - you.moves -= wield_cost; + you.mod_moves( -wield_cost ); std::string msg; @@ -13109,7 +13109,7 @@ bool item::process_litcig( map &here, Character *carrier, const tripoint &pos ) } else { carrier->add_effect( effect_weed_high, duration / 2 ); } - carrier->moves -= 15; + carrier->mod_moves( -to_moves( 1_seconds ) * 0.15 ); if( ( carrier->has_effect( effect_shakes ) && one_in( 10 ) ) || ( carrier->has_trait( trait_JITTERY ) && one_in( 200 ) ) ) { diff --git a/src/item_location.cpp b/src/item_location.cpp index dbf208fca31cc..f00179dc43798 100644 --- a/src/item_location.cpp +++ b/src/item_location.cpp @@ -236,7 +236,7 @@ class item_location::impl::item_on_map : public item_location::impl } item_location obtain( Character &ch, int qty ) override { - ch.moves -= obtain_cost( ch, qty ); + ch.mod_moves( -obtain_cost( ch, qty ) ); on_contents_changed(); item obj = target()->split( qty ); @@ -507,7 +507,7 @@ class item_location::impl::item_on_vehicle : public item_location::impl } item_location obtain( Character &ch, int qty ) override { - ch.moves -= obtain_cost( ch, qty ); + ch.mod_moves( -obtain_cost( ch, qty ) ); on_contents_changed(); item obj = target()->split( qty ); diff --git a/src/iuse.cpp b/src/iuse.cpp index 970e7ee7aa7ec..8af26d23452a0 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -651,7 +651,7 @@ std::optional iuse::eyedrops( Character *p, item *it, const tripoint & ) return std::nullopt; } p->add_msg_if_player( _( "You use your %s." ), it->tname() ); - p->moves -= to_moves( 10_seconds ); + p->mod_moves( -to_moves( 10_seconds ) ); if( p->has_effect( effect_boomered ) ) { p->remove_effect( effect_boomered ); p->add_msg_if_player( m_good, _( "You wash the slime from your eyes." ) ); @@ -821,7 +821,7 @@ std::optional iuse::weed_cake( Character *p, item *, const tripoint & ) p->set_painkiller( ( p->get_painkiller() + 3 ) * 2 ); } p->add_effect( effect_weed_high, duration ); - p->moves -= 100; + p->mod_moves( -to_moves( 1_seconds ) ); if( one_in( 5 ) ) { weed_msg( *p ); } @@ -1029,7 +1029,7 @@ std::optional iuse::inhaler( Character *p, item *, const tripoint & ) std::optional iuse::oxygen_bottle( Character *p, item *it, const tripoint & ) { - p->moves -= to_moves( 10_seconds ); + p->mod_moves( -to_moves( 10_seconds ) ); p->add_msg_player_or_npc( m_neutral, string_format( _( "You breathe deeply from the %s." ), it->tname() ), string_format( _( " breathes from the %s." ), @@ -1925,7 +1925,7 @@ std::optional iuse::extinguisher( Character *p, item *it, const tripoint & } tripoint dest = *dest_; - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); map &here = get_map(); // Reduce the strength of fire (if any) in the target tile. @@ -1934,7 +1934,7 @@ std::optional iuse::extinguisher( Character *p, item *it, const tripoint & // Also spray monsters in that tile. if( monster *const mon_ptr = get_creature_tracker().creature_at( dest, true ) ) { monster &critter = *mon_ptr; - critter.moves -= to_moves( 2_seconds ); + critter.mod_moves( -to_moves( 2_seconds ) ); bool blind = false; if( one_in( 2 ) && critter.has_flag( mon_flag_SEES ) ) { blind = true; @@ -2302,7 +2302,7 @@ std::optional iuse::mace( Character *p, item *it, const tripoint & ) } tripoint dest = *dest_; - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); map &here = get_map(); here.add_field( dest, fd_tear_gas, 2, 3_turns ); @@ -2310,7 +2310,7 @@ std::optional iuse::mace( Character *p, item *it, const tripoint & ) // Also spray monsters in that tile. if( monster *const mon_ptr = get_creature_tracker().creature_at( dest, true ) ) { monster &critter = *mon_ptr; - critter.moves -= to_moves( 2_seconds ); + critter.mod_moves( -to_moves( 2_seconds ) ); bool blind = false; if( one_in( 2 ) && critter.has_flag( mon_flag_SEES ) ) { blind = true; @@ -2318,7 +2318,7 @@ std::optional iuse::mace( Character *p, item *it, const tripoint & ) } // even if it's not blinded getting maced hurts a lot and stuns it if( !critter.has_flag( mon_flag_NO_BREATHE ) ) { - critter.moves -= to_moves( 3_seconds ); + critter.mod_moves( -to_moves( 3_seconds ) ); p->add_msg_if_player( _( "The %s recoils in pain!" ), critter.name() ); } viewer &player_view = get_player_view(); @@ -2342,7 +2342,7 @@ std::optional iuse::manage_exosuit( Character *p, item *it, const tripoint add_msg( m_warning, _( "Your %s does not have any pockets to contain modules." ), it->tname() ); return std::nullopt; } - p->moves -= exosuit_interact::run( it ); + p->mod_moves( -exosuit_interact::run( it ) ); return 0; } @@ -2396,7 +2396,7 @@ std::optional iuse::unpack_item( Character *p, item *it, const tripoint & ) return std::nullopt; } std::string oname = it->typeId().str() + "_on"; - p->moves -= to_moves( 10_seconds ); + p->mod_moves( -to_moves( 10_seconds ) ); p->add_msg_if_player( _( "You unpack your %s for use." ), it->tname() ); it->convert( itype_id( oname ), p ).active = false; // Check if unpacking led to invalid container state @@ -2457,7 +2457,7 @@ std::optional iuse::pack_item( Character *p, item *it, const tripoint & ) debugmsg( "no item type to turn it into (%s)!", oname ); return std::nullopt; } - p->moves -= to_moves( 10_seconds ); + p->mod_moves( -to_moves( 10_seconds ) ); p->add_msg_if_player( _( "You pack your %s for storage." ), it->tname() ); it->convert( itype_id( oname ), p ).active = false; } @@ -2492,7 +2492,7 @@ std::optional iuse::water_purifier( Character *p, item *it, const tripoint return std::nullopt; } - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); for( item *water : liquids ) { water->convert( itype_water_clean, p ).poison = 0; @@ -3258,7 +3258,7 @@ std::optional iuse::teleport( Character *p, item *it, const tripoint & ) if( !it->ammo_sufficient( p ) ) { return std::nullopt; } - p->moves -= to_moves( 1_seconds ); + p->mod_moves( -to_moves( 1_seconds ) ); teleport::teleport( *p ); return 1; } @@ -3646,7 +3646,7 @@ std::optional iuse::tazer( Character *p, item *it, const tripoint &pos ) } const float hit_roll = p->hit_roll(); - p->moves -= to_moves( 1_seconds ); + p->mod_moves( -to_moves( 1_seconds ) ); const bool tazer_was_dodged = target->dodge_check( p->hit_roll() ); const bool tazer_was_armored = hit_roll < target->get_armor_type( STATIC( @@ -3662,15 +3662,15 @@ std::optional iuse::tazer( Character *p, item *it, const tripoint &pos ) } else { // Stun duration scales harshly inversely with big creatures if( target->get_size() == creature_size::tiny ) { - target->moves -= rng( 150, 250 ); + target->mod_moves( -to_moves( 1_seconds ) * rng_float( 1.5, 2.5 ) ); } else if( target->get_size() == creature_size::small ) { - target->moves -= rng( 125, 200 ); + target->mod_moves( -to_moves( 1_seconds ) * rng_float( 1.25, 2.0 ) ); } else if( target->get_size() == creature_size::large ) { - target->moves -= rng( 95, 115 ); + target->mod_moves( -to_moves( 1_seconds ) * rng_float( 0.95, 1.15 ) ); } else if( target->get_size() == creature_size::huge ) { - target->moves -= rng( 50, 80 ); + target->mod_moves( -to_moves( 1_seconds ) * rng_float( 0.5, 0.8 ) ); } else { - target->moves -= rng( 110, 150 ); + target->mod_moves( -to_moves( 1_seconds ) * rng_float( 1.1, 1.5 ) ); } p->add_msg_player_or_npc( m_good, _( "You shock %s!" ), @@ -4344,7 +4344,7 @@ std::optional iuse::vortex( Character *p, item *it, const tripoint & ) continue; } p->add_msg_if_player( m_warning, _( "Air swirls all over…" ) ); - p->moves -= to_moves( 1_seconds ); + p->mod_moves( -to_moves( 1_seconds ) ); it->convert( itype_spiral_stone, p ); mon->friendly = -1; return 1; @@ -4833,13 +4833,13 @@ std::optional iuse::mop( Character *p, item *, const tripoint & ) } if( p->is_blind() ) { p->add_msg_if_player( m_info, _( "You move the mop around, unsure whether it's doing any good." ) ); - p->moves -= 15; + p->mod_moves( -to_moves( 1_seconds ) * 0.15 ); if( one_in( 3 ) ) { here.mop_spills( pnt ); } } else if( here.mop_spills( pnt ) ) { p->add_msg_if_player( m_info, _( "You mop up the spill." ) ); - p->moves -= 15; + p->mod_moves( -to_moves( 1_seconds ) * 0.15 ); } else { return std::nullopt; } @@ -4892,7 +4892,7 @@ std::optional iuse::handle_ground_graffiti( Character &p, item *it, const s } move_cost = 2 * message.length(); } - p.moves -= move_cost; + p.mod_moves( -move_cost ); if( it != nullptr ) { return 1; } else { @@ -5049,7 +5049,7 @@ int iuse::towel_common( Character *p, item *it, bool ) if( mult == 0 ) { mult = 1; } - p->moves -= 50 * mult; + p->mod_moves( -to_moves( 1_seconds ) * 0.5 * mult ); if( it ) { // WET, active items have their timer decremented every turn it->set_flag( flag_WET ); @@ -5072,7 +5072,7 @@ std::optional iuse::adrenaline_injector( Character *p, item *it, const trip return std::nullopt; } - p->moves -= to_moves( 1_seconds ); + p->mod_moves( -to_moves( 1_seconds ) ); p->add_msg_player_or_npc( _( "You inject yourself with adrenaline." ), _( " injects themselves with adrenaline." ) ); @@ -5220,7 +5220,7 @@ std::optional gun_repair( Character *p, item *, item_location &loc ) const std::string startdurability = fix.durability_indicator( true ); sounds::sound( p->pos(), 8, sounds::sound_t::activity, "crunch", true, "tool", "repair_kit" ); p->practice( skill_mechanics, 10 ); - p->moves -= to_moves( 20_seconds ); + p->mod_moves( -to_moves( 20_seconds ) ); fix.mod_damage( -itype::damage_scale ); @@ -5448,7 +5448,7 @@ std::optional iuse::robotcontrol( Character *p, item *it, const tripoint & return 1; } case 1: { //make all friendly robots stop their purposeless extermination of (un)life. - p->moves -= to_moves( 1_seconds ); + p->mod_moves( -to_moves( 1_seconds ) ); int f = 0; //flag to check if you have robotic allies for( monster &critter : g->all_monsters() ) { if( critter.friendly != 0 && critter.type->in_species( species_ROBOT ) ) { @@ -5465,7 +5465,7 @@ std::optional iuse::robotcontrol( Character *p, item *it, const tripoint & return 1; } case 2: { //make all friendly robots terminate (un)life with extreme prejudice - p->moves -= to_moves( 1_seconds ); + p->mod_moves( -to_moves( 1_seconds ) ); int f = 0; //flag to check if you have robotic allies for( monster &critter : g->all_monsters() ) { if( critter.friendly != 0 && critter.has_flag( mon_flag_ELECTRONIC ) ) { @@ -5616,7 +5616,7 @@ std::optional iuse::einktabletpc( Character *p, item *it, const tripoint & it->set_var( "EIPC_PHOTOS", count ); } - p->moves -= to_moves( rng( 3_seconds, 7_seconds ) ); + p->mod_moves( -to_moves( rng( 3_seconds, 7_seconds ) ) ); if( p->has_trait( trait_PSYCHOPATH ) ) { p->add_msg_if_player( m_info, _( "Wasted time. These pictures do not provoke your senses." ) ); @@ -5631,7 +5631,7 @@ std::optional iuse::einktabletpc( Character *p, item *it, const tripoint & if( ei_music == choice ) { - p->moves -= 30; + p->mod_moves( -to_moves( 1_seconds ) * 0.3 ); // Turn on the screen before playing musics if( !it->active ) { if( it->is_transformable() ) { @@ -5660,7 +5660,7 @@ std::optional iuse::einktabletpc( Character *p, item *it, const tripoint & } if( ei_recipe == choice ) { - p->moves -= 50; + p->mod_moves( -to_moves( 1_seconds ) * 0.5 ); uilist rmenu; for( const recipe_id &rid : it->get_saved_recipes() ) { @@ -6609,7 +6609,7 @@ std::optional iuse::camera( Character *p, item *it, const tripoint & ) std::vector trajectory = line_to( p->pos(), aim_point, 0, 0 ); trajectory.push_back( aim_point ); - p->moves -= 50; + p->mod_moves( -to_moves( 1_seconds ) * 0.5 ); sounds::sound( p->pos(), 8, sounds::sound_t::activity, _( "Click." ), true, "tool", "camera_shutter" ); @@ -6803,7 +6803,7 @@ std::optional iuse::camera( Character *p, item *it, const tripoint & ) return std::nullopt; } - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); avatar *you = p->as_avatar(); item_location loc; @@ -6947,7 +6947,7 @@ std::optional iuse::afs_translocator( Character *p, item *it, const tripoin tripoint dest = *dest_; - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); map &here = get_map(); if( here.impassable( dest ) || here.has_flag( ter_furn_flag::TFLAG_NO_FLOOR, dest ) || @@ -7039,7 +7039,7 @@ std::optional iuse::radiocar( Character *p, item *it, const tripoint & ) if( put.has_flag( flag_RADIOCARITEM ) && ( put.volume() <= 1250_ml || ( put.weight() <= 2_kilogram ) ) ) { - p->moves -= to_moves( 3_seconds ); + p->mod_moves( -to_moves( 3_seconds ) ); p->add_msg_if_player( _( "You armed your RC car with %s." ), put.tname() ); it->put_in( p->i_rem( &put ), pocket_type::CONTAINER ); @@ -7051,7 +7051,7 @@ std::optional iuse::radiocar( Character *p, item *it, const tripoint & ) put.tname() ); } } else { // Disarm the car - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); p->inv->assign_empty_invlet( *bomb_it, *p, true ); // force getting an invlet. p->i_add( *bomb_it ); @@ -7227,7 +7227,7 @@ std::optional iuse::radiocontrol( Character *p, item *it, const tripoint & p->add_msg_if_player( _( "Click." ) ); sendRadioSignal( *p, signal ); - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); } return 1; @@ -7263,7 +7263,7 @@ static bool hackveh( Character &p, item &it, vehicle &veh ) if( effort == 0 && !query_yn( _( "Try to hack this car's security system?" ) ) ) { // Scanning for security systems isn't free - p.moves -= to_moves( 1_seconds ); + p.mod_moves( -to_moves( 1_seconds ) ); it.charges -= 1; return false; } @@ -7282,7 +7282,7 @@ static bool hackveh( Character &p, item &it, vehicle &veh ) success = true; } - p.moves -= to_moves( time_duration::from_seconds( effort ) ); + p.mod_moves( -to_moves( time_duration::from_seconds( effort ) ) ); it.charges -= effort; if( success && advanced ) { // Unlock controls, but only if they're drive-by-wire veh.is_locked = false; @@ -7419,7 +7419,7 @@ std::optional iuse::remoteveh( Character *p, item *it, const tripoint &pos static bool multicooker_hallu( Character &p ) { - p.moves -= to_moves( 2_seconds ); + p.mod_moves( -to_moves( 2_seconds ) ); const int random_hallu = rng( 1, 7 ); switch( random_hallu ) { @@ -7716,7 +7716,7 @@ std::optional iuse::multicooker( Character *p, item *it, const tripoint &po p->practice( skill_electronics, rng( 5, 10 ) ); p->practice( skill_fabrication, rng( 5, 10 ) ); - p->moves -= to_moves( 7_seconds ); + p->mod_moves( -to_moves( 7_seconds ) ); /** @EFFECT_INT increases chance to successfully upgrade multi-cooker */ @@ -8115,7 +8115,7 @@ std::optional iuse::capture_monster_act( Character *p, item *it, const trip p->add_msg_if_player( m_bad, _( "The %1$s avoids your attempts to put it in the %2$s." ), f.type->nname(), it->type->nname( 1 ) ); } - p->moves -= to_moves( 1_seconds ); + p->mod_moves( -to_moves( 1_seconds ) ); } else { add_msg( _( "The %s can't capture nothing" ), it->tname() ); return std::nullopt; @@ -8293,7 +8293,7 @@ std::optional iuse::wash_items( Character *p, bool soft_items, bool hard_it std::optional iuse::break_stick( Character *p, item *it, const tripoint & ) { - p->moves -= to_moves( 2_seconds ); + p->mod_moves( -to_moves( 2_seconds ) ); p->mod_stamina( static_cast( 0.05f * p->get_stamina_max() ) ); if( p->get_str() < 5 ) { diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index e79ee3d7d6737..6fb98924b9ae3 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -253,7 +253,8 @@ std::optional iuse_transform::use( Character *p, item &it, const tripoint & p->add_msg_if_player( m_neutral, msg_transform, it.tname() ); } - p->moves -= moves; + // Uses the moves specified by iuse_actor's definition + p->mod_moves( -moves ); if( need_fire && p->has_trait( trait_PYROMANIA ) ) { if( one_in( 2 ) ) { @@ -818,7 +819,8 @@ std::optional consume_drug_iuse::use( Character *p, item &it, const tripoin p->i_add_or_drop( used_up ); } - p->moves -= moves; + // Uses the moves specified by iuse_actor's definition + p->mod_moves( -moves ); return 1; } @@ -904,7 +906,8 @@ std::optional place_monster_iuse::use( Character *p, item &it, const tripoi return std::nullopt; } } - p->moves -= moves; + // Uses the moves specified by iuse_actor's definition + p->mod_moves( -moves ); newmon.ammo = newmon.type->starting_ammo; if( !newmon.has_flag( mon_flag_INTERIOR_AMMO ) ) { @@ -1103,7 +1106,7 @@ static ret_val check_deploy_square( Character *p, item &it, const trip here.mop_spills( tripoint_bub_ms( pnt ) ); p->add_msg_if_player( m_info, _( "You mopped up the spill with a nearby mop when deploying a %s." ), it.tname() ); - p->moves -= 15; + p->mod_moves( -to_moves( 15_seconds ) ); } else { return ret_val::make_failure( pos, _( "You need a mop to clean up liquids before deploying the %s." ), it.tname() ); @@ -1728,7 +1731,7 @@ void salvage_actor::cut_up( Character &p, item_location &cut ) const int amount = salvaged_mat.second; if( amount > 0 ) { // Time based on number of components. - p.moves -= moves_per_part; + p.mod_moves( -moves_per_part ); if( result.count_by_charges() ) { result.charges = amount; amount = 1; @@ -1925,7 +1928,8 @@ std::optional fireweapon_off_actor::use( Character *p, item &it, return std::nullopt; } - p->moves -= moves; + // Uses the moves specified by iuse_actor's definition + p->mod_moves( -moves ); if( rng( 0, 10 ) - it.damage_level() > success_chance && !p->is_underwater() ) { if( noise > 0 ) { sounds::sound( p->pos(), noise, sounds::sound_t::combat, success_message ); @@ -2021,7 +2025,8 @@ std::unique_ptr manualnoise_actor::clone() const std::optional manualnoise_actor::use( Character *p, item &, const tripoint & ) const { - p->moves -= moves; + // Uses the moves specified by iuse_actor's definition + p->mod_moves( -moves ); if( noise > 0 ) { sounds::sound( p->pos(), noise, sounds::sound_t::activity, noise_message.empty() ? _( "Hsss" ) : noise_message.translated(), true, noise_id, noise_variant ); @@ -3312,7 +3317,7 @@ std::optional heal_actor::use( Character *p, item &it, const tripoint &pos // NPC: Will only use its inventory for first aid items. p->activity.targets.emplace_back( *p, &it ); p->activity.str_values.emplace_back( hpp.c_str() ); - p->moves = 0; + p->set_moves( 0 ); return 0; } @@ -4710,7 +4715,7 @@ std::optional link_up_actor::use( Character *p, item &it, const tripoint &p it.update_link_traits(); it.process( here, p, p->pos() ); - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 0; } else if( choice == 21 ) { @@ -4746,7 +4751,7 @@ std::optional link_up_actor::use( Character *p, item &it, const tripoint &p loc->set_var( "cable", "plugged_in" ); it.update_link_traits(); it.process( here, p, p->pos() ); - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 0; } else if( choice == 22 ) { @@ -4782,7 +4787,7 @@ std::optional link_up_actor::use( Character *p, item &it, const tripoint &p loc->set_var( "cable", "plugged_in" ); it.update_link_traits(); it.process( here, p, p->pos() ); - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 0; } return std::nullopt; @@ -4851,7 +4856,7 @@ std::optional link_up_actor::link_to_veh_app( Character *p, item &it, } it.process( here, p, p->pos() ); - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 0; } else { @@ -4871,7 +4876,7 @@ std::optional link_up_actor::link_to_veh_app( Character *p, item &it, // Remove linked_flag from attached parts - the just-added cable vehicle parts do the same thing. it.reset_link( true, p ); } - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 1; // Let the cable be destroyed. } } @@ -4920,7 +4925,7 @@ std::optional link_up_actor::link_tow_cable( Character *p, item &it, sel_vp->vehicle().name ); it.process( here, p, p->pos() ); - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 0; } else { @@ -4935,7 +4940,7 @@ std::optional link_up_actor::link_tow_cable( Character *p, item &it, p->add_msg_if_player( m_good, result.str() ); } - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 1; // Let the cable be destroyed. } } @@ -5042,7 +5047,7 @@ std::optional link_up_actor::link_extend_cable( Character *p, item &it, extension.remove_item(); p->invalidate_inventory_validity_cache(); p->drop_invalid_inventory(); - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 0; } @@ -5089,7 +5094,7 @@ std::optional link_up_actor::remove_extensions( Character *p, item &it ) co } p->i_add_or_drop( cable_main_copy ); - p->moves -= move_cost; + p->mod_moves( -move_cost ); return 0; } @@ -5402,7 +5407,7 @@ std::optional sew_advanced_actor::use( Character *p, item &it, const tripoi std::vector comps; comps.emplace_back( repair_item, items_needed ); - p->moves -= to_moves( 30_seconds * p->fine_detail_vision_mod() ); + p->mod_moves( -to_moves( 30_seconds * p->fine_detail_vision_mod() ) ); p->practice( used_skill, items_needed * 3 + 3 ); /** @EFFECT_TAILOR randomly improves clothing modification efforts */ int rn = dice( 3, 2 + round( p->get_skill_level( used_skill ) ) ); // Skill diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index f6b1a179a92e3..78f39a104eb72 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -1365,7 +1365,7 @@ void spell_effect::mod_moves( const spell &sp, Creature &caster, const tripoint continue; } sp.make_sound( potential_target, caster ); - critter->moves += sp.damage( caster ); + critter->mod_moves( sp.damage( caster ) ); } } @@ -1676,7 +1676,7 @@ void spell_effect::dash( const spell &sp, Creature &caster, const tripoint &targ ++walk_point; } // save the amount of moves the caster has so we can restore them after the dash - const int cur_moves = caster.moves; + const int cur_moves = caster.get_moves(); creature_tracker &creatures = get_creature_tracker(); while( walk_point != trajectory.end() ) { if( caster_you != nullptr ) { @@ -1697,7 +1697,7 @@ void spell_effect::dash( const spell &sp, Creature &caster, const tripoint &targ // we want the last tripoint in the actually reached trajectory --walk_point; } - caster.moves = cur_moves; + caster.set_moves( cur_moves ); tripoint far_target; calc_ray_end( coord_to_angle( source, target ), sp.aoe( caster ), here.getlocal( *walk_point ), diff --git a/src/map_field.cpp b/src/map_field.cpp index c7e73b197a44e..29efc38bb945b 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1502,7 +1502,7 @@ void map::player_in_field( Character &you ) // Sludge is on the ground, but you are above the ground when boarded on a vehicle if( !you.has_trait( trait_GASTROPOD_FOOT ) && ( !you.in_vehicle ) ) { you.add_msg_if_player( m_bad, _( "The sludge is thick and sticky. You struggle to pull free." ) ); - you.moves -= cur.get_field_intensity() * 300; + you.mod_moves( -cur.get_field_intensity() * 300 ); cur.set_field_intensity( 0 ); } } @@ -1835,13 +1835,13 @@ void map::monster_in_field( monster &z ) } if( cur_field_type == fd_sap ) { - z.moves -= cur.get_field_intensity() * 5; + z.mod_moves( -cur.get_field_intensity() * 5 ); mod_field_intensity( z.pos(), cur.get_field_type(), -1 ); } if( cur_field_type == fd_sludge ) { if( !z.digs() && !z.flies() && !z.has_flag( mon_flag_SLUDGEPROOF ) ) { - z.moves -= cur.get_field_intensity() * 300; + z.mod_moves( -cur.get_field_intensity() * 300 ); cur.set_field_intensity( 0 ); } } @@ -1873,7 +1873,7 @@ void map::monster_in_field( monster &z ) } else if( cur.get_field_intensity() == 2 ) { dam += rng( 6, 12 ); if( !z.flies() ) { - z.moves -= 20; + z.mod_moves( -to_moves( 1_seconds ) * 0.2 ); if( dam > 0 ) { z.add_effect( effect_onfire, 1_turns * rng( dam / 2, dam * 2 ) ); } @@ -1881,7 +1881,7 @@ void map::monster_in_field( monster &z ) } else if( cur.get_field_intensity() == 3 ) { dam += rng( 10, 20 ); if( !z.flies() || one_in( 3 ) ) { - z.moves -= 40; + z.mod_moves( -to_moves( 1_seconds ) * 0.4 ); if( dam > 0 ) { z.add_effect( effect_onfire, 1_turns * rng( dam / 2, dam * 2 ) ); } @@ -1891,11 +1891,11 @@ void map::monster_in_field( monster &z ) if( cur_field_type == fd_smoke ) { if( !z.has_flag( mon_flag_NO_BREATHE ) ) { if( cur.get_field_intensity() == 3 ) { - z.moves -= rng( 10, 20 ); + z.mod_moves( -to_moves( 1_seconds ) * rng_float( 0.1, 0.2 ) ); } // Plants suffer from smoke even worse if( z.made_of( material_veggy ) ) { - z.moves -= rng( 1, cur.get_field_intensity() * 12 ); + z.mod_moves( -to_moves( 1_seconds ) * rng_float( 0.01, cur.get_field_intensity() * 0.12 ) ); } } @@ -1931,24 +1931,25 @@ void map::monster_in_field( monster &z ) if( cur_field_type == fd_toxic_gas ) { if( !z.has_flag( mon_flag_NO_BREATHE ) ) { dam += cur.get_field_intensity(); - z.moves -= cur.get_field_intensity(); + z.mod_moves( -cur.get_field_intensity() ); } } if( cur_field_type == fd_nuke_gas ) { if( !z.has_flag( mon_flag_NO_BREATHE ) ) { if( cur.get_field_intensity() == 3 ) { - z.moves -= rng( 60, 120 ); + z.mod_moves( -to_moves( 1_seconds ) * rng_float( 0.6, 1.2 ) ); dam += rng( 30, 50 ); } else if( cur.get_field_intensity() == 2 ) { - z.moves -= rng( 20, 50 ); + z.mod_moves( -to_moves( 1_seconds ) * rng_float( 0.2, 0.5 ) ); dam += rng( 10, 25 ); } else { - z.moves -= rng( 0, 15 ); + z.mod_moves( -to_moves( 1_seconds ) * rng_float( 0.0, 0.15 ) ); dam += rng( 0, 12 ); } if( z.made_of( material_veggy ) ) { - z.moves -= rng( cur.get_field_intensity() * 5, cur.get_field_intensity() * 12 ); + z.mod_moves( -to_moves( 1_seconds ) * rng_float( cur.get_field_intensity() * 0.05, + cur.get_field_intensity() * 0.12 ) ); dam *= cur.get_field_intensity(); } } @@ -1972,7 +1973,7 @@ void map::monster_in_field( monster &z ) dam += -25; } dam += rng( 0, 8 ); - z.moves -= 20; + z.mod_moves( -to_moves( 1_seconds ) * 0.2 ); } if( cur_field_type == fd_electricity ) { // We don't want to increase dam, but deal a separate hit so that it can apply effects @@ -2008,13 +2009,13 @@ void map::monster_in_field( monster &z ) dam += rng( 2, 6 ); } else if( cur.get_field_intensity() == 2 ) { dam += rng( 6, 12 ); - z.moves -= 20; + z.mod_moves( -to_moves( 1_seconds ) * 0.2 ); if( !z.made_of( phase_id::LIQUID ) && !z.made_of_any( Creature::cmat_flameres ) ) { z.add_effect( effect_onfire, rng( 8_turns, 12_turns ) ); } } else if( cur.get_field_intensity() == 3 ) { dam += rng( 10, 20 ); - z.moves -= 40; + z.mod_moves( -to_moves( 1_seconds ) * 0.4 ); if( !z.made_of( phase_id::LIQUID ) && !z.made_of_any( Creature::cmat_flameres ) ) { z.add_effect( effect_onfire, rng( 12_turns, 16_turns ) ); } @@ -2026,21 +2027,21 @@ void map::monster_in_field( monster &z ) !z.make_fungus() ) { // Don't insta-kill jabberwocks, that's silly const int intensity = cur.get_field_intensity(); - z.moves -= rng( 10 * intensity, 30 * intensity ); + z.mod_moves( -rng( 10 * intensity, 30 * intensity ) ); dam += rng( 0, 10 * intensity ); } } if( cur_field_type == fd_fungicidal_gas ) { if( z.type->in_species( species_FUNGUS ) ) { const int intensity = cur.get_field_intensity(); - z.moves -= rng( 10 * intensity, 30 * intensity ); + z.mod_moves( -rng( 10 * intensity, 30 * intensity ) ); dam += rng( 4, 7 * intensity ); } } if( cur_field_type == fd_insecticidal_gas ) { if( z.made_of( material_iflesh ) && !z.has_flag( mon_flag_INSECTICIDEPROOF ) ) { const int intensity = cur.get_field_intensity(); - z.moves -= rng( 10 * intensity, 30 * intensity ); + z.mod_moves( -rng( 10 * intensity, 30 * intensity ) ); dam += rng( 4, 7 * intensity ); } } diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index a22fb605a3cd9..aac41cdfdee6b 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -222,7 +222,7 @@ bool leap_actor::call( monster &z ) const return false; // Nowhere to leap! } - z.moves -= move_cost; + z.mod_moves( -move_cost ); viewer &player_view = get_player_view(); const tripoint chosen = random_entry( options ); bool seen = player_view.sees( z ); // We can see them jump... @@ -306,7 +306,7 @@ bool mon_spellcasting_actor::call( monster &mon ) const spell_instance.name(), target_name ); avatar fake_player; - mon.moves -= spell_instance.casting_time( fake_player, true ); + mon.mod_moves( -spell_instance.casting_time( fake_player, true ) ); spell_instance.cast_all_effects( mon, target ); return true; @@ -497,7 +497,7 @@ int melee_actor::do_grab( monster &z, Creature *target, bodypart_id bp_id ) cons const std::optional vp_seatbelt = veh_part.avail_part_with_feature( "SEATBELT" ); if( vp_seatbelt ) { if( grab_data.respect_seatbelts ) { - z.moves -= move_cost * 2; + z.mod_moves( -move_cost * 2 ); foe->add_msg_player_or_npc( msg_type, _( "%1s tries to drag you, but is stopped by your %2s!" ), _( "%1s tries to drag , but is stopped by their %2s!" ), z.disp_name( false, true ), vp_seatbelt->part().name( false ) ); @@ -1202,7 +1202,7 @@ bool gun_actor::try_target( monster &z, Creature &target ) const _( "You're not sure why you've got a laser dot on you…" ) ); } - z.moves -= targeting_cost; + z.mod_moves( -targeting_cost ); return false; } @@ -1219,7 +1219,7 @@ bool gun_actor::try_target( monster &z, Creature &target ) const void gun_actor::shoot( monster &z, const tripoint &target, const gun_mode_id &mode, int inital_recoil ) const { - z.moves -= move_cost; + z.mod_moves( -move_cost ); itype_id mig_gun_type = item_controller->migrate_id( gun_type ); item gun( mig_gun_type ); diff --git a/src/monattack.cpp b/src/monattack.cpp index 5ec40fa859ef4..ab41b96dcf32e 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -603,7 +603,7 @@ bool mattack::shriek( monster *z ) } // It takes a while - z->moves -= 240; + z->mod_moves( -to_moves( 1_seconds ) * 2.4 ); sounds::sound( z->pos(), 50, sounds::sound_t::alert, _( "a terrible shriek!" ), false, "shout", "shriek" ); return true; @@ -622,7 +622,7 @@ bool mattack::shriek_alert( monster *z ) return false; } add_msg_if_player_sees( *z, _( "The %s begins shrieking!" ), z->name() ); - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); sounds::sound( z->pos(), 120, sounds::sound_t::alert, _( "a piercing wail!" ), false, "shout", "wail" ); z->add_effect( effect_shrieking, 1_minutes ); @@ -688,7 +688,7 @@ bool mattack::howl( monster *z ) } // It takes a while - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); sounds::sound( z->pos(), 35, sounds::sound_t::alert, _( "an ear-piercing howl!" ), false, "shout", "howl" ); @@ -722,7 +722,7 @@ bool mattack::rattle( monster *z ) } // It takes a very short while - z->moves -= 20; + z->mod_moves( -to_moves( 1_seconds ) * 0.2 ); sounds::sound( z->pos(), 10, sounds::sound_t::alarm, _( "a sibilant rattling sound!" ), false, "misc", "rattling" ); @@ -747,7 +747,7 @@ bool mattack::acid( monster *z ) return false; } // It takes a while - z->moves -= 300; + z->mod_moves( -to_moves( 3_seconds ) ); sounds::sound( z->pos(), 4, sounds::sound_t::combat, _( "a spitting noise." ), false, "misc", "spitting" ); @@ -795,7 +795,7 @@ bool mattack::acid_barf( monster *z ) return false; } - z->moves -= 80; + z->mod_moves( -to_moves( 1_seconds ) * 0.8 ); // Make sure it happens before uncanny dodge get_map().add_field( target->pos(), fd_acid, 1 ); @@ -863,7 +863,7 @@ bool mattack::acid_accurate( monster *z ) return false; } - z->moves -= 50; + z->mod_moves( -to_moves( 1_seconds ) * 0.5 ); projectile proj; proj.speed = 10; @@ -909,7 +909,7 @@ bool mattack::shockstorm( monster *z ) } // It takes a while - z->moves -= 50; + z->mod_moves( -to_moves( 1_seconds ) * 0.5 ); if( seen ) { game_message_type msg_type = target->is_avatar() ? m_bad : m_neutral; @@ -993,7 +993,7 @@ bool mattack::pull_metal_weapon( monster *z ) if( !weapon->has_flag( flag_NO_UNWIELD ) && metal_portion ) { const float wp_skill = foe->get_skill_level( skill_melee ); // It takes a while - z->moves -= att_cost_pull; + z->mod_moves( -att_cost_pull ); int success = 100; ///\Grip strength increases resistance to pull_metal_weapon special attack if( foe->str_cur > min_str ) { @@ -1047,7 +1047,7 @@ bool mattack::boomer( monster *z ) map &here = get_map(); std::vector line = here.find_clear_path( z->pos(), target->pos() ); // It takes a while - z->moves -= 250; + z->mod_moves( -to_moves( 1_seconds ) * 2.5 ); Character &player_character = get_player_character(); bool u_see = player_character.sees( *z ); if( u_see ) { @@ -1088,7 +1088,7 @@ bool mattack::boomer_glow( monster *z ) map &here = get_map(); std::vector line = here.find_clear_path( z->pos(), target->pos() ); // It takes a while - z->moves -= 250; + z->mod_moves( -to_moves( 1_seconds ) * 2.5 ); Character &player_character = get_player_character(); bool u_see = player_character.sees( *z ); if( u_see ) { @@ -1177,9 +1177,9 @@ bool mattack::resurrect( monster *z ) if( sees_necromancer ) { add_msg( m_info, _( "The %s throws its arms wide." ), z->name() ); } - while( z->moves >= 0 ) { + while( z->get_moves() >= 0 ) { z->add_effect( effect_raising, 1_minutes ); - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); } return false; } @@ -1196,9 +1196,9 @@ bool mattack::resurrect( monster *z ) if( sees_necromancer && x_in_y( 1, std::sqrt( lowest_raise_score / 30.0 ) ) ) { add_msg( m_info, _( "The %s gesticulates wildly." ), z->name() ); } - while( z->moves >= 0 ) { + while( z->get_moves() >= 0 ) { z->add_effect( effect_raising, 1_minutes ); - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); return false; } } else if( raising_level != 0 ) { @@ -1250,7 +1250,8 @@ bool mattack::resurrect( monster *z ) } z->remove_effect( effect_raising ); // Takes one turn - z->moves -= z->type->speed; + // Note: Moves will already be 0 when raised, this purposefully incurs a move deficit. + z->mod_moves( -z->type->speed ); // Penalize speed by between 10% and 50% based on how damaged the corpse is. float speed_penalty = 0.1 + ( corpse_damage * 0.1 ); z->set_speed_base( z->get_speed_base() - speed_penalty * z->type->speed ); @@ -1302,7 +1303,7 @@ bool mattack::smash( monster *z ) } // Costs lots of moves to give you a little bit of a chance to get away. - z->moves -= 400; + z->mod_moves( -to_moves( 4_seconds ) ); // Can we dodge the attack? Uses player dodge function % chance (melee.cpp) if( target->dodge_check( z ) ) { @@ -1482,14 +1483,14 @@ bool mattack::science( monster *const z ) // I said SCIENCE again! DebugLog( D_WARNING, D_GAME ) << "Bad enum value in science."; break; case att_shock : - z->moves -= att_cost_shock; + z->mod_moves( -att_cost_shock ); // Just reuse the taze - it's a bit different (shocks torso vs all), // but let's go for consistency here taze( z, target ); break; case att_radiation : { - z->moves -= att_cost_rad; + z->mod_moves( -att_cost_rad ); add_msg_if_player_sees( *z, m_bad, _( "The %1$s fires a shimmering beam towards %2$s!" ), z->name(), target->disp_name() ); @@ -1520,7 +1521,7 @@ bool mattack::science( monster *const z ) // I said SCIENCE again! } break; case att_manhack : { - z->moves -= att_cost_manhack; + z->mod_moves( -att_cost_manhack ); z->ammo[itype_bot_manhack]--; add_msg_if_player_sees( *z, m_warning, _( "A manhack flies out of one of the holes on the %s!" ), z->name() ); @@ -1532,7 +1533,7 @@ bool mattack::science( monster *const z ) // I said SCIENCE again! } break; case att_acid_pool : { - z->moves -= att_cost_acid; + z->mod_moves( -att_cost_acid ); add_msg_if_player_sees( *z, m_warning, _( "The %s shudders, and some sort of caustic fluid leaks from a its damaged shell!" ), z->name() ); @@ -1560,7 +1561,7 @@ bool mattack::science( monster *const z ) // I said SCIENCE again! // the special case; see above if( i == m_flavor.size() - 1 ) { - z->moves -= att_cost_flavor; + z->mod_moves( -att_cost_flavor ); } add_msg_if_player_sees( *z, m_warning, _( m_flavor[i] ), z->name() ); } @@ -1693,7 +1694,7 @@ bool mattack::grow_vine( monster *z ) return false; } } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); // Attempt to fill up to 8 surrounding tiles. for( int i = 0; i < rng( 1, 8 ); ++i ) { if( monster *const vine = g->place_critter_around( mon_creeper_vine, z->pos(), 1 ) ) { @@ -1725,7 +1726,7 @@ bool mattack::vine( monster *z ) int vine_neighbors = 0; map &here = get_map(); creature_tracker &creatures = get_creature_tracker(); - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); for( const tripoint &dest : here.points_in_radius( z->pos(), 1 ) ) { Creature *critter = creatures.creature_at( dest ); if( critter != nullptr && z->attitude_to( *critter ) == Creature::Attitude::HOSTILE ) { @@ -1745,7 +1746,7 @@ bool mattack::vine( monster *z ) d.add_damage( damage_bash, 8 ); critter->deal_damage( z, bphit, d ); critter->check_dead_state(); - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); return true; } @@ -1784,7 +1785,7 @@ bool mattack::spit_sap( monster *z ) return false; } - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); projectile proj; proj.speed = 10; @@ -1800,7 +1801,7 @@ bool mattack::triffid_heartbeat( monster *z ) { sounds::sound( z->pos(), 14, sounds::sound_t::movement, _( "thu-THUMP." ), true, "misc", "heartbeat" ); - z->moves -= 300; + z->mod_moves( -to_moves( 3_seconds ) ); if( z->friendly != 0 ) { return true; // TODO: when friendly: open a way to the stairs, don't spawn monsters @@ -1865,7 +1866,7 @@ bool mattack::fungus( monster *z ) { // TODO: Infect NPCs? // It takes a while - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); //~ the sound of a fungus releasing spores sounds::sound( z->pos(), 10, sounds::sound_t::combat, _( "Pouf!" ), false, "misc", "puff" ); @@ -1934,7 +1935,7 @@ bool mattack::fungus_haze( monster *z ) sounds::sound( z->pos(), 10, sounds::sound_t::combat, _( "Pouf!" ), true, "misc", "puff" ); add_msg_if_player_sees( *z, m_info, _( "The %s pulses, and fresh fungal material bursts forth." ), z->name() ); - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); map &here = get_map(); for( const tripoint &dest : here.points_in_radius( z->pos(), 3 ) ) { here.add_field( dest, fd_fungal_haze, rng( 1, 2 ) ); @@ -1981,7 +1982,7 @@ bool mattack::fungus_big_blossom( monster *z ) if( u_see ) { add_msg( m_info, _( "The %s pulses, and fresh fungal material bursts forth!" ), z->name() ); } - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); for( const tripoint &dest : here.points_in_radius( z->pos(), 12 ) ) { here.add_field( dest, fd_fungal_haze, rng( 1, 2 ) ); } @@ -2017,7 +2018,7 @@ bool mattack::fungus_inject( monster *z ) return true; } add_msg( m_warning, _( "The %s jabs at you with a needlelike point!" ), z->name() ); - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); bodypart_id hit = target->get_random_body_part(); damage_instance dam_inst = damage_instance( damage_cut, rng( 5, 11 ) ); @@ -2072,7 +2073,7 @@ bool mattack::fungus_bristle( monster *z ) add_msg( msg_type, _( "The %1$s swipes at %2$s with a barbed tendril!" ), z->name(), target->disp_name() ); - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); bodypart_id hit = target->get_random_body_part(); damage_instance dam_inst = damage_instance( damage_cut, rng( 7, 16 ) ); @@ -2240,7 +2241,7 @@ bool mattack::fungus_fortify( monster *z ) add_msg( m_warning, _( "The %s takes aim, and spears at you with a massive tendril!" ), z->name() ); - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); bodypart_id hit = target->get_random_body_part(); damage_instance dam_inst = damage_instance( damage_stab, rng( 15, 21 ) ); @@ -2284,7 +2285,7 @@ bool mattack::impale( monster *z ) return false; } - z->moves -= 80; + z->mod_moves( -to_moves( 1_seconds ) * 0.8 ); bodypart_id hit = bodypart_id( "torso" ); damage_instance dam_inst = damage_instance( damage_stab, rng( 10, 20 ), rng( 5, 15 ), .5 ); @@ -2315,7 +2316,8 @@ bool mattack::impale( monster *z ) if( rng( 0, 200 + dam ) > 100 ) { target->add_effect( effect_downed, 3_turns ); } - z->moves -= 80; //Takes extra time for the creature to pull out the protrusion + z->mod_moves( -to_moves( 1_seconds ) * + 0.8 ); //Takes extra time for the creature to pull out the protrusion } else { target->add_msg_player_or_npc( _( "The %1$s tries to impale your torso, but fails to penetrate your armor!" ), @@ -2391,12 +2393,12 @@ bool mattack::dermatik( monster *z ) //~ 1$s monster name(dermatik), 2$s bodypart name in accusative. target->add_msg_if_player( _( "The %1$s lands on your %2$s, but can't penetrate your armor." ), z->name(), body_part_name_accusative( targeted ) ); - z->moves -= 150; // Attempted laying takes a while + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); // Attempted laying takes a while return true; } // Success! - z->moves -= 500; // Successful laying takes a long time + z->mod_moves( -to_moves( 5_seconds ) ); // Successful laying takes a long time //~ 1$s monster name(dermatik), 2$s bodypart name in accusative. target->add_msg_if_player( m_bad, _( "The %1$s sinks its ovipositor into your %2$s!" ), z->name(), @@ -2437,7 +2439,7 @@ bool mattack::plant( monster *z ) z->name() ); z->poly( mon_fungaloid_young ); - z->moves -= 1000; // It takes a while + z->mod_moves( -to_moves( 10_seconds ) ); // It takes a while return false; } else { add_msg_if_player_sees( *z, _( "The %s falls to the ground and bursts!" ), z->name() ); @@ -2613,7 +2615,7 @@ bool mattack::formblob( monster *z ) poly_keep_speed( *z, mon_blob ); } - z->moves = 0; + z->set_moves( 0 ); return true; } @@ -2781,7 +2783,7 @@ bool mattack::tentacle( monster *z ) _( "The %s lashes its tentacle at you!" ), _( "The %s lashes its tentacle at !" ), z->name() ); - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); bodypart_id hit = target->get_random_body_part(); damage_instance dam_inst = damage_instance( damage_bash, rng( 10, 20 ) ); @@ -2827,7 +2829,7 @@ bool mattack::gene_sting( monster *z ) return false; } - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); damage_instance dam = damage_instance(); dam.add_damage( damage_stab, 6, 10, 0.6, 1 ); @@ -2848,7 +2850,7 @@ bool mattack::para_sting( monster *z ) return false; } - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); damage_instance dam = damage_instance(); dam.add_damage( damage_stab, 6, 8, 0.8, 1 ); @@ -3188,7 +3190,7 @@ bool mattack::photograph( monster *z ) // TODO: might need to be revisited when it can target npcs. return false; } - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); add_msg( m_warning, _( "The %s takes your picture!" ), z->name() ); // TODO: Make the player known to the faction std::string msg; @@ -3247,7 +3249,7 @@ bool mattack::tazer( monster *z ) void mattack::taze( monster *z, Creature *target ) { // It takes a while - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); if( target == nullptr ) { return; }; @@ -3309,12 +3311,12 @@ void mattack::rifle( monster *z, Creature *target ) if( !z->has_effect( effect_targeted ) ) { sounds::sound( z->pos(), 8, sounds::sound_t::alarm, _( "beep-beep." ), false, "misc", "beep" ); z->add_effect( effect_targeted, 8_turns ); - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); return; } } // It takes a while - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { @@ -3363,7 +3365,7 @@ void mattack::frag( monster *z, Creature *target ) // This is for the bots, not sounds::sound( z->pos(), 10, sounds::sound_t::electronic_speech, _( "Targeting." ), false, "speech", z->type->id.str() ); z->add_effect( effect_targeted, 5_turns ); - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); // Should give some ability to get behind cover, // even though it's patently unrealistic. return; @@ -3375,7 +3377,7 @@ void mattack::frag( monster *z, Creature *target ) // This is for the bots, not // No need to aim tmp.recoil = 0; // It takes a while - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { @@ -3421,7 +3423,7 @@ void mattack::tankgun( monster *z, Creature *target ) "servomotor" ); z->add_effect( effect_targeted, 1_minutes ); target->add_effect( effect_laserlocked, 1_minutes ); - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); // Should give some ability to get behind cover, // even though it's patently unrealistic. return; @@ -3434,7 +3436,7 @@ void mattack::tankgun( monster *z, Creature *target ) // No need to aim tmp.recoil = 0; // It takes a while - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); if( z->ammo[ammo_type] <= 0 ) { if( one_in( 3 ) ) { @@ -3698,7 +3700,7 @@ void mattack::flame( monster *z, Creature *target ) if( target != &player_character ) { // friendly // It takes a while - z->moves -= 500; + z->mod_moves( -to_moves( 5_seconds ) ); if( !here.sees( z->pos(), target->pos(), dist ) ) { // shouldn't happen debugmsg( "mattack::flame invoked on invisible target" ); @@ -3721,7 +3723,7 @@ void mattack::flame( monster *z, Creature *target ) } // It takes a while - z->moves -= 500; + z->mod_moves( -to_moves( 5_seconds ) ); if( !here.sees( z->pos(), target->pos(), dist + 1 ) ) { // shouldn't happen debugmsg( "mattack::flame invoked on invisible target" ); @@ -4024,7 +4026,7 @@ bool mattack::upgrade( monster *z ) } // Takes one turn - z->moves -= z->type->speed; + z->mod_moves( -z->type->speed ); monster *target = random_entry( targets ); @@ -4062,7 +4064,7 @@ bool mattack::upgrade( monster *z ) bool mattack::breathe( monster *z ) { // It takes a while - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); bool able = z->type->id == mon_breather_hub; creature_tracker &creatures = get_creature_tracker(); @@ -4108,7 +4110,7 @@ bool mattack::stretch_bite( monster *z ) return false; } - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); map &here = get_map(); for( tripoint &pnt : here.find_clear_path( z->pos(), target->pos() ) ) { @@ -4126,7 +4128,7 @@ bool mattack::stretch_bite( monster *z ) // Can we dodge the attack? Uses player dodge function % chance (melee.cpp) if( target->dodge_check( z, hit, dam_inst ) ) { - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); z->add_effect( effect_stunned, 3_turns ); game_message_type msg_type = target->is_avatar() ? m_warning : m_info; target->add_msg_player_or_npc( msg_type, @@ -4207,7 +4209,7 @@ bool mattack::flesh_golem( monster *z ) if( dist > 1 ) { if( one_in( 12 ) ) { - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); // It doesn't "nearly deafen you" when it roars from the other side of bubble sounds::sound( z->pos(), 80, sounds::sound_t::alert, _( "a terrifying roar!" ), false, "shout", "roar" ); @@ -4221,7 +4223,7 @@ bool mattack::flesh_golem( monster *z ) } add_msg_if_player_sees( *z, _( "The %1$s swings a massive claw at %2$s!" ), z->name(), target->disp_name() ); - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); bodypart_id hit = target->get_random_body_part(); damage_instance dam_inst = damage_instance( damage_bash, rng( 5, 10 ) ); @@ -4328,7 +4330,7 @@ bool mattack::lunge( monster *z ) if( dist > 4 || !z->sees( *target ) ) { return false; } - z->moves += 200; + z->mod_moves( z->get_speed() * 2.0 ); if( seen ) { add_msg( _( "The %1$s lunges for %2$s!" ), z->name(), target->disp_name() ); } @@ -4343,7 +4345,7 @@ bool mattack::lunge( monster *z ) return false; } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); bodypart_id hit = target->get_random_body_part(); damage_instance dam_inst = damage_instance( damage_bash, rng( 3, 7 ) ); @@ -4417,7 +4419,7 @@ bool mattack::longswipe( monster *z ) if( !z->is_adjacent( target, true ) ) { if( one_in( 5 ) ) { - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); bodypart_id hit = target->get_random_body_part(); damage_instance dam_inst = damage_instance( damage_cut, rng( 3, 7 ) ); @@ -4454,7 +4456,7 @@ bool mattack::longswipe( monster *z ) } return false; } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); bodypart_id hit = bodypart_id( "head" ); damage_instance dam_inst = damage_instance( damage_cut, rng( 6, 10 ) ); @@ -4509,7 +4511,7 @@ bool mattack::blow_whistle( monster *z ) static void parrot_common( monster *parrot ) { // It takes a while - parrot->moves -= 100; + parrot->mod_moves( -to_moves( 1_seconds ) ); const SpeechBubble &speech = get_speech( parrot->type->id.str() ); sounds::sound( parrot->pos(), speech.volume, sounds::sound_t::speech, speech.text.translated(), false, "speech", parrot->type->id.str() ); @@ -4520,7 +4522,7 @@ bool mattack::parrot( monster *z ) if( z->has_effect( effect_shrieking ) ) { sounds::sound( z->pos(), 120, sounds::sound_t::alert, _( "a piercing wail!" ), false, "shout", "wail" ); - z->moves -= 40; + z->mod_moves( -to_moves( 1_seconds ) * 0.4 ); return false; } else if( one_in( 20 ) ) { parrot_common( z ); @@ -4568,7 +4570,7 @@ bool mattack::darkman( monster *z ) return false; } if( monster *const shadow = g->place_critter_around( mon_shadow, z->pos(), 1 ) ) { - z->moves -= 10; + z->mod_moves( -to_moves( 1_seconds ) * 0.1 ); shadow->make_ally( *z ); add_msg_if_player_sees( *z, m_warning, _( "A shadow splits from the %s!" ), z->name() ); } @@ -4763,7 +4765,7 @@ bool mattack::riotbot( monster *z ) if( wielded && wielded->type == handcuffs.type ) { wielded->set_flag( flag_NO_UNWIELD ); } - foe->moves -= 300; + foe->mod_moves( -to_moves( 3_seconds ) ); add_msg( m_bad, _( "The robot puts handcuffs on you." ) ); } @@ -4777,7 +4779,7 @@ bool mattack::riotbot( monster *z ) sounds::sound( z->pos(), 5, sounds::sound_t::electronic_speech, _( "Do not attempt to flee or to remove the handcuffs, citizen. That can be dangerous to your health." ) ); - z->moves -= 300; + z->mod_moves( -to_moves( 3_seconds ) ); return true; } @@ -4792,12 +4794,12 @@ bool mattack::riotbot( monster *z ) add_msg( m_good, _( "You fall to the ground and feign a sudden convulsive attack. Though you're obviously still alive, the robot cannot tell the difference between your 'attack' and a potentially fatal medical condition. It backs off, signaling for medical help." ) ); - z->moves -= 300; + z->mod_moves( -to_moves( 3_seconds ) ); z->anger = -rng( 0, 50 ); return true; } else { add_msg( m_bad, _( "Your awkward movements do not fool the robot." ) ); - foe->moves -= 100; + foe->mod_moves( -to_moves( 1_seconds ) ); bad_trick = true; } } @@ -4805,7 +4807,7 @@ bool mattack::riotbot( monster *z ) if( ( choice == ur_resist ) || bad_trick ) { add_msg( m_bad, _( "The robot sprays tear gas!" ) ); - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); for( const tripoint &dest : here.points_in_radius( z->pos(), 2 ) ) { if( here.passable( dest ) && @@ -4827,7 +4829,7 @@ bool mattack::riotbot( monster *z ) if( dist > 5 && dist < 18 && one_in( 10 ) ) { - z->moves -= 50; + z->mod_moves( -to_moves( 1_seconds ) * 0.5 ); // Precautionary shot int delta = dist / 4 + 1; @@ -4869,7 +4871,7 @@ bool mattack::evolve_kill_strike( monster *z ) return false; } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); damage_instance damage( z->type->melee_damage ); damage.mult_damage( 1.33f ); @@ -4989,7 +4991,7 @@ bool mattack::tindalos_teleport( monster *z ) if( one_in( 7 ) ) { if( monster *const afterimage = g->place_critter_around( mon_hound_tindalos_afterimage, z->pos(), 1 ) ) { - z->moves -= 140; + z->mod_moves( -to_moves( 1_seconds ) * 1.4 ); afterimage->make_ally( *z ); afterimage->nickname = z->nickname; add_msg_if_player_sees( *z, m_warning, @@ -5029,7 +5031,7 @@ bool mattack::flesh_tendril( monster *z ) if( target == nullptr || !z->sees( *target ) ) { if( one_in( 70 ) ) { add_msg( _( "The floor trembles underneath your feet." ) ); - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); sounds::sound( z->pos(), 60, sounds::sound_t::alert, _( "a deafening roar!" ), false, "shout", "roar" ); } @@ -5045,7 +5047,7 @@ bool mattack::flesh_tendril( monster *z ) spawned = mon_zombie_gasbag_impaler; } if( monster *const summoned = g->place_critter_around( spawned, z->pos(), 1 ) ) { - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); summoned->make_ally( *z ); get_map().propagate_field( z->pos(), fd_gibs_flesh, 75, 1 ); add_msg_if_player_sees( *z, m_warning, _( "A %s struggles to pull itself free from the %s!" ), @@ -5140,7 +5142,7 @@ bool mattack::bio_op_takedown( monster *z ) add_msg( _( "The %1$s mechanically grabs at %2$s!" ), z->name(), target->disp_name() ); } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); // Can we dodge the attack? Uses player dodge function % chance (melee.cpp) if( target->dodge_check( z ) ) { @@ -5248,7 +5250,7 @@ bool mattack::bio_op_impale( monster *z ) add_msg( _( "The %1$s mechanically lunges at %2$s!" ), z->name(), target->disp_name() ); } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); // Can we dodge the attack? Uses player dodge function % chance (melee.cpp) if( target->dodge_check( z ) ) { @@ -5332,7 +5334,7 @@ bool mattack::bio_op_disarm( monster *z ) add_msg( _( "The %1$s mechanically reaches for %2$s!" ), z->name(), target->disp_name() ); } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); // Can we dodge the attack? Uses player dodge function % chance (melee.cpp) if( target->dodge_check( z ) ) { @@ -5564,7 +5566,7 @@ static int grenade_helper( monster *const z, Creature *const target, const int d } itype_id att = *possible_attacks.pick(); - z->moves -= moves; + z->mod_moves( -moves ); z->ammo[att]--; // if the player can see it @@ -5686,7 +5688,7 @@ bool mattack::stretch_attack( monster *z ) return false; } - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); map &here = get_map(); for( tripoint &pnt : here.find_clear_path( z->pos(), target->pos() ) ) { if( here.impassable( pnt ) ) { @@ -5711,7 +5713,7 @@ bool mattack::stretch_attack( monster *z ) _( " evades the stretched arm!" ) ); target->on_dodge( z, z->type->melee_skill ); //takes some time to retract the arm - z->moves -= 150; + z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); return true; } @@ -5761,7 +5763,7 @@ bool mattack::zombie_fuse( monster *z ) } add_msg_if_player_sees( *z, _( "The %1$s fuses with the %2$s." ), critter->name(), z->name() ); - z->moves -= 200; + z->mod_moves( -to_moves( 2_seconds ) ); if( z->get_size() < creature_size::huge ) { z->add_effect( effect_grown_of_fuse, 10_days, true, std::min( critter->get_hp_max(), @@ -5785,7 +5787,7 @@ bool mattack::zombie_fuse( monster *z ) bool mattack::doot( monster *z ) { - z->moves -= 300; + z->mod_moves( -to_moves( 3_seconds ) ); add_msg_if_player_sees( *z, _( "The %s doots its trumpet!" ), z->name() ); int spooks = 0; for( const tripoint &spookyscary : get_map().points_in_radius( z->pos(), 2 ) ) { @@ -5814,7 +5816,7 @@ bool mattack::speaker( monster *z ) bool mattack::dsa_drone_scan( monster *z ) { - z->moves -= 100; + z->mod_moves( -to_moves( 1_seconds ) ); constexpr int scan_range = 30; // Select a target: the avatar or a nearby NPC. Must be visible and within scan range Character *target = &get_player_character(); diff --git a/src/monexamine.cpp b/src/monexamine.cpp index 0aa8da6d22ca0..eb388327ae594 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -113,7 +113,7 @@ void swap( monster &z ) { std::string pet_name = z.get_name(); Character &player_character = get_player_character(); - player_character.moves -= 150; + player_character.mod_moves( -to_moves( 1_seconds ) * 1.5 ); ///\EFFECT_STR increases chance to successfully swap positions with your pet ///\EFFECT_DEX increases chance to successfully swap positions with your pet @@ -138,7 +138,7 @@ void push( monster &z ) { std::string pet_name = z.get_name(); Character &player_character = get_player_character(); - player_character.moves -= 30; + player_character.mod_moves( -to_moves( 1_seconds ) * 0.3 ); ///\EFFECT_STR increases chance to successfully push your pet if( one_in( player_character.str_cur ) ) { @@ -201,7 +201,7 @@ void attach_bag_to( monster &z ) z.add_effect( effect_has_bag, 1_turns, true ); // Update encumbrance in case we were wearing it player_character.flag_encumbrance(); - player_character.moves -= 200; + player_character.mod_moves( -to_moves( 2_seconds ) ); } void dump_items( monster &z ) @@ -217,7 +217,7 @@ void dump_items( monster &z ) } z.inv.clear(); add_msg( _( "You dump the contents of the %s's bag on the ground." ), pet_name ); - player_character.moves -= 200; + player_character.mod_moves( -to_moves( 2_seconds ) ); } void remove_bag_from( monster &z ) @@ -231,7 +231,7 @@ void remove_bag_from( monster &z ) get_map().add_item_or_charges( player_character.pos(), *z.storage_item ); add_msg( _( "You remove the %1$s from %2$s." ), z.storage_item->display_name(), pet_name ); z.storage_item.reset(); - player_character.moves -= 200; + player_character.mod_moves( -to_moves( 2_seconds ) ); } else { add_msg( m_bad, _( "Your %1$s doesn't have a bag!" ), pet_name ); } @@ -330,7 +330,7 @@ bool add_armor( monster &z ) loc.remove_item(); z.add_effect( effect_monster_armor, 1_turns, true ); // TODO: armoring a horse takes a lot longer than 2 seconds. This should be a long action. - get_player_character().moves -= 200; + get_player_character().mod_moves( -to_moves( 2_seconds ) ); return true; } @@ -350,7 +350,7 @@ void remove_armor( monster &z ) pet_name ); z.armor_item.reset(); // TODO: removing armor from a horse takes a lot longer than 2 seconds. This should be a long action. - get_player_character().moves -= 200; + get_player_character().mod_moves( -to_moves( 2_seconds ) ); } else { add_msg( m_bad, _( "Your %1$s isn't wearing armor!" ), pet_name ); } diff --git a/src/monmove.cpp b/src/monmove.cpp index 6d5c5a06bc753..49bf9d11fc4a9 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1298,7 +1298,7 @@ void monster::move() move_to( local_next_step, false, false, get_stagger_adjust( pos(), destination, local_next_step ) ); if( !did_something ) { - moves -= 100; // If we don't do this, we'll get infinite loops. + mod_moves( -get_speed() ); // If we don't do this, we'll get infinite loops. } if( has_effect( effect_dragging ) && dragged_foe != nullptr ) { @@ -1704,7 +1704,7 @@ bool monster::bash_at( const tripoint &p ) int bashskill = group_bash_skill( p ); here.bash( p, bashskill ); - moves -= 100; + mod_moves( -get_speed() ); return true; } @@ -1873,7 +1873,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, if( here.has_flag( ter_furn_flag::TFLAG_CLIMBABLE, destination ) ) { if( here.impassable( destination ) && critter == nullptr ) { if( flies() ) { - moves -= 100; + mod_moves( -get_speed() ); force = true; if( get_option( "LOG_MONSTER_MOVEMENT" ) ) { add_msg_if_player_sees( *this, _( "The %1$s flies over the %2$s." ), name(), @@ -1881,7 +1881,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, here.tername( p ) ); } } else if( climbs() ) { - moves -= 150; + mod_moves( -get_speed() * 1.5 ); force = true; if( get_option( "LOG_MONSTER_MOVEMENT" ) ) { add_msg_if_player_sees( *this, _( "The %1$s climbs over the %2$s." ), name(), @@ -1912,7 +1912,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, destination ) : calc_movecost( pos(), destination ) ); if( cost > 0.0f ) { - moves -= static_cast( std::ceil( cost ) ); + mod_moves( -static_cast( std::ceil( cost ) ) ); } else { return false; } @@ -2169,11 +2169,11 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) move_to( p ); } - moves -= movecost_attacker; + mod_moves( -movecost_attacker ); // Don't knock down a creature that successfully // pushed another creature, just reduce moves - critter->moves -= dest_movecost_from; + critter->mod_moves( -dest_movecost_from ); return true; } else { return false; @@ -2188,7 +2188,7 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) } else if( !critter->has_flag( mon_flag_IMMOBILE ) ) { critter->setpos( dest ); move_to( p ); - moves -= movecost_attacker; + mod_moves( -movecost_attacker ); critter->add_effect( effect_downed, time_duration::from_turns( movecost_from / 100 + 1 ) ); } return true; @@ -2209,11 +2209,11 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) name(), critter->disp_name() ); } - moves -= movecost_attacker; + mod_moves( -movecost_attacker ); if( movecost_from > 100 ) { critter->add_effect( effect_downed, time_duration::from_turns( movecost_from / 100 + 1 ) ); } else { - critter->moves -= movecost_from; + critter->mod_moves( -movecost_from ); } return true; diff --git a/src/npcmove.cpp b/src/npcmove.cpp index f53b814e06d0c..272e67b8c3e6c 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1888,7 +1888,7 @@ void npc::execute_action( npc_action action ) break; case npc_talk_to_player: get_avatar().talk_to( get_talker_for( this ) ); - moves = 0; + set_moves( 0 ); break; case npc_mug_player: @@ -3042,12 +3042,12 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo const double base_moves = run_cost( here.combined_movecost( pos(), p ), diag ) * 100.0 / mounted_creature->get_speed(); const double encumb_moves = get_weight() / 4800.0_gram; - moves -= static_cast( std::ceil( base_moves + encumb_moves ) ); + mod_moves( -static_cast( std::ceil( base_moves + encumb_moves ) ) ); if( mounted_creature->has_flag( mon_flag_RIDEABLE_MECH ) ) { mounted_creature->use_mech_power( 1_kJ ); } } else { - moves -= run_cost( here.combined_movecost( pos(), p ), diag ); + mod_moves( -run_cost( here.combined_movecost( pos(), p ), diag ) ); } moved = true; } else if( here.open_door( *this, p, !here.is_outside( pos() ), true ) ) { @@ -3088,7 +3088,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo set_attitude( NPCATT_FLEE_TEMP ); } - moves = 0; + set_moves( 0 ); } if( moved ) { @@ -3658,7 +3658,7 @@ void npc::pick_up_item() add_msg_debug( debugmode::DF_NPC, "%s::pick_up_item(); Canceling on player's request", get_name() ); fetching_item = false; wanted_item = nullptr; - moves -= 1; + mod_moves( -1 ); return; } @@ -4012,7 +4012,7 @@ bool npc::do_player_activity() } } if( multi_type && moves == moves_before ) { - moves -= 1; + mod_moves( -1 ); } /* if the activity is finished, grab any backlog or change the mission */ if( !has_destination() && !activity ) { @@ -4409,7 +4409,7 @@ void npc::use_painkiller() add_msg_if_player_sees( *this, _( "%1$s takes some %2$s." ), disp_name(), it->tname() ); item_location loc = item_location( *this, it ); const time_duration &consume_time = get_consume_time( *loc ); - moves -= to_moves( consume_time ); + mod_moves( -to_moves( consume_time ) ); consume( loc ); } } @@ -4621,7 +4621,7 @@ bool npc::consume_food() // TODO: Message that "X begins eating Y?" Right now it appears to the player // that "Urist eats a carp roast" and then stands still doing nothing // for a while. - moves -= to_moves( consume_time ); + mod_moves( -to_moves( consume_time ) ); } else { debugmsg( "%s failed to consume %s", get_name(), best_food->tname() ); } @@ -4651,7 +4651,7 @@ void npc::mug_player( Character &mark ) cash += mark.cash; mark.cash = 0; } - moves = 0; + set_moves( 0 ); // Describe the action if( mark.is_npc() ) { if( u_see ) { @@ -5352,7 +5352,7 @@ void npc::do_reload( const item_location &it ) return; } - moves -= reload_time; + mod_moves( -reload_time ); recoil = MAX_RECOIL; if( get_player_view().sees( *this ) ) { diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 3fc726a2d117c..73397d292457f 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -1239,7 +1239,7 @@ void game::chat() add_msg( emote_msg ); } - u.moves -= 100; + u.mod_moves( -u.get_speed() ); } void npc::handle_sound( const sounds::sound_t spriority, const std::string &description, @@ -4123,7 +4123,7 @@ talk_effect_fun_t::func f_turn_cost( const JsonObject &jo, std::string_view memb return [cost]( dialogue & d ) { Character *target = d.actor( false )->get_character(); if( target ) { - target->moves -= to_moves( cost.evaluate( d ) ); + target->mod_moves( -to_moves( cost.evaluate( d ) ) ); } }; } diff --git a/src/pickup.cpp b/src/pickup.cpp index 6c0b63eae7c04..a172955f57388 100644 --- a/src/pickup.cpp +++ b/src/pickup.cpp @@ -309,11 +309,11 @@ static bool pick_one_up( item_location &loc, int quantity, bool &got_water, bool info.total_bulk_volume += loc->volume( false, false, quantity ); if( !is_bulk_load( pre_info, info ) ) { // Cost to take an item from a container or map - player_character.moves -= loc.obtain_cost( player_character, quantity ); + player_character.mod_moves( -loc.obtain_cost( player_character, quantity ) ); } else { // Pure cost to handling item excluding overhead. - player_character.moves -= std::max( player_character.item_handling_cost( *loc, true, 0, quantity, - true ), 1 ); + player_character.mod_moves( -std::max( player_character.item_handling_cost( *loc, true, 0, quantity, + true ), 1 ) ); } contents_change_handler handler; handler.unseal_pocket_containing( loc ); @@ -348,7 +348,7 @@ bool Pickup::do_pickup( std::vector &targets, std::vector &q PickupMap mapPickup; bool problem = false; - while( !problem && player_character.moves >= 0 && !targets.empty() ) { + while( !problem && player_character.get_moves() >= 0 && !targets.empty() ) { item_location target = std::move( targets.back() ); int quantity = quantities.back(); // Whether we pick the item up or not, we're done trying to do so, diff --git a/src/player_activity.cpp b/src/player_activity.cpp index 7374f3caa39d9..1926578532c68 100644 --- a/src/player_activity.cpp +++ b/src/player_activity.cpp @@ -265,17 +265,17 @@ void player_activity::do_turn( Character &you ) if( type->based_on() == based_on_type::TIME ) { if( moves_left >= 100 ) { moves_left -= 100 * activity_mult; - you.moves = 0; + you.set_moves( 0 ); } else { - you.moves -= you.moves * moves_left / 100; + you.mod_moves( -you.get_moves() * moves_left / 100 ); moves_left = 0; } } else if( type->based_on() == based_on_type::SPEED ) { - if( you.moves <= moves_left ) { - moves_left -= you.moves * activity_mult; - you.moves = 0; + if( you.get_moves() <= moves_left ) { + moves_left -= you.get_moves() * activity_mult; + you.set_moves( 0 ); } else { - you.moves -= moves_left; + you.mod_moves( -moves_left ); moves_left = 0; } } diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index 9be2f388c0a23..bfc796d461437 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -218,7 +218,7 @@ static void eff_fun_fungus( Character &u, effect &it ) // 6-12 hours of worse symptoms if( one_in( 3600 + bonus * 18 ) ) { u.add_msg_if_player( m_bad, _( "You spasm suddenly!" ) ); - u.moves -= 100; + u.mod_moves( -to_moves( 1_seconds ) ); u.apply_damage( nullptr, bodypart_id( "torso" ), resists ? rng( 1, 5 ) : 5 ); } if( x_in_y( u.vomit_mod(), ( 4800 + bonus * 24 ) ) || one_in( 12000 + bonus * 60 ) ) { @@ -226,7 +226,7 @@ static void eff_fun_fungus( Character &u, effect &it ) _( " vomits a thick, gray goop." ) ); const int awfulness = rng( 0, resists ? rng( 1, 70 ) : 70 ); - u.moves = -200; + u.set_moves( -to_moves( 2_seconds ) ); u.mod_hunger( awfulness ); u.mod_thirst( awfulness ); ///\EFFECT_STR decreases damage taken by fungus effect @@ -240,7 +240,7 @@ static void eff_fun_fungus( Character &u, effect &it ) u.add_msg_player_or_npc( m_bad, _( "You vomit thousands of live spores!" ), _( " vomits thousands of live spores!" ) ); - u.moves = -500; + u.set_moves( -to_moves( 5_seconds ) ); map &here = get_map(); fungal_effects fe; for( const tripoint &sporep : here.points_in_radius( u.pos(), 1 ) ) { @@ -1301,7 +1301,7 @@ void Character::hardcoded_effects( effect &it ) } get_event_bus().send( getID() ); schedule_effect_removal( effect_formication, bp ); - moves -= 600; + mod_moves( -to_moves( 6_seconds ) ); triggered = true; } if( triggered ) { @@ -1323,7 +1323,7 @@ void Character::hardcoded_effects( effect &it ) add_msg_if_player_sees( pos(), _( "%1$s starts scratching their %2$s!" ), get_name(), body_part_name_accusative( bp ) ); } - moves -= 150; + mod_moves( -to_moves( 1_seconds ) * 1.5 ); mod_pain( 1 ); apply_damage( nullptr, bp, 1 ); } diff --git a/src/ranged.cpp b/src/ranged.cpp index db187745e5112..5606a15c808e3 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -850,7 +850,7 @@ void npc::pretend_fire( npc *source, int shots, item &gun ) add_msg_if_player_sees( *source, m_warning, _( "You hear %s." ), data.sound ); curshot++; - moves -= 100; + mod_moves( -get_speed() ); } } @@ -919,7 +919,7 @@ int Character::fire_gun( const tripoint &target, int shots, item &gun ) int delay = 0; // delayed recoil that has yet to be applied while( curshot != shots ) { if( gun.faults.count( fault_gun_chamber_spent ) && curshot == 0 ) { - moves -= 50; + mod_moves( -get_speed() * 0.5 ); gun.faults.erase( fault_gun_chamber_spent ); add_msg_if_player( _( "You cycle your %s manually." ), gun.tname() ); } @@ -1054,7 +1054,7 @@ int Character::fire_gun( const tripoint &target, int shots, item &gun ) } } // Use different amounts of time depending on the type of gun and our skill - moves -= time_to_attack( *this, *gun_id ); + mod_moves( -time_to_attack( *this, *gun_id ) ); const islot_gun &firing = *gun.type->gun; for( const std::pair &hurt_part : firing.hurt_part_when_fired ) { @@ -1523,7 +1523,7 @@ static void do_aim( Character &you, const item &relevant, const double min_recoi practice_archery_proficiency( you, relevant ); // Only drain stamina on initial draw - if( you.moves == 1 ) { + if( you.get_moves() == 1 ) { mod_stamina_archery( you, relevant ); } } @@ -3423,7 +3423,7 @@ bool target_ui::action_aim() // We've changed pc.recoil, update penalty recalc_aim_turning_penalty(); - return you->moves > 0; + return you->get_moves() > 0; } bool target_ui::action_drop_aim() @@ -3454,7 +3454,7 @@ bool target_ui::action_aim_and_shoot( const std::string &action ) const double min_recoil = calculate_aim_cap( *you, dst ); do { do_aim( *you, relevant ? *relevant : null_item_reference(), min_recoil ); - } while( you->moves > 0 && you->recoil > aim_threshold && + } while( you->get_moves() > 0 && you->recoil > aim_threshold && you->recoil - sight_dispersion > min_recoil ); // If we made it under the aim threshold, go ahead and fire. diff --git a/src/relic.cpp b/src/relic.cpp index 9d6d81277d46d..b2a7279b4818c 100644 --- a/src/relic.cpp +++ b/src/relic.cpp @@ -419,7 +419,7 @@ int relic::activate( Creature &caster, const tripoint &target ) caster.add_msg_if_player( m_bad, _( "This artifact lacks the charges to activate." ) ); return 0; } - caster.moves -= moves; + caster.mod_moves( -moves ); for( const fake_spell &sp : active_effects ) { spell casting = sp.get_spell( caster, sp.level ); casting.cast_all_effects( caster, target ); diff --git a/src/suffer.cpp b/src/suffer.cpp index 0b19931fe8c59..85a38667bf45f 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -489,7 +489,7 @@ void suffer::from_chemimbalance( Character &you ) } if( one_turn_in( 6_hours ) && !you.has_effect( effect_sleep ) ) { you.add_msg_if_player( m_bad, _( "You feel dizzy for a moment." ) ); - you.moves -= rng( 10, 30 ); + you.mod_moves( -to_moves( 1_seconds ) * rng_float( 0.1, 0.3 ) ); } if( one_turn_in( 6_hours ) ) { int hungadd = 5 * rng( -1, 3 ); @@ -609,7 +609,7 @@ void suffer::from_asthma( Character &you, const int current_stim ) } else if( auto_use ) { int charges = 0; if( you.use_charges_if_avail( itype_inhaler, 1 ) ) { - you.moves -= 40; + you.mod_moves( -to_moves( 1_seconds ) * 0.4 ); charges = you.charges_of( itype_inhaler ); if( charges == 0 ) { you.add_msg_if_player( m_bad, _( "You use your last inhaler charge." ) ); @@ -623,7 +623,7 @@ void suffer::from_asthma( Character &you, const int current_stim ) you.add_effect( effect_took_antiasthmatic, rng( 6_hours, 12_hours ) ); } else if( you.use_charges_if_avail( itype_oxygen_tank, 1 ) || you.use_charges_if_avail( itype_smoxygen_tank, 1 ) ) { - you.moves -= 500; // synched with use action + you.mod_moves( -to_moves( 5_seconds ) ); // synched with use action charges = you.charges_of( itype_oxygen_tank ) + you.charges_of( itype_smoxygen_tank ); if( charges == 0 ) { you.add_msg_if_player( m_bad, _( "You breathe in the last bit of oxygen " @@ -1219,7 +1219,7 @@ void suffer::from_bad_bionics( Character &you ) } else { you.add_msg_if_player( m_bad, _( "You experience an electrical discharge!" ) ); } - you.moves -= 150; + you.mod_moves( -to_moves( 1_seconds ) * 1.5 ); you.mod_power_level( -bio_dis_shock->power_trigger ); item_location weapon = you.get_wielded_item(); @@ -1445,7 +1445,7 @@ void suffer::without_sleep( Character &you, const int sleep_deprivation ) if( sleep_deprivation >= SLEEP_DEPRIVATION_MINOR ) { if( one_turn_in( 75_minutes ) ) { you.add_msg_if_player( m_warning, _( "You feel lightheaded for a moment." ) ); - you.moves -= 10; + you.mod_moves( -to_moves( 1_seconds ) * 0.1 ); } if( one_turn_in( 100_minutes ) ) { you.add_msg_if_player( m_warning, _( "Your muscles spasm uncomfortably." ) ); @@ -1460,7 +1460,7 @@ void suffer::without_sleep( Character &you, const int sleep_deprivation ) if( sleep_deprivation >= SLEEP_DEPRIVATION_SERIOUS ) { if( one_turn_in( 75_minutes ) ) { you.add_msg_if_player( m_bad, _( "Your mind lapses into unawareness briefly." ) ); - you.moves -= rng( 20, 80 ); + you.mod_moves( -to_moves( 1_seconds ) * rng_float( 0.2, 0.8 ) ); } if( one_turn_in( 125_minutes ) ) { you.add_msg_if_player( m_bad, _( "Your muscles ache in stressfully unpredictable ways." ) ); @@ -1488,7 +1488,7 @@ void suffer::without_sleep( Character &you, const int sleep_deprivation ) "trouble keeping your balance." ) ); you.add_effect( effect_shakes, 15_minutes ); } else if( you.has_effect( effect_shakes ) && one_turn_in( 75_seconds ) ) { - you.moves -= 10; + you.mod_moves( -to_moves( 1_seconds ) * 0.1 ); you.add_msg_player_or_npc( m_warning, _( "Your shaking legs make you stumble." ), _( " stumbles." ) ); if( !you.is_on_ground() && one_in( 10 ) ) { diff --git a/src/talker_npc.cpp b/src/talker_npc.cpp index ae75306237457..6a316a6541b3b 100644 --- a/src/talker_npc.cpp +++ b/src/talker_npc.cpp @@ -171,7 +171,7 @@ std::vector talker_npc::get_topics( bool radio_contact ) if( add_topics.back() == "TALK_NONE" ) { add_topics.back() = me_npc->pick_talk_topic( player_character ); } - me_npc->moves -= 100; + me_npc->mod_moves( -to_moves( 1_seconds ) ); if( player_character.is_deaf() ) { if( add_topics.back() == me_npc->chatbin.talk_mug || @@ -364,7 +364,7 @@ static consumption_result try_consume( npc &p, item &it, std::string &reason ) } const time_duration &consume_time = p.get_consume_time( to_eat ); - p.moves -= to_moves( consume_time ); + p.mod_moves( -to_moves( consume_time ) ); p.consume( to_eat ); reason = p.chat_snippets().snip_consume_eat.translated(); } @@ -395,7 +395,7 @@ static consumption_result try_consume( npc &p, item &it, std::string &reason ) p.consume_effects( to_eat ); to_eat.charges -= amount_used; - p.moves -= 250; + p.mod_moves( -to_moves( 1_seconds ) * 2.5 ); } else { debugmsg( "Unknown comestible type of item: %s\n", to_eat.tname() ); } @@ -450,7 +450,7 @@ std::string talker_npc::give_item_to( const bool to_use ) // Eating first, to avoid evaluating bread as a weapon const consumption_result consume_res = try_consume( *me_npc, given, reason ); if( consume_res != REFUSED ) { - player_character.moves -= 100; + player_character.mod_moves( -to_moves( 1_seconds ) ); if( consume_res == CONSUMED_ALL ) { player_character.i_rem( &given ); } else if( given.is_container() ) { @@ -510,7 +510,7 @@ std::string talker_npc::give_item_to( const bool to_use ) if( taken ) { player_character.i_rem( &given ); - player_character.moves -= 100; + player_character.mod_moves( -to_moves( 1_seconds ) ); me_npc->has_new_items = true; } diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 56e3e92099381..f608ff65c5f2f 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -142,7 +142,7 @@ bool trapfunc::glass( const tripoint &p, Creature *c, item * ) monster *z = dynamic_cast( c ); const char dmg = std::max( 0, rng( -10, 10 ) ); if( z != nullptr && dmg > 0 ) { - z->moves -= 80; + z->mod_moves( -z->get_speed() * 0.8 ); } if( dmg > 0 ) { c->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, dmg ) ); @@ -161,7 +161,7 @@ bool trapfunc::cot( const tripoint &, Creature *c, item * ) if( z != nullptr ) { // Haha, only monsters stumble over a cot, humans are smart. add_msg( m_good, _( "The %s stumbles over the cot!" ), z->name() ); - c->moves -= 100; + c->mod_moves( -c->get_speed() ); return true; } return false; @@ -224,9 +224,9 @@ bool trapfunc::board( const tripoint &, Creature *c, item * ) if( z != nullptr ) { if( z->has_effect( effect_ridden ) ) { add_msg( m_warning, _( "Your %s stepped on a spiked board!" ), c->get_name() ); - get_player_character().moves -= 80; + get_player_character().mod_moves( -z->get_speed() * 0.8 ); } else { - z->moves -= 80; + z->mod_moves( -z->get_speed() * 0.8 ); } z->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, rng( 3, 5 ) ) ); @@ -265,9 +265,9 @@ bool trapfunc::caltrops( const tripoint &, Creature *c, item * ) if( z != nullptr ) { if( z->has_effect( effect_ridden ) ) { add_msg( m_warning, _( "Your %s steps on a sharp metal caltrop!" ), c->get_name() ); - get_player_character().moves -= 80; + get_player_character().mod_moves( -z->get_speed() * 0.8 ); } else { - z->moves -= 80; + z->mod_moves( -z->get_speed() * 0.8 ); } z->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, rng( 9, 15 ) ) ); @@ -309,7 +309,7 @@ bool trapfunc::caltrops_glass( const tripoint &p, Creature *c, item * ) _( " steps on a sharp glass caltrop!" ) ); monster *z = dynamic_cast( c ); if( z != nullptr ) { - z->moves -= 80; + z->mod_moves( -z->get_speed() * 0.8 ); z->deal_damage( nullptr, bodypart_id( "foot_l" ), damage_instance( damage_cut, rng( 9, 15 ) ) ); z->deal_damage( nullptr, bodypart_id( "foot_r" ), damage_instance( damage_cut, rng( 9, 15 ) ) ); } else { @@ -355,7 +355,7 @@ bool trapfunc::tripwire( const tripoint &p, Creature *c, item * ) player_character.setpos( random_entry( valid ) ); z->setpos( player_character.pos() ); } - player_character.moves -= 150; + player_character.mod_moves( -z->get_speed() * 1.5 ); g->update_map( player_character ); } else { z->stumble(); @@ -374,7 +374,7 @@ bool trapfunc::tripwire( const tripoint &p, Creature *c, item * ) if( !valid.empty() ) { you->setpos( random_entry( valid ) ); } - you->moves -= 150; + you->mod_moves( -you->get_speed() * 1.5 ); if( c->is_avatar() ) { g->update_map( player_character ); } @@ -1190,7 +1190,7 @@ bool trapfunc::sinkhole( const tripoint &p, Creature *c, item *i ) } here.remove_trap( p ); here.ter_set( p, t_pit ); - c->moves -= 100; + c->mod_moves( -c->get_speed() ); pit( p, c, i ); return true; } diff --git a/src/turret.cpp b/src/turret.cpp index 782a2bcb349b7..e7fdbdcada106 100644 --- a/src/turret.cpp +++ b/src/turret.cpp @@ -431,8 +431,8 @@ bool vehicle::turrets_aim( std::vector &turrets ) } ///\EFFECT_INT speeds up aiming of vehicle turrets - player_character.moves = std::min( 0, - player_character.moves - 100 + ( 5 * player_character.int_cur ) ); + player_character.set_moves( std::min( 0, + player_character.get_moves() - 100 + ( 5 * player_character.int_cur ) ) ); } return got_target; } diff --git a/src/vehicle_autodrive.cpp b/src/vehicle_autodrive.cpp index b852602ffe979..f3c3c870d0646 100644 --- a/src/vehicle_autodrive.cpp +++ b/src/vehicle_autodrive.cpp @@ -1414,7 +1414,7 @@ autodrive_result vehicle::do_autodrive( Character &driver ) // pldrive() does not handle steering multiple times in one call correctly // call it multiple times, matching how a player controls the vehicle for( int i = 0; i < std::abs( turn_delta ); i++ ) { - if( driver.moves <= 0 ) { + if( driver.get_moves() <= 0 ) { // we couldn't steer as many times as we wanted to but there's // nothing we can do about it now, hope we don't crash! break; diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 899b42cdb0906..6327bc1dc534d 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -1434,7 +1434,7 @@ void vehicle::pldrive( Character &driver, const point &p, int z ) // - 50% Skill at Per/Dex 12: 1-in-18 chance } if( z != 0 && is_rotorcraft() ) { - driver.moves = std::min( driver.moves, 0 ); + driver.set_moves( std::min( driver.get_moves(), 0 ) ); thrust( 0, z ); } units::angle turn_delta = vehicles::steer_increment * p.x; @@ -1460,7 +1460,7 @@ void vehicle::pldrive( Character &driver, const point &p, int z ) // If you've got more moves than speed, it's most likely time stop // Let's get rid of that - driver.moves = std::min( driver.moves, driver.get_speed() ); + driver.set_moves( std::min( driver.get_moves(), driver.get_speed() ) ); ///\EFFECT_DEX reduces chance of losing control of vehicle when turning @@ -1500,7 +1500,7 @@ void vehicle::pldrive( Character &driver, const point &p, int z ) fumble_time = 2; } turn_delta *= fumble_factor; - cost = std::max( cost, driver.moves + fumble_time * 100 ); + cost = std::max( cost, driver.get_moves() + fumble_time * 100 ); } else if( one_in( 10 ) ) { // Don't warn all the time or it gets spammy if( cost >= driver.get_speed() * 2 ) { @@ -1513,7 +1513,7 @@ void vehicle::pldrive( Character &driver, const point &p, int z ) turn( turn_delta ); // At most 3 turns per turn, because otherwise it looks really weird and jumpy - driver.moves -= std::max( cost, driver.get_speed() / 3 + 1 ); + driver.mod_moves( -std::max( cost, driver.get_speed() / 3 + 1 ) ); } if( p.y != 0 ) { diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 245c2395852b2..2a1475317020d 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -124,7 +124,7 @@ void handbrake() veh->velocity = sgn * ( std::abs( veh->velocity ) - braking_power ); } } - player_character.moves = 0; + player_character.set_moves( 0 ); } void vehicle::control_doors() diff --git a/src/widget.cpp b/src/widget.cpp index e607b044dfcdd..ea4a1aab70601 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -806,7 +806,7 @@ int widget::get_var_value( const avatar &ava ) const value = ava.movecounter; break; case widget_var::move_remainder: - value = ava.moves; + value = ava.get_moves(); break; case widget_var::move_cost: value = ava.run_cost( 100 ); diff --git a/tests/activity_scheduling_helper.cpp b/tests/activity_scheduling_helper.cpp index 96763f1774037..94a687f538a20 100644 --- a/tests/activity_scheduling_helper.cpp +++ b/tests/activity_scheduling_helper.cpp @@ -112,7 +112,7 @@ weariness_events do_activity( tasklist tasks, bool do_clear_avatar ) // Consume food, become weary, etc guy.update_body(); // Start each turn with a fresh set of moves - guy.moves = 100; + guy.set_moves( 100 ); task.do_turn( guy ); } // Cancel our activity, now that we're done diff --git a/tests/addiction_test.cpp b/tests/addiction_test.cpp index 62bafd5f4b200..f2e6bd12ad9ea 100644 --- a/tests/addiction_test.cpp +++ b/tests/addiction_test.cpp @@ -62,7 +62,7 @@ static void clear_addictions( Character &u ) { u.addictions.clear(); u.clear_effects(); - u.moves = 100; + u.set_moves( u.get_speed() ); u.set_daily_health( 0 ); u.str_max = 8; u.dex_max = 8; diff --git a/tests/cardio_test.cpp b/tests/cardio_test.cpp index ff2065bd0a738..f669055cd1398 100644 --- a/tests/cardio_test.cpp +++ b/tests/cardio_test.cpp @@ -75,7 +75,7 @@ static int running_steps( Character &they, const ter_id &terrain = t_pavement ) int last_moves = they.get_speed(); int last_stamina = they.get_stamina_max(); // Take a deep breath and start running - they.moves = last_moves; + they.set_moves( last_moves ); they.set_stamina( last_stamina ); they.set_movement_mode( move_mode_run ); // Run as long as possible @@ -91,12 +91,12 @@ static int running_steps( Character &they, const ter_id &terrain = t_pavement ) ++steps; // Ensure moves are decreasing, or else a turn will never pass - REQUIRE( they.moves < last_moves ); - const int move_cost = last_moves - they.moves; + REQUIRE( they.get_moves() < last_moves ); + const int move_cost = last_moves - they.get_moves(); // When moves run out, one turn has passed - if( they.moves <= 0 ) { + if( they.get_moves() <= 0 ) { // Get "speed" moves back each turn - they.moves += they.get_speed(); + they.mod_moves( they.get_speed() ); calendar::turn += 1_turns; turns += 1; @@ -111,7 +111,7 @@ static int running_steps( Character &they, const ter_id &terrain = t_pavement ) REQUIRE( they.get_stamina() < last_stamina ); last_stamina = they.get_stamina(); } - last_moves = they.moves; + last_moves = they.get_moves(); } // Reset to starting position they.setpos( left ); diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index e317758d3a827..6b94b2c5c6fd1 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -507,7 +507,7 @@ static int actually_test_craft( const recipe_id &rid, int interrupt_after_turns, set_time( midnight ); // Kill light to interrupt crafting } ++turns; - player_character.moves = 100; + player_character.set_moves( 100 ); player_character.activity.do_turn( player_character ); if( turns % 60 == 0 ) { player_character.update_mental_focus(); @@ -528,7 +528,7 @@ static int test_craft_for_prof( const recipe_id &rid, const proficiency_id &prof set_time( midnight ); } - player_character.moves = 100; + player_character.set_moves( 100 ); player_character.set_focus( 100 ); player_character.activity.do_turn( player_character ); ++turns; @@ -1027,7 +1027,7 @@ static int resume_craft() int turns = 0; while( player_character.activity.id() == ACT_CRAFT ) { ++turns; - player_character.moves = 100; + player_character.set_moves( 100 ); player_character.activity.do_turn( player_character ); if( turns % 60 == 0 ) { player_character.update_mental_focus(); diff --git a/tests/firstaid_test.cpp b/tests/firstaid_test.cpp index 43fe20cec5202..7b52f55cfaed7 100644 --- a/tests/firstaid_test.cpp +++ b/tests/firstaid_test.cpp @@ -21,8 +21,8 @@ static const skill_id skill_firstaid( "firstaid" ); static void process_activity_interrupt( Character &guy, const int interrupt_time ) { do { - guy.moves += guy.get_speed(); - while( guy.moves > 0 && guy.has_activity( ACT_FIRSTAID ) ) { + guy.mod_moves( guy.get_speed() ); + while( guy.get_moves() > 0 && guy.has_activity( ACT_FIRSTAID ) ) { guy.activity.do_turn( guy ); if( guy.activity.moves_total - guy.activity.moves_left >= interrupt_time ) { // Assume the player confirms the option to cancel the activity when getting interrupted, diff --git a/tests/gates_test.cpp b/tests/gates_test.cpp index 257a691bd1e03..9e11b1ddfa8a5 100644 --- a/tests/gates_test.cpp +++ b/tests/gates_test.cpp @@ -153,7 +153,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows // set move value to 0 so we know how many // move points were spent opening and closing gates - they.moves = 0; + they.set_moves( 0 ); WHEN( "avatar opens door" ) { REQUIRE( here.ter_set( pos, t_door_c ) ); @@ -162,7 +162,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE( avatar_action::move( they, here, tripoint_east ) ); THEN( "avatar should spend move points" ) { - CHECK( they.moves == -open_move_cost ); + CHECK( they.get_moves() == -open_move_cost ); } } WHEN( "avatar fails to open locked door" ) { @@ -172,7 +172,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE_FALSE( avatar_action::move( they, here, tripoint_east ) ); THEN( "avatar should not spend move points" ) { - CHECK( they.moves == 0 ); + CHECK( they.get_moves() == 0 ); } } GIVEN( "that avatar is outdoors" ) { @@ -185,7 +185,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE_FALSE( avatar_action::move( they, here, tripoint_east ) ); THEN( "avatar should spend move points" ) { - CHECK( they.moves == 0 ); + CHECK( they.get_moves() == 0 ); } } } @@ -224,7 +224,7 @@ TEST_CASE( "character_should_lose_moves_when_opening_or_closing_doors_or_windows REQUIRE( avatar_action::move( they, here, tripoint_east ) ); THEN( "avatar should spend move points" ) { - CHECK( they.moves == -open_move_cost ); + CHECK( they.get_moves() == -open_move_cost ); } } } diff --git a/tests/invlet_test.cpp b/tests/invlet_test.cpp index 51f32619af046..c236a7e3e51a4 100644 --- a/tests/invlet_test.cpp +++ b/tests/invlet_test.cpp @@ -241,7 +241,7 @@ static void drop_at_feet( Character &you, const std::string &id ) item *found = retrieve_item( you, id ); REQUIRE( found ); item_location loc( you, found ); - you.moves = 100; + you.set_moves( 100 ); you.drop( loc, you.pos() ); you.activity.do_turn( you ); @@ -256,7 +256,7 @@ static void pick_up_from_feet( Character &you, const std::string &id ) item *found = retrieve_item( map_cursor( you.pos() ), id ); REQUIRE( found ); - you.moves = 100; + you.set_moves( 100 ); const std::vector target_items = { item_location( map_cursor( you.pos() ), found ) }; you.assign_activity( pickup_activity_actor( target_items, { 0 }, you.pos(), false ) ); you.activity.do_turn( you ); diff --git a/tests/item_pocket_test.cpp b/tests/item_pocket_test.cpp index 4aab366299862..6148c57fd937f 100644 --- a/tests/item_pocket_test.cpp +++ b/tests/item_pocket_test.cpp @@ -1748,7 +1748,7 @@ static void test_pickup_autoinsert_results( Character &u, bool wear, const item_ size_t on_ground, size_t in_top, size_t in_nested, bool count_by_charges = false ) { map &m = get_map(); - u.moves = 100; + u.set_moves( 100 ); while( !u.activity.is_null() ) { u.activity.do_turn( u ); } @@ -2268,11 +2268,11 @@ TEST_CASE( "multipocket_liquid_transfer_test", "[pocket][item][liquid]" ) liquid_target.pos = jug_w_water.position(); liquid_target.dest_opt = LD_ITEM; liquid_target.item_loc = suit; - u.moves = 100; + u.set_moves( 100 ); liquid_handler::perform_liquid_transfer( *jug_w_water->all_items_top().front(), nullptr, nullptr, -1, nullptr, liquid_target ); THEN( "liquid fills the worn container's pockets, some left over" ) { - CHECK( u.moves == 0 ); + CHECK( u.get_moves() == 0 ); CHECK( !jug_w_water->only_item().is_null() ); CHECK( jug_w_water->only_item().charges == 3 ); CHECK( suit->all_items_top().size() == 2 ); @@ -2296,11 +2296,11 @@ TEST_CASE( "multipocket_liquid_transfer_test", "[pocket][item][liquid]" ) liquid_target.pos = jug_w_water.position(); liquid_target.dest_opt = LD_ITEM; liquid_target.item_loc = suit; - u.moves = 100; + u.set_moves( 100 ); liquid_handler::perform_liquid_transfer( *jug_w_water->all_items_top().front(), nullptr, nullptr, -1, nullptr, liquid_target ); THEN( "liquid fills the worn container's pockets, some left over" ) { - CHECK( u.moves == 0 ); + CHECK( u.get_moves() == 0 ); CHECK( !jug_w_water->only_item().is_null() ); CHECK( jug_w_water->only_item().charges == 7 ); CHECK( suit->all_items_top().size() == 2 ); @@ -2322,14 +2322,14 @@ TEST_CASE( "multipocket_liquid_transfer_test", "[pocket][item][liquid]" ) liquid_target.pos = jug_w_water.position(); liquid_target.dest_opt = LD_ITEM; liquid_target.item_loc = suit; - u.moves = 100; + u.set_moves( 100 ); liquid_handler::perform_liquid_transfer( *jug_w_water->all_items_top().front(), nullptr, nullptr, -1, nullptr, liquid_target ); m.make_active( jug_w_water ); CHECK( jug_w_water->only_item().charges == 0 ); jug_w_water->remove_item( jug_w_water->only_item() ); THEN( "liquid fills one of the worn container's pockets, none left over" ) { - CHECK( u.moves == 0 ); + CHECK( u.get_moves() == 0 ); CHECK( jug_w_water->is_container_empty() ); CHECK( suit->all_items_top().size() == 1 ); CHECK( suit->all_items_top().front()->charges == 2 ); @@ -2346,14 +2346,14 @@ TEST_CASE( "multipocket_liquid_transfer_test", "[pocket][item][liquid]" ) liquid_target.pos = jug_w_water.position(); liquid_target.dest_opt = LD_ITEM; liquid_target.item_loc = suit; - u.moves = 100; + u.set_moves( 100 ); liquid_handler::perform_liquid_transfer( *jug_w_water->all_items_top().front(), nullptr, nullptr, -1, nullptr, liquid_target ); m.make_active( jug_w_water ); CHECK( jug_w_water->only_item().charges == 0 ); jug_w_water->remove_item( jug_w_water->only_item() ); THEN( "liquid fills one of the worn container's pockets, none left over" ) { - CHECK( u.moves == 0 ); + CHECK( u.get_moves() == 0 ); CHECK( jug_w_water->is_container_empty() ); CHECK( suit->all_items_top().size() == 2 ); int total = 0; @@ -2375,15 +2375,15 @@ TEST_CASE( "multipocket_liquid_transfer_test", "[pocket][item][liquid]" ) liquid_target.dest_opt = LD_ITEM; liquid_target.item_loc = jug_w_water; for( item *&it : suit->all_items_top() ) { - u.moves = 100; + u.set_moves( 100 ); REQUIRE( it->charges == 6 ); liquid_handler::perform_liquid_transfer( *it, nullptr, nullptr, -1, nullptr, liquid_target ); - CHECK( u.moves == 0 ); + CHECK( u.get_moves() == 0 ); CHECK( it->charges == 0 ); suit->remove_item( *it ); } THEN( "liquid fills most of the empty container, none left over" ) { - CHECK( u.moves == 0 ); + CHECK( u.get_moves() == 0 ); CHECK( !jug_w_water->only_item().is_null() ); CHECK( jug_w_water->only_item().charges == 12 ); CHECK( suit->is_container_empty() ); @@ -2400,10 +2400,10 @@ TEST_CASE( "multipocket_liquid_transfer_test", "[pocket][item][liquid]" ) liquid_target.dest_opt = LD_ITEM; liquid_target.item_loc = jug_w_water; for( item *&it : suit->all_items_top() ) { - u.moves = 100; + u.set_moves( 100 ); REQUIRE( it->charges == 6 ); liquid_handler::perform_liquid_transfer( *it, nullptr, nullptr, -1, nullptr, liquid_target ); - if( u.moves == 0 && it->charges == 0 ) { + if( u.get_moves() == 0 && it->charges == 0 ) { suit->remove_item( *it ); } } diff --git a/tests/monster_test.cpp b/tests/monster_test.cpp index 6541e8c7825c4..e93e1a72d511f 100644 --- a/tests/monster_test.cpp +++ b/tests/monster_test.cpp @@ -48,11 +48,11 @@ static int moves_to_destination( const std::string &monster_type, int moves_spent = 0; for( int turn = 0; turn < 1000; ++turn ) { test_monster.mod_moves( monster_speed ); - while( test_monster.moves >= 0 ) { + while( test_monster.get_moves() >= 0 ) { test_monster.anger = 100; - const int moves_before = test_monster.moves; + const int moves_before = test_monster.get_moves(); test_monster.move(); - moves_spent += moves_before - test_monster.moves; + moves_spent += moves_before - test_monster.get_moves(); if( test_monster.get_location() == test_monster.get_dest() ) { g->remove_zombie( test_monster ); return moves_spent; @@ -118,7 +118,7 @@ static int can_catch_player( const std::string &monster_type, const tripoint &di std::vector tracker; for( int turn = 0; turn < 1000; ++turn ) { test_player.mod_moves( target_speed ); - while( test_player.moves >= 0 ) { + while( test_player.get_moves() >= 0 ) { test_player.setpos( test_player.pos() + direction_of_flight ); if( test_player.pos().x < SEEX * static_cast( MAPSIZE / 2 ) || test_player.pos().y < SEEY * static_cast( MAPSIZE / 2 ) || @@ -140,10 +140,10 @@ static int can_catch_player( const std::string &monster_type, const tripoint &di get_map().clear_traps(); test_monster.set_dest( test_player.get_location() ); test_monster.mod_moves( monster_speed ); - while( test_monster.moves >= 0 ) { - const int moves_before = test_monster.moves; + while( test_monster.get_moves() >= 0 ) { + const int moves_before = test_monster.get_moves(); test_monster.move(); - tracker.push_back( {'m', moves_before - test_monster.moves, + tracker.push_back( {'m', moves_before - test_monster.get_moves(), rl_dist( test_monster.pos(), test_player.pos() ), test_monster.pos() } ); diff --git a/tests/move_cost_test.cpp b/tests/move_cost_test.cpp index 5a630a42f9563..52d9a5d661a6e 100644 --- a/tests/move_cost_test.cpp +++ b/tests/move_cost_test.cpp @@ -220,33 +220,33 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) clear_avatar(); clear_map(); u.wear_item( item( "sneakers" ) ); - u.moves = 0; + u.set_moves( 0 ); WHEN( "is walking" ) { u.set_movement_mode( move_mode_walk ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -100 ); + CHECK( u.get_moves() == -100 ); } } WHEN( "is crouching" ) { u.set_movement_mode( move_mode_crouch ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -200 ); + CHECK( u.get_moves() == -200 ); } } WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 600 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -600 ); + CHECK( u.get_moves() == -600 ); } } } @@ -255,33 +255,33 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) clear_avatar(); u.wear_item( item( "sneakers" ) ); u.wear_item( item( "test_briefcase" ) ); - u.moves = 0; + u.set_moves( 0 ); WHEN( "is walking" ) { u.set_movement_mode( move_mode_walk ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -100 ); + CHECK( u.get_moves() == -100 ); } } WHEN( "is crouching" ) { u.set_movement_mode( move_mode_crouch ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -200 ); + CHECK( u.get_moves() == -200 ); } } WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 660 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -660 ); + CHECK( u.get_moves() == -660 ); } } } @@ -289,33 +289,33 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) avatar &u = get_avatar(); clear_avatar(); u.wear_item( item( "test_hazmat_suit" ) ); - u.moves = 0; + u.set_moves( 0 ); WHEN( "is walking" ) { u.set_movement_mode( move_mode_walk ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 154 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -154 ); + CHECK( u.get_moves() == -154 ); } } WHEN( "is crouching" ) { u.set_movement_mode( move_mode_crouch ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 309 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -309 ); + CHECK( u.get_moves() == -309 ); } } WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 932 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -932 ); + CHECK( u.get_moves() == -932 ); } } } @@ -325,33 +325,33 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) clear_avatar(); u.wear_item( item( "sneakers" ) ); u.set_part_hp_cur( body_part_arm_l, 10 ); - u.moves = 0; + u.set_moves( 0 ); WHEN( "is walking" ) { u.set_movement_mode( move_mode_walk ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -100 ); + CHECK( u.get_moves() == -100 ); } } WHEN( "is crouching" ) { u.set_movement_mode( move_mode_crouch ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -200 ); + CHECK( u.get_moves() == -200 ); } } WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 803 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -803 ); + CHECK( u.get_moves() == -803 ); } } } @@ -361,33 +361,33 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) u.wear_item( item( "sneakers" ) ); u.wear_item( item( "test_briefcase" ) ); u.set_part_hp_cur( body_part_arm_l, 10 ); - u.moves = 0; + u.set_moves( 0 ); WHEN( "is walking" ) { u.set_movement_mode( move_mode_walk ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 100 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -100 ); + CHECK( u.get_moves() == -100 ); } } WHEN( "is crouching" ) { u.set_movement_mode( move_mode_crouch ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 200 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -200 ); + CHECK( u.get_moves() == -200 ); } } WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 818 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -818 ); + CHECK( u.get_moves() == -818 ); } } } @@ -396,33 +396,33 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) clear_avatar(); u.wear_item( item( "test_hazmat_suit" ) ); u.set_part_hp_cur( body_part_arm_l, 10 ); - u.moves = 0; + u.set_moves( 0 ); WHEN( "is walking" ) { u.set_movement_mode( move_mode_walk ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 154 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -154 ); + CHECK( u.get_moves() == -154 ); } } WHEN( "is crouching" ) { u.set_movement_mode( move_mode_crouch ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "no crawling modifier" ) { CHECK( u.run_cost( 100 ) == 309 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -309 ); + CHECK( u.get_moves() == -309 ); } } WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1246 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -1246 ); + CHECK( u.get_moves() == -1246 ); } } } @@ -433,16 +433,16 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) u.wear_item( item( "sneakers" ) ); u.set_part_hp_cur( body_part_leg_l, 0 ); u.set_part_hp_cur( body_part_leg_r, 0 ); - u.moves = 0; + u.set_moves( 0 ); // Can't walk or couch w/ broken legs WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1000 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -1000 ); + CHECK( u.get_moves() == -1000 ); } } } @@ -453,16 +453,16 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) u.wear_item( item( "test_briefcase" ) ); u.set_part_hp_cur( body_part_leg_l, 0 ); u.set_part_hp_cur( body_part_leg_r, 0 ); - u.moves = 0; + u.set_moves( 0 ); // Can't walk or couch w/ broken legs WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1179 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -1179 ); + CHECK( u.get_moves() == -1179 ); } } } @@ -472,16 +472,16 @@ TEST_CASE( "Crawl_score_effects_on_movement_cost", "[move_cost]" ) u.wear_item( item( "test_hazmat_suit" ) ); u.set_part_hp_cur( body_part_leg_l, 0 ); u.set_part_hp_cur( body_part_leg_r, 0 ); - u.moves = 0; + u.set_moves( 0 ); // Can't walk or couch w/ broken legs WHEN( "is prone" ) { u.set_movement_mode( move_mode_prone ); - REQUIRE( u.moves == 0 ); + REQUIRE( u.get_moves() == 0 ); THEN( "apply crawling modifier" ) { CHECK( u.run_cost( 100 ) == 1561 ); avatar_action::move( u, get_map(), point_south ); - CHECK( u.moves == -1561 ); + CHECK( u.get_moves() == -1561 ); } } } diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index 21174c1b1d89c..01faf5eaa674d 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -375,7 +375,7 @@ TEST_CASE( "npc-board-player-vehicle" ) int turns = 0; while( turns++ < 100 && companion->pos() != data.npc_target ) { - companion->moves = 100; + companion->set_moves( 100 ); /* Uncommment for extra debug info tripoint npc_pos = companion->pos(); optional_vpart_position vp = here.veh_at( npc_pos ); diff --git a/tests/player_activities_test.cpp b/tests/player_activities_test.cpp index adc5d28221cf4..70216112806e1 100644 --- a/tests/player_activities_test.cpp +++ b/tests/player_activities_test.cpp @@ -240,7 +240,7 @@ TEST_CASE( "safecracking", "[activity][safecracking]" ) REQUIRE( mp.furn( safe ) == f_safe_l ); WHEN( "player is safecracking" ) { - dummy.moves += dummy.get_speed(); + dummy.mod_moves( dummy.get_speed() ); for( int i = 0; i < 100; ++i ) { dummy.activity.do_turn( dummy ); } @@ -436,7 +436,7 @@ TEST_CASE( "shearing", "[activity][shearing][animals]" ) dummy.activity.start_or_resume( dummy, false ); REQUIRE( dummy.activity.id() == ACT_SHEARING ); - dummy.moves += dummy.get_speed(); + dummy.mod_moves( dummy.get_speed() ); for( int i = 0; i < 100; ++i ) { dummy.activity.do_turn( dummy ); } @@ -711,7 +711,7 @@ TEST_CASE( "boltcut", "[activity][boltcut]" ) AND_THEN( "player can resume the activity" ) { setup_activity( boltcutter_elec ); - dummy.moves = dummy.get_speed(); + dummy.mod_moves( dummy.get_speed() ); dummy.activity.do_turn( dummy ); CHECK( dummy.activity.id() == ACT_BOLTCUTTING ); CHECK( dummy.activity.moves_left < to_moves( furn_test_f_boltcut3->boltcut->duration() ) ); @@ -976,7 +976,7 @@ TEST_CASE( "hacksaw", "[activity][hacksaw]" ) AND_THEN( "player can resume the activity" ) { setup_activity( hacksaw_elec ); - dummy.moves = dummy.get_speed(); + dummy.mod_moves( dummy.get_speed() ); dummy.activity.do_turn( dummy ); CHECK( dummy.activity.id() == ACT_HACKSAW ); CHECK( dummy.activity.moves_left < to_moves( furn_test_f_hacksaw3->hacksaw->duration() ) ); @@ -1231,7 +1231,7 @@ TEST_CASE( "oxytorch", "[activity][oxytorch]" ) AND_THEN( "player can resume the activity" ) { setup_activity( welding_torch ); - dummy.moves = dummy.get_speed(); + dummy.mod_moves( dummy.get_speed() ); dummy.activity.do_turn( dummy ); CHECK( dummy.activity.id() == ACT_OXYTORCH ); CHECK( dummy.activity.moves_left < to_moves( furn_test_f_oxytorch3->oxytorch->duration() ) ); diff --git a/tests/player_helpers.cpp b/tests/player_helpers.cpp index ee06776363f78..4c124975d549c 100644 --- a/tests/player_helpers.cpp +++ b/tests/player_helpers.cpp @@ -221,8 +221,8 @@ void equip_shooter( npc &shooter, const std::vector &apparel ) void process_activity( Character &dummy ) { do { - dummy.moves += dummy.get_speed(); - while( dummy.moves > 0 && dummy.activity ) { + dummy.mod_moves( dummy.get_speed() ); + while( dummy.get_moves() > 0 && dummy.activity ) { dummy.activity.do_turn( dummy ); } } while( dummy.activity ); diff --git a/tests/ranged_balance_test.cpp b/tests/ranged_balance_test.cpp index 86514453b38c4..6afc3f84ca172 100644 --- a/tests/ranged_balance_test.cpp +++ b/tests/ranged_balance_test.cpp @@ -125,7 +125,7 @@ static dispersion_sources get_dispersion( npc &shooter, const int aim_time, int item_location gun = shooter.get_wielded_item(); dispersion_sources dispersion = shooter.get_weapon_dispersion( *gun ); - shooter.moves = aim_time; + shooter.set_moves( aim_time ); shooter.recoil = MAX_RECOIL; // Aim as well as possible within the provided time. shooter.aim( Target_attributes( range, 0.5, 0.0f, true ) ); diff --git a/tests/reload_time_test.cpp b/tests/reload_time_test.cpp index 6f8a7a348a693..8284a7c584ac9 100644 --- a/tests/reload_time_test.cpp +++ b/tests/reload_time_test.cpp @@ -36,9 +36,9 @@ static void check_reload_time( const std::string &weapon, const std::string &amm CAPTURE( shooter.item_handling_cost( *shooter.used_weapon(), true, 0 ) ); CAPTURE( shooter.used_weapon()->get_reload_time() ); aim_activity_actor act = aim_activity_actor::use_wielded(); - int moves_before = shooter.moves; + int moves_before = shooter.get_moves(); REQUIRE( act.load_RAS_weapon() ); - int moves_after = shooter.moves; + int moves_after = shooter.get_moves(); int spent_moves = moves_before - moves_after; int expected_upper = expected_moves * 1.05; int expected_lower = expected_moves * 0.95; diff --git a/tests/throwing_test.cpp b/tests/throwing_test.cpp index d3755bbc216c3..2f0c706f9122a 100644 --- a/tests/throwing_test.cpp +++ b/tests/throwing_test.cpp @@ -258,7 +258,7 @@ static void test_player_kills_monster( ++turns; mon.process_turn(); mon.set_dest( you.get_location() ); - while( mon.moves > 0 ) { + while( mon.get_moves() > 0 ) { mon.move(); } diff --git a/tests/unload_naked_test.cpp b/tests/unload_naked_test.cpp index 74ba9fd55c076..d9985e3b8b136 100644 --- a/tests/unload_naked_test.cpp +++ b/tests/unload_naked_test.cpp @@ -38,7 +38,7 @@ TEST_CASE( "unload_revolver_naked_one_bullet", "[unload][nonmagzine]" ) // Unload weapon item_location revo_loc = player_character.get_wielded_item(); - player_character.moves = 100; + player_character.set_moves( 100 ); REQUIRE( player_character.unload( revo_loc ) ); player_character.activity.do_turn( player_character ); @@ -73,10 +73,10 @@ TEST_CASE( "unload_revolver_naked_fully_loaded", "[unload][nonmagzine]" ) // Unload weapon item_location revo_loc = player_character.get_wielded_item(); - player_character.moves = 100; + player_character.set_moves( 100 ); REQUIRE( player_character.unload( revo_loc ) ); while( player_character.activity ) { - player_character.moves = 100; + player_character.set_moves( 100 ); player_character.activity.do_turn( player_character ); } diff --git a/tests/vehicle_part_test.cpp b/tests/vehicle_part_test.cpp index 8e9cfa658e50a..97c0d5ff26791 100644 --- a/tests/vehicle_part_test.cpp +++ b/tests/vehicle_part_test.cpp @@ -183,7 +183,7 @@ static void test_craft_via_rig( const std::vector &items, int give_battery REQUIRE( character.activity ); REQUIRE( character.activity.id() == ACT_CRAFT ); while( character.activity.id() == ACT_CRAFT ) { - character.moves = 100; + character.set_moves( 100 ); character.activity.do_turn( character ); } diff --git a/tests/water_movement_test.cpp b/tests/water_movement_test.cpp index 96cd80998b7a9..25da7932211b5 100644 --- a/tests/water_movement_test.cpp +++ b/tests/water_movement_test.cpp @@ -267,7 +267,7 @@ static int swimming_steps( avatar &swimmer ) constexpr int STOP_STEPS = 9000; int last_moves = swimmer.get_speed(); int last_stamina = swimmer.get_stamina_max(); - swimmer.moves = last_moves; + swimmer.set_moves( last_moves ); swimmer.set_stamina( last_stamina ); while( swimmer.get_stamina() > 0 && !swimmer.has_effect( effect_winded ) && steps < STOP_STEPS ) { if( steps % 2 == 0 ) { @@ -278,8 +278,8 @@ static int swimming_steps( avatar &swimmer ) REQUIRE( avatar_action::move( swimmer, here, tripoint_west ) ); } ++steps; - REQUIRE( swimmer.moves < last_moves ); - if( swimmer.moves <= 0 ) { + REQUIRE( swimmer.get_moves() < last_moves ); + if( swimmer.get_moves() <= 0 ) { calendar::turn += 1_turns; const int stamina_cost = last_stamina - swimmer.get_stamina(); REQUIRE( stamina_cost > 0 ); @@ -287,7 +287,7 @@ static int swimming_steps( avatar &swimmer ) swimmer.process_turn(); last_stamina = swimmer.get_stamina(); } - last_moves = swimmer.moves; + last_moves = swimmer.get_moves(); } swimmer.setpos( left ); return steps; diff --git a/tests/wield_times_test.cpp b/tests/wield_times_test.cpp index a9793d40c43e2..78384e71d0f60 100644 --- a/tests/wield_times_test.cpp +++ b/tests/wield_times_test.cpp @@ -35,10 +35,10 @@ static void wield_check_from_inv( avatar &guy, const itype_id &item_name, const CAPTURE( item_loc->typeId() ); guy.set_moves( 1000 ); - const int old_moves = guy.moves; + const int old_moves = guy.get_moves(); REQUIRE( guy.wield( item_loc ) ); CAPTURE( guy.get_wielded_item()->typeId() ); - int move_cost = old_moves - guy.moves; + int move_cost = old_moves - guy.get_moves(); INFO( "Strength:" << guy.get_str() ); CHECK( Approx( expected_moves ).epsilon( 0.1f ) == move_cost );