]> git.localhorst.tv Git - blobs.git/blobdiff - src/creature/creature.cpp
only show death message when damage is max
[blobs.git] / src / creature / creature.cpp
index 667dc1740bdfa4fa37227b5ba74396a61dc9de2b..911d9d024f4ce7c58d4b69e4960ec42575e67ba4 100644 (file)
@@ -208,6 +208,14 @@ void Creature::DoWork(double amount) noexcept {
 
 void Creature::Hurt(double amount) noexcept {
        stats.Damage().Add(amount);
+       if (stats.Damage().Full()) {
+               Die();
+       }
+}
+
+void Creature::Die() noexcept {
+       if (Dead()) return;
+
        if (stats.Damage().Full()) {
                std::ostream &log = sim.Log() << name << " ";
                if (stats.Exhaustion().Full()) {
@@ -225,12 +233,7 @@ void Creature::Hurt(double amount) noexcept {
                        << " (" << ui::PercentageString(Age() / properties.Lifetime())
                        << " of life expectancy of " << ui::TimeString(properties.Lifetime())
                        << ")" << std::endl;
-               Die();
        }
-}
-
-void Creature::Die() noexcept {
-       if (Dead()) return;
 
        sim.SetDead(this);
        death = sim.Time();
@@ -437,7 +440,6 @@ void Creature::TickStats(double dt) {
        for (auto &s : stats.stat) {
                s.Add(s.gain * dt);
        }
-       stats.Breath().Add(stats.Breath().gain * stats.Exhaustion().value * dt);
        // TODO: damage values depending on properties
        if (stats.Breath().Full()) {
                constexpr double dps = 1.0 / 4.0;