From ed866fbee491453ce52d91b7705422c7182249dd Mon Sep 17 00:00:00 2001 From: gsemaj Date: Mon, 11 Apr 2022 16:52:35 -0400 Subject: [PATCH] (WIP) Move ICombatant functions around a bit --- src/Combat.cpp | 24 ++++++++++++++++++++++++ src/Entities.cpp | 13 ------------- src/Entities.hpp | 12 ++++-------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/Combat.cpp b/src/Combat.cpp index 2e7f76c..25179c7 100644 --- a/src/Combat.cpp +++ b/src/Combat.cpp @@ -17,6 +17,30 @@ using namespace Combat; /// Player Id -> Bullet Id -> Bullet std::map> Combat::Bullets; +void Player::takeDamage(EntityRef src, int amt) { + // stubbed +} + +void Player::heal(EntityRef src, int amt) { + // stubbed +} + +bool Player::isAlive() { + return HP > 0; +} + +void CombatNPC::takeDamage(EntityRef src, int amt) { + // stubbed +} + +void CombatNPC::heal(EntityRef src, int amt) { + // stubbed +} + +bool CombatNPC::isAlive() { + return hp > 0; +} + static std::pair getDamage(int attackPower, int defensePower, bool shouldCrit, bool batteryBoost, int attackerStyle, int defenderStyle, int difficulty) { diff --git a/src/Entities.cpp b/src/Entities.cpp index 51aaa27..a859af2 100644 --- a/src/Entities.cpp +++ b/src/Entities.cpp @@ -103,19 +103,6 @@ sPCAppearanceData Player::getAppearanceData() { return data; } -// player combat methods; not sure if this is the right place to put them -void Player::takeDamage(EntityRef src, int amt) { - // stubbed -} - -void Player::heal(EntityRef src, int amt) { - // stubbed -} - -bool Player::isAlive() { - return HP > 0; -} - // TODO: this is less effiecient than it was, because of memset() void Player::enterIntoViewOf(CNSocket *sock) { INITSTRUCT(sP_FE2CL_PC_NEW, pkt); diff --git a/src/Entities.hpp b/src/Entities.hpp index a39512a..1671727 100644 --- a/src/Entities.hpp +++ b/src/Entities.hpp @@ -134,15 +134,11 @@ struct CombatNPC : public BaseNPC, public ICombatant { _stepAI(this, currTime); } - virtual void takeDamage(EntityRef src, int amt) override { - // stubbed - } + virtual bool isExtant() override { return hp > 0; } - virtual void heal(EntityRef src, int amt) override { - // stubbed - } - - virtual bool isAlive() override { return hp > 0; } + virtual void takeDamage(EntityRef src, int amt) override; + virtual void heal(EntityRef src, int amt) override; + virtual bool isAlive() override; }; // Mob is in MobAI.hpp, Player is in Player.hpp