X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2Fgoal.cpp;h=daf8f901d7989b780cb067712eb65e4b5e14cd3c;hp=95a3426d986419b8e0e1459fca9cc5d442c083ca;hb=b03c2f42ba325ab909b159a4bc8e7568defdc4c5;hpb=da5e275f10252813b4de3af5e58f0c7975468962 diff --git a/src/creature/goal.cpp b/src/creature/goal.cpp index 95a3426..daf8f90 100644 --- a/src/creature/goal.cpp +++ b/src/creature/goal.cpp @@ -88,12 +88,15 @@ void IdleGoal::Tick(double dt) { } void IdleGoal::Action() { - double fert = GetCreature().Fertility(); - double rand = Assets().random.UNorm(); - if (fert > rand) { - std::cout << "[" << int(GetCreature().GetSimulation().Time()) - << "s] " << GetCreature().Name() << " split" << std::endl; - Split(GetCreature()); + // check if eligible to split + if (GetCreature().Mass() > GetCreature().GetProperties().Birth().mass * 1.8) { + double fert = GetCreature().Fertility(); + double rand = Assets().random.UNorm(); + if (fert > rand) { + std::cout << "[" << int(GetCreature().GetSimulation().Time()) + << "s] " << GetCreature().Name() << " split" << std::endl; + Split(GetCreature()); + } } } @@ -147,6 +150,7 @@ void LocateResourceGoal::Action() { } else { GetSteering().GoTo(target_pos); } + GetSteering().Haste(Urgency()); } void LocateResourceGoal::LocateResource() { @@ -190,7 +194,7 @@ void LocateResourceGoal::SearchVicinity() { if (yield != type.resources.cend()) { // TODO: subtract minimum yield rating[y - begin.y][x - begin.x] = yield->ubiquity; - double dist = 1.0 - 0.25 * glm::length2(planet.TileCenter(srf, x, y) - pos); + double dist = std::max(0.125, 0.25 * glm::length(planet.TileCenter(srf, x, y) - pos)); rating[y - begin.y][x - begin.x] /= dist; } } @@ -233,6 +237,7 @@ void LocateResourceGoal::SearchVicinity() { target_pos[(srf + 1) % 3] += Assets().random.SNorm(); // bias towards current direction target_pos += glm::normalize(GetSituation().Velocity()) * 0.5; + target_pos = clamp(target_pos, -planet.Radius(), planet.Radius()); GetSteering().GoTo(target_pos); } }