]> git.localhorst.tv Git - blobs.git/blobdiff - src/creature/creature.cpp
steering tweaks
[blobs.git] / src / creature / creature.cpp
index 8c7d23569ac42b039f4ffe604b0cd2d9e177969d..d7a9724fbe62474884cf9538165efbac1df73b81 100644 (file)
@@ -216,22 +216,24 @@ void Creature::Hurt(double amount) noexcept {
 void Creature::Die() noexcept {
        if (Dead()) return;
 
-       std::ostream &log = sim.Log() << name << " ";
-       if (stats.Exhaustion().Full()) {
-               log << "died of exhaustion";
-       } else if (stats.Breath().Full()) {
-               log << "suffocated";
-       } else if (stats.Thirst().Full()) {
-               log << "died of thirst";
-       } else if (stats.Hunger().Full()) {
-               log << "starved to death";
-       } else {
-               log << "succumed to wounds";
+       if (stats.Damage().Full()) {
+               std::ostream &log = sim.Log() << name << " ";
+               if (stats.Exhaustion().Full()) {
+                       log << "died of exhaustion";
+               } else if (stats.Breath().Full()) {
+                       log << "suffocated";
+               } else if (stats.Thirst().Full()) {
+                       log << "died of thirst";
+               } else if (stats.Hunger().Full()) {
+                       log << "starved to death";
+               } else {
+                       log << "succumed to wounds";
+               }
+               log << " at an age of " << ui::TimeString(Age())
+                       << " (" << ui::PercentageString(Age() / properties.Lifetime())
+                       << " of life expectancy of " << ui::TimeString(properties.Lifetime())
+                       << ")" << std::endl;
        }
-       log << " at an age of " << ui::TimeString(Age())
-               << " (" << ui::PercentageString(Age() / properties.Lifetime())
-               << " of life expectancy of " << ui::TimeString(properties.Lifetime())
-               << ")" << std::endl;
 
        sim.SetDead(this);
        death = sim.Time();
@@ -948,10 +950,8 @@ glm::dvec3 Steering::Force(const Situation::State &s) const noexcept {
                        glm::dvec3 diff = s.Position() - other->GetSituation().Position();
                        if (length2(diff) > max_look * max_look) continue;
                        if (!c.PerceptionTest(other->GetSituation().Position())) continue;
-                       double sep = length(diff) - other->Size() * 0.707 - c.Size() * 0.707;
-                       if (sep < min_dist) {
-                               repulse += normalize(diff) * (1.0 - sep / min_dist);
-                       }
+                       double sep = glm::clamp(length(diff) - other->Size() * 0.707 - c.Size() * 0.707, 0.0, min_dist);
+                       repulse += normalize(diff) * (1.0 - sep / min_dist) * force;
                }
                result += repulse;
        }