int BasicMonster::navigateTo(Point target) { // TODO: One centralized dijkstra should improve performance significantly TCODPath path = TCODPath(level->getWidth(), level->getHeight(), new PathFindingCallback(), level); path.compute(position.x, position.y, target.x, target.y); Point step; if (!path.isEmpty() && path.walk(&step.x, &step.y, true)) { Creature* c = level->creatureAt(step); if (c != NULL) { // TODO: more elegant solution? return 10; } else if (getStatusStrength(STATUS_BEARTRAP) > 0) { // TODO: resolve bear trap and other statuses somewhere else if (rng->getInt(0,9) == 0) endStatus(STATUS_BEARTRAP); return 10; } else { float diagonal = (step.x - position.x != 0 && step.y - position.y != 0) ? std::sqrt(2.f) : 1.f; moveTo(step); return static_cast<int>(getWalkingSpeed() * diagonal); } } else { return 0; } }
void Client::changeStatus(Client::Status status) { endStatus(); startStatus(status); emit userStatusChanged(status); }