summaryrefslogtreecommitdiff
path: root/src/being/being.cpp
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 /src/being/being.cpp
parentcf71f3e3ce615bbd6ad1180d3edc8d995fc1914e (diff)
downloadmanaplus-19125da4c29f4475aafa4bf9bf2d9400bceff657.tar.gz
manaplus-19125da4c29f4475aafa4bf9bf2d9400bceff657.tar.bz2
manaplus-19125da4c29f4475aafa4bf9bf2d9400bceff657.tar.xz
manaplus-19125da4c29f4475aafa4bf9bf2d9400bceff657.zip
Show hp bar in own homunculus.
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r--src/being/being.cpp92
1 files changed, 85 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