mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 21:40:03 +00:00
Change HUD enemy health bar to use actorId
This commit is contained in:
parent
07cfa2abd5
commit
103325bfb8
@ -92,6 +92,7 @@ namespace MWGui
|
|||||||
, mSpellVisible(true)
|
, mSpellVisible(true)
|
||||||
, mWorldMouseOver(false)
|
, mWorldMouseOver(false)
|
||||||
, mEnemyHealthTimer(-1)
|
, mEnemyHealthTimer(-1)
|
||||||
|
, mEnemyActorId(-1)
|
||||||
, mIsDrowning(false)
|
, mIsDrowning(false)
|
||||||
, mWeaponSpellTimer(0.f)
|
, mWeaponSpellTimer(0.f)
|
||||||
, mDrowningFlashTheta(0.f)
|
, mDrowningFlashTheta(0.f)
|
||||||
@ -609,7 +610,10 @@ namespace MWGui
|
|||||||
|
|
||||||
void HUD::updateEnemyHealthBar()
|
void HUD::updateEnemyHealthBar()
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats& stats = mEnemy.getClass().getCreatureStats(mEnemy);
|
MWWorld::Ptr enemy = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mEnemyActorId);
|
||||||
|
if (enemy.isEmpty())
|
||||||
|
return;
|
||||||
|
MWMechanics::CreatureStats& stats = enemy.getClass().getCreatureStats(enemy);
|
||||||
mEnemyHealth->setProgressRange(100);
|
mEnemyHealth->setProgressRange(100);
|
||||||
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
|
// Health is usually cast to int before displaying. Actors die whenever they are < 1 health.
|
||||||
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)
|
// Therefore any value < 1 should show as an empty health bar. We do the same in statswindow :)
|
||||||
@ -620,7 +624,7 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
mSpellIcons->updateWidgets(mEffectBox, true);
|
mSpellIcons->updateWidgets(mEffectBox, true);
|
||||||
|
|
||||||
if (!mEnemy.isEmpty() && mEnemyHealth->getVisible())
|
if (mEnemyActorId != -1 && mEnemyHealth->getVisible())
|
||||||
{
|
{
|
||||||
updateEnemyHealthBar();
|
updateEnemyHealthBar();
|
||||||
}
|
}
|
||||||
@ -634,7 +638,7 @@ namespace MWGui
|
|||||||
|
|
||||||
void HUD::setEnemy(const MWWorld::Ptr &enemy)
|
void HUD::setEnemy(const MWWorld::Ptr &enemy)
|
||||||
{
|
{
|
||||||
mEnemy = enemy;
|
mEnemyActorId = enemy.getClass().getCreatureStats(enemy).getActorId();
|
||||||
mEnemyHealthTimer = 5;
|
mEnemyHealthTimer = 5;
|
||||||
if (!mEnemyHealth->getVisible())
|
if (!mEnemyHealth->getVisible())
|
||||||
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() - MyGUI::IntPoint(0,20));
|
mWeaponSpellBox->setPosition(mWeaponSpellBox->getPosition() - MyGUI::IntPoint(0,20));
|
||||||
@ -644,7 +648,7 @@ namespace MWGui
|
|||||||
|
|
||||||
void HUD::resetEnemy()
|
void HUD::resetEnemy()
|
||||||
{
|
{
|
||||||
mEnemy = MWWorld::Ptr();
|
mEnemyActorId = -1;
|
||||||
mEnemyHealthTimer = -1;
|
mEnemyHealthTimer = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace MWGui
|
|||||||
|
|
||||||
SpellIcons* mSpellIcons;
|
SpellIcons* mSpellIcons;
|
||||||
|
|
||||||
MWWorld::Ptr mEnemy;
|
int mEnemyActorId;
|
||||||
float mEnemyHealthTimer;
|
float mEnemyHealthTimer;
|
||||||
|
|
||||||
bool mIsDrowning;
|
bool mIsDrowning;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user