Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Aug 14, 2021
1 parent 7091847 commit 4a8fb44
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool avatar_action::move( avatar &you, map &m, const tripoint &d )
}

// If any leg broken without crutches and not already on the ground topple over
if( ( you.get_working_leg_count() < 2 && !you.weapon.has_flag( flag_CRUTCHES ) ) &&
if( ( you.get_working_leg_count() < 2 && !you.get_wielded_weapon()->has_flag( flag_CRUTCHES ) ) &&
!you.is_prone() ) {
you.set_movement_mode( move_mode_id( "prone" ) );
you.add_msg_if_player( m_bad,
Expand Down
4 changes: 2 additions & 2 deletions src/crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,8 @@ static item_location place_craft_or_disassembly(
amenu.text = string_format( pgettext( "in progress craft", "What to do with the %s?" ),
craft.display_name() );

amenu.addentry( WIELD_CRAFT, ch.can_unwield( ch.weapon ).success(),
'1', _( "Dispose of your wielded %s and start working." ), ch.weapon.tname() );
amenu.addentry( WIELD_CRAFT, ch.can_unwield( *ch.get_wielded_weapon() ).success(),
'1', _( "Dispose of your wielded %s and start working." ), ch.get_wielded_weapon()->tname() );
amenu.addentry( DROP_CRAFT, true, '2', _( "Put it down and start working." ) );
const bool can_stash = ch.can_pickVolume( craft ) &&
ch.can_pickWeight( craft, !get_option<bool>( "DANGEROUS_PICKUPS" ) );
Expand Down
3 changes: 2 additions & 1 deletion src/gamemode_tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ void tutorial_game::post_action( action_id act )
Character &player_character = get_player_character();
switch( act ) {
case ACTION_RELOAD_WEAPON:
if( player_character.get_wielded_weapon()->is_gun() && !tutorials_seen[tut_lesson::LESSON_GUN_FIRE] ) {
if( player_character.get_wielded_weapon()->is_gun() &&
!tutorials_seen[tut_lesson::LESSON_GUN_FIRE] ) {
g->place_critter_at( mon_zombie, player_character.pos() + tripoint( 0, -6, 0 ) );
g->place_critter_at( mon_zombie, player_character.pos() + tripoint( 2, -5, 0 ) );
g->place_critter_at( mon_zombie, player_character.pos() + tripoint( -2, -5, 0 ) );
Expand Down
3 changes: 0 additions & 3 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3323,9 +3323,6 @@ void mattack::rifle( monster *z, Creature *target )
return;
}
add_msg_if_player_sees( *z, m_warning, _( "The %s opens up with its rifle!" ), z->name() );
tmp.set_wielded_weapon( item( "nato_assault_rifle" ).ammo_set( ammo_type, z->ammo[ ammo_type ] ) );
const item *weapon = tmp.get_wielded_weapon();
int burst = std::max( weapon->gun_get_mode( gun_mode_id( "AUTO" ) ).qty, 1 );

tmp.set_wielded_weapon( item( "m4_carbine" ).ammo_set( ammo_type, z->ammo[ ammo_type ] ) );
int burst = std::max( tmp.get_wielded_weapon()->gun_get_mode( gun_mode_id( "AUTO" ) ).qty, 1 );
Expand Down
4 changes: 2 additions & 2 deletions src/npc_attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ npc_attack_rating npc_attack_rating::operator-=( const int rhs )
void npc_attack_spell::use( npc &source, const tripoint &location ) const
{
spell &sp = source.magic->get_spell( attack_spell_id );
if( source.has_weapon() && !source.weapon.has_flag( flag_id( "MAGIC_FOCUS" ) ) &&
if( source.has_weapon() && !source.get_wielded_weapon()->has_flag( flag_id( "MAGIC_FOCUS" ) ) &&
!sp.has_flag( spell_flag::NO_HANDS ) ) {
source.unwield();
}
Expand Down Expand Up @@ -153,7 +153,7 @@ int npc_attack_spell::base_time_penalty( const npc &source ) const
{
const spell &attack_spell = source.magic->get_spell( attack_spell_id );
int time_penalty = 0;
if( source.has_weapon() && !source.weapon.has_flag( flag_id( "MAGIC_FOCUS" ) ) &&
if( source.has_weapon() && !source.get_wielded_weapon()->has_flag( flag_id( "MAGIC_FOCUS" ) ) &&
!attack_spell.has_flag( spell_flag::NO_HANDS ) ) {
time_penalty += npc_attack_constants::base_time_penalty;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/player_activities_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ TEST_CASE( "shearing", "[activity][shearing][animals]" )
dummy.process_items();
}

CHECK( dummy.weapon.ammo_remaining() == 0 );
REQUIRE( dummy.weapon.typeId().str() == itype_test_shears_off.str() );
CHECK( dummy.get_wielded_weapon()->ammo_remaining() == 0 );
REQUIRE( dummy.get_wielded_weapon()->typeId().str() == itype_test_shears_off.str() );

CHECK( dummy.max_quality( qual_SHEAR ) <= 0 );

Expand Down
12 changes: 6 additions & 6 deletions tests/unload_naked_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ TEST_CASE( "unload_revolver_naked_one_bullet", "[unload][nonmagzine]" )
REQUIRE( player_character.wield( revolver ) );
REQUIRE( player_character.is_armed( ) );

CHECK( player_character.weapon.ammo_remaining() == 1 );
CHECK( player_character.get_wielded_weapon()->ammo_remaining() == 1 );

// Unload weapon
item_location revo_loc( dummy, &player_character.weapon );
item_location revo_loc( dummy, player_character.get_wielded_weapon() );
player_character.moves = 100;
REQUIRE( player_character.unload( revo_loc ) );
player_character.activity.do_turn( player_character );

// No bullets in wielded gun
CHECK( player_character.weapon.ammo_remaining() == 0 );
CHECK( player_character.get_wielded_weapon()->ammo_remaining() == 0 );

// No bullets in inventory
const std::vector<item *> bullets = dummy.items_with( []( const item & item ) {
Expand All @@ -69,16 +69,16 @@ TEST_CASE( "unload_revolver_naked_fully_loaded", "[unload][nonmagzine]" )
REQUIRE( player_character.wield( revolver ) );
REQUIRE( player_character.is_armed( ) );

CHECK( player_character.weapon.remaining_ammo_capacity() == 0 );
CHECK( player_character.get_wielded_weapon()->remaining_ammo_capacity() == 0 );

// Unload weapon
item_location revo_loc( dummy, &player_character.weapon );
item_location revo_loc( dummy, player_character.get_wielded_weapon() );
player_character.moves = 100;
REQUIRE( player_character.unload( revo_loc ) );
player_character.activity.do_turn( player_character );

// No bullets in wielded gun
CHECK( player_character.weapon.ammo_remaining() == 0 );
CHECK( player_character.get_wielded_weapon()->ammo_remaining() == 0 );

// No bullets in inventory
const std::vector<item *> bullets = dummy.items_with( []( const item & item ) {
Expand Down

0 comments on commit 4a8fb44

Please sign in to comment.