Skip to content

Commit

Permalink
move disarm and reach_attack out of player (CleverRaven#45605)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT authored Nov 25, 2020
1 parent 665b039 commit 41d013b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/avatar.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ class avatar : public player
void talk_to( std::unique_ptr<talker> talk_with, bool text_only = false,
bool radio_contact = false );

/**
* Try to disarm the NPC. May result in fail attempt, you receiving the wepon and instantly wielding it,
* or the weapon falling down on the floor nearby. NPC is always getting angry with you.
* @param target Target NPC to disarm
*/
void disarm( npc &target );

/**
* Helper function for player::read.
*
Expand Down
4 changes: 4 additions & 0 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,10 @@ class Character : public Creature, public visitable<Character>
*/
void melee_attack( Creature &t, bool allow_special, const matec_id &force_technique,
bool allow_unarmed = true );

/** Handles reach melee attacks */
void reach_attack( const tripoint &p );

/**
* Calls the to other melee_attack function with an empty technique id (meaning no specific
* technique should be used).
Expand Down
4 changes: 2 additions & 2 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ void Character::melee_attack( Creature &t, bool allow_special, const matec_id &f
}
}

void player::reach_attack( const tripoint &p )
void Character::reach_attack( const tripoint &p )
{
matec_id force_technique = tec_none;
/** @EFFECT_MELEE >5 allows WHIP_DISARM technique */
Expand Down Expand Up @@ -2433,7 +2433,7 @@ double Character::unarmed_value() const
return melee_value( item() );
}

void player::disarm( npc &target )
void avatar::disarm( npc &target )
{
if( !target.is_armed() ) {
return;
Expand Down
10 changes: 0 additions & 10 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ class player : public Character
*/
int fire_gun( const tripoint &target, int shots, item &gun );

/** Handles reach melee attacks */
void reach_attack( const tripoint &p );

/**
* Checks both the neighborhoods of from and to for climbable surfaces,
* returns move cost of climbing from `from` to `to`.
Expand Down Expand Up @@ -432,13 +429,6 @@ class player : public Character
using Character::query_yn;
bool query_yn( const std::string &mes ) const override;

/**
* Try to disarm the NPC. May result in fail attempt, you receiving the wepon and instantly wielding it,
* or the weapon falling down on the floor nearby. NPC is always getting angry with you.
* @param target Target NPC to disarm
*/
void disarm( npc &target );

protected:

void store( JsonOut &json ) const;
Expand Down

0 comments on commit 41d013b

Please sign in to comment.