mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
fixed errors.
This commit is contained in:
@@ -366,7 +366,7 @@ bool Unit::haveOffhandWeapon() const
|
||||
return m_canDualWield;
|
||||
}
|
||||
|
||||
void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed)
|
||||
void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath, bool forceDestination)
|
||||
{
|
||||
Movement::MoveSplineInit init(*this);
|
||||
init.MoveTo(x,y,z);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#ifndef TRINITY_SHAREDDEFINES_H
|
||||
#define TRINITY_SHAREDDEFINES_H
|
||||
|
||||
#include "DetourNavMesh.h"
|
||||
#include "Define.h"
|
||||
#include <cassert>
|
||||
|
||||
@@ -3524,4 +3525,33 @@ enum CalendarError
|
||||
|
||||
// Calendar - end
|
||||
|
||||
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
|
||||
#define MMAP_VERSION 3
|
||||
|
||||
struct MmapTileHeader
|
||||
{
|
||||
uint32 mmapMagic;
|
||||
uint32 dtVersion;
|
||||
uint32 mmapVersion;
|
||||
uint32 size;
|
||||
bool usesLiquids : 1;
|
||||
|
||||
MmapTileHeader() : mmapMagic(MMAP_MAGIC), dtVersion(DT_NAVMESH_VERSION),
|
||||
mmapVersion(MMAP_VERSION), size(0), usesLiquids(true) {}
|
||||
};
|
||||
|
||||
enum NavTerrain
|
||||
{
|
||||
NAV_EMPTY = 0x00,
|
||||
NAV_GROUND = 0x01,
|
||||
NAV_MAGMA = 0x02,
|
||||
NAV_SLIME = 0x04,
|
||||
NAV_WATER = 0x08,
|
||||
NAV_UNUSED1 = 0x10,
|
||||
NAV_UNUSED2 = 0x20,
|
||||
NAV_UNUSED3 = 0x40,
|
||||
NAV_UNUSED4 = 0x80
|
||||
// we only have 8 bits
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -285,13 +285,13 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z)
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
sLog->outStaticDebug("Player (GUID: %u) targeted point (Id: %u X: %f Y: %f Z: %f)", _owner->GetGUIDLow(), id, x, y, z);
|
||||
Mutate(new PointMovementGenerator<Player>(id, x, y, z), MOTION_SLOT_ACTIVE);
|
||||
Mutate(new PointMovementGenerator<Player>(id, x, y, z, true), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outStaticDebug("Creature (Entry: %u GUID: %u) targeted point (ID: %u X: %f Y: %f Z: %f)",
|
||||
_owner->GetEntry(), _owner->GetGUIDLow(), id, x, y, z);
|
||||
Mutate(new PointMovementGenerator<Creature>(id, x, y, z), MOTION_SLOT_ACTIVE);
|
||||
Mutate(new PointMovementGenerator<Creature>(id, x, y, z, true), MOTION_SLOT_ACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,51 +33,6 @@
|
||||
template<class T>
|
||||
void ConfusedMovementGenerator<T>::Initialize(T &unit)
|
||||
{
|
||||
float const wander_distance = 4;
|
||||
float x = unit.GetPositionX();
|
||||
float y = unit.GetPositionY();
|
||||
float z = unit.GetPositionZ();
|
||||
|
||||
Map const* map = unit.GetBaseMap();
|
||||
|
||||
i_nextMove = 1;
|
||||
|
||||
bool is_water_ok, is_land_ok;
|
||||
for (uint8 idx = 0; idx < MAX_CONF_WAYPOINTS + 1; ++idx)
|
||||
{
|
||||
float wanderX = x + (wander_distance * (float)rand_norm() - wander_distance/2);
|
||||
float wanderY = y + (wander_distance * (float)rand_norm() - wander_distance/2);
|
||||
|
||||
// prevent invalid coordinates generation
|
||||
Trinity::NormalizeMapCoord(wanderX);
|
||||
Trinity::NormalizeMapCoord(wanderY);
|
||||
|
||||
if (unit.IsWithinLOS(wanderX, wanderY, z))
|
||||
{
|
||||
bool is_water = map->IsInWater(wanderX, wanderY, z);
|
||||
|
||||
if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
|
||||
{
|
||||
//! Cannot use coordinates outside our InhabitType. Use the current or previous position.
|
||||
wanderX = idx > 0 ? i_waypoints[idx-1][0] : x;
|
||||
wanderY = idx > 0 ? i_waypoints[idx-1][1] : y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//! Trying to access path outside line of sight. Skip this by using the current or previous position.
|
||||
wanderX = idx > 0 ? i_waypoints[idx-1][0] : x;
|
||||
wanderY = idx > 0 ? i_waypoints[idx-1][1] : y;
|
||||
}
|
||||
|
||||
unit.UpdateAllowedPositionZ(wanderX, wanderY, z);
|
||||
|
||||
//! Positions are fine - apply them to this waypoint
|
||||
i_waypoints[idx][0] = wanderX;
|
||||
i_waypoints[idx][1] = wanderY;
|
||||
i_waypoints[idx][2] = z;
|
||||
}
|
||||
|
||||
unit.GetPosition(i_x, i_y, i_z);
|
||||
unit.StopMoving();
|
||||
unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
|
||||
@@ -115,10 +70,9 @@ bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
|
||||
// start moving
|
||||
unit.AddUnitState(UNIT_STATE_CONFUSED_MOVE);
|
||||
|
||||
ASSERT(i_nextMove <= MAX_CONF_WAYPOINTS);
|
||||
float x = i_waypoints[i_nextMove][0];
|
||||
float y = i_waypoints[i_nextMove][1];
|
||||
float z = i_waypoints[i_nextMove][2];
|
||||
float x = i_x + 10.0f*((float)rand_norm() - 0.5f);
|
||||
float y = i_y + 10.0f*((float)rand_norm() - 0.5f);
|
||||
float z = i_z;
|
||||
|
||||
unit.UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class ConfusedMovementGenerator : public MovementGeneratorMedium< T, ConfusedMov
|
||||
MovementGeneratorType GetMovementGeneratorType() { return CONFUSED_MOTION_TYPE; }
|
||||
private:
|
||||
TimeTracker i_nextMoveTime;
|
||||
float i_waypoints[24+1][3];
|
||||
float i_x, i_y, i_z;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -72,29 +72,29 @@ bool FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float
|
||||
if (dist_from_caster > 0.2f)
|
||||
angle_to_caster = fright->GetAngle(&owner);
|
||||
else
|
||||
angle_to_caster = frand(0, 2*M_PI_F);
|
||||
angle_to_caster = frand(0, 2 * static_cast<float>(M_PI));
|
||||
}
|
||||
else
|
||||
{
|
||||
dist_from_caster = 0.0f;
|
||||
angle_to_caster = frand(0, 2*M_PI_F);
|
||||
angle_to_caster = frand(0, 2 * static_cast<float>(M_PI));
|
||||
}
|
||||
|
||||
float dist, angle;
|
||||
if (dist_from_caster < MIN_QUIET_DISTANCE)
|
||||
{
|
||||
dist = frand(0.4f, 1.3f)*(MIN_QUIET_DISTANCE - dist_from_caster);
|
||||
angle = angle_to_caster + frand(-M_PI_F/8, M_PI_F/8);
|
||||
angle = angle_to_caster + frand(-static_cast<float>(M_PI)/8, static_cast<float>(M_PI)/8);
|
||||
}
|
||||
else if(dist_from_caster > MAX_QUIET_DISTANCE)
|
||||
{
|
||||
dist = frand(0.4f, 1.0f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE);
|
||||
angle = -angle_to_caster + frand(-M_PI_F/4, M_PI_F/4);
|
||||
angle = -angle_to_caster + frand(-static_cast<float>(M_PI)/4, static_cast<float>(M_PI)/4);
|
||||
}
|
||||
else // we are inside quiet range
|
||||
{
|
||||
dist = frand(0.6f, 1.2f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE);
|
||||
angle = frand(0, 2*M_PI_F);
|
||||
angle = frand(0, 2*static_cast<float>(M_PI));
|
||||
}
|
||||
|
||||
float curr_x, curr_y, curr_z;
|
||||
|
||||
@@ -34,7 +34,7 @@ void HomeMovementGenerator<Creature>::Finalize(Creature& owner)
|
||||
{
|
||||
if (arrived)
|
||||
{
|
||||
owner.ClearUnitState(UNIT_STAT_EVADE);
|
||||
owner.ClearUnitState(UNIT_STATE_EVADE);
|
||||
owner.SetWalk(true);
|
||||
owner.LoadCreaturesAddon(true);
|
||||
owner.AI()->JustReachedHome();
|
||||
@@ -71,14 +71,3 @@ bool HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32 /*tim
|
||||
arrived = owner.movespline->Finalized();
|
||||
return !arrived;
|
||||
}
|
||||
|
||||
void HomeMovementGenerator<Creature>::Finalize(Creature& owner)
|
||||
{
|
||||
if (arrived)
|
||||
{
|
||||
owner.ClearUnitState(UNIT_STATE_EVADE);
|
||||
owner.SetWalk(true);
|
||||
owner.LoadCreaturesAddon(true);
|
||||
owner.AI()->JustReachedHome();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ bool PathFinderMovementGenerator::calculate(float destX, float destY, float dest
|
||||
|
||||
// make sure navMesh works - we can run on map w/o mmap
|
||||
// check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
|
||||
if (!m_navMesh || !m_navMeshQuery || m_sourceUnit->HasUnitState(UNIT_STAT_IGNORE_PATHFINDING) ||
|
||||
if (!m_navMesh || !m_navMeshQuery || m_sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) ||
|
||||
!HaveTile(start) || !HaveTile(dest))
|
||||
{
|
||||
BuildShortcut();
|
||||
@@ -186,7 +186,7 @@ void PathFinderMovementGenerator::BuildPolyPath(const Vector3 &startPos, const V
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)\n");
|
||||
BuildShortcut();
|
||||
m_type = (m_sourceUnit->GetTypeId() == TYPEID_UNIT && ((Creature*)m_sourceUnit)->canFly())
|
||||
m_type = (m_sourceUnit->GetTypeId() == TYPEID_UNIT && ((Creature*)m_sourceUnit)->CanFly())
|
||||
? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH;
|
||||
return;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ void PathFinderMovementGenerator::BuildPolyPath(const Vector3 &startPos, const V
|
||||
else
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "++ BuildPolyPath :: flying case\n");
|
||||
if (owner->canFly())
|
||||
if (owner->CanFly())
|
||||
buildShotrcut = true;
|
||||
}
|
||||
}
|
||||
@@ -532,7 +532,7 @@ NavTerrain PathFinderMovementGenerator::getNavTerrain(float x, float y, float z)
|
||||
LiquidData data;
|
||||
m_sourceUnit->GetBaseMap()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &data);
|
||||
|
||||
switch (data.type)
|
||||
switch (data.type_flags)
|
||||
{
|
||||
case MAP_LIQUID_TYPE_WATER:
|
||||
case MAP_LIQUID_TYPE_OCEAN:
|
||||
|
||||
@@ -59,8 +59,8 @@ bool PointMovementGenerator<T>::Update(T &unit, const uint32 & /*diff*/)
|
||||
template<class T>
|
||||
void PointMovementGenerator<T>::Finalize(T &unit)
|
||||
{
|
||||
if (unit.HasUnitState(UNIT_STAT_CHARGING))
|
||||
unit.ClearUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
|
||||
if (unit.HasUnitState(UNIT_STATE_CHARGING))
|
||||
unit.ClearUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
|
||||
|
||||
if (unit.movespline->Finalized())
|
||||
MovementInform(unit);
|
||||
|
||||
@@ -68,7 +68,7 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
|
||||
|
||||
// allow pets following their master to cheat while generating paths
|
||||
bool forceDest = (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->isPet()
|
||||
&& owner.HasUnitState(UNIT_STAT_FOLLOW));
|
||||
&& owner.HasUnitState(UNIT_STATE_FOLLOW));
|
||||
i_path->calculate(x, y, z, forceDest);
|
||||
if (i_path->getPathType() & PATHFIND_NOPATH)
|
||||
return;
|
||||
@@ -153,7 +153,7 @@ bool TargetedMovementGeneratorMedium<T,D>::Update(T &owner, const uint32 & time_
|
||||
G3D::Vector3 dest = owner.movespline->FinalDestination();
|
||||
|
||||
bool targetMoved = false;
|
||||
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->canFly())
|
||||
if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly())
|
||||
targetMoved = !i_target->IsWithinDist3d(dest.x, dest.y, dest.z, allowed_dist);
|
||||
else
|
||||
targetMoved = !i_target->IsWithinDist2d(dest.x, dest.y, allowed_dist);
|
||||
|
||||
@@ -39,7 +39,7 @@ class TargetedMovementGeneratorMedium : public MovementGeneratorMedium< T, D >,
|
||||
{
|
||||
protected:
|
||||
TargetedMovementGeneratorMedium(Unit &target, float offset, float angle) :
|
||||
TargetedMovementGeneratorBase(target), i_recheckDistance(0),, i_path(NULL),
|
||||
TargetedMovementGeneratorBase(target), i_recheckDistance(0), i_path(NULL),
|
||||
i_offset(offset), i_angle(angle),
|
||||
i_recalculateTravel(false), i_targetReached(false)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,6 @@ namespace Movement
|
||||
UpdateResult _updateState(int32& ms_time_diff);
|
||||
int32 next_timestamp() const { return spline.length(point_Idx+1);}
|
||||
int32 segment_time_elapsed() const { return next_timestamp()-time_passed;}
|
||||
int32 Duration() const { return spline.length();}
|
||||
int32 timeElapsed() const { return Duration() - time_passed;}
|
||||
int32 timePassed() const { return time_passed;}
|
||||
|
||||
@@ -88,7 +87,7 @@ namespace Movement
|
||||
void _Interrupt() { splineflags.done = true;}
|
||||
|
||||
public:
|
||||
|
||||
int32 Duration() const { return spline.length();}
|
||||
void Initialize(const MoveSplineInitArgs&);
|
||||
bool Initialized() const { return !spline.empty();}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user