summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
Diffstat (limited to 'src/being')
-rw-r--r--src/being/localplayer.cpp18
-rw-r--r--src/being/localplayer.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 935b64c70..a9a51bd56 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -110,6 +110,7 @@ extern SkillDialog *skillDialog;
LocalPlayer::LocalPlayer(const int id, const uint16_t subtype) :
Being(id, ActorType::Player, subtype, nullptr),
AttributeListener(),
+ PlayerDeathListener(),
StatListener(),
mGMLevel(0),
mCrazyMoveState(0),
@@ -1106,6 +1107,13 @@ void LocalPlayer::attributeChanged(const int id,
case Attributes::LEVEL:
mLevel = newVal;
break;
+ case Attributes::HP:
+ if (oldVal != 0 && newVal == 0
+ && localPlayer->getCurrentAction() != BeingAction::DEAD)
+ {
+ PlayerDeathListener::distributeEvent();
+ }
+ break;
default:
break;
}
@@ -3276,3 +3284,13 @@ void LocalPlayer::setTestParticle(const std::string &fileName,
mTestParticleHash = UpdaterWindow::getFileHash(mTestParticleName);
}
}
+
+void LocalPlayer::playerDeath()
+{
+ if (mAction != BeingAction::DEAD)
+ {
+ setAction(BeingAction::DEAD, 0);
+ recalcSpritesOrder();
+ }
+}
+
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 46ed22cb8..dd5043572 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -31,6 +31,7 @@
#include "listeners/actorspritelistener.h"
#include "listeners/attributelistener.h"
+#include "listeners/playerdeathlistener.h"
#include "listeners/statlistener.h"
#include <vector>
@@ -49,6 +50,7 @@ class OkDialog;
class LocalPlayer final : public Being,
public ActorSpriteListener,
public AttributeListener,
+ public PlayerDeathListener,
public StatListener
{
public:
@@ -289,6 +291,8 @@ class LocalPlayer final : public Being,
*/
void optionChanged(const std::string &value) override final;
+ void playerDeath() override final;
+
/**
* set a following player.
*/