void Creature::goToFollowCreature() { if (followCreature) { FindPathParams fpp; getPathSearchParams(followCreature, fpp); Monster* monster = getMonster(); if (monster && !monster->getMaster() && (monster->isFleeing() || fpp.maxTargetDist > 1)) { Direction dir = DIRECTION_NONE; if (monster->isFleeing()) { monster->getDistanceStep(followCreature->getPosition(), dir, true); } else { //maxTargetDist > 1 if (!monster->getDistanceStep(followCreature->getPosition(), dir)) { // if we can't get anything then let the A* calculate listWalkDir.clear(); if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) { hasFollowPath = true; startAutoWalk(listWalkDir); } else { hasFollowPath = false; } return; } } if (dir != DIRECTION_NONE) { listWalkDir.clear(); listWalkDir.push_front(dir); hasFollowPath = true; startAutoWalk(listWalkDir); } } else { listWalkDir.clear(); if (getPathTo(followCreature->getPosition(), listWalkDir, fpp)) { hasFollowPath = true; startAutoWalk(listWalkDir); } else { hasFollowPath = false; } } } onFollowCreatureComplete(followCreature); }
void Creature::getPathToFollowCreature() { if(followCreature){ FindPathParams fpp; getPathSearchParams(followCreature, fpp); if(g_game.getPathToEx(this, followCreature->getPosition(), listWalkDir, fpp)){ hasFollowPath = true; startAutoWalk(listWalkDir); } else{ hasFollowPath = false; } } onFollowCreatureComplete(followCreature); }
void Creature::goToFollowCreature() { if(getPlayer() && (OTSYS_TIME() - lastFailedFollow <= g_config.getNumber(ConfigManager::FOLLOW_EXHAUST))) return; if(followCreature) { FindPathParams fpp; getPathSearchParams(followCreature, fpp); if(g_game.getPathToEx(this, followCreature->getPosition(), listWalkDir, fpp)) { hasFollowPath = true; startAutoWalk(listWalkDir); } else { hasFollowPath = false; lastFailedFollow = OTSYS_TIME(); } } onFollowCreatureComplete(followCreature); }