179{
181 return false;
182
183 if (!owner || !owner->IsAlive())
184 return false;
185
187 {
188 owner->StopMoving();
190 return true;
191 }
192
195
196
198 {
199
200 owner->StopMoving();
202
203 if (cOwner)
204 {
205 if (!isStoppedBecauseOfCasting)
207
209 }
210 return true;
211 }
212
213 bool forceDest =
214
216 (owner->CanFly())
217 ;
218
220
222 bool const mutualTarget = target->
GetVictim() == owner;
224 float const meleeRange = owner->GetMeleeRange(target);
225 float const minTarget = (
_range ?
_range->MinTolerance : 0.0f) + chaseRange;
226 float const maxRange =
_range ?
_range->MaxRange + chaseRange : meleeRange;
228
230
231
232 if (angle && !mutualChase &&
_mutualChase && mutualTarget && chaseRange < meleeRange)
233 {
235 mutualChase = true;
236 }
237
238
239
240 if (angle && !mutualChase && !
_mutualChase && mutualTarget && chaseRange < meleeRange && cOwner && cOwner->IsPet())
241 {
243 mutualChase = true;
244 }
245
246
249 {
251
253 {
255 {
257 {
260 if (cOwner)
262 owner->StopMoving();
263 owner->SetInFront(target);
265 return true;
266 }
267 }
268 }
269 }
270
271
273 {
277 owner->SetInFront(target);
278
279 if (cOwner)
281
283 }
284
285 if (cOwner)
286 {
288 {
291 {
294 }
295 }
298 }
299
301 return true;
302
303
305 {
309 {
310
312 {
316 return true;
317 }
318
319
320 float x, y, z;
322 bool withinRange = owner->IsInDist(target, maxRange);
323 bool withinLOS = owner->IsWithinLOS(x, y, z);
324 bool moveToward = !(withinRange && withinLOS);
325
326
328 i_path = std::make_unique<PathGenerator>(owner);
329 else
331
332
333 float additionalRange = 0;
334 bool predictDestination = !mutualChase && target->
isMoving();
335 if (predictDestination)
336 {
340 else
341 {
344 else
346 }
347 float speed = target->
GetSpeed(moveType) * 0.5f;
348 additionalRange = owner->GetExactDistSq(target) < G3D::square(speed) ? 0 : speed;
349 }
350
351 bool shortenPath;
352
353
354 if (moveToward && !angle)
355 {
356
357 shortenPath = true;
358 }
359 else
360 {
361
362 target->
GetNearPoint(owner, x, y, z, (moveToward ? maxTarget : minTarget) - chaseRange - additionalRange, 0, angle ? target->ToAbsoluteAngle(angle->RelativeAngle) : target->GetAngle(owner));
363 shortenPath = false;
364 }
365
366 bool walk = false;
367 if (cOwner && !cOwner->
IsPet())
368 {
370 {
372 walk = owner->IsWalking();
373 break;
375 walk = true;
376 break;
377 default:
378 break;
379 }
380 }
381
383 }
384 }
385
386 return true;
387}
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:426
bool HasLostTarget(Unit *unit) const
Definition TargetedMovementGenerator.h:58
bool _movingTowards
Definition TargetedMovementGenerator.h:74
void UpdateLeashExtensionTime()
Definition Creature.cpp:3727
CreatureMovementData const & GetMovementTemplate() const
Definition Creature.cpp:3109
bool IsMovementPreventedByCasting() const override
Definition Creature.cpp:3654
bool IsPlayer() const
Definition Object.h:201
Player * ToPlayer()
Definition Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
bool IsGameMaster() const
Definition Player.h:1178
float GetSpeed(UnitMoveType mtype) const
Definition Unit.cpp:11278
virtual bool CanFly() const =0
bool IsWithinMeleeRange(Unit const *obj, float dist=0.f) const
Definition Unit.cpp:782
bool isInAccessiblePlaceFor(Creature const *c) const
Definition Unit.cpp:4384
bool HasUnitMovementFlag(uint32 f) const
Definition Unit.h:775
bool isMoving() const
Definition Unit.h:1712
Unit * GetVictim() const
Definition Unit.h:904
bool IsWalking() const
Definition Unit.h:1711
bool IsInMap(WorldObject const *obj) const
Definition Object.cpp:1339
CreatureChaseMovementType GetChase() const
Definition CreatureData.h:151
void GetPosition(float &x, float &y) const
Definition Position.h:126
void Update(int32 diff)
Definition Timer.h:239
bool Passed() const
Definition Timer.h:244