mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
fix(Core/Movement): (#7008)
- Get zone/area IDs from vmap data in the liquid update - Add new method Map::getFullVMapDataForPosition to get area info and liquid info in a single vmap lookup - Adjust GetZoneId/GetAreaId on WorldObject to always return these cached fields. - Clean up liquid state handling on Unit and Player - Implemented getting area id from gameobject spawns. - Removed old core related to getting movement flags dependent on environment. - Movement flags are now processed more precisely and dynamically. Original source: TrinityCore. - Closes #5086 - Updates #2208.
This commit is contained in:
@@ -26,7 +26,7 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* unit)
|
||||
float y = unit->GetPositionY();
|
||||
float z = unit->GetPositionZ();
|
||||
|
||||
Map const* map = unit->GetBaseMap();
|
||||
Map const* map = unit->GetMap();
|
||||
|
||||
bool is_water_ok, is_land_ok;
|
||||
_InitSpecific(unit, is_water_ok, is_land_ok);
|
||||
@@ -50,7 +50,7 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* unit)
|
||||
}
|
||||
else if (unit->IsWithinLOS(wanderX, wanderY, z))
|
||||
{
|
||||
bool is_water = map->IsInWater(wanderX, wanderY, z);
|
||||
bool is_water = map->IsInWater(unit->GetPhaseMask(), wanderX, wanderY, z, unit->GetCollisionHeight());
|
||||
|
||||
if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ bool FleeingMovementGenerator<T>::_getPoint(T* owner, float& x, float& y, float&
|
||||
if (!owner)
|
||||
return false;
|
||||
|
||||
const Map* _map = owner->GetBaseMap();
|
||||
const Map* _map = owner->GetMap();
|
||||
|
||||
x = owner->GetPositionX();
|
||||
y = owner->GetPositionY();
|
||||
|
||||
@@ -29,8 +29,6 @@ void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner)
|
||||
|
||||
if (!owner->HasSwimmingFlagOutOfCombat())
|
||||
owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SWIMMING);
|
||||
|
||||
owner->UpdateEnvironmentIfNeeded(2);
|
||||
}
|
||||
|
||||
void HomeMovementGenerator<Creature>::DoReset(Creature*)
|
||||
|
||||
@@ -197,8 +197,8 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
|
||||
{
|
||||
bool buildShotrcut = false;
|
||||
|
||||
bool isUnderWaterStart = _source->GetMap()->IsUnderWater(startPos.x, startPos.y, startPos.z);
|
||||
bool isUnderWaterEnd = _source->GetMap()->IsUnderWater(endPos.x, endPos.y, endPos.z);
|
||||
bool isUnderWaterStart = _source->GetMap()->IsUnderWater(_source->GetPhaseMask(), startPos.x, startPos.y, startPos.z, _source->GetCollisionHeight());
|
||||
bool isUnderWaterEnd = _source->GetMap()->IsUnderWater(_source->GetPhaseMask(), endPos.x, endPos.y, endPos.z, _source->GetCollisionHeight());
|
||||
bool isFarUnderWater = startFarFromPoly ? isUnderWaterStart : isUnderWaterEnd;
|
||||
|
||||
Unit const* _sourceUnit = _source->ToUnit();
|
||||
@@ -565,9 +565,9 @@ void PathGenerator::BuildPointPath(const float* startPoint, const float* endPoin
|
||||
uint32 newPointCount = 0;
|
||||
for (uint32 i = 0; i < pointCount; ++i) {
|
||||
G3D::Vector3 vector = G3D::Vector3(pathPoints[i * VERTEX_SIZE + 2], pathPoints[i * VERTEX_SIZE], pathPoints[i * VERTEX_SIZE + 1]);
|
||||
ZLiquidStatus status = _source->GetMap()->getLiquidStatus(vector.x, vector.y, vector.z, MAP_ALL_LIQUIDS, nullptr);
|
||||
LiquidData const& liquidData = _source->GetMap()->GetLiquidData(_source->GetPhaseMask(), vector.x, vector.y, vector.z, _source->GetCollisionHeight(), MAP_ALL_LIQUIDS);
|
||||
// One of the points is not in the water
|
||||
if (status == LIQUID_MAP_UNDER_WATER)
|
||||
if (liquidData.Status == LIQUID_MAP_UNDER_WATER)
|
||||
{
|
||||
// if the first point is under water
|
||||
// then set a proper z for it
|
||||
@@ -699,11 +699,11 @@ void PathGenerator::UpdateFilter()
|
||||
NavTerrain PathGenerator::GetNavTerrain(float x, float y, float z) const
|
||||
{
|
||||
LiquidData data;
|
||||
ZLiquidStatus liquidStatus = _source->GetMap()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &data);
|
||||
if (liquidStatus == LIQUID_MAP_NO_WATER)
|
||||
LiquidData const& liquidData = _source->GetMap()->GetLiquidData(_source->GetPhaseMask(), x, y, z, _source->GetCollisionHeight(), MAP_ALL_LIQUIDS);
|
||||
if (liquidData.Status == LIQUID_MAP_NO_WATER)
|
||||
return NAV_GROUND;
|
||||
|
||||
switch (data.type_flags)
|
||||
switch (data.Flags)
|
||||
{
|
||||
case MAP_LIQUID_TYPE_WATER:
|
||||
case MAP_LIQUID_TYPE_OCEAN:
|
||||
@@ -1149,8 +1149,8 @@ bool PathGenerator::IsSwimmableSegment(float const* v1, float const* v2, bool ch
|
||||
bool PathGenerator::IsSwimmableSegment(float x, float y, float z, float destX, float destY, float destZ, bool checkSwim) const
|
||||
{
|
||||
Creature const* _sourceCreature = _source->ToCreature();
|
||||
return _source->GetMap()->IsInWater(x, y, z) &&
|
||||
_source->GetMap()->IsInWater(destX, destY, destZ) &&
|
||||
return _source->GetMap()->IsInWater(_source->GetPhaseMask(), x, y, z, _source->GetCollisionHeight()) &&
|
||||
_source->GetMap()->IsInWater(_source->GetPhaseMask(), destX, destY, destZ, _source->GetCollisionHeight()) &&
|
||||
(!checkSwim || !_sourceCreature || _sourceCreature->CanSwim());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user