mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-20 23:01:36 -04:00
Attempt on converting updatewaterstate for use with units (pets and vehicles)
This commit is contained in:
@@ -6830,11 +6830,6 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, bool t
|
||||
if (GetGroup())
|
||||
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
|
||||
|
||||
// code block for underwater state update
|
||||
// Unit::UpdatePosition() checks for validity and updates our coordinates
|
||||
// so we re-fetch them instead of using "raw" coordinates from function params
|
||||
UpdateUnderwaterState(GetMap(), GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
|
||||
if (GetTrader() && !IsWithinDistInMap(GetTrader(), INTERACTION_DISTANCE))
|
||||
GetSession()->SendCancelTrade();
|
||||
|
||||
|
||||
@@ -3089,6 +3089,48 @@ bool Unit::IsUnderWater() const
|
||||
return GetBaseMap()->IsUnderWater(GetPositionX(), GetPositionY(), GetPositionZ());
|
||||
}
|
||||
|
||||
void Unit::UpdateUnderwaterState(Map* m, float x, float y, float z)
|
||||
{
|
||||
if (!isPet() && !IsVehicle())
|
||||
return;
|
||||
|
||||
LiquidData liquid_status;
|
||||
ZLiquidStatus res = m->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status);
|
||||
if (!res)
|
||||
{
|
||||
if (_lastLiquid && _lastLiquid->SpellId)
|
||||
RemoveAurasDueToSpell(_lastLiquid->SpellId);
|
||||
|
||||
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_UNDERWATER);
|
||||
_lastLiquid = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (uint32 liqEntry = liquid_status.entry)
|
||||
{
|
||||
LiquidTypeEntry const* liquid = sLiquidTypeStore.LookupEntry(liqEntry);
|
||||
if (_lastLiquid && _lastLiquid->SpellId && _lastLiquid->Id != liqEntry)
|
||||
RemoveAurasDueToSpell(_lastLiquid->SpellId);
|
||||
|
||||
if (liquid && liquid->SpellId)
|
||||
{
|
||||
if (res & (LIQUID_MAP_UNDER_WATER | LIQUID_MAP_IN_WATER))
|
||||
CastSpell(this, liquid->SpellId, true);
|
||||
else
|
||||
RemoveAurasDueToSpell(liquid->SpellId);
|
||||
}
|
||||
|
||||
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_ABOVEWATER);
|
||||
_lastLiquid = liquid;
|
||||
}
|
||||
else if (_lastLiquid && _lastLiquid->SpellId)
|
||||
{
|
||||
RemoveAurasDueToSpell(_lastLiquid->SpellId);
|
||||
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_UNDERWATER);
|
||||
_lastLiquid = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::DeMorph()
|
||||
{
|
||||
SetDisplayId(GetNativeDisplayId());
|
||||
@@ -17255,6 +17297,9 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
else if (turn)
|
||||
UpdateOrientation(orientation);
|
||||
|
||||
// code block for underwater state update
|
||||
UpdateUnderwaterState(GetMap(), x, y, z);
|
||||
|
||||
return (relocated || turn);
|
||||
}
|
||||
|
||||
|
||||
@@ -1580,6 +1580,7 @@ class Unit : public WorldObject
|
||||
|
||||
virtual bool IsInWater() const;
|
||||
virtual bool IsUnderWater() const;
|
||||
virtual void UpdateUnderwaterState(Map* m, float x, float y, float z);
|
||||
bool isInAccessiblePlaceFor(Creature const* c) const;
|
||||
|
||||
void SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 OverHeal, uint32 Absorb, bool critical = false);
|
||||
@@ -2353,6 +2354,7 @@ class Unit : public WorldObject
|
||||
uint32 m_state; // Even derived shouldn't modify
|
||||
uint32 m_CombatTimer;
|
||||
uint32 m_lastManaUse; // msecs
|
||||
LiquidTypeEntry const* _lastLiquid;
|
||||
TimeTrackerSmall m_movesplineTimer;
|
||||
|
||||
Diminishing m_Diminishing;
|
||||
|
||||
@@ -114,6 +114,9 @@ void MotionMaster::UpdateMotion(uint32 diff)
|
||||
|
||||
_cleanFlag &= ~MMCF_RESET;
|
||||
}
|
||||
|
||||
// probably not the best place to pu this but im not really sure where else to put it.
|
||||
_owner->UpdateUnderwaterState(_owner->GetMap(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
|
||||
}
|
||||
|
||||
void MotionMaster::DirectClean(bool reset)
|
||||
|
||||
Reference in New Issue
Block a user