diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-27 22:24:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-27 22:24:01 +0300 |
commit | 60859a71dd9794b0216cc7a60146d417e06dbbad (patch) | |
tree | 2e4bed96f702247edac6e967d77b3be4a8110eec /src | |
parent | 9fc44b1a5274ad8a1f7bcb6a1649e77e88a74640 (diff) | |
download | manaverse-60859a71dd9794b0216cc7a60146d417e06dbbad.tar.gz manaverse-60859a71dd9794b0216cc7a60146d417e06dbbad.tar.bz2 manaverse-60859a71dd9794b0216cc7a60146d417e06dbbad.tar.xz manaverse-60859a71dd9794b0216cc7a60146d417e06dbbad.zip |
Show hp bar for mercenary.
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 74 | ||||
-rw-r--r-- | src/being/being.h | 9 |
2 files changed, 82 insertions, 1 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index b7770c037..a44870e13 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -42,6 +42,7 @@ #include "being/playerrelations.h" #ifdef EATHENA_SUPPORT #include "being/homunculusinfo.h" +#include "being/mercenaryinfo.h" #endif // EATHENA_SUPPORT #include "const/utils/timer.h" @@ -3603,6 +3604,18 @@ void Being::drawHomunculus(Graphics *restrict const graphics, drawBeingCursor(graphics, px, py); drawHomunculusSpriteAt(graphics, px, py); } + +void Being::drawMercenary(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); + drawMercenarySpriteAt(graphics, px, py); +} #endif // EATHENA_SUPPORT void Being::drawPortal(Graphics *restrict const graphics, @@ -3638,8 +3651,12 @@ void Being::draw(Graphics *restrict const graphics, offsetX, offsetY); break; - case ActorType::Pet: case ActorType::Mercenary: + drawMercenary(graphics, + offsetX, + offsetY); + break; + case ActorType::Pet: case ActorType::SkillUnit: case ActorType::Unknown: #endif @@ -3874,6 +3891,61 @@ void Being::drawHomunculusSpriteAt(Graphics *restrict const graphics, } } } + +void Being::drawMercenarySpriteAt(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 MercenaryInfo *const info = PlayerInfo::getMercenary(); + if (info && + mId == info->id) + { + // show hp bar here + int maxHP = PlayerInfo::getStatBase(Attributes::MERC_MAX_HP); + if (!maxHP) + maxHP = mInfo->getMaxHP(); + + drawHpBar(graphics, + maxHP, + PlayerInfo::getStatBase(Attributes::MERC_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, diff --git a/src/being/being.h b/src/being/being.h index 6c7f480af..9a9cfb1a8 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -962,6 +962,11 @@ class Being notfinal : public ActorSprite, const int offsetY) const restrict2 A_NONNULL(2); + void drawMercenary(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; @@ -1076,6 +1081,10 @@ class Being notfinal : public ActorSprite, void drawHomunculusSpriteAt(Graphics *restrict const graphics, const int x, const int y) const restrict2 A_NONNULL(2); + + void drawMercenarySpriteAt(Graphics *restrict const graphics, + const int x, + const int y) const restrict2 A_NONNULL(2); #endif // EATHENA_SUPPORT void drawCompound(Graphics *const graphics, |