diff --git a/src/bionics.cpp b/src/bionics.cpp index 588dfdf2f1541..056a871b2ae90 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -244,7 +244,7 @@ void npc::check_or_use_weapon_cbm( const bionic_id &cbm_id ) bool player::activate_bionic( int b, bool eff_only ) { bionic &bio = ( *my_bionics )[b]; - + const bool mounted = is_mounted(); if( bio.incapacitated_time > 0_turns ) { add_msg( m_info, _( "Your %s is shorting out and can't be activated." ), bionics[bio.id].name ); @@ -356,6 +356,10 @@ bool player::activate_bionic( int b, bool eff_only ) mod_moves( -100 ); } else if( bio.id == "bio_time_freeze" ) { + if( mounted ) { + add_msg_if_player( m_info, _( "You cannot activate that while mounted." ) ); + return false; + } mod_moves( power_level ); power_level = 0; add_msg_if_player( m_good, _( "Your speed suddenly increases!" ) ); @@ -371,6 +375,10 @@ bool player::activate_bionic( int b, bool eff_only ) add_effect( effect_teleglow, rng( 5_minutes, 40_minutes ) ); } } else if( bio.id == "bio_teleport" ) { + if( mounted ) { + add_msg_if_player( m_info, _( "You cannot activate that while mounted." ) ); + return false; + } g->teleport(); add_effect( effect_teleglow, 30_minutes ); mod_moves( -100 ); @@ -1512,6 +1520,9 @@ bool player::can_install_bionics( const itype &type, player &installer, bool aut debugmsg( "Tried to install NULL bionic" ); return false; } + if( is_mounted() ) { + return false; + } int assist_bonus = installer.get_effect_int( effect_assisted ); const bionic_id &bioid = type.bionic->id; diff --git a/src/handle_action.cpp b/src/handle_action.cpp index fd6ce6b14cd5c..78a74187777c2 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -883,7 +883,10 @@ static void wait() static void sleep() { player &u = g->u; - + if( u.is_mounted() ) { + u.add_msg_if_player( m_info, _( "You cannot sleep while mounted." ) ); + return; + } uilist as_m; as_m.text = _( "Are you sure you want to sleep?" ); // (Y)es/(S)ave before sleeping/(N)o diff --git a/src/iuse.cpp b/src/iuse.cpp index f7ca0df36ec73..435fef93aad0a 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -840,7 +840,10 @@ int iuse::meditate( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p->has_trait( trait_SPIRITUAL ) ) { const int moves = to_moves( 20_minutes ); p->assign_activity( activity_id( "ACT_MEDITATE" ), moves ); @@ -1680,10 +1683,13 @@ static bool good_fishing_spot( tripoint pos ) int iuse::fishing_rod( player *p, item *it, bool, const tripoint & ) { if( p->is_npc() ) { - // Long actions - NPCs don't like those yet + // Long actions - NPCs don't like those yet. + return 0; + } + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); return 0; } - const cata::optional pnt_ = choose_adjacent( _( "Fish where?" ) ); if( !pnt_ ) { return 0; @@ -1717,7 +1723,10 @@ int iuse::fish_trap( player *p, item *it, bool t, const tripoint &pos ) it->charges = 0; return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p->is_underwater() ) { p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; @@ -1972,12 +1981,12 @@ int iuse::pack_cbm( player *p, item *it, bool, const tripoint & ) const int success = p->get_skill_level( skill_firstaid ) - rng( 0, 6 ); if( success > 0 ) { - add_msg( m_info, _( "You carefully prepare the CBM for sterilization." ) ); + p->add_msg_if_player( m_info, _( "You carefully prepare the CBM for sterilization." ) ); } else { bionic.get_item()->set_flag( "PACKED_FAULTY" ); - add_msg( m_info, _( "You put the CBM in the pouch and close it." ) ); + p->add_msg_if_player( m_info, _( "You put the CBM in the pouch and close it." ) ); if( success == 0 ) { - add_msg( m_bad, _( "You're not sure about the quality of your work." ) ); + p->add_msg_if_player( m_info, _( "You're not sure about the quality of your work." ) ); } } @@ -2038,6 +2047,10 @@ static int cauterize_elec( player &p, item &it ) int iuse::water_purifier( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } auto obj = g->inv_map_splice( []( const item & e ) { return !e.contents.empty() && e.contents.front().typeId() == "water"; }, _( "Purify what?" ), 1, _( "You don't have water to purify." ) ); @@ -2084,7 +2097,7 @@ int iuse::directional_antenna( player *p, item *it, bool, const tripoint & ) // Find the radio station its tuned to (if any) const auto tref = overmap_buffer.find_radio_station( radio.frequency ); if( !tref ) { - add_msg( m_info, _( "You can't find the direction if your radio isn't tuned." ) ); + p->add_msg_if_player( m_info, _( "You can't find the direction if your radio isn't tuned." ) ); return 0; } // Report direction. @@ -2282,6 +2295,10 @@ static bool pry_nails( player &p, const ter_id &type, const tripoint &pnt ) int iuse::hammer( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } // If anyone other than the player wants to use one of these, // they're going to need to figure out how to aim it. const cata::optional pnt_ = choose_adjacent( _( "Pry where?" ) ); @@ -2301,6 +2318,10 @@ int iuse::hammer( player *p, item *it, bool, const tripoint & ) int iuse::crowbar( player *p, item *it, bool, const tripoint &pos ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } // TODO: Make this 3D now that NPCs get to use items tripoint pnt = pos; if( pos == p->pos() ) { @@ -2456,7 +2477,10 @@ int iuse::makemound( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Till soil where?" ) ); if( !pnt_ ) { return 0; @@ -2464,7 +2488,8 @@ int iuse::makemound( player *p, item *it, bool t, const tripoint & ) const tripoint pnt = *pnt_; if( pnt == p->pos() ) { - add_msg( m_info, _( "You think about jumping on a shovel, but then change up your mind." ) ); + p->add_msg_if_player( m_info, + _( "You think about jumping on a shovel, but then change up your mind." ) ); return 0; } @@ -2615,7 +2640,10 @@ int iuse::dig( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const tripoint dig_point = p->pos(); const bool can_dig_here = g->m.has_flag( "DIGGABLE", dig_point ) && @@ -2707,7 +2735,10 @@ int iuse::dig_channel( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const tripoint dig_point = p->pos(); tripoint north = dig_point + point_north; @@ -2769,7 +2800,10 @@ int iuse::fill_pit( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Fill which pit or mound?" ) ); if( !pnt_ ) { return 0; @@ -2777,7 +2811,7 @@ int iuse::fill_pit( player *p, item *it, bool t, const tripoint & ) const tripoint pnt = *pnt_; if( pnt == p->pos() ) { - add_msg( m_info, _( "You decide not to bury yourself that early." ) ); + p->add_msg_if_player( m_info, _( "You decide not to bury yourself that early." ) ); return 0; } @@ -2816,6 +2850,10 @@ int iuse::fill_pit( player *p, item *it, bool t, const tripoint & ) int iuse::clear_rubble( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Clear rubble where?" ) ); if( !pnt_ ) { return 0; @@ -2845,6 +2883,10 @@ void act_vehicle_siphon( vehicle * ); // veh_interact.cpp int iuse::siphon( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Siphon from where?" ) ); if( !pnt_ ) { return 0; @@ -3065,7 +3107,10 @@ int iuse::jackhammer( player *p, item *it, bool, const tripoint &pos ) if( !p->has_enough_charges( *it, false ) ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p->is_underwater() ) { p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; @@ -3117,7 +3162,10 @@ int iuse::pickaxe( player *p, item *it, bool, const tripoint &pos ) // Long action return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p->is_underwater() ) { p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; @@ -3169,7 +3217,10 @@ int iuse::burrow( player *p, item *it, bool, const tripoint &pos ) // Long action return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p->is_underwater() ) { p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; @@ -3275,7 +3326,10 @@ int iuse::teleport( player *p, item *it, bool, const tripoint & ) // That would be evil return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( !it->ammo_sufficient() ) { return 0; } @@ -3366,7 +3420,7 @@ int iuse::granade( player *p, item *it, bool, const tripoint & ) return it->type->charges_to_use(); } -int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) +int iuse::granade_act( player *p, item *it, bool t, const tripoint &pos ) { if( pos.x == -999 || pos.y == -999 ) { return 0; @@ -3375,8 +3429,8 @@ int iuse::granade_act( player *, item *it, bool t, const tripoint &pos ) // Vol 0 = only heard if you hold it sounds::sound( pos, 0, sounds::sound_t::speech, _( "Merged!" ), true, "speech", it->typeId() ); } else if( it->charges > 0 ) { - add_msg( m_info, _( "You've already pulled the %s's pin, try throwing it instead." ), - it->tname() ); + p->add_msg_if_player( m_info, _( "You've already pulled the %s's pin, try throwing it instead." ), + it->tname() ); return 0; } else { // When that timer runs down... int explosion_radius = 3; @@ -3587,7 +3641,8 @@ int iuse::molotov_lit( player *p, item *it, bool t, const tripoint &pos ) if( pos.x == -999 || pos.y == -999 ) { return 0; } else if( it->charges > 0 ) { - add_msg( m_info, _( "You've already lit the %s, try throwing it instead." ), it->tname() ); + p->add_msg_if_player( m_info, _( "You've already lit the %s, try throwing it instead." ), + it->tname() ); return 0; } else if( p->has_item( *it ) && it->charges == 0 ) { it->charges += 1; @@ -3664,7 +3719,7 @@ int iuse::firecracker( player *p, item *it, bool, const tripoint & ) return it->type->charges_to_use(); } -int iuse::firecracker_act( player *, item *it, bool t, const tripoint &pos ) +int iuse::firecracker_act( player *p, item *it, bool t, const tripoint &pos ) { if( pos.x == -999 || pos.y == -999 ) { return 0; @@ -3672,7 +3727,8 @@ int iuse::firecracker_act( player *, item *it, bool t, const tripoint &pos ) if( t ) { // Simple timer effects sounds::sound( pos, 0, sounds::sound_t::alarm, _( "ssss..." ), true, "misc", "lit_fuse" ); } else if( it->charges > 0 ) { - add_msg( m_info, _( "You've already lit the %s, try throwing it instead." ), it->tname() ); + p->add_msg_if_player( m_info, _( "You've already lit the %s, try throwing it instead." ), + it->tname() ); return 0; } else { // When that timer runs down... sounds::sound( pos, 20, sounds::sound_t::combat, _( "Bang!" ), true, "explosion", "small" ); @@ -3750,6 +3806,10 @@ int iuse::portal( player *p, item *it, bool, const tripoint & ) if( !it->ammo_sufficient() ) { return 0; } + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } tripoint t( p->posx() + rng( -2, 2 ), p->posy() + rng( -2, 2 ), p->posz() ); g->m.trap_set( t, tr_portal ); return it->type->charges_to_use(); @@ -3998,6 +4058,10 @@ int iuse::mp3_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::rpgdie( player *you, item *die, bool, const tripoint & ) { + if( you->is_mounted() ) { + you->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } int num_sides = die->get_var( "die_num_sides", 0 ); if( num_sides == 0 ) { const std::vector sides_options = { 4, 6, 8, 10, 12, 20, 50 }; @@ -4151,13 +4215,16 @@ int iuse::portable_game( player *p, item *it, bool, const tripoint & ) // Long action return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p->is_underwater() ) { p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } if( p->has_trait( trait_ILLITERATE ) ) { - add_msg( _( "You're illiterate!" ) ); + p->add_msg_if_player( m_info, _( "You're illiterate!" ) ); return 0; } else if( it->ammo_remaining() < 15 ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); @@ -4266,7 +4333,10 @@ int iuse::vibe( player *p, item *it, bool, const tripoint & ) // Also, that would be creepy as fuck, seriously return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do... that while mounted." ) ); + return 0; + } if( ( p->is_underwater() ) && ( !( ( p->has_trait( trait_GILLS ) ) || ( p->is_wearing( "rebreather_on" ) ) || ( p->is_wearing( "rebreather_xl_on" ) ) || ( p->is_wearing( "mask_h20survivor_on" ) ) ) ) ) { @@ -4355,7 +4425,10 @@ int iuse::blood_draw( player *p, item *it, bool, const tripoint & ) if( p->is_npc() ) { return 0; // No NPCs for now! } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( !it->contents.empty() ) { p->add_msg_if_player( m_info, _( "That %s is full!" ), it->tname() ); return 0; @@ -4416,6 +4489,10 @@ int iuse::blood_draw( player *p, item *it, bool, const tripoint & ) //This is just used for robofac_intercom_mission_2 int iuse::mind_splicer( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } for( auto &map_it : g->m.i_at( point( p->posx(), p->posy() ) ) ) { if( map_it.typeId() == "rmi2_corpse" && query_yn( _( "Use the mind splicer kit on the %s?" ), colorize( map_it.tname(), @@ -4443,6 +4520,10 @@ int iuse::mind_splicer( player *p, item *it, bool, const tripoint & ) void iuse::cut_log_into_planks( player &p ) { + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return; + } const int moves = to_moves( 20_minutes ); p.add_msg_if_player( _( "You cut the log into planks." ) ); @@ -4455,7 +4536,10 @@ int iuse::lumber( player *p, item *it, bool t, const tripoint & ) if( t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } // Check if player is standing on any lumber for( auto &i : g->m.i_at( p->pos() ) ) { if( i.typeId() == "log" ) { @@ -4471,7 +4555,7 @@ int iuse::lumber( player *p, item *it, bool t, const tripoint & ) item &cut = p->i_at( pos ); if( cut.is_null() ) { - add_msg( m_info, _( "You do not have that item!" ) ); + p->add_msg_if_player( m_info, _( "You do not have that item!" ) ); return 0; } p->i_rem( &cut ); @@ -4498,7 +4582,10 @@ int iuse::chop_tree( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Chop down which tree?" ) ); if( !pnt_ ) { return 0; @@ -4506,7 +4593,7 @@ int iuse::chop_tree( player *p, item *it, bool t, const tripoint & ) const tripoint pnt = *pnt_; if( pnt == p->pos() ) { - add_msg( m_info, _( "You're not stern enough to shave yourself with THIS." ) ); + p->add_msg_if_player( m_info, _( "You're not stern enough to shave yourself with THIS." ) ); return 0; } @@ -4515,7 +4602,7 @@ int iuse::chop_tree( player *p, item *it, bool t, const tripoint & ) if( g->m.has_flag( "TREE", pnt ) ) { moves = chop_moves( p, it ); } else { - add_msg( m_info, _( "You can't chop down that." ) ); + p->add_msg_if_player( m_info, _( "You can't chop down that." ) ); return 0; } const std::vector helpers = g->u.get_crafting_helpers(); @@ -4534,7 +4621,10 @@ int iuse::chop_logs( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Chop which tree trunk?" ) ); if( !pnt_ ) { return 0; @@ -4547,7 +4637,7 @@ int iuse::chop_logs( player *p, item *it, bool t, const tripoint & ) if( ter == t_trunk || ter == t_stump ) { moves = chop_moves( p, it ); } else { - add_msg( m_info, _( "You can't chop that." ) ); + p->add_msg_if_player( m_info, _( "You can't chop that." ) ); return 0; } const std::vector helpers = g->u.get_crafting_helpers(); @@ -4567,10 +4657,13 @@ int iuse::oxytorch( player *p, item *it, bool, const tripoint & ) // Long action return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } static const quality_id GLARE( "GLARE" ); if( !p->has_quality( GLARE, 2 ) ) { - add_msg( m_info, _( "You need welding goggles to do that." ) ); + p->add_msg_if_player( m_info, _( "You need welding goggles to do that." ) ); return 0; } @@ -4601,7 +4694,7 @@ int iuse::oxytorch( player *p, item *it, bool, const tripoint & ) ter == t_door_bar_locked || ter == t_door_metal_pickable ) { turns = to_turns( 15_seconds ); } else { - add_msg( m_info, _( "You can't cut that." ) ); + p->add_msg_if_player( m_info, _( "You can't cut that." ) ); return 0; } @@ -4609,7 +4702,7 @@ int iuse::oxytorch( player *p, item *it, bool, const tripoint & ) int moves = to_moves( time_duration::from_turns( turns ) ); if( charges > it->ammo_remaining() ) { - add_msg( m_info, _( "Your torch doesn't have enough acetylene to cut that." ) ); + p->add_msg_if_player( m_info, _( "Your torch doesn't have enough acetylene to cut that." ) ); return 0; } @@ -4628,7 +4721,10 @@ int iuse::hacksaw( player *p, item *it, bool t, const tripoint & ) if( !p || t ) { return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Cut up metal where?" ) ); if( !pnt_ ) { return 0; @@ -4637,7 +4733,7 @@ int iuse::hacksaw( player *p, item *it, bool t, const tripoint & ) if( pnt == p->pos() ) { add_msg( m_info, _( "Why would you do that?" ) ); - add_msg( m_info, _( "You're not even chained to a boiler." ) ); + p->add_msg_if_player( m_info, _( "You're not even chained to a boiler." ) ); return 0; } @@ -4654,7 +4750,7 @@ int iuse::hacksaw( player *p, item *it, bool t, const tripoint & ) } else if( ter == t_door_bar_c || ter == t_door_bar_locked || ter == t_bars ) { moves = to_moves( 15_minutes ); } else { - add_msg( m_info, _( "You can't cut that." ) ); + p->add_msg_if_player( m_info, _( "You can't cut that." ) ); return 0; } @@ -4667,6 +4763,10 @@ int iuse::hacksaw( player *p, item *it, bool t, const tripoint & ) int iuse::boltcutters( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Cut up metal where?" ) ); if( !pnt_ ) { return 0; @@ -4690,7 +4790,7 @@ int iuse::boltcutters( player *p, item *it, bool, const tripoint & ) "boltcutters" ); g->m.spawn_item( pnt, "wire", 20 ); } else { - add_msg( m_info, _( "You can't cut that." ) ); + p->add_msg_if_player( m_info, _( "You can't cut that." ) ); return 0; } return it->type->charges_to_use(); @@ -4698,6 +4798,10 @@ int iuse::boltcutters( player *p, item *it, bool, const tripoint & ) int iuse::mop( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Mop where?" ) ); if( !pnt_ ) { return 0; @@ -4710,13 +4814,13 @@ int iuse::mop( player *p, item *it, bool, const tripoint & ) return 0; } if( p->is_blind() ) { - add_msg( _( "You move the mop around, unsure whether it's doing any good." ) ); + p->add_msg_if_player( m_info, _( "You move the mop around, unsure whether it's doing any good." ) ); p->moves -= 15; if( one_in( 3 ) ) { g->m.mop_spills( pnt ); } } else if( g->m.mop_spills( pnt ) ) { - add_msg( _( "You mop up the spill." ) ); + p->add_msg_if_player( m_info, _( "You mop up the spill." ) ); p->moves -= 15; } else { p->add_msg_if_player( m_info, _( "There's nothing to mop there." ) ); @@ -5096,9 +5200,9 @@ int iuse::handle_ground_graffiti( player &p, item *it, const std::string &prefix move_cost = 3 * g->m.graffiti_at( where ).length(); g->m.delete_graffiti( where ); if( grave ) { - add_msg( _( "You blur the inscription on the grave." ) ); + p.add_msg_if_player( m_info, _( "You blur the inscription on the grave." ) ); } else { - add_msg( _( "You manage to get rid of the message on the ground." ) ); + p.add_msg_if_player( m_info, _( "You manage to get rid of the message on the ground." ) ); } } else { add_msg( _( "There isn't anything to erase here." ) ); @@ -5107,9 +5211,9 @@ int iuse::handle_ground_graffiti( player &p, item *it, const std::string &prefix } else { g->m.set_graffiti( where, message ); if( grave ) { - add_msg( _( "You carve an inscription on the grave." ) ); + p.add_msg_if_player( m_info, _( "You carve an inscription on the grave." ) ); } else { - add_msg( _( "You write a message on the ground." ) ); + p.add_msg_if_player( m_info, _( "You write a message on the ground." ) ); } move_cost = 2 * message.length(); } @@ -5149,15 +5253,16 @@ static bool heat_item( player &p ) if( target.has_flag( "EATEN_COLD" ) ) { target.cold_up(); - add_msg( _( "You defrost the food, but don't heat it up, since you enjoy it cold." ) ); + p.add_msg_if_player( m_info, + _( "You defrost the food, but don't heat it up, since you enjoy it cold." ) ); } else { - add_msg( _( "You defrost and heat up the food." ) ); + p.add_msg_if_player( m_info, _( "You defrost and heat up the food." ) ); target.heat_up(); // x2 because we have to defrost and heat move_mod *= 2; } } else { - add_msg( _( "You heat up the food." ) ); + p.add_msg_if_player( m_info, _( "You heat up the food." ) ); target.heat_up(); } p.mod_moves( -move_mod ); // time needed to actually heat up @@ -5190,6 +5295,10 @@ int iuse::heat_food( player *p, item *it, bool, const tripoint & ) int iuse::hotplate( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( it->typeId() != "atomic_coffeepot" && ( !it->units_sufficient( *p ) ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; @@ -5294,6 +5403,10 @@ int iuse::unfold_generic( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } vehicle *veh = g->m.add_vehicle( vproto_id( "none" ), p->pos().xy(), 0, 0, 0, false ); if( veh == nullptr ) { p->add_msg_if_player( m_info, _( "There's no room to unfold the %s." ), it->tname() ); @@ -5493,6 +5606,10 @@ int iuse::gun_repair( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } /** @EFFECT_MECHANICS >1 allows gun repair */ if( p->get_skill_level( skill_mechanics ) < 2 ) { p->add_msg_if_player( m_info, _( "You need a mechanics skill of 2 to use this repair kit." ) ); @@ -5631,8 +5748,12 @@ int iuse::misc_repair( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p->fine_detail_vision_mod() > 4 ) { - add_msg( m_info, _( "You can't see to repair!" ) ); + p->add_msg_if_player( m_info, _( "You can't see to repair!" ) ); return 0; } /** @EFFECT_FABRICATION >0 allows use of repair kit */ @@ -5745,7 +5866,8 @@ int iuse::robotcontrol( player *p, item *it, bool, const tripoint & ) if( p->has_trait( trait_HYPEROPIC ) && !p->worn_with_flag( "FIX_FARSIGHT" ) && !p->has_effect( effect_contacts ) && !p->has_bionic( bionic_id( "bio_eye_optic" ) ) ) { - add_msg( m_info, _( "You'll need to put on reading glasses before you can see the screen." ) ); + p->add_msg_if_player( m_info, + _( "You'll need to put on reading glasses before you can see the screen." ) ); return 0; } @@ -6096,7 +6218,9 @@ int iuse::einktabletpc( player *p, item *it, bool t, const tripoint &pos ) } return 0; - + } else if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; } else if( !p->is_npc() ) { enum { @@ -6108,12 +6232,13 @@ int iuse::einktabletpc( player *p, item *it, bool t, const tripoint &pos ) return 0; } if( p->has_trait( trait_ILLITERATE ) ) { - add_msg( m_info, _( "You cannot read a computer screen." ) ); + p->add_msg_if_player( m_info, _( "You cannot read a computer screen." ) ); return 0; } if( p->has_trait( trait_HYPEROPIC ) && !p->worn_with_flag( "FIX_FARSIGHT" ) && !p->has_effect( effect_contacts ) && !p->has_bionic( bionic_id( "bio_eye_optic" ) ) ) { - add_msg( m_info, _( "You'll need to put on reading glasses before you can see the screen." ) ); + p->add_msg_if_player( m_info, + _( "You'll need to put on reading glasses before you can see the screen." ) ); return 0; } @@ -7494,6 +7619,7 @@ int iuse::camera( player *p, item *it, bool, const tripoint & ) int iuse::ehandcuffs( player *p, item *it, bool t, const tripoint &pos ) { + if( t ) { if( g->m.has_flag( "SWIMMABLE", pos.xy() ) ) { @@ -7587,7 +7713,7 @@ int iuse::ehandcuffs( player *p, item *it, bool t, const tripoint &pos ) return it->type->charges_to_use(); } -int iuse::foodperson( player *, item *it, bool t, const tripoint &pos ) +int iuse::foodperson( player *p, item *it, bool t, const tripoint &pos ) { if( t ) { if( calendar::once_every( 1_minutes ) ) { @@ -7601,7 +7727,8 @@ int iuse::foodperson( player *, item *it, bool t, const tripoint &pos ) time_duration shift = time_duration::from_turns( it->magazine_current()->ammo_remaining() * it->type->tool->turns_per_charge ); - add_msg( m_info, _( "Your HUD lights-up: \"Your shift ends in %s\"." ), to_string( shift ) ); + p->add_msg_if_player( m_info, _( "Your HUD lights-up: \"Your shift ends in %s\"." ), + to_string( shift ) ); return 0; } @@ -8023,7 +8150,7 @@ static bool multicooker_hallu( player &p ) m->add_effect( effect_run, 1_turns, num_bp, true ); } } else { - add_msg( m_bad, _( "You're surrounded by aggressive multi-cookers!" ) ); + p.add_msg_if_player( m_info, _( "You're surrounded by aggressive multi-cookers!" ) ); for( auto &point : points ) { if( monster *const m = g->summon_mon( mon_hallu_multicooker, point ) ) { @@ -8138,7 +8265,6 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) { static const std::set multicooked_subcats = { "CSC_FOOD_MEAT", "CSC_FOOD_VEGGI", "CSC_FOOD_PASTA" }; static const int charges_to_start = 50; - if( t ) { if( !it->units_sufficient( *p ) ) { it->active = false; @@ -8192,7 +8318,8 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) } if( p->has_trait( trait_ILLITERATE ) ) { - add_msg( m_info, _( "You cannot read, and don't understand the screen or the buttons!" ) ); + p->add_msg_if_player( m_info, + _( "You cannot read, and don't understand the screen or the buttons!" ) ); return 0; } @@ -8204,7 +8331,8 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) if( p->has_trait( trait_HYPEROPIC ) && !p->worn_with_flag( "FIX_FARSIGHT" ) && !p->has_effect( effect_contacts ) ) { - add_msg( m_info, _( "You'll need to put on reading glasses before you can see the screen." ) ); + p->add_msg_if_player( m_info, + _( "You'll need to put on reading glasses before you can see the screen." ) ); return 0; } @@ -8372,7 +8500,7 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) if( mc_upgrade == choice ) { if( !p->has_morale_to_craft() ) { - add_msg( m_info, _( "Your morale is too low to craft..." ) ); + p->add_msg_if_player( m_info, _( "Your morale is too low to craft..." ) ); return 0; } @@ -8619,6 +8747,10 @@ int iuse::cable_attach( player *p, item *it, bool, const tripoint & ) int iuse::shavekit( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( !it->ammo_sufficient() ) { p->add_msg_if_player( _( "You need soap to use this." ) ); } else { @@ -8630,6 +8762,10 @@ int iuse::shavekit( player *p, item *it, bool, const tripoint & ) int iuse::hairkit( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const int moves = to_moves( 30_minutes ); p->assign_activity( activity_id( "ACT_HAIRCUT" ), moves ); return it->type->charges_to_use(); @@ -8732,6 +8868,10 @@ int iuse::directional_hologram( player *p, item *it, bool, const tripoint &pos ) int iuse::capture_monster_veh( player *p, item *it, bool, const tripoint &pos ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( !it->has_flag( "VEHICLE" ) ) { p->add_msg_if_player( m_info, _( "The %s must be installed in a vehicle before being loaded." ), it->tname() ); @@ -8801,6 +8941,10 @@ int item::contain_monster( const tripoint &target ) int iuse::capture_monster_act( player *p, item *it, bool, const tripoint &pos ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot capture a creature mounted." ) ); + return 0; + } if( it->has_var( "contained_name" ) ) { tripoint target; if( g->is_empty( pos ) ) { @@ -8890,7 +9034,10 @@ int iuse::ladder( player *p, item *, bool, const tripoint & ) debugmsg( "Ladder can't be used in non-z-level mode" ); return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional pnt_ = choose_adjacent( _( "Put the ladder where?" ) ); if( !pnt_ ) { return 0; @@ -8922,7 +9069,10 @@ int iuse::wash_soft_items( player *p, item *, bool, const tripoint & ) p->add_msg_if_player( _( "You can't see to do that!" ) ); return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } // Check that player isn't over volume limit as this might cause it to break... this is a hack. // TODO: find a better solution. if( p->volume_capacity() < p->volume_carried() ) { @@ -8940,7 +9090,10 @@ int iuse::wash_hard_items( player *p, item *, bool, const tripoint & ) p->add_msg_if_player( _( "You can't see to do that!" ) ); return 0; } - + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } // Check that player isn't over volume limit as this might cause it to break... this is a hack. // TODO: find a better solution. if( p->volume_capacity() < p->volume_carried() ) { @@ -8972,6 +9125,10 @@ int iuse::wash_all_items( player *p, item *, bool, const tripoint & ) int iuse::wash_items( player *p, bool soft_items, bool hard_items ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } p->inv.restack( *p ); const inventory &crafting_inv = p->crafting_inventory(); @@ -9134,6 +9291,10 @@ int iuse::panacea( player *p, item *it, bool, const tripoint & ) int iuse::craft( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( !p->is_wielding( *it ) ) { if( !p->is_armed() || query_yn( "Wield the %s and start working?", it->tname() ) ) { if( !p->wield( *it ) ) { @@ -9178,6 +9339,10 @@ int iuse::craft( player *p, item *it, bool, const tripoint & ) int iuse::disassemble( player *p, item *it, bool, const tripoint & ) { + if( p->is_mounted() ) { + p->add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( !p->has_item( *it ) ) { return 0; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index bd3484c8c2295..210a2f63c427e 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -520,7 +520,10 @@ int unfold_vehicle_iuse::use( player &p, item &it, bool /*t*/, const tripoint &/ p.add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } - + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } for( const auto &tool : tools_needed ) { // Amount == -1 means need one, but don't consume it. if( !p.has_amount( tool.first, 1 ) ) { @@ -930,6 +933,11 @@ int pick_lock_actor::use( player &p, item &it, bool, const tripoint & ) const return 0; } + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } + std::set allowed_ter_id { t_chaingate_l, t_door_locked, @@ -966,6 +974,7 @@ int pick_lock_actor::use( player &p, item &it, bool, const tripoint & ) const if( !pnt_ ) { pnt_ = choose_adjacent( _( "Use your lockpick where?" ) ); } + if( !pnt_ ) { return 0; } @@ -1109,6 +1118,10 @@ void deploy_furn_actor::load( JsonObject &obj ) int deploy_furn_actor::use( player &p, item &it, bool, const tripoint &pos ) const { + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } tripoint pnt = pos; if( pos == p.pos() ) { if( const cata::optional pnt_ = choose_adjacent( _( "Deploy where?" ) ) ) { @@ -1771,7 +1784,10 @@ int cauterize_actor::use( player &p, item &it, bool t, const tripoint & ) const if( t ) { return 0; } - + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } bool has_disease = p.has_effect( effect_bite ) || p.has_effect( effect_bleed ); bool did_cauterize = false; @@ -1811,6 +1827,9 @@ ret_val cauterize_actor::can_use( const player &p, const item &it, bool, return ret_val::make_failure( _( "You are not bleeding or bitten, there is no need to cauterize yourself." ) ); } + if( p.is_mounted() ) { + return ret_val::make_failure( _( "You cannot cauterize while mounted." ) ); + } if( flame ) { if( !p.has_charges( "fire", 4 ) ) { @@ -1846,7 +1865,10 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const if( t ) { return 0; } - + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } auto items = g->m.i_at( point( p.posx(), p.posy() ) ); std::vector corpses; @@ -1965,7 +1987,9 @@ ret_val enzlave_actor::can_use( const player &p, const item &, bool, const return ret_val::make_failure( _( "You need at least %s 1." ), skill_survival->name() ); } - + if( p.is_mounted() ) { + return ret_val::make_failure( _( "You cannot do that while mounted." ) ); + } if( p.get_skill_level( skill_firstaid ) < 1 ) { //~ %s - name of the required skill. return ret_val::make_failure( _( "You need at least %s 1." ), @@ -2147,6 +2171,12 @@ void musical_instrument_actor::load( JsonObject &obj ) int musical_instrument_actor::use( player &p, item &it, bool t, const tripoint & ) const { + if( p.is_mounted() ) { + p.add_msg_player_or_npc( m_bad, _( "You can't play music while mounted." ), + _( " can't play music while mounted." ) ); + it.active = false; + return 0; + } if( p.is_underwater() ) { p.add_msg_player_or_npc( m_bad, _( "You can't play music underwater" ), @@ -2258,6 +2288,9 @@ ret_val musical_instrument_actor::can_use( const player &p, const item &, if( p.is_underwater() ) { return ret_val::make_failure( _( "You can't do that while underwater." ) ); } + if( p.is_mounted() ) { + return ret_val::make_failure( _( "You can't do that while mounted." ) ); + } return ret_val::make_success(); } @@ -2829,6 +2862,13 @@ bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool pr } return false; } + if( p.is_mounted() ) { + if( print_msg ) { + p.add_msg_player_or_npc( m_bad, _( "You can't do that while mounted." ), + _( " can't do that while mounted." ) ); + } + return false; + } if( p.fine_detail_vision_mod() > 4 ) { if( print_msg ) { p.add_msg_if_player( m_info, _( "You can't see to do that!" ) ); @@ -3393,7 +3433,10 @@ int heal_actor::use( player &p, item &it, bool, const tripoint &pos ) const p.add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } - + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You can't do that while mounted." ) ); + return 0; + } if( get_option( "FILTHY_WOUNDS" ) && it.is_filthy() ) { p.add_msg_if_player( m_info, _( "You can't use filthy items for healing." ) ); return 0; @@ -3861,6 +3904,10 @@ int place_trap_actor::use( player &p, item &it, bool, const tripoint & ) const p.add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; } + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You can't do that while mounted." ) ); + return 0; + } const cata::optional pos_ = choose_adjacent( string_format( _( "Place %s where?" ), it.tname() ) ); if( !pos_ ) { @@ -4021,7 +4068,9 @@ ret_val install_bionic_actor::can_use( const player &p, const item &it, bo if( !it.is_bionic() ) { return ret_val::make_failure(); } - + if( p.is_mounted() ) { + return ret_val::make_failure( _( "You can't install bionics while mounted." ) ); + } if( !get_option( "MANUAL_BIONIC_INSTALLATION" ) && !p.has_trait( trait_id( "DEBUG_BIONICS" ) ) ) { return ret_val::make_failure( _( "You can't self-install bionics." ) ); @@ -4272,7 +4321,10 @@ void deploy_tent_actor::load( JsonObject &obj ) int deploy_tent_actor::use( player &p, item &it, bool, const tripoint & ) const { int diam = 2 * radius + 1; - + if( p.is_mounted() ) { + p.add_msg_if_player( _( "You cannot do that while mounted." ) ); + return 0; + } const cata::optional dir = choose_direction( string_format( _( "Put up the %s where (%dx%d clear area)?" ), it.tname(), diam, diam ) ); if( !dir ) { @@ -4352,6 +4404,10 @@ void weigh_self_actor::info( const item &, std::vector &dump ) const int weigh_self_actor::use( player &p, item &, bool, const tripoint & ) const { + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot weigh yourself while mounted." ) ); + return 0; + } // this is a weight, either in kgs or in lbs. double weight = convert_weight( p.get_weight() ); if( weight > convert_weight( max_weight ) ) { @@ -4397,7 +4453,10 @@ int sew_advanced_actor::use( player &p, item &it, bool, const tripoint & ) const if( p.is_npc() ) { return 0; } - + if( p.is_mounted() ) { + p.add_msg_if_player( m_info, _( "You cannot do that while mounted." ) ); + return 0; + } if( p.is_underwater() ) { p.add_msg_if_player( m_info, _( "You can't do that while underwater." ) ); return 0; diff --git a/src/player.cpp b/src/player.cpp index 4b443834bd805..9bffa0e60c4fe 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1561,7 +1561,6 @@ int player::run_cost( int base_cost, bool diag ) const if( diag ) { movecost *= 0.7071f; // because everything here assumes 100 is base } - float stamina_modifier; const bool flatground = movecost < 105; // The "FLAT" tag includes soft surfaces, so not a good fit. const bool on_road = flatground && g->m.has_flag( "ROAD", pos() ); @@ -1661,19 +1660,17 @@ int player::run_cost( int base_cost, bool diag ) const } // Both walk and run speed drop to half their maximums as stamina approaches 0. // Convert stamina to a float first to allow for decimal place carrying - stamina_modifier = ( static_cast( stamina ) / get_stamina_max() + 1 ) / 2; - } else { - stamina_modifier = 1.0; - } + float stamina_modifier = ( static_cast( stamina ) / get_stamina_max() + 1 ) / 2; + if( move_mode == PMM_RUN && stamina > 0 ) { + // Rationale: Average running speed is 2x walking speed. (NOT sprinting) + stamina_modifier *= 2.0; + } + if( move_mode == PMM_CROUCH ) { + stamina_modifier *= 0.5; + } + movecost /= stamina_modifier; - if( move_mode == PMM_RUN && stamina > 0 ) { - // Rationale: Average running speed is 2x walking speed. (NOT sprinting) - stamina_modifier *= 2.0; - } - if( move_mode == PMM_CROUCH ) { - stamina_modifier *= 0.5; } - movecost /= stamina_modifier; if( diag ) { movecost *= M_SQRT2;