summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-27 18:58:44 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-27 18:58:44 +0300
commit19125da4c29f4475aafa4bf9bf2d9400bceff657 (patch)
tree60da9e8a38cebb46ad50a5e60d4dd43cca36c89f
parentcf71f3e3ce615bbd6ad1180d3edc8d995fc1914e (diff)
downloadplus-19125da4c29f4475aafa4bf9bf2d9400bceff657.tar.gz
plus-19125da4c29f4475aafa4bf9bf2d9400bceff657.tar.bz2
plus-19125da4c29f4475aafa4bf9bf2d9400bceff657.tar.xz
plus-19125da4c29f4475aafa4bf9bf2d9400bceff657.zip
Show hp bar in own homunculus.
-rw-r--r--src/being/being.cpp92
-rw-r--r--src/being/being.h11
2 files changed, 96 insertions, 7 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index b91b40844..b7770c037 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -40,6 +40,9 @@
#include "being/localplayer.h"
#include "being/playerinfo.h"
#include "being/playerrelations.h"
+#ifdef EATHENA_SUPPORT
+#include "being/homunculusinfo.h"
+#endif // EATHENA_SUPPORT
#include "const/utils/timer.h"
@@ -3588,6 +3591,20 @@ void Being::drawMonster(Graphics *restrict const graphics,
drawMonsterSpriteAt(graphics, px, py);
}
+#ifdef EATHENA_SUPPORT
+void Being::drawHomunculus(Graphics *restrict const graphics,
+ const int offsetX,
+ const int offsetY) const restrict2
+{
+ // getActorX() + offsetX;
+ const int px = mPixelX - mapTileSize / 2 + offsetX;
+ // getActorY() + offsetY;
+ const int py = mPixelY - mapTileSize + offsetY;
+ drawBeingCursor(graphics, px, py);
+ drawHomunculusSpriteAt(graphics, px, py);
+}
+#endif // EATHENA_SUPPORT
+
void Being::drawPortal(Graphics *restrict const graphics,
const int offsetX,
const int offsetY) const restrict2
@@ -3615,6 +3632,17 @@ void Being::draw(Graphics *restrict const graphics,
offsetX,
offsetY);
break;
+#ifdef EATHENA_SUPPORT
+ case ActorType::Homunculus:
+ drawHomunculus(graphics,
+ offsetX,
+ offsetY);
+ break;
+ case ActorType::Pet:
+ case ActorType::Mercenary:
+ case ActorType::SkillUnit:
+ case ActorType::Unknown:
+#endif
case ActorType::Monster:
drawMonster(graphics,
offsetX,
@@ -3624,13 +3652,6 @@ void Being::draw(Graphics *restrict const graphics,
case ActorType::FloorItem:
case ActorType::LocalPet:
case ActorType::Avatar:
-#ifdef EATHENA_SUPPORT
- case ActorType::Pet:
- case ActorType::Mercenary:
- case ActorType::Homunculus:
- case ActorType::SkillUnit:
- case ActorType::Unknown:
-#endif
default:
drawOther(graphics,
offsetX,
@@ -3798,6 +3819,63 @@ void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
}
}
+#ifdef EATHENA_SUPPORT
+void Being::drawHomunculusSpriteAt(Graphics *restrict const graphics,
+ const int x,
+ const int y) const restrict2
+{
+ if (mHighlightMonsterAttackRange &&
+ mAction != BeingAction::DEAD)
+ {
+ if (!userPalette)
+ {
+ CompoundSprite::drawSimple(graphics, x, y);
+ return;
+ }
+
+ int attackRange;
+ if (mAttackRange)
+ attackRange = mapTileSize * mAttackRange;
+ else
+ attackRange = mapTileSize;
+
+ graphics->setColor(userPalette->getColorWithAlpha(
+ UserColorId::MONSTER_ATTACK_RANGE));
+
+ graphics->fillRectangle(Rect(
+ x - attackRange, y - attackRange,
+ 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
+ }
+
+ CompoundSprite::drawSimple(graphics, x, y);
+
+ if (mShowMobHP &&
+ mInfo)
+ {
+ const HomunculusInfo *const info = PlayerInfo::getHomunculus();
+ if (info &&
+ mId == info->id)
+ {
+ // show hp bar here
+ int maxHP = PlayerInfo::getStatBase(Attributes::HOMUN_MAX_HP);
+ if (!maxHP)
+ maxHP = mInfo->getMaxHP();
+
+ drawHpBar(graphics,
+ maxHP,
+ PlayerInfo::getStatBase(Attributes::HOMUN_HP),
+ mDamageTaken,
+ UserColorId::MONSTER_HP,
+ UserColorId::MONSTER_HP2,
+ x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
+ y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
+ 2 * 50,
+ 4);
+ }
+ }
+}
+#endif
+
void Being::drawPortalSpriteAt(Graphics *restrict const graphics,
const int x,
const int y) const restrict2
diff --git a/src/being/being.h b/src/being/being.h
index 737a5efd5..6c7f480af 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -957,6 +957,11 @@ class Being notfinal : public ActorSprite,
{ return mLastAttackY; }
#ifdef EATHENA_SUPPORT
+ void drawHomunculus(Graphics *restrict const graphics,
+ const int offsetX,
+ const int offsetY) const
+ restrict2 A_NONNULL(2);
+
void setTrickDead(const bool b) restrict2 override final;
void setChat(ChatObject *restrict const obj) restrict2;
@@ -1067,6 +1072,12 @@ class Being notfinal : public ActorSprite,
const int x,
const int y) const restrict2 A_NONNULL(2);
+#ifdef EATHENA_SUPPORT
+ void drawHomunculusSpriteAt(Graphics *restrict const graphics,
+ const int x,
+ const int y) const restrict2 A_NONNULL(2);
+#endif // EATHENA_SUPPORT
+
void drawCompound(Graphics *const graphics,
const int posX,
const int posY) const A_NONNULL(2);