feat(Core/Movement): Improved pathfinding, collisions and movements (#4220)
Npc positioning Implemented slope check to avoid unwanted climbing for some kind of movements (backwards, repositioning etc.) Implemented backwards movement Re-implemented circle repositioning algorithm (smartest than retail, but with the same feeling) Fixed random position of summoned minions Improved pet following movement. Also, they attack NPC from behind now. Thanks to @Footman Swimming creatures Fixed max_z coordinate for swimming creatures. Now only part of their body is allowed to be out of the water level Fixed pathfinder for swimming creatures creating shortcuts for specific segments, now they swim underwater to reach the seashore instead of flying above the water level. Creatures with water InhabitType but no swimming flag now, when not in combat, will walk on water depth instead of swimming. Thanks @jackpoz for the original code UNIT_FLAG_SWIMMING in UpdateEnvironmentIfNeeded to show the swimming animation correctly when underwater Implemented HasEnoughWater check to avoid swimming creatures to go where the water level is too low but also to properly enable swimming animation only when a creature has enough water to swim. Walking creatures Extended the DetourNavMeshQuery adding area cost based on walkability (slope angle + source height) to find better paths at runtime instead of completely remove them from mmaps improve Z height in certain conditions (see #4205, #4203, #4247 ) Flying creatures Rewriting of the hover system Removed hacks and improved the UpdateEnvironmentIfNeeded. Now creatures can properly switch from flying to walk etc. Spells LOS on spell effect must be calculated on CollisionHeight and HitSpherePoint instead of position coords. Improved position for object/creature spawned via spells Improved checks for Fleeing movements (fear spells) Other improvements Implemented method to calculate the CollisionWidth from dbc (used by repositioning algorithm etc.) Improved raycast and collision checks Co-authored-by: Footman <p.alexej@freenet.de> Co-authored-by: Helias <stefanoborzi32@gmail.com> Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com> Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "SharedDefines.h"
|
||||
#include "Object.h"
|
||||
#include "Spline/MoveSpline.h"
|
||||
#include <optional>
|
||||
|
||||
class MovementGenerator;
|
||||
class Unit;
|
||||
@@ -66,6 +67,31 @@ enum RotateDirection
|
||||
ROTATE_DIRECTION_RIGHT
|
||||
};
|
||||
|
||||
struct ChaseRange
|
||||
{
|
||||
ChaseRange(float range);
|
||||
ChaseRange(float _minRange, float _maxRange);
|
||||
ChaseRange(float _minRange, float _minTolerance, float _maxTolerance, float _maxRange);
|
||||
|
||||
// this contains info that informs how we should path!
|
||||
float MinRange; // we have to move if we are within this range... (min. attack range)
|
||||
float MinTolerance; // ...and if we are, we will move this far away
|
||||
float MaxRange; // we have to move if we are outside this range... (max. attack range)
|
||||
float MaxTolerance; // ...and if we are, we will move into this range
|
||||
};
|
||||
|
||||
struct ChaseAngle
|
||||
{
|
||||
ChaseAngle(float angle, float _tolerance = M_PI_4);
|
||||
|
||||
float RelativeAngle; // we want to be at this angle relative to the target (0 = front, M_PI = back)
|
||||
float Tolerance; // but we'll tolerate anything within +- this much
|
||||
|
||||
float UpperBound() const;
|
||||
float LowerBound() const;
|
||||
bool IsAngleOkay(float relativeAngle) const;
|
||||
};
|
||||
|
||||
// assume it is 25 yard per 0.6 second
|
||||
#define SPEED_CHARGE 42.0f
|
||||
|
||||
@@ -163,7 +189,11 @@ public:
|
||||
void MoveTargetedHome();
|
||||
void MoveRandom(float wanderDistance = 0.0f);
|
||||
void MoveFollow(Unit* target, float dist, float angle, MovementSlot slot = MOTION_SLOT_ACTIVE);
|
||||
void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
|
||||
void MoveChase(Unit* target, std::optional<ChaseRange> dist = {}, std::optional<ChaseAngle> angle = {});
|
||||
void MoveChase(Unit* target, float dist, float angle) { MoveChase(target, ChaseRange(dist), ChaseAngle(angle)); }
|
||||
void MoveChase(Unit* target, float dist) { MoveChase(target, ChaseRange(dist)); }
|
||||
void MoveCircleTarget(Unit* target);
|
||||
void MoveBackwards(Unit* target, float dist);
|
||||
void MoveConfused();
|
||||
void MoveFleeing(Unit* enemy, uint32 time = 0);
|
||||
void MovePoint(uint32 id, const Position& pos, bool generatePath = true, bool forceDestination = true)
|
||||
|
||||
Reference in New Issue
Block a user