212{
214 return false;
215
216 if (!owner || !owner->IsAlive())
217 return false;
218
220 {
221 owner->StopMoving();
223 return true;
224 }
225
228
229
231 {
232
233 owner->StopMoving();
235
236 if (cOwner)
238
239 return true;
240 }
241
242 bool forceDest =
243
245 (owner->CanFly())
246 ;
247
249
251 bool const mutualTarget = target->
GetVictim() == owner;
253 float const meleeRange = owner->GetMeleeRange(target);
254 float const minTarget = (
_range ?
_range->MinTolerance : 0.0f) + chaseRange;
255 float const maxRange =
_range ?
_range->MaxRange + chaseRange : meleeRange;
257
259
260
261 if (angle && !mutualChase &&
_mutualChase && mutualTarget && chaseRange < meleeRange)
262 {
264 mutualChase = true;
265 }
266
267
268
269 if (angle && !mutualChase && !
_mutualChase && mutualTarget && chaseRange < meleeRange && cOwner && cOwner->IsPet())
270 {
272 mutualChase = true;
273 }
274
275
278 {
280
282 {
284 {
286 {
289 if (cOwner)
291 owner->StopMoving();
292 owner->SetInFront(target);
294 return true;
295 }
296 }
297 }
298 }
299
300
302 {
306 owner->SetInFront(target);
307
308 if (cOwner)
310
312 }
313
314 if (cOwner)
315 {
318 }
319
321 return true;
322
323
325 {
331 {
332
334 {
338 return true;
339 }
340
341
342 float x, y, z;
344 bool withinRange = owner->IsInDist(target, maxRange);
345 bool withinLOS = owner->IsWithinLOS(x, y, z);
346 bool moveToward = !(withinRange && withinLOS);
347
348
350 i_path = std::make_unique<PathGenerator>(owner);
351 else
353
354
355 float additionalRange = 0;
356 bool predictDestination = !mutualChase && target->
isMoving();
357 if (predictDestination)
358 {
362 else
363 {
366 else
368 }
369 float speed = target->
GetSpeed(moveType) * 0.5f;
370 additionalRange = owner->GetExactDistSq(target) < G3D::square(speed) ? 0 : speed;
371 }
372
373 bool shortenPath;
374
375
376 if (moveToward && !angle)
377 {
378
379 shortenPath = true;
380 }
381 else
382 {
383
384 target->
GetNearPoint(owner, x, y, z, (moveToward ? maxTarget : minTarget) - chaseRange - additionalRange, 0, angle ? target->ToAbsoluteAngle(angle->RelativeAngle) : target->GetAngle(owner));
385 shortenPath = false;
386 }
387
388 bool walk = false;
389 if (cOwner && !cOwner->
IsPet())
390 {
392 {
394 walk = owner->IsWalking();
395 break;
397 walk = true;
398 break;
399 default:
400 break;
401 }
402 }
403
405 }
406 }
407
408 return true;
409}
float GetChaseRange(Unit const *owner, Unit const *target)
Definition TargetedMovementGenerator.cpp:35
static bool IsMutualChase(Unit *owner, Unit *target)
Definition TargetedMovementGenerator.cpp:27
@ MOVEMENTFLAG_BACKWARD
Definition UnitDefines.h:373
@ UNIT_STATE_NOT_MOVE
Definition UnitDefines.h:225
@ UNIT_STATE_NO_COMBAT_MOVEMENT
Definition UnitDefines.h:204
UnitMoveType
Definition UnitDefines.h:355
@ MOVE_FLIGHT
Definition UnitDefines.h:362
@ MOVE_FLIGHT_BACK
Definition UnitDefines.h:363
@ MOVE_RUN
Definition UnitDefines.h:357
@ MOVE_RUN_BACK
Definition UnitDefines.h:358
@ MOVE_WALK
Definition UnitDefines.h:356
bool _mutualChase
Definition TargetedMovementGenerator.h:75
bool PositionOkay(T *owner, Unit *target, Optional< float > maxDistance, Optional< ChaseAngle > angle)
Definition TargetedMovementGenerator.cpp:47
void MovementInform(T *)
Definition TargetedMovementGenerator.cpp:450
bool HasLostTarget(Unit *unit) const
Definition TargetedMovementGenerator.h:58
bool _movingTowards
Definition TargetedMovementGenerator.h:74
CreatureMovementData const & GetMovementTemplate() const
Definition Creature.cpp:3148
bool IsMovementPreventedByCasting() const override
Definition Creature.cpp:3708
bool IsPlayer() const
Definition Object.h:207
Player * ToPlayer()
Definition Object.h:208
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
bool IsGameMaster() const
Definition Player.h:1178
float GetSpeed(UnitMoveType mtype) const
Definition Unit.cpp:11047
virtual bool CanFly() const =0
bool isInAccessiblePlaceFor(Creature const *c) const
Definition Unit.cpp:4140
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:775
bool isMoving() const
Definition Unit.h:1715
Unit * GetVictim() const
Definition Unit.h:904
bool IsWalking() const
Definition Unit.h:1714
bool IsInMap(WorldObject const *obj) const
Definition Object.cpp:1344
CreatureChaseMovementType GetChase() const
Definition CreatureData.h:151
void Update(int32 diff)
Definition Timer.h:239
bool Passed() const
Definition Timer.h:244