Teleport creatures back to spawn on evade if no path.

This commit is contained in:
ratkosrb
2021-01-12 13:59:33 +02:00
parent 57d83ec91b
commit 2aedc345fc
+19 -5
View File
@@ -43,18 +43,32 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature & owner)
owner.ModifyAuraState(AURA_STATE_HEALTHLESS_10_PERCENT, false);
owner.ModifyAuraState(AURA_STATE_HEALTHLESS_5_PERCENT, false);
Movement::MoveSplineInit init(owner, "HomeMovementGenerator");
float x, y, z, o;
bool setFacing = false;
// at apply we can select more nice return points base at current movegen
if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner, x, y, z))
{
owner.GetRespawnCoord(x, y, z, &o);
init.SetFacing(o);
setFacing = true;
}
init.MoveTo(x, y, z, MOVE_PATHFINDING | MOVE_FORCE_DESTINATION);
init.SetWalk(false);
init.Launch();
PathFinder path(&owner);
path.calculate(x, y, z, true);
if ((path.getPathType() & PATHFIND_NORMAL) && !((path.getPathType() & PATHFIND_NOT_USING_PATH) && (path.getPathType() & PATHFIND_DEST_FORCED)))
{
Movement::MoveSplineInit init(owner, "HomeMovementGenerator");
if (setFacing)
init.SetFacing(o);
init.Move(&path);
init.SetWalk(false);
init.Launch();
}
else // too far away or no path
owner.NearTeleportTo(x, y, z, o);
arrived = false;
owner.ClearUnitState(UNIT_STAT_ALL_DYN_STATES);