mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 17:49:10 +00:00
refactor(Core/Creature): Remove Inhabit Type (#9272)
This is in reference to issue: https://github.com/azerothcore/azerothcore-wotlk/issues/4361 This is comprised of a cherry pick and partial tc cherry pick:592516ae69dbadb6369c34cfa69efd12de860b4aa22bc236eb
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "InstanceScript.h"
|
||||
#include "Log.h"
|
||||
#include "MapMgr.h"
|
||||
#include "MovementGenerator.h"
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineInit.h"
|
||||
#include "ObjectAccessor.h"
|
||||
@@ -3777,13 +3778,14 @@ bool Unit::isInAccessiblePlaceFor(Creature const* c) const
|
||||
return false;
|
||||
}
|
||||
|
||||
// In water or jumping in water
|
||||
if (IsInWater() || (GetLiquidData().Status == LIQUID_MAP_ABOVE_WATER && (IsFalling() || (ToPlayer() && ToPlayer()->IsFalling()))))
|
||||
if (IsInWater())
|
||||
{
|
||||
return IsUnderWater() ? c->CanEnterWater() : (c->CanEnterWater() || c->CanFly());
|
||||
return c->CanEnterWater();
|
||||
}
|
||||
else
|
||||
{
|
||||
return c->CanWalk() || c->CanFly();
|
||||
}
|
||||
|
||||
return c->CanWalk() || c->CanFly() || (c->CanSwim() && IsInWater());
|
||||
}
|
||||
|
||||
void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data)
|
||||
@@ -13578,28 +13580,29 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
|
||||
case MOVE_RUN:
|
||||
case MOVE_SWIM:
|
||||
case MOVE_FLIGHT:
|
||||
{
|
||||
// Set creature speed rate
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
speed *= ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached
|
||||
|
||||
// Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need
|
||||
/// @todo possible affect only on MOVE_RUN
|
||||
if (int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED))
|
||||
{
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
if (Creature* creature = ToCreature())
|
||||
{
|
||||
speed *= ToCreature()->GetCreatureTemplate()->speed_run; // at this point, MOVE_WALK is never reached
|
||||
uint32 immuneMask = creature->GetCreatureTemplate()->MechanicImmuneMask;
|
||||
if (immuneMask & (1 << (MECHANIC_SNARE - 1)) || immuneMask & (1 << (MECHANIC_DAZE - 1)))
|
||||
break;
|
||||
}
|
||||
|
||||
// Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need
|
||||
// TODO: possible affect only on MOVE_RUN
|
||||
if (int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED))
|
||||
{
|
||||
// Use speed from aura
|
||||
float max_speed = normalization / (IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]);
|
||||
|
||||
// Xinef: normal movement speed - multiply by creature db modifer
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
max_speed *= ToCreature()->GetCreatureTemplate()->speed_run;
|
||||
|
||||
if (speed > max_speed)
|
||||
speed = max_speed;
|
||||
}
|
||||
break;
|
||||
// Use speed from aura
|
||||
float max_speed = normalization / (IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]);
|
||||
if (speed > max_speed)
|
||||
speed = max_speed;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -16039,6 +16042,11 @@ void Unit::SendPetAIReaction(ObjectGuid guid)
|
||||
|
||||
///----------End of Pet responses methods----------
|
||||
|
||||
MovementGeneratorType Unit::GetDefaultMovementType() const
|
||||
{
|
||||
return IDLE_MOTION_TYPE;
|
||||
}
|
||||
|
||||
void Unit::StopMoving()
|
||||
{
|
||||
ClearUnitState(UNIT_STATE_MOVING);
|
||||
@@ -16058,6 +16066,26 @@ void Unit::StopMoving()
|
||||
init.Stop();
|
||||
}
|
||||
|
||||
void Unit::PauseMovement(uint32 timer /* = 0*/, uint8 slot /* = 0*/)
|
||||
{
|
||||
if (slot >= MAX_MOTION_SLOT)
|
||||
return;
|
||||
|
||||
if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(slot))
|
||||
movementGenerator->Pause(timer);
|
||||
|
||||
StopMoving();
|
||||
}
|
||||
|
||||
void Unit::ResumeMovement(uint32 timer /* = 0*/, uint8 slot /* = 0*/)
|
||||
{
|
||||
if (slot >= MAX_MOTION_SLOT)
|
||||
return;
|
||||
|
||||
if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(slot))
|
||||
movementGenerator->Resume(timer);
|
||||
}
|
||||
|
||||
void Unit::StopMovingOnCurrentPos() // pussywizard
|
||||
{
|
||||
ClearUnitState(UNIT_STATE_MOVING);
|
||||
@@ -17649,8 +17677,16 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE))
|
||||
{
|
||||
movementGenerator->Pause(0);
|
||||
}
|
||||
|
||||
GetMotionMaster()->Clear(MOTION_SLOT_ACTIVE);
|
||||
|
||||
StopMoving();
|
||||
|
||||
ToCreature()->AI()->OnCharmed(true);
|
||||
GetMotionMaster()->MoveIdle();
|
||||
|
||||
// Xinef: If creature can fly, add normal player flying flag (fixes speed)
|
||||
if (charmer->GetTypeId() == TYPEID_PLAYER && ToCreature()->CanFly())
|
||||
@@ -19107,7 +19143,7 @@ bool Unit::CanSwim() const
|
||||
return true;
|
||||
if (HasFlag(UNIT_FIELD_FLAGS_2, 0x1000000))
|
||||
return false;
|
||||
if (IsPet() && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT))
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT))
|
||||
return true;
|
||||
return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_RENAME | UNIT_FLAG_SWIMMING);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user