172{
173 float casterDistance = 0.f;
174 float casterAngle = 0.f;
175 Unit* fleeTarget =
nullptr;
178
179 if (fleeTarget)
180 {
182 if (casterDistance > 0.2f)
183 {
184 casterAngle = fleeTarget->
GetAngle(owner);
185 }
186 else
187 {
188 casterAngle =
frand(0.0f, 2.0f *
float(M_PI));
189 }
190 }
191 else
192 {
193 casterDistance = 0.0f;
194 casterAngle =
frand(0.0f, 2.0f *
float(M_PI));
195 }
196
197 float distance = 0.f;
198 float angle = 0.f;
200 {
202 angle = casterAngle +
frand(-
float(M_PI) / 8.0f,
float(M_PI) / 8.0f);
203 }
205 {
207 angle = -casterAngle +
frand(-
float(M_PI) / 4.0f,
float(M_PI) / 4.0f);
208 }
209 else
210 {
212 angle =
frand(0.0f, 2.0f *
float(M_PI));
213 }
214
215
216
217 angle -= owner->GetOrientation();
218
219 owner->MovePositionToFirstCollision(position, distance, angle);
220}
float frand(float min, float max)
Definition: Random.cpp:57
#define MAX_QUIET_DISTANCE
Definition: FleeingMovementGenerator.cpp:28
#define MIN_QUIET_DISTANCE
Definition: FleeingMovementGenerator.cpp:27
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:204
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1245
float GetAngle(const Position *pos) const
Definition: Position.cpp:77