void Creature::Hurt(double amount) noexcept {
stats.Damage().Add(amount);
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;
Die();
}
}
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";
+ }
+ 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();
steering.Off();
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;