From 474b2dfd35fc72d076e5b86f7e7b09aff05972e6 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Sat, 14 Dec 2024 15:26:00 +0100 Subject: [PATCH] typified creature.h and monster.h --- src/activity_actor.cpp | 6 +- src/activity_handlers.cpp | 4 +- src/advanced_inv.cpp | 4 +- src/armor_layers.cpp | 2 +- src/avatar.cpp | 4 +- src/avatar_action.cpp | 2 +- src/ballistics.cpp | 2 +- src/bionics.cpp | 2 +- src/cata_tiles.cpp | 4 +- src/character.cpp | 90 ++++++++--------- src/character.h | 6 +- src/character_inventory.cpp | 2 +- src/computer_session.cpp | 14 ++- src/construction.cpp | 2 +- src/crafting.cpp | 4 +- src/creature.cpp | 69 ++++++------- src/creature.h | 19 ++-- src/debug_menu.cpp | 2 +- src/display.cpp | 2 +- src/do_turn.cpp | 8 +- src/faction.cpp | 11 +- src/game.cpp | 67 +++++++------ src/grab.cpp | 4 +- src/handle_action.cpp | 4 +- src/iexamine.cpp | 6 +- src/inventory_ui.cpp | 9 +- src/iuse.cpp | 24 ++--- src/iuse_actor.cpp | 8 +- src/lightmap.cpp | 11 +- src/magic_spell_effect.cpp | 6 +- src/map.cpp | 16 +-- src/map.h | 2 + src/mattack_actors.cpp | 24 ++--- src/melee.cpp | 35 +++---- src/monattack.cpp | 166 ++++++++++++++++--------------- src/mondeath.cpp | 2 +- src/mondefense.cpp | 6 +- src/monexamine.cpp | 2 +- src/monmove.cpp | 148 +++++++++++++-------------- src/monster.cpp | 44 ++++---- src/monster.h | 46 ++++----- src/npc.cpp | 8 +- src/npc_attack.cpp | 9 +- src/npcmove.cpp | 61 ++++++------ src/npctalk.cpp | 8 +- src/npctalk_funcs.cpp | 4 +- src/overmap.cpp | 2 +- src/player_hardcoded_effects.cpp | 10 +- src/ranged.cpp | 13 +-- src/sounds.cpp | 24 ++--- src/suffer.cpp | 3 +- src/timed_event.cpp | 3 +- src/trapfunc.cpp | 12 +-- tests/act_build_test.cpp | 26 ++--- tests/archery_damage_test.cpp | 2 +- tests/char_sight_test.cpp | 10 +- tests/coverage_test.cpp | 4 +- tests/crafting_test.cpp | 2 +- tests/eoc_test.cpp | 2 +- tests/explosion_balance_test.cpp | 2 +- tests/harvest_test.cpp | 2 +- tests/limb_test.cpp | 8 +- tests/melee_test.cpp | 6 +- tests/monster_attack_test.cpp | 4 +- tests/monster_test.cpp | 18 ++-- tests/npc_test.cpp | 4 +- tests/vehicle_fake_part_test.cpp | 2 +- tests/vehicle_ramp_test.cpp | 2 +- tests/vision_test.cpp | 2 +- tests/visitable_zone_test.cpp | 2 +- tests/weakpoint_test.cpp | 2 +- 71 files changed, 584 insertions(+), 562 deletions(-) diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 167802a92e286..4930e19c870ba 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -1721,9 +1721,9 @@ void glide_activity_actor::do_turn( player_activity &act, Character &you ) moved_tiles = 0; } you.mod_moves( -you.get_speed() * 0.5 ); - get_map().update_visibility_cache( you.pos_bub().z() ); - get_map().update_visibility_cache( you.pos_bub().x() ); - get_map().update_visibility_cache( you.pos_bub().y() ); + get_map().update_visibility_cache( you.posz() ); + get_map().update_visibility_cache( you.posx() ); + get_map().update_visibility_cache( you.posy() ); if( you.is_avatar() ) { g->update_map( you ); } diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 2924118de669c..0f7c025065b8e 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -3032,7 +3032,7 @@ void activity_handlers::find_mount_do_turn( player_activity *act, Character *you guy.revert_after_activity(); return; } - if( rl_dist( guy.pos(), mon->pos() ) <= 1 ) { + if( rl_dist( guy.pos_bub(), mon->pos_bub() ) <= 1 ) { if( mon->has_effect( effect_controlled ) ) { mon->remove_effect( effect_controlled ); } @@ -3835,7 +3835,7 @@ void activity_handlers::spellcasting_finish( player_activity *act, Character *yo } if( spell_being_cast.has_flag( spell_flag::VERBAL ) && !you->has_flag( json_flag_SILENT_SPELL ) ) { - sounds::sound( you->pos(), you->get_shout_volume() / 2, sounds::sound_t::speech, + sounds::sound( you->pos_bub(), you->get_shout_volume() / 2, sounds::sound_t::speech, _( "cast a spell" ), false ); } diff --git a/src/advanced_inv.cpp b/src/advanced_inv.cpp index 76a64104a1cd7..24745dab3edfb 100644 --- a/src/advanced_inv.cpp +++ b/src/advanced_inv.cpp @@ -752,7 +752,7 @@ void advanced_inventory::recalc_pane( side p ) // If container is no longer adjacent or on the player's z-level, nullify it. if( std::abs( offset.x() ) > 1 || std::abs( offset.y() ) > 1 || - player_character.pos_bub().z() != pane.container.pos_bub().z() ) { + player_character.posz() != pane.container.pos_bub().z() ) { pane.container = item_location::nowhere; pane.container_base_loc = NUM_AIM_LOCATIONS; @@ -2364,7 +2364,7 @@ void advanced_inventory::draw_minimap() } if( !invert_left || !invert_right ) { - player_character.draw( minimap, player_character.pos(), invert_left || invert_right ); + player_character.draw( minimap, player_character.pos_bub(), invert_left || invert_right ); } } diff --git a/src/armor_layers.cpp b/src/armor_layers.cpp index 1f901aa14a124..042f2d00a00c3 100644 --- a/src/armor_layers.cpp +++ b/src/armor_layers.cpp @@ -938,7 +938,7 @@ void outfit::sort_armor( Character &guy ) } } else { // Player is sorting NPC's armor here - if( rl_dist( player_character.pos(), guy.pos() ) > 1 ) { + if( rl_dist( player_character.pos_bub(), guy.pos_bub() ) > 1 ) { guy.add_msg_if_npc( m_bad, _( "%s is too far to sort armor." ), guy.get_name() ); return; } diff --git a/src/avatar.cpp b/src/avatar.cpp index 280a9c92b0f5b..41cf12f9e9e96 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -1276,7 +1276,7 @@ void avatar::rebuild_aim_cache() const } // some basic angle inclusion math, but also everything with 15 is still seen - if( rl_dist( tripoint_bub_ms( smx, smy, pos_bub().z() ), pos_bub() ) < 15 ) { + if( rl_dist( tripoint_bub_ms( smx, smy, posz() ), pos_bub() ) < 15 ) { aim_cache[smx][smy] = false; } else if( lower_bound > upper_bound ) { aim_cache[smx][smy] = !( current_angle >= lower_bound || @@ -1304,7 +1304,7 @@ void avatar::set_movement_mode( const move_mode_id &new_mode ) // crouching affects visibility //TODO: Replace with dirtying vision_transparency_cache get_map().set_transparency_cache_dirty( pos_bub() ); - get_map().set_seen_cache_dirty( pos_bub().z() ); + get_map().set_seen_cache_dirty( posz() ); recoil = MAX_RECOIL; } else { add_msg( new_mode->change_message( false, get_steed_type() ) ); diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 5e67aefeabb48..5fab32280086e 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -911,7 +911,7 @@ bool avatar_action::eat_here( avatar &you ) } } if( you.has_active_mutation( trait_GRAZER ) ) { - const ter_id &ter_underfoot = here.ter( you.pos() ); + const ter_id &ter_underfoot = here.ter( you.pos_bub() ); if( ter_underfoot == ter_t_grass_golf || ter_underfoot == ter_t_grass ) { add_msg( _( "This grass is too short to graze." ) ); return true; diff --git a/src/ballistics.cpp b/src/ballistics.cpp index 5f343fd1d6d78..46c87d0f39b80 100644 --- a/src/ballistics.cpp +++ b/src/ballistics.cpp @@ -554,7 +554,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, z.add_effect( effect_bounced, 1_turns ); projectile_attack( proj, tp, z.pos_bub(), dispersion, origin, in_veh ); sfx::play_variant_sound( "fire_gun", "bio_lightning_tail", - sfx::get_heard_volume( z.pos() ), sfx::get_heard_angle( z.pos() ) ); + sfx::get_heard_volume( z.pos_bub() ), sfx::get_heard_angle( z.pos() ) ); } } diff --git a/src/bionics.cpp b/src/bionics.cpp index 30b574514c60d..0ec63968d6e39 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -897,7 +897,7 @@ bool Character::activate_bionic( bionic &bio, bool eff_only, bool *close_bionics } else if( bio.id == bio_resonator ) { add_msg_activate(); //~Sound of a bionic sonic-resonator shaking the area - sounds::sound( pos(), 30, sounds::sound_t::combat, _( "VRRRRMP!" ), false, "bionic", + sounds::sound( pos_bub(), 30, sounds::sound_t::combat, _( "VRRRRMP!" ), false, "bionic", static_cast( bio_resonator ) ); for( const tripoint_bub_ms &bashpoint : here.points_in_radius( pos_bub(), 1 ) ) { here.bash( bashpoint, 110 ); diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 8d685d8f75d7a..bc8290aa1edde 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -4195,7 +4195,7 @@ bool cata_tiles::draw_critter_above( const tripoint &p, lit_level ll, int &heigh // Search for a creature above while( pcritter == nullptr && scan_p.z() <= OVERMAP_HEIGHT && !here.dont_draw_lower_floor( scan_p ) && - scan_p.z() - you.pos_bub().z() <= fov_3d_z_range ) { + scan_p.z() - you.posz() <= fov_3d_z_range ) { pcritter = get_creature_tracker().creature_at( scan_p, true ); scan_p.z()++; } @@ -4208,7 +4208,7 @@ bool cata_tiles::draw_critter_above( const tripoint &p, lit_level ll, int &heigh // Draw shadow if( draw_from_id_string( "shadow", TILE_CATEGORY::NONE, empty_string, p, - 0, 0, ll, false, height_3d ) && scan_p.z() - 1 > you.pos_bub().z() && you.sees( critter ) ) { + 0, 0, ll, false, height_3d ) && scan_p.z() - 1 > you.posz() && you.sees( critter ) ) { bool is_player = false; bool sees_player = false; diff --git a/src/character.cpp b/src/character.cpp index 566c5227dc157..b75b3250336a5 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -1632,7 +1632,7 @@ bool Character::check_outbounds_activity( const player_activity &act, bool check add_msg_debug( debugmode::DF_CHARACTER, "npc %s at pos %s, activity target is not inbounds at %s therefore " "activity was stashed", - disp_name(), pos().to_string_writable(), + disp_name(), pos_bub().to_string_writable(), act.placement.to_string_writable() ); return true; } @@ -1723,8 +1723,8 @@ bool Character::check_mount_will_move( const tripoint &dest_loc ) continue; } Attitude att = critter.attitude_to( *this ); - if( att == Attitude::HOSTILE && sees( critter ) && rl_dist( pos(), critter.pos() ) <= 15 && - rl_dist( dest_loc, critter.pos() ) < rl_dist( pos(), critter.pos() ) ) { + if( att == Attitude::HOSTILE && sees( critter ) && rl_dist( pos_bub(), critter.pos_bub() ) <= 15 && + rl_dist( dest_loc, critter.pos_bub().raw() ) < rl_dist( pos_bub(), critter.pos_bub() ) ) { add_msg_if_player( _( "You fail to budge your %s!" ), mounted_creature->get_name() ); return false; } @@ -1758,8 +1758,8 @@ bool Character::check_mount_is_spooked() double chance = 1.0; Attitude att = critter.attitude_to( *this ); // actually too close now - horse might spook. - if( att == Attitude::HOSTILE && sees( critter ) && rl_dist( pos(), critter.pos() ) <= 10 ) { - chance += 10 - rl_dist( pos(), critter.pos() ); + if( att == Attitude::HOSTILE && sees( critter ) && rl_dist( pos_bub(), critter.pos_bub() ) <= 10 ) { + chance += 10 - rl_dist( pos_bub(), critter.pos_bub() ); if( critter.get_size() >= mount_size ) { chance *= 2; } @@ -2042,7 +2042,7 @@ void Character::on_dodge( Creature *source, float difficulty, float training_lev martial_arts_data->ma_ondodge_effects( *this ); // For adjacent attackers check for techniques usable upon successful dodge - if( source && square_dist( pos(), source->pos() ) == 1 ) { + if( source && square_dist( pos_bub(), source->pos_bub() ) == 1 ) { matec_id tec = std::get<0>( pick_technique( *source, used_weapon(), false, true, false ) ); if( tec != tec_none && !is_dead_state() ) { @@ -2077,7 +2077,7 @@ bool Character::uncanny_dodge() if( !( can_dodge_bio || can_dodge_mut || can_dodge_both ) ) { return false; } - tripoint adjacent = adjacent_tile(); + tripoint_bub_ms adjacent{ adjacent_tile() }; if( can_dodge_both ) { mod_power_level( -trigger_cost / 2 ); @@ -2098,7 +2098,7 @@ bool Character::uncanny_dodge() if( in_vehicle && veh_part ) { here.unboard_vehicle( pos_bub() ); } - if( adjacent.x != posx() || adjacent.y != posy() ) { + if( adjacent.xy() != pos_bub().xy() ) { set_pos_only( adjacent ); //landed in a vehicle tile @@ -2313,11 +2313,11 @@ void Character::make_footstep_noise() const return; } if( is_mounted() ) { - sounds::sound( pos(), volume, sounds::sound_t::movement, + sounds::sound( pos_bub(), volume, sounds::sound_t::movement, mounted_creature.get()->type->get_footsteps(), false, "none", "none" ); } else { - sounds::sound( pos(), volume, sounds::sound_t::movement, _( "footsteps" ), true, + sounds::sound( pos_bub(), volume, sounds::sound_t::movement, _( "footsteps" ), true, "none", "none" ); // Sound of footsteps may awaken nearby monsters } sfx::do_footstep(); @@ -2330,7 +2330,7 @@ void Character::make_clatter_sound() const if( volume <= 0 ) { return; } - sounds::sound( pos(), volume, sounds::sound_t::movement, _( "clattering equipment" ), true, + sounds::sound( pos_bub(), volume, sounds::sound_t::movement, _( "clattering equipment" ), true, "none", "none" ); // Sound of footsteps may awaken nearby monsters } @@ -2878,8 +2878,8 @@ float Character::fine_detail_vision_mod( const tripoint &p ) const // Same calculation as above, but with a result 3 lower. float ambient_light{}; tripoint_bub_ms const check_p = p.is_invalid() ? pos_bub() : tripoint_bub_ms( p ); - tripoint const avatar_p = get_avatar().pos(); - if( is_avatar() || check_p.z() == avatar_p.z ) { + tripoint_bub_ms const avatar_p = get_avatar().pos_bub(); + if( is_avatar() || check_p.z() == avatar_p.z() ) { ambient_light = std::max( 1.0f, LIGHT_AMBIENT_LIT - get_map().ambient_light_at( check_p ) + 1.0f ); } else { @@ -3146,10 +3146,10 @@ void Character::on_move( const tripoint_abs_ms &old_pos ) Creature::on_move( old_pos ); // Ugly to compare a tripoint_bub_ms with a tripoint_abs_ms, but the 'z' component // is the same regardless of the x/y reference point. - if( this->pos_bub().z() != old_pos.z() ) { + if( this->posz() != old_pos.z() ) { // Make sure caches are rebuilt in a timely manner to ensure companions aren't // caught in the "dark" because the caches aren't updated on their next move. - get_map().build_map_cache( this->pos_bub().z() ); + get_map().build_map_cache( this->posz() ); } // In case we've moved out of range of lifting assist. if( using_lifting_assist ) { @@ -5696,7 +5696,7 @@ nc_color Character::symbol_color() const return cyan_background( basic ); } - const field &fields = get_map().field_at( pos() ); + const field &fields = get_map().field_at( pos_bub() ); // Priority: electricity, fire, acid, gases bool has_elec = false; @@ -7315,7 +7315,7 @@ void Character::cough( bool harmful, int loudness ) if( !is_npc() ) { add_msg( m_bad, _( "You cough heavily." ) ); } - sounds::sound( pos(), loudness, sounds::sound_t::speech, _( "a hacking cough." ), false, "misc", + sounds::sound( pos_bub(), loudness, sounds::sound_t::speech, _( "a hacking cough." ), false, "misc", "cough" ); mod_moves( -get_speed() * 0.8 ); @@ -7448,7 +7448,8 @@ void Character::shout( std::string msg, bool order ) add_msg_if_player( m_warning, _( "The sound of your voice is significantly muffled!" ) ); } - sounds::sound( pos(), noise, order ? sounds::sound_t::order : sounds::sound_t::alert, msg, false, + sounds::sound( pos_bub(), noise, order ? sounds::sound_t::order : sounds::sound_t::alert, msg, + false, "shout", shout ); } @@ -8192,7 +8193,7 @@ dealt_damage_instance Character::deal_damage( Creature *source, bodypart_id bp, int cut_dam = dealt_dams.type_damage( damage_cut ); if( source && has_flag( json_flag_ACIDBLOOD ) && !bp->has_flag( json_flag_BIONIC_LIMB ) && !one_in( 3 ) && - ( dam >= 4 || cut_dam > 0 ) && ( rl_dist( player_character.pos(), source->pos() ) <= 1 ) ) { + ( dam >= 4 || cut_dam > 0 ) && ( rl_dist( player_character.pos_bub(), source->pos_bub() ) <= 1 ) ) { if( is_avatar() ) { add_msg( m_good, _( "Your acidic blood splashes %s in mid-attack!" ), source->disp_name() ); @@ -8474,7 +8475,7 @@ void Character::spores() map &here = get_map(); fungal_effects fe; //~spore-release sound - sounds::sound( pos(), 10, sounds::sound_t::combat, _( "Pouf!" ), false, "misc", "puff" ); + sounds::sound( pos_bub(), 10, sounds::sound_t::combat, _( "Pouf!" ), false, "misc", "puff" ); for( const tripoint_bub_ms &sporep : here.points_in_radius( pos_bub(), 1 ) ) { if( sporep == pos_bub() ) { continue; @@ -8486,7 +8487,7 @@ void Character::spores() void Character::blossoms() { // Player blossoms are shorter-ranged, but you can fire much more frequently if you like. - sounds::sound( pos(), 10, sounds::sound_t::combat, _( "Pouf!" ), false, "misc", "puff" ); + sounds::sound( pos_bub(), 10, sounds::sound_t::combat, _( "Pouf!" ), false, "misc", "puff" ); map &here = get_map(); for( const tripoint_bub_ms &tmp : here.points_in_radius( pos_bub(), 2 ) ) { here.add_field( tmp, fd_fungal_haze, rng( 1, 2 ) ); @@ -10388,14 +10389,14 @@ void Character::place_corpse( const tripoint_abs_omt &om_target ) bool Character::is_visible_in_range( const Creature &critter, const int range ) const { - return sees( critter ) && rl_dist( pos(), critter.pos() ) <= range; + return sees( critter ) && rl_dist( pos_bub(), critter.pos_bub() ) <= range; } std::vector Character::get_visible_creatures( const int range ) const { return g->get_creatures_if( [this, range]( const Creature & critter ) -> bool { - return this != &critter && pos() != critter.pos() && // TODO: get rid of fake npcs (pos() check) - rl_dist( pos(), critter.pos() ) <= range && sees( critter ); + return this != &critter && pos_bub() != critter.pos_bub() && + rl_dist( pos_bub(), critter.pos_bub() ) <= range && sees( critter ); } ); } @@ -10419,9 +10420,8 @@ std::vector Character::get_targetable_creatures( const int range, bo } } } - bool in_range = std::round( rl_dist_exact( pos(), critter.pos() ) ) <= range; - // TODO: get rid of fake npcs (pos() check) - bool valid_target = this != &critter && pos() != critter.pos() && attitude_to( critter ) != Creature::Attitude::FRIENDLY; + bool in_range = std::round( rl_dist_exact( pos_bub(), critter.pos_bub() ) ) <= range; + bool valid_target = this != &critter && pos_bub() != critter.pos_bub() && attitude_to( critter ) != Creature::Attitude::FRIENDLY; return valid_target && in_range && can_see; } ); } @@ -10434,7 +10434,7 @@ int Character::get_mutation_visibility_cap( const Character *observed ) const // 3 perception and 3 distance would see all mutations - cap 0 // 3 perception and 15 distance - cap 5, some mutations visible // 3 perception and 20 distance would be barely able to discern huge antlers on a person - cap 10 - const int dist = rl_dist( pos(), observed->pos() ); + const int dist = rl_dist( pos_bub(), observed->pos_bub() ); int visibility_cap; if( per_cur <= 1 ) { visibility_cap = INT_MAX; @@ -10448,8 +10448,8 @@ std::vector Character::get_hostile_creatures( int range ) const { return g->get_creatures_if( [this, range]( const Creature & critter ) -> bool { // Fixes circular distance range for ranged attacks - float dist_to_creature = std::round( rl_dist_exact( pos(), critter.pos() ) ); - return this != &critter && pos() != critter.pos() && // TODO: get rid of fake npcs (pos() check) + float dist_to_creature = std::round( rl_dist_exact( pos_bub(), critter.pos_bub() ) ); + return this != &critter && pos_bub() != critter.pos_bub() && dist_to_creature <= range && critter.attitude_to( *this ) == Creature::Attitude::HOSTILE && sees( critter ); } ); @@ -10463,13 +10463,13 @@ void Character::echo_pulse() // Sound travels farther underwater if( has_effect( effect_subaquatic_sonar ) && is_underwater() ) { pulse_range = 16; - sounds::sound( this->pos(), 5, sounds::sound_t::movement, _( "boop." ), true, + sounds::sound( this->pos_bub(), 5, sounds::sound_t::movement, _( "boop." ), true, "none", "none" ); } else if( !has_effect( effect_subaquatic_sonar ) && is_underwater() ) { add_msg_if_player( m_warning, _( "You can't echolocate underwater!" ) ); return; } else { - sounds::sound( this->pos(), 5, sounds::sound_t::movement, _( "chirp." ), true, + sounds::sound( this->pos_bub(), 5, sounds::sound_t::movement, _( "chirp." ), true, "none", "none" ); } for( tripoint_bub_ms origin : points_in_radius( pos_bub(), pulse_range ) ) { @@ -10624,10 +10624,10 @@ bool Character::can_hear( const tripoint &source, const int volume ) const } // source is in-ear and at our square, we can hear it - if( source == pos() && volume == 0 ) { + if( source == pos_bub().raw() && volume == 0 ) { return true; } - const int dist = rl_dist( source, pos() ); + const int dist = rl_dist( source, pos_bub().raw() ); const float volume_multiplier = hearing_ability(); return ( volume - get_weather().weather_id->sound_attn ) * volume_multiplier >= dist; } @@ -11041,7 +11041,7 @@ void Character::gravity_check() { if( get_map().tr_at( pos_bub() ) == tr_ledge && !has_effect_with_flag( json_flag_GLIDING ) ) { get_map().tr_at( pos_bub() ).trigger( pos(), *this ); - get_map().update_visibility_cache( pos_bub().z() ); + get_map().update_visibility_cache( posz() ); } } @@ -11294,7 +11294,7 @@ bool Character::sees( const Creature &critter ) const { // This handles only the player/npc specific stuff (monsters don't have traits or bionics). const int dist = rl_dist( pos_bub(), critter.pos_bub() ); - if( std::abs( pos_bub().z() - critter.pos_bub().z() ) > fov_3d_z_range ) { + if( std::abs( posz() - critter.posz() ) > fov_3d_z_range ) { return false; } if( dist <= 3 && has_active_mutation( trait_ANTENNAE ) ) { @@ -11449,7 +11449,7 @@ int Character::intimidation() const bool Character::defer_move( const tripoint &next ) { // next must be adjacent to current pos - if( square_dist( next, pos() ) != 1 ) { + if( square_dist( next, pos_bub().raw() ) != 1 ) { return false; } // next must be adjacent to subsequent move in any preexisting automove route @@ -11895,7 +11895,7 @@ void Character::invalidate_pseudo_items() pseudo_items_valid = false; } -bool Character::avoid_trap( const tripoint &pos, const trap &tr ) const +bool Character::avoid_trap( const tripoint_bub_ms &pos, const trap &tr ) const { /** @EFFECT_DEX increases chance to avoid traps */ @@ -12457,7 +12457,7 @@ float Character::fall_damage_mod() const } // force is maximum damage to hp before scaling -int Character::impact( const int force, const tripoint &p ) +int Character::impact( const int force, const tripoint_bub_ms &p ) { // Falls over ~30m are fatal more often than not // But that would be quite a lot considering 21 z-levels in game @@ -12479,7 +12479,7 @@ int Character::impact( const int force, const tripoint &p ) // Being slammed against things rather than landing means we can't // control the impact as well - const bool slam = p != pos(); + const bool slam = p != pos_bub(); std::string target_name = "a swarm of bugs"; Creature *critter = get_creature_tracker().creature_at( p ); map &here = get_map(); @@ -12642,9 +12642,9 @@ bool Character::can_fly() } // FIXME: Relies on hardcoded bash damage type -void Character::knock_back_to( const tripoint &to ) +void Character::knock_back_to( const tripoint_bub_ms &to ) { - if( to == pos_bub().raw() ) { + if( to == pos_bub() ) { return; } @@ -12656,7 +12656,7 @@ void Character::knock_back_to( const tripoint &to ) add_effect( effect_stunned, 1_turns ); /** @EFFECT_STR_MAX allows knocked back player to knock back, damage, stun some monsters */ if( ( str_max - 6 ) / 4 > critter->type->size ) { - critter->knock_back_from( pos() ); // Chain reaction! + critter->knock_back_from( pos_bub() ); // Chain reaction! critter->apply_damage( this, bodypart_id( "torso" ), ( str_max - 6 ) / 4 ); critter->add_effect( effect_stunned, 1_turns ); } else if( ( str_max - 6 ) / 4 == critter->type->size ) { @@ -12686,7 +12686,7 @@ void Character::knock_back_to( const tripoint &to ) if( here.has_flag( ter_furn_flag::TFLAG_LIQUID, to ) && here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, to ) ) { if( !is_npc() ) { - avatar_action::swim( here, get_avatar(), tripoint_bub_ms( to ) ); + avatar_action::swim( here, get_avatar(), to ); } // TODO: NPCs can't swim! } else if( here.impassable( to ) ) { // Wait, it's a wall @@ -13179,7 +13179,7 @@ void Character::pause() } // Don't drop on the ground when the ground is on fire - if( total_left > 1_minutes && !is_dangerous_fields( here.field_at( pos() ) ) ) { + if( total_left > 1_minutes && !is_dangerous_fields( here.field_at( pos_bub() ) ) ) { add_effect( effect_downed, 2_turns, false, 0, true ); add_msg_player_or_npc( m_warning, _( "You roll on the ground, trying to smother the fire!" ), diff --git a/src/character.h b/src/character.h index cc62b58920ee0..dc270f8b63275 100644 --- a/src/character.h +++ b/src/character.h @@ -2523,7 +2523,7 @@ class Character : public Creature, public visitable bool cast_spell( spell &sp, bool fake_spell, const std::optional &target ); /** Called when a player triggers a trap, returns true if they don't set it off */ - bool avoid_trap( const tripoint &pos, const trap &tr ) const override; + bool avoid_trap( const tripoint_bub_ms &pos, const trap &tr ) const override; //returns true if the warning is now beyond final and results in hostility. bool add_faction_warning( const faction_id &id ) const; @@ -2620,11 +2620,11 @@ class Character : public Creature, public visitable /** Returns multiplier on fall damage at low velocity (knockback/pit/1 z-level, not 5 z-levels) */ float fall_damage_mod() const override; /** Deals falling/collision damage with terrain/creature at pos */ - int impact( int force, const tripoint &pos ) override; + int impact( int force, const tripoint_bub_ms &pos ) override; /** Checks to see if the character is able to use their wings properly */ bool can_fly(); /** Knocks the player to a specified tile */ - void knock_back_to( const tripoint &to ) override; + void knock_back_to( const tripoint_bub_ms &to ) override; /** Returns overall % of HP remaining */ int hp_percentage() const override; diff --git a/src/character_inventory.cpp b/src/character_inventory.cpp index b9eb57bd35d5c..7fc9c54a62ef8 100644 --- a/src/character_inventory.cpp +++ b/src/character_inventory.cpp @@ -595,7 +595,7 @@ void Character::drop( const drop_locations &what, const tripoint &target, } invalidate_leak_level_cache(); const std::optional vp = get_map().veh_at( target ).cargo(); - if( rl_dist( pos(), target ) > 1 || !( stash || get_map().can_put_items( target ) ) + if( rl_dist( pos_bub().raw(), target ) > 1 || !( stash || get_map().can_put_items( target ) ) || ( vp.has_value() && vp->part().is_cleaner_on() ) ) { add_msg_player_or_npc( m_info, _( "You can't place items here!" ), _( " can't place items here!" ) ); diff --git a/src/computer_session.cpp b/src/computer_session.cpp index 377a1966e940f..e0b70fe08b1e9 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -500,7 +500,7 @@ void computer_session::action_toll() reset_terminal(); } else { comp.next_attempt = calendar::turn + 1_minutes; - sounds::sound( get_player_character().pos(), 120, sounds::sound_t::alarm, + sounds::sound( get_player_character().pos_bub(), 120, sounds::sound_t::alarm, //~ the sound of a church bell ringing _( "Bohm… Bohm… Bohm…" ), true, "environment", "church_bells" ); @@ -545,7 +545,8 @@ void computer_session::action_release() { get_event_bus().send(); Character &player_character = get_player_character(); - sounds::sound( player_character.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), false, + sounds::sound( player_character.pos_bub(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), + false, "environment", "alarm" ); get_map().translate_radius( ter_t_reinforced_glass, ter_t_thconc_floor, 25.0, @@ -563,7 +564,8 @@ void computer_session::action_release_disarm() void computer_session::action_release_bionics() { Character &player_character = get_player_character(); - sounds::sound( player_character.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), false, + sounds::sound( player_character.pos_bub(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), + false, "environment", "alarm" ); get_map().translate_radius( ter_t_reinforced_glass, ter_t_thconc_floor, 3.0, @@ -1345,7 +1347,8 @@ void computer_session::action_irradiator() print_error( _( " >> Radiation spike detected!\n" ) ); print_error( _( "WARNING [912]: Catastrophic malfunction! Contamination detected!" ) ); print_error( _( "EMERGENCY PROCEDURE [1]: Evacuate. Evacuate. Evacuate.\n" ) ); - sounds::sound( player_character.pos(), 30, sounds::sound_t::alarm, _( "an alarm sound!" ), false, + sounds::sound( player_character.pos_bub(), 30, sounds::sound_t::alarm, _( "an alarm sound!" ), + false, "environment", "alarm" ); here.i_rem( dest, it ); @@ -1615,7 +1618,8 @@ void computer_session::failure_alarm() { Character &player_character = get_player_character(); get_event_bus().send( player_character.getID() ); - sounds::sound( player_character.pos(), 60, sounds::sound_t::alarm, _( "an alarm sound!" ), false, + sounds::sound( player_character.pos_bub(), 60, sounds::sound_t::alarm, _( "an alarm sound!" ), + false, "environment", "alarm" ); } diff --git a/src/construction.cpp b/src/construction.cpp index 85a194e137b41..e1e83b8b2048d 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1504,7 +1504,7 @@ bool construct::check_support( const tripoint_bub_ms &p ) bool construct::check_support_below( const tripoint_bub_ms &p ) { bool blocking_creature = g->get_creature_if( [&]( const Creature & creature ) { - return creature.pos() == p.raw(); + return creature.pos_bub() == p; } ) != nullptr; map &here = get_map(); diff --git a/src/crafting.cpp b/src/crafting.cpp index fa5a9c47b96e0..d3ea3b5f4a8ba 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -3088,7 +3088,7 @@ std::vector Character::get_crafting_helpers() const && guy.is_npc() && !guy.in_sleep_state() && guy.is_obeying( *this ) - && rl_dist( guy.pos(), pos() ) < PICKUP_RANGE + && rl_dist( guy.pos_bub(), pos_bub() ) < PICKUP_RANGE && get_map().clear_path( pos_bub(), guy.pos_bub(), PICKUP_RANGE, 1, 100 ); } ); } @@ -3097,7 +3097,7 @@ std::vector Character::get_crafting_group() const { return g->get_characters_if( [this]( const Character & guy ) { return guy.is_ally( *this ) - && rl_dist( guy.pos(), pos() ) < PICKUP_RANGE + && rl_dist( guy.pos_bub(), pos_bub() ) < PICKUP_RANGE && get_map().clear_path( pos_bub(), guy.pos_bub(), PICKUP_RANGE, 1, 100 ); } ); } diff --git a/src/creature.cpp b/src/creature.cpp index 404b13d79de58..a7a9e0190c521 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -216,14 +216,14 @@ tripoint_bub_ms Creature::pos_bub() const void Creature::setpos( const tripoint &p ) { - const tripoint_abs_ms old_loc = get_location(); - set_pos_only( p ); - on_move( old_loc ); + Creature::setpos( tripoint_bub_ms( p ) ); } void Creature::setpos( const tripoint_bub_ms &p ) { - Creature::setpos( p.raw() ); + const tripoint_abs_ms old_loc = get_location(); + set_pos_only( p ); + on_move( old_loc ); } bool Creature::will_be_cramped_in_vehicle_tile( const tripoint_abs_ms &loc ) const @@ -299,7 +299,7 @@ void Creature::move_to( const tripoint_abs_ms &loc ) on_move( old_loc ); } -void Creature::set_pos_only( const tripoint &p ) +void Creature::set_pos_only( const tripoint_bub_ms &p ) { location = get_map().getglobal( p ); } @@ -486,7 +486,7 @@ bool Creature::sees( const Creature &critter ) const map &here = get_map(); - const int target_range = rl_dist( pos(), critter.pos() ); + const int target_range = rl_dist( pos_bub(), critter.pos_bub() ); if( target_range > MAX_VIEW_DISTANCE ) { return false; } @@ -553,7 +553,7 @@ bool Creature::sees( const Creature &critter ) const ( here.has_flag( ter_furn_flag::TFLAG_SHALLOW_WATER, critter.pos_bub() ) && critter.get_size() < creature_size::medium ) ) ) || ( critter.has_flag( mon_flag_NIGHT_INVISIBILITY ) && - here.light_at( critter.pos() ) <= lit_level::LOW ) || + here.light_at( critter.pos_bub() ) <= lit_level::LOW ) || critter.has_effect( effect_invisibility ) || ( !is_likely_underwater() && critter.is_likely_underwater() && majority_rule( critter.has_flag( mon_flag_WATER_CAMOUFLAGE ), @@ -570,7 +570,7 @@ bool Creature::sees( const Creature &critter ) const } if( ch != nullptr ) { if( ch->is_crouching() || ch->has_effect( effect_all_fours ) || ch->is_prone() || - pos_bub().z() != critter.pos_bub().z() ) { + posz() != critter.posz() ) { const int coverage = std::max( here.obstacle_coverage( pos_bub(), critter.pos_bub() ), here.ledge_coverage( *this, critter.pos_bub() ) ); if( coverage < 30 ) { @@ -652,7 +652,7 @@ bool Creature::sees( const tripoint_bub_ms &t, bool is_avatar, int range_mod ) c const float player_visibility_factor = get_player_character().visibility() / 100.0f; int adj_range = std::floor( range * player_visibility_factor ); return adj_range >= wanted_range && - here.get_cache_ref( pos().z ).seen_cache[pos().x][pos().y] > LIGHT_TRANSPARENCY_SOLID; + here.get_cache_ref( posz() ).seen_cache[posx()][posy()] > LIGHT_TRANSPARENCY_SOLID; } else { return here.sees( pos_bub(), t, range ); } @@ -705,7 +705,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area // granularity increases with proximity iff_hangle = ( pldist == 2 ? 30_degrees : 60_degrees ); } - u_angle = coord_to_angle( pos(), player_pos.raw() ); + u_angle = coord_to_angle( pos_bub(), player_pos ); } if( area > 0 && in_veh != nullptr ) { @@ -747,7 +747,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area } } while( continueFlag ); - tripoint oldPos = pos(); + tripoint_bub_ms oldPos = pos_bub(); setpos( path_to_target.back() ); //Temporary moving targeting npc on vehicle boundary position bool seesFromVehBound = sees( *m ); // And look from there setpos( oldPos ); @@ -758,7 +758,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area continue; } } - int dist = rl_dist( pos(), m->pos() ) + 1; // rl_dist can be 0 + int dist = rl_dist( pos_bub(), m->pos_bub() ) + 1; // rl_dist can be 0 if( dist > range + 1 || dist < area ) { // Too near or too far continue; @@ -784,7 +784,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area // only when the target is actually "hostile enough" bool maybe_boo = false; if( angle_iff ) { - units::angle tangle = coord_to_angle( pos(), m->pos() ); + units::angle tangle = coord_to_angle( pos_bub(), m->pos_bub() ); units::angle diff = units::fabs( u_angle - tangle ); // Player is in the angle and not too far behind the target if( ( diff + iff_hangle > 360_degrees || diff < iff_hangle ) && @@ -808,7 +808,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area continue; // Handle this late so that boo_hoo++ can happen } // Expensive check for proximity to vehicle - if( self_area_iff && overlaps_vehicle( in_veh->get_points(), tripoint_bub_ms( m->pos() ), area ) ) { + if( self_area_iff && overlaps_vehicle( in_veh->get_points(), m->pos_bub(), area ) ) { continue; } @@ -850,7 +850,7 @@ bool Creature::is_adjacent( const Creature *target, const bool allow_z_levels ) return false; } - if( rl_dist( pos(), target->pos() ) != 1 ) { + if( rl_dist( pos_bub(), target->pos_bub() ) != 1 ) { return false; } @@ -1521,7 +1521,7 @@ void Creature::longpull( const std::string &name, const tripoint_bub_ms &p ) c->move_to( tripoint_abs_ms( line_to( get_location().raw(), c->get_location().raw(), 0, 0 ).front() ) ); c->add_effect( effect_stunned, 1_seconds ); - sounds::sound( c->pos(), 5, sounds::sound_t::combat, _( "Shhhk!" ) ); + sounds::sound( c->pos_bub(), 5, sounds::sound_t::combat, _( "Shhhk!" ) ); } else { add_msg_if_player( m_bad, _( "%s weight makes it difficult to pull towards you." ), c->disp_name( true, true ) ); @@ -1557,7 +1557,7 @@ bool Creature::stumble_invis( const Creature &player, const bool stumblemsg ) return true; } -bool Creature::attack_air( const tripoint &p ) +bool Creature::attack_air( const tripoint_bub_ms &p ) { // Calculate move cost differently for monsters and npcs int move_cost = 100; @@ -1575,7 +1575,7 @@ bool Creature::attack_air( const tripoint &p ) // Attack animation if( get_option( "ANIMATIONS" ) ) { std::map area_color; - area_color[tripoint_bub_ms( p )] = c_black; + area_color[ p ] = c_black; explosion_handler::draw_custom_explosion( area_color, "animation_hit" ); } @@ -3195,13 +3195,14 @@ void Creature::draw( const catacurses::window &w, const point_bub_ms &origin, bo draw( w, tripoint_bub_ms( origin, posz() ), inverted ); } -void Creature::draw( const catacurses::window &w, const tripoint &origin, bool inverted ) const +void Creature::draw( const catacurses::window &w, const tripoint_bub_ms &origin, + bool inverted ) const { if( is_draw_tiles_mode() ) { return; } - point draw( -origin.xy() + point( getmaxx( w ) / 2 + posx(), getmaxy( w ) / 2 + posy() ) ); + point draw( point( getmaxx( w ) / 2 + posx(), getmaxy( w ) / 2 + posy() ) - origin.xy().raw() ); if( inverted ) { mvwputch_inv( w, draw, basic_symbol_color(), symbol() ); } else if( is_symbol_highlighted() ) { @@ -3209,12 +3210,8 @@ void Creature::draw( const catacurses::window &w, const tripoint &origin, bool i } else { mvwputch( w, draw, symbol_color(), symbol() ); } -} -void Creature::draw( const catacurses::window &w, const tripoint_bub_ms &origin, - bool inverted ) const -{ - Creature::draw( w, origin.raw(), inverted ); + Creature::draw( w, origin, inverted ); } bool Creature::is_symbol_highlighted() const @@ -3333,27 +3330,27 @@ std::string Creature::replace_with_npc_name( std::string input ) const return input; } -void Creature::knock_back_from( const tripoint &p ) +void Creature::knock_back_from( const tripoint_bub_ms &p ) { - if( p == pos() ) { + if( p == pos_bub() ) { return; // No effect } if( is_hallucination() ) { die( nullptr ); return; } - tripoint to = pos(); - if( p.x < posx() ) { - to.x++; + tripoint_bub_ms to = pos_bub(); + if( p.x() < posx() ) { + to.x()++; } - if( p.x > posx() ) { - to.x--; + if( p.x() > posx() ) { + to.x()--; } - if( p.y < posy() ) { - to.y++; + if( p.y() < posy() ) { + to.y()++; } - if( p.y > posy() ) { - to.y--; + if( p.y() > posy() ) { + to.y()--; } knock_back_to( to ); diff --git a/src/creature.h b/src/creature.h index 1a346ec654be2..518cd1dc40aca 100644 --- a/src/creature.h +++ b/src/creature.h @@ -310,10 +310,10 @@ class Creature : public viewer tripoint pos() const; tripoint_bub_ms pos_bub() const; inline int posx() const { - return pos().x; + return pos_bub().x(); } inline int posy() const { - return pos().y; + return pos_bub().y(); } inline int posz() const { return get_location().z(); @@ -382,7 +382,7 @@ class Creature : public viewer * @param tr is the trap that was triggered. * @param pos is the location of the trap (not necessarily of the creature) in the main map. */ - virtual bool avoid_trap( const tripoint &pos, const trap &tr ) const = 0; + virtual bool avoid_trap( const tripoint_bub_ms &pos, const trap &tr ) const = 0; /** * The functions check whether this creature can see the target. @@ -394,6 +394,7 @@ class Creature : public viewer */ /*@{*/ bool sees( const Creature &critter ) const override; + // TODO: Get rid of untyped overload. bool sees( const tripoint &t, bool is_avatar = false, int range_mod = 0 ) const override; bool sees( const tripoint_bub_ms &t, bool is_avatar = false, int range_mod = 0 ) const override; /*@}*/ @@ -438,12 +439,12 @@ class Creature : public viewer damage_instance &dam ) = 0; // TODO: this is just a shim so knockbacks work - void knock_back_from( const tripoint &p ); + void knock_back_from( const tripoint_bub_ms &p ); double calculate_by_enchantment( double modify, enchant_vals::mod value, bool round_output = false ) const; void adjust_taken_damage_by_enchantments( damage_unit &du ) const; void adjust_taken_damage_by_enchantments_post_absorbed( damage_unit &du ) const; - virtual void knock_back_to( const tripoint &to ) = 0; + virtual void knock_back_to( const tripoint_bub_ms &to ) = 0; // Converts the "cover_vitals" protection on the specified body part into // a modifier (between 0 and 1) that would be applied to incoming critical damage @@ -520,7 +521,7 @@ class Creature : public viewer // Temporarily reveals an invisible player when a monster tries to enter their location bool stumble_invis( const Creature &player, bool stumblemsg = true ); // Attack an empty location - bool attack_air( const tripoint &p ); + bool attack_air( const tripoint_bub_ms &p ); /** * This creature just dodged an attack - possibly special/ranged attack - from source. @@ -595,7 +596,7 @@ class Creature : public viewer /** Returns multiplier on fall damage at low velocity (knockback/pit/1 z-level, not 5 z-levels) */ virtual float fall_damage_mod() const = 0; /** Deals falling/collision damage with terrain/creature at pos */ - virtual int impact( int force, const tripoint &pos ) = 0; + virtual int impact( int force, const tripoint_bub_ms &pos ) = 0; /** * This function checks the creatures @ref is_dead_state and (if true) calls @ref die. @@ -789,7 +790,7 @@ class Creature : public viewer tripoint_abs_ms location; protected: // Sets the creature's position without any side-effects. - void set_pos_only( const tripoint &p ); + void set_pos_only( const tripoint_bub_ms &p ); // Sets the creature's position without any side-effects. void set_location( const tripoint_abs_ms &loc ); // Invoked when the creature's position changes. @@ -959,8 +960,6 @@ class Creature : public viewer bool underwater; void draw( const catacurses::window &w, const point_bub_ms &origin, bool inverted ) const; - // TODO: Get rid of the untyped overload - void draw( const catacurses::window &w, const tripoint &origin, bool inverted ) const; void draw( const catacurses::window &w, const tripoint_bub_ms &origin, bool inverted ) const; /** * Write information about this creature. diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 9dd497967a088..60a7c7f994a35 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1745,7 +1745,7 @@ static void teleport_short() return; } g->place_player( *where ); - const tripoint new_pos( player_character.pos() ); + const tripoint_bub_ms new_pos( player_character.pos_bub() ); add_msg( _( "You teleport to point %s." ), new_pos.to_string() ); } diff --git a/src/display.cpp b/src/display.cpp index c834e4c645881..1b313403a6398 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -1492,7 +1492,7 @@ std::string display::colorized_bodygraph_text( const Character &u, const std::st std::pair display::weather_text_color( const Character &u ) { - if( u.pos().z < 0 ) { + if( u.posz() < 0 ) { return std::make_pair( _( "Underground" ), c_light_gray ); } else { weather_manager &weather = get_weather(); diff --git a/src/do_turn.cpp b/src/do_turn.cpp index e2cef4622e979..81e48148999bf 100644 --- a/src/do_turn.cpp +++ b/src/do_turn.cpp @@ -326,7 +326,7 @@ void monmove() if( !critter.is_dead() && u.has_active_bionic( bio_alarm ) && u.get_power_level() >= bio_alarm->power_trigger && - rl_dist( u.pos(), critter.pos() ) <= 5 && + rl_dist( u.pos_bub(), critter.pos_bub() ) <= 5 && !critter.is_hallucination() ) { u.mod_power_level( -bio_alarm->power_trigger ); add_msg( m_warning, _( "Your motion alarm goes off!" ) ); @@ -402,7 +402,7 @@ void overmap_npc_move() continue; } npc *npc_to_add = elem.get(); - if( ( !npc_to_add->is_active() || rl_dist( u.pos(), npc_to_add->pos() ) > SEEX * 2 ) && + if( ( !npc_to_add->is_active() || rl_dist( u.pos_bub(), npc_to_add->pos_bub() ) > SEEX * 2 ) && npc_to_add->mission == NPC_MISSION_TRAVELLING ) { travelling_npcs.push_back( npc_to_add ); } @@ -540,7 +540,7 @@ bool do_turn() // Process NPC sound events before they move or they hear themselves talking for( npc &guy : g->all_npcs() ) { - if( rl_dist( guy.pos(), u.pos() ) < MAX_VIEW_DISTANCE ) { + if( rl_dist( guy.pos_bub(), u.pos_bub() ) < MAX_VIEW_DISTANCE ) { sounds::process_sound_markers( &guy ); } } @@ -561,7 +561,7 @@ bool do_turn() g->mon_info_update(); // Process any new sounds the player caused during their turn. for( npc &guy : g->all_npcs() ) { - if( rl_dist( guy.pos(), u.pos() ) < MAX_VIEW_DISTANCE ) { + if( rl_dist( guy.pos_bub(), u.pos_bub() ) < MAX_VIEW_DISTANCE ) { sounds::process_sound_markers( &guy ); } } diff --git a/src/faction.cpp b/src/faction.cpp index 0d54f4d4ce9ff..dc0c516e37473 100644 --- a/src/faction.cpp +++ b/src/faction.cpp @@ -725,18 +725,19 @@ int npc::faction_display( const catacurses::window &fac_w, const int width ) con bool guy_has_radio = cache_has_item_with_flag( json_flag_TWO_WAY_RADIO, true ); // is the NPC even in the same area as the player? if( rl_dist( player_abspos, global_omt_location() ) > 3 || - ( rl_dist( player_character.pos(), pos() ) > SEEX * 2 || !player_character.sees( pos_bub() ) ) ) { + ( rl_dist( player_character.pos_bub(), pos_bub() ) > SEEX * 2 || + !player_character.sees( pos_bub() ) ) ) { if( u_has_radio && guy_has_radio ) { - if( !( player_character.pos().z >= 0 && pos().z >= 0 ) && - !( player_character.pos().z == pos().z ) ) { + if( !( player_character.posz() >= 0 && posz() >= 0 ) && + !( player_character.posz() == posz() ) ) { //Early exit can_see = _( "Not within radio range" ); see_color = c_light_red; } else { // TODO: better range calculation than just elevation. const int base_range = 200; - float send_elev_boost = ( 1 + ( player_character.pos().z * 0.1 ) ); - float recv_elev_boost = ( 1 + ( pos().z * 0.1 ) ); + float send_elev_boost = ( 1 + ( player_character.posz() * 0.1 ) ); + float recv_elev_boost = ( 1 + ( posz() * 0.1 ) ); if( ( square_dist( player_character.global_sm_location(), global_sm_location() ) <= base_range * send_elev_boost * recv_elev_boost ) ) { //Direct radio contact, both of their elevation are in effect diff --git a/src/game.cpp b/src/game.cpp index 747c9b3c4f635..2d44befb90566 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1302,7 +1302,7 @@ void game::on_witness_theft( const item &target ) Character &p = get_player_character(); std::vector witnesses; for( npc &elem : g->all_npcs() ) { - if( rl_dist( elem.pos(), p.pos() ) < MAX_VIEW_DISTANCE && elem.sees( p.pos_bub() ) && + if( rl_dist( elem.pos_bub(), p.pos_bub() ) < MAX_VIEW_DISTANCE && elem.sees( p.pos_bub() ) && target.is_owned_by( elem ) ) { witnesses.push_back( &elem ); } @@ -1848,7 +1848,7 @@ void game::validate_mounted_npcs() continue; } mounted_pl->mounted_creature = shared_from( m ); - mounted_pl->setpos( m.pos() ); + mounted_pl->setpos( m.pos_bub() ); mounted_pl->add_effect( effect_riding, 1_turns, true ); m.mounted_player = mounted_pl; } @@ -4294,7 +4294,7 @@ std::optional game::get_veh_dir_indicator_location( bool next ) vehicle *const veh = &vp->vehicle(); rl_vec2d face = next ? veh->dir_vec() : veh->face_vec(); float r = 10.0f; - return tripoint_rel_ms( static_cast( r * face.x ), static_cast( r * face.y ), u.pos().z ); + return tripoint_rel_ms( static_cast( r * face.x ), static_cast( r * face.y ), u.posz() ); } void game::draw_veh_dir_indicator( bool next ) @@ -4642,7 +4642,7 @@ void game::mon_info_update( ) monster &critter = *m; const monster_attitude matt = critter.attitude( &u ); - const int mon_dist = rl_dist( u.pos(), critter.pos() ); + const int mon_dist = rl_dist( u.pos_bub(), critter.pos_bub() ); if( !safemode_empty ) { need_processing = get_safemode().check_monster( critter.name(), @@ -4693,7 +4693,7 @@ void game::mon_info_update( ) } else if( p != nullptr ) { //Safe mode NPC check - const int npc_dist = rl_dist( u.pos(), p->pos() ); + const int npc_dist = rl_dist( u.pos_bub(), p->pos_bub() ); if( !safemode_empty ) { need_processing = get_safemode().check_monster( get_safemode().npc_type_name(), @@ -5133,7 +5133,7 @@ static bool can_place_monster( const monster &mon, const tripoint_bub_ms &p ) if( creatures.creature_at( p ) ) { return false; } - return mon.will_move_to( p.raw() ) && mon.know_danger_at( p.raw() ); + return mon.will_move_to( p ) && mon.know_danger_at( p ); } static bool can_place_npc( const tripoint_bub_ms &p ) @@ -5200,7 +5200,7 @@ monster *game::place_critter_around( const shared_ptr_fast &mon, if( !where ) { return nullptr; } - mon->spawn( where->raw() ); + mon->spawn( *where ); return critter_tracker->add( mon ) ? mon.get() : nullptr; } @@ -5223,7 +5223,7 @@ monster *game::place_critter_within( const shared_ptr_fast &mon, if( !where ) { return nullptr; } - mon->spawn( where->raw() ); + mon->spawn( *where ); return critter_tracker->add( mon ) ? mon.get() : nullptr; } @@ -5348,12 +5348,12 @@ bool game::spawn_hallucination( const tripoint_bub_ms &p, const mtype_id &mt, const shared_ptr_fast phantasm = make_shared_fast( mt ); phantasm->hallucination = true; - phantasm->spawn( p.raw() ); + phantasm->spawn( p ); if( lifespan.has_value() ) { phantasm->set_summon_time( lifespan.value() ); } //Don't attempt to place phantasms inside of other creatures - if( !get_creature_tracker().creature_at( phantasm->pos(), true ) ) { + if( !get_creature_tracker().creature_at( phantasm->pos_bub(), true ) ) { return critter_tracker->add( phantasm ); } else { return false; @@ -5401,7 +5401,7 @@ bool game::swap_critters( Creature &a, Creature &b ) if( creatures.creature_at( a.pos_bub() ) != &a ) { if( creatures.creature_at( a.pos_bub() ) == nullptr ) { debugmsg( "Tried to swap %s and %s when the latter isn't present at its own location (%d,%d,%d).", - b.disp_name(), a.disp_name(), a.pos_bub().x(), a.pos_bub().y(), a.pos_bub().z() ); + b.disp_name(), a.disp_name(), a.posx(), a.posy(), a.posz() ); } else { debugmsg( "Tried to swap when it would cause a collision between %s and %s.", b.disp_name(), creatures.creature_at( a.pos_bub() )->disp_name() ); @@ -5411,7 +5411,7 @@ bool game::swap_critters( Creature &a, Creature &b ) if( creatures.creature_at( b.pos_bub() ) != &b ) { if( creatures.creature_at( b.pos_bub() ) == nullptr ) { debugmsg( "Tried to swap %s and %s when the latter isn't present at its own location (%d,%d,%d).", - a.disp_name(), b.disp_name(), b.pos_bub().x(), b.pos_bub().y(), b.pos_bub().z() ); + a.disp_name(), b.disp_name(), b.posx(), b.posy(), b.posz() ); } else { debugmsg( "Tried to swap when it would cause a collision between %s and %s.", a.disp_name(), creatures.creature_at( b.pos_bub() )->disp_name() ); @@ -5454,7 +5454,7 @@ bool game::swap_critters( Creature &a, Creature &b ) } tripoint_bub_ms temp = second.pos_bub(); - second.setpos( first.pos() ); + second.setpos( first.pos_bub() ); if( first.is_avatar() ) { walk_move( temp ); @@ -8309,9 +8309,9 @@ void game::list_items_monsters() const Creature::Attitude att_rhs = rhs->attitude_to( u ); return att_lhs < att_rhs || ( att_lhs == att_rhs - && rl_dist( u.pos(), lhs->pos() ) < rl_dist( u.pos(), rhs->pos() ) ); + && rl_dist( u.pos_bub(), lhs->pos_bub() ) < rl_dist( u.pos_bub(), rhs->pos_bub() ) ); } else { // Sort just by ditance if player has inattentive trait - return ( rl_dist( u.pos(), lhs->pos() ) < rl_dist( u.pos(), rhs->pos() ) ); + return ( rl_dist( u.pos_bub(), lhs->pos_bub() ) < rl_dist( u.pos_bub(), rhs->pos_bub() ) ); } } ); @@ -9099,7 +9099,7 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list } mvwprintz( w_monsters, point( width - 19, y ), color, sText ); - const int mon_dist = rl_dist( u.pos(), critter->pos() ); + const int mon_dist = rl_dist( u.pos_bub(), critter->pos_bub() ); const int numd = mon_dist > 999 ? 4 : mon_dist > 99 ? 3 : mon_dist > 9 ? 2 : 1; @@ -9108,7 +9108,7 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list selected ? c_light_green : c_light_gray, "%*d %s", numd, mon_dist, - direction_name_short( direction_from( u.pos(), critter->pos() ) ) ); + direction_name_short( direction_from( u.pos_bub(), critter->pos_bub() ) ) ); } mvwprintz( w_monsters_border, point( ( width / 2 ) - numw - 2, 0 ), c_light_green, " %*d", numw, @@ -9127,7 +9127,7 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list wprintz( w_monster_info_border, c_light_green, ctxt.press_x( "look" ) ); wprintz( w_monster_info_border, c_light_gray, " %s", _( "to look around" ) ); - if( cCurMon && rl_dist( u.pos(), cCurMon->pos() ) <= max_gun_range ) { + if( cCurMon && rl_dist( u.pos_bub(), cCurMon->pos_bub() ) <= max_gun_range ) { std::string press_to_fire_text = string_format( _( "%s %s" ), ctxt.press_x( "fire" ), string_format( _( "to shoot" ) ) ); @@ -9200,7 +9200,7 @@ game::vmenu_ret game::list_monsters( const std::vector &monster_list hide_ui = false; ui.mark_resize(); } else if( action == "fire" ) { - if( cCurMon != nullptr && rl_dist( u.pos(), cCurMon->pos() ) <= max_gun_range ) { + if( cCurMon != nullptr && rl_dist( u.pos_bub(), cCurMon->pos_bub() ) <= max_gun_range ) { u.last_target = shared_from( *cCurMon ); u.recoil = MAX_RECOIL; u.view_offset = stored_view_offset; @@ -10295,10 +10295,11 @@ bool game::check_safe_mode_allowed( bool repeat_safe_mode_warnings ) get_safemode().lastmon_whitelist = get_safemode().npc_type_name(); } else if( new_seen_mon.size() == 1 ) { const shared_ptr_fast &mon = new_seen_mon.back(); - const std::string dist_text = string_format( _( "%d tiles" ), rl_dist( u.pos(), mon->pos() ) ); + const std::string dist_text = string_format( _( "%d tiles" ), rl_dist( u.pos_bub(), + mon->pos_bub() ) ); //~ %s: Cardinal/ordinal direction ("east") const std::string dir_text = string_format( _( "to the %s" ), - colorize( direction_name( direction_from( u.pos(), mon->pos() ) ), dir_color ) ); + colorize( direction_name( direction_from( u.pos_bub(), mon->pos_bub() ) ), dir_color ) ); //~ %1$s: Name of monster spotted ("headless zombie") //~ %2$s: Distance to monster ("17 tiles") //~ %3$s: Description of where the monster is ("to the east") @@ -10315,8 +10316,8 @@ bool game::check_safe_mode_allowed( bool repeat_safe_mode_warnings ) // Find the most frequent type to call out by name. std::unordered_map> mons_by_name; for( const shared_ptr_fast &mon : new_seen_mon ) { - min_dist = std::min( min_dist, rl_dist( u.pos(), mon->pos() ) ); - max_dist = std::max( min_dist, rl_dist( u.pos(), mon->pos() ) ); + min_dist = std::min( min_dist, rl_dist( u.pos_bub(), mon->pos_bub() ) ); + max_dist = std::max( min_dist, rl_dist( u.pos_bub(), mon->pos_bub() ) ); mons_by_name[mon->name()].push_back( mon.get() ); } const std::vector &most_frequent_mon = std::max_element( mons_by_name.begin(), @@ -10341,7 +10342,7 @@ bool game::check_safe_mode_allowed( bool repeat_safe_mode_warnings ) std::transform( most_frequent_mon.begin(), most_frequent_mon.end(), std::inserter( most_frequent_mon_dirs, most_frequent_mon_dirs.begin() ), [&]( const monster * const mon ) { - return direction_from( u.pos(), mon->pos() ); + return direction_from( u.pos_bub(), mon->pos_bub() ); } ); std::string dir_text; if( most_frequent_mon_dirs.size() == 1 ) { @@ -11036,10 +11037,10 @@ point_rel_sm game::place_player( const tripoint_bub_ms &dest_loc, bool quick ) // TODO: handling for ridden creatures other than players mount. if( !critter.has_effect( effect_ridden ) ) { if( u.is_mounted() ) { - std::vector maybe_valid; + std::vector maybe_valid; for( const tripoint_bub_ms &jk : m.points_in_radius( critter.pos_bub(), 1 ) ) { if( is_empty( jk ) ) { - maybe_valid.push_back( jk.raw() ); + maybe_valid.push_back( jk ); } } bool moved = false; @@ -11055,7 +11056,7 @@ point_rel_sm game::place_player( const tripoint_bub_ms &dest_loc, bool quick ) } } else { // Force the movement even though the player is there right now. - const bool moved = critter.move_to( u.pos(), /*force=*/false, /*step_on_critter=*/true ); + const bool moved = critter.move_to( u.pos_bub(), /*force=*/false, /*step_on_critter=*/true ); if( moved ) { add_msg( _( "You displace the %s." ), critter.name() ); } else { @@ -11952,7 +11953,7 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo // Approximate critter's "stopping power" with its max hp force = std::min( 1.5f * critter.type->hp, flvel ); const int damage = rng( force, force * 2.0f ) / 6; - c->impact( damage, pt.raw() ); + c->impact( damage, pt ); // Multiply zed damage by 6 because no body parts const int zed_damage = std::max( 0, ( damage - critter.get_armor_type( damage_bash, bodypart_id( "torso" ) ) ) * 6 ); @@ -11972,7 +11973,7 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo force = flvel - 1; } const int damage = rng( force, force * 2.0f ) / 9; - c->impact( damage, pt.raw() ); + c->impact( damage, pt ); if( m.is_bashable( pt ) ) { // Only go through if we successfully make the tile passable m.bash( pt, flvel ); @@ -12032,7 +12033,7 @@ bool game::fling_creature( Creature *c, const units::angle &dir, float flvel, bo force = std::max( force / 2 - 5, 0 ); } if( force > 0 ) { - int dmg = c->impact( force, c->pos() ); + int dmg = c->impact( force, c->pos_bub() ); // TODO: Make landing damage the floor m.bash( c->pos_bub(), dmg / 4, false, false, false ); } @@ -12455,7 +12456,7 @@ void game::vertical_move( int movez, bool force, bool peeking ) player_displace = true; } } - monster *mon = creatures.creature_at( u.pos(), true ); + monster *mon = creatures.creature_at( u.pos_bub(), true ); // if the monster is ridden by the player or an NPC: // Dont displace them. If they are mounted by a friendly NPC, // then the NPC will already have been displaced just above. @@ -12995,7 +12996,7 @@ void game::shift_monsters( const tripoint_rel_sm &shift ) } for( monster &critter : all_monsters() ) { if( shift.xy() != point_rel_sm::zero ) { - critter.shift( shift.raw().xy() ); + critter.shift( shift.xy() ); } if( m.inbounds( critter.pos_bub() ) ) { @@ -13133,7 +13134,7 @@ void game::display_scent() return; } shared_ptr_fast scent_cb = make_shared_fast( [&]() { - scent.draw( w_terrain, div * 2, u.pos() + u.view_offset.raw() ); + scent.draw( w_terrain, div * 2, u.pos_bub().raw() + u.view_offset.raw() ); } ); g->add_draw_callback( scent_cb ); diff --git a/src/grab.cpp b/src/grab.cpp index 03cf941dba44d..a6187040bb717 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -253,8 +253,8 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) } } // Set player location to illegal value so it can't collide with vehicle. - const tripoint player_prev = u.pos(); - u.setpos( tripoint::zero ); + const tripoint_bub_ms player_prev = u.pos_bub(); + u.setpos( tripoint_bub_ms::zero ); std::vector colls; failed = grabbed_vehicle->collision( colls, actual_dir, true ); u.setpos( player_prev ); diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 76d74a0aa7bc1..924b40ed09343 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -1095,7 +1095,7 @@ avatar::smash_result avatar::smash( tripoint_bub_ms &smashp ) if( glass_portion && rng( 0, vol + 3 ) < vol ) { add_msg( m_bad, _( "Your %s shatters!" ), weapon->tname() ); weapon->spill_contents( pos_bub() ); - sounds::sound( pos(), 24, sounds::sound_t::combat, "CRACK!", true, "smash", + sounds::sound( pos_bub(), 24, sounds::sound_t::combat, "CRACK!", true, "smash", "glass" ); deal_damage( nullptr, bodypart_id( "hand_r" ), damage_instance( damage_cut, rng( 0, @@ -2779,7 +2779,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, add_msg( m_info, _( "Ignoring enemy!" ) ); for( auto &elem : player_character.get_mon_visible().new_seen_mon ) { monster &critter = *elem; - critter.ignoring = rl_dist( player_character.pos(), critter.pos() ); + critter.ignoring = rl_dist( player_character.pos_bub(), critter.pos_bub() ); } set_safe_mode( SAFE_MODE_ON ); } else if( player_character.has_effect( effect_laserlocked ) ) { diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 36f688bd7d88c..1f38e0fc7b76e 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1646,7 +1646,7 @@ void iexamine::deployed_furniture( Character &you, const tripoint_bub_ms &pos ) const furn_t &fo = here.furn( pos ).obj(); const std::string &name = fo.name(); - if( you.pos_bub().z() != pos.z() ) { + if( you.posz() != pos.z() ) { drop_pos = you.pos_bub(); if( !you.query_yn( _( "Pull up the %s?" ), name ) ) { return; @@ -5400,7 +5400,7 @@ void iexamine::pay_gas( Character &you, const tripoint_bub_ms &examp ) return; } - sounds::sound( you.pos(), 6, sounds::sound_t::activity, _( "Glug Glug Glug" ), true, "tool", + sounds::sound( you.pos_bub(), 6, sounds::sound_t::activity, _( "Glug Glug Glug" ), true, "tool", "gaspump" ); int cost = liters * pricePerUnit; @@ -5430,7 +5430,7 @@ void iexamine::pay_gas( Character &you, const tripoint_bub_ms &examp ) popup( _( "Unable to refund, no fuel in pump." ) ); return; } - sounds::sound( you.pos(), 6, sounds::sound_t::activity, _( "Glug Glug Glug" ), true, "tool", + sounds::sound( you.pos_bub(), 6, sounds::sound_t::activity, _( "Glug Glug Glug" ), true, "tool", "gaspump" ); // getGasPricePerLiter( platinum_discount) min price to avoid exploit diff --git a/src/inventory_ui.cpp b/src/inventory_ui.cpp index 2839ab433bfd3..4cc044ada0691 100644 --- a/src/inventory_ui.cpp +++ b/src/inventory_ui.cpp @@ -2164,13 +2164,14 @@ void inventory_selector::add_nearby_items( int radius ) { if( radius >= 0 ) { map &here = get_map(); - for( const tripoint &pos : closest_points_first( u.pos(), radius ) ) { + for( const tripoint_bub_ms &pos : closest_points_first( u.pos_bub(), radius ) ) { // can not reach this -> can not access its contents - if( u.pos() != pos && !here.clear_path( u.pos(), pos, rl_dist( u.pos(), pos ), 1, 100 ) ) { + if( u.pos_bub() != pos && + !here.clear_path( u.pos_bub(), pos, rl_dist( u.pos_bub(), pos ), 1, 100 ) ) { continue; } - add_map_items( pos ); - add_vehicle_items( pos ); + add_map_items( pos.raw() ); + add_vehicle_items( pos.raw() ); } } } diff --git a/src/iuse.cpp b/src/iuse.cpp index 3c59888fe25ca..9004b4dbd9e25 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -4391,7 +4391,7 @@ std::optional iuse::vibe( Character *p, item *it, const tripoint_bub_ms & ) std::optional iuse::vortex( Character *p, item *it, const tripoint_bub_ms & ) { - std::vector spawn; + std::vector spawn; spawn.reserve( 28 ); for( int i = -3; i <= 3; i++ ) { spawn.emplace_back( -3, i ); @@ -4401,8 +4401,8 @@ std::optional iuse::vortex( Character *p, item *it, const tripoint_bub_ms & } while( !spawn.empty() ) { - const tripoint_bub_ms offset( random_entry_removed( spawn ), 0 ); - monster *const mon = g->place_critter_at( mon_vortex, offset + p->pos() ); + const tripoint_rel_ms offset( random_entry_removed( spawn ), 0 ); + monster *const mon = g->place_critter_at( mon_vortex, p->pos_bub() + offset ); if( !mon ) { continue; } @@ -5238,7 +5238,7 @@ std::optional iuse::talking_doll( Character *p, item *it, const tripoint_bu p->add_msg_if_player( m_neutral, _( "You press a button on the doll to make it talk." ) ); const SpeechBubble speech = get_speech( it->typeId().str() ); - sounds::sound( p->pos(), speech.volume, sounds::sound_t::electronic_speech, + sounds::sound( p->pos_bub(), speech.volume, sounds::sound_t::electronic_speech, speech.text.translated(), true, "speech", it->typeId().str() ); return 1; @@ -5285,7 +5285,7 @@ std::optional gun_repair( Character *p, item *, item_location &loc ) return std::nullopt; } const std::string startdurability = fix.durability_indicator( true ); - sounds::sound( p->pos(), 8, sounds::sound_t::activity, "crunch", true, "tool", "repair_kit" ); + sounds::sound( p->pos_bub(), 8, sounds::sound_t::activity, "crunch", true, "tool", "repair_kit" ); p->practice( skill_mechanics, 10 ); p->mod_moves( -to_moves( 20_seconds ) ); @@ -5394,7 +5394,7 @@ std::optional iuse::toolmod_attach( Character *p, item *it, const tripoint_ std::optional iuse::bell( Character *p, item *it, const tripoint_bub_ms & ) { if( it->typeId() == itype_cow_bell ) { - sounds::sound( p->pos(), 12, sounds::sound_t::music, _( "Clank! Clank!" ), true, "misc", + sounds::sound( p->pos_bub(), 12, sounds::sound_t::music, _( "Clank! Clank!" ), true, "misc", "cow_bell" ); if( !p->is_deaf() ) { auto cattle_level = @@ -5406,7 +5406,7 @@ std::optional iuse::bell( Character *p, item *it, const tripoint_bub_ms & ) } } } else { - sounds::sound( p->pos(), 4, sounds::sound_t::music, _( "Ring! Ring!" ), true, "misc", "bell" ); + sounds::sound( p->pos_bub(), 4, sounds::sound_t::music, _( "Ring! Ring!" ), true, "misc", "bell" ); } return 1; } @@ -5426,7 +5426,7 @@ bool iuse::robotcontrol_can_target( Character *p, const monster &m ) return !m.is_dead() && m.type->in_species( species_ROBOT ) && m.friendly == 0 - && rl_dist( p->pos(), m.pos() ) <= 10; + && rl_dist( p->pos_bub(), m.pos_bub() ) <= 10; } std::optional iuse::robotcontrol( Character *p, item *it, const tripoint_bub_ms & ) @@ -6045,7 +6045,7 @@ static std::string effects_description_for_creature( Creature *const creature, s } if( creature->has_effect( effect_riding ) ) { pose = _( "rides" ); - monster *const mon = get_creature_tracker().creature_at( creature->pos(), false ); + monster *const mon = get_creature_tracker().creature_at( creature->pos_bub(), false ); figure_effects += pronoun_gender + string_format( _( " is riding %s. " ), colorize( mon->name(), c_light_blue ) ); } @@ -6682,7 +6682,7 @@ std::optional iuse::camera( Character *p, item *it, const tripoint_bub_ms & trajectory.push_back( aim_point ); p->mod_moves( -to_moves( 1_seconds ) * 0.5 ); - sounds::sound( p->pos(), 8, sounds::sound_t::activity, _( "Click." ), true, "tool", + sounds::sound( p->pos_bub(), 8, sounds::sound_t::activity, _( "Click." ), true, "tool", "camera_shutter" ); for( std::vector::iterator point_it = trajectory.begin(); @@ -7168,7 +7168,7 @@ static void sendRadioSignal( Character &p, const flag_id &signal ) for( const tripoint_bub_ms &loc : here.points_in_radius( p.pos_bub(), 60 ) ) { for( item &it : here.i_at( loc ) ) { if( it.has_flag( flag_RADIO_ACTIVATION ) && it.has_flag( signal ) ) { - sounds::sound( p.pos(), 6, sounds::sound_t::alarm, _( "beep" ), true, "misc", "beep" ); + sounds::sound( p.pos_bub(), 6, sounds::sound_t::alarm, _( "beep" ), true, "misc", "beep" ); if( it.has_flag( flag_RADIO_INVOKE_PROC ) ) { // Invoke to transform a radio-modded explosive into its active form // The item activation may have all kinds of requirements. Like requiring item to be wielded. @@ -7189,7 +7189,7 @@ static void sendRadioSignal( Character &p, const flag_id &signal ) } ); if( itm != nullptr ) { - sounds::sound( p.pos(), 6, sounds::sound_t::alarm, _( "beep" ), true, "misc", "beep" ); + sounds::sound( p.pos_bub(), 6, sounds::sound_t::alarm, _( "beep" ), true, "misc", "beep" ); // Invoke to transform a radio-modded explosive into its active form if( itm->has_flag( flag_RADIO_INVOKE_PROC ) ) { itm->type->invoke( &p, *itm, loc.raw() ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 6211c41996ab8..125492362b746 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -2025,7 +2025,7 @@ std::optional fireweapon_off_actor::use( Character *p, item &it, 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 ); + sounds::sound( p->pos_bub(), noise, sounds::sound_t::combat, success_message ); } else { p->add_msg_if_player( "%s", success_message ); } @@ -2121,7 +2121,7 @@ std::optional manualnoise_actor::use( Character *p, item &, const tripoint_ // 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, + sounds::sound( p->pos_bub(), noise, sounds::sound_t::activity, noise_message.empty() ? _( "Hsss" ) : noise_message.translated(), true, noise_id, noise_variant ); } p->add_msg_if_player( "%s", use_message ); @@ -2305,10 +2305,10 @@ std::optional musical_instrument_actor::use( Character *p, item &it, } if( morale_effect >= 0 ) { - sounds::sound( p->pos(), volume, sounds::sound_t::music, desc, true, "musical_instrument", + sounds::sound( p->pos_bub(), volume, sounds::sound_t::music, desc, true, "musical_instrument", it.typeId().str() ); } else { - sounds::sound( p->pos(), volume, sounds::sound_t::music, desc, true, "musical_instrument_bad", + sounds::sound( p->pos_bub(), volume, sounds::sound_t::music, desc, true, "musical_instrument_bad", it.typeId().str() ); } diff --git a/src/lightmap.cpp b/src/lightmap.cpp index c358968642a72..b6e36a4429b83 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -660,19 +660,24 @@ void map::add_light_source( const tripoint_bub_ms &p, float luminance ) // Tile light/transparency: 3D lit_level map::light_at( const tripoint &p ) const +{ + return map::light_at( tripoint_bub_ms( p ) ); +} + +lit_level map::light_at( const tripoint_bub_ms &p ) const { if( !inbounds( p ) ) { return lit_level::DARK; // Out of bounds } - const level_cache &map_cache = get_cache_ref( p.z ); + const level_cache &map_cache = get_cache_ref( p.z() ); const auto &lm = map_cache.lm; const auto &sm = map_cache.sm; - if( sm[p.x][p.y] >= LIGHT_SOURCE_BRIGHT ) { + if( sm[p.x()][p.y()] >= LIGHT_SOURCE_BRIGHT ) { return lit_level::BRIGHT; } - const float max_light = lm[p.x][p.y].max(); + const float max_light = lm[p.x()][p.y()].max(); if( max_light >= LIGHT_AMBIENT_LIT ) { return lit_level::LIT; } diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 57d3543dc4a17..181f5249309ad 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -176,7 +176,7 @@ void spell_effect::short_range_teleport( const spell &sp, Creature &caster, static void swap_pos( Creature &caster, const tripoint_bub_ms &target ) { Creature *const critter = get_creature_tracker().creature_at( target ); - critter->setpos( caster.pos() ); + critter->setpos( caster.pos_bub() ); caster.setpos( target ); //update map in case a monster swapped positions with the player @@ -885,7 +885,7 @@ static void spell_move( const spell &sp, const Creature &caster, valid |= victim == &caster && can_target_self; } if( valid ) { - victim->knock_back_to( to.raw() ); + victim->knock_back_to( to ); } } } @@ -1941,7 +1941,7 @@ void spell_effect::slime_split_on_death( const spell &sp, Creature &caster, shared_ptr_fast mon = make_shared_fast( slime_id ); mon->ammo = mon->type->starting_ammo; - if( mon->will_move_to( dest.raw() ) && mon->know_danger_at( dest.raw() ) ) { + if( mon->will_move_to( dest ) && mon->know_danger_at( dest ) ) { if( monster *const blob = g->place_critter_around( mon, dest, 0 ) ) { sp.make_sound( dest, caster ); if( !permanent ) { diff --git a/src/map.cpp b/src/map.cpp index 17c99812ec845..26a6a27d8c46a 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1266,7 +1266,7 @@ bool map::deregister_vehicle_zone( zone_data &zone ) const std::set map::get_moving_vehicle_targets( const Creature &z, int max_range ) { - const tripoint_bub_ms zpos( z.pos() ); + const tripoint_bub_ms zpos( z.pos_bub() ); std::set priority; std::set visible; for( wrapped_vehicle &v : get_vehicles() ) { @@ -7172,7 +7172,7 @@ void map::update_visibility_cache( const int zlev ) return; } - if( player_character.pos_bub().z() - zlev < fov_3d_z_range && zlev > -OVERMAP_DEPTH ) { + if( player_character.posz() - zlev < fov_3d_z_range && zlev > -OVERMAP_DEPTH ) { update_visibility_cache( zlev - 1 ); } visibility_variables_cache.variables_set = true; // Not used yet @@ -9884,15 +9884,15 @@ void map::build_obstacle_cache( } // Iterate over creatures and set them to block their squares relative to their size. for( Creature &critter : g->all_creatures() ) { - const tripoint loc = critter.pos(); - if( loc.z != start.z() ) { + const tripoint_bub_ms loc = critter.pos_bub(); + if( loc.z() != start.z() ) { continue; } // TODO: scale this with expected creature "thickness". - obstacle_cache[loc.x][loc.y].velocity = 1.2f; + obstacle_cache[loc.x()][loc.y()].velocity = 1.2f; // ranged_target_size is "proportion of square that is blocked", and density needs to be // "transmissivity of square", so we need the reciprocal. - obstacle_cache[loc.x][loc.y].density = 1.0 - critter.ranged_target_size(); + obstacle_cache[loc.x()][loc.y()].density = 1.0 - critter.ranged_target_size(); } } @@ -10433,7 +10433,7 @@ void map::maybe_trigger_prox_trap( const tripoint_bub_ms &pos, Creature &c, return; } - if( !tr.has_flag( json_flag_UNDODGEABLE ) && may_avoid && c.avoid_trap( pos.raw(), tr ) ) { + if( !tr.has_flag( json_flag_UNDODGEABLE ) && may_avoid && c.avoid_trap( pos, tr ) ) { Character *const pl = c.as_character(); if( !tr.is_always_invisible() && pl && !pl->knows_trap( pos ) ) { pl->add_msg_if_player( _( "You've spotted a %1$s!" ), tr.name() ); @@ -10467,7 +10467,7 @@ void map::maybe_trigger_trap( const tripoint_bub_ms &pos, Creature &c, const boo return; } - if( !tr.has_flag( json_flag_UNDODGEABLE ) && may_avoid && c.avoid_trap( pos.raw(), tr ) ) { + if( !tr.has_flag( json_flag_UNDODGEABLE ) && may_avoid && c.avoid_trap( pos, tr ) ) { Character *const pl = c.as_character(); if( !tr.is_always_invisible() && pl && !pl->knows_trap( pos ) ) { pl->add_msg_if_player( _( "You've spotted a %1$s!" ), tr.name() ); diff --git a/src/map.h b/src/map.h index 5d99f67e39dc0..9fa1708fd677f 100644 --- a/src/map.h +++ b/src/map.h @@ -2041,7 +2041,9 @@ class map // Light/transparency float light_transparency( const tripoint_bub_ms &p ) const; // Assumes 0,0 is light map center + // TODO: Get rid of untyped overload. lit_level light_at( const tripoint &p ) const; + lit_level light_at( const tripoint_bub_ms &p ) const; // Raw values for tilesets float ambient_light_at( const tripoint_bub_ms &p ) const; /** diff --git a/src/mattack_actors.cpp b/src/mattack_actors.cpp index 56f1434d20381..883ced4c95494 100644 --- a/src/mattack_actors.cpp +++ b/src/mattack_actors.cpp @@ -168,12 +168,12 @@ bool leap_actor::call( monster &z ) const "Candidate farther from target than optimal path, discarded" ); continue; } - if( !ignore_dest_terrain && !z.will_move_to( candidate.raw() ) ) { + if( !ignore_dest_terrain && !z.will_move_to( candidate ) ) { add_msg_debug( debugmode::DF_MATTACK, "Candidate place it can't enter, discarded" ); continue; } - if( !ignore_dest_danger && !z.know_danger_at( candidate.raw() ) ) { + if( !ignore_dest_danger && !z.know_danger_at( candidate ) ) { add_msg_debug( debugmode::DF_MATTACK, "Candidate with dangerous conditions, discarded" ); continue; @@ -619,7 +619,7 @@ int melee_actor::do_grab( monster &z, Creature *target, bodypart_id bp_id ) cons if( z.can_move_to( target_square ) ) { monster *zz = target->as_monster(); tripoint_bub_ms zpt = z.pos_bub(); - z.move_to( target_square.raw(), false, false, grab_data.drag_movecost_mod ); + z.move_to( target_square, false, false, grab_data.drag_movecost_mod ); if( !g->is_empty( zpt ) ) { //Cancel the grab if the space is occupied by something return 0; } @@ -720,7 +720,7 @@ bool melee_actor::call( monster &z ) const if( uncanny_dodgeable && target->uncanny_dodge() ) { game_message_type msg_type = target->is_avatar() ? m_warning : m_info; - sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ), + sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos_bub() ), sfx::get_heard_angle( z.pos() ) ); target->add_msg_player_or_npc( msg_type, miss_msg_u, get_option( "LOG_MONSTER_ATTACK_MONSTER" ) ? miss_msg_npc : translation(), @@ -730,7 +730,7 @@ bool melee_actor::call( monster &z ) const if( dodgeable ) { if( hitspread < 0 ) { - sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ), + sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos_bub() ), sfx::get_heard_angle( z.pos() ) ); target->add_msg_player_or_npc( msg_type, miss_msg_u, get_option( "LOG_MONSTER_ATTACK_MONSTER" ) ? miss_msg_npc : translation(), @@ -865,7 +865,7 @@ bool melee_actor::call( monster &z ) const if( damage_total > 0 ) { on_damage( z, *target, dealt_damage ); } else { - sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos() ), + sfx::play_variant_sound( "mon_bite", "bite_miss", sfx::get_heard_volume( z.pos_bub() ), sfx::get_heard_angle( z.pos() ) ); target->add_msg_player_or_npc( msg_type, no_dmg_msg_u, get_option( "LOG_MONSTER_ATTACK_MONSTER" ) ? no_dmg_msg_npc : translation(), @@ -885,7 +885,7 @@ bool melee_actor::call( monster &z ) const } if( throw_strength > 0 && !( target->has_flag( mon_flag_IMMOBILE ) || target->has_effect_with_flag( json_flag_CANNOT_MOVE ) ) ) { - if( g->fling_creature( target, coord_to_angle( z.pos(), target->pos() ), + if( g->fling_creature( target, coord_to_angle( z.pos_bub(), target->pos_bub() ), throw_strength ) ) { target->add_msg_player_or_npc( msg_type, throw_msg_u, get_option( "LOG_MONSTER_ATTACK_MONSTER" ) ? throw_msg_npc : translation(), @@ -907,9 +907,9 @@ bool melee_actor::call( monster &z ) const // the item is ripped off your character if( sturdiness < chance ) { float path_distance = rng_float( 0, 1.0 ); - tripoint vector = target->pos() - z.pos(); - vector = tripoint( vector.x * path_distance, vector.y * path_distance, vector.z * path_distance ); - pd[index]->spill_contents( z.pos() + vector ); + tripoint_rel_ms vector = target->pos_bub() - z.pos_bub(); + vector = { vector.x() *path_distance, vector.y() *path_distance, vector.z() *path_distance }; + pd[index]->spill_contents( z.pos() + vector.raw() ); add_msg( m_bad, _( "As you hit the ground something comes loose and is knocked away from you!" ) ); popup( _( "As you hit the ground something comes loose and is knocked away from you!" ) ); } @@ -1194,7 +1194,7 @@ bool gun_actor::try_target( monster &z, Creature &target ) const if( not_targeted || not_laser_locked ) { if( targeting_volume > 0 && !targeting_sound.empty() ) { - sounds::sound( z.pos(), targeting_volume, sounds::sound_t::alarm, + sounds::sound( z.pos_bub(), targeting_volume, sounds::sound_t::alarm, targeting_sound ); } if( not_targeted ) { @@ -1259,7 +1259,7 @@ bool gun_actor::shoot( monster &z, const tripoint_bub_ms &target, const gun_mode if( !gun.ammo_sufficient( nullptr ) ) { if( !no_ammo_sound.empty() ) { - sounds::sound( z.pos(), 10, sounds::sound_t::combat, no_ammo_sound ); + sounds::sound( z.pos_bub(), 10, sounds::sound_t::combat, no_ammo_sound ); } return false; } diff --git a/src/melee.cpp b/src/melee.cpp index 148b9ab7ff443..92fa730425367 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -864,7 +864,7 @@ bool Character::melee_attack_abstract( Creature &t, bool allow_special, if( !is_quiet() ) { // check martial arts silence //sound generated later int volume = enchantment_cache->modify_value( enchant_vals::mod::ATTACK_NOISE, 8 ); - sounds::sound( pos(), volume, sounds::sound_t::combat, _( "whack!" ) ); + sounds::sound( pos_bub(), volume, sounds::sound_t::combat, _( "whack!" ) ); } std::string material = "flesh"; if( t.is_monster() ) { @@ -1584,8 +1584,8 @@ bool Character::valid_aoe_technique( Creature const &t, const ma_technique &tech if( technique.aoe == "wide" ) { //check if either (or both) of the squares next to our target contain a possible victim //offsets are a pre-computed matrix allowing us to quickly lookup adjacent squares - tripoint left = pos() + tripoint( offset_a[lookup], offset_b[lookup], 0 ); - tripoint right = pos() + tripoint( offset_b[lookup], -offset_a[lookup], 0 ); + tripoint_bub_ms left = pos_bub() + tripoint_rel_ms( offset_a[lookup], offset_b[lookup], 0 ); + tripoint_bub_ms right = pos_bub() + tripoint_rel_ms( offset_b[lookup], -offset_a[lookup], 0 ); monster *const mon_l = creatures.creature_at( left ); if( mon_l && mon_l->friendly == 0 ) { @@ -1613,9 +1613,9 @@ bool Character::valid_aoe_technique( Creature const &t, const ma_technique &tech // Impale hits the target and a single target behind them // Check if the square cardinally behind our target, or to the left / right, // contains a possible target. - tripoint left = t.pos() + tripoint( offset_a[lookup], offset_b[lookup], 0 ); - tripoint target_pos = t.pos() + ( t.pos() - pos() ); - tripoint right = t.pos() + tripoint( offset_b[lookup], -offset_b[lookup], 0 ); + tripoint_bub_ms left = t.pos_bub() + tripoint_rel_ms( offset_a[lookup], offset_b[lookup], 0 ); + tripoint_bub_ms target_pos = t.pos_bub() + ( t.pos_bub() - pos_bub() ); + tripoint_bub_ms right = t.pos_bub() + tripoint_rel_ms( offset_b[lookup], -offset_b[lookup], 0 ); monster *const mon_l = creatures.creature_at( left ); monster *const mon_t = creatures.creature_at( target_pos ); @@ -1776,7 +1776,8 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, // if the weapon needs ammo we now expend it cur_weapon.get_item()->ammo_consume( 1, pos_bub(), this ); // thing going off should be as loud as the ammo - sounds::sound( pos(), current_ammo->ammo->loudness, sounds::sound_t::combat, _( "Crack!" ), true ); + sounds::sound( pos_bub(), current_ammo->ammo->loudness, sounds::sound_t::combat, _( "Crack!" ), + true ); const itype_id casing = *current_ammo->ammo->casing; if( cur_weapon.get_item()->has_flag( flag_RELOAD_EJECT ) ) { cur_weapon.get_item()->force_insert_item( item( casing ).set_flag( flag_CASING ), @@ -1787,26 +1788,26 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, if( technique.side_switch && !( t.has_flag( mon_flag_IMMOBILE ) || t.has_effect_with_flag( json_flag_CANNOT_MOVE ) ) ) { - const tripoint b = t.pos(); + const tripoint_bub_ms b = t.pos_bub(); point new_; - if( b.x > posx() ) { + if( b.x() > posx() ) { new_.x = posx() - 1; - } else if( b.x < posx() ) { + } else if( b.x() < posx() ) { new_.x = posx() + 1; } else { - new_.x = b.x; + new_.x = b.x(); } - if( b.y > posy() ) { + if( b.y() > posy() ) { new_.y = posy() - 1; - } else if( b.y < posy() ) { + } else if( b.y() < posy() ) { new_.y = posy() + 1; } else { - new_.y = b.y; + new_.y = b.y(); } - const tripoint_bub_ms &dest{ new_.x, new_.y, b.z }; + const tripoint_bub_ms &dest{ new_.x, new_.y, b.z()}; if( g->is_empty( dest ) ) { t.setpos( dest ); } @@ -1817,7 +1818,7 @@ void Character::perform_technique( const ma_technique &technique, Creature &t, const tripoint_bub_ms prev_pos = t.pos_bub(); // track target startpoint for knockback_follow const point kb_offset( rng( -technique.knockback_spread, technique.knockback_spread ), rng( -technique.knockback_spread, technique.knockback_spread ) ); - tripoint kb_point( posx() + kb_offset.x, posy() + kb_offset.y, posz() ); + tripoint_bub_ms kb_point( posx() + kb_offset.x, posy() + kb_offset.y, posz() ); for( int dist = rng( 1, technique.knockback_dist ); dist > 0; dist-- ) { t.knock_back_from( kb_point ); } @@ -2281,7 +2282,7 @@ std::string Character::melee_special_effects( Creature &t, damage_instance &d, i weap.tname() ); } - sounds::sound( pos(), 16, sounds::sound_t::combat, "Crack!", true, "smash_success", + sounds::sound( pos_bub(), 16, sounds::sound_t::combat, "Crack!", true, "smash_success", "smash_glass_contents" ); // Dump its contents on the ground weap.spill_contents( pos_bub() ); diff --git a/src/monattack.cpp b/src/monattack.cpp index 9f2a69d005aad..febffc35aea21 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -237,14 +237,14 @@ static const trait_id trait_THRESH_MYCUS( "THRESH_MYCUS" ); static bool within_visual_range( monster *z, int max_range ) { Character &player_character = get_player_character(); - return !( rl_dist( z->pos(), player_character.pos() ) > max_range || + return !( rl_dist( z->pos_bub(), player_character.pos_bub() ) > max_range || !z->sees( player_character ) ); } static bool within_target_range( const monster *const z, const Creature *const target, int range ) { return target != nullptr && - rl_dist( z->pos(), target->pos() ) <= range && + rl_dist( z->pos_bub(), target->pos_bub() ) <= range && z->sees( *target ); } @@ -262,7 +262,7 @@ static Creature *sting_get_target( monster *z, float range = 5.0f ) return nullptr; } - return rl_dist( z->pos(), target->pos() ) <= range ? target : nullptr; + return rl_dist( z->pos_bub(), target->pos_bub() ) <= range ? target : nullptr; } static bool sting_shoot( monster *z, Creature *target, damage_instance &dam, float range ) @@ -605,14 +605,14 @@ bool mattack::shriek( monster *z ) { Creature *target = z->attack_target(); if( target == nullptr || - rl_dist( z->pos(), target->pos() ) > 4 || + rl_dist( z->pos_bub(), target->pos_bub() ) > 4 || !z->sees( *target ) ) { return false; } // It takes a while z->mod_moves( -to_moves( 1_seconds ) * 2.4 ); - sounds::sound( z->pos(), 50, sounds::sound_t::alert, _( "a terrible shriek!" ), false, "shout", + sounds::sound( z->pos_bub(), 50, sounds::sound_t::alert, _( "a terrible shriek!" ), false, "shout", "shriek" ); return true; } @@ -625,13 +625,13 @@ bool mattack::shriek_alert( monster *z ) Creature *target = z->attack_target(); - if( target == nullptr || rl_dist( z->pos(), target->pos() ) > 15 || + if( target == nullptr || rl_dist( z->pos_bub(), target->pos_bub() ) > 15 || !z->sees( *target ) ) { return false; } add_msg_if_player_sees( *z, _( "The %s begins shrieking!" ), z->name() ); z->mod_moves( -to_moves( 1_seconds ) * 1.5 ); - sounds::sound( z->pos(), 120, sounds::sound_t::alert, _( "a piercing wail!" ), false, "shout", + sounds::sound( z->pos_bub(), 120, sounds::sound_t::alert, _( "a piercing wail!" ), false, "shout", "wail" ); z->add_effect( effect_shrieking, 1_minutes ); @@ -649,7 +649,7 @@ bool mattack::shriek_stun( monster *z ) return false; } - int dist = rl_dist( z->pos(), target->pos() ); + int dist = rl_dist( z->pos_bub(), target->pos_bub() ); // Currently the cone is 2D, so don't use it for 3D attacks if( dist > 7 || z->posz() != target->posz() || @@ -657,7 +657,7 @@ bool mattack::shriek_stun( monster *z ) return false; } - units::angle target_angle = coord_to_angle( z->pos(), target->pos() ); + units::angle target_angle = coord_to_angle( z->pos_bub(), target->pos_bub() ); units::angle cone_angle = 20_degrees; map &here = get_map(); creature_tracker &creatures = get_creature_tracker(); @@ -692,14 +692,14 @@ bool mattack::rattle( monster *z ) const int min_dist = z->friendly != 0 ? 1 : 4; Creature *target = &get_player_character(); // Can't use attack_target - the snake has no target - if( rl_dist( z->pos(), target->pos() ) > min_dist || + if( rl_dist( z->pos_bub(), target->pos_bub() ) > min_dist || !z->sees( *target ) ) { return false; } // It takes a very short while z->mod_moves( -to_moves( 1_seconds ) * 0.2 ); - sounds::sound( z->pos(), 10, sounds::sound_t::alarm, _( "a sibilant rattling sound!" ), false, + sounds::sound( z->pos_bub(), 10, sounds::sound_t::alarm, _( "a sibilant rattling sound!" ), false, "misc", "rattling" ); return true; @@ -724,7 +724,7 @@ bool mattack::acid( monster *z ) } // It takes a while z->mod_moves( -to_moves( 3_seconds ) ); - sounds::sound( z->pos(), 4, sounds::sound_t::combat, _( "a spitting noise." ), false, "misc", + sounds::sound( z->pos_bub(), 4, sounds::sound_t::combat, _( "a spitting noise." ), false, "misc", "spitting" ); projectile proj; @@ -862,7 +862,7 @@ bool mattack::shockstorm( monster *z ) add_msg( msg_type, _( "A bolt of electricity arcs towards %s!" ), target->disp_name() ); } if( !player_character.is_deaf() ) { - sfx::play_variant_sound( "fire_gun", "bio_lightning", sfx::get_heard_volume( z->pos() ) ); + sfx::play_variant_sound( "fire_gun", "bio_lightning", sfx::get_heard_volume( z->pos_bub() ) ); } tripoint_bub_ms tarp( target->posx() + rng( -1, 1 ) + rng( -1, 1 ), target->posy() + rng( -1, 1 ) + rng( -1, 1 ), @@ -890,7 +890,7 @@ bool mattack::shocking_reveal( monster *z ) shockstorm( z ); const translation WHAT_A_SCOOP = SNIPPET.random_from_category( "clickbait" ).value_or( translation() ); - sounds::sound( z->pos(), 10, sounds::sound_t::alert, + sounds::sound( z->pos_bub(), 10, sounds::sound_t::alert, string_format( _( "the %s obnoxiously yelling \"%s!!!\"" ), z->name(), WHAT_A_SCOOP ) ); return true; @@ -955,7 +955,7 @@ bool mattack::pull_metal_weapon( monster *z ) proj.speed = 50; proj.impact = damage_instance( damage_bash, pulled_weapon.weight() / 250_gram ); // make the projectile stop one tile short to prevent hitting the monster - proj.range = rl_dist( foe->pos(), z->pos() ) - 1; + proj.range = rl_dist( foe->pos_bub(), z->pos_bub() ) - 1; proj.proj_effects = { { ammo_effect_NO_ITEM_DAMAGE, ammo_effect_DRAW_AS_LINE, ammo_effect_NO_DAMAGE_SCALING, ammo_effect_JET } }; dealt_projectile_attack dealt = projectile_attack( proj, foe->pos_bub(), z->pos_bub(), @@ -986,7 +986,7 @@ bool mattack::boomer( monster *z ) } Creature *target = z->attack_target(); - if( target == nullptr || rl_dist( z->pos(), target->pos() ) > 3 || !z->sees( *target ) ) { + if( target == nullptr || rl_dist( z->pos_bub(), target->pos_bub() ) > 3 || !z->sees( *target ) ) { return false; } @@ -1027,7 +1027,7 @@ bool mattack::boomer_glow( monster *z ) } Creature *target = z->attack_target(); - if( target == nullptr || rl_dist( z->pos(), target->pos() ) > 3 || !z->sees( *target ) ) { + if( target == nullptr || rl_dist( z->pos_bub(), target->pos_bub() ) > 3 || !z->sees( *target ) ) { return false; } @@ -1268,7 +1268,7 @@ bool mattack::smash( monster *z ) z->remove_effect( effect_grabbing ); // TODO: Make this parabolic - g->fling_creature( target, coord_to_angle( z->pos(), target->pos() ), + g->fling_creature( target, coord_to_angle( z->pos_bub(), target->pos_bub() ), z->type->melee_sides * z->type->melee_dice * 3 ); return true; @@ -1452,7 +1452,7 @@ bool mattack::growplants( monster *z ) bool mattack::grow_vine( monster *z ) { if( z->friendly ) { - if( rl_dist( get_player_character().pos(), z->pos() ) <= 3 ) { + if( rl_dist( get_player_character().pos_bub(), z->pos_bub() ) <= 3 ) { // Friendly vines keep the area around you free, so you can move. return false; } @@ -1543,7 +1543,7 @@ bool mattack::spit_sap( monster *z ) Creature *target = z->attack_target(); if( target == nullptr || - rl_dist( z->pos(), target->pos() ) > 12 || + rl_dist( z->pos_bub(), target->pos_bub() ) > 12 || !z->sees( *target ) ) { return false; } @@ -1562,7 +1562,7 @@ bool mattack::spit_sap( monster *z ) bool mattack::triffid_heartbeat( monster *z ) { - sounds::sound( z->pos(), 14, sounds::sound_t::movement, _( "thu-THUMP." ), true, "misc", + sounds::sound( z->pos_bub(), 14, sounds::sound_t::movement, _( "thu-THUMP." ), true, "misc", "heartbeat" ); z->mod_moves( -to_moves( 3_seconds ) ); if( z->friendly != 0 ) { @@ -1632,7 +1632,7 @@ bool mattack::fungus( monster *z ) 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" ); + sounds::sound( z->pos_bub(), 10, sounds::sound_t::combat, _( "Pouf!" ), false, "misc", "puff" ); add_msg_if_player_sees( *z, m_warning, _( "Spores are released from the %s!" ), z->name() ); // Use less laggy methods of reproduction when there is a lot of mons around @@ -1681,7 +1681,7 @@ bool mattack::fungus( monster *z ) bool mattack::fungus_corporate( monster *z ) { if( x_in_y( 1, 20 ) ) { - sounds::sound( z->pos(), 10, sounds::sound_t::speech, _( "\"Buy SpOreos™ now!\"" ) ); + sounds::sound( z->pos_bub(), 10, sounds::sound_t::speech, _( "\"Buy SpOreos™ now!\"" ) ); if( get_player_view().sees( *z ) ) { add_msg( m_warning, _( "Delicious snacks are released from the %s!" ), z->name() ); get_map().add_item( z->pos_bub(), item( "sporeos" ) ); @@ -1695,7 +1695,7 @@ bool mattack::fungus_corporate( monster *z ) bool mattack::fungus_haze( monster *z ) { //~ That spore sound again - sounds::sound( z->pos(), 10, sounds::sound_t::combat, _( "Pouf!" ), true, "misc", "puff" ); + sounds::sound( z->pos_bub(), 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->mod_moves( -to_moves( 1_seconds ) * 1.5 ); @@ -1730,18 +1730,18 @@ bool mattack::fungus_big_blossom( monster *z ) add_msg( m_warning, _( "The %s suddenly inhales!" ), z->name() ); } //~Sound of a giant fungal blossom inhaling - sounds::sound( z->pos(), 20, sounds::sound_t::combat, _( "WOOOSH!" ), true, "misc", "inhale" ); + sounds::sound( z->pos_bub(), 20, sounds::sound_t::combat, _( "WOOOSH!" ), true, "misc", "inhale" ); if( u_see ) { add_msg( m_bad, _( "The %s discharges an immense flow of spores, smothering the flames!" ), z->name() ); } //~Sound of a giant fungal blossom blowing out the dangerous fire! - sounds::sound( z->pos(), 20, sounds::sound_t::combat, _( "POUFF!" ), true, "misc", "exhale" ); + sounds::sound( z->pos_bub(), 20, sounds::sound_t::combat, _( "POUFF!" ), true, "misc", "exhale" ); return true; } else { // No fire detected, routine haze-emission //~ That spore sound, much louder - sounds::sound( z->pos(), 15, sounds::sound_t::combat, _( "POUF." ), true, "misc", "puff" ); + sounds::sound( z->pos_bub(), 15, sounds::sound_t::combat, _( "POUF." ), true, "misc", "puff" ); if( u_see ) { add_msg( m_info, _( "The %s pulses, and fresh fungal material bursts forth!" ), z->name() ); } @@ -1759,7 +1759,7 @@ bool mattack::fungus_inject( monster *z ) // For faster copy+paste Creature *target = &get_player_character(); Character &player_character = get_player_character(); - if( rl_dist( z->pos(), player_character.pos() ) > 1 ) { + if( rl_dist( z->pos_bub(), player_character.pos_bub() ) > 1 ) { return false; } @@ -1896,7 +1896,7 @@ bool mattack::fungus_sprout( monster *z ) } if( push_player ) { - const units::angle angle = coord_to_angle( z->pos(), player_character.pos() ); + const units::angle angle = coord_to_angle( z->pos_bub(), player_character.pos_bub() ); add_msg( m_bad, _( "You're shoved away as a fungal wall grows!" ) ); g->fling_creature( &player_character, angle, rng( 10, 50 ) ); } @@ -1926,7 +1926,7 @@ bool mattack::fungus_fortify( monster *z ) // You have the other two. Is it really necessary for us to fight? add_msg( m_info, _( "The %s spreads its tendrils. It seems as though it's expecting you…" ), z->name() ); - if( rl_dist( z->pos(), player_character.pos() ) < 3 ) { + if( rl_dist( z->pos_bub(), player_character.pos_bub() ) < 3 ) { if( query_yn( _( "The tower extends and aims several tendrils from its depths. Hold still?" ) ) ) { add_msg( m_warning, _( "The %s works several tendrils into your arms, legs, torso, and even neck…" ), @@ -1937,7 +1937,7 @@ bool mattack::fungus_fortify( monster *z ) player_character.unset_mutation( trait_MARLOSS ); player_character.unset_mutation( trait_MARLOSS_BLUE ); player_character.set_mutation( trait_THRESH_MARLOSS ); - here.ter_set( player_character.pos(), + here.ter_set( player_character.pos_bub(), ter_t_marloss ); // We only show you the door. You walk through it on your own. get_memorial().add( pgettext( "memorial_male", "Was shown to the Marloss Gateway." ), @@ -1969,15 +1969,16 @@ bool mattack::fungus_fortify( monster *z ) } if( push_player ) { add_msg( m_bad, _( "You're shoved away as a fungal hedgerow grows!" ) ); - g->fling_creature( &player_character, coord_to_angle( z->pos(), player_character.pos() ), rng( 10, - 50 ) ); + g->fling_creature( &player_character, coord_to_angle( z->pos_bub(), player_character.pos_bub() ), + rng( 10, + 50 ) ); } if( fortified || mycus || peaceful ) { return true; } // TODO: De-playerize the whole block - const int dist = rl_dist( z->pos(), player_character.pos() ); + const int dist = rl_dist( z->pos_bub(), player_character.pos_bub() ); if( dist >= 12 ) { return false; } @@ -2152,7 +2153,7 @@ bool mattack::formblob( monster *z ) // If we're big enough, spawn a baby blob. shared_ptr_fast mon = make_shared_fast( mon_blob_small ); mon->ammo = mon->type->starting_ammo; - if( mon->will_move_to( dest.raw() ) && mon->know_danger_at( dest.raw() ) ) { + if( mon->will_move_to( dest ) && mon->know_danger_at( dest ) ) { didit = true; z->set_speed_base( z->get_speed_base() - mon_blob_small->speed ); if( monster *const blob = g->place_critter_around( mon, dest, 0 ) ) { @@ -2436,17 +2437,17 @@ bool mattack::nurse_check_up( monster *z ) // First we offer the check up then we wait to the player to come close if( !z->has_effect( effect_countdown ) ) { - sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Come here and stand still for a few minutes, I'll give you a check-up.\"" ) ) ); z->add_effect( effect_countdown, 30_minutes ); - } else if( rl_dist( target->pos(), z->pos() ) > 1 ) { + } else if( rl_dist( target->pos_bub(), z->pos_bub() ) > 1 ) { // Giving them some encouragement - sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Come on. I don't bite, I promise it won't hurt one bit.\"" ) ) ); } else { - sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Here we go. Just hold still.\"" ) ) ); if( target->is_avatar() ) { @@ -2488,7 +2489,7 @@ bool mattack::nurse_assist( monster *z ) if( found_target ) { if( target->is_wearing( itype_badge_doctor ) || z->attitude_to( *target ) == Creature::Attitude::FRIENDLY ) { - sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 8, sounds::sound_t::electronic_speech, SNIPPET.expand( target->male ? _( "a soft robotic voice say, \"Welcome doctor . I'll be your assistant today.\"" ) : _( "a soft robotic voice say, \"Welcome doctor . I'll be your assistant today.\"" ) ) ); @@ -2573,13 +2574,13 @@ bool mattack::nurse_operate( monster *z ) monster *mon = dynamic_cast( critter ); if( mon != nullptr && mon != z ) { if( mon->type->id != mon_nursebot_defective ) { - sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Unhand this patient immediately! If you keep interfering with the procedure I'll be forced to call law enforcement.\"" ) ) ); // Try to push the perpetrator away - z->push_to( mon->pos(), 6, 0 ); + z->push_to( mon->pos_bub(), 6, 0 ); } else { - sounds::sound( z->pos(), 8, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Greetings kinbot. Please take good care of this patient.\"" ) ) ); z->anger = 0; @@ -2624,7 +2625,7 @@ bool mattack::check_money_left( monster *z ) } const SpeechBubble &speech_no_time = get_speech( "mon_grocerybot_friendship_done" ); - sounds::sound( z->pos(), speech_no_time.volume, + sounds::sound( z->pos_bub(), speech_no_time.volume, sounds::sound_t::electronic_speech, speech_no_time.text ); z->remove_effect( effect_paid ); return true; @@ -2634,7 +2635,7 @@ bool mattack::check_money_left( monster *z ) if( time_left < 1_minutes ) { if( calendar::once_every( 20_seconds ) ) { const SpeechBubble &speech_time_low = get_speech( "mon_grocerybot_running_out_of_friendship" ); - sounds::sound( z->pos(), speech_time_low.volume, + sounds::sound( z->pos_bub(), speech_time_low.volume, sounds::sound_t::electronic_speech, speech_time_low.text ); } } @@ -2642,7 +2643,7 @@ bool mattack::check_money_left( monster *z ) if( z->friendly == -1 && !z->has_effect( effect_paid ) ) { if( calendar::once_every( 3_hours ) ) { const SpeechBubble &speech_override_start = get_speech( "mon_grocerybot_hacked" ); - sounds::sound( z->pos(), speech_override_start.volume, + sounds::sound( z->pos_bub(), speech_override_start.volume, sounds::sound_t::electronic_speech, speech_override_start.text ); } } @@ -2747,15 +2748,15 @@ bool mattack::photograph( monster *z ) } else { msg = _( "a robotic voice boom, \"Citizen… database connection lost!\"" ); } - sounds::sound( z->pos(), 15, sounds::sound_t::alert, msg, false, "speech", z->type->id.str() ); + sounds::sound( z->pos_bub(), 15, sounds::sound_t::alert, msg, false, "speech", z->type->id.str() ); if( player_character.is_armed() ) { std::string msg = string_format( _( "\"Drop your %s! Now!\"" ), weapon->is_gun() ? _( "gun" ) : _( "weapon" ) ); - sounds::sound( z->pos(), 15, sounds::sound_t::alert, msg ); + sounds::sound( z->pos_bub(), 15, sounds::sound_t::alert, msg ); } const SpeechBubble &speech = get_speech( z->type->id.str() ); - sounds::sound( z->pos(), speech.volume, sounds::sound_t::alert, speech.text.translated() ); + sounds::sound( z->pos_bub(), speech.volume, sounds::sound_t::alert, speech.text.translated() ); const effect &depleted = z->get_effect( effect_eyebot_depleted ); const effect &assisted = z->get_effect( effect_eyebot_assisted ); @@ -3052,22 +3053,22 @@ bool mattack::copbot( monster *z ) return true; } - if( rl_dist( z->pos(), target->pos() ) > 2 || foe == nullptr || !z->sees( *target ) ) { + if( rl_dist( z->pos_bub(), target->pos_bub() ) > 2 || foe == nullptr || !z->sees( *target ) ) { if( one_in( 3 ) ) { if( sees_u ) { if( foe->unarmed_attack() ) { - sounds::sound( z->pos(), 18, sounds::sound_t::alert, + sounds::sound( z->pos_bub(), 18, sounds::sound_t::alert, _( "a robotic voice boom, \"Citizen, Halt!\"" ), false, "speech", z->type->id.str() ); } else if( !cuffed ) { - sounds::sound( z->pos(), 18, sounds::sound_t::alert, + sounds::sound( z->pos_bub(), 18, sounds::sound_t::alert, _( "a robotic voice boom, \"Please put down your weapon.\"" ), false, "speech", z->type->id.str() ); } } else { - sounds::sound( z->pos(), 18, sounds::sound_t::alert, + sounds::sound( z->pos_bub(), 18, sounds::sound_t::alert, _( "a robotic voice boom, \"Come out with your hands up!\"" ), false, "speech", z->type->id.str() ); } } else { - sounds::sound( z->pos(), 18, sounds::sound_t::alarm, + sounds::sound( z->pos_bub(), 18, sounds::sound_t::alarm, _( "a police siren, whoop WHOOP" ), false, "environment", "police_siren" ); } return true; @@ -3092,7 +3093,7 @@ bool mattack::ratking( monster *z ) } Character &player_character = get_player_character(); // Disable z-level ratting or it can get silly - if( rl_dist( z->pos(), player_character.pos() ) > 50 || + if( rl_dist( z->pos_bub(), player_character.pos_bub() ) > 50 || z->posz() != player_character.posz() ) { return false; } @@ -3114,7 +3115,7 @@ bool mattack::ratking( monster *z ) add_msg( m_warning, _( "\"FOUL INTERLOPER…\"" ) ); break; } - if( rl_dist( z->pos(), player_character.pos() ) <= 10 ) { + if( rl_dist( z->pos_bub(), player_character.pos_bub() ) <= 10 ) { player_character.add_effect( effect_rat, 3_minutes ); } @@ -3123,7 +3124,7 @@ bool mattack::ratking( monster *z ) bool mattack::generator( monster *z ) { - sounds::sound( z->pos(), 100, sounds::sound_t::activity, "hmmmm" ); + sounds::sound( z->pos_bub(), 100, sounds::sound_t::activity, "hmmmm" ); if( calendar::once_every( 1_minutes ) && z->get_hp() < z->get_hp_max() ) { z->heal( 1 ); } @@ -3248,7 +3249,7 @@ bool mattack::flesh_golem( monster *z ) return false; } - int dist = rl_dist( z->pos(), target->pos() ); + int dist = rl_dist( z->pos_bub(), target->pos_bub() ); if( dist > 20 || !z->sees( *target ) ) { return false; @@ -3258,7 +3259,7 @@ bool mattack::flesh_golem( monster *z ) if( one_in( 12 ) ) { 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", + sounds::sound( z->pos_bub(), 80, sounds::sound_t::alert, _( "a terrifying roar!" ), false, "shout", "roar" ); return true; } @@ -3364,7 +3365,7 @@ bool mattack::lunge( monster *z ) return false; } - int dist = rl_dist( z->pos(), target->pos() ); + int dist = rl_dist( z->pos_bub(), target->pos_bub() ); if( dist > 20 || !z->sees( *target ) ) { return false; @@ -3439,7 +3440,8 @@ bool mattack::blow_whistle( monster *z ) return false; } add_msg_if_player_sees( *z, m_warning, _( "The %1$s loudly blows their whistle!" ), z->name() ); - sounds::sound( z->pos(), 40, sounds::sound_t::alarm, _( "FWEEEET!" ), false, "misc", "whistle" ); + sounds::sound( z->pos_bub(), 40, sounds::sound_t::alarm, _( "FWEEEET!" ), false, "misc", + "whistle" ); return true; } @@ -3449,14 +3451,14 @@ static void parrot_common( monster *parrot ) // It takes a while 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(), + sounds::sound( parrot->pos_bub(), speech.volume, sounds::sound_t::speech, speech.text.translated(), false, "speech", parrot->type->id.str() ); } 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", + sounds::sound( z->pos_bub(), 120, sounds::sound_t::alert, _( "a piercing wail!" ), false, "shout", "wail" ); z->mod_moves( -to_moves( 1_seconds ) * 0.4 ); return false; @@ -3502,7 +3504,7 @@ bool mattack::darkman( monster *z ) return false; } Character &player_character = get_player_character(); - if( rl_dist( z->pos(), player_character.pos() ) > 40 ) { + if( rl_dist( z->pos_bub(), player_character.pos_bub() ) > 40 ) { return false; } if( monster *const shadow = g->place_critter_around( mon_shadow, z->pos_bub(), 1 ) ) { @@ -3546,7 +3548,7 @@ bool mattack::darkman( monster *z ) bool mattack::slimespring( monster *z ) { Character &player_character = get_player_character(); - if( rl_dist( z->pos(), player_character.pos() ) > 30 ) { + if( rl_dist( z->pos_bub(), player_character.pos_bub() ) > 30 ) { return false; } @@ -3560,7 +3562,7 @@ bool mattack::slimespring( monster *z ) add_msg( m_good, "%s", SNIPPET.random_from_category( "slime_cheers" ).value_or( translation() ) ); player_character.remove_effect( effect_social_dissatisfied ); } - if( rl_dist( z->pos(), player_character.pos() ) <= 3 && z->sees( player_character ) ) { + if( rl_dist( z->pos_bub(), player_character.pos_bub() ) <= 3 && z->sees( player_character ) ) { if( player_character.has_effect( effect_bleed ) || player_character.has_effect( effect_bite ) ) { //~ Lowercase is intended: they're small voices. @@ -3619,7 +3621,7 @@ bool mattack::riotbot( monster *z ) z->anger = 0; if( calendar::once_every( 25_turns ) ) { - sounds::sound( z->pos(), 10, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 10, sounds::sound_t::electronic_speech, _( "Halt and submit to arrest, citizen! The police will be here any moment." ), false, "speech", z->type->id.str() ); } @@ -3633,12 +3635,12 @@ bool mattack::riotbot( monster *z ) return true; } - const int dist = rl_dist( z->pos(), target->pos() ); + const int dist = rl_dist( z->pos_bub(), target->pos_bub() ); // We need empty hands to arrest if( foe && foe->is_avatar() && !foe->is_armed() ) { - sounds::sound( z->pos(), 15, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 15, sounds::sound_t::electronic_speech, _( "Please stay in place, citizen, do not make any movements!" ), false, "speech", z->type->id.str() ); @@ -3705,14 +3707,14 @@ bool mattack::riotbot( monster *z ) add_msg( m_bad, _( "The robot puts handcuffs on you." ) ); } - sounds::sound( z->pos(), 5, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 5, sounds::sound_t::electronic_speech, _( "You are under arrest, citizen. You have the right to remain silent. If you do not remain silent, anything you say may be used against you in a court of law." ), false, "speech", z->type->id.str() ); - sounds::sound( z->pos(), 5, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 5, sounds::sound_t::electronic_speech, _( "You have the right to an attorney. If you cannot afford an attorney, one will be provided at no cost to you. You may have your attorney present during any questioning." ) ); - sounds::sound( z->pos(), 5, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 5, sounds::sound_t::electronic_speech, _( "If you do not understand these rights, an officer will explain them in greater detail when taking you into custody." ) ); - sounds::sound( z->pos(), 5, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 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->mod_moves( -to_moves( 3_seconds ) ); @@ -3759,7 +3761,7 @@ bool mattack::riotbot( monster *z ) } if( calendar::once_every( 5_turns ) ) { - sounds::sound( z->pos(), 25, sounds::sound_t::electronic_speech, + sounds::sound( z->pos_bub(), 25, sounds::sound_t::electronic_speech, _( "Empty your hands and hold your position, citizen!" ), false, "speech", z->type->id.str() ); } @@ -3779,7 +3781,7 @@ bool mattack::riotbot( monster *z ) target->posz() ); //~ Sound of a riot control bot using its blinding flash - sounds::sound( z->pos(), 3, sounds::sound_t::combat, _( "fzzzzzt" ), false, "misc", "flash" ); + sounds::sound( z->pos_bub(), 3, sounds::sound_t::combat, _( "fzzzzzt" ), false, "misc", "flash" ); std::vector traj = line_to( z->pos_bub(), dest, 0, 0 ); for( tripoint_bub_ms &elem : traj ) { @@ -3905,7 +3907,7 @@ bool mattack::mon_leech_evolution( monster *z ) std::list queens; for( monster &candidate : g->all_monsters() ) { if( candidate.in_species( species_LEECH_PLANT ) && candidate.has_flag( mon_flag_QUEEN ) && - rl_dist( z->pos(), candidate.pos() ) < 35 ) { + rl_dist( z->pos_bub(), candidate.pos_bub() ) < 35 ) { queens.push_back( &candidate ); } } @@ -3970,13 +3972,13 @@ bool mattack::flesh_tendril( monster *z ) if( one_in( 70 ) ) { add_msg( _( "The floor trembles underneath your feet." ) ); z->mod_moves( -to_moves( 2_seconds ) ); - sounds::sound( z->pos(), 60, sounds::sound_t::alert, _( "a deafening roar!" ), false, "shout", + sounds::sound( z->pos_bub(), 60, sounds::sound_t::alert, _( "a deafening roar!" ), false, "shout", "roar" ); } return false; } - const int distance_to_target = rl_dist( z->pos(), target->pos() ); + const int distance_to_target = rl_dist( z->pos_bub(), target->pos_bub() ); // the monster summons stuff to fight you if( distance_to_target > 3 && one_in( 12 ) ) { @@ -3998,7 +4000,7 @@ bool mattack::flesh_tendril( monster *z ) //it pulls you towards itself and then knocks you away bool pulled = z->type->special_attacks.at( "ranged_pull" )->call( *z ); if( pulled && one_in( 4 ) ) { - sounds::sound( z->pos(), 60, sounds::sound_t::alarm, _( "a deafening roar!" ), false, "shout", + sounds::sound( z->pos_bub(), 60, sounds::sound_t::alarm, _( "a deafening roar!" ), false, "shout", "roar" ); } return pulled; @@ -4006,7 +4008,7 @@ bool mattack::flesh_tendril( monster *z ) if( distance_to_target <= 1 ) { if( one_in( 8 ) ) { - g->fling_creature( target, coord_to_angle( z->pos(), target->pos() ), + g->fling_creature( target, coord_to_angle( z->pos_bub(), target->pos_bub() ), z->type->melee_sides * z->type->melee_dice * 3 ); } else { z->type->special_attacks.at( "grab" )->call( *z ); @@ -4668,14 +4670,14 @@ bool mattack::doot( monster *z ) continue; } } - sounds::sound( z->pos(), 200, sounds::sound_t::music, _( "DOOT." ), false, "music_instrument", + sounds::sound( z->pos_bub(), 200, sounds::sound_t::music, _( "DOOT." ), false, "music_instrument", "trumpet" ); return true; } bool mattack::speaker( monster *z ) { - sounds::sound( z->pos(), 60, sounds::sound_t::order, + sounds::sound( z->pos_bub(), 60, sounds::sound_t::order, SNIPPET.random_from_category( "speaker_warning" ).value_or( translation() ) ); return true; } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index fb3d9372cfd70..e8a7cf1499eda 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -62,7 +62,7 @@ item_location mdeath::normal( monster &z ) if( !z.quiet_death && !z.has_flag( mon_flag_QUIETDEATH ) ) { if( z.type->in_species( species_ZOMBIE ) ) { - sfx::play_variant_sound( "mon_death", "zombie_death", sfx::get_heard_volume( z.pos() ) ); + sfx::play_variant_sound( "mon_death", "zombie_death", sfx::get_heard_volume( z.pos_bub() ) ); } //Currently it is possible to get multiple messages that a monster died. diff --git a/src/mondefense.cpp b/src/mondefense.cpp index 34ee6de05d09d..d8013e4824a25 100644 --- a/src/mondefense.cpp +++ b/src/mondefense.cpp @@ -162,7 +162,7 @@ void mdefense::return_fire( monster &m, Creature *source, const dealt_projectile const Character *const foe = dynamic_cast( source ); // No return fire for quiet or completely silent projectiles (bows, throwing etc). if( foe == nullptr || !foe->get_wielded_item() || - foe->get_wielded_item()->gun_noise().volume < rl_dist( m.pos(), source->pos() ) ) { + foe->get_wielded_item()->gun_noise().volume < rl_dist( m.pos_bub(), source->pos_bub() ) ) { return; } @@ -178,7 +178,7 @@ void mdefense::return_fire( monster &m, Creature *source, const dealt_projectile return; } - const int distance_to_source = rl_dist( m.pos(), source->pos() ); + const int distance_to_source = rl_dist( m.pos_bub(), source->pos_bub() ); // TODO: implement different rule, dependent on sound and probably some other things // Add some inaccuracy since it is blind fire (at a tile, not the player directly) @@ -186,7 +186,7 @@ void mdefense::return_fire( monster &m, Creature *source, const dealt_projectile for( const std::pair &attack : m.type->special_attacks ) { if( attack.second->id == "gun" ) { - sounds::sound( m.pos(), 50, sounds::sound_t::alert, + sounds::sound( m.pos_bub(), 50, sounds::sound_t::alert, _( "Detected shots from unseen attacker, return fire mode engaged." ) ); const gun_actor *gunactor = dynamic_cast( attack.second.get() ); if( gunactor->get_max_range() < distance_to_source ) { diff --git a/src/monexamine.cpp b/src/monexamine.cpp index ab74fca6e7293..4c6fc0b128716 100644 --- a/src/monexamine.cpp +++ b/src/monexamine.cpp @@ -177,7 +177,7 @@ void push( monster &z ) } point delta( z.posx() - player_character.posx(), z.posy() - player_character.posy() ); - if( z.move_to( tripoint( z.posx( ) + delta.x, z.posy( ) + delta.y, z.posz( ) ) ) ) { + if( z.move_to( tripoint_bub_ms( z.posx( ) + delta.x, z.posy( ) + delta.y, z.posz( ) ) ) ) { add_msg( _( "You pushed the %s." ), pet_name ); } else { add_msg( _( "You pushed the %s, but it resisted." ), pet_name ); diff --git a/src/monmove.cpp b/src/monmove.cpp index b5f58a05b36ec..f5423d4901643 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -136,7 +136,7 @@ static bool z_is_valid( int z ) return z >= -OVERMAP_DEPTH && z <= OVERMAP_HEIGHT; } -bool monster::will_move_to( const tripoint &p ) const +bool monster::will_move_to( const tripoint_bub_ms &p ) const { map &here = get_map(); if( here.impassable( p ) ) { @@ -168,7 +168,7 @@ bool monster::will_move_to( const tripoint &p ) const return false; } - if( has_flag( mon_flag_SUNDEATH ) && g->is_in_sunlight( tripoint_bub_ms( p ) ) ) { + if( has_flag( mon_flag_SUNDEATH ) && g->is_in_sunlight( p ) ) { return false; } @@ -180,7 +180,7 @@ bool monster::will_move_to( const tripoint &p ) const return true; } -bool monster::know_danger_at( const tripoint &p ) const +bool monster::know_danger_at( const tripoint_bub_ms &p ) const { map &here = get_map(); @@ -257,19 +257,19 @@ bool monster::know_danger_at( const tripoint &p ) const return true; } -bool monster::can_reach_to( const tripoint &p ) const +bool monster::can_reach_to( const tripoint_bub_ms &p ) const { map &here = get_map(); - if( p.z > pos_bub().z() && z_is_valid( pos_bub().z() ) ) { - if( here.has_flag( ter_furn_flag::TFLAG_RAMP_UP, tripoint_bub_ms( p.x, p.y, p.z - 1 ) ) ) { + if( p.z() > posz() && z_is_valid( posz() ) ) { + if( here.has_flag( ter_furn_flag::TFLAG_RAMP_UP, p + tripoint_rel_ms::below ) ) { return true; } if( !here.has_flag( ter_furn_flag::TFLAG_GOES_UP, pos_bub() ) && here.has_floor( p ) ) { // can't go through the roof return false; } - } else if( p.z < pos_bub().z() && z_is_valid( pos_bub().z() ) ) { - const tripoint_bub_ms above = tripoint_bub_ms( p + tripoint::above ); + } else if( p.z() < posz() && z_is_valid( posz() ) ) { + const tripoint_bub_ms above = p + tripoint::above; if( here.has_flag( ter_furn_flag::TFLAG_RAMP_DOWN, above ) ) { return true; } @@ -285,12 +285,12 @@ bool monster::can_reach_to( const tripoint &p ) const bool monster::can_move_to( const tripoint &p ) const { - return can_reach_to( p ) && will_move_to( p ); + return monster::can_move_to( tripoint_bub_ms( p ) ); } bool monster::can_move_to( const tripoint_bub_ms &p ) const { - return monster::can_move_to( p.raw() ); + return can_reach_to( p ) && will_move_to( p ); } float monster::rate_target( Creature &c, float best, bool smart ) const @@ -461,11 +461,11 @@ void monster::plan() monster_plan mon_plan( *this ); map &here = get_map(); - std::bitset seen_levels = here.get_inter_level_visibility( pos().z ); + std::bitset seen_levels = here.get_inter_level_visibility( posz() ); monster_attitude mood = attitude(); Character &player_character = get_player_character(); // If we can see the player, move toward them or flee. - if( friendly == 0 && seen_levels.test( player_character.pos().z + OVERMAP_DEPTH ) && + if( friendly == 0 && seen_levels.test( player_character.posz() + OVERMAP_DEPTH ) && sees( player_character ) ) { mon_plan.dist = rate_target( player_character, mon_plan.dist, mon_plan.smart_planning ); mon_plan.fleeing = mon_plan.fleeing || is_fleeing( player_character ); @@ -491,7 +491,7 @@ void monster::plan() } else if( friendly != 0 && !mon_plan.docile ) { for( monster &tmp : g->all_monsters() ) { if( tmp.friendly == 0 && tmp.attitude_to( *this ) == Attitude::HOSTILE && - seen_levels.test( tmp.pos().z + OVERMAP_DEPTH ) ) { + seen_levels.test( tmp.posz() + OVERMAP_DEPTH ) ) { float rating = rate_target( tmp, mon_plan.dist, mon_plan.smart_planning ); if( rating < mon_plan.dist ) { mon_plan.target = &tmp; @@ -515,7 +515,7 @@ void monster::plan() if( faction_att == MFA_NEUTRAL || faction_att == MFA_FRIENDLY ) { continue; } - if( !seen_levels.test( who.pos().z + OVERMAP_DEPTH ) ) { + if( !seen_levels.test( who.posz() + OVERMAP_DEPTH ) ) { continue; } @@ -780,7 +780,7 @@ static float get_stagger_adjust( const tripoint &source, const tripoint &destina * Returns true if the given square presents a possibility of drowning for the monster: it's deep water, it's liquid, * the monster can drown, and there is no boardable vehicle part present. */ -bool monster::is_aquatic_danger( const tripoint &at_pos ) const +bool monster::is_aquatic_danger( const tripoint_bub_ms &at_pos ) const { map &here = get_map(); return here.has_flag_ter( ter_furn_flag::TFLAG_DEEP_WATER, at_pos ) && @@ -788,7 +788,7 @@ bool monster::is_aquatic_danger( const tripoint &at_pos ) const can_drown() && !here.veh_at( at_pos ).part_with_feature( "BOARDABLE", false ); } -bool monster::die_if_drowning( const tripoint &at_pos, const int chance ) +bool monster::die_if_drowning( const tripoint_bub_ms &at_pos, const int chance ) { if( is_aquatic_danger( at_pos ) && one_in( chance ) ) { add_msg_if_player_sees( at_pos, _( "The %s drowns!" ), name() ); @@ -896,7 +896,7 @@ void monster::move() } // if the monster is in a deep water tile, it has a chance to drown - if( die_if_drowning( pos(), 10 ) ) { + if( die_if_drowning( pos_bub(), 10 ) ) { return; } @@ -1245,12 +1245,12 @@ void monster::move() if( moved ) { // Actual effects of moving to the square we've chosen const tripoint_bub_ms local_next_step = here.bub_from_abs( next_step ); const bool did_something = - ( !pacified && attack_at( local_next_step.raw() ) ) || + ( !pacified && attack_at( local_next_step ) ) || ( !pacified && can_open_doors && here.open_door( *this, local_next_step, !here.is_outside( pos_bub() ) ) ) || - ( !pacified && bash_at( local_next_step.raw() ) ) || - ( !pacified && push_to( local_next_step.raw(), 0, 0 ) ) || - move_to( local_next_step.raw(), false, false, get_stagger_adjust( pos(), destination.raw(), + ( !pacified && bash_at( local_next_step ) ) || + ( !pacified && push_to( local_next_step, 0, 0 ) ) || + move_to( local_next_step, false, false, get_stagger_adjust( pos(), destination.raw(), local_next_step.raw() ) ); if( !did_something ) { @@ -1331,11 +1331,11 @@ void monster::nursebot_operate( Character *dragged_foe ) add_effect( effect_countdown, 2_turns ); add_msg( m_bad, _( "The %s produces a syringe full of some translucent liquid." ), name() ); } else if( creatures.creature_at( get_dest() ) != nullptr && has_effect( effect_dragging ) ) { - sounds::sound( pos(), 8, sounds::sound_t::electronic_speech, + sounds::sound( pos_bub(), 8, sounds::sound_t::electronic_speech, string_format( _( "a soft robotic voice say, \"Please step away from the Autodoc, this patient needs immediate care.\"" ) ) ); // TODO: Make it able to push NPC/player - push_to( here.bub_from_abs( get_dest() ).raw(), 4, 0 ); + push_to( here.bub_from_abs( get_dest() ), 4, 0 ); } } if( get_effect_dur( effect_countdown ) == 1_turns && !has_effect( effect_operating ) ) { @@ -1373,7 +1373,7 @@ void monster::nursebot_operate( Character *dragged_foe ) // footsteps will determine how loud a monster's normal movement is // and create a sound in the monsters location when they move -void monster::footsteps( const tripoint &p ) +void monster::footsteps( const tripoint_bub_ms &p ) { if( is_hallucination() ) { return; @@ -1416,11 +1416,11 @@ void monster::footsteps( const tripoint &p ) if( volume == 0 ) { return; } - int dist = rl_dist( p, get_player_character().pos() ); - sounds::add_footstep( p, volume, dist, this, type->get_footsteps() ); + int dist = rl_dist( p, get_player_character().pos_bub() ); + sounds::add_footstep( p.raw(), volume, dist, this, type->get_footsteps() ); } -tripoint monster::scent_move() +tripoint_bub_ms monster::scent_move() { // TODO: Remove when scentmap is 3D if( std::abs( posz() - get_map().get_abs_sub().z() ) > SCENT_MAP_Z_REACH ) { @@ -1435,8 +1435,8 @@ tripoint monster::scent_move() const std::set &tracked_scents = type->scents_tracked; const std::set &ignored_scents = type->scents_ignored; - std::vector sdirection; - std::vector smoves; + std::vector sdirection; + std::vector smoves; int bestsmell = 10; // Squares with smell 0 are not eligible targets. int smell_threshold = 200; // Squares at or above this level are ineligible. @@ -1452,7 +1452,7 @@ tripoint monster::scent_move() bestsmell = scent_here; } - tripoint next( -1, -1, posz() ); + tripoint_bub_ms next( -1, -1, posz() ); // Scent is too weak, can't follow it. if( scent_here == 0 ) { return next; @@ -1487,7 +1487,7 @@ tripoint monster::scent_move() map &here = get_map(); if( !fleeing && scent_here > smell_threshold ) { // Smell too strong to track, wander around - sdirection.push_back( pos() ); + sdirection.push_back( pos_bub() ); } else { // Get direction of scent for( const tripoint_bub_ms &dest : here.points_in_radius( pos_bub(), 1, SCENT_MAP_Z_REACH ) ) { @@ -1498,19 +1498,19 @@ tripoint monster::scent_move() } if( ( !fleeing && smell > bestsmell ) || ( fleeing && smell < bestsmell ) ) { sdirection.clear(); - sdirection.push_back( dest.raw() ); + sdirection.push_back( dest ); bestsmell = smell; } else if( ( !fleeing && smell == bestsmell ) || ( fleeing && smell == bestsmell ) ) { - sdirection.push_back( dest.raw() ); + sdirection.push_back( dest ); } } } - for( const tripoint &direction : sdirection ) { + for( const tripoint_bub_ms &direction : sdirection ) { // Add some randomness to make creatures zigzag towards the source - for( const tripoint &dest : here.points_in_radius( direction, 1 ) ) { - if( here.valid_move( pos(), dest, can_bash, true ) && - ( can_move_to( dest ) || ( dest == player_character.pos() ) || + for( const tripoint_bub_ms &dest : here.points_in_radius( direction, 1 ) ) { + if( here.valid_move( pos_bub(), dest, can_bash, true ) && + ( can_move_to( dest ) || ( dest == player_character.pos_bub() ) || ( can_bash && here.bash_rating( bash_estimate(), dest ) > 0 ) ) ) { smoves.push_back( dest ); } @@ -1520,7 +1520,7 @@ tripoint monster::scent_move() return random_entry( smoves, next ); } -int monster::calc_movecost( const tripoint &f, const tripoint &t ) const +int monster::calc_movecost( const tripoint_bub_ms &f, const tripoint_bub_ms &t ) const { int movecost = 0; @@ -1574,7 +1574,7 @@ int monster::calc_movecost( const tripoint &f, const tripoint &t ) const return movecost; } -int monster::calc_climb_cost( const tripoint &f, const tripoint &t ) const +int monster::calc_climb_cost( const tripoint_bub_ms &f, const tripoint_bub_ms &t ) const { if( flies() ) { return 100; @@ -1622,9 +1622,9 @@ static std::vector get_bashing_zone( const tripoint &bashee, const tri return zone; } -bool monster::bash_at( const tripoint &p ) +bool monster::bash_at( const tripoint_bub_ms &p ) { - if( p.z != posz() ) { + if( p.z() != posz() ) { // TODO: Remove this return false; } @@ -1682,7 +1682,7 @@ int monster::bash_skill() const return type->bash_skill; } -int monster::group_bash_skill( const tripoint &target ) +int monster::group_bash_skill( const tripoint_bub_ms &target ) { if( !has_flag( mon_flag_GROUP_BASH ) ) { return bash_skill(); @@ -1691,12 +1691,12 @@ int monster::group_bash_skill( const tripoint &target ) // pileup = more bash skill, but only help bashing mob directly in front of target const int max_helper_depth = 5; - const std::vector bzone = get_bashing_zone( target, pos(), max_helper_depth ); + const std::vector bzone = get_bashing_zone( target.raw(), pos(), max_helper_depth ); creature_tracker &creatures = get_creature_tracker(); for( const tripoint &candidate : bzone ) { // Drawing this line backwards excludes the target and includes the candidate. - std::vector path_to_target = line_to( target, candidate, 0, 0 ); + std::vector path_to_target = line_to( target.raw(), candidate, 0, 0 ); bool connected = true; monster *mon = nullptr; for( const tripoint &in_path : path_to_target ) { @@ -1719,13 +1719,13 @@ int monster::group_bash_skill( const tripoint &target ) // If we made it here, the last monster checked was the candidate. monster &helpermon = *mon; // Contribution falls off rapidly with distance from target. - bashskill += helpermon.bash_skill() / rl_dist( candidate, target ); + bashskill += helpermon.bash_skill() / rl_dist( candidate, target.raw() ); } return bashskill; } -bool monster::attack_at( const tripoint &p ) +bool monster::attack_at( const tripoint_bub_ms &p ) { if( has_flag( mon_flag_PACIFIST ) || has_flag( json_flag_CANNOT_ATTACK ) ) { return false; @@ -1734,7 +1734,7 @@ bool monster::attack_at( const tripoint &p ) Character &player_character = get_player_character(); const bool sees_player = sees( player_character ); // Targeting player location - if( p == player_character.pos() ) { + if( p == player_character.pos_bub() ) { if( sees_player ) { return melee_attack( player_character ); } else { @@ -1780,7 +1780,7 @@ bool monster::attack_at( const tripoint &p ) if( has_effect( effect_stumbled_into_invisible ) && get_map().has_field_at( p, field_fd_last_known ) && !sees_player && attitude_to( player_character ) == Attitude::HOSTILE ) { - return attack_air( p ); + return attack_air( tripoint_bub_ms( p ) ); } // Nothing to attack. @@ -1800,13 +1800,13 @@ static tripoint_bub_ms find_closest_stair( const tripoint_bub_ms &near_this, return near_this; } -bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, +bool monster::move_to( const tripoint_bub_ms &p, bool force, bool step_on_critter, const float stagger_adjustment ) { const bool on_ground = !digging() && !flies(); - const bool z_move = p.z != pos_bub().z(); - const bool going_up = p.z > pos_bub().z(); + const bool z_move = p.z() != posz(); + const bool going_up = p.z() > posz(); tripoint_bub_ms destination( p ); map &here = get_map(); @@ -1863,9 +1863,9 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, // Note: Keep this as float here or else it will cancel valid moves const float cost = stagger_adjustment * static_cast( climbs() && - here.has_flag( ter_furn_flag::TFLAG_NO_FLOOR, p ) ? calc_climb_cost( pos_bub().raw(), - destination.raw() ) : calc_movecost( pos_bub().raw(), - destination.raw() ) ); + here.has_flag( ter_furn_flag::TFLAG_NO_FLOOR, p ) ? calc_climb_cost( pos_bub(), + destination ) : calc_movecost( pos_bub(), + destination ) ); if( cost > 0.0f ) { mod_moves( -static_cast( std::ceil( cost ) ) ); } else { @@ -1912,7 +1912,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, } setpos( destination ); - footsteps( destination.raw() ); + footsteps( destination ); underwater = will_be_water; optional_vpart_position vp_dest = here.veh_at( destination ); if( vp_dest ) { @@ -2041,7 +2041,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, return true; } -bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) +bool monster::push_to( const tripoint_bub_ms &p, const int boost, const size_t depth ) { if( is_hallucination() ) { // Don't let hallucinations push, not even other hallucinations @@ -2057,7 +2057,7 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) // TODO: Generalize this to Creature monster *const critter = creatures.creature_at( p ); if( critter == nullptr || critter == this || - p == pos() || critter->movement_impaired() ) { + p == pos_bub() || critter->movement_impaired() ) { return false; } @@ -2082,7 +2082,7 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) map &here = get_map(); const int movecost_from = 50 * here.move_cost( p ); const int movecost_attacker = std::max( movecost_from, 200 - 10 * ( attack - defend ) ); - const tripoint dir = p - pos(); + const tripoint_rel_ms dir = p - pos_bub(); // Mark self as pushed to simplify recursive pushing add_effect( effect_pushed, 1_turns ); @@ -2094,12 +2094,12 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) } // Pushing forward is easier than pushing aside - const int direction_penalty = std::abs( d.x - dir.x ) + std::abs( d.y - dir.y ); + const int direction_penalty = std::abs( d.x - dir.x() ) + std::abs( d.y - dir.y() ); if( direction_penalty > 2 ) { continue; } - tripoint dest( p + d ); + tripoint_bub_ms dest( p + d ); const int dest_movecost_from = 50 * here.move_cost( dest ); // Pushing into cars/windows etc. is harder @@ -2163,7 +2163,7 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) critter->add_effect( effect_stunned, rng( 0_turns, 2_turns ) ); Character &player_character = get_player_character(); // Only print the message when near player or it can get spammy - if( rl_dist( player_character.pos(), pos() ) < 4 ) { + if( rl_dist( player_character.pos_bub(), pos_bub() ) < 4 ) { add_msg_if_player_sees( *critter, m_warning, _( "The %1$s tramples %2$s." ), name(), critter->disp_name() ); } @@ -2221,16 +2221,16 @@ void monster::stumble() here.has_flag( ter_furn_flag::TFLAG_SWIMMABLE, dest ) && !here.has_flag( ter_furn_flag::TFLAG_SWIMMABLE, pos_bub() ) ) && ( creatures.creature_at( dest, is_hallucination() ) == nullptr ) ) { - if( move_to( dest.raw(), true, false ) ) { + if( move_to( dest, true, false ) ) { break; } } } } -void monster::knock_back_to( const tripoint &to ) +void monster::knock_back_to( const tripoint_bub_ms &to ) { - if( to == pos() ) { + if( to == pos_bub() ) { return; // No effect } @@ -2247,7 +2247,7 @@ void monster::knock_back_to( const tripoint &to ) apply_damage( z, bodypart_id( "torso" ), static_cast( z->type->size ) ); add_effect( effect_stunned, 1_turns ); if( type->size > 1 + z->type->size ) { - z->knock_back_from( pos() ); // Chain reaction! + z->knock_back_from( pos_bub() ); // Chain reaction! z->apply_damage( this, bodypart_id( "torso" ), static_cast( type->size ) ); z->add_effect( effect_stunned, 1_turns ); } else if( type->size > z->type->size ) { @@ -2309,7 +2309,7 @@ void monster::knock_back_to( const tripoint &to ) Make sure that non-smashing monsters won't "teleport" through windows Injure monsters if they're gonna be walking through pits or whatever */ -bool monster::will_reach( const point &p ) +bool monster::will_reach( const point_bub_ms &p ) { monster_attitude att = attitude( &get_player_character() ); if( att != MATT_FOLLOW && att != MATT_ATTACK && att != MATT_FRIEND ) { @@ -2322,11 +2322,11 @@ bool monster::will_reach( const point &p ) if( ( has_flag( mon_flag_IMMOBILE ) || has_flag( mon_flag_RIDEABLE_MECH ) || has_flag( json_flag_CANNOT_MOVE ) ) && - ( pos().xy() != p ) ) { + ( pos_bub().xy() != p ) ) { return false; } - const std::vector path = get_map().route( pos_bub(), tripoint_bub_ms( p.x, p.y, + const std::vector path = get_map().route( pos_bub(), tripoint_bub_ms( p, posz() ), get_pathfinding_settings() ); if( path.empty() ) { return false; @@ -2337,23 +2337,23 @@ bool monster::will_reach( const point &p ) return true; } - if( can_hear() && wandf > 0 && rl_dist( get_map().bub_from_abs( wander_pos ).xy().raw(), p ) <= 2 && + if( can_hear() && wandf > 0 && rl_dist( get_map().bub_from_abs( wander_pos ).xy(), p ) <= 2 && rl_dist( get_location().xy(), wander_pos.xy() ) <= wandf ) { return true; } - if( can_see() && sees( tripoint_bub_ms( p.x, p.y, posz() ) ) ) { + if( can_see() && sees( tripoint_bub_ms( p, posz() ) ) ) { return true; } return false; } -int monster::turns_to_reach( const point &p ) +int monster::turns_to_reach( const point_bub_ms &p ) { map &here = get_map(); // HACK: This function is a(n old) temporary hack that should soon be removed - const std::vector path = here.route( pos_bub(), tripoint_bub_ms( p.x, p.y, + const std::vector path = here.route( pos_bub(), tripoint_bub_ms( p, posz() ), get_pathfinding_settings() ); if( path.empty() ) { return 999; @@ -2367,9 +2367,9 @@ int monster::turns_to_reach( const point &p ) // the doors intact. return 999; } else if( i == 0 ) { - turns += static_cast( calc_movecost( pos(), next.raw() ) ) / get_speed(); + turns += static_cast( calc_movecost( pos_bub(), next ) ) / get_speed(); } else { - turns += static_cast( calc_movecost( path[i - 1].raw(), next.raw() ) ) / get_speed(); + turns += static_cast( calc_movecost( path[i - 1], next ) ) / get_speed(); } } diff --git a/src/monster.cpp b/src/monster.cpp index 5ed42536b0f8e..fe952e9b32852 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -320,7 +320,7 @@ monster::monster( const mtype_id &id ) : monster() aggro_character = type->aggro_character; } -monster::monster( const mtype_id &id, const tripoint &p ) : monster( id ) +monster::monster( const mtype_id &id, const tripoint_bub_ms &p ) : monster( id ) { set_pos_only( p ); unset_dest(); @@ -728,7 +728,7 @@ void monster::try_biosignature() } } -void monster::spawn( const tripoint &p ) +void monster::spawn( const tripoint_bub_ms &p ) { set_pos_only( p ); unset_dest(); @@ -1305,7 +1305,7 @@ nc_color monster::color_with_effects() const return ret; } -bool monster::avoid_trap( const tripoint & /* pos */, const trap &tr ) const +bool monster::avoid_trap( const tripoint_bub_ms & /* pos */, const trap &tr ) const { // The trap position is not used, monsters are to stupid to remember traps. Actually, they do // not even see them. @@ -1484,7 +1484,7 @@ void monster::set_patrol_route( const std::vector &patrol_pts_rel_ms ) next_patrol_point = 0; } -void monster::shift( const point & ) +void monster::shift( const point_rel_sm & ) { // TODO: migrate this to absolute coords and get rid of shift() path.clear(); @@ -1567,7 +1567,7 @@ bool monster::is_fleeing( Character &u ) const return false; } monster_attitude att = attitude( &u ); - return att == MATT_FLEE || ( att == MATT_FOLLOW && rl_dist( pos(), u.pos() ) <= 4 ); + return att == MATT_FLEE || ( att == MATT_FOLLOW && rl_dist( pos_bub(), u.pos_bub() ) <= 4 ); } Creature::Attitude monster::attitude_to( const Creature &other ) const @@ -2096,7 +2096,7 @@ bool monster::melee_attack( Creature &target, float accuracy ) if( u_see_my_spot ) { if( target.is_avatar() ) { sfx::play_variant_sound( "melee_attack", "monster_melee_hit", - sfx::get_heard_volume( target.pos() ) ); + sfx::get_heard_volume( target.pos_bub() ) ); // don't make a pain yelp if our limb is a bionic if( !dealt_dam.bp_hit->has_flag( json_flag_BIONIC_LIMB ) ) { sfx::do_player_death_hurt( dynamic_cast( target ), false ); @@ -2106,7 +2106,7 @@ bool monster::melee_attack( Creature &target, float accuracy ) body_part_name_accusative( dealt_dam.bp_hit ) ); } else if( target.is_npc() ) { if( has_effect( effect_ridden ) && has_flag( mon_flag_RIDEABLE_MECH ) && - pos() == player_character.pos() ) { + pos_bub() == player_character.pos_bub() ) { //~ %1$s: name of your mount, %2$s: target NPC name, %3$d: damage value add_msg( m_good, _( "Your %1$s hits %2$s for %3$d damage!" ), name(), target.disp_name(), total_dealt ); @@ -2118,7 +2118,7 @@ bool monster::melee_attack( Creature &target, float accuracy ) } } else { if( has_effect( effect_ridden ) && has_flag( mon_flag_RIDEABLE_MECH ) && - pos() == player_character.pos() ) { + pos_bub() == player_character.pos_bub() ) { //~ %1$s: name of your mount, %2$s: target creature name, %3$d: damage value add_msg( m_good, _( "Your %1$s hits %2$s for %3$d damage!" ), get_name(), target.disp_name(), total_dealt ); @@ -2677,7 +2677,7 @@ float monster::fall_damage_mod() const return 0.0f; } -int monster::impact( const int force, const tripoint &p ) +int monster::impact( const int force, const tripoint_bub_ms &p ) { if( force <= 0 ) { return force; @@ -2820,7 +2820,8 @@ void monster::process_turn() if( has_flag( mon_flag_ELECTRIC_FIELD ) && !is_hallucination() ) { if( has_effect( effect_emp ) ) { if( calendar::once_every( 10_turns ) ) { - sounds::sound( pos(), 5, sounds::sound_t::combat, _( "hummmmm." ), false, "humming", "electric" ); + sounds::sound( pos_bub(), 5, sounds::sound_t::combat, _( "hummmmm." ), false, "humming", + "electric" ); } } else { weather_manager &weather = get_weather(); @@ -2829,7 +2830,7 @@ void monster::process_turn() for( const item &item : items ) { if( item.made_of( phase_id::LIQUID ) && item.flammable() ) { // start a fire! here.add_field( zap, fd_fire, 2, 1_minutes ); - sounds::sound( pos(), 30, sounds::sound_t::combat, _( "fwoosh!" ), false, "fire", "ignition" ); + sounds::sound( pos_bub(), 30, sounds::sound_t::combat, _( "fwoosh!" ), false, "fire", "ignition" ); break; } } @@ -2852,9 +2853,10 @@ void monster::process_turn() if( weather.lightning_active && !has_effect( effect_supercharged ) && here.is_outside( pos_bub() ) ) { weather.lightning_active = false; // only one supercharge per strike - sounds::sound( pos(), 300, sounds::sound_t::combat, _( "BOOOOOOOM!!!" ), false, "environment", + sounds::sound( pos_bub(), 300, sounds::sound_t::combat, _( "BOOOOOOOM!!!" ), false, "environment", "thunder_near" ); - sounds::sound( pos(), 20, sounds::sound_t::combat, _( "vrrrRRRUUMMMMMMMM!" ), false, "explosion", + sounds::sound( pos_bub(), 20, sounds::sound_t::combat, _( "vrrrRRRUUMMMMMMMM!" ), false, + "explosion", "default" ); Character &player_character = get_player_character(); if( player_character.sees( pos_bub() ) ) { @@ -2864,7 +2866,7 @@ void monster::process_turn() } add_effect( effect_supercharged, 12_hours ); } else if( has_effect( effect_supercharged ) && calendar::once_every( 5_turns ) ) { - sounds::sound( pos(), 20, sounds::sound_t::combat, _( "VMMMMMMMMM!" ), false, "humming", + sounds::sound( pos_bub(), 20, sounds::sound_t::combat, _( "VMMMMMMMMM!" ), false, "humming", "electric" ); } } @@ -3304,21 +3306,23 @@ void monster::process_one_effect( effect &it, bool is_new ) } } else if( id == effect_fake_common_cold ) { if( calendar::once_every( time_duration::from_seconds( rng( 30, 300 ) ) ) && one_in( 2 ) ) { - sounds::sound( pos(), 4, sounds::sound_t::speech, _( "a hacking cough." ), false, "misc", "cough" ); + sounds::sound( pos_bub(), 4, sounds::sound_t::speech, _( "a hacking cough." ), false, "misc", + "cough" ); } avatar &you = get_avatar(); // No NPCs for now. - if( rl_dist( pos(), you.pos() ) <= 1 ) { + if( rl_dist( pos_bub(), you.pos_bub() ) <= 1 ) { you.get_sick( false ); } } else if( id == effect_fake_flu ) { // Need to define the two separately because it's theoretically (and realistically) possible to have both flu and cold at once, both for players and monsters. if( calendar::once_every( time_duration::from_seconds( rng( 30, 300 ) ) ) && one_in( 2 ) ) { - sounds::sound( pos(), 4, sounds::sound_t::speech, _( "a hacking cough." ), false, "misc", "cough" ); + sounds::sound( pos_bub(), 4, sounds::sound_t::speech, _( "a hacking cough." ), false, "misc", + "cough" ); } avatar &you = get_avatar(); // No NPCs for now. - if( rl_dist( pos(), you.pos() ) <= 1 ) { + if( rl_dist( pos_bub(), you.pos_bub() ) <= 1 ) { you.get_sick( true ); } } @@ -3823,7 +3827,7 @@ float monster::get_mountable_weight_ratio() const return type->mountable_weight_ratio; } -void monster::hear_sound( const tripoint &source, const int vol, const int dist, +void monster::hear_sound( const tripoint_bub_ms &source, const int vol, const int dist, bool provocative ) { if( !can_hear() ) { @@ -3864,7 +3868,7 @@ void monster::hear_sound( const tripoint &source, const int vol, const int dist, return; } // only trigger this if the monster is not friendly or the source isn't the player - if( friendly == 0 || source != get_player_character().pos() ) { + if( friendly == 0 || source != get_player_character().pos_bub() ) { process_trigger( mon_trigger::SOUND, volume ); } provocative_sound = tmp_provocative; diff --git a/src/monster.h b/src/monster.h index fc1154b1bce11..e47aeb571e972 100644 --- a/src/monster.h +++ b/src/monster.h @@ -88,7 +88,7 @@ class monster : public Creature public: monster(); explicit monster( const mtype_id &id ); - monster( const mtype_id &id, const tripoint &pos ); + monster( const mtype_id &id, const tripoint_bub_ms &pos ); monster( const monster & ); monster( monster && ) noexcept( map_is_noexcept ); ~monster() override; @@ -119,7 +119,7 @@ class monster : public Creature void try_biosignature(); void refill_udders(); void digest_food(); - void spawn( const tripoint &p ); + void spawn( const tripoint_bub_ms &p ); void spawn( const tripoint_abs_ms &loc ); std::vector get_absorb_material() const; std::vector get_no_absorb_material() const; @@ -190,14 +190,14 @@ class monster : public Creature bool is_pet_follow() const; bool has_intelligence() const; - bool avoid_trap( const tripoint &pos, const trap &tr ) const override; + bool avoid_trap( const tripoint_bub_ms &pos, const trap &tr ) const override; void serialize( JsonOut &json ) const; void deserialize( const JsonObject &data ); void deserialize( const JsonObject &data, const tripoint_abs_sm &submap_loc ); // Performs any necessary coordinate updates due to map shift. - void shift( const point &sm_shift ); + void shift( const point_rel_sm &sm_shift ); void set_patrol_route( const std::vector &patrol_pts_rel_ms ); /** @@ -213,12 +213,12 @@ class monster : public Creature // TODO: Get rid of untyped overload bool can_move_to( const tripoint &p ) const; bool can_move_to( const tripoint_bub_ms &p ) const; - bool can_reach_to( const tripoint &p ) const; - bool will_move_to( const tripoint &p ) const; - bool know_danger_at( const tripoint &p ) const; + bool can_reach_to( const tripoint_bub_ms &p ) const; + bool will_move_to( const tripoint_bub_ms &p ) const; + bool know_danger_at( const tripoint_bub_ms &p ) const; - bool will_reach( const point &p ); // Do we have plans to get to (x, y)? - int turns_to_reach( const point &p ); // How long will it take? + bool will_reach( const point_bub_ms &p ); // Do we have plans to get to (x, y)? + int turns_to_reach( const point_bub_ms &p ); // How long will it take? // Returns true if the monster has a current goal bool has_dest() const; @@ -255,21 +255,21 @@ class monster : public Creature // will change mon_plan::dist void anger_cub_threatened( monster_plan &mon_plan ); void move(); // Actual movement - void footsteps( const tripoint &p ); // noise made by movement + void footsteps( const tripoint_bub_ms &p ); // noise made by movement void shove_vehicle( const tripoint_bub_ms &remote_destination, const tripoint_bub_ms &nearby_destination ); // shove vehicles out of the way // check if the given square could drown a drownable monster - bool is_aquatic_danger( const tripoint &at_pos ) const; + bool is_aquatic_danger( const tripoint_bub_ms &at_pos ) const; // check if a monster at a position will drown and kill it if necessary // returns true if the monster dies // chance is the one_in( chance ) that the monster will drown - bool die_if_drowning( const tripoint &at_pos, int chance = 1 ); + bool die_if_drowning( const tripoint_bub_ms &at_pos, int chance = 1 ); - tripoint scent_move(); - int calc_movecost( const tripoint &f, const tripoint &t ) const; - int calc_climb_cost( const tripoint &f, const tripoint &t ) const; + tripoint_bub_ms scent_move(); + int calc_movecost( const tripoint_bub_ms &f, const tripoint_bub_ms &t ) const; + int calc_climb_cost( const tripoint_bub_ms &f, const tripoint_bub_ms &t ) const; bool is_immune_field( const field_type_id &fid ) const override; @@ -290,7 +290,7 @@ class monster : public Creature * * @return true if movement successful, false otherwise */ - bool move_to( const tripoint &p, bool force = false, bool step_on_critter = false, + bool move_to( const tripoint_bub_ms &p, bool force = false, bool step_on_critter = false, float stagger_adjustment = 1.0 ); /** @@ -301,14 +301,14 @@ class monster : public Creature * * @return true if something was attacked, false otherwise */ - bool attack_at( const tripoint &p ); + bool attack_at( const tripoint_bub_ms &p ); /** * Try to smash/bash/destroy your way through the terrain at p. * * @return true if we destroyed something, false otherwise. */ - bool bash_at( const tripoint &p ); + bool bash_at( const tripoint_bub_ms &p ); /** * Try to push away whatever occupies p, then step in. @@ -320,17 +320,17 @@ class monster : public Creature * * @return True if we managed to push something and took its place, false otherwise. */ - bool push_to( const tripoint &p, int boost, size_t depth ); + bool push_to( const tripoint_bub_ms &p, int boost, size_t depth ); /** Returns innate monster bash skill, without calculating additional from helpers */ int bash_skill() const; int bash_estimate() const; /** Returns ability of monster and any cooperative helpers to * bash the designated target. **/ - int group_bash_skill( const tripoint &target ); + int group_bash_skill( const tripoint_bub_ms &target ); void stumble(); - void knock_back_to( const tripoint &to ) override; + void knock_back_to( const tripoint_bub_ms &to ) override; // Combat bool is_fleeing( Character &u ) const; @@ -426,7 +426,7 @@ class monster : public Creature /** Returns multiplier on fall damage at low velocity (knockback/pit/1 z-level, not 5 z-levels) */ float fall_damage_mod() const override; /** Deals falling/collision damage with terrain/creature at pos */ - int impact( int force, const tripoint &pos ) override; + int impact( int force, const tripoint_bub_ms &pos ) override; bool has_grab_break_tec() const override; @@ -492,7 +492,7 @@ class monster : public Creature * @param vol Volume at the center of the sound source * @param distance Distance to sound source (currently just rl_dist) */ - void hear_sound( const tripoint &source, int vol, int distance, bool provocative ); + void hear_sound( const tripoint_bub_ms &source, int vol, int distance, bool provocative ); bool is_hallucination() const override; // true if the monster isn't actually real diff --git a/src/npc.cpp b/src/npc.cpp index e3b46f998e38e..c2a2be0e99742 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -272,7 +272,7 @@ standard_npc::standard_npc( const std::string &name, const tripoint &pos, int sk_lvl, int s_str, int s_dex, int s_int, int s_per ) { this->name = name; - set_pos_only( pos ); + set_pos_only( tripoint_bub_ms( pos ) ); if( !getID().is_valid() ) { setID( g->assign_npc_id() ); } @@ -1916,11 +1916,11 @@ void npc::say( const std::string &line, const sounds::sound_t spriority ) const // Sound happens even if we can't hear it if( spriority == sounds::sound_t::order || spriority == sounds::sound_t::alert ) { - sounds::sound( pos(), get_shout_volume(), spriority, sound, false, "speech", + sounds::sound( pos_bub(), get_shout_volume(), spriority, sound, false, "speech", male ? "NPC_m" : "NPC_f" ); } else { // Always shouting when in danger or short time since being in danger - sounds::sound( pos(), danger_assessment() > NPC_DANGER_VERY_LOW ? + sounds::sound( pos_bub(), danger_assessment() > NPC_DANGER_VERY_LOW ? get_shout_volume() : indoor_voice(), sounds::sound_t::speech, sound, false, "speech", @@ -2691,7 +2691,7 @@ bool npc::emergency( float danger ) const //Active npcs are the npcs near the player that are actively simulated. bool npc::is_active() const { - return get_creature_tracker().creature_at( pos() ) == this; + return get_creature_tracker().creature_at( pos_bub() ) == this; } int npc::follow_distance() const diff --git a/src/npc_attack.cpp b/src/npc_attack.cpp index 47a85009e6aa3..88cb3c8fd99eb 100644 --- a/src/npc_attack.cpp +++ b/src/npc_attack.cpp @@ -400,7 +400,8 @@ npc_attack_rating npc_attack_melee::evaluate_critter( const npc &source, double damage{ weapon.base_damage_melee().total_damage() }; damage *= 100.0 / weapon.attack_time( source ); const int reach_range{ weapon.reach_range( source ) }; - const int distance_to_me = clamp( rl_dist( source.pos(), critter->pos() ) - reach_range, 0, 10 ); + const int distance_to_me = clamp( rl_dist( source.pos_bub(), critter->pos_bub() ) - reach_range, 0, + 10 ); // Multiplier of 0.5f to 1.5f based on distance const float distance_multiplier = 1.5f - distance_to_me * 0.1f; double potential = damage * distance_multiplier; @@ -408,7 +409,7 @@ npc_attack_rating npc_attack_melee::evaluate_critter( const npc &source, if( damage >= critter->get_hp() ) { potential *= npc_attack_constants::kill_modifier; } - if( target && target->pos() == critter->pos() ) { + if( target && target->pos_bub() == critter->pos_bub() ) { potential *= npc_attack_constants::target_modifier; } @@ -576,7 +577,7 @@ npc_attack_rating npc_attack_gun::evaluate_tripoint( if( damage >= critter->get_hp() ) { potential *= npc_attack_constants::kill_modifier; } - if( target && target->pos() == critter->pos() ) { + if( target && target->pos_bub() == critter->pos_bub() ) { potential *= npc_attack_constants::target_modifier; } return npc_attack_rating( static_cast( std::round( potential ) ), location ); @@ -844,7 +845,7 @@ npc_attack_rating npc_attack_throw::evaluate_tripoint( if( potential > 0.0f && critter && damage >= critter->get_hp() ) { potential *= npc_attack_constants::kill_modifier; } - if( potential > 0.0f && target && critter && target->pos() == critter->pos() ) { + if( potential > 0.0f && target && critter && target->pos_bub() == critter->pos_bub() ) { potential *= npc_attack_constants::target_modifier; } return npc_attack_rating( static_cast( std::round( potential ) ), location ); diff --git a/src/npcmove.cpp b/src/npcmove.cpp index f36ed9f6354b4..2c137685878ed 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -311,7 +311,7 @@ tripoint_bub_ms npc::good_escape_direction( bool include_pos ) } } else if( path.empty() && run_to_friend && is_player_ally() ) { Character &player_character = get_player_character(); - int dist = rl_dist( pos(), player_character.pos() ); + int dist = rl_dist( pos_bub(), player_character.pos_bub() ); int def_radius = rules.has_flag( ally_rule::follow_close ) ? follow_distance() : 6; if( dist > def_radius ) { add_msg_debug( debugmode::DF_NPC_MOVEAI, @@ -441,7 +441,7 @@ std::vector npc::find_dangerous_explosives() const const explosion_iuse *actor = dynamic_cast( use->get_actor_ptr() ); const int safe_range = actor->explosion.safe_range(); - if( rl_dist( pos(), elem.position() ) >= safe_range ) { + if( rl_dist( pos_bub(), elem.pos_bub() ) >= safe_range ) { continue; // Far enough. } @@ -502,7 +502,7 @@ float npc::evaluate_character( const Character &candidate, bool my_gun, bool ene if( !enemy ) { if( candidate_gun || ( is_player_ally() && candidate.is_avatar() ) ) { // later we should evaluate if the NPC trusts the player enough to stick to them so reliably - int dist = rl_dist( pos(), candidate.pos() ); + int dist = rl_dist( pos_bub(), candidate.pos_bub() ); if( dist > mem_combat.formation_distance ) { mem_combat.formation_distance = std::max( dist, mem_combat.engagement_distance ); } @@ -688,7 +688,7 @@ std::optional npc_short_term_cache::closest_enemy_to_friendly_distance() co if( enemy.expired() ) { continue; } - distance = std::min( distance, rl_dist( buddy.lock()->pos(), enemy.lock()->pos() ) ); + distance = std::min( distance, rl_dist( buddy.lock()->pos_bub(), enemy.lock()->pos_bub() ) ); } } if( distance == INT_MAX ) { @@ -830,7 +830,7 @@ void npc::assess_danger() ai_cache.hostile_guys.emplace_back( g->shared_from( critter ) ); // warn and consider the odds for distant enemies - int dist = rl_dist( pos(), critter.pos() ); + int dist = rl_dist( pos_bub(), critter.pos_bub() ); float critter_threat = evaluate_monster( critter, dist ); // ignore targets behind glass even if we can see them @@ -902,7 +902,7 @@ void npc::assess_danger() // us or an ally float priority = std::max( critter_threat - 2.0f * ( scaled_distance - 1.0f ), is_too_close ? critter_threat : 0.0f ); - cur_threat_map[direction_from( pos(), critter.pos() )] += priority; + cur_threat_map[direction_from( pos_bub(), critter.pos_bub() )] += priority; if( priority > highest_priority ) { highest_priority = priority; ai_cache.target = g->shared_from( critter ); @@ -921,7 +921,7 @@ void npc::assess_danger() // Warn about sufficiently risky nearby hostiles const auto handle_hostile = [&]( const Character & foe, float foe_threat, const std::string & bogey, const std::string & warning ) { - int dist = rl_dist( pos(), foe.pos() ); + int dist = rl_dist( pos_bub(), foe.pos_bub() ); // ignore targets behind glass even if we can see them if( !clear_shot_reach( pos(), foe.pos(), false ) ) { // still warn about enemies behind impassable glass walls, but not as often. @@ -958,7 +958,7 @@ void npc::assess_danger() float priority = std::max( foe_threat - 2.0f * ( scaled_distance - 1 ), is_too_close ? std::max( foe_threat, NPC_DANGER_VERY_LOW ) : 0.0f ); - cur_threat_map[direction_from( pos(), foe.pos() )] += priority; + cur_threat_map[direction_from( pos_bub(), foe.pos_bub() )] += priority; if( priority > highest_priority ) { warn_about( warning, 1_minutes ); highest_priority = priority; @@ -1007,7 +1007,7 @@ void npc::assess_danger() // whoever the NPC perceives as their closest leader. float player_diff = std::max( evaluate_character( player_character, npc_ranged, is_enemy() ), NPC_DANGER_VERY_LOW ); - int dist = rl_dist( pos(), player_character.pos() ); + int dist = rl_dist( pos_bub(), player_character.pos_bub() ); if( is_enemy() ) { add_msg_debug( debugmode::DF_NPC_COMBATAI, "%s identified player as an enemy of threat level %1.2f", @@ -1147,7 +1147,7 @@ void npc::act_on_danger_assessment() set_attitude( NPCATT_FLEE_TEMP ); if( mem_combat.panic > 5 && is_player_ally() && sees( player_character.pos_bub() ) ) { // consider warning player about panic - int panic_alert = rl_dist( pos(), player_character.pos() ) - player_character.get_per(); + int panic_alert = rl_dist( pos_bub(), player_character.pos_bub() ) - player_character.get_per(); if( mem_combat.panic - personality.bravery > panic_alert ) { if( one_in( 4 ) && mem_combat.panic < 10 + personality.bravery ) { add_msg( m_bad, _( "%s is starting to panic a bit." ), name ); @@ -1369,7 +1369,7 @@ void npc::move() action = method_of_fleeing(); } else if( ( target == &player_character && attitude == NPCATT_FLEE_TEMP ) || has_effect( effect_npc_run_away ) ) { - if( hp_percentage() > 30 && target && rl_dist( pos(), target->pos() ) <= 1 ) { + if( hp_percentage() > 30 && target && rl_dist( pos_bub(), target->pos_bub() ) <= 1 ) { action = method_of_attack(); } else { action = method_of_fleeing(); @@ -1445,8 +1445,9 @@ void npc::move() } if( action == npc_undecided && is_walking_with() && rules.has_flag( ally_rule::follow_close ) && - rl_dist( pos(), player_character.pos() ) > follow_distance() && !( player_character.in_vehicle && - in_vehicle ) ) { + rl_dist( pos_bub(), player_character.pos_bub() ) > follow_distance() && + !( player_character.in_vehicle && + in_vehicle ) ) { action = npc_follow_player; } @@ -1550,7 +1551,7 @@ void npc::move() ( ( action == npc_follow_embarked && in_vehicle ) || ( action == npc_follow_player && - ( rl_dist( pos(), player_character.pos() ) <= follow_distance() || + ( rl_dist( pos_bub(), player_character.pos_bub() ) <= follow_distance() || posz() != player_character.posz() ) ) ) ) { action = method_of_attack(); @@ -2572,7 +2573,7 @@ npc_action npc::address_player() // Leave sleeping characters alone. return npc_undecided; } - if( rl_dist( pos(), player_character.pos() ) <= 6 ) { + if( rl_dist( pos_bub(), player_character.pos_bub() ) <= 6 ) { return npc_talk_to_player; // Close enough to talk to you } else { if( one_in( 10 ) ) { @@ -2604,7 +2605,7 @@ npc_action npc::address_player() } if( attitude == NPCATT_LEAD ) { - if( rl_dist( pos(), player_character.pos() ) >= 12 || !sees( player_character ) ) { + if( rl_dist( pos_bub(), player_character.pos_bub() ) >= 12 || !sees( player_character ) ) { int intense = get_effect_int( effect_catch_up ); if( intense < 10 ) { say( chat_snippets().snip_keep_up.translated() ); @@ -2722,7 +2723,7 @@ bool npc::wont_hit_friend( const tripoint_bub_ms &tar, const item &it, bool thro map &here = get_map(); std::vector trajectory = here.find_clear_path( pos_bub(), tar ); - units::angle target_angle = coord_to_angle( pos(), tar.raw() ); + units::angle target_angle = coord_to_angle( pos_bub(), tar ); double dispersion = throwing ? throwing_dispersion( it, nullptr ) : total_gun_dispersion( it, recoil_total(), it.ammo_data()->ammo->shot_spread ).max(); units::angle safe_angle = units::from_arcmin( dispersion ); @@ -2743,7 +2744,7 @@ bool npc::wont_hit_friend( const tripoint_bub_ms &tar, const item &it, bool thro // TODO: Extract common functions with turret target selection units::angle safe_angle_ally = safe_angle; - units::angle ally_angle = coord_to_angle( pos(), ally.pos() ); + units::angle ally_angle = coord_to_angle( pos_bub(), ally.pos_bub() ); units::angle angle_diff = units::fabs( ally_angle - target_angle ); angle_diff = std::min( 360_degrees - angle_diff, angle_diff ); if( angle_diff < safe_angle_ally ) { @@ -2771,7 +2772,7 @@ bool npc::enough_time_to_reload( const item &gun ) const return true; } - const int distance = rl_dist( pos(), target->pos() ); + const int distance = rl_dist( pos_bub(), target->pos_bub() ); const float target_speed = target->speed_rating(); const float turns_til_reached = distance / target_speed; if( target->is_avatar() || target->is_npc() ) { @@ -2832,10 +2833,10 @@ bool npc::update_path( const tripoint_bub_ms &p, const bool no_bashing, bool for if( !ai_cache.sound_alerts.empty() ) { ai_cache.sound_alerts.erase( ai_cache.sound_alerts.begin() ); add_msg_debug( debugmode::DF_NPC, "failed to path to sound alert %s->%s", - pos().to_string_writable(), p.to_string_writable() ); + pos_bub().to_string_writable(), p.to_string_writable() ); } add_msg_debug( debugmode::DF_NPC, "Failed to path %s->%s", - pos().to_string_writable(), p.to_string_writable() ); + pos_bub().to_string_writable(), p.to_string_writable() ); } while( !new_path.empty() && new_path[0] == pos_bub() ) { @@ -3017,7 +3018,7 @@ void npc::move_to( const tripoint_bub_ms &pt, bool no_bashing, std::set [%s]", get_name(), - pos().to_string_writable(), wanted_item_pos.to_string_writable() ); + pos_bub().to_string_writable(), wanted_item_pos.to_string_writable() ); if( const std::optional dest = nearest_passable( wanted_item_pos, pos_bub() ) ) { update_path( *dest ); } @@ -3700,7 +3701,7 @@ void npc::pick_up_item() const int dist_to_pickup = rl_dist( pos_bub(), wanted_item_pos ); if( dist_to_pickup > 1 && !path.empty() ) { add_msg_debug( debugmode::DF_NPC, "Moving; [%s] => [%s]", - pos().to_string_writable(), path[0].to_string_writable() ); + pos_bub().to_string_writable(), path[0].to_string_writable() ); move_to_next(); return; @@ -3852,7 +3853,7 @@ bool npc::would_take_that( const item &it, const tripoint_bub_ms &p ) followers.push_back( npc_to_add ); } for( npc *&elem : followers ) { - if( elem->sees( this->pos() ) || elem->sees( p ) ) { + if( elem->sees( this->pos_bub() ) || elem->sees( p ) ) { return false; } } @@ -3888,7 +3889,7 @@ bool npc::find_corpse_to_pulp() player_character.in_vehicle || is_hallucination() ) { return false; } - if( rl_dist( pos(), player_character.pos() ) >= mem_combat.engagement_distance ) { + if( rl_dist( pos_bub(), player_character.pos_bub() ) >= mem_combat.engagement_distance ) { // don't start to pulp corpses if you're already far from the player. return false; } @@ -4326,7 +4327,7 @@ void npc::heal_player( Character &patient ) return; } - int dist = rl_dist( pos(), patient.pos() ); + int dist = rl_dist( pos_bub(), patient.pos_bub() ); if( dist > 1 ) { // We need to move to the player @@ -4645,7 +4646,7 @@ void npc::mug_player( Character &mark ) make_angry(); } - if( rl_dist( pos(), mark.pos() ) > 1 ) { // We have to travel + if( rl_dist( pos_bub(), mark.pos_bub() ) > 1 ) { // We have to travel update_path( mark.pos_bub() ); move_to_next(); return; @@ -4786,7 +4787,7 @@ void npc::reach_omt_destination() if( is_player_ally() ) { Character &player_character = get_player_character(); talk_function::assign_guard( *this ); - if( rl_dist( player_character.pos(), pos() ) > SEEX * 2 ) { + if( rl_dist( player_character.pos_bub(), pos_bub() ) > SEEX * 2 ) { if( player_character.cache_has_item_with_flag( flag_TWO_WAY_RADIO, true ) && cache_has_item_with_flag( flag_TWO_WAY_RADIO, true ) ) { add_msg_if_player_sees( pos(), m_info, _( "From your two-way radio you hear %s reporting in, " @@ -5366,7 +5367,7 @@ void npc::do_reload( const item_location &it ) if( get_player_view().sees( *this ) ) { add_msg( _( "%1$s reloads their %2$s." ), get_name(), it->tname() ); - sfx::play_variant_sound( "reload", it->typeId().str(), sfx::get_heard_volume( pos() ), + sfx::play_variant_sound( "reload", it->typeId().str(), sfx::get_heard_volume( pos_bub() ), sfx::get_heard_angle( pos() ) ); } diff --git a/src/npctalk.cpp b/src/npctalk.cpp index cd32e3b93ad14..08d6c8a3d2911 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -6659,8 +6659,8 @@ talk_effect_fun_t::func f_spawn_monster( const JsonObject &jo, std::string_view if( single_target ) { // Find a hostile creature in range to be used to create a hallucination or a copy of Creature *copy = g->get_creature_if( [target_range]( const Creature & critter ) -> bool { - bool not_self = get_player_character().pos() != critter.pos(); - bool in_range = std::round( rl_dist_exact( get_player_character().pos(), critter.pos() ) ) <= target_range; + bool not_self = get_player_character().pos_bub() != critter.pos_bub(); + bool in_range = std::round( rl_dist_exact( get_player_character().pos_bub(), critter.pos_bub() ) ) <= target_range; bool valid_target = get_player_character().attitude_to( critter ) == Creature::Attitude::HOSTILE; return not_self && in_range && valid_target; } ); @@ -6673,8 +6673,8 @@ talk_effect_fun_t::func f_spawn_monster( const JsonObject &jo, std::string_view // Find all hostile creatures in range to be used to create hallucinations or copies of std::vector monsters_in_range = g->get_creatures_if( [target_range]( const Creature & critter ) -> bool { - bool not_self = get_player_character().pos() != critter.pos(); - bool in_range = std::round( rl_dist_exact( get_player_character().pos(), critter.pos() ) ) <= target_range; + bool not_self = get_player_character().pos_bub() != critter.pos_bub(); + bool in_range = std::round( rl_dist_exact( get_player_character().pos_bub(), critter.pos_bub() ) ) <= target_range; bool valid_target = get_player_character().attitude_to( critter ) == Creature::Attitude::HOSTILE; return not_self && in_range && valid_target; } ); diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index 91c6c57e4d38e..2d5d7c5cf9a6d 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -692,7 +692,7 @@ void talk_function::lesser_give_all_aid( npc &p ) Character &player_character = get_player_character(); for( npc &guy : g->all_npcs() ) { - if( guy.is_walking_with() && rl_dist( guy.pos(), player_character.pos() ) < PICKUP_RANGE ) { + if( guy.is_walking_with() && rl_dist( guy.pos_bub(), player_character.pos_bub() ) < PICKUP_RANGE ) { for( const bodypart_id &bp : guy.get_all_body_parts( get_body_part_flags::only_main ) ) { guy.heal( bp, rng( 5, 15 ) ); @@ -738,7 +738,7 @@ void talk_function::give_all_aid( npc &p ) Character &player_character = get_player_character(); for( npc &guy : g->all_npcs() ) { - if( guy.is_walking_with() && rl_dist( guy.pos(), player_character.pos() ) < PICKUP_RANGE ) { + if( guy.is_walking_with() && rl_dist( guy.pos_bub(), player_character.pos_bub() ) < PICKUP_RANGE ) { for( const bodypart_id &bp : guy.get_all_body_parts( get_body_part_flags::only_main ) ) { guy.heal( bp, 5 * rng( 2, 5 ) ); diff --git a/src/overmap.cpp b/src/overmap.cpp index e835aff590bfb..e336a99ff8728 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -3292,7 +3292,7 @@ bool overmap::monster_check( const std::pair &candidate const auto matching_range = monster_map.equal_range( candidate.first ); return std::find_if( matching_range.first, matching_range.second, [candidate]( const std::pair &match ) { - return candidate.second.pos() == match.second.pos() && + return candidate.second.pos_bub() == match.second.pos_bub() && candidate.second.type == match.second.type; } ) != matching_range.second; } diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index a32e96e1703ba..55d34979b5140 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -172,7 +172,7 @@ static void eff_fun_fake_common_cold( Character &u, effect & ) } avatar &you = get_avatar(); // No NPCs for now. - if( rl_dist( u.pos(), you.pos() ) <= 1 ) { + if( rl_dist( u.pos_bub(), you.pos_bub() ) <= 1 ) { you.get_sick( false ); } } @@ -183,7 +183,7 @@ static void eff_fun_fake_flu( Character &u, effect & ) } avatar &you = get_avatar(); // No NPCs for now. - if( rl_dist( u.pos(), you.pos() ) <= 1 ) { + if( rl_dist( u.pos_bub(), you.pos_bub() ) <= 1 ) { you.get_sick( true ); } } @@ -436,7 +436,7 @@ static void eff_fun_hallu( Character &u, effect &it ) int loudness = 20 + u.str_cur - u.int_cur; loudness = ( loudness > 5 ? loudness : 5 ); loudness = ( loudness < 30 ? loudness : 30 ); - sounds::sound( u.pos(), loudness, sounds::sound_t::speech, _( random_entry_ref( npc_hallu ) ), + sounds::sound( u.pos_bub(), loudness, sounds::sound_t::speech, _( random_entry_ref( npc_hallu ) ), false, "speech", loudness < 15 ? ( u.male ? "NPC_m" : "NPC_f" ) : ( u.male ? "NPC_m_loud" : "NPC_f_loud" ) ); } @@ -1608,14 +1608,14 @@ void Character::hardcoded_effects( effect &it ) it.mod_duration( 10_minutes ); } else if( dur == 2_turns ) { // let the sound code handle the wake-up part - sounds::sound( pos(), 16, sounds::sound_t::alarm, _( "beep-beep-beep!" ), false, "tool", + sounds::sound( pos_bub(), 16, sounds::sound_t::alarm, _( "beep-beep-beep!" ), false, "tool", "alarm_clock" ); } } } else { if( dur == 1_turns ) { if( player_character.has_alarm_clock() ) { - sounds::sound( player_character.pos(), 16, sounds::sound_t::alarm, + sounds::sound( player_character.pos_bub(), 16, sounds::sound_t::alarm, _( "beep-beep-beep!" ), false, "tool", "alarm_clock" ); const std::string alarm = _( "Your alarm is going off." ); g->cancel_activity_or_ignore_query( distraction_type::noise, alarm ); diff --git a/src/ranged.cpp b/src/ranged.cpp index 0fa2e4b6f6c53..3484547f22a32 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -1336,8 +1336,8 @@ int Character::throwing_dispersion( const item &to_throw, Creature *critter, if( critter != nullptr ) { // It's easier to dodge at close range (thrower needs to adjust more) // Dodge x10 at point blank, x5 at 1 dist, then flat - float effective_dodge = critter->get_dodge() * std::max( 1, 10 - 5 * rl_dist( pos(), - critter->pos() ) ); + float effective_dodge = critter->get_dodge() * std::max( 1, 10 - 5 * rl_dist( pos_bub(), + critter->pos_bub() ) ); dispersion += throw_dispersion_per_dodge( true ) * effective_dodge; } // 1 perception per 1 eye encumbrance @@ -2319,7 +2319,7 @@ void make_gun_sound_effect( const Character &p, bool burst, item *weapon ) { const item::sound_data data = weapon->gun_noise( burst ); if( data.volume > 0 ) { - sounds::sound( p.pos(), data.volume, sounds::sound_t::combat, + sounds::sound( p.pos_bub(), data.volume, sounds::sound_t::combat, data.sound.empty() ? _( "Bang!" ) : data.sound ); } tname::segment_bitset segs( tname::unprefixed_tname ); @@ -2629,7 +2629,7 @@ target_handler::trajectory target_ui::run() avatar &player_character = get_avatar(); on_out_of_scope cleanup( [&here, &player_character]() { - here.invalidate_map_cache( player_character.pos().z + player_character.view_offset.z() ); + here.invalidate_map_cache( player_character.posz() + player_character.view_offset.z() ); } ); shared_ptr_fast target_ui_cb = make_shared_fast( @@ -2993,7 +2993,7 @@ bool target_ui::handle_cursor_movement( const std::string &action, bool &skip_re } else if( action == "SELECT" && ( mouse_pos = ctxt.get_coordinates( g->w_terrain, g->ter_view_p.raw().xy() ) ) ) { // Set pos by clicking with mouse - mouse_pos->z() = you->pos().z + you->view_offset.z(); + mouse_pos->z() = you->posz() + you->view_offset.z(); set_cursor_pos( tripoint_bub_ms( *mouse_pos ) ); } else if( action == "LEVEL_UP" || action == "LEVEL_DOWN" ) { // Shift view/cursor up/down one z level @@ -3170,7 +3170,8 @@ void target_ui::update_target_list() // Get targets in range and sort them by distance (targets[0] is the closest) targets = you->get_targetable_creatures( range, mode == TargetMode::Reach ); std::sort( targets.begin(), targets.end(), [&]( const Creature * lhs, const Creature * rhs ) { - return rl_dist_exact( lhs->pos(), you->pos() ) < rl_dist_exact( rhs->pos(), you->pos() ); + return rl_dist_exact( lhs->pos_bub(), you->pos_bub() ) < rl_dist_exact( rhs->pos_bub(), + you->pos_bub() ); } ); } diff --git a/src/sounds.cpp b/src/sounds.cpp index 6ed6ccd3478c0..5456a81349690 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -483,7 +483,7 @@ void sounds::process_sounds() // If they later get physical effects from loud noises we'll have to change this // to use the unmodified volume for those effects. const int vol = this_centroid.volume - weather_vol; - const tripoint source = tripoint( this_centroid.x, this_centroid.y, this_centroid.z ); + const tripoint_bub_ms source = tripoint_bub_ms( this_centroid.x, this_centroid.y, this_centroid.z ); // --- Monster sound handling here --- // Alert all hordes int sig_power = get_signal_for_hordes( this_centroid ); @@ -491,13 +491,13 @@ void sounds::process_sounds() const point_abs_ms abs_ms = get_map().getglobal( source ).xy(); const point_abs_sm abs_sm( coords::project_to( abs_ms ) ); - const tripoint_abs_sm target( abs_sm, source.z ); + const tripoint_abs_sm target( abs_sm, source.z() ); overmap_buffer.signal_hordes( target, sig_power ); } // Alert all monsters (that can hear) to the sound. for( monster &critter : g->all_monsters() ) { // TODO: Generalize this to Creature::hear_sound - const int dist = sound_distance( source, critter.pos() ); + const int dist = sound_distance( source.raw(), critter.pos() ); if( vol * 2 > dist ) { // Exclude monsters that certainly won't hear the sound critter.hear_sound( source, vol, dist, this_centroid.provocative ); @@ -506,7 +506,7 @@ void sounds::process_sounds() // Trigger sound-triggered traps and ensure they are still valid for( const trap *trapType : trap::get_sound_triggered_traps() ) { for( const tripoint_bub_ms &tp : get_map().trap_locations( trapType->id ) ) { - const int dist = sound_distance( source, tp.raw() ); + const int dist = sound_distance( source.raw(), tp.raw() ); const trap &tr = get_map().tr_at( tp ); // Exclude traps that certainly won't hear the sound if( vol * 2 > dist ) { @@ -958,7 +958,7 @@ void sfx::do_vehicle_engine_sfx() if( !is_channel_playing( ch ) ) { play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, - sfx::get_heard_volume( player_character.pos() ), ch, 1000 ); + sfx::get_heard_volume( player_character.pos_bub() ), ch, 1000 ); add_msg_debug( debugmode::DF_SOUND, "START %s %s", id_and_variant.first, id_and_variant.second ); } else { add_msg_debug( debugmode::DF_SOUND, "PLAYING" ); @@ -1003,11 +1003,11 @@ void sfx::do_vehicle_engine_sfx() if( current_gear > previous_gear ) { play_variant_sound( "vehicle", "gear_shift", seas_str, indoors, night, - get_heard_volume( player_character.pos() ), 0_degrees, 0.8, 0.8 ); + get_heard_volume( player_character.pos_bub() ), 0_degrees, 0.8, 0.8 ); add_msg_debug( debugmode::DF_SOUND, "GEAR UP" ); } else if( current_gear < previous_gear ) { play_variant_sound( "vehicle", "gear_shift", seas_str, indoors, night, - get_heard_volume( player_character.pos() ), 0_degrees, 1.2, 1.2 ); + get_heard_volume( player_character.pos_bub() ), 0_degrees, 1.2, 1.2 ); add_msg_debug( debugmode::DF_SOUND, "GEAR DOWN" ); } double pitch = 1.0; @@ -1151,8 +1151,8 @@ void sfx::do_ambient() } audio_muted = false; const bool is_deaf = player_character.is_deaf(); - const int heard_volume = get_heard_volume( player_character.pos() ); - const bool is_underground = player_character.pos().z < 0; + const int heard_volume = get_heard_volume( player_character.pos_bub() ); + const bool is_underground = player_character.posz() < 0; const bool is_sheltered = g->is_sheltered( player_character.pos_bub() ); const bool night = is_night( calendar::turn ); const bool weather_changed = @@ -1508,7 +1508,7 @@ void sfx::do_projectile_hit( const Creature &target ) return; } - const int heard_volume = sfx::get_heard_volume( target.pos() ); + const int heard_volume = sfx::get_heard_volume( target.pos_bub() ); const units::angle angle = get_heard_angle( target.pos() ); const season_type seas = season_of_year( calendar::turn ); const std::string seas_str = season_str( seas ); @@ -1555,7 +1555,7 @@ void sfx::do_player_death_hurt( const Character &target, bool death ) const std::string seas_str = season_str( seas ); const bool indoors = !is_creature_outside( get_player_character() ); const bool night = is_night( calendar::turn ); - int heard_volume = get_heard_volume( target.pos() ); + int heard_volume = get_heard_volume( target.pos_bub() ); const bool male = target.male; if( !male && !death ) { play_variant_sound( "deal_damage", "hurt_f", seas_str, indoors, night, heard_volume ); @@ -1903,7 +1903,7 @@ void sfx::do_obstacle( const std::string &obst ) const std::string seas_str = season_str( seas ); const bool indoors = !is_creature_outside( player_character ); const bool night = is_night( calendar::turn ); - int heard_volume = sfx::get_heard_volume( player_character.pos() ); + int heard_volume = sfx::get_heard_volume( player_character.pos_bub() ); if( sfx::has_variant_sound( "plmove", obst, seas_str, indoors, night ) ) { play_variant_sound( "plmove", obst, seas_str, indoors, night, heard_volume, 0_degrees, 0.8, 1.2 ); diff --git a/src/suffer.cpp b/src/suffer.cpp index fee24ef96e6d8..ce290f1c640ad 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -1638,7 +1638,8 @@ void suffer::from_artifact_resonance( Character &you, int amt ) you.add_msg_player_or_npc( m_bad, _( "You hear a painfully loud grinding noise from your location." ), _( "A painfully loud grinding noise suddenly blares from the location of ." ) ); - sounds::sound( you.pos(), 5000, sounds::sound_t::movement, _( "A horribly loud grinding sound!" ), + sounds::sound( you.pos_bub(), 5000, sounds::sound_t::movement, + _( "A horribly loud grinding sound!" ), true, "misc", "scraping" ); } else if( rng_outcome == 3 ) { you.add_msg_player_or_npc( m_bad, diff --git a/src/timed_event.cpp b/src/timed_event.cpp index 3f33ca50200e3..707f152ec94ea 100644 --- a/src/timed_event.cpp +++ b/src/timed_event.cpp @@ -125,7 +125,8 @@ void timed_event::actualize() // You could drop the flag, you know. if( player_character.has_amount( itype_petrified_eye, 1 ) ) { - sounds::sound( player_character.pos(), 60, sounds::sound_t::alert, _( "a tortured scream!" ), false, + sounds::sound( player_character.pos_bub(), 60, sounds::sound_t::alert, _( "a tortured scream!" ), + false, "shout", "scream_tortured" ); if( !player_character.is_deaf() ) { diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 7be1ecf0c62f2..2549290f86fdc 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -230,7 +230,7 @@ static void mount_step_on_trap_make_slow_give_msg( monster *z, const tripoint &p map &here = get_map(); Character *rider = nullptr; for( npc &guy : g->all_npcs() ) { - if( guy.pos() == p && guy.pos() == z->pos() ) { + if( guy.pos() == p && guy.pos_bub() == z->pos_bub() ) { rider = &guy; break; } @@ -420,7 +420,7 @@ bool trapfunc::tripwire( const tripoint &p, Creature *c, item * ) } if( !valid.empty() ) { player_character.setpos( random_entry( valid ) ); - z->setpos( player_character.pos() ); + z->setpos( player_character.pos_bub() ); } player_character.mod_moves( -z->get_speed() * 1.5 ); g->update_map( player_character ); @@ -1353,7 +1353,7 @@ bool trapfunc::ledge( const tripoint &p, Creature *c, item * ) } if( valid.empty() ) { - critter->setpos( c->pos() ); + critter->setpos( c->pos_bub() ); add_msg( m_bad, _( "You fall down under %s!" ), critter->disp_name() ); } else { critter->setpos( random_entry( valid ) ); @@ -1378,7 +1378,7 @@ bool trapfunc::ledge( const tripoint &p, Creature *c, item * ) if( c->has_effect( effect_strengthened_gravity ) ) { height += 1; } - c->impact( height * 10, where.raw() ); + c->impact( height * 10, where ); return true; } @@ -1422,11 +1422,11 @@ bool trapfunc::ledge( const tripoint &p, Creature *c, item * ) } else { you->add_msg_if_player( m_bad, _( "You attempt to break the fall with your %s but it is out of fuel!" ), jetpack.tname() ); - you->impact( height * 30, where.raw() ); + you->impact( height * 30, where ); } } else { - you->impact( height * 30, where.raw() ); + you->impact( height * 30, where ); } if( here.has_flag( ter_furn_flag::TFLAG_DEEP_WATER, where ) ) { diff --git a/tests/act_build_test.cpp b/tests/act_build_test.cpp index 72dbae5511a39..09ddb994dad98 100644 --- a/tests/act_build_test.cpp +++ b/tests/act_build_test.cpp @@ -37,7 +37,7 @@ void run_activities( Character &u, int max_moves ) u.set_moves( u.get_speed() ); if( u.is_auto_moving() ) { u.setpos( get_map().bub_from_abs( tripoint_abs_ms( *u.destination_point ) ) ); - get_map().build_map_cache( u.pos().z ); + get_map().build_map_cache( u.posz() ); u.start_destination_activity(); } u.activity.do_turn( u ); @@ -124,7 +124,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity with pre_terrain" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_door( tripoint::south ); construction const build = setup_testcase( u, "test_constr_door", tri_door, tripoint_bub_ms() ); @@ -137,7 +137,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity with pre_terrain and starting far away" ) { u.setpos( tripoint_bub_ms{ ACTIVITY_SEARCH_DISTANCE - 1, 0, 0} ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_window( tripoint::south ); construction const build = setup_testcase( u, "test_constr_door", tri_window, tripoint_bub_ms() ); @@ -149,7 +149,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity with pre_flags" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_window( tripoint::south ); construction const build = setup_testcase( u, "test_constr_window_boarded", tri_window, tripoint_bub_ms() ); @@ -160,7 +160,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity with prereq with only pre_special" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_gravel( tripoint::south ); construction const pre_build = setup_testcase( u, "test_constr_railroad_rubble", tri_gravel, tripoint_bub_ms() ); @@ -179,7 +179,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity - alternative build from same group" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_window( tripoint::south ); construction const build = setup_testcase( u, "test_constr_window_boarded", tri_window, tripoint_bub_ms() ); @@ -191,7 +191,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity with existing partial" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_window( tripoint::south ); construction const build = setup_testcase( u, "test_constr_window_boarded", tri_window, tripoint_bub_ms() ); @@ -204,7 +204,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity with alternative partial" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_window( tripoint::south ); construction const build = setup_testcase( u, "test_constr_window_boarded", tri_window, tripoint_bub_ms() ); @@ -217,7 +217,7 @@ void run_test_case( Character &u ) SECTION( "1-step construction activity with mismatched partial" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_window( tripoint::south ); construction const build = setup_testcase( u, "test_constr_window_boarded", tri_window, tripoint_bub_ms() ); @@ -232,7 +232,7 @@ void run_test_case( Character &u ) SECTION( "visible but unreachable construction" ) { u.setpos( tripoint::zero ); u.path_settings->bash_strength = 0; - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_window = { 0, 5, 0 }; for( tripoint_bub_ms const &it : here.points_in_radius( tri_window, 1 ) ) { here.ter_set( it, ter_t_metal_grate_window ); @@ -250,7 +250,7 @@ void run_test_case( Character &u ) SECTION( "multiple-step construction activity with fetch required" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_door( tripoint::south ); construction const build = setup_testcase( u, "test_constr_door_peep", tri_door, { 0, PICKUP_RANGE * 2 + 1, 0 } ); @@ -260,7 +260,7 @@ void run_test_case( Character &u ) SECTION( "multiple-step construction activity with prereq from a different group" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_door( tripoint::south ); construction const build = setup_testcase( u, "test_constr_palisade_gate", tri_door, tripoint_bub_ms( tripoint::south_east ) ); @@ -270,7 +270,7 @@ void run_test_case( Character &u ) SECTION( "multiple-step construction activity with partial of a recursive prerequisite" ) { u.setpos( tripoint::zero ); - here.build_map_cache( u.pos().z ); + here.build_map_cache( u.posz() ); tripoint_bub_ms const tri_door( tripoint::south ); partial_con pc; pc.id = get_construction( "test_constr_pit_shallow" ).id; diff --git a/tests/archery_damage_test.cpp b/tests/archery_damage_test.cpp index 5f9a514935650..b3c0ee4ce7282 100644 --- a/tests/archery_damage_test.cpp +++ b/tests/archery_damage_test.cpp @@ -57,7 +57,7 @@ static void test_projectile_attack( const std::string &target_type, bool killabl dealt_projectile_attack &attack, const std::string &weapon_type ) { for( int i = 0; i < 10; ++i ) { - monster target{ mtype_id( target_type ), tripoint::zero }; + monster target{ mtype_id( target_type ), tripoint_bub_ms::zero }; //the missed_by field is modified by deal_projectile_attack() and must be reset attack.missed_by = accuracy_critical * 0.75; target.deal_projectile_attack( nullptr, attack, false ); diff --git a/tests/char_sight_test.cpp b/tests/char_sight_test.cpp index c777aaa74a2c0..8ba380a387e39 100644 --- a/tests/char_sight_test.cpp +++ b/tests/char_sight_test.cpp @@ -88,7 +88,7 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision // yes, surprisingly, we need to test for this calendar::turn = calendar::turn_zero; tripoint const z_shift = GENERATE( tripoint::above, tripoint::zero ); - dummy.setpos( dummy.pos() + z_shift ); // This implicitly rebuilds the light map. + dummy.setpos( dummy.pos_bub() + z_shift ); // This implicitly rebuilds the light map. CAPTURE( z_shift ); REQUIRE_FALSE( g->is_in_sunlight( dummy.pos_bub() ) ); REQUIRE( here.ambient_light_at( dummy.pos_bub() ) == Approx( LIGHT_AMBIENT_MINIMAL ) ); @@ -96,7 +96,7 @@ TEST_CASE( "light_and_fine_detail_vision_mod", "[character][sight][light][vision // 7.3 is LIGHT_AMBIENT_MINIMAL, a dark cloudy night, unlit indoors CHECK( dummy.fine_detail_vision_mod() == Approx( 7.3f ) ); - dummy.setpos( dummy.pos() - z_shift ); + dummy.setpos( dummy.pos_bub() - z_shift ); } SECTION( "blindfolded" ) { @@ -118,7 +118,7 @@ TEST_CASE( "npc_light_and_fine_detail_vision_mod", "[character][npc][sight][ligh clear_map(); tripoint const u_shift = GENERATE( tripoint::zero, tripoint::above ); CAPTURE( u_shift ); - u.setpos( u.pos() + u_shift ); + u.setpos( u.pos_bub() + u_shift ); scoped_weather_override weather_clear( WEATHER_CLEAR ); time_point time_dst; @@ -136,11 +136,11 @@ TEST_CASE( "npc_light_and_fine_detail_vision_mod", "[character][npc][sight][ligh set_time( time_dst ); REQUIRE( u.fine_detail_vision_mod() == expected_vision ); SECTION( "NPC on same z-level" ) { - n.setpos( u.pos() + tripoint::east ); + n.setpos( u.pos_bub() + tripoint::east ); CHECK( n.fine_detail_vision_mod() == u.fine_detail_vision_mod() ); } SECTION( "NPC on a different z-level" ) { - n.setpos( u.pos() + tripoint::above ); + n.setpos( u.pos_bub() + tripoint::above ); // light map is not calculated outside the player character's z-level // even if fov_3d_z_range > 0, and building light map on multiple levels // could be expensive, so make NPCs able to see things in this case to diff --git a/tests/coverage_test.cpp b/tests/coverage_test.cpp index 86c162fd31bd5..889950a79ab95 100644 --- a/tests/coverage_test.cpp +++ b/tests/coverage_test.cpp @@ -47,7 +47,7 @@ static void check_not_near( const std::string &subject, float actual, const floa static float get_avg_melee_dmg( const std::string &clothing_id, bool infect_risk = false ) { - monster zed( mon_manhack, mon_pos.raw() ); + monster zed( mon_manhack, mon_pos ); standard_npc dude( "TestCharacter", dude_pos.raw(), {}, 0, 8, 8, 8, 8 ); item cloth( clothing_id ); if( infect_risk ) { @@ -83,7 +83,7 @@ static float get_avg_melee_dmg( const std::string &clothing_id, bool infect_risk static float get_avg_melee_dmg( item cloth, bool infect_risk = false ) { - monster zed( mon_manhack, mon_pos.raw() ); + monster zed( mon_manhack, mon_pos ); standard_npc dude( "TestCharacter", dude_pos.raw(), {}, 0, 8, 8, 8, 8 ); if( infect_risk ) { cloth.set_flag( json_flag_FILTHY ); diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index 3df173f95a004..373183b7aaeb2 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -343,7 +343,7 @@ TEST_CASE( "crafting_with_a_companion", "[.]" ) g->load_npcs(); CHECK( !dummy.in_vehicle ); - dummy.setpos( who.pos() ); + dummy.setpos( who.pos_bub() ); const auto helpers( dummy.get_crafting_helpers() ); REQUIRE( std::find( helpers.begin(), helpers.end(), &who ) != helpers.end() ); diff --git a/tests/eoc_test.cpp b/tests/eoc_test.cpp index 228f88a6f4fec..e83f5c4bb6bb6 100644 --- a/tests/eoc_test.cpp +++ b/tests/eoc_test.cpp @@ -336,7 +336,7 @@ TEST_CASE( "EOC_transform_line", "[eoc][timed_event]" ) return p.xy() != get_avatar().pos().xy(); } ); REQUIRE( dest.has_value() ); - npc.setpos( { dest.value().xy(), get_avatar().pos().z } ); + npc.setpos( { dest.value().xy(), get_avatar().posz() } ); tripoint_abs_ms const start = get_avatar().get_location(); tripoint_abs_ms const end = npc.get_location(); diff --git a/tests/explosion_balance_test.cpp b/tests/explosion_balance_test.cpp index c1102ef22baf7..c47daac875234 100644 --- a/tests/explosion_balance_test.cpp +++ b/tests/explosion_balance_test.cpp @@ -117,7 +117,7 @@ static void check_lethality( const std::string &explosive_id, const int range, f } ); num_survivors += survivors.size(); for( Creature *survivor : survivors ) { - survivor_stats << survivor->pos() << " " << survivor->get_hp() << ", "; + survivor_stats << survivor->pos_bub() << " " << survivor->get_hp() << ", "; bool wounded = survivor->get_hp() < survivor->get_hp_max() * 0.75; num_wounded += wounded ? 1 : 0; total_hp += survivor->get_hp(); diff --git a/tests/harvest_test.cpp b/tests/harvest_test.cpp index 9737475ab1e03..efb847c3b1934 100644 --- a/tests/harvest_test.cpp +++ b/tests/harvest_test.cpp @@ -22,7 +22,7 @@ static const skill_id skill_firstaid( "firstaid" ); static const skill_id skill_survival( "survival" ); static const int max_iters = 1000; -static constexpr tripoint mon_pos( HALF_MAPSIZE_X - 1, HALF_MAPSIZE_Y, 0 ); +static constexpr tripoint_bub_ms mon_pos( HALF_MAPSIZE_X - 1, HALF_MAPSIZE_Y, 0 ); static void butcher_mon( const mtype_id &monid, const activity_id &actid, int *cbm_count, int *sample_count, int *other_count ) diff --git a/tests/limb_test.cpp b/tests/limb_test.cpp index 0225ad738edc5..3c6e12ff0c8fe 100644 --- a/tests/limb_test.cpp +++ b/tests/limb_test.cpp @@ -181,8 +181,8 @@ TEST_CASE( "drying_rate", "[character][limb]" ) CAPTURE( units::to_fahrenheit( weather_point.temperature ) ); CAPTURE( weather_point.humidity ); - REQUIRE( here.ter( dude.pos() ).id() == ter_t_grass ); - REQUIRE( here.furn( dude.pos() ).id() == furn_str_id::NULL_ID() ); + REQUIRE( here.ter( dude.pos_bub() ).id() == ter_t_grass ); + REQUIRE( here.furn( dude.pos_bub() ).id() == furn_str_id::NULL_ID() ); REQUIRE( body_part_arm_l->drying_rate == 1.0f ); dude.drench( 100, dude.get_drenching_body_parts(), false ); @@ -200,8 +200,8 @@ TEST_CASE( "drying_rate", "[character][limb]" ) // Birdify, clear water clear_character( dude, true ); create_bird_char( dude ); - REQUIRE( here.ter( dude.pos() ).id() == ter_t_grass ); - REQUIRE( here.furn( dude.pos() ).id() == furn_str_id::NULL_ID() ); + REQUIRE( here.ter( dude.pos_bub() ).id() == ter_t_grass ); + REQUIRE( here.furn( dude.pos_bub() ).id() == furn_str_id::NULL_ID() ); REQUIRE( body_part_test_bird_wing_l->drying_rate == 2.0f ); REQUIRE( body_part_test_bird_wing_r->drying_rate == 0.5f ); REQUIRE( dude.get_part_wetness( body_part_test_bird_wing_l ) == 0 ); diff --git a/tests/melee_test.cpp b/tests/melee_test.cpp index 69268ab24418b..5d0168b27a3c3 100644 --- a/tests/melee_test.cpp +++ b/tests/melee_test.cpp @@ -330,7 +330,7 @@ static void check_damage_from_test_fire( const std::string &mon_id, int expected clear_creatures(); standard_npc dude( "TestCharacter", dude_pos, {}, 8, 10, 10, 10, 10 ); monster &mon = spawn_test_monster( mon_id, dude.pos_bub() + tripoint::east ); - REQUIRE( mon.pos() == dude.pos() + tripoint::east ); + REQUIRE( mon.pos_bub() == dude.pos_bub() + tripoint::east ); REQUIRE( mon.get_armor_type( damage_test_fire, body_part_bp_null ) == expected_resist ); REQUIRE( mon.is_immune_damage( damage_test_fire ) == is_immune ); REQUIRE( mon.get_hp() == mon.get_hp_max() ); @@ -359,7 +359,7 @@ static void check_eocs_from_test_fire( const std::string &mon_id ) clear_creatures(); standard_npc dude( "TestCharacter", dude_pos, {}, 8, 10, 10, 10, 10 ); monster &mon = spawn_test_monster( mon_id, dude.pos_bub() + tripoint::east ); - REQUIRE( mon.pos() == dude.pos() + tripoint::east ); + REQUIRE( mon.pos_bub() == dude.pos_bub() + tripoint::east ); REQUIRE( mon.get_hp() == mon.get_hp_max() ); REQUIRE( dude.get_value( "general_dmg_type_test_test_fire" ).empty() ); REQUIRE( mon.get_value( "general_dmg_type_test_test_fire" ).empty() ); @@ -396,7 +396,7 @@ static void check_damage_from_test_fire( const std::vector &armor_i REQUIRE( dude2.wear_item( item( itm ), false ).has_value() ); } dude2.set_movement_mode( move_mode_prone ); // no dodging allowed :) - REQUIRE( dude2.pos() == dude.pos() + tripoint::east ); + REQUIRE( dude2.pos_bub() == dude.pos_bub() + tripoint::east ); REQUIRE( dude2.get_armor_type( damage_test_fire, checked_bp ) == expected_resist ); REQUIRE( dude2.is_immune_damage( damage_test_fire ) == is_immune ); REQUIRE( dude2.get_hp() == dude2.get_hp_max() ); diff --git a/tests/monster_attack_test.cpp b/tests/monster_attack_test.cpp index d278cde9dcb03..3b825fc7ca3f8 100644 --- a/tests/monster_attack_test.cpp +++ b/tests/monster_attack_test.cpp @@ -93,7 +93,7 @@ static void test_monster_attack( const tripoint &target_offset, bool expect_atta CAPTURE( target_location ); CHECK( test_monster.sees( target_location ) == expect_vision ); if( special_attack == nullptr ) { - CHECK( test_monster.attack_at( target_location.raw() ) == expect_attack ); + CHECK( test_monster.attack_at( target_location ) == expect_attack ); } else { CHECK( special_attack( &test_monster ) == expect_attack ); } @@ -219,7 +219,7 @@ TEST_CASE( "monster_throwing_sanity_test", "[throwing],[balance]" ) Creature *target = test_monster.attack_target(); REQUIRE( target ); REQUIRE( test_monster.sees( *target ) ); - REQUIRE( rl_dist( test_monster.pos(), target->pos() ) <= 5 ); + REQUIRE( rl_dist( test_monster.pos_bub(), target->pos_bub() ) <= 5 ); statistics damage_dealt; statistics hits; epsilon_threshold threshold{ expected_damage, 2.5 }; diff --git a/tests/monster_test.cpp b/tests/monster_test.cpp index d6e02712b5a7e..d5b2ba30e20a8 100644 --- a/tests/monster_test.cpp +++ b/tests/monster_test.cpp @@ -120,14 +120,14 @@ static int can_catch_player( const std::string &monster_type, const tripoint &di for( int turn = 0; turn < 1000; ++turn ) { test_player.mod_moves( target_speed ); 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 ) || - test_player.pos().x >= SEEX * ( 1 + static_cast( MAPSIZE / 2 ) ) || - test_player.pos().y >= SEEY * ( 1 + static_cast( MAPSIZE / 2 ) ) ) { + test_player.setpos( test_player.pos_bub() + direction_of_flight ); + if( test_player.posx() < SEEX * static_cast( MAPSIZE / 2 ) || + test_player.posy() < SEEY * static_cast( MAPSIZE / 2 ) || + test_player.posx() >= SEEX * ( 1 + static_cast( MAPSIZE / 2 ) ) || + test_player.posy() >= SEEY * ( 1 + static_cast( MAPSIZE / 2 ) ) ) { tripoint offset = center - test_player.pos(); test_player.setpos( center ); - test_monster.setpos( test_monster.pos() + offset ); + test_monster.setpos( test_monster.pos_bub() + offset ); // Verify that only the player and one monster are present. REQUIRE( g->num_creatures() == 2 ); } @@ -145,14 +145,14 @@ static int can_catch_player( const std::string &monster_type, const tripoint &di const int moves_before = test_monster.get_moves(); test_monster.move(); tracker.push_back( {'m', moves_before - test_monster.get_moves(), - rl_dist( test_monster.pos(), test_player.pos() ), + rl_dist( test_monster.pos_bub(), test_player.pos_bub() ), test_monster.pos() } ); - if( rl_dist( test_monster.pos(), test_player.pos() ) == 1 ) { + if( rl_dist( test_monster.pos_bub(), test_player.pos_bub() ) == 1 ) { INFO( tracker ); clear_map(); return turn; - } else if( rl_dist( test_monster.pos(), test_player.pos() ) > 20 ) { + } else if( rl_dist( test_monster.pos_bub(), test_player.pos_bub() ) > 20 ) { INFO( tracker ); clear_map(); return -turn; diff --git a/tests/npc_test.cpp b/tests/npc_test.cpp index 58f40f1a583bb..1ce6850feee52 100644 --- a/tests/npc_test.cpp +++ b/tests/npc_test.cpp @@ -562,7 +562,7 @@ TEST_CASE( "npc_can_target_player" ) Character &player_character = get_player_character(); npc &hostile = spawn_npc( player_character.pos_bub().xy() + point::south, "thug" ); - REQUIRE( rl_dist( player_character.pos(), hostile.pos() ) <= 1 ); + REQUIRE( rl_dist( player_character.pos_bub(), hostile.pos_bub() ) <= 1 ); hostile.set_attitude( NPCATT_KILL ); hostile.name = "Enemy NPC"; @@ -591,7 +591,7 @@ TEST_CASE( "npc_uses_guns", "[npc_ai]" ) Character &player_character = get_player_character(); point five_tiles_south = {0, 5}; npc &hostile = spawn_npc( player_character.pos_bub().xy() + five_tiles_south, "thug" ); - REQUIRE( rl_dist( player_character.pos(), hostile.pos() ) >= 4 ); + REQUIRE( rl_dist( player_character.pos_bub(), hostile.pos_bub() ) >= 4 ); hostile.set_attitude( NPCATT_KILL ); hostile.name = "Enemy NPC"; arm_shooter( hostile, "M24" ); diff --git a/tests/vehicle_fake_part_test.cpp b/tests/vehicle_fake_part_test.cpp index 3fd8bdc95a71b..301601cfa2bb5 100644 --- a/tests/vehicle_fake_part_test.cpp +++ b/tests/vehicle_fake_part_test.cpp @@ -412,7 +412,7 @@ TEST_CASE( "open_and_close_fake_doors", "[vehicle][vehicle_fake]" ) continue; } CAPTURE( prev_player_pos ); - CAPTURE( you.pos() ); + CAPTURE( you.pos_bub() ); REQUIRE( veh->can_close( vp.part_index(), you ) ); REQUIRE( veh->can_close( fake_door.part_index(), you ) ); you.setpos( vp.pos_bub() ); diff --git a/tests/vehicle_ramp_test.cpp b/tests/vehicle_ramp_test.cpp index 42a9e728e0daf..f442a8736e97b 100644 --- a/tests/vehicle_ramp_test.cpp +++ b/tests/vehicle_ramp_test.cpp @@ -177,7 +177,7 @@ static void ramp_transition_angled( const vproto_id &veh_id, const units::angle VPFLAG_BOARDABLE, true ); REQUIRE( vp ); if( vp ) { - const int z_change = map_starting_point.z() - player_character.pos_bub().z(); + const int z_change = map_starting_point.z() - player_character.posz(); here.unboard_vehicle( *vp, &player_character, false ); here.ter_set( map_starting_point, ter_id( "t_pavement" ) ); player_character.setpos( map_starting_point ); diff --git a/tests/vision_test.cpp b/tests/vision_test.cpp index ff4fe3e8850ac..a5b35d28f2872 100644 --- a/tests/vision_test.cpp +++ b/tests/vision_test.cpp @@ -68,7 +68,7 @@ static std::string vision_test_info( map_test_case &t ) using namespace map_test_case_common; out << "origin: " << t.get_origin() << '\n'; - out << "player: " << get_player_character().pos() << '\n'; + out << "player: " << get_player_character().pos_bub() << '\n'; out << "unimpaired_range: " << get_player_character().unimpaired_range() << '\n'; out << "vision_threshold: " << here.get_visibility_variables_cache().vision_threshold << '\n'; diff --git a/tests/visitable_zone_test.cpp b/tests/visitable_zone_test.cpp index daf224b9c18a1..c04892e493663 100644 --- a/tests/visitable_zone_test.cpp +++ b/tests/visitable_zone_test.cpp @@ -178,7 +178,7 @@ TEST_CASE( "visitable_zone_surface_test" ) spawn_site = it->name_; } CAPTURE( spawn_site ); - CAPTURE( mon->pos() ); + CAPTURE( mon->pos_bub() ); CAPTURE( mon->get_reachable_zone() ); CHECK( mon->get_reachable_zone() != 0 ); } diff --git a/tests/weakpoint_test.cpp b/tests/weakpoint_test.cpp index fa132e77cc345..e7e3631d013cd 100644 --- a/tests/weakpoint_test.cpp +++ b/tests/weakpoint_test.cpp @@ -70,7 +70,7 @@ static weakpoint_report damage_monster( const mtype_id &target_type, const damag { weakpoint_report ret{}; for( int i = 0; i < attacks; i++ ) { - monster target{ mtype_id( target_type ), tripoint::zero }; + monster target{ mtype_id( target_type ), tripoint_bub_ms::zero }; ret.Accumulate( target.deal_damage( nullptr, bodypart_id( "torso" ), dam ) ); }