50{
52 return false;
53
54 if (!owner || !owner->IsAlive())
55 return false;
56
58
59
61 {
65 {
66 cOwner2->SetCannotReachTarget();
67 }
68
69 return true;
70 }
71
72 bool forceDest =
73
75 (owner->CanFly())
76 ;
77
79
81 float const hitboxSum = owner->GetCombatReach() + target->
GetCombatReach();
82 float const minTarget = (
_range ?
_range->MinTolerance : 0.0f) + hitboxSum;
83 float const maxRange =
_range ?
_range->MaxRange + hitboxSum : owner->GetMeleeRange(target);
86
89 {
91
93 {
95 {
96 cOwner2->SetCannotReachTarget();
97 }
98
101
102 owner->StopMoving();
103 owner->SetInFront(target);
105 return true;
106 }
107 }
108
110 {
112 owner->SetInFront(target);
114
115 if (owner->IsWithinMeleeRange(this->i_target.getTarget()))
116 {
119 {
120 cOwner2->SetCannotReachTarget();
121 }
122 }
124 {
126 {
128 }
129 }
130
133 }
134
136 return true;
137
139
141 {
143 {
144 cOwner2->SetCannotReachTarget();
145 }
146
147 return true;
148 }
149
150 float tarX, tarY, tarZ;
152
153 bool withinRange = owner->IsInDist(target, maxRange);
154 bool withinLOS = owner->IsWithinLOS(tarX, tarY, tarZ);
155 bool moveToward = !(withinRange && withinLOS);
156
158
160 {
161
163 {
167 return true;
168 }
169 }
170
172 i_path = std::make_unique<PathGenerator>(owner);
173 else
175
176 float x, y, z;
177 bool shortenPath;
178
179 if (moveToward && !angle)
180 {
181
183 shortenPath = true;
184 }
185 else
186 {
187
188 target->
GetNearPoint(owner, x, y, z, (moveToward ? maxTarget : minTarget) - hitboxSum, 0, angle ? target->
ToAbsoluteAngle(angle->RelativeAngle) : target->
GetAngle(owner));
189 shortenPath = false;
190 }
191
192 if (owner->IsHovering())
193 owner->UpdateAllowedPositionZ(x, y, z);
194
196
197 bool success =
i_path->CalculatePath(x, y, z, forceDest);
199 {
200 if (cOwner)
201 {
203 }
204
205 return true;
206 }
207
208 if (shortenPath)
210
211 if (cOwner)
212 {
214 }
215
216 bool walk = false;
217 if (cOwner && !cOwner->
IsPet())
218 {
220 {
221 case CreatureChaseMovementType::CanWalk:
222 if (owner->IsWalking())
223 walk = true;
224 break;
225 case CreatureChaseMovementType::AlwaysWalk:
226 walk = true;
227 break;
228 default:
229 break;
230 }
231 }
232
234
236 init.MovebyPath(
i_path->GetPath());
237 init.SetFacing(target);
238 init.SetWalk(walk);
239 init.Launch();
240
241 return true;
242}
#define CONTACT_DISTANCE
Definition: ObjectDefines.h:23
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
@ UNIT_STATE_NOT_MOVE
Definition: Unit.h:371
@ PATHFIND_NOPATH
Definition: PathGenerator.h:51
@ PATHFIND_INCOMPLETE
Definition: PathGenerator.h:50
static bool IsMutualChase(Unit *owner, Unit *target)
Definition: TargetedMovementGenerator.cpp:27
TO * getTarget() const
Definition: Reference.h:95
bool isValid() const
Definition: Reference.h:79
void Update(int32 diff)
Definition: Timer.h:239
void Reset(int32 interval)
Definition: Timer.h:249
bool Passed() const
Definition: Timer.h:244
void SetCannotReachTarget(ObjectGuid const &target=ObjectGuid::Empty)
Definition: Creature.cpp:3539
CreatureMovementData const & GetMovementTemplate() const
Definition: Creature.cpp:2884
bool IsMovementPreventedByCasting() const override
Definition: Creature.cpp:3517
CreatureChaseMovementType GetChase() const
Definition: CreatureData.h:156
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ=0, Position const *startPos=nullptr) const
Definition: Object.cpp:2589
float ToAbsoluteAngle(float relAngle) const
Definition: Position.h:203
float GetPositionZ() const
Definition: Position.h:119
float GetPositionX() const
Definition: Position.h:117
void GetPosition(float &x, float &y) const
Definition: Position.h:122
float GetPositionY() const
Definition: Position.h:118
float GetAngle(const Position *pos) const
Definition: Position.cpp:77
bool IsPet() const
Definition: Unit.h:1413
float GetCombatReach() const override
Definition: Unit.h:1347
bool isInAccessiblePlaceFor(Creature const *c) const
Definition: Unit.cpp:4133
FollowerReference i_target
Definition: TargetedMovementGenerator.h:34
bool _mutualChase
Definition: TargetedMovementGenerator.h:70
bool PositionOkay(T *owner, Unit *target, Optional< float > maxDistance, Optional< ChaseAngle > angle)
Definition: TargetedMovementGenerator.cpp:36
void MovementInform(T *)
Definition: TargetedMovementGenerator.cpp:281
bool HasLostTarget(Unit *unit) const
Definition: TargetedMovementGenerator.h:59
bool _movingTowards
Definition: TargetedMovementGenerator.h:69
Definition: MoveSplineInit.h:71