mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
refactor(Core): Make more use of helpers. (#19835)
* Init. * Reword. * Update codestyle script. Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com> * Add gameobject type ID check, reorder checks. * Add helper/codestyle check for unit type. * `IsUnit()` -> `IsCreature()` * Add `IsUnit()` method. * Use type mask. https: //github.com/TrinityCore/TrinityCore/commit/cc71da35b5dc74abf71f8691161525a23d870bb5 Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com> Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com> * Replace instances of `isType` with `IsUnit`. --------- Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com> Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
@@ -1904,7 +1904,7 @@ bool Creature::CanStartAttack(Unit const* who) const
|
||||
return false;
|
||||
|
||||
// This set of checks is should be done only for creatures
|
||||
if ((IsImmuneToNPC() && who->GetTypeId() != TYPEID_PLAYER) || // flag is valid only for non player characters
|
||||
if ((IsImmuneToNPC() && !who->IsPlayer()) || // flag is valid only for non player characters
|
||||
(IsImmuneToPC() && who->IsPlayer())) // immune to PC and target is a player, return false
|
||||
{
|
||||
return false;
|
||||
@@ -1915,7 +1915,7 @@ bool Creature::CanStartAttack(Unit const* who) const
|
||||
return false;
|
||||
|
||||
// Do not attack non-combat pets
|
||||
if (who->GetTypeId() == TYPEID_UNIT && who->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
|
||||
if (who->IsCreature() && who->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
|
||||
return false;
|
||||
|
||||
if (!CanFly() && (GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE + m_CombatDistance)) // too much Z difference, skip very costy vmap calculations here
|
||||
@@ -2498,7 +2498,7 @@ bool Creature::CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction /
|
||||
return false;
|
||||
|
||||
// pussywizard: or if enemy is in evade mode
|
||||
if (enemy && enemy->GetTypeId() == TYPEID_UNIT && enemy->ToCreature()->IsInEvadeMode())
|
||||
if (enemy && enemy->IsCreature() && enemy->ToCreature()->IsInEvadeMode())
|
||||
return false;
|
||||
|
||||
// we don't need help from non-combatant ;)
|
||||
@@ -2636,7 +2636,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
|
||||
return false;
|
||||
|
||||
// pussywizard: or if enemy is in evade mode
|
||||
if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode())
|
||||
if (victim->IsCreature() && victim->ToCreature()->IsInEvadeMode())
|
||||
return false;
|
||||
|
||||
// cannot attack if is during 5 second grace period, unless being attacked
|
||||
|
||||
@@ -254,14 +254,14 @@ void TempSummon::InitSummon()
|
||||
WorldObject* owner = GetSummoner();
|
||||
if (owner)
|
||||
{
|
||||
if (owner->GetTypeId() == TYPEID_UNIT)
|
||||
if (owner->IsCreature())
|
||||
{
|
||||
if (owner->ToCreature()->IsAIEnabled)
|
||||
{
|
||||
owner->ToCreature()->AI()->JustSummoned(this);
|
||||
}
|
||||
}
|
||||
else if (owner->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
else if (owner->IsGameObject())
|
||||
{
|
||||
if (owner->ToGameObject()->AI())
|
||||
{
|
||||
@@ -304,11 +304,11 @@ void TempSummon::UnSummon(uint32 msTime)
|
||||
|
||||
if (WorldObject* owner = GetSummoner())
|
||||
{
|
||||
if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
||||
if (owner->IsCreature() && owner->ToCreature()->IsAIEnabled)
|
||||
{
|
||||
owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
|
||||
}
|
||||
else if (owner->GetTypeId() == TYPEID_GAMEOBJECT && owner->ToGameObject()->AI())
|
||||
else if (owner->IsGameObject() && owner->ToGameObject()->AI())
|
||||
{
|
||||
owner->ToGameObject()->AI()->SummonedCreatureDespawn(this);
|
||||
}
|
||||
|
||||
@@ -1280,7 +1280,7 @@ bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
|
||||
Unit* owner = GetOwner();
|
||||
if (owner)
|
||||
{
|
||||
if (seer->isType(TYPEMASK_UNIT) && owner->IsFriendlyTo(seer->ToUnit()))
|
||||
if (seer->IsUnit() && owner->IsFriendlyTo(seer->ToUnit()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1521,7 +1521,7 @@ void GameObject::Use(Unit* user)
|
||||
return;
|
||||
case GAMEOBJECT_TYPE_QUESTGIVER: //2
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -1550,7 +1550,7 @@ void GameObject::Use(Unit* user)
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
if (ChairListSlots.empty()) // this is called once at first chair use to make list of available slots
|
||||
@@ -1717,7 +1717,7 @@ void GameObject::Use(Unit* user)
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -1818,7 +1818,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -1831,7 +1831,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
if (owner)
|
||||
{
|
||||
if (owner->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!owner->IsPlayer())
|
||||
return;
|
||||
|
||||
// accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect)
|
||||
@@ -1908,7 +1908,7 @@ void GameObject::Use(Unit* user)
|
||||
{
|
||||
GameObjectTemplate const* info = GetGOInfo();
|
||||
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -1934,7 +1934,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
case GAMEOBJECT_TYPE_FLAGSTAND: // 24
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -1966,7 +1966,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
case GAMEOBJECT_TYPE_FISHINGHOLE: // 25
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -1978,7 +1978,7 @@ void GameObject::Use(Unit* user)
|
||||
|
||||
case GAMEOBJECT_TYPE_FLAGDROP: // 26
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -2036,7 +2036,7 @@ void GameObject::Use(Unit* user)
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
if (user->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!user->IsPlayer())
|
||||
return;
|
||||
|
||||
Player* player = user->ToPlayer();
|
||||
@@ -2063,7 +2063,7 @@ void GameObject::Use(Unit* user)
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!spellInfo)
|
||||
{
|
||||
if (user->GetTypeId() != TYPEID_PLAYER || !sOutdoorPvPMgr->HandleCustomSpell(user->ToPlayer(), spellId, this))
|
||||
if (!user->IsPlayer() || !sOutdoorPvPMgr->HandleCustomSpell(user->ToPlayer(), spellId, this))
|
||||
LOG_ERROR("entities.gameobject", "WORLD: unknown spell id {} at use action for gameobject (Entry: {} GoType: {})", spellId, GetEntry(), GetGoType());
|
||||
else
|
||||
LOG_DEBUG("outdoorpvp", "WORLD: {} non-dbc spell was handled by OutdoorPvP", spellId);
|
||||
|
||||
@@ -226,7 +226,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target)
|
||||
}
|
||||
}
|
||||
|
||||
if (isType(TYPEMASK_UNIT))
|
||||
if (IsUnit())
|
||||
{
|
||||
if (((Unit*)this)->GetVictim())
|
||||
flags |= UPDATEFLAG_HAS_TARGET;
|
||||
@@ -275,7 +275,7 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const
|
||||
{
|
||||
ASSERT(target);
|
||||
|
||||
if (isType(TYPEMASK_UNIT) || isType(TYPEMASK_PLAYER))
|
||||
if (IsUnit() || isType(TYPEMASK_PLAYER))
|
||||
{
|
||||
if (Battleground* bg = target->GetBattleground())
|
||||
{
|
||||
@@ -345,7 +345,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
|
||||
Unit const* unit = nullptr;
|
||||
WorldObject const* object = nullptr;
|
||||
|
||||
if (isType(TYPEMASK_UNIT))
|
||||
if (IsUnit())
|
||||
unit = ToUnit();
|
||||
else
|
||||
object = ((WorldObject*)this);
|
||||
@@ -1101,20 +1101,20 @@ void WorldObject::setActive(bool on)
|
||||
|
||||
if (on)
|
||||
{
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
if (IsCreature())
|
||||
map->AddToActive(this->ToCreature());
|
||||
else if (IsDynamicObject())
|
||||
map->AddToActive((DynamicObject*)this);
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
else if (IsGameObject())
|
||||
map->AddToActive((GameObject*)this);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetTypeId() == TYPEID_UNIT)
|
||||
if (IsCreature())
|
||||
map->RemoveFromActive(this->ToCreature());
|
||||
else if (IsDynamicObject())
|
||||
map->RemoveFromActive((DynamicObject*)this);
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
else if (IsGameObject())
|
||||
map->RemoveFromActive((GameObject*)this);
|
||||
}
|
||||
}
|
||||
@@ -1147,7 +1147,7 @@ void WorldObject::SetPositionDataUpdate()
|
||||
_updatePositionData = true;
|
||||
|
||||
// Calls immediately for charmed units
|
||||
if (GetTypeId() == TYPEID_UNIT && ToUnit()->IsCharmedOwnedByPlayerOrPlayer())
|
||||
if (IsCreature() && ToUnit()->IsCharmedOwnedByPlayerOrPlayer())
|
||||
UpdatePositionData();
|
||||
}
|
||||
|
||||
@@ -1531,7 +1531,7 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
|
||||
{
|
||||
float new_z = GetMapHeight(x, y, z);
|
||||
if (new_z > INVALID_HEIGHT)
|
||||
z = new_z + (isType(TYPEMASK_UNIT) ? static_cast<Unit const*>(this)->GetHoverHeight() : 0.0f);
|
||||
z = new_z + (IsUnit() ? static_cast<Unit const*>(this)->GetHoverHeight() : 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1634,7 +1634,7 @@ float WorldObject::GetGridActivationRange() const
|
||||
{
|
||||
return ToCreature()->m_SightDistance;
|
||||
}
|
||||
else if (((GetTypeId() == TYPEID_GAMEOBJECT && ToGameObject()->IsTransport()) || IsDynamicObject()) && isActiveObject())
|
||||
else if (((IsGameObject() && ToGameObject()->IsTransport()) || IsDynamicObject()) && isActiveObject())
|
||||
{
|
||||
return GetMap()->GetVisibilityRange();
|
||||
}
|
||||
@@ -1644,11 +1644,11 @@ float WorldObject::GetGridActivationRange() const
|
||||
|
||||
float WorldObject::GetVisibilityRange() const
|
||||
{
|
||||
if (IsVisibilityOverridden() && GetTypeId() == TYPEID_UNIT)
|
||||
if (IsVisibilityOverridden() && IsCreature())
|
||||
{
|
||||
return *m_visibilityDistanceOverride;
|
||||
}
|
||||
else if (GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
else if (IsGameObject())
|
||||
{
|
||||
{
|
||||
if (IsInWintergrasp())
|
||||
@@ -1677,11 +1677,11 @@ float WorldObject::GetSightRange(WorldObject const* target) const
|
||||
{
|
||||
if (target)
|
||||
{
|
||||
if (target->IsVisibilityOverridden() && target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsVisibilityOverridden() && target->IsCreature())
|
||||
{
|
||||
return *target->m_visibilityDistanceOverride;
|
||||
}
|
||||
else if (target->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
else if (target->IsGameObject())
|
||||
{
|
||||
if (IsInWintergrasp() && target->IsInWintergrasp())
|
||||
{
|
||||
@@ -1872,7 +1872,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
|
||||
|
||||
bool WorldObject::CanNeverSee(WorldObject const* obj) const
|
||||
{
|
||||
if (GetTypeId() == TYPEID_UNIT && obj->GetTypeId() == TYPEID_UNIT)
|
||||
if (IsCreature() && obj->IsCreature())
|
||||
return GetMap() != obj->GetMap() || (!InSamePhase(obj) && ToUnit()->GetVehicleBase() != obj && this != obj->ToUnit()->GetVehicleBase());
|
||||
return GetMap() != obj->GetMap() || !InSamePhase(obj);
|
||||
}
|
||||
@@ -1901,7 +1901,7 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth, bool che
|
||||
// xinef: ignore units players have at client, this cant be cheated!
|
||||
if (checkClient)
|
||||
{
|
||||
if (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->HaveAtClient(obj))
|
||||
if (!IsPlayer() || !ToPlayer()->HaveAtClient(obj))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -1992,7 +1992,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
|
||||
float distance = GetExactDist(obj);
|
||||
float combatReach = 0.0f;
|
||||
|
||||
if (isType(TYPEMASK_UNIT))
|
||||
if (IsUnit())
|
||||
combatReach = ((Unit*)this)->GetCombatReach();
|
||||
|
||||
if (distance < combatReach)
|
||||
@@ -2006,7 +2006,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
|
||||
if (!(obj->m_stealth.GetFlags() & (1 << i)))
|
||||
continue;
|
||||
|
||||
if (isType(TYPEMASK_UNIT))
|
||||
if (IsUnit())
|
||||
if (((Unit*)this)->HasAuraTypeWithMiscvalue(SPELL_AURA_DETECT_STEALTH, i))
|
||||
return true;
|
||||
|
||||
@@ -2389,7 +2389,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
|
||||
if (respawnTime)
|
||||
go->SetSpellId(1);
|
||||
|
||||
if (IsPlayer() || (GetTypeId() == TYPEID_UNIT && summonType == GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)) //not sure how to handle this
|
||||
if (IsPlayer() || (IsCreature() && summonType == GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)) //not sure how to handle this
|
||||
ToUnit()->AddGameObject(go);
|
||||
else
|
||||
go->SetSpawnedByDefault(false);
|
||||
@@ -2406,7 +2406,7 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3
|
||||
return nullptr;
|
||||
|
||||
//summon->SetName(GetName());
|
||||
if (setLevel && (IsPlayer() || GetTypeId() == TYPEID_UNIT))
|
||||
if (setLevel && (IsPlayer() || IsCreature()))
|
||||
{
|
||||
summon->SetFaction(((Unit*)this)->GetFaction());
|
||||
summon->SetLevel(((Unit*)this)->GetLevel());
|
||||
@@ -2428,9 +2428,9 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3
|
||||
*/
|
||||
void WorldObject::SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list /*= nullptr*/)
|
||||
{
|
||||
ASSERT((GetTypeId() == TYPEID_GAMEOBJECT || GetTypeId() == TYPEID_UNIT) && "Only GOs and creatures can summon npc groups!");
|
||||
ASSERT((IsGameObject() || IsCreature()) && "Only GOs and creatures can summon npc groups!");
|
||||
|
||||
std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetEntry(), GetTypeId() == TYPEID_GAMEOBJECT ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group);
|
||||
std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetEntry(), IsGameObject() ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group);
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
@@ -2742,7 +2742,7 @@ void WorldObject::GetContactPoint(WorldObject const* obj, float& x, float& y, fl
|
||||
GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
|
||||
|
||||
// Exclude gameobjects from LoS calculations
|
||||
if (std::fabs(this->GetPositionZ() - z) > 3.0f || (GetTypeId() != TYPEID_GAMEOBJECT && !IsWithinLOS(x, y, z)))
|
||||
if (std::fabs(this->GetPositionZ() - z) > 3.0f || (!IsGameObject() && !IsWithinLOS(x, y, z)))
|
||||
{
|
||||
x = this->GetPositionX();
|
||||
y = this->GetPositionY();
|
||||
@@ -2955,7 +2955,7 @@ void WorldObject::DestroyForNearbyPlayers()
|
||||
if (!player->HaveAtClient(this))
|
||||
continue;
|
||||
|
||||
if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) /// @todo: this is for puppet
|
||||
if (IsUnit() && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) /// @todo: this is for puppet
|
||||
continue;
|
||||
|
||||
DestroyForPlayer(player);
|
||||
@@ -3123,7 +3123,7 @@ float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/,
|
||||
float WorldObject::GetMapWaterOrGroundLevel(float x, float y, float z, float* ground/* = nullptr*/) const
|
||||
{
|
||||
return GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, ground,
|
||||
isType(TYPEMASK_UNIT) ? !static_cast<Unit const*>(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false,
|
||||
IsUnit() ? !static_cast<Unit const*>(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false,
|
||||
std::max(GetCollisionHeight(), Z_OFFSET_FIND_HEIGHT));
|
||||
}
|
||||
|
||||
|
||||
@@ -198,11 +198,13 @@ public:
|
||||
Player* ToPlayer() { if (IsPlayer()) return reinterpret_cast<Player*>(this); else return nullptr; }
|
||||
[[nodiscard]] Player const* ToPlayer() const { if (IsPlayer()) return reinterpret_cast<Player const*>(this); else return nullptr; }
|
||||
|
||||
Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return nullptr; }
|
||||
[[nodiscard]] Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature const*>(this); else return nullptr; }
|
||||
[[nodiscard]] inline bool IsCreature() const { return GetTypeId() == TYPEID_UNIT; }
|
||||
Creature* ToCreature() { if (IsCreature()) return reinterpret_cast<Creature*>(this); else return nullptr; }
|
||||
[[nodiscard]] Creature const* ToCreature() const { if (IsCreature()) return reinterpret_cast<Creature const*>(this); else return nullptr; }
|
||||
|
||||
Unit* ToUnit() { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast<Unit*>(this); else return nullptr; }
|
||||
[[nodiscard]] Unit const* ToUnit() const { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast<Unit const*>(this); else return nullptr; }
|
||||
[[nodiscard]] inline bool IsUnit() const { return isType(TYPEMASK_UNIT); }
|
||||
Unit* ToUnit() { if (IsCreature() || IsPlayer()) return reinterpret_cast<Unit*>(this); else return nullptr; }
|
||||
[[nodiscard]] Unit const* ToUnit() const { if (IsCreature() || IsPlayer()) return reinterpret_cast<Unit const*>(this); else return nullptr; }
|
||||
|
||||
[[nodiscard]] inline bool IsGameObject() const { return GetTypeId() == TYPEID_GAMEOBJECT; }
|
||||
GameObject* ToGameObject() { if (IsGameObject()) return reinterpret_cast<GameObject*>(this); else return nullptr; }
|
||||
|
||||
@@ -181,20 +181,20 @@ class ObjectGuid
|
||||
{
|
||||
switch (high)
|
||||
{
|
||||
case HighGuid::Item: return TYPEID_ITEM;
|
||||
//case HighGuid::Container: return TYPEID_CONTAINER; HighGuid::Container == HighGuid::Item currently
|
||||
case HighGuid::Unit: return TYPEID_UNIT;
|
||||
case HighGuid::Pet: return TYPEID_UNIT;
|
||||
case HighGuid::Player: return TYPEID_PLAYER;
|
||||
case HighGuid::GameObject: return TYPEID_GAMEOBJECT;
|
||||
case HighGuid::Item: return TYPEID_ITEM;
|
||||
//case HighGuid::Container: return TYPEID_CONTAINER; HighGuid::Container == HighGuid::Item currently
|
||||
case HighGuid::Unit: return TYPEID_UNIT;
|
||||
case HighGuid::Pet: return TYPEID_UNIT;
|
||||
case HighGuid::Player: return TYPEID_PLAYER;
|
||||
case HighGuid::GameObject: return TYPEID_GAMEOBJECT;
|
||||
case HighGuid::DynamicObject: return TYPEID_DYNAMICOBJECT;
|
||||
case HighGuid::Corpse: return TYPEID_CORPSE;
|
||||
case HighGuid::Mo_Transport: return TYPEID_GAMEOBJECT;
|
||||
case HighGuid::Vehicle: return TYPEID_UNIT;
|
||||
case HighGuid::Corpse: return TYPEID_CORPSE;
|
||||
case HighGuid::Mo_Transport: return TYPEID_GAMEOBJECT;
|
||||
case HighGuid::Vehicle: return TYPEID_UNIT;
|
||||
// unknown
|
||||
case HighGuid::Instance:
|
||||
case HighGuid::Group:
|
||||
default: return TYPEID_OBJECT;
|
||||
default: return TYPEID_OBJECT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2060,7 +2060,7 @@ void Pet::InitPetCreateSpells()
|
||||
bool Pet::resetTalents()
|
||||
{
|
||||
Unit* owner = GetOwner();
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!owner || !owner->IsPlayer())
|
||||
return false;
|
||||
|
||||
if (!sScriptMgr->CanResetTalents(this))
|
||||
@@ -2228,7 +2228,7 @@ void Pet::InitTalentForLevel()
|
||||
uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
|
||||
|
||||
Unit* owner = GetOwner();
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!owner || !owner->IsPlayer())
|
||||
return;
|
||||
|
||||
// Reset talents in case low level (on level down) or wrong points for level (hunter can unlearn TP increase talent)
|
||||
@@ -2368,7 +2368,7 @@ void Pet::LearnPetPassives()
|
||||
void Pet::CastPetAuras(bool current)
|
||||
{
|
||||
Unit* owner = GetOwner();
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!owner || !owner->IsPlayer())
|
||||
return;
|
||||
|
||||
if (!IsPermanentPetFor(owner->ToPlayer()))
|
||||
@@ -2397,7 +2397,7 @@ void Pet::learnSpellHighRank(uint32 spellid)
|
||||
void Pet::SynchronizeLevelWithOwner()
|
||||
{
|
||||
Unit* owner = GetOwner();
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!owner || !owner->IsPlayer())
|
||||
return;
|
||||
|
||||
switch (getPetType())
|
||||
|
||||
@@ -130,7 +130,7 @@ void KillRewarder::_InitXP(Player* player)
|
||||
_xp = Acore::XP::Gain(player, _victim, _isBattleGround);
|
||||
|
||||
if (_xp && !_isBattleGround && _victim) // pussywizard: npcs with relatively low hp give lower exp
|
||||
if (_victim->GetTypeId() == TYPEID_UNIT)
|
||||
if (_victim->IsCreature())
|
||||
if (const CreatureTemplate* ct = _victim->ToCreature()->GetCreatureTemplate())
|
||||
if (ct->ModHealth <= 0.75f && ct->ModHealth >= 0.0f)
|
||||
_xp = uint32(_xp * ct->ModHealth);
|
||||
|
||||
@@ -2385,7 +2385,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate, bool isLFGReward)
|
||||
return;
|
||||
}
|
||||
|
||||
if (victim && victim->GetTypeId() == TYPEID_UNIT && !victim->ToCreature()->hasLootRecipient())
|
||||
if (victim && victim->IsCreature() && !victim->ToCreature()->hasLootRecipient())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -6023,7 +6023,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
|
||||
// do not reward honor in arenas, but enable onkill spellproc
|
||||
if (InArena())
|
||||
{
|
||||
if (!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!uVictim || uVictim == this || !uVictim->IsPlayer())
|
||||
return false;
|
||||
|
||||
if (GetBgTeamId() == uVictim->ToPlayer()->GetBgTeamId())
|
||||
@@ -9256,7 +9256,7 @@ void Player::StopCastingCharm(Aura* except /*= nullptr*/)
|
||||
return;
|
||||
}
|
||||
|
||||
if (charm->GetTypeId() == TYPEID_UNIT)
|
||||
if (charm->IsCreature())
|
||||
{
|
||||
if (charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET))
|
||||
{
|
||||
@@ -9611,7 +9611,7 @@ void Player::CharmSpellInitialize()
|
||||
}
|
||||
|
||||
uint8 addlist = 0;
|
||||
if (charm->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!charm->IsPlayer())
|
||||
{
|
||||
//CreatureInfo const* cinfo = charm->ToCreature()->GetCreatureTemplate();
|
||||
//if (cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK)
|
||||
@@ -9627,7 +9627,7 @@ void Player::CharmSpellInitialize()
|
||||
data << uint16(0);
|
||||
data << uint32(0);
|
||||
|
||||
if (charm->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!charm->IsPlayer())
|
||||
data << uint8(charm->ToCreature()->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0);
|
||||
else
|
||||
data << uint32(0);
|
||||
@@ -12622,7 +12622,7 @@ bool Player::isHonorOrXPTarget(Unit* victim) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (victim->GetTypeId() == TYPEID_UNIT)
|
||||
if (victim->IsCreature())
|
||||
{
|
||||
if (victim->IsTotem() || victim->IsCritter() || victim->IsPet() || (victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP))
|
||||
{
|
||||
@@ -12684,7 +12684,7 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar
|
||||
if (!pRewardSource)
|
||||
return;
|
||||
|
||||
ObjectGuid creature_guid = (pRewardSource->GetTypeId() == TYPEID_UNIT) ? pRewardSource->GetGUID() : ObjectGuid::Empty;
|
||||
ObjectGuid creature_guid = (pRewardSource->IsCreature()) ? pRewardSource->GetGUID() : ObjectGuid::Empty;
|
||||
|
||||
// prepare data for near group iteration
|
||||
if (Group* group = GetGroup())
|
||||
@@ -12818,7 +12818,7 @@ void Player::SetClientControl(Unit* target, bool allowMove, bool packetOnly /*=
|
||||
SetMover(target);
|
||||
|
||||
// Xinef: disable moving if target has disable move flag
|
||||
if (target->GetTypeId() != TYPEID_UNIT)
|
||||
if (!target->IsCreature())
|
||||
return;
|
||||
|
||||
if (allowMove && target->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
|
||||
@@ -12855,12 +12855,12 @@ void Player::SetMover(Unit* target)
|
||||
LOG_INFO("misc", "Player::SetMover (B2) - {}, {}, {}, {}, {}, {}, {}, {}", target->GetGUID().ToString(), target->GetMapId(), target->GetInstanceId(), target->FindMap()->GetId(), target->IsInWorld() ? 1 : 0, target->IsDuringRemoveFromWorld() ? 1 : 0, (target->ToPlayer() && target->ToPlayer()->IsBeingTeleported() ? 1 : 0), target->isBeingLoaded() ? 1 : 0);
|
||||
}
|
||||
m_mover->m_movedByPlayer = nullptr;
|
||||
if (m_mover->GetTypeId() == TYPEID_UNIT)
|
||||
if (m_mover->IsCreature())
|
||||
m_mover->GetMotionMaster()->Initialize();
|
||||
|
||||
m_mover = target;
|
||||
m_mover->m_movedByPlayer = this;
|
||||
if (m_mover->GetTypeId() == TYPEID_UNIT)
|
||||
if (m_mover->IsCreature())
|
||||
m_mover->GetMotionMaster()->Initialize();
|
||||
}
|
||||
|
||||
@@ -13105,7 +13105,7 @@ void Player::StopCastingBindSight(Aura* except /*= nullptr*/)
|
||||
{
|
||||
if (WorldObject* target = GetViewpoint())
|
||||
{
|
||||
if (target->isType(TYPEMASK_UNIT))
|
||||
if (target->IsUnit())
|
||||
{
|
||||
((Unit*)target)->RemoveAurasByType(SPELL_AURA_BIND_SIGHT, GetGUID(), except);
|
||||
((Unit*)target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS, GetGUID(), except);
|
||||
@@ -13129,7 +13129,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
|
||||
// farsight dynobj or puppet may be very far away
|
||||
UpdateVisibilityOf(target);
|
||||
|
||||
if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
|
||||
if (target->IsUnit() && !GetVehicle())
|
||||
((Unit*)target)->AddPlayerToVision(this);
|
||||
SetSeer(target);
|
||||
}
|
||||
@@ -13146,7 +13146,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
|
||||
return;
|
||||
}
|
||||
|
||||
if (target->isType(TYPEMASK_UNIT) && !GetVehicle())
|
||||
if (target->IsUnit() && !GetVehicle())
|
||||
static_cast<Unit*>(target)->RemovePlayerFromVision(this);
|
||||
|
||||
// must immediately set seer back otherwise may crash
|
||||
|
||||
@@ -44,13 +44,13 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
|
||||
|
||||
uint32 npcflags = 0;
|
||||
|
||||
if (source->GetTypeId() == TYPEID_UNIT)
|
||||
if (source->IsCreature())
|
||||
{
|
||||
npcflags = source->ToUnit()->GetNpcFlags();
|
||||
if (showQuests && npcflags & UNIT_NPC_FLAG_QUESTGIVER)
|
||||
PrepareQuestMenu(source->GetGUID());
|
||||
}
|
||||
else if (source->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
else if (source->IsGameObject())
|
||||
if (showQuests && source->ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
|
||||
PrepareQuestMenu(source->GetGUID());
|
||||
|
||||
@@ -211,7 +211,7 @@ void Player::SendPreparedGossip(WorldObject* source)
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
if (source->GetTypeId() == TYPEID_UNIT)
|
||||
if (source->IsCreature())
|
||||
{
|
||||
// in case no gossip flag and quest menu not empty, open quest menu (client expect gossip menu with this flag)
|
||||
if (!source->ToCreature()->HasNpcFlag(UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty())
|
||||
@@ -220,7 +220,7 @@ void Player::SendPreparedGossip(WorldObject* source)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (source->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
else if (source->IsGameObject())
|
||||
{
|
||||
// probably need to find a better way here
|
||||
if (!PlayerTalkClass->GetGossipMenu().GetMenuId() && !PlayerTalkClass->GetQuestMenu().Empty())
|
||||
@@ -256,7 +256,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
|
||||
uint32 gossipOptionId = item->OptionType;
|
||||
ObjectGuid guid = source->GetGUID();
|
||||
|
||||
if (sWorld->getIntConfig(CONFIG_INSTANT_TAXI) == 2 && source->GetTypeId() == TYPEID_UNIT)
|
||||
if (sWorld->getIntConfig(CONFIG_INSTANT_TAXI) == 2 && source->IsCreature())
|
||||
{
|
||||
if (gossipOptionId == GOSSIP_ACTION_TOGGLE_INSTANT_FLIGHT && source->ToUnit()->GetNpcFlags() & UNIT_NPC_FLAG_FLIGHTMASTER)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
|
||||
}
|
||||
}
|
||||
|
||||
if (source->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||
if (source->IsGameObject())
|
||||
{
|
||||
if (gossipOptionId > GOSSIP_OPTION_QUESTGIVER)
|
||||
{
|
||||
|
||||
@@ -829,7 +829,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
|
||||
if (quest->GetRewSpellCast() > 0)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpellCast());
|
||||
if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast())
|
||||
if (questGiver->IsUnit() && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast())
|
||||
{
|
||||
if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID()))
|
||||
creature->CastSpell(this, quest->GetRewSpellCast(), true);
|
||||
@@ -840,7 +840,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
|
||||
else if (quest->GetRewSpell() > 0)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpell());
|
||||
if (questGiver->isType(TYPEMASK_UNIT) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast())
|
||||
if (questGiver->IsUnit() && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL) && !spellInfo->HasEffect(SPELL_EFFECT_CREATE_ITEM) && !spellInfo->IsSelfCast())
|
||||
{
|
||||
if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID()))
|
||||
creature->CastSpell(this, quest->GetRewSpell(), true);
|
||||
|
||||
@@ -939,7 +939,7 @@ void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType, Item* ite
|
||||
if (GetShapeshiftForm() == FORM_TREE)
|
||||
return; // use weapon but not skill up
|
||||
|
||||
if (victim->GetTypeId() == TYPEID_UNIT &&
|
||||
if (victim->IsCreature() &&
|
||||
(victim->ToCreature()->GetCreatureTemplate()->flags_extra &
|
||||
CREATURE_FLAG_EXTRA_NO_SKILL_GAINS))
|
||||
return;
|
||||
@@ -1670,7 +1670,7 @@ void Player::UpdateVisibilityOf(WorldObject* target)
|
||||
{
|
||||
if (!CanSeeOrDetect(target, false, true))
|
||||
{
|
||||
if (target->GetTypeId() == TYPEID_UNIT)
|
||||
if (target->IsCreature())
|
||||
BeforeVisibilityDestroy<Creature>(target->ToCreature(), this);
|
||||
|
||||
target->DestroyForPlayer(this);
|
||||
@@ -1687,7 +1687,7 @@ void Player::UpdateVisibilityOf(WorldObject* target)
|
||||
// target aura duration for caster show only if target exist at
|
||||
// caster client send data at target visibility change (adding to
|
||||
// client)
|
||||
if (target->isType(TYPEMASK_UNIT))
|
||||
if (target->IsUnit())
|
||||
GetInitialVisiblePackets((Unit*) target);
|
||||
}
|
||||
}
|
||||
@@ -1913,7 +1913,7 @@ void Player::UpdateCharmedAI()
|
||||
|
||||
// Xinef: we should be killed if caster enters evade mode and charm is
|
||||
// infinite
|
||||
if (charmer->GetTypeId() == TYPEID_UNIT &&
|
||||
if (charmer->IsCreature() &&
|
||||
charmer->ToCreature()->IsInEvadeMode())
|
||||
{
|
||||
AuraEffectList const& auras =
|
||||
|
||||
@@ -34,7 +34,7 @@ CharmInfo::CharmInfo(Unit* unit)
|
||||
for (uint8 i = 0; i < MAX_SPELL_CHARM; ++i)
|
||||
_charmspells[i].SetActionAndType(0, ACT_DISABLED);
|
||||
|
||||
if (_unit->GetTypeId() == TYPEID_UNIT)
|
||||
if (_unit->IsCreature())
|
||||
{
|
||||
_oldReactState = _unit->ToCreature()->GetReactState();
|
||||
_unit->ToCreature()->SetReactState(REACT_PASSIVE);
|
||||
@@ -76,7 +76,7 @@ void CharmInfo::InitEmptyActionBar(bool withAttack)
|
||||
|
||||
void CharmInfo::InitPossessCreateSpells()
|
||||
{
|
||||
if (_unit->GetTypeId() == TYPEID_UNIT)
|
||||
if (_unit->IsCreature())
|
||||
{
|
||||
// Adding switch until better way is found. Malcrom
|
||||
// Adding entrys to this switch will prevent COMMAND_ATTACK being added to pet bar.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -67,7 +67,7 @@ Vehicle::~Vehicle()
|
||||
|
||||
void Vehicle::Install()
|
||||
{
|
||||
if (_me->GetTypeId() == TYPEID_UNIT)
|
||||
if (_me->IsCreature())
|
||||
{
|
||||
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId))
|
||||
_me->setPowerType(Powers(powerDisplay->PowerType));
|
||||
@@ -76,7 +76,7 @@ void Vehicle::Install()
|
||||
}
|
||||
|
||||
_status = STATUS_INSTALLED;
|
||||
if (GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetBase()->IsCreature())
|
||||
sScriptMgr->OnInstall(this);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ void Vehicle::Uninstall()
|
||||
LOG_DEBUG("vehicles", "Vehicle::Uninstall {}", _me->GetGUID().ToString());
|
||||
RemoveAllPassengers();
|
||||
|
||||
if (_me && _me->GetTypeId() == TYPEID_UNIT)
|
||||
if (_me && _me->IsCreature())
|
||||
{
|
||||
sScriptMgr->OnUninstall(this);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ void Vehicle::Reset(bool evading /*= false*/)
|
||||
_me->SetNpcFlag(UNIT_NPC_FLAG_SPELLCLICK);
|
||||
}
|
||||
|
||||
if (GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetBase()->IsCreature())
|
||||
sScriptMgr->OnReset(this);
|
||||
}
|
||||
|
||||
@@ -274,8 +274,8 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
|
||||
// already installed
|
||||
if (passenger->GetEntry() == entry)
|
||||
{
|
||||
ASSERT(passenger->GetTypeId() == TYPEID_UNIT);
|
||||
if (_me->GetTypeId() == TYPEID_UNIT)
|
||||
ASSERT(passenger->IsCreature());
|
||||
if (_me->IsCreature())
|
||||
{
|
||||
if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled)
|
||||
passenger->ToCreature()->AI()->EnterEvadeMode();
|
||||
@@ -297,7 +297,7 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetBase()->IsCreature())
|
||||
sScriptMgr->OnInstallAccessory(this, accessory);
|
||||
}
|
||||
}
|
||||
@@ -382,7 +382,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
unit->m_movementInfo.transport.guid = _me->GetGUID();
|
||||
|
||||
// xinef: removed seat->first == 0 check...
|
||||
if (_me->GetTypeId() == TYPEID_UNIT
|
||||
if (_me->IsCreature()
|
||||
&& unit->IsPlayer()
|
||||
&& seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
|
||||
{
|
||||
@@ -424,14 +424,14 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
init.SetTransportEnter();
|
||||
init.Launch();
|
||||
|
||||
if (_me->GetTypeId() == TYPEID_UNIT)
|
||||
if (_me->IsCreature())
|
||||
{
|
||||
if (_me->ToCreature()->IsAIEnabled)
|
||||
_me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
if (GetBase()->IsCreature())
|
||||
sScriptMgr->OnAddPassenger(this, unit, seatId);
|
||||
|
||||
// Remove parachute on vehicle switch
|
||||
@@ -468,7 +468,7 @@ void Vehicle::RemovePassenger(Unit* unit)
|
||||
|
||||
seat->second.Passenger.Reset();
|
||||
|
||||
if (_me->GetTypeId() == TYPEID_UNIT && unit->IsPlayer() && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
|
||||
if (_me->IsCreature() && unit->IsPlayer() && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
|
||||
_me->RemoveCharmedBy(unit);
|
||||
|
||||
if (_me->IsInWorld())
|
||||
@@ -486,10 +486,10 @@ void Vehicle::RemovePassenger(Unit* unit)
|
||||
if (_me->IsFlying() && !_me->GetInstanceId() && unit->IsPlayer() && !(unit->ToPlayer()->GetDelayedOperations() & DELAYED_VEHICLE_TELEPORT) && _me->GetEntry() != 30275 /*NPC_WILD_WYRM*/)
|
||||
_me->CastSpell(unit, VEHICLE_SPELL_PARACHUTE, true);
|
||||
|
||||
if (_me->GetTypeId() == TYPEID_UNIT)
|
||||
if (_me->IsCreature())
|
||||
sScriptMgr->OnRemovePassenger(this, unit);
|
||||
|
||||
if (_me->GetTypeId() == TYPEID_UNIT && _me->ToCreature()->IsAIEnabled)
|
||||
if (_me->IsCreature() && _me->ToCreature()->IsAIEnabled)
|
||||
_me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, false);
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ void Vehicle::RelocatePassengers()
|
||||
|
||||
void Vehicle::Dismiss()
|
||||
{
|
||||
if (GetBase()->GetTypeId() != TYPEID_UNIT)
|
||||
if (!GetBase()->IsCreature())
|
||||
return;
|
||||
|
||||
LOG_DEBUG("vehicles", "Vehicle::Dismiss {}", _me->GetGUID().ToString());
|
||||
@@ -535,7 +535,7 @@ bool Vehicle::IsVehicleInUse()
|
||||
{
|
||||
if (passenger->IsPlayer())
|
||||
return true;
|
||||
else if (passenger->GetTypeId() == TYPEID_UNIT && passenger->GetVehicleKit() && passenger->GetVehicleKit()->IsVehicleInUse())
|
||||
else if (passenger->IsCreature() && passenger->GetVehicleKit() && passenger->GetVehicleKit()->IsVehicleInUse())
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ void Vehicle::TeleportVehicle(float x, float y, float z, float ang)
|
||||
passenger->NearTeleportTo(x, y, z, ang, false, true);
|
||||
passenger->ToPlayer()->ScheduleDelayedOperation(DELAYED_VEHICLE_TELEPORT);
|
||||
}
|
||||
else if (passenger->GetTypeId() == TYPEID_UNIT && passenger->GetVehicleKit())
|
||||
else if (passenger->IsCreature() && passenger->GetVehicleKit())
|
||||
passenger->GetVehicleKit()->TeleportVehicle(x, y, z, ang);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user