diff --git a/apps/codestyle/codestyle.py b/apps/codestyle/codestyle.py index ac5af08a533a5c..bad3aee1f66df1 100644 --- a/apps/codestyle/codestyle.py +++ b/apps/codestyle/codestyle.py @@ -108,14 +108,20 @@ def get_typeid_check(file: io, file_path: str) -> None: check_failed = False # Parse all the file for line_number, line in enumerate(file, start = 1): - if 'GetTypeId() == TYPEID_PLAYER' in line: - print(f"Please use IsPlayer() instead GetTypeId(): {file_path} at line {line_number}") + if 'GetTypeId() == TYPEID_ITEM' in line or 'GetTypeId() != TYPEID_ITEM' in line: + print(f"Please use IsItem() instead of GetTypeId(): {file_path} at line {line_number}") check_failed = True - if 'GetTypeId() == TYPEID_ITEM' in line: - print(f"Please use IsItem() instead GetTypeId(): {file_path} at line {line_number}") + if 'GetTypeId() == TYPEID_UNIT' in line or 'GetTypeId() != TYPEID_UNIT' in line: + print(f"Please use IsCreature() instead of GetTypeId(): {file_path} at line {line_number}") check_failed = True - if 'GetTypeId() == TYPEID_DYNOBJECT' in line: - print(f"Please use IsDynamicObject() instead GetTypeId(): {file_path} at line {line_number}") + if 'GetTypeId() == TYPEID_PLAYER' in line or 'GetTypeId() != TYPEID_PLAYER' in line: + print(f"Please use IsPlayer() instead of GetTypeId(): {file_path} at line {line_number}") + check_failed = True + if 'GetTypeId() == TYPEID_GAMEOBJECT' in line or 'GetTypeId() != TYPEID_GAMEOBJECT' in line: + print(f"Please use IsGameObject() instead of GetTypeId(): {file_path} at line {line_number}") + check_failed = True + if 'GetTypeId() == TYPEID_DYNOBJECT' in line or 'GetTypeId() != TYPEID_DYNOBJECT' in line: + print(f"Please use IsDynamicObject() instead of GetTypeId(): {file_path} at line {line_number}") check_failed = True # Handle the script error and update the result output if check_failed: diff --git a/src/server/game/AI/CoreAI/PassiveAI.cpp b/src/server/game/AI/CoreAI/PassiveAI.cpp index 796231e410e3a3..a34ce30d8179ab 100644 --- a/src/server/game/AI/CoreAI/PassiveAI.cpp +++ b/src/server/game/AI/CoreAI/PassiveAI.cpp @@ -65,7 +65,7 @@ void PossessedAI::JustDied(Unit* /*u*/) void PossessedAI::KilledUnit(Unit* /*victim*/) { // We killed a creature, disable victim's loot - //if (victim->GetTypeId() == TYPEID_UNIT) + //if (victim->IsCreature()) // victim->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE); } diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 6d1892b0f9a26b..3803e815aa9b69 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -613,7 +613,7 @@ void PetAI::DoAttack(Unit* target, bool chase) if (_canMeleeAttack()) { - float angle = combatRange == 0.f && target->GetTypeId() != TYPEID_PLAYER && !target->IsPet() ? float(M_PI) : 0.f; + float angle = combatRange == 0.f && !target->IsPlayer() && !target->IsPet() ? float(M_PI) : 0.f; float tolerance = combatRange == 0.f ? float(M_PI_4) : float(M_PI * 2); me->GetMotionMaster()->MoveChase(target, ChaseRange(0.f, combatRange), ChaseAngle(angle, tolerance)); } diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 5240c88e56a2d9..710f4a453a60f7 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -427,7 +427,7 @@ bool NonTankTargetSelector::operator()(Unit const* target) const if (!target) return false; - if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) + if (_playerOnly && !target->IsPlayer()) return false; if (Unit* currentVictim = _source->GetThreatMgr().GetCurrentVictim()) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 0f7c501638aa50..aefb6a673dbb8b 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -76,7 +76,7 @@ struct DefaultTargetSelector : public Acore::unary_function if (target == except) return false; - if (m_playerOnly && (target->GetTypeId() != TYPEID_PLAYER)) + if (m_playerOnly && (!target->IsPlayer())) return false; if (m_dist > 0.0f && !me->IsWithinCombatRange(target, m_dist)) @@ -148,7 +148,7 @@ struct PowerUsersSelector : public Acore::unary_function if (target->getPowerType() != _power) return false; - if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) + if (_playerOnly && !target->IsPlayer()) return false; if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist)) @@ -170,7 +170,7 @@ struct FarthestTargetSelector : public Acore::unary_function if (!_me || !target) return false; - if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) + if (_playerOnly && !target->IsPlayer()) return false; if (_maxDist > 0.0f && !_me->IsInRange(target, _minDist, _maxDist)) diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 1f97131cb161b3..52c1da79d78c1d 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -107,7 +107,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange Map* map = creature->GetMap(); if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated { - LOG_ERROR("entities.unit.ai", "DoZoneInCombat call for map {} that isn't a dungeon (creature entry = {})", map->GetId(), creature->GetTypeId() == TYPEID_UNIT ? creature->ToCreature()->GetEntry() : 0); + LOG_ERROR("entities.unit.ai", "DoZoneInCombat call for map {} that isn't a dungeon (creature entry = {})", map->GetId(), creature->IsCreature() ? creature->ToCreature()->GetEntry() : 0); return; } @@ -175,10 +175,10 @@ void CreatureAI::MoveInLineOfSight(Unit* who) void CreatureAI::TriggerAlert(Unit const* who) const { // If there's no target, or target isn't a player do nothing - if (!who || who->GetTypeId() != TYPEID_PLAYER) + if (!who || !who->IsPlayer()) return; // If this unit isn't an NPC, is already distracted, is in combat, is confused, stunned or fleeing, do nothing - if (me->GetTypeId() != TYPEID_UNIT || me->IsEngaged() || me->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING | UNIT_STATE_DISTRACTED)) + if (!me->IsCreature() || me->IsEngaged() || me->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING | UNIT_STATE_DISTRACTED)) return; // Only alert for hostiles! if (me->IsCivilian() || me->HasReactState(REACT_PASSIVE) || !me->IsHostileTo(who) || !me->_IsTargetAcceptable(who)) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index b252923bab4498..69830d815fa3ff 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -178,7 +178,7 @@ class PlayerOrPetCheck public: bool operator() (WorldObject* unit) const { - if (unit->GetTypeId() != TYPEID_PLAYER) + if (!unit->IsPlayer()) if (!unit->ToUnit()->GetOwnerGUID().IsPlayer()) return true; diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 0319ed5c724ca9..c6aa04a393b6b2 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -111,7 +111,7 @@ bool npc_escortAI::AssistPlayerInCombatAgainst(Unit* who) } // or if enemy is in evade mode - if (who->GetTypeId() == TYPEID_UNIT && who->ToCreature()->IsInEvadeMode()) + if (who->IsCreature() && who->ToCreature()->IsInEvadeMode()) { return false; } diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 01bab2e9d84e64..97e6ea16453ca2 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -4217,7 +4217,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui { if (!me || !unit) return; - if (e.event.kill.playerOnly && unit->GetTypeId() != TYPEID_PLAYER) + if (e.event.kill.playerOnly && !unit->IsPlayer()) return; if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature) return; @@ -4254,7 +4254,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) || (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit))) { - if (e.event.los.playerOnly && unit->GetTypeId() != TYPEID_PLAYER) + if (e.event.los.playerOnly && !unit->IsPlayer()) return; RecalcTimer(e, e.event.los.cooldownMin, e.event.los.cooldownMax); ProcessAction(e, unit); @@ -4278,7 +4278,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui (hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) || (hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit))) { - if (e.event.los.playerOnly && unit->GetTypeId() != TYPEID_PLAYER) + if (e.event.los.playerOnly && !unit->IsPlayer()) return; RecalcTimer(e, e.event.los.cooldownMin, e.event.los.cooldownMax); ProcessAction(e, unit); @@ -5269,7 +5269,7 @@ WorldObject* SmartScript::GetLastInvoker(WorldObject* invoker) const bool SmartScript::IsUnit(WorldObject* obj) { - return obj && (obj->GetTypeId() == TYPEID_UNIT || obj->IsPlayer()); + return obj && (obj->IsCreature() || obj->IsPlayer()); } bool SmartScript::IsPlayer(WorldObject* obj) @@ -5279,7 +5279,7 @@ bool SmartScript::IsPlayer(WorldObject* obj) bool SmartScript::IsCreature(WorldObject* obj) { - return obj && obj->GetTypeId() == TYPEID_UNIT; + return obj && obj->IsCreature(); } bool SmartScript::IsCharmedCreature(WorldObject* obj) @@ -5295,7 +5295,7 @@ bool SmartScript::IsCharmedCreature(WorldObject* obj) bool SmartScript::IsGameObject(WorldObject* obj) { - return obj && obj->GetTypeId() == TYPEID_GAMEOBJECT; + return obj && obj->IsGameObject(); } void SmartScript::IncPhase(uint32 p) diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 52c2ae11f38514..9d3626e3d6c49c 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -304,11 +304,11 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un case ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE: return true; case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE: - if (!target || target->GetTypeId() != TYPEID_UNIT) + if (!target || !target->IsCreature()) return false; return target->GetEntry() == creature.id; case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE: - if (!target || target->GetTypeId() != TYPEID_PLAYER) + if (!target || !target->IsPlayer()) return false; if (classRace.class_id && classRace.class_id != target->ToPlayer()->getClass()) return false; @@ -316,7 +316,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un return false; return true; case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE: - if (!source || source->GetTypeId() != TYPEID_PLAYER) + if (!source || !source->IsPlayer()) return false; if (classRace.class_id && classRace.class_id != source->ToPlayer()->getClass()) return false; @@ -324,7 +324,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un return false; return true; case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH: - if (!target || target->GetTypeId() != TYPEID_PLAYER) + if (!target || !target->IsPlayer()) return false; return !target->HealthAbovePct(health.percent); case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD: @@ -371,7 +371,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount; case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM: { - if (!target || target->GetTypeId() != TYPEID_PLAYER) + if (!target || !target->IsPlayer()) return false; // DB data compatibility... @@ -1501,7 +1501,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // map specific case (BG in fact) expected player targeted damage/heal - if (!unit || unit->GetTypeId() != TYPEID_PLAYER) + if (!unit || !unit->IsPlayer()) continue; } diff --git a/src/server/game/Combat/ThreatMgr.cpp b/src/server/game/Combat/ThreatMgr.cpp index 92ca0c04994ff6..185ad3f9d0de87 100644 --- a/src/server/game/Combat/ThreatMgr.cpp +++ b/src/server/game/Combat/ThreatMgr.cpp @@ -81,7 +81,7 @@ bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellIn if (threatSpell && threatSpell->HasAttribute(SPELL_ATTR1_NO_THREAT)) return false; - ASSERT(hatingUnit->GetTypeId() == TYPEID_UNIT); + ASSERT(hatingUnit->IsCreature()); return true; } @@ -190,7 +190,7 @@ void HostileReference::updateOnlineStatus() // target is no player or not gamemaster // target is not in flight if (isValid() - && (getTarget()->GetTypeId() != TYPEID_PLAYER || !getTarget()->ToPlayer()->IsGameMaster()) + && (!getTarget()->IsPlayer() || !getTarget()->ToPlayer()->IsGameMaster()) && !getTarget()->IsInFlight() && getTarget()->IsInMap(GetSourceUnit()) && getTarget()->InSamePhase(GetSourceUnit()) diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index 5385612ff7fc26..0ebcefceef005d 100644 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -326,7 +326,7 @@ namespace DisableMgr if (unit) { if ((spellFlags & SPELL_DISABLE_PLAYER && unit->IsPlayer()) || - (unit->GetTypeId() == TYPEID_UNIT && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE))) + (unit->IsCreature() && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE))) { if (spellFlags & SPELL_DISABLE_MAP) { diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 29086a8dcb72a8..33a29453199969 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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 diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index b080b772e9656c..86ea77673995d6 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -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); } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 4fd9a5cd3e6611..5cf90d71a97ea3 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -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); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index d494cd8da8d941..371a776aaa9461 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -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(this)->GetHoverHeight() : 0.0f); + z = new_z + (IsUnit() ? static_cast(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* 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 const* data = sObjectMgr->GetSummonGroup(GetEntry(), GetTypeId() == TYPEID_GAMEOBJECT ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group); + std::vector 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(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false, + IsUnit() ? !static_cast(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false, std::max(GetCollisionHeight(), Z_OFFSET_FIND_HEIGHT)); } diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 6b439663c49a08..d9d168ed478ae1 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -198,11 +198,13 @@ class Object Player* ToPlayer() { if (IsPlayer()) return reinterpret_cast(this); else return nullptr; } [[nodiscard]] Player const* ToPlayer() const { if (IsPlayer()) return reinterpret_cast(this); else return nullptr; } - Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast(this); else return nullptr; } - [[nodiscard]] Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast(this); else return nullptr; } + [[nodiscard]] inline bool IsCreature() const { return GetTypeId() == TYPEID_UNIT; } + Creature* ToCreature() { if (IsCreature()) return reinterpret_cast(this); else return nullptr; } + [[nodiscard]] Creature const* ToCreature() const { if (IsCreature()) return reinterpret_cast(this); else return nullptr; } - Unit* ToUnit() { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast(this); else return nullptr; } - [[nodiscard]] Unit const* ToUnit() const { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast(this); else return nullptr; } + [[nodiscard]] inline bool IsUnit() const { return isType(TYPEMASK_UNIT); } + Unit* ToUnit() { if (IsCreature() || IsPlayer()) return reinterpret_cast(this); else return nullptr; } + [[nodiscard]] Unit const* ToUnit() const { if (IsCreature() || IsPlayer()) return reinterpret_cast(this); else return nullptr; } [[nodiscard]] inline bool IsGameObject() const { return GetTypeId() == TYPEID_GAMEOBJECT; } GameObject* ToGameObject() { if (IsGameObject()) return reinterpret_cast(this); else return nullptr; } diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index eb69c7d120bf85..a8d99fe80e1cf5 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -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; } } diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index f3228f3cd559a3..c3fa426a5c04e0 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -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()) diff --git a/src/server/game/Entities/Player/KillRewarder.cpp b/src/server/game/Entities/Player/KillRewarder.cpp index 680aaa43ef170d..1ce4308aaeb022 100644 --- a/src/server/game/Entities/Player/KillRewarder.cpp +++ b/src/server/game/Entities/Player/KillRewarder.cpp @@ -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); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 97593309f23d64..068eaa8d26ddd9 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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(target)->RemovePlayerFromVision(this); // must immediately set seer back otherwise may crash diff --git a/src/server/game/Entities/Player/PlayerGossip.cpp b/src/server/game/Entities/Player/PlayerGossip.cpp index 1029ae4786659d..609d9776dd80f0 100644 --- a/src/server/game/Entities/Player/PlayerGossip.cpp +++ b/src/server/game/Entities/Player/PlayerGossip.cpp @@ -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) { diff --git a/src/server/game/Entities/Player/PlayerQuest.cpp b/src/server/game/Entities/Player/PlayerQuest.cpp index 44e46fc741e44c..2a95b3e2777ec9 100644 --- a/src/server/game/Entities/Player/PlayerQuest.cpp +++ b/src/server/game/Entities/Player/PlayerQuest.cpp @@ -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); diff --git a/src/server/game/Entities/Player/PlayerUpdates.cpp b/src/server/game/Entities/Player/PlayerUpdates.cpp index 59079f311aac48..e74493499ab589 100644 --- a/src/server/game/Entities/Player/PlayerUpdates.cpp +++ b/src/server/game/Entities/Player/PlayerUpdates.cpp @@ -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(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 = diff --git a/src/server/game/Entities/Unit/CharmInfo.cpp b/src/server/game/Entities/Unit/CharmInfo.cpp index d315f01a207e47..c278bd3663c6af 100644 --- a/src/server/game/Entities/Unit/CharmInfo.cpp +++ b/src/server/game/Entities/Unit/CharmInfo.cpp @@ -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. diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 5d0fd1a0c8c4e6..5adb8a875b2eca 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -393,7 +393,7 @@ void Unit::Update(uint32 p_time) return; // pussywizard: - if (GetTypeId() != TYPEID_PLAYER || (!ToPlayer()->IsBeingTeleported() && !bRequestForcedVisibilityUpdate)) + if (!IsPlayer() || (!ToPlayer()->IsBeingTeleported() && !bRequestForcedVisibilityUpdate)) { if (m_delayed_unit_relocation_timer) { @@ -560,7 +560,7 @@ class SplineHandler bool operator()(Movement::MoveSpline::UpdateResult result) { if ((result & (Movement::MoveSpline::Result_NextSegment | Movement::MoveSpline::Result_JustArrived)) && - _unit->GetTypeId() == TYPEID_UNIT && _unit->GetMotionMaster()->GetCurrentMovementGeneratorType() == ESCORT_MOTION_TYPE && + _unit->IsCreature() && _unit->GetMotionMaster()->GetCurrentMovementGeneratorType() == ESCORT_MOTION_TYPE && _unit->movespline->GetId() == _unit->GetMotionMaster()->GetCurrentSplineId()) { _unit->ToCreature()->AI()->MovementInform(ESCORT_MOTION_TYPE, _unit->movespline->currentPathIdx() - 1); @@ -595,7 +595,7 @@ void Unit::UpdateSplineMovement(uint32 t_diff) { DisableSpline(); - if (movespline->HasAnimation() && GetTypeId() == TYPEID_UNIT && IsAlive()) + if (movespline->HasAnimation() && IsCreature() && IsAlive()) SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, movespline->GetAnimationType()); } @@ -786,7 +786,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons void Unit::DealDamageMods(Unit const* victim, uint32& damage, uint32* absorb) { - if (!victim || !victim->IsAlive() || victim->IsInFlight() || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) + if (!victim || !victim->IsAlive() || victim->IsInFlight() || (victim->IsCreature() && victim->ToCreature()->IsEvadingAttacks())) { if (absorb) *absorb += damage; @@ -831,7 +831,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage } // Signal the pet it was attacked so the AI can respond if needed - if (victim->GetTypeId() == TYPEID_UNIT && attacker != victim && victim->IsPet() && victim->IsAlive()) + if (victim->IsCreature() && attacker != victim && victim->IsPet() && victim->IsAlive()) victim->ToPet()->AI()->AttackedBy(attacker); if (damagetype != NODAMAGE) @@ -1039,7 +1039,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage if (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE) victim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE, spellProto ? spellProto->Id : 0); - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) { // Part of Evade mechanics. DoT's and Thorns / Retribution Aura do not contribute to this if (damagetype != DOT && damage > 0 && !victim->GetOwnerGUID().IsPlayer() && (!spellProto || !spellProto->HasAura(SPELL_AURA_DAMAGE_SHIELD))) @@ -1432,7 +1432,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss, if (!victim) return; - if (!victim->IsAlive() || victim->IsInFlight() || (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks())) + if (!victim->IsAlive() || victim->IsInFlight() || (victim->IsCreature() && victim->ToCreature()->IsEvadingAttacks())) return; SpellInfo const* spellProto = damageInfo->spellInfo; @@ -1525,7 +1525,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, CalcDamageInfo* damageInfo, Weapon for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) { // only players have secondary weapon damage - if (i > 0 && GetTypeId() != TYPEID_PLAYER) + if (i > 0 && !IsPlayer()) { break; } @@ -1819,7 +1819,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) auto canTakeMeleeDamage = [&]() { - return victim->IsAlive() && !victim->HasUnitState(UNIT_STATE_IN_FLIGHT) && (victim->GetTypeId() != TYPEID_UNIT || !victim->ToCreature()->IsEvadingAttacks()); + return victim->IsAlive() && !victim->HasUnitState(UNIT_STATE_IN_FLIGHT) && (!victim->IsCreature() || !victim->ToCreature()->IsEvadingAttacks()); }; if (!canTakeMeleeDamage()) @@ -1879,7 +1879,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) // If this is a creature and it attacks from behind it has a probability to daze it's victim if ((damageInfo->damages[0].damage + damageInfo->damages[1].damage) && ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && - GetTypeId() != TYPEID_PLAYER && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(M_PI, this) + !IsPlayer() && !ToCreature()->IsControlledByPlayer() && !victim->HasInArc(M_PI, this) && (victim->IsPlayer() || !victim->ToCreature()->isWorldBoss()) && !victim->IsVehicle())) { // -probability is between 0% and 40% @@ -2125,7 +2125,7 @@ void Unit::CalcAbsorbResist(DamageInfo& dmgInfo, bool Splited) // Magic damage, check for resists // Ignore spells that cant be resisted // Xinef: holy resistance exists for npcs - if (!(schoolMask & SPELL_SCHOOL_MASK_NORMAL) && (!(schoolMask & SPELL_SCHOOL_MASK_HOLY) || victim->GetTypeId() == TYPEID_UNIT) && (!spellInfo || (!spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL) && !spellInfo->HasAttribute(SPELL_ATTR4_NO_CAST_LOG)))) + if (!(schoolMask & SPELL_SCHOOL_MASK_NORMAL) && (!(schoolMask & SPELL_SCHOOL_MASK_HOLY) || victim->IsCreature()) && (!spellInfo || (!spellInfo->HasAttribute(SPELL_ATTR0_CU_BINARY_SPELL) && !spellInfo->HasAttribute(SPELL_ATTR4_NO_CAST_LOG)))) { float averageResist = Unit::GetEffectiveResistChance(attacker, schoolMask, victim); @@ -2626,7 +2626,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType /*= BASE_A if (IsPlayer() && !m_Controlled.empty()) for (Unit::ControlSet::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) if (Unit* pet = *itr) - if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT) + if (pet->IsAlive() && pet->IsCreature()) pet->ToCreature()->AI()->OwnerAttacked(victim); } } @@ -2770,7 +2770,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const { - if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks()) + if (victim->IsCreature() && victim->ToCreature()->IsEvadingAttacks()) { return MELEE_HIT_EVADE; } @@ -2888,7 +2888,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy // Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon) if (attType != RANGED_ATTACK && (IsPlayer() || IsPet()) && - victim->GetTypeId() != TYPEID_PLAYER && !victim->IsPet() && + !victim->IsPlayer() && !victim->IsPet() && GetLevel() < victim->getLevelForTarget(this)) { // cap possible value (with bonuses > max skill) @@ -2909,7 +2909,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy if (getLevelForTarget(victim) >= victim->getLevelForTarget(this) + 4 && // can be from by creature (if can) or from controlled player that considered as creature !IsControlledByPlayer() && - !(GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSHING_BLOWS)) + !(IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSHING_BLOWS)) { // when their weapon skill is 15 or more above victim's defense skill tmp = victimDefenseSkill; @@ -2936,7 +2936,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy if (tmp > 0 && roll < (sum += tmp)) { LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT <{}, {})", sum - tmp, sum); - if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) + if (IsCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) { LOG_DEBUG("entities.unit", "RollMeleeOutcomeAgainst: CRIT DISABLED)"); } @@ -3006,7 +3006,7 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add float Unit::CalculateLevelPenalty(SpellInfo const* spellProto) const { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return 1.0f; if (spellProto->SpellLevel <= 0 || spellProto->SpellLevel >= spellProto->MaxLevel) @@ -3073,7 +3073,7 @@ bool Unit::isSpellBlocked(Unit* victim, SpellInfo const* spellProto, WeaponAttac if (victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION) || victim->HasInArc(M_PI, this)) { // Check creatures flags_extra for disable block - if (victim->GetTypeId() == TYPEID_UNIT && + if (victim->IsCreature() && victim->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) return false; @@ -3199,7 +3199,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo } // Check creatures flags_extra for disable parry - if (victim->GetTypeId() == TYPEID_UNIT) + if (victim->IsCreature()) { uint32 flagEx = victim->ToCreature()->GetCreatureTemplate()->flags_extra; // Xinef: no dodge flag @@ -3294,7 +3294,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo) { // Can`t miss on dead target (on skinning for example) - if (!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsAlive() && !victim->IsPlayer()) return SPELL_MISS_NONE; // vehicles cant miss @@ -3314,12 +3314,12 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo SpellSchoolMask schoolMask = spellInfo->GetSchoolMask(); int32 thisLevel = getLevelForTarget(victim); - if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTrigger()) + if (IsCreature() && ToCreature()->IsTrigger()) thisLevel = std::max(thisLevel, spellInfo->SpellLevel); int32 levelDiff = int32(victim->getLevelForTarget(this)) - thisLevel; int32 MISS_CHANCE_MULTIPLIER; - if (sWorld->getBoolConfig(CONFIG_MISS_CHANCE_MULTIPLIER_ONLY_FOR_PLAYERS) && GetTypeId() != TYPEID_PLAYER) // keep it as it was originally (7 and 11) + if (sWorld->getBoolConfig(CONFIG_MISS_CHANCE_MULTIPLIER_ONLY_FOR_PLAYERS) && !IsPlayer()) // keep it as it was originally (7 and 11) { MISS_CHANCE_MULTIPLIER = victim->IsPlayer() ? 7 : 11; } @@ -3455,7 +3455,7 @@ SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spell, bool Ca return SPELL_MISS_NONE; // Return evade for units in evade mode - if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks() && !spell->HasAura(SPELL_AURA_CONTROL_VEHICLE) + if (victim->IsCreature() && victim->ToCreature()->IsEvadingAttacks() && !spell->HasAura(SPELL_AURA_CONTROL_VEHICLE) && !spell->HasAttribute(SPELL_ATTR0_CU_IGNORE_EVADE) && !spell->HasAttribute(SPELL_ATTR1_AURA_STAYS_AFTER_COMBAT)) return SPELL_MISS_EVADE; @@ -3530,7 +3530,7 @@ SpellMissInfo Unit::SpellHitResult(Unit* victim, Spell const* spell, bool CanRef } // Return evade for units in evade mode - if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsEvadingAttacks() && !spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE) && + if (victim->IsCreature() && victim->ToCreature()->IsEvadingAttacks() && !spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE) && !spellInfo->HasAttribute(SPELL_ATTR0_CU_IGNORE_EVADE) && !spellInfo->HasAttribute(SPELL_ATTR1_AURA_STAYS_AFTER_COMBAT)) { return SPELL_MISS_EVADE; @@ -3637,7 +3637,7 @@ float Unit::GetUnitParryChance() const chance = player->GetRealParry(); //GetFloatValue(PLAYER_PARRY_PERCENTAGE); } } - else if (GetTypeId() == TYPEID_UNIT) + else if (IsCreature()) { if (ToCreature()->isWorldBoss()) chance = 13.4f; // + 0.6 by skill diff @@ -4224,7 +4224,7 @@ void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data) void Unit::ProcessTerrainStatusUpdate() { - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) ToCreature()->UpdateMovementFlags(); if (IsFlying() || (!IsControlledByPlayer())) @@ -4430,7 +4430,7 @@ AuraApplication* Unit::_CreateAuraApplication(Aura* aura, uint8 effMask) // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) // Xinef: Added IsAllowingDeadTarget check - if (!IsAlive() && !aurSpellInfo->IsDeathPersistent() && !aurSpellInfo->IsAllowingDeadTarget() && (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->GetSession()->PlayerLoading())) + if (!IsAlive() && !aurSpellInfo->IsDeathPersistent() && !aurSpellInfo->IsAllowingDeadTarget() && (!IsPlayer() || !ToPlayer()->GetSession()->PlayerLoading())) return nullptr; Unit* caster = aura->GetCaster(); @@ -6232,11 +6232,11 @@ void Unit::RemoveAllGameObjects() void Unit::SendSpellNonMeleeReflectLog(SpellNonMeleeDamage* log, Unit* attacker) { // Xinef: function for players only, placed in unit because of cosmetics - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return; WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16 + 4 + 4 + 4 + 1 + 4 + 4 + 1 + 1 + 4 + 4 + 1)); // we guess size - //IF we are in cheat mode we swap absorb with damage and set damage to 0, this way we can still debug damage but our hp bar will not drop + // If we are in cheat mode we swap absorb with damage and set damage to 0, this way we can still debug damage but our HP bar will not drop uint32 damage = log->damage; uint32 absorb = log->absorb; if (log->target->IsPlayer() && log->target->ToPlayer()->GetCommandStatus(CHEAT_GOD)) @@ -6624,7 +6624,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // 41409 Dementia: Every 5 seconds either gives you -5% damage/healing. (Druid, Shaman, Priest, Warlock, Mage, Paladin) case 39446: { - if (GetTypeId() != TYPEID_PLAYER || !IsAlive()) + if (!IsPlayer() || !IsAlive()) return false; // Select class defined buff @@ -6709,7 +6709,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // cast 45428 Arcane Strike if Exalted by Scryers case 45482: { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; // Get Aldor reputation rank @@ -6732,7 +6732,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // cast 45432 Light's Ward if Exalted by Scryers case 45483: { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; // Get Aldor reputation rank @@ -6756,7 +6756,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // cast 45430 Arcane Surge if Exalted by Scryers case 45484: { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; // Get Aldor reputation rank @@ -6815,7 +6815,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere } case 71519: // Deathbringer's Will Normal { - if (GetTypeId() != TYPEID_PLAYER || HasSpellCooldown(71484)) + if (!IsPlayer() || HasSpellCooldown(71484)) return false; AddSpellCooldown(71484, 0, cooldown); @@ -6858,7 +6858,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere } case 71562: // Deathbringer's Will Heroic { - if (GetTypeId() != TYPEID_PLAYER || HasSpellCooldown(71561)) + if (!IsPlayer() || HasSpellCooldown(71561)) return false; AddSpellCooldown(71561, 0, cooldown); @@ -7044,7 +7044,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Incanter's Regalia set (add trigger chance to Mana Shield) if (dummySpell->SpellFamilyFlags[0] & 0x8000) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; target = this; @@ -7384,7 +7384,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere { if (procSpell->SpellVisual[0] == 750 && procSpell->Effects[1].ApplyAuraName == 3) { - if (target && target->GetTypeId() == TYPEID_UNIT) + if (target && target->IsCreature()) { triggered_spell_id = 54820; break; @@ -8225,7 +8225,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Flametongue Weapon (Passive) if (dummySpell->SpellFamilyFlags[0] & 0x200000) { - if (GetTypeId() != TYPEID_PLAYER || !victim || !victim->IsAlive() || !castItem || !castItem->IsEquipped()) + if (!IsPlayer() || !victim || !victim->IsAlive() || !castItem || !castItem->IsEquipped()) return false; WeaponAttackType attType = WeaponAttackType(Player::GetAttackBySlot(castItem->GetSlot())); @@ -8300,7 +8300,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Lightning Overload if (dummySpell->SpellIconID == 2018) // only this spell have SpellFamily Shaman SpellIconID == 2018 and dummy aura { - if(!procSpell || GetTypeId() != TYPEID_PLAYER || !victim) + if(!procSpell || !IsPlayer() || !victim) return false; if (procEx & PROC_EX_CRITICAL_HIT) @@ -8356,7 +8356,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere // Improved Blood Presence if (dummySpell->SpellIconID == 2636) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; basepoints0 = CalculatePct(int32(damage), triggerAmount); break; @@ -9145,7 +9145,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg // Item - Hunter T9 4P Bonus (Steady Shot) else if (auraSpellInfo->Id == 67151) { - if (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->GetPet()) + if (!IsPlayer() || !ToPlayer()->GetPet()) return false; target = ToPlayer()->GetPet(); @@ -9185,7 +9185,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg case 67712: // Item - Coliseum 25 Normal Caster Trinket case 67758: // Item - Coliseum 25 Heroic Caster Trinket { - if (!victim || !victim->IsAlive() || GetTypeId() != TYPEID_PLAYER) + if (!victim || !victim->IsAlive() || !IsPlayer()) return false; uint32 stack_spell_id = 0; @@ -9353,7 +9353,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg // Blood Presence (Improved) else if (auraSpellInfo->Id == 63611) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; trigger_spell_id = 50475; @@ -9401,7 +9401,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg case 12849: case 12867: { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; if (procFlags & PROC_FLAG_DONE_OFFHAND_ATTACK) @@ -9479,7 +9479,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg break; // Ulduar, Hodir, Toasty Fire case 62821: - if (this->GetTypeId() != TYPEID_PLAYER) // spell has Attribute, but persistent area auras ignore it + if (!this->IsPlayer()) // spell has Attribute, but persistent area auras ignore it return false; break; case 15337: // Improved Spirit Tap (Rank 1) @@ -9521,7 +9521,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg // Item - Death Knight T10 Melee 4P Bonus if (auraSpellInfo->Id == 70656) { - if (GetTypeId() != TYPEID_PLAYER || !IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) + if (!IsPlayer() || !IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) return false; for (uint8 i = 0; i < MAX_RUNES; ++i) @@ -9541,7 +9541,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg // Rime else if (auraSpellInfo->SpellIconID == 56) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return false; // Howling Blast @@ -10001,7 +10001,7 @@ FactionTemplateEntry const* Unit::GetFactionTemplateEntry() const void Unit::SetFaction(uint32 faction) { SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, faction); - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) ToCreature()->UpdateMoveInLineOfSightState(); } @@ -10309,7 +10309,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) AddUnitState(UNIT_STATE_MELEE_ATTACKING); // set position before any AI calls/assistance - //if (GetTypeId() == TYPEID_UNIT) + //if (IsCreature()) // ToCreature()->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); if (creature && !(IsControllableGuardian() && IsControlledByPlayer())) { @@ -10390,7 +10390,7 @@ void Unit::CombatStop(bool includingCast) ClearInCombat(); // xinef: just in case - if (IsPetInCombat() && GetTypeId() != TYPEID_PLAYER) + if (IsPetInCombat() && !IsPlayer()) ClearInPetCombat(); } @@ -10763,7 +10763,7 @@ void Unit::SetMinion(Minion* minion, bool apply) (*itr)->OutDebugInfo(); ABORT(); } - ASSERT((*itr)->GetTypeId() == TYPEID_UNIT); + ASSERT((*itr)->IsCreature()); if (!(*itr)->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) continue; @@ -10792,7 +10792,7 @@ void Unit::GetAllMinionsByEntry(std::list& Minions, uint32 entry) { Unit* unit = *itr; ++itr; - if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT + if (unit->GetEntry() == entry && unit->IsCreature() && unit->ToCreature()->IsSummon()) // minion, actually Minions.push_back(unit->ToCreature()); } @@ -10804,7 +10804,7 @@ void Unit::RemoveAllMinionsByEntry(uint32 entry) { Unit* unit = *itr; ++itr; - if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT + if (unit->GetEntry() == entry && unit->IsCreature() && unit->ToCreature()->IsSummon()) // minion, actually unit->ToTempSummon()->UnSummon(); // i think this is safe because i have never heard that a despawned minion will trigger a same minion @@ -10907,7 +10907,7 @@ int32 Unit::DealHeal(Unit* healer, Unit* victim, uint32 addhealth) Unit* unit = healer; - if (healer && healer->GetTypeId() == TYPEID_UNIT && healer->ToCreature()->IsTotem()) + if (healer && healer->IsCreature() && healer->ToCreature()->IsTotem()) unit = healer->GetOwner(); if (!unit) @@ -11055,7 +11055,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) if (IsPlayer()) player = ToPlayer(); // Should we enable this also for charmed units? - else if (GetTypeId() == TYPEID_UNIT && IsPet()) + else if (IsCreature() && IsPet()) player = GetOwner()->ToPlayer(); if (!player) @@ -11229,7 +11229,7 @@ float Unit::SpellPctDamageModsDone(Unit* victim, SpellInfo const* spellProto, Da return 1.0f; // For totems get damage bonus from owner - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) { if (IsTotem()) { @@ -11560,7 +11560,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin return pdamage; // For totems get damage bonus from owner - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) { if (IsTotem()) { @@ -11581,7 +11581,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin float DoneTotalMod = TotalMod ? TotalMod : SpellPctDamageModsDone(victim, spellProto, damagetype); // Config : RATE_CREATURE_X_SPELLDAMAGE & Do Not Modify Pet/Guardian/Mind Controled Damage - if (GetTypeId() == TYPEID_UNIT && (!ToCreature()->IsPet() || !ToCreature()->IsGuardian() || !ToCreature()->IsControlledByPlayer())) + if (IsCreature() && (!ToCreature()->IsPet() || !ToCreature()->IsGuardian() || !ToCreature()->IsControlledByPlayer())) DoneTotalMod *= ToCreature()->GetSpellDamageMod(ToCreature()->GetCreatureTemplate()->rank); // Some spells don't benefit from pct done mods @@ -11932,7 +11932,7 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask, bool isDoT) float Unit::SpellDoneCritChance(Unit const* /*victim*/, SpellInfo const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType, bool skipEffectCheck) const { // Mobs can't crit with spells. - if (GetTypeId() == TYPEID_UNIT && !GetSpellModOwner()) + if (IsCreature() && !GetSpellModOwner()) return -100.0f; // not critting spell @@ -12298,7 +12298,7 @@ uint32 Unit::SpellCriticalHealingBonus(Unit const* caster, SpellInfo const* spel float Unit::SpellPctHealingModsDone(Unit* victim, SpellInfo const* spellProto, DamageEffectType damagetype) { // For totems get healing bonus from owner (statue isn't totem in fact) - if (GetTypeId() == TYPEID_UNIT && IsTotem()) + if (IsCreature() && IsTotem()) if (Unit* owner = GetOwner()) return owner->SpellPctHealingModsDone(victim, spellProto, damagetype); @@ -12390,7 +12390,7 @@ float Unit::SpellPctHealingModsDone(Unit* victim, SpellInfo const* spellProto, D uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint8 effIndex, float TotalMod, uint32 stack) { // For totems get healing bonus from owner (statue isn't totem in fact) - if (GetTypeId() == TYPEID_UNIT && IsTotem()) + if (IsCreature() && IsTotem()) if (Unit* owner = GetOwner()) return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, effIndex, TotalMod, stack); @@ -13014,7 +13014,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType if (!victim || pdamage == 0) return 0; - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) { // Dancing Rune Weapon... if (GetEntry() == 27893) @@ -13446,7 +13446,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry) // xinef: if we have charmed npc, stun him also if (Unit* charm = player->GetCharm()) - if (charm->GetTypeId() == TYPEID_UNIT) + if (charm->IsCreature()) charm->SetUnitFlag(UNIT_FLAG_STUNNED); WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4); @@ -13511,7 +13511,7 @@ void Unit::Dismount() // xinef: if we have charmed npc, remove stun also if (Unit* charm = player->GetCharm()) - if (charm->GetTypeId() == TYPEID_UNIT && !charm->HasUnitState(UNIT_STATE_STUNNED)) + if (charm->IsCreature() && !charm->HasUnitState(UNIT_STATE_STUNNED)) charm->RemoveUnitFlag(UNIT_FLAG_STUNNED); } } @@ -13519,7 +13519,7 @@ void Unit::Dismount() void Unit::SetInCombatWith(Unit* enemy, uint32 duration) { // Xinef: Dont allow to start combat with triggers - if (enemy->GetTypeId() == TYPEID_UNIT && enemy->ToCreature()->IsTrigger()) + if (enemy->IsCreature() && enemy->ToCreature()->IsTrigger()) return; Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf(); @@ -13563,7 +13563,7 @@ void Unit::SetImmuneToNPC(bool apply, bool keepCombat) void Unit::CombatStart(Unit* victim, bool initialAggro) { // Xinef: Dont allow to start combat with triggers - if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsTrigger()) + if (victim->IsCreature() && victim->ToCreature()->IsTrigger()) return; if (initialAggro) @@ -13574,7 +13574,7 @@ void Unit::CombatStart(Unit* victim, bool initialAggro) victim->SetStandState(UNIT_STAND_STATE_STAND); } - if (!victim->IsInCombat() && victim->GetTypeId() != TYPEID_PLAYER && !victim->ToCreature()->HasReactState(REACT_PASSIVE) && victim->ToCreature()->IsAIEnabled) + if (!victim->IsInCombat() && !victim->IsPlayer() && !victim->ToCreature()->HasReactState(REACT_PASSIVE) && victim->ToCreature()->IsAIEnabled) { if (victim->IsPet()) victim->ToCreature()->AI()->AttackedBy(this); // PetAI has special handler before AttackStart() @@ -13629,7 +13629,7 @@ void Unit::CombatStart(Unit* victim, bool initialAggro) SetContestedPvP(who->ToPlayer()); Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); - if (player && who->IsPvP() && (who->GetTypeId() != TYPEID_PLAYER || !player->duel || player->duel->Opponent != who)) + if (player && who->IsPvP() && (!who->IsPlayer() || !player->duel || player->duel->Opponent != who)) { player->UpdatePvP(true); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); @@ -13639,7 +13639,7 @@ void Unit::CombatStart(Unit* victim, bool initialAggro) void Unit::CombatStartOnCast(Unit* target, bool initialAggro, uint32 duration) { // Xinef: Dont allow to start combat with triggers - if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsTrigger()) + if (target->IsCreature() && target->ToCreature()->IsTrigger()) return; if (initialAggro) @@ -13656,7 +13656,7 @@ void Unit::CombatStartOnCast(Unit* target, bool initialAggro, uint32 duration) SetContestedPvP(who->ToPlayer()); Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); - if (player && who->IsPvP() && (who->GetTypeId() != TYPEID_PLAYER || !player->duel || player->duel->Opponent != who)) + if (player && who->IsPvP() && (!who->IsPlayer() || !player->duel || player->duel->Opponent != who)) { player->UpdatePvP(true); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); @@ -13678,7 +13678,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration) return; // xinef: if we somehow engage in combat (scripts, dunno) with player, remove this flag so he can fight back - if (GetTypeId() == TYPEID_UNIT && enemy && IsImmuneToPC() && enemy->GetCharmerOrOwnerPlayerOrPlayerItself()) + if (IsCreature() && enemy && IsImmuneToPC() && enemy->GetCharmerOrOwnerPlayerOrPlayerItself()) SetImmuneToPC(false); // unit has engaged in combat, remove immunity so players can fight back if (IsInCombat()) @@ -13726,7 +13726,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration) ++itr; // Xinef: Dont set combat for passive units, they will evade in next update... - if (controlled->GetTypeId() == TYPEID_UNIT && controlled->ToCreature()->HasReactState(REACT_PASSIVE)) + if (controlled->IsCreature() && controlled->ToCreature()->HasReactState(REACT_PASSIVE)) continue; controlled->SetInCombatState(PvP, enemy, duration); @@ -13873,10 +13873,10 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo Player* owner = GetAffectingPlayer(); Unit const* const thisUnit = owner ? owner : this; if (!(target->IsPlayer() && thisUnit->IsPlayer()) && - !(target->GetTypeId() == TYPEID_UNIT && thisUnit->GetTypeId() == TYPEID_UNIT)) + !(target->IsCreature() && thisUnit->IsCreature())) { Player const* player = target->IsPlayer() ? target->ToPlayer() : thisUnit->ToPlayer(); - Unit const* creature = target->GetTypeId() == TYPEID_UNIT ? target : thisUnit; + Unit const* creature = target->IsCreature() ? target : thisUnit; if (FactionTemplateEntry const* factionTemplate = creature->GetFactionTemplateEntry()) { @@ -14235,7 +14235,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) } case MOVE_FLIGHT: { - if (GetTypeId() == TYPEID_UNIT && IsControlledByPlayer()) // not sure if good for pet + if (IsCreature() && IsControlledByPlayer()) // not sure if good for pet { main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED); stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS); @@ -14280,7 +14280,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) case MOVE_FLIGHT: { // Set creature speed rate - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) { if (IsPet() && ToPet()->isControlled() && IsControlledByPlayer()) { @@ -14341,7 +14341,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) if (float minSpeedMod = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED)) { - float base_speed = (GetTypeId() == TYPEID_UNIT ? ToCreature()->GetCreatureTemplate()->speed_run : 1.0f); + float base_speed = (IsCreature() ? ToCreature()->GetCreatureTemplate()->speed_run : 1.0f); float min_speed = base_speed * (minSpeedMod / 100.0f); if (speed < min_speed) speed = min_speed; @@ -14429,7 +14429,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) if (pet && (pet->HasUnitFlag(UNIT_FLAG_POSSESSED) || pet->IsVehicle())) pet = nullptr; - if (pet && pet->GetTypeId() == TYPEID_UNIT && !pet->IsInCombat() && pet->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE) + if (pet && pet->IsCreature() && !pet->IsInCombat() && pet->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE) pet->UpdateSpeed(mtype, forced); if (Unit* critter = ObjectAccessor::GetUnit(*this, GetCritterGUID())) critter->UpdateSpeed(mtype, forced); @@ -14544,7 +14544,7 @@ void Unit::setDeathState(DeathState s, bool despawn) bool Unit::CanHaveThreatList() const { // only creatures can have threat list - if (GetTypeId() != TYPEID_UNIT) + if (!IsCreature()) return false; // only alive units can have threat list @@ -14593,7 +14593,7 @@ void Unit::AddThreat(Unit* victim, float fThreat, SpellSchoolMask schoolMask, Sp void Unit::TauntApply(Unit* taunter) { - ASSERT(GetTypeId() == TYPEID_UNIT); + ASSERT(IsCreature()); if (!taunter || (taunter->IsPlayer() && taunter->ToPlayer()->IsGameMaster())) return; @@ -14623,7 +14623,7 @@ void Unit::TauntApply(Unit* taunter) void Unit::TauntFadeOut(Unit* taunter) { - ASSERT(GetTypeId() == TYPEID_UNIT); + ASSERT(IsCreature()); if (!taunter || (taunter->IsPlayer() && taunter->ToPlayer()->IsGameMaster())) return; @@ -14716,7 +14716,7 @@ Unit* Creature::SelectVictim() // it in combat but attacker not make any damage and not enter to aggro radius to have record in threat list // Note: creature does not have targeted movement generator but has attacker in this case for (AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) - if ((*itr) && CanCreatureAttack(*itr) && (*itr)->GetTypeId() != TYPEID_PLAYER && !(*itr)->ToCreature()->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) + if ((*itr) && CanCreatureAttack(*itr) && !(*itr)->IsPlayer() && !(*itr)->ToCreature()->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) return nullptr; if (GetVehicle()) @@ -15000,7 +15000,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, if (group == DIMINISHING_TAUNT) { - if (GetTypeId() == TYPEID_UNIT && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_OBEYS_TAUNT_DIMINISHING_RETURNS)) + if (IsCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_OBEYS_TAUNT_DIMINISHING_RETURNS)) { DiminishingLevels diminish = Level; switch (diminish) @@ -15027,7 +15027,7 @@ float Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, // Some diminishings applies to mobs too (for example, Stun) else if ((GetDiminishingReturnsGroupType(group) == DRTYPE_PLAYER && ((targetOwner ? (targetOwner->IsPlayer()) : (IsPlayer())) - || (GetTypeId() == TYPEID_UNIT && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) + || (IsCreature() && ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) || GetDiminishingReturnsGroupType(group) == DRTYPE_ALL) { DiminishingLevels diminish = Level; @@ -15423,7 +15423,7 @@ void Unit::SetHealth(uint32 val) SetUInt32Value(UNIT_FIELD_HEALTH, val); // mobs that are now or were below 30% need to update their speed - if (GetTypeId() == TYPEID_UNIT && !(IsPet() && ToPet()->isControlled() && IsControlledByPlayer()) && (prevHealthPct < 30.0 || HealthBelowPct(30))) + if (IsCreature() && !(IsPet() && ToPet()->isControlled() && IsControlledByPlayer()) && (prevHealthPct < 30.0 || HealthBelowPct(30))) { UpdateSpeed(MOVE_RUN, false); } @@ -16337,7 +16337,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, u case SPELL_AURA_MOD_CASTING_SPEED_NOT_STACK: // Skip melee hits or instant cast spells // xinef: check channeled spells which are affected by haste also - if (procSpellInfo && (procSpellInfo->SpellFamilyName || GetTypeId() != TYPEID_PLAYER) && + if (procSpellInfo && (procSpellInfo->SpellFamilyName || !IsPlayer()) && (procSpellInfo->CalcCastTime() > 0 /*|| (procSpell->IsChanneled() && procSpell->GetDuration() > 0 && (HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, procSpell) || procSpell->HasAttribute(SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC)))*/)) takeCharges = true; @@ -16539,7 +16539,7 @@ Player* Unit::GetSpellModOwner() const void Unit::SendPetActionFeedback(uint8 msg) { Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || !owner->IsPlayer()) return; WorldPacket data(SMSG_PET_ACTION_FEEDBACK, 1); @@ -16550,7 +16550,7 @@ void Unit::SendPetActionFeedback(uint8 msg) void Unit::SendPetTalk(uint32 pettalk) { Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || !owner->IsPlayer()) return; WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4); @@ -16562,7 +16562,7 @@ void Unit::SendPetTalk(uint32 pettalk) void Unit::SendPetAIReaction(ObjectGuid guid) { Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || !owner->IsPlayer()) return; WorldPacket data(SMSG_AI_REACTION, 8 + 4); @@ -17009,7 +17009,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply) uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const { // Not apply this to creature casted spells with casttime == 0 - if (CastingTime == 0 && GetTypeId() == TYPEID_UNIT && !IsPet()) + if (CastingTime == 0 && IsCreature() && !IsPet()) return 3500; if (CastingTime > 7000) CastingTime = 7000; @@ -17109,7 +17109,7 @@ void Unit::UpdateAuraForGroup(uint8 slot) player->SetAuraUpdateMaskForRaid(slot); } } - else if (GetTypeId() == TYPEID_UNIT && IsPet()) + else if (IsCreature() && IsPet()) { Pet* pet = ((Pet*)this); if (pet->isControlled()) @@ -17148,7 +17148,7 @@ float Unit::CalculateDefaultCoefficient(SpellInfo const* spellInfo, DamageEffect float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) { - if (!normalized || GetTypeId() != TYPEID_PLAYER) + if (!normalized || !IsPlayer()) return float(GetAttackTime(attType)) / 1000.0f; Item* Weapon = ToPlayer()->GetWeaponForAttack(attType, true); @@ -17216,7 +17216,7 @@ void Unit::SetContestedPvP(Player* attackedPlayer, bool lookForNearContestedGuar void Unit::AddPetAura(PetAura const* petSpell) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return; m_petAuras.insert(petSpell); @@ -17228,7 +17228,7 @@ void Unit::AddPetAura(PetAura const* petSpell) void Unit::RemovePetAura(PetAura const* petSpell) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return; m_petAuras.erase(petSpell); @@ -17257,7 +17257,7 @@ bool Unit::IsPetAura(Aura const* aura) { Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || !owner->IsPlayer()) return false; // if the owner has that pet aura, return true @@ -17270,7 +17270,7 @@ bool Unit::IsPetAura(Aura const* aura) Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return nullptr; Pet* pet = new Pet(ToPlayer(), HUNTER_PET); @@ -17294,7 +17294,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id) Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id) { - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return nullptr; CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry); @@ -17828,7 +17828,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp plrVictim->SendDurabilityLoss(); } // Call KilledUnit for creatures - if (killer && killer->GetTypeId() == TYPEID_UNIT && killer->IsAIEnabled) + if (killer && killer->IsCreature() && killer->IsAIEnabled) killer->ToCreature()->AI()->KilledUnit(victim); // last damage from non duel opponent or opponent controlled creature @@ -17859,7 +17859,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp } // Call KilledUnit for creatures, this needs to be called after the lootable flag is set - if (killer && killer->GetTypeId() == TYPEID_UNIT && killer->IsAIEnabled) + if (killer && killer->IsCreature() && killer->IsAIEnabled) killer->ToCreature()->AI()->KilledUnit(victim); // Call creature just died function @@ -17925,7 +17925,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp // achievement stuff if (killer && victim->IsPlayer()) { - if (killer->GetTypeId() == TYPEID_UNIT) + if (killer->IsCreature()) victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, killer->GetEntry()); else if (victim != killer && killer->IsPlayer()) victim->ToPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, killer->ToPlayer()->GetTeamId()); @@ -18013,7 +18013,7 @@ void Unit::SetControlled(bool apply, UnitState state, Unit* source /*= nullptr*/ break; case UNIT_STATE_ROOT: // Prevent creature_template_movement rooted flag from being removed on aura expiration. - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) { if (ToCreature()->GetCreatureTemplate()->Movement.Rooted) { @@ -18099,16 +18099,16 @@ void Unit::SetStunned(bool apply) if (IsAlive() && GetVictim()) SetTarget(GetVictim()->GetGUID()); - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) { // don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface) Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId() != TYPEID_PLAYER || !owner->ToPlayer()->IsMounted()) + if (!owner || !owner->IsPlayer() || !owner->ToPlayer()->IsMounted()) RemoveUnitFlag(UNIT_FLAG_STUNNED); // Xinef: same for charmed npcs owner = GetCharmer(); - if (!owner || owner->GetTypeId() != TYPEID_PLAYER || !owner->ToPlayer()->IsMounted()) + if (!owner || !owner->IsPlayer() || !owner->ToPlayer()->IsMounted()) RemoveUnitFlag(UNIT_FLAG_STUNNED); } else @@ -18143,7 +18143,7 @@ void Unit::SetRooted(bool apply, bool isStun) } // Creature specific - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) { if (isStun && movespline->Finalized()) { @@ -18194,7 +18194,7 @@ void Unit::SetRooted(bool apply, bool isStun) void Unit::DisableRotate(bool apply) { - if (GetTypeId() != TYPEID_UNIT) + if (!IsCreature()) return; if (apply) @@ -18359,7 +18359,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au StopAttackingInvalidTarget(); - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) { GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); @@ -18407,7 +18407,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au GetCharmInfo()->InitCharmCreateSpells(); // Xinef: convert charm npcs dont have pet bar so initialize them as defensive helpers - if (type == CHARM_TYPE_CONVERT && GetTypeId() == TYPEID_UNIT) + if (type == CHARM_TYPE_CONVERT && IsCreature()) ToCreature()->SetReactState(REACT_DEFENSIVE); } } @@ -18431,7 +18431,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au playerCharmer->PossessSpellInitialize(); break; case CHARM_TYPE_CHARM: - if (GetTypeId() == TYPEID_UNIT && charmer->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET_CHARM)) + if (IsCreature() && charmer->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET_CHARM)) { CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate(); if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) @@ -18519,7 +18519,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) GetMotionMaster()->InitDefault(); // xinef: remove stunned flag if owner was mounted - if (GetTypeId() == TYPEID_UNIT && !HasUnitState(UNIT_STATE_STUNNED)) + if (IsCreature() && !HasUnitState(UNIT_STATE_STUNNED)) RemoveUnitFlag(UNIT_FLAG_STUNNED); // If charmer still exists @@ -18527,7 +18527,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) return; ASSERT(type != CHARM_TYPE_POSSESS || charmer->IsPlayer()); - ASSERT(type != CHARM_TYPE_VEHICLE || (GetTypeId() == TYPEID_UNIT && IsVehicle())); + ASSERT(type != CHARM_TYPE_VEHICLE || (IsCreature() && IsVehicle())); charmer->SetCharm(this, false); @@ -18553,7 +18553,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) ClearUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD); break; case CHARM_TYPE_CHARM: - if (GetTypeId() == TYPEID_UNIT && charmer->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET_CHARM)) + if (IsCreature() && charmer->IsClass(CLASS_WARLOCK, CLASS_CONTEXT_PET_CHARM)) { CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate(); if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) @@ -18608,7 +18608,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) playerCharmer->SendRemoveControlBar(); // xinef: Always delete charm info (restores react state) - if (IsPlayer() || (GetTypeId() == TYPEID_UNIT && !ToCreature()->IsGuardian())) + if (IsPlayer() || (IsCreature() && !ToCreature()->IsGuardian())) DeleteCharmInfo(); } @@ -18704,11 +18704,11 @@ bool Unit::IsInPartyWith(Unit const* unit) const if (u1->IsPlayer() && u2->IsPlayer()) return u1->ToPlayer()->IsInSameGroupWith(u2->ToPlayer()); // Xinef: we assume that npcs with the same faction are in party - else if (u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer()) + else if (u1->IsCreature() && u2->IsCreature() && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer()) return u1->GetFaction() == u2->GetFaction(); // Xinef: creature type_flag should work for party check only if player group is not a raid - else if ((u2->IsPlayer() && u1->GetTypeId() == TYPEID_UNIT && (u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u2->ToPlayer()->GetGroup() && !u2->ToPlayer()->GetGroup()->isRaidGroup()) || - (u1->IsPlayer() && u2->GetTypeId() == TYPEID_UNIT && (u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u1->ToPlayer()->GetGroup() && !u1->ToPlayer()->GetGroup()->isRaidGroup())) + else if ((u2->IsPlayer() && u1->IsCreature() && (u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u2->ToPlayer()->GetGroup() && !u2->ToPlayer()->GetGroup()->isRaidGroup()) || + (u1->IsPlayer() && u2->IsCreature() && (u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) && u1->ToPlayer()->GetGroup() && !u1->ToPlayer()->GetGroup()->isRaidGroup())) return true; else return false; @@ -18727,10 +18727,10 @@ bool Unit::IsInRaidWith(Unit const* unit) const if (u1->IsPlayer() && u2->IsPlayer()) return u1->ToPlayer()->IsInSameRaidWith(u2->ToPlayer()); // Xinef: we assume that npcs with the same faction are in party - else if (u1->GetTypeId() == TYPEID_UNIT && u2->GetTypeId() == TYPEID_UNIT && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer()) + else if (u1->IsCreature() && u2->IsCreature() && !u1->IsControlledByPlayer() && !u2->IsControlledByPlayer()) return u1->GetFaction() == u2->GetFaction(); - else if ((u2->IsPlayer() && u1->GetTypeId() == TYPEID_UNIT && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || - (u1->IsPlayer() && u2->GetTypeId() == TYPEID_UNIT && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) + else if ((u2->IsPlayer() && u1->IsCreature() && u1->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || + (u1->IsPlayer() && u2->IsCreature() && u2->ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)) return true; else return false; @@ -18847,13 +18847,13 @@ void Unit::SendPlaySpellImpact(ObjectGuid guid, uint32 id) void Unit::ApplyResilience(Unit const* victim, float* crit, int32* damage, bool isCrit, CombatRating type) { // player mounted on multi-passenger mount is also classified as vehicle - if (victim->IsVehicle() && victim->GetTypeId() != TYPEID_PLAYER) + if (victim->IsVehicle() && !victim->IsPlayer()) return; Unit const* target = nullptr; if (victim->IsPlayer()) target = victim; - else if (victim->GetTypeId() == TYPEID_UNIT) + else if (victim->IsCreature()) { if (Unit* owner = victim->GetOwner()) if (owner->IsPlayer()) @@ -18981,7 +18981,7 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) return; // modify hostile references for new phasemask, some special cases deal with hostile references themselves - if (GetTypeId() == TYPEID_UNIT || (!ToPlayer()->IsGameMaster() && !ToPlayer()->GetSession()->PlayerLogout())) + if (IsCreature() || (!ToPlayer()->IsGameMaster() && !ToPlayer()->GetSession()->PlayerLogout())) { HostileRefMgr& refMgr = getHostileRefMgr(); HostileReference* ref = refMgr.getFirst(); @@ -18996,7 +18996,7 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) } // modify threat lists for new phasemask - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) { ThreatContainer::StorageType threatList = GetThreatMgr().GetThreatList(); ThreatContainer::StorageType offlineThreatList = GetThreatMgr().GetOfflineThreatList(); @@ -19024,7 +19024,7 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) { Unit* controlled = *itr; ++itr; - if (controlled->GetTypeId() == TYPEID_UNIT) + if (controlled->IsCreature()) { controlled->SetPhaseMask(newPhaseMask, true); } @@ -19310,7 +19310,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const if (formEntry && formEntry->modelID_A) { // Take the alliance modelid as default - if (GetTypeId() != TYPEID_PLAYER) + if (!IsPlayer()) return formEntry->modelID_A; else { @@ -19434,7 +19434,7 @@ Unit* Unit::GetRedirectThreatTarget() const void Unit::JumpTo(float speedXY, float speedZ, bool forward) { float angle = forward ? 0 : M_PI; - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ); else { @@ -19771,7 +19771,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) } // xinef: move fall, should we support all creatures that exited vehicle in air? Currently Quest Drag and Drop only, Air Assault quest - if (GetTypeId() == TYPEID_UNIT && !CanFly() && vehicleInfo && (vehicleInfo->m_ID == 113 || vehicleInfo->m_ID == 8 || vehicleInfo->m_ID == 290 || vehicleInfo->m_ID == 298)) + if (IsCreature() && !CanFly() && vehicleInfo && (vehicleInfo->m_ID == 113 || vehicleInfo->m_ID == 8 || vehicleInfo->m_ID == 290 || vehicleInfo->m_ID == 298)) { GetMotionMaster()->MoveFall(); } @@ -19783,7 +19783,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) { vehicle->Dismiss(); } - else if (vehicleBase->GetTypeId() == TYPEID_UNIT) + else if (vehicleBase->IsCreature()) { vehicle->Uninstall(); vehicleBase->m_Events.AddEvent(new VehicleDespawnEvent(*vehicleBase, 2000), vehicleBase->m_Events.CalculateTime(2000)); @@ -19928,7 +19928,7 @@ void Unit::SendTameFailure(uint8 result) void Unit::SendTeleportPacket(Position& pos) { Position oldPos = { GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation() }; - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) Relocate(&pos); if (IsPlayer()) { @@ -19937,7 +19937,7 @@ void Unit::SendTeleportPacket(Position& pos) WorldPacket data2(MSG_MOVE_TELEPORT, 38); data2 << GetPackGUID(); BuildMovementPacket(&data2); - if (GetTypeId() == TYPEID_UNIT) + if (IsCreature()) Relocate(&oldPos); if (IsPlayer()) Relocate(&pos); @@ -20250,7 +20250,7 @@ uint32 Unit::GetResistance(SpellSchoolMask mask) const void Unit::PetSpellFail(SpellInfo const* spellInfo, Unit* target, uint32 result) { CharmInfo* charmInfo = GetCharmInfo(); - if (!charmInfo || GetTypeId() != TYPEID_UNIT) + if (!charmInfo || !IsCreature()) return; if ((DisableMgr::IsPathfindingEnabled(GetMap()) || result != SPELL_FAILED_LINE_OF_SIGHT) && target) @@ -20300,7 +20300,7 @@ void Unit::PetSpellFail(SpellInfo const* spellInfo, Unit* target, uint32 result) int32 Unit::CalculateAOEDamageReduction(int32 damage, uint32 schoolMask, Unit* caster) const { damage = int32(float(damage) * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, schoolMask)); - if (caster && caster->GetTypeId() == TYPEID_UNIT) + if (caster && caster->IsCreature()) damage = int32(float(damage) * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, schoolMask)); return damage; @@ -20592,7 +20592,7 @@ bool Unit::SetHover(bool enable, bool /*packetOnly = false*/, bool /*updateAnima else { RemoveUnitMovementFlag(MOVEMENTFLAG_HOVER); - if (hoverHeight && (!isDying() || GetTypeId() != TYPEID_UNIT)) + if (hoverHeight && (!isDying() || !IsCreature())) { float newZ = std::max(GetFloorZ(), GetPositionZ() - hoverHeight); UpdateAllowedPositionZ(GetPositionX(), GetPositionY(), newZ); @@ -20861,7 +20861,7 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi valuesUpdateBuf.put(posPointers.UnitFieldBytes2Pos, (m_uint32Values[UNIT_FIELD_BYTES_2] & ((UNIT_BYTE2_FLAG_SANCTUARY /*| UNIT_BYTE2_FLAG_AURAS | UNIT_BYTE2_FLAG_UNK5*/) << 8))); // this flag is at uint8 offset 1 !! }// pussywizard / Callmephil else if (target->IsSpectator() && target->FindMap() && target->FindMap()->IsBattleArena() && - (this->IsPlayer() || this->GetTypeId() == TYPEID_UNIT || this->IsDynamicObject())) + (this->IsPlayer() || this->IsCreature() || this->IsDynamicObject())) { valuesUpdateBuf.put(posPointers.UnitFieldBytes2Pos, (m_uint32Values[UNIT_FIELD_BYTES_2] & 0xFFFFF2FF)); // clear UNIT_BYTE2_FLAG_PVP, UNIT_BYTE2_FLAG_FFA_PVP, UNIT_BYTE2_FLAG_SANCTUARY } @@ -20879,7 +20879,7 @@ void Unit::PatchValuesUpdate(ByteBuffer& valuesUpdateBuf, BuildValuesCachePosPoi valuesUpdateBuf.put(posPointers.UnitFieldFactionTemplatePos, uint32(target->GetFaction())); }// pussywizard / Callmephil else if (target->IsSpectator() && target->FindMap() && target->FindMap()->IsBattleArena() && - (this->IsPlayer() || this->GetTypeId() == TYPEID_UNIT || this->IsDynamicObject())) + (this->IsPlayer() || this->IsCreature() || this->IsDynamicObject())) { valuesUpdateBuf.put(posPointers.UnitFieldFactionTemplatePos, uint32(target->GetFaction())); } diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 22952cd67563c6..ca5bbbd34eabd0 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -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); } } diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index d3e1e89b2d1856..e238a306195bcb 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -91,7 +91,7 @@ namespace Acore { Unit& i_unit; bool isCreature; - explicit AIRelocationNotifier(Unit& unit) : i_unit(unit), isCreature(unit.GetTypeId() == TYPEID_UNIT) {} + explicit AIRelocationNotifier(Unit& unit) : i_unit(unit), isCreature(unit.IsCreature()) {} template void Visit(GridRefMgr&) {} void Visit(CreatureMapType&); }; @@ -864,7 +864,7 @@ namespace Acore bool operator()(Unit* u) { if (u->IsAlive() && !u->IsCritter() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u) && - (i_funit->GetTypeId() != TYPEID_UNIT || !i_funit->ToCreature()->IsAvoidingAOE())) // pussywizard + (!i_funit->IsCreature() || !i_funit->ToCreature()->IsAvoidingAOE())) // pussywizard return true; else return false; @@ -887,7 +887,7 @@ namespace Acore if (u->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET) return false; - if (u->GetTypeId() == TYPEID_UNIT && (u->ToCreature()->IsTotem() || u->ToCreature()->IsTrigger() || u->ToCreature()->IsAvoidingAOE())) // pussywizard: added IsAvoidingAOE() + if (u->IsCreature() && (u->ToCreature()->IsTotem() || u->ToCreature()->IsTrigger() || u->ToCreature()->IsAvoidingAOE())) // pussywizard: added IsAvoidingAOE() return false; if (!u->isTargetableForAttack(false, i_funit)) @@ -918,7 +918,7 @@ namespace Acore return false; } - if (u->GetTypeId() == TYPEID_UNIT && u->ToCreature()->IsTotem()) + if (u->IsCreature() && u->ToCreature()->IsTotem()) { return false; } @@ -930,7 +930,7 @@ namespace Acore uint32 losChecks = LINEOFSIGHT_ALL_CHECKS; Optional collisionHeight = { }; - if (i_obj->GetTypeId() == TYPEID_GAMEOBJECT) + if (i_obj->IsGameObject()) { losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2; collisionHeight = i_owner->GetCollisionHeight(); @@ -1203,7 +1203,7 @@ namespace Acore if (!me->IsValidAttackTarget(u)) return false; - if (i_playerOnly && u->GetTypeId() != TYPEID_PLAYER) + if (i_playerOnly && !u->IsPlayer()) return false; m_range = me->GetDistance(u); // use found unit range as new range limit for next check diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index d1691c32515e56..f5c3df9b85d858 100644 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -791,7 +791,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit); //Send scripted event call - if (unit && unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->AI()) + if (unit && unit->IsCreature() && ((Creature*)unit)->AI()) ((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), text_emote); } diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index fe432e186c4886..ef7560e76e80c4 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -410,7 +410,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData) } movementInfo.pos.Relocate(mover->GetPositionX(), mover->GetPositionY(), mover->GetPositionZ()); - if (mover->GetTypeId() == TYPEID_UNIT) + if (mover->IsCreature()) { movementInfo.transport.guid = mover->m_movementInfo.transport.guid; movementInfo.transport.pos.Relocate(mover->m_movementInfo.transport.pos.GetPositionX(), mover->m_movementInfo.transport.pos.GetPositionY(), mover->m_movementInfo.transport.pos.GetPositionZ()); diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 8368c8723658ca..af53948caa167d 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -50,7 +50,7 @@ void WorldSession::HandleDismissCritter(WorldPackets::Pet::DismissCritter& packe if (_player->GetCritterGUID() == pet->GetGUID()) { - if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->IsSummon()) + if (pet->IsCreature() && pet->ToCreature()->IsSummon()) pet->ToTempSummon()->UnSummon(); } } @@ -234,7 +234,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe // Not let attack through obstructions bool checkLos = !DisableMgr::IsPathfindingEnabled(pet->GetMap()) || - (TargetUnit->GetTypeId() == TYPEID_UNIT && (TargetUnit->ToCreature()->isWorldBoss() || TargetUnit->ToCreature()->IsDungeonBoss())); + (TargetUnit->IsCreature() && (TargetUnit->ToCreature()->isWorldBoss() || TargetUnit->ToCreature()->IsDungeonBoss())); if (checkLos && !pet->IsWithinLOSInMap(TargetUnit)) { @@ -252,7 +252,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe { pet->AttackStop(); - if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature()->IsAIEnabled) + if (!pet->IsPlayer() && pet->ToCreature()->IsAIEnabled) { charmInfo->SetIsCommandAttack(true); charmInfo->SetIsAtStay(false); @@ -292,7 +292,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe } else if (pet->GetOwnerGUID() == GetPlayer()->GetGUID()) { - ASSERT(pet->GetTypeId() == TYPEID_UNIT); + ASSERT(pet->IsCreature()); if (pet->IsPet()) { if (pet->ToPet()->getPetType() == HUNTER_PET) @@ -323,7 +323,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe case REACT_DEFENSIVE: //recovery case REACT_AGGRESSIVE: //activete - if (pet->GetTypeId() == TYPEID_UNIT) + if (pet->IsCreature()) pet->ToCreature()->SetReactState(ReactStates(spellId)); else charmInfo->SetPlayerReactState(ReactStates(spellId)); @@ -491,7 +491,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe if (pet->GetVictim()) pet->AttackStop(); - if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature() && pet->ToCreature()->IsAIEnabled) + if (!pet->IsPlayer() && pet->ToCreature() && pet->ToCreature()->IsAIEnabled) { charmInfo->SetIsCommandAttack(true); charmInfo->SetIsAtStay(false); @@ -537,7 +537,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe else victim = nullptr; - if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature() && pet->ToCreature()->IsAIEnabled) + if (!pet->IsPlayer() && pet->ToCreature() && pet->ToCreature()->IsAIEnabled) { pet->StopMoving(); pet->GetMotionMaster()->Clear(); @@ -775,7 +775,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) //sign for autocast if (act_state == ACT_ENABLED) { - if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet()) + if (pet->IsCreature() && pet->IsPet()) { ((Pet*)pet)->ToggleAutocast(spellInfo, true); } @@ -793,7 +793,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData) //sign for no/turn off autocast else if (act_state == ACT_DISABLED) { - if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet()) + if (pet->IsCreature() && pet->IsPet()) { ((Pet*)pet)->ToggleAutocast(spellInfo, false); } diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 120424711d0d5f..4933dc6ef9268c 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -123,7 +123,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData) Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM | TYPEMASK_PLAYER); // no or incorrect quest giver - if (!object || object == _player || (object->GetTypeId() != TYPEID_PLAYER && !object->hasQuest(questId)) || + if (!object || object == _player || (!object->IsPlayer() && !object->hasQuest(questId)) || (object->IsPlayer() && !object->ToPlayer()->CanShareQuest(questId))) { _player->PlayerTalkClass->SendCloseGossip(); diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index a373d5bf7f8e8d..e932155873ffb9 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -409,7 +409,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) if (Vehicle* veh = mover->GetVehicleKit()) if (const VehicleSeatEntry* seat = veh->GetSeatForPassenger(_player)) if (seat->m_flags & VEHICLE_SEAT_FLAG_CAN_ATTACK || spellInfo->Effects[EFFECT_0].Effect == SPELL_EFFECT_OPEN_LOCK /*allow looting from vehicle, but only if player has required spell (all necessary opening spells are in playercreateinfo_spell)*/) - if ((mover->GetTypeId() == TYPEID_UNIT && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive()) // the creature can't cast that spell, check player instead + if ((mover->IsCreature() && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive()) // the creature can't cast that spell, check player instead { if( !(spellInfo->Targets & TARGET_FLAG_GAMEOBJECT_ITEM) && (!_player->HasActiveSpell (spellId) || spellInfo->IsPassive()) ) { @@ -419,12 +419,12 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) } // at this point, player is a valid caster - // swapping the mover will stop the check below at == TYPEID_UNIT, so everything works fine + // swapping the mover will stop the check below at IsUnit, so everything works fine mover = _player; } // not have spell in spellbook or spell passive and not casted by client - if ((mover->GetTypeId() == TYPEID_UNIT && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive()) + if ((mover->IsCreature() && !mover->ToCreature()->HasSpell(spellId)) || spellInfo->IsPassive()) { //cheater? kick? ban? recvPacket.rfinish(); // prevent spam at ignore packet diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 0c0581192e07c5..122257c15221ea 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -679,7 +679,7 @@ void InstanceScript::DoCastSpellOnPlayer(Player* player, uint32 spell, bool incl for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2) { if (Unit* controlled = *itr2) - if (controlled->IsInWorld() && controlled->GetTypeId() == TYPEID_UNIT) + if (controlled->IsInWorld() && controlled->IsCreature()) controlled->CastSpell(player, spell, true); } } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index f2d298624dee84..ec3dffb8fa605f 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -587,7 +587,7 @@ bool Map::AddToMap(T* obj, bool checkTransport) obj->AddToWorld(); if (checkTransport) - if (!(obj->GetTypeId() == TYPEID_GAMEOBJECT && obj->ToGameObject()->IsTransport())) // dont add transport to transport ;d + if (!(obj->IsGameObject() && obj->ToGameObject()->IsTransport())) // dont add transport to transport ;d if (Transport* transport = GetTransportForPos(obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj)) transport->AddPassenger(obj, true); @@ -602,7 +602,7 @@ bool Map::AddToMap(T* obj, bool checkTransport) // Xinef: little hack for vehicles, accessories have to be added after visibility update so they wont fall off the vehicle, moved from Creature::AIM_Initialize // Initialize vehicle, this is done only for summoned npcs, DB creatures are handled by grid loaders - if (obj->GetTypeId() == TYPEID_UNIT) + if (obj->IsCreature()) if (Vehicle* vehicle = obj->ToCreature()->GetVehicleKit()) vehicle->Reset(); return true; @@ -2662,8 +2662,8 @@ void Map::AddObjectToSwitchList(WorldObject* obj, bool on) { ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId()); // i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses - // the contained objects only if GetTypeId() == TYPEID_UNIT , so we can return in all other cases - if (obj->GetTypeId() != TYPEID_UNIT && obj->GetTypeId() != TYPEID_GAMEOBJECT) + // the contained objects only if IsCreature() , so we can return in all other cases + if (!obj->IsCreature() && !obj->IsGameObject()) return; std::map::iterator itr = i_objectsToSwitch.find(obj); diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 84167be2255389..39b8aa7173dfef 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -244,7 +244,7 @@ void MotionMaster::MoveRandom(float wanderDistance) if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE)) return; - if (_owner->GetTypeId() == TYPEID_UNIT) + if (_owner->IsCreature()) { LOG_DEBUG("movement.motionmaster", "Creature ({}) start moving random", _owner->GetGUID().ToString()); Mutate(new RandomMovementGenerator(wanderDistance), MOTION_SLOT_IDLE); @@ -260,12 +260,12 @@ void MotionMaster::MoveTargetedHome(bool walk /*= false*/) { Clear(false); - if (_owner->GetTypeId() == TYPEID_UNIT && !_owner->ToCreature()->GetCharmerOrOwnerGUID()) + if (_owner->IsCreature() && !_owner->ToCreature()->GetCharmerOrOwnerGUID()) { LOG_DEBUG("movement.motionmaster", "Creature ({}) targeted home", _owner->GetGUID().ToString()); Mutate(new HomeMovementGenerator(walk), MOTION_SLOT_ACTIVE); } - else if (_owner->GetTypeId() == TYPEID_UNIT && _owner->ToCreature()->GetCharmerOrOwnerGUID()) + else if (_owner->IsCreature() && _owner->ToCreature()->GetCharmerOrOwnerGUID()) { _owner->ClearUnitState(UNIT_STATE_EVADE); @@ -645,7 +645,7 @@ void MotionMaster::MoveFall(uint32 id /*=0*/, bool addFlagForNPC) _owner->m_movementInfo.SetFallTime(0); _owner->ToPlayer()->SetFallInformation(GameTime::GetGameTime().count(), _owner->GetPositionZ()); } - else if (_owner->GetTypeId() == TYPEID_UNIT && addFlagForNPC) // pussywizard + else if (_owner->IsCreature() && addFlagForNPC) // pussywizard { _owner->RemoveUnitMovementFlag(MOVEMENTFLAG_MASK_MOVING); _owner->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY); diff --git a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp index 5f64daef33fdab..c1505f9af14484 100644 --- a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp @@ -72,7 +72,7 @@ bool RotateMovementGenerator::Update(Unit* owner, uint32 diff) void RotateMovementGenerator::Finalize(Unit* unit) { unit->ClearUnitState(UNIT_STATE_ROTATING); - if (unit->GetTypeId() == TYPEID_UNIT) + if (unit->IsCreature()) unit->ToCreature()->AI()->MovementInform(ROTATE_MOTION_TYPE, 0); } @@ -90,7 +90,7 @@ void DistractMovementGenerator::Finalize(Unit* owner) owner->ClearUnitState(UNIT_STATE_DISTRACTED); // If this is a creature, then return orientation to original position (for idle movement creatures) - if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()) + if (owner->IsCreature() && owner->ToCreature()) { float angle = owner->ToCreature()->GetHomePosition().GetOrientation(); owner->SetFacingTo(angle); diff --git a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp index ebe4934f8af2f3..4ec46038cc00b5 100644 --- a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp @@ -636,7 +636,7 @@ void PathGenerator::CreateFilter() uint16 includeFlags = 0; uint16 excludeFlags = 0; - if (_source->GetTypeId() == TYPEID_UNIT) + if (_source->IsCreature()) { Creature* creature = (Creature*)_source; if (creature->CanWalk()) diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index b3b43a572ac94b..e77fd91074b288 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -231,10 +231,10 @@ bool EffectMovementGenerator::Update(Unit* unit, uint32) void EffectMovementGenerator::Finalize(Unit* unit) { - if (unit->GetTypeId() != TYPEID_UNIT) + if (!unit->IsCreature()) return; - if (unit->GetTypeId() == TYPEID_UNIT && unit->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) && unit->movespline->isFalling()) // pussywizard + if (unit->IsCreature() && unit->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) && unit->movespline->isFalling()) // pussywizard unit->RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING); // Need restore previous movement since we have no proper states system diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 015f93650f914d..59a97bc9eea60f 100644 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -305,7 +305,7 @@ void ChaseMovementGenerator::DoReset(T* owner) template void ChaseMovementGenerator::MovementInform(T* owner) { - if (owner->GetTypeId() != TYPEID_UNIT) + if (!owner->IsCreature()) return; // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle @@ -385,7 +385,7 @@ bool FollowMovementGenerator::PositionOkay(Unit* target, bool isPlayerPet, bo float exactDistSq = target->GetExactDistSq(_lastTargetPosition->GetPositionX(), _lastTargetPosition->GetPositionY(), _lastTargetPosition->GetPositionZ()); float distanceTolerance = 0.25f; // For creatures, increase tolerance - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) { distanceTolerance += _range + _range; } @@ -554,7 +554,7 @@ void FollowMovementGenerator::DoReset(T* owner) template void FollowMovementGenerator::MovementInform(T* owner) { - if (owner->GetTypeId() != TYPEID_UNIT) + if (!owner->IsCreature()) return; // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 44df2047c0bd5c..2fc354e01b7a52 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -513,7 +513,7 @@ void OutdoorPvP::HandleKill(Player* killer, Unit* killed) // creature kills must be notified, even if not inside objective / not outdoor pvp active // player kills only count if active and inside objective - if ((groupGuy->IsOutdoorPvPActive() && IsInsideObjective(groupGuy)) || killed->GetTypeId() == TYPEID_UNIT) + if ((groupGuy->IsOutdoorPvPActive() && IsInsideObjective(groupGuy)) || killed->IsCreature()) { HandleKillImpl(groupGuy, killed); } @@ -522,7 +522,7 @@ void OutdoorPvP::HandleKill(Player* killer, Unit* killed) else { // creature kills must be notified, even if not inside objective / not outdoor pvp active - if ((killer->IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed->GetTypeId() == TYPEID_UNIT) + if ((killer->IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed->IsCreature()) { HandleKillImpl(killer, killed); } diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index fe945d7195c847..ebf2d3daa2d415 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -157,7 +157,7 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s Unit* unit = nullptr; if (!obj) LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target"); - else if (!obj->isType(TYPEMASK_UNIT)) + else if (!obj->IsUnit()) LOG_ERROR("maps.script", "{} {} object is not unit (TypeId: {}, Entry: {}, GUID: {}), skipping.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString()); else @@ -236,7 +236,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script LOG_ERROR("maps.script", "{} door guid is not specified.", scriptInfo->GetDebugInfo()); else if (!source) LOG_ERROR("maps.script", "{} source object is nullptr.", scriptInfo->GetDebugInfo()); - else if (!source->isType(TYPEMASK_UNIT)) + else if (!source->IsUnit()) LOG_ERROR("maps.script", "{} source object is not unit ({}), skipping.", scriptInfo->GetDebugInfo(), source->GetGUID().ToString()); else { @@ -510,7 +510,7 @@ void Map::ScriptsProcess() Player* player = target->ToPlayer(); if (player) { - if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER) + if (!source->IsCreature() && !source->IsGameObject() && !source->IsPlayer()) { LOG_ERROR("maps.script", "{} source is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), source->GetGUID().ToString()); break; @@ -522,7 +522,7 @@ void Map::ScriptsProcess() player = source->ToPlayer(); if (player) { - if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsCreature() && !target->IsGameObject() && !target->IsPlayer()) { LOG_ERROR("maps.script", "{} target is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString()); break; @@ -538,7 +538,7 @@ void Map::ScriptsProcess() } // quest id and flags checked at script loading - if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->IsAlive()) && + if ((!worldObject->IsCreature() || ((Unit*)worldObject)->IsAlive()) && (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance)))) player->GroupEventHappens(step.script->QuestExplored.QuestID, worldObject); else @@ -641,7 +641,7 @@ void Map::ScriptsProcess() break; } - if (target->GetTypeId() != TYPEID_GAMEOBJECT) + if (!target->IsGameObject()) { LOG_ERROR("maps.script", "{} target object is not gameobject ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString()); break; @@ -697,13 +697,13 @@ void Map::ScriptsProcess() break; } - if (!uSource || !uSource->isType(TYPEMASK_UNIT)) + if (!uSource || !uSource->IsUnit()) { LOG_ERROR("maps.script", "{} no source unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID); break; } - if (!uTarget || !uTarget->isType(TYPEMASK_UNIT)) + if (!uTarget || !uTarget->IsUnit()) { LOG_ERROR("maps.script", "{} no target unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID); break; diff --git a/src/server/game/Scripting/ScriptDefines/VehicleScript.cpp b/src/server/game/Scripting/ScriptDefines/VehicleScript.cpp index ae58a8cd52c3d7..590050f4d4b7b6 100644 --- a/src/server/game/Scripting/ScriptDefines/VehicleScript.cpp +++ b/src/server/game/Scripting/ScriptDefines/VehicleScript.cpp @@ -22,7 +22,7 @@ void ScriptMgr::OnInstall(Vehicle* veh) { ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(veh->GetBase()->IsCreature()); if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) { @@ -33,7 +33,7 @@ void ScriptMgr::OnInstall(Vehicle* veh) void ScriptMgr::OnUninstall(Vehicle* veh) { ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(veh->GetBase()->IsCreature()); if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) { @@ -44,7 +44,7 @@ void ScriptMgr::OnUninstall(Vehicle* veh) void ScriptMgr::OnReset(Vehicle* veh) { ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(veh->GetBase()->IsCreature()); if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) { @@ -55,7 +55,7 @@ void ScriptMgr::OnReset(Vehicle* veh) void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory) { ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(veh->GetBase()->IsCreature()); ASSERT(accessory); if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) @@ -67,7 +67,7 @@ void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory) void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId) { ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(veh->GetBase()->IsCreature()); ASSERT(passenger); if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) @@ -79,7 +79,7 @@ void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId) void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger) { ASSERT(veh); - ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); + ASSERT(veh->GetBase()->IsCreature()); ASSERT(passenger); if (auto tempScript = ScriptRegistry::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 92a3021a1a428f..acb1089525c91a 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -798,7 +798,7 @@ void AuraEffect::HandleEffect(Unit* target, uint8 mode, bool apply) void AuraEffect::ApplySpellMod(Unit* target, bool apply) { - if (!m_spellmod || target->GetTypeId() != TYPEID_PLAYER) + if (!m_spellmod || !target->IsPlayer()) return; target->ToPlayer()->AddSpellMod(m_spellmod, apply); @@ -951,7 +951,7 @@ void AuraEffect::UpdatePeriodic(Unit* caster) case 49472: // Drink Coffee case 57073: case 61830: - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) return; // Get SPELL_AURA_MOD_POWER_REGEN aura from spell if (AuraEffect* aurEff = GetBase()->GetEffect(0)) @@ -1712,7 +1712,7 @@ void AuraEffect::HandleDetectAmore(AuraApplication const* aurApp, uint8 mode, bo } Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) { return; } @@ -1744,7 +1744,7 @@ void AuraEffect::HandleSpiritOfRedemption(AuraApplication const* aurApp, uint8 m Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // prepare spirit state @@ -1779,7 +1779,7 @@ void AuraEffect::HandleAuraGhost(AuraApplication const* aurApp, uint8 mode, bool Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (apply) @@ -2178,7 +2178,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode, // Orb of Deception case 16739: { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; switch (target->getRace()) @@ -2237,7 +2237,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode, // Corsair Costume case 51926: { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; switch (target->getRace()) @@ -2811,7 +2811,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (Player* targetPlayer = target->ToPlayer()) @@ -2842,7 +2842,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo if ((*iter)->GetCurrentSpell(i) && (*iter)->GetCurrentSpell(i)->m_targets.GetUnitTargetGUID() == target->GetGUID()) { SpellInfo const* si = (*iter)->GetCurrentSpell(i)->GetSpellInfo(); - if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->GetTypeId() == TYPEID_UNIT) + if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->IsCreature()) { Creature* c = (*iter)->ToCreature(); if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss()) @@ -3009,7 +3009,7 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode, if (apply) target->SetFlag(field, flag); - if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->GetCurrentEquipmentId()) + if (target->IsCreature() && target->ToCreature()->GetCurrentEquipmentId()) target->UpdateDamagePhysical(attType); } @@ -3112,7 +3112,7 @@ void AuraEffect::HandleAuraTrackCreatures(AuraApplication const* aurApp, uint8 m Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (apply) @@ -3128,7 +3128,7 @@ void AuraEffect::HandleAuraTrackResources(AuraApplication const* aurApp, uint8 m Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (apply) @@ -3144,7 +3144,7 @@ void AuraEffect::HandleAuraTrackStealthed(AuraApplication const* aurApp, uint8 m Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (!(apply)) @@ -3206,7 +3206,7 @@ void AuraEffect::HandleAuraModPetTalentsPoints(AuraApplication const* aurApp, ui Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // Recalculate pet talent points @@ -3220,7 +3220,7 @@ void AuraEffect::HandleAuraModSkill(AuraApplication const* aurApp, uint8 mode, b return; Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; uint32 prot = GetMiscValue(); @@ -3318,7 +3318,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode target->SetCanFly(apply); - if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsLevitating()) + if (!apply && target->IsCreature() && !target->IsLevitating()) target->GetMotionMaster()->MoveFall(); } @@ -3444,7 +3444,7 @@ void AuraEffect::HandleAuraModTotalThreat(AuraApplication const* aurApp, uint8 m Unit* target = aurApp->GetTarget(); - if (!target->IsAlive() || target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsAlive() || !target->IsPlayer()) return; Unit* caster = GetCaster(); @@ -3547,7 +3547,7 @@ void AuraEffect::HandleModPossess(AuraApplication const* aurApp, uint8 mode, boo Unit* caster = GetCaster(); // no support for posession AI yet - if (caster && caster->GetTypeId() == TYPEID_UNIT) + if (caster && caster->IsCreature()) { HandleModCharm(aurApp, mode, apply); return; @@ -3567,7 +3567,7 @@ void AuraEffect::HandleModPossessPet(AuraApplication const* aurApp, uint8 mode, return; Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) return; //seems it may happen that when removing it is no longer owner's pet @@ -3575,7 +3575,7 @@ void AuraEffect::HandleModPossessPet(AuraApplication const* aurApp, uint8 mode, // return; Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT || !target->IsPet()) + if (!target->IsCreature() || !target->IsPet()) return; Pet* pet = target->ToPet(); @@ -3675,7 +3675,7 @@ void AuraEffect::HandleAuraControlVehicle(AuraApplication const* aurApp, uint8 m if (GetId() == 53111) // Devour Humanoid { Unit::Kill(target, caster); - if (caster->GetTypeId() == TYPEID_UNIT) + if (caster->IsCreature()) caster->ToCreature()->RemoveCorpse(); } @@ -3725,7 +3725,7 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp, { target->SetCanFly(apply); - if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsLevitating()) + if (!apply && target->IsCreature() && !target->IsLevitating()) target->GetMotionMaster()->MoveFall(); } @@ -4464,8 +4464,8 @@ void AuraEffect::HandleModPercentStat(AuraApplication const* aurApp, uint8 mode, return; } - // only players have base stats - if (target->GetTypeId() != TYPEID_PLAYER) + // only players currently use base stats + if (!target->IsPlayer()) return; for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) @@ -4482,7 +4482,7 @@ void AuraEffect::HandleModSpellDamagePercentFromStat(AuraApplication const* aurA Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // Magic damage modifiers implemented in Unit::SpellDamageBonus @@ -4498,7 +4498,7 @@ void AuraEffect::HandleModSpellHealingPercentFromStat(AuraApplication const* aur Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // Recalculate bonus @@ -4512,7 +4512,7 @@ void AuraEffect::HandleModSpellDamagePercentFromAttackPower(AuraApplication cons Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // Magic damage modifiers implemented in Unit::SpellDamageBonus @@ -4528,7 +4528,7 @@ void AuraEffect::HandleModSpellHealingPercentFromAttackPower(AuraApplication con Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // Recalculate bonus @@ -4542,7 +4542,7 @@ void AuraEffect::HandleModHealingDone(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // implemented in Unit::SpellHealingBonus // this information is for client side only @@ -4613,7 +4613,7 @@ void AuraEffect::HandleAuraModResistenceOfStatPercent(AuraApplication const* aur Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (GetMiscValue() != SPELL_SCHOOL_MASK_NORMAL) @@ -4635,7 +4635,7 @@ void AuraEffect::HandleAuraModExpertise(AuraApplication const* aurApp, uint8 mod Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; target->ToPlayer()->UpdateExpertise(BASE_ATTACK); @@ -4652,7 +4652,7 @@ void AuraEffect::HandleModPowerRegen(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // Update manaregen value @@ -4675,7 +4675,7 @@ void AuraEffect::HandleModManaRegen(AuraApplication const* aurApp, uint8 mode, b Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; //Note: an increase in regen does NOT cause threat. @@ -4815,7 +4815,7 @@ void AuraEffect::HandleAuraModParryPercent(AuraApplication const* aurApp, uint8 Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (!target->ToPlayer()->CanParry()) @@ -4831,7 +4831,7 @@ void AuraEffect::HandleAuraModDodgePercent(AuraApplication const* aurApp, uint8 Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; target->ToPlayer()->UpdateDodgePercentage(); @@ -4844,7 +4844,7 @@ void AuraEffect::HandleAuraModBlockPercent(AuraApplication const* aurApp, uint8 Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; target->ToPlayer()->UpdateBlockPercentage(); @@ -4862,7 +4862,7 @@ void AuraEffect::HandleAuraModWeaponCritPercent(AuraApplication const* aurApp, u Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; for (int i = 0; i < MAX_ATTACK; ++i) @@ -4937,7 +4937,7 @@ void AuraEffect::HandleModSpellCritChanceShool(AuraApplication const* aurApp, ui Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; for (int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school) @@ -4952,7 +4952,7 @@ void AuraEffect::HandleAuraModCritPct(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) { target->m_baseSpellCritChance += (apply) ? GetAmount() : -GetAmount(); return; @@ -5051,7 +5051,7 @@ void AuraEffect::HandleRangedAmmoHaste(AuraApplication const* aurApp, uint8 mode Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; target->ApplyAttackTimePercentMod(RANGED_ATTACK, (float)GetAmount(), apply); @@ -5068,7 +5068,7 @@ void AuraEffect::HandleModRating(AuraApplication const* aurApp, uint8 mode, bool Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) @@ -5083,7 +5083,7 @@ void AuraEffect::HandleModRatingFromStat(AuraApplication const* aurApp, uint8 mo Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // Just recalculate ratings @@ -5202,7 +5202,7 @@ void AuraEffect::HandleModDamageDone(AuraApplication const* aurApp, uint8 mode, if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) != 0 && sScriptMgr->CanModAuraEffectDamageDone(this, target, aurApp, mode, apply)) { // apply generic physical damage bonuses including wand case - if (GetSpellInfo()->EquippedItemClass == -1 || target->GetTypeId() != TYPEID_PLAYER) + if (GetSpellInfo()->EquippedItemClass == -1 || !target->IsPlayer()) { target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_VALUE, float(GetAmount()), apply); target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_VALUE, float(GetAmount()), apply); @@ -5279,7 +5279,7 @@ void AuraEffect::HandleModDamagePercentDone(AuraApplication const* aurApp, uint8 target->ToPlayer()->_ApplyWeaponDependentAuraDamageMod(item, WeaponAttackType(i), this, apply); } - if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) && (GetSpellInfo()->EquippedItemClass == -1 || target->GetTypeId() != TYPEID_PLAYER)) + if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) && (GetSpellInfo()->EquippedItemClass == -1 || !target->IsPlayer())) { target->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT, float(GetAmount()), apply); target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, TOTAL_PCT, float(GetAmount()), apply); @@ -5373,7 +5373,7 @@ void AuraEffect::HandleNoReagentUseAura(AuraApplication const* aurApp, uint8 mod Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; flag96 mask; @@ -5393,7 +5393,7 @@ void AuraEffect::HandleAuraRetainComboPoints(AuraApplication const* aurApp, uint Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler @@ -5609,7 +5609,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool break; case 43681: // Inactive { - if (target->GetTypeId() != TYPEID_PLAYER || aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) + if (!target->IsPlayer() || aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) return; if (target->GetMap()->IsBattleground()) @@ -5643,7 +5643,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool break; case 46374: // quest The Power of the Elements (11893) { - if (target->isDead() && GetBase() && target->GetTypeId() == TYPEID_UNIT && target->GetEntry() == 24601) + if (target->isDead() && GetBase() && target->IsCreature() && target->GetEntry() == 24601) { auto caster2 = GetBase()->GetCaster(); if (caster2 && caster2->IsPlayer()) @@ -5716,7 +5716,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool case 57821: // Champion of the Kirin Tor case 57822: // Wyrmrest Champion { - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) break; uint32 FactionID = 0; @@ -5860,7 +5860,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) return; Player* plCaster = caster->ToPlayer(); @@ -5904,7 +5904,7 @@ void AuraEffect::HandleBindSight(AuraApplication const* aurApp, uint8 mode, bool Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) return; caster->ToPlayer()->SetViewpoint(target, apply); @@ -5918,7 +5918,7 @@ void AuraEffect::HandleFarSight(AuraApplication const* /*aurApp*/, uint8 mode, b } Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) { return; } @@ -5943,7 +5943,7 @@ void AuraEffect::HandleForceReaction(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; Player* player = target->ToPlayer(); @@ -6023,7 +6023,7 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; Player* player = target->ToPlayer(); @@ -6095,7 +6095,7 @@ void AuraEffect::HandleAuraOpenStable(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER || !target->IsInWorld()) + if (!target->IsPlayer() || !target->IsInWorld()) return; if (apply) @@ -6154,7 +6154,7 @@ void AuraEffect::HandleAuraSetVehicle(AuraApplication const* aurApp, uint8 mode, Unit* target = aurApp->GetTarget(); - if (target->GetTypeId() != TYPEID_PLAYER || !target->IsInWorld()) + if (!target->IsPlayer() || !target->IsInWorld()) return; uint32 vehicleId = GetMiscValue(); @@ -6184,7 +6184,7 @@ void AuraEffect::HandlePreventResurrection(AuraApplication const* aurApp, uint8 if (!(mode & AURA_EFFECT_HANDLE_REAL)) return; - if (aurApp->GetTarget()->GetTypeId() != TYPEID_PLAYER) + if (!aurApp->GetTarget()->IsPlayer()) return; if (apply) @@ -6270,7 +6270,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const // Death Rune Mastery if (GetSpellInfo()->SpellIconID == 3041 || GetSpellInfo()->SpellIconID == 22 || GetSpellInfo()->SpellIconID == 2622) { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (!target->ToPlayer()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) return; @@ -6355,7 +6355,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) return; // Inoculate Nestlewood Owlkin case 29528: - if (target->GetTypeId() != TYPEID_UNIT) // prevent error reports in case ignored player target + if (!target->IsCreature()) // prevent error reports in case ignored player target return; break; // Feed Captured Animal @@ -6367,7 +6367,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster) { // move loot to player inventory and despawn target if (caster && caster->IsPlayer() && - target->GetTypeId() == TYPEID_UNIT && + target->IsCreature() && target->ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_GAS_CLOUD) { Player* player = caster->ToPlayer(); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 051c3031075739..0a4e6e7c41e71e 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -380,7 +380,7 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne casterGUID = caster->GetGUID(); // check if aura can be owned by owner - if (owner->isType(TYPEMASK_UNIT)) + if (owner->IsUnit()) if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld()) // owner not in world so don't allow to own not self casted single target auras if (casterGUID != owner->GetGUID() && spellproto->IsSingleTarget()) @@ -1789,7 +1789,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b { if (removeMode != AURA_REMOVE_BY_EXPIRE) break; - if (caster->GetTypeId() != TYPEID_PLAYER) + if (!caster->IsPlayer()) break; Player* player = caster->ToPlayer(); @@ -1860,7 +1860,7 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b { if (!GetEffect(0) || GetEffect(0)->GetAuraType() != SPELL_AURA_PERIODIC_DUMMY) break; - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) break; if (!target->ToPlayer()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) break; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 60d153f9d62f71..24d07cc9452347 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -743,7 +743,7 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets) unit = selectedUnit; } // try to use attacked unit as a target - else if ((m_caster->GetTypeId() == TYPEID_UNIT) && neededTargets & (TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT)) + else if ((m_caster->IsCreature()) && neededTargets & (TARGET_FLAG_UNIT_ENEMY | TARGET_FLAG_UNIT)) unit = m_caster->GetVictim(); // didn't find anything - let's use self as target @@ -1788,7 +1788,7 @@ void Spell::SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImpli case TARGET_UNIT_PASSENGER_5: case TARGET_UNIT_PASSENGER_6: case TARGET_UNIT_PASSENGER_7: - if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsVehicle()) + if (m_caster->IsCreature() && m_caster->ToCreature()->IsVehicle()) target = m_caster->GetVehicleKit()->GetPassenger(targetType.GetTarget() - TARGET_UNIT_PASSENGER_0); break; default: @@ -2365,7 +2365,7 @@ void Spell::prepareDataForTriggerSystem(AuraEffect const* /*triggeredByAura*/) m_procEx |= PROC_EX_INTERNAL_TRIGGERED; } // Totem casts require spellfamilymask defined in spell_proc_event to proc - if (m_originalCaster && m_caster != m_originalCaster && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsTotem() && m_caster->IsControlledByPlayer()) + if (m_originalCaster && m_caster != m_originalCaster && m_caster->IsCreature() && m_caster->ToCreature()->IsTotem() && m_caster->IsControlledByPlayer()) m_procEx |= PROC_EX_INTERNAL_REQ_FAMILY; } @@ -2692,7 +2692,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) { spellHitTarget = m_caster; unitTarget = m_caster; - if (m_caster->GetTypeId() == TYPEID_UNIT) + if (m_caster->IsCreature()) m_caster->ToCreature()->LowerPlayerDamageReq(target->damage); } } @@ -2919,7 +2919,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) } // Failed Pickpocket, reveal rogue - if (missInfo == SPELL_MISS_RESIST && m_spellInfo->HasAttribute(SPELL_ATTR0_CU_PICKPOCKET) && unitTarget->GetTypeId() == TYPEID_UNIT && m_caster) + if (missInfo == SPELL_MISS_RESIST && m_spellInfo->HasAttribute(SPELL_ATTR0_CU_PICKPOCKET) && unitTarget->IsCreature() && m_caster) { m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK); if (unitTarget->ToCreature()->IsAIEnabled) @@ -2965,19 +2965,19 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) } // Check for SPELL_ATTR7_CAN_CAUSE_INTERRUPT - if (m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_CAUSE_INTERRUPT) && effectUnit->GetTypeId() != TYPEID_PLAYER) + if (m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_CAUSE_INTERRUPT) && !effectUnit->IsPlayer()) caster->CastSpell(effectUnit, SPELL_INTERRUPT_NONPLAYER, true); if (spellHitTarget) { //AI functions - if (spellHitTarget->GetTypeId() == TYPEID_UNIT) + if (spellHitTarget->IsCreature()) { if (spellHitTarget->ToCreature()->IsAIEnabled) spellHitTarget->ToCreature()->AI()->SpellHit(m_caster, m_spellInfo); } - if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsAIEnabled) + if (m_caster->IsCreature() && m_caster->ToCreature()->IsAIEnabled) m_caster->ToCreature()->AI()->SpellHitTarget(spellHitTarget, m_spellInfo); // Needs to be called after dealing damage/healing to not remove breaking on damage auras @@ -3053,7 +3053,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA // Xinef: Also check evade state if (m_spellInfo->Speed > 0.0f) { - if (unit->GetTypeId() == TYPEID_UNIT && unit->ToCreature()->IsInEvadeMode()) + if (unit->IsCreature() && unit->ToCreature()->IsInEvadeMode()) return SPELL_MISS_EVADE; if (unit->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE) && unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) @@ -3101,12 +3101,12 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA // Xinef: Do not increase diminishing level for self cast m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo, m_triggeredByAuraSpell.spellInfo); // xinef: do not increase diminish level for bosses (eg. Void Reaver silence is never diminished) - if (((m_spellFlags & SPELL_FLAG_REFLECTED) && !(unit->HasAuraType(SPELL_AURA_REFLECT_SPELLS))) || (aura_effmask && m_diminishGroup && unit != m_caster && (m_caster->GetTypeId() != TYPEID_UNIT || !m_caster->ToCreature()->isWorldBoss()))) + if (((m_spellFlags & SPELL_FLAG_REFLECTED) && !(unit->HasAuraType(SPELL_AURA_REFLECT_SPELLS))) || (aura_effmask && m_diminishGroup && unit != m_caster && (!m_caster->IsCreature() || !m_caster->ToCreature()->isWorldBoss()))) { m_diminishLevel = unit->GetDiminishing(m_diminishGroup); DiminishingReturnsType type = GetDiminishingReturnsGroupType(m_diminishGroup); - uint32 flagsExtra = unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetCreatureTemplate()->flags_extra : 0; + uint32 flagsExtra = unit->IsCreature() ? unit->ToCreature()->GetCreatureTemplate()->flags_extra : 0; // Increase Diminishing on unit, current informations for actually casts will use values above if ((type == DRTYPE_PLAYER && (unit->IsCharmedOwnedByPlayerOrPlayer() || flagsExtra & CREATURE_FLAG_EXTRA_ALL_DIMINISH || @@ -3685,7 +3685,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const // set target for proper facing if ((m_casttime || m_spellInfo->IsChanneled()) && !HasTriggeredCastFlag(TRIGGERED_IGNORE_SET_FACING)) { - if (m_caster->GetTypeId() == TYPEID_UNIT && !m_caster->ToCreature()->IsInEvadeMode() && + if (m_caster->IsCreature() && !m_caster->ToCreature()->IsInEvadeMode() && ((m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) || m_spellInfo->IsPositive())) { // Xinef: Creature should focus to cast target if there is explicit target or self if casting positive spell @@ -3838,14 +3838,14 @@ void Spell::_cast(bool skipCheck) if (!playerCaster->m_Controlled.empty()) for (Unit::ControlSet::iterator itr = playerCaster->m_Controlled.begin(); itr != playerCaster->m_Controlled.end(); ++itr) if (Unit* pet = *itr) - if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT) + if (pet->IsAlive() && pet->IsCreature()) pet->ToCreature()->AI()->OwnerAttacked(m_targets.GetUnitTarget()); } SetExecutedCurrently(true); if (!HasTriggeredCastFlag(TRIGGERED_IGNORE_SET_FACING)) - if (m_caster->GetTypeId() == TYPEID_UNIT && m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) + if (m_caster->IsCreature() && m_targets.GetObjectTarget() && m_caster != m_targets.GetObjectTarget()) m_caster->SetInFront(m_targets.GetObjectTarget()); CallScriptBeforeCastHandlers(); @@ -4087,7 +4087,7 @@ void Spell::_cast(bool skipCheck) // handle this here, in other places SpellHitTarget can be set to nullptr, if there is an error in this function if (m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_CAUSE_INTERRUPT)) if (Unit* target = m_targets.GetUnitTarget()) - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) m_caster->CastSpell(target, 32747, true); // xinef: start combat at cast for delayed spells, only for explicit target @@ -4346,7 +4346,7 @@ void Spell::_handle_finish_phase() void Spell::SendSpellCooldown() { // xinef: properly add creature cooldowns - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) { if (!HasTriggeredCastFlag(TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD)) { @@ -4489,7 +4489,7 @@ void Spell::finish(bool ok) if (m_spellInfo->IsChanneled() && m_caster->IsPlayer()) { if (Unit* charm = m_caster->GetCharm()) - if (charm->GetTypeId() == TYPEID_UNIT + if (charm->IsCreature() && charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET) && charm->GetUInt32Value(UNIT_CREATED_BY_SPELL) == m_spellInfo->Id) ((Puppet*)charm)->UnSummon(); @@ -4521,7 +4521,7 @@ void Spell::finish(bool ok) if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_ENCOUNTER_REWARD) && m_caster->FindMap()) m_caster->FindMap()->UpdateEncounterState(ENCOUNTER_CREDIT_CAST_SPELL, m_spellInfo->Id, m_caster); - if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsSummon()) + if (m_caster->IsCreature() && m_caster->ToCreature()->IsSummon()) { // Unsummon statue uint32 spell = m_caster->GetUInt32Value(UNIT_CREATED_BY_SPELL); @@ -4673,7 +4673,7 @@ void Spell::SendCastResult(SpellCastResult result) if (result == SPELL_CAST_OK) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER || m_caster->IsCharmed()) + if (!m_caster->IsPlayer() || m_caster->IsCharmed()) return; if (m_caster->ToPlayer()->GetSession()->PlayerLoading()) // don't send cast results at loading time @@ -5242,7 +5242,7 @@ void Spell::SendResurrectRequest(Player* target) void Spell::TakeCastItem() { - if (!m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_CastItem || !m_caster->IsPlayer()) return; // not remove cast item at triggered spell (equipping, weapon damage, etc) @@ -5401,7 +5401,7 @@ SpellCastResult Spell::CheckRuneCost(uint32 RuneCostID) if (m_spellInfo->PowerType != POWER_RUNE || !RuneCostID) return SPELL_CAST_OK; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_CAST_OK; Player* player = m_caster->ToPlayer(); @@ -5452,7 +5452,7 @@ SpellCastResult Spell::CheckRuneCost(uint32 RuneCostID) void Spell::TakeRunePower(bool didHit) { - if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_caster->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) + if (!m_caster->IsPlayer() || !m_caster->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) return; SpellRuneCostEntry const* runeCostData = sSpellRuneCostStore.LookupEntry(m_spellInfo->RuneCostID); @@ -5521,7 +5521,7 @@ void Spell::TakeRunePower(bool didHit) void Spell::TakeReagents() { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : nullptr; @@ -5680,7 +5680,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent())) return SPELL_FAILED_NOT_READY; } - else if (!IsTriggered() && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->IsSpellProhibited(m_spellInfo->GetSchoolMask())) + else if (!IsTriggered() && m_caster->IsCreature() && m_caster->ToCreature()->IsSpellProhibited(m_spellInfo->GetSchoolMask())) return SPELL_FAILED_NOT_READY; } @@ -5987,7 +5987,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_NOT_IN_ARENA; // zone check - if (m_caster->GetTypeId() == TYPEID_UNIT || !m_caster->ToPlayer()->IsGameMaster()) + if (m_caster->IsCreature() || !m_caster->ToPlayer()->IsGameMaster()) { uint32 zone, area; m_caster->GetZoneAndAreaId(zone, area); @@ -6114,7 +6114,7 @@ SpellCastResult Spell::CheckCast(bool strict) { case SPELL_EFFECT_LEARN_SPELL: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_BAD_TARGETS; if (m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_PET) @@ -6140,7 +6140,7 @@ SpellCastResult Spell::CheckCast(bool strict) // check target only for unit target case if (Unit* unitTarget = m_targets.GetUnitTarget()) { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_BAD_TARGETS; Pet* pet = unitTarget->ToPet(); @@ -6167,7 +6167,7 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_FEED_PET: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_BAD_TARGETS; Item* foodItem = m_targets.GetItemTarget(); @@ -6260,7 +6260,7 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_SKINNING: { - if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.GetUnitTarget() || m_targets.GetUnitTarget()->GetTypeId() != TYPEID_UNIT) + if (!m_caster->IsPlayer() || !m_targets.GetUnitTarget() || !m_targets.GetUnitTarget()->IsCreature()) return SPELL_FAILED_BAD_TARGETS; if (!(m_targets.GetUnitTarget()->GetUnitFlags() & UNIT_FLAG_SKINNABLE)) @@ -6286,7 +6286,7 @@ SpellCastResult Spell::CheckCast(bool strict) m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_GAMEOBJECT_ITEM_TARGET) break; - if (m_caster->GetTypeId() != TYPEID_PLAYER // only players can open locks, gather etc. + if (!m_caster->IsPlayer() // only players can open locks, gather etc. // we need a go target in case of TARGET_GAMEOBJECT_TARGET || (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget())) return SPELL_FAILED_BAD_TARGETS; @@ -6410,7 +6410,7 @@ SpellCastResult Spell::CheckCast(bool strict) { if (m_targets.GetUnitTarget()) { - if (m_targets.GetUnitTarget()->GetTypeId() != TYPEID_PLAYER) + if (!m_targets.GetUnitTarget()->IsPlayer()) return SPELL_FAILED_BAD_TARGETS; if (m_targets.GetUnitTarget()->GetPetGUID()) return SPELL_FAILED_ALREADY_HAVE_SUMMON; @@ -6472,7 +6472,7 @@ SpellCastResult Spell::CheckCast(bool strict) } case SPELL_EFFECT_SUMMON_PLAYER: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_BAD_TARGETS; if (!m_caster->GetTarget()) return SPELL_FAILED_BAD_TARGETS; @@ -6507,7 +6507,7 @@ SpellCastResult Spell::CheckCast(bool strict) // RETURN HERE case SPELL_EFFECT_SUMMON_RAF_FRIEND: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_BAD_TARGETS; Player* playerCaster = m_caster->ToPlayer(); @@ -6602,7 +6602,7 @@ SpellCastResult Spell::CheckCast(bool strict) break; case SPELL_AURA_MOD_POSSESS_PET: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_NO_PET; Pet* pet = m_caster->ToPlayer()->GetPet(); @@ -6637,7 +6637,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (Unit* target = m_targets.GetUnitTarget()) { - if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsVehicle()) + if (target->IsCreature() && target->ToCreature()->IsVehicle()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; if (target->IsMounted()) @@ -6719,7 +6719,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_spellInfo->Effects[i].IsTargetingArea()) break; - if (m_caster->GetTypeId() != TYPEID_PLAYER || m_CastItem) + if (!m_caster->IsPlayer() || m_CastItem) break; if (!m_targets.GetUnitTarget()) @@ -6757,7 +6757,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_CastItem) return SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_NOT_TRADING; TradeData* my_trade = m_caster->ToPlayer()->GetTradeData(); @@ -7058,7 +7058,7 @@ SpellCastResult Spell::CheckRange(bool strict) float min_range = m_caster->GetSpellMinRangeForTarget(target, m_spellInfo); // xinef: hack for npc shooters - if (min_range && GetCaster()->GetTypeId() == TYPEID_UNIT && !GetCaster()->GetOwnerGUID().IsPlayer() && min_range <= 6.0f) + if (min_range && GetCaster()->IsCreature() && !GetCaster()->GetOwnerGUID().IsPlayer() && min_range <= 6.0f) range_type = SPELL_RANGE_RANGED; if (Player* modOwner = m_caster->GetSpellModOwner()) @@ -7076,7 +7076,7 @@ SpellCastResult Spell::CheckRange(bool strict) if (range_type == SPELL_RANGE_MELEE) { float real_max_range = max_range; - if (m_caster->GetTypeId() != TYPEID_UNIT && m_caster->isMoving() && target->isMoving() && !m_caster->IsWalking() && !target->IsWalking()) + if (!m_caster->IsCreature() && m_caster->isMoving() && target->isMoving() && !m_caster->IsWalking() && !target->IsWalking()) real_max_range -= MIN_MELEE_REACH; // Because of lag, we can not check too strictly here (is only used if both caster and target are moving) else real_max_range -= 2 * MIN_MELEE_REACH; @@ -7255,7 +7255,7 @@ SpellCastResult Spell::CheckItems() // check target item if (m_targets.GetItemTargetGUID()) { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_BAD_TARGETS; if (!m_targets.GetItemTarget()) @@ -7606,7 +7606,7 @@ SpellCastResult Spell::CheckItems() case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return SPELL_FAILED_TARGET_NOT_PLAYER; if (m_attackType != RANGED_ATTACK) @@ -7760,7 +7760,7 @@ SpellCastResult Spell::CheckSpellFocus() void Spell::Delayed() // only called in DealDamage() { - if (!m_caster)// || m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster)// || !m_caster->IsPlayer()) return; //if (m_spellState == SPELL_STATE_DELAYED) @@ -7805,7 +7805,7 @@ void Spell::Delayed() // only called in DealDamage() void Spell::DelayedChannel() { - if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER || getState() != SPELL_STATE_CASTING) + if (!m_caster || !m_caster->IsPlayer() || getState() != SPELL_STATE_CASTING) return; if (isDelayableNoMore()) // Spells may only be delayed twice @@ -7919,7 +7919,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const case SPELL_AURA_MOD_CHARM: case SPELL_AURA_MOD_POSSESS_PET: case SPELL_AURA_AOE_CHARM: - if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle()) + if (target->IsCreature() && target->IsVehicle()) return false; if (target->IsMounted()) return false; @@ -7935,7 +7935,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const // xinef: skip los checking if spell has appropriate attribute, or target requires specific entry // this is only for target addition and target has to have unselectable flag, this is valid for FLAG_EXTRA_TRIGGER and quest triggers however there are some without this flag, used not_selectable - if (m_spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) || (target->GetTypeId() == TYPEID_UNIT && target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) && (m_spellInfo->Effects[eff].TargetA.GetCheckType() == TARGET_CHECK_ENTRY || m_spellInfo->Effects[eff].TargetB.GetCheckType() == TARGET_CHECK_ENTRY))) + if (m_spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) || (target->IsCreature() && target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE) && (m_spellInfo->Effects[eff].TargetA.GetCheckType() == TARGET_CHECK_ENTRY || m_spellInfo->Effects[eff].TargetB.GetCheckType() == TARGET_CHECK_ENTRY))) return true; // if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour @@ -7992,7 +7992,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const } break; case SPELL_EFFECT_SUMMON_RAF_FRIEND: - if (m_caster->GetTypeId() != TYPEID_PLAYER || target->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer() || !target->IsPlayer()) return false; if (m_caster->ToPlayer()->GetSession()->IsARecruiter() && target->ToPlayer()->GetSession()->GetRecruiterId() != m_caster->ToPlayer()->GetSession()->GetAccountId()) return false; @@ -8385,7 +8385,7 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk reqSkillValue = lockInfo->Skill[j]; // castitem check: rogue using skeleton keys. the skill values should not be added in this case. - skillValue = m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER ? + skillValue = m_CastItem || !m_caster->IsPlayer() ? 0 : m_caster->ToPlayer()->GetSkillValue(skillId); // skill bonus provided by casting spell (mostly item spells) @@ -9035,14 +9035,14 @@ namespace Acore bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target) { - if (target->GetTypeId() == TYPEID_GAMEOBJECT) + if (target->IsGameObject()) { if (!target->ToGameObject()->IsInRange(_position->GetPositionX(), _position->GetPositionY(), _position->GetPositionZ(), _range)) return false; } else if (!target->IsWithinDist3d(_position, _range)) return false; - else if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsAvoidingAOE()) // pussywizard + else if (target->IsCreature() && target->ToCreature()->IsAvoidingAOE()) // pussywizard return false; return WorldObjectSpellTargetCheck::operator ()(target); } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 293557bd22600b..aab419f79df4f9 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -257,7 +257,7 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex) if (!unitTarget || unitTarget->IsAlive()) return; - if (unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget->IsPlayer()) return; if (!unitTarget->IsInWorld()) @@ -435,7 +435,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) // Shadow Bite else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000) { - if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->IsPet()) + if (m_caster->IsCreature() && m_caster->IsPet()) { if (Player* owner = m_caster->GetOwner()->ToPlayer()) { @@ -776,7 +776,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex) { sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, gameObjTarget); } - else if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT) + else if (unitTarget && unitTarget->IsCreature()) { sScriptMgr->OnDummyEffect(m_caster, m_spellInfo->Id, effIndex, unitTarget->ToCreature()); } @@ -2065,7 +2065,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) { LOG_DEBUG("spells.aura", "WORLD: Open Lock - No Player Caster!"); return; @@ -2182,7 +2182,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* player = m_caster->ToPlayer(); @@ -2291,7 +2291,7 @@ void Spell::EffectProficiency(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* p_target = m_caster->ToPlayer(); @@ -2524,7 +2524,7 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex) if (!unitTarget) return; - if (unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget->IsPlayer()) { if (unitTarget->ToPet()) EffectLearnPetSpell(effIndex); @@ -2686,7 +2686,7 @@ void Spell::EffectPickPocket(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; m_caster->ToPlayer()->SendLoot(unitTarget->GetGUID(), LOOT_PICKPOCKETING); @@ -2697,7 +2697,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; float radius = m_spellInfo->Effects[effIndex].CalcRadius(); @@ -2751,7 +2751,7 @@ void Spell::EffectLearnSkill(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget->IsPlayer()) return; if (damage < 0) @@ -2767,7 +2767,7 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget->IsPlayer()) return; // not scale value for item based reward (/10 value expected) @@ -2801,7 +2801,7 @@ void Spell::EffectTradeSkill(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; // uint32 skillid = m_spellInfo->Effects[i].MiscValue; // uint16 skillmax = unitTarget->ToPlayer()->(skillid); @@ -2813,7 +2813,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; if (!itemTarget) return; @@ -2869,7 +2869,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; if (!itemTarget) return; @@ -2923,7 +2923,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* p_caster = m_caster->ToPlayer(); @@ -3070,7 +3070,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/) if (!unitTarget) return; - if (unitTarget->GetTypeId() != TYPEID_UNIT) + if (!unitTarget->IsCreature()) return; Creature* creatureTarget = unitTarget->ToCreature(); @@ -3199,7 +3199,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) if (!pet) return; - if (m_caster->GetTypeId() == TYPEID_UNIT) + if (m_caster->IsCreature()) { if (m_caster->ToCreature()->IsTotem()) pet->SetReactState(REACT_AGGRESSIVE); @@ -3831,7 +3831,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) /*// Mug Transformation case 41931: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; uint8 bag = 19; @@ -3874,12 +3874,12 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) } case 52173: // Coyote Spirit Despawn case 60243: // Blood Parrot Despawn - if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->ToCreature()->IsSummon()) + if (unitTarget->IsCreature() && unitTarget->ToCreature()->IsSummon()) unitTarget->ToTempSummon()->UnSummon(); return; case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget || !unitTarget->IsCreature() || !m_caster->IsPlayer()) return; unitTarget->ToCreature()->DespawnOrUnsummon(); @@ -3888,7 +3888,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) } case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) { - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; // Delete item from inventory at death @@ -3899,7 +3899,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) case 58418: // Portal to Orgrimmar case 58420: // Portal to Stormwind { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0) + if (!unitTarget || !unitTarget->IsPlayer() || effIndex != 0) return; uint32 spellID = m_spellInfo->Effects[EFFECT_0].CalcValue(); @@ -4041,7 +4041,7 @@ void Spell::EffectSanctuary(SpellEffIndex /*effIndex*/) if ((*iter)->GetCurrentSpell(i) && (*iter)->GetCurrentSpell(i)->m_targets.GetUnitTargetGUID() == unitTarget->GetGUID()) { SpellInfo const* si = (*iter)->GetCurrentSpell(i)->GetSpellInfo(); - if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->GetTypeId() == TYPEID_UNIT) + if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->IsCreature()) { Creature* c = (*iter)->ToCreature(); if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss()) @@ -4085,7 +4085,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER || unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget || !m_caster->IsPlayer() || !unitTarget->IsPlayer()) return; Player* caster = m_caster->ToPlayer(); @@ -4161,7 +4161,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* target = m_caster->ToPlayer(); @@ -4311,7 +4311,7 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX) + if (!m_caster->IsPlayer() || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX) return; Player* player = m_caster->ToPlayer(); @@ -4770,7 +4770,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/) // xinef: we should also force pets to remove us from current target Unit::AttackerSet attackerSet; for (Unit::AttackerSet::const_iterator itr = m_caster->getAttackers().begin(); itr != m_caster->getAttackers().end(); ++itr) - if ((*itr)->GetTypeId() == TYPEID_UNIT && !(*itr)->CanHaveThreatList()) + if ((*itr)->IsCreature() && !(*itr)->CanHaveThreatList()) attackerSet.insert(*itr); for (Unit::AttackerSet::const_iterator itr = attackerSet.begin(); itr != attackerSet.end(); ++itr) @@ -4801,7 +4801,7 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/) if (spell->m_targets.GetUnitTargetGUID() == m_caster->GetGUID()) { SpellInfo const* si = spell->GetSpellInfo(); - if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->GetTypeId() == TYPEID_UNIT) + if (si->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT) && (*iter)->IsCreature()) { Creature* c = (*iter)->ToCreature(); if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss()) @@ -4832,7 +4832,7 @@ void Spell::EffectSelfResurrect(SpellEffIndex effIndex) if (!m_caster || m_caster->IsAlive()) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; if (!m_caster->IsInWorld()) return; @@ -4870,9 +4870,9 @@ void Spell::EffectSkinning(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (unitTarget->GetTypeId() != TYPEID_UNIT) + if (!unitTarget->IsCreature()) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Creature* creature = unitTarget->ToCreature(); @@ -5472,7 +5472,7 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* p_caster = m_caster->ToPlayer(); @@ -5497,7 +5497,7 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* p_caster = m_caster->ToPlayer(); @@ -5535,7 +5535,7 @@ void Spell::EffectSpiritHeal(SpellEffIndex /*effIndex*/) return; /* - if (unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget->IsPlayer()) return; if (!unitTarget->IsInWorld()) return; @@ -5554,7 +5554,7 @@ void Spell::EffectSkinPlayerCorpse(SpellEffIndex /*effIndex*/) return; LOG_DEBUG("spells.aura", "Effect: SkinPlayerCorpse"); - if ((m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->IsAlive())) + if ((!m_caster->IsPlayer()) || (!unitTarget->IsPlayer()) || (unitTarget->IsAlive())) return; unitTarget->ToPlayer()->RemovedInsignia(m_caster->ToPlayer()); @@ -5747,7 +5747,7 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* player = m_caster->ToPlayer(); @@ -5820,7 +5820,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->GetPetGUID() || !unitTarget->IsClass(CLASS_HUNTER, CLASS_CONTEXT_PET)) + if (!unitTarget || !unitTarget->IsPlayer() || unitTarget->GetPetGUID() || !unitTarget->IsClass(CLASS_HUNTER, CLASS_CONTEXT_PET)) return; uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue; @@ -6088,7 +6088,7 @@ void Spell::EffectRenamePet(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || + if (!unitTarget || !unitTarget->IsCreature() || !unitTarget->IsPet() || unitTarget->ToPet()->getPetType() != HUNTER_PET) return; @@ -6199,7 +6199,7 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; Player* p_caster = m_caster->ToPlayer(); @@ -6242,7 +6242,7 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget || !unitTarget->IsPlayer()) return; Player* player = m_caster->ToPlayer(); @@ -6319,7 +6319,7 @@ void Spell::EffectSummonRaFFriend(SpellEffIndex /*effIndex*/) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) return; - if (m_caster->GetTypeId() != TYPEID_PLAYER) + if (!m_caster->IsPlayer()) return; if (!unitTarget) diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 78fd3ce6337609..aad55356b8c21d 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -343,9 +343,9 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { - if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly + if (range == TEXT_RANGE_NORMAL) // ignores team and GM only { - if (!target || target->GetTypeId() != TYPEID_PLAYER) + if (!target || !target->IsPlayer()) return; target->ToPlayer()->GetSession()->SendPacket(data); diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index c90a6300e3f326..91ad59fe176245 100644 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -189,9 +189,9 @@ void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { - if (range == TEXT_RANGE_NORMAL) //ignores team and gmOnly + if (range == TEXT_RANGE_NORMAL) // ignores team and GM only { - if (!target || target->GetTypeId() != TYPEID_PLAYER) + if (!target || !target->IsPlayer()) return; localizer(const_cast(target->ToPlayer())); diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 852c79a3a3ed2d..93fe67cc3cf5e8 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -263,7 +263,7 @@ class debug_commandscript : public CommandScript Unit* unit = handler->getSelectedUnit(); Player* player = nullptr; - if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) + if (!unit || (!unit->IsPlayer())) { player = handler->GetSession()->GetPlayer(); } diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index b80a48f741c73f..5d689897984334 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1142,7 +1142,7 @@ class misc_commandscript : public CommandScript { if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE)) { - if (target->GetTypeId() == TYPEID_UNIT && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard + if (target->IsCreature() && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard { target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth()); } @@ -2393,7 +2393,7 @@ class misc_commandscript : public CommandScript Unit* target = handler->getSelectedUnit(); if (player->GetTarget() && target) { - if (target->GetTypeId() != TYPEID_UNIT || target->IsPet()) + if (!target->IsCreature() || target->IsPet()) { handler->SendErrorMessage(LANG_SELECT_CREATURE); return false; @@ -2745,7 +2745,7 @@ class misc_commandscript : public CommandScript } case HOME_MOTION_TYPE: { - if (unit->GetTypeId() == TYPEID_UNIT) + if (unit->IsCreature()) { handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); } @@ -2816,7 +2816,7 @@ class misc_commandscript : public CommandScript if (!target->IsAlive() || !damage) return true; - if (target->GetTypeId() == TYPEID_UNIT && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard + if (target->IsCreature() && handler->GetSession()->GetSecurity() == SEC_CONSOLE) // pussywizard target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth()); if (percent) diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index c06d9a3d94155c..a7daa30246214d 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -336,7 +336,7 @@ class npc_commandscript : public CommandScript return false; Unit* unit = handler->getSelectedUnit(); - if (!unit || unit->GetTypeId() != TYPEID_UNIT) + if (!unit || !unit->IsCreature()) { handler->SendErrorMessage(LANG_SELECT_CREATURE); return false; diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp index 51f19f74b690ee..63219693bf6412 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/boss_ambassador_flamelash.cpp @@ -221,7 +221,7 @@ class npc_burning_spirit : public CreatureScript void IsSummonedBy(WorldObject* summoner) override { - if (summoner->GetTypeId() != TYPEID_UNIT) + if (!summoner->IsCreature()) { return; } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp index a356db01a81e4e..e5ca5f2aaf8a8e 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_nefarian.cpp @@ -212,7 +212,7 @@ struct ClassCallSelector : public Acore::unary_function bool operator()(Unit const* target) const { - if (!_me || !target || target->GetTypeId() != TYPEID_PLAYER) + if (!_me || !target || !target->IsPlayer()) { return false; } @@ -1114,7 +1114,7 @@ class spell_class_call_polymorph : public SpellScript { targets.remove_if([&](WorldObject const* target) -> bool { - return target->GetTypeId() != TYPEID_PLAYER || target->ToPlayer()->IsGameMaster() || target->ToPlayer()->HasAura(SPELL_POLYMORPH); + return !target->IsPlayer() || target->ToPlayer()->IsGameMaster() || target->ToPlayer()->HasAura(SPELL_POLYMORPH); }); if (!targets.empty()) diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp index 7265ab78e54b59..c837cfc8132707 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackwingLair/boss_razorgore.cpp @@ -110,7 +110,7 @@ class boss_razorgore : public CreatureScript bool CanAIAttack(Unit const* target) const override { - if (target->GetTypeId() == TYPEID_UNIT && !secondPhase) + if (target->IsCreature() && !secondPhase) { return false; } diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp index eee82b93361d57..7cccc64796541d 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/boss_majordomo_executus.cpp @@ -587,7 +587,7 @@ class spell_hate_to_zero : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleHit(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/molten_core.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/molten_core.cpp index 9abac74756c304..9d1d0033e2a6dd 100644 --- a/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/molten_core.cpp +++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/MoltenCore/molten_core.cpp @@ -129,7 +129,7 @@ class spell_mc_play_dead_aura : public AuraScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 305091957b0833..e93336e13d2a2e 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -155,7 +155,7 @@ struct boss_priestess_delrissa : public ScriptedAI void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; if (PlayersKilled < SAY_DEATH) diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp index eb9e7777b9d395..1b3df4fd47c8c1 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter2.cpp @@ -678,7 +678,7 @@ class npc_a_special_surprise : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (PlayerGUID || who->GetTypeId() != TYPEID_PLAYER || !who->IsWithinDist(me, INTERACTION_DISTANCE)) + if (PlayerGUID || !who->IsPlayer() || !who->IsWithinDist(me, INTERACTION_DISTANCE)) return; if (MeetQuestCondition(who->ToPlayer())) diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp index c018ba6a82ff65..39de1d1c07c2c1 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter5.cpp @@ -458,7 +458,7 @@ class npc_highlord_darion_mograine : public CreatureScript { Position pos = LightOfDawnFightPos[urand(0, 9)]; if (Unit* target = cr->SelectNearbyTarget(nullptr, 10.0f)) - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->GetMotionMaster()->MoveCharge(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), me->GetSpeed(MOVE_RUN)); cr->GetMotionMaster()->MoveCharge(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), me->GetSpeed(MOVE_RUN)); } diff --git a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp index 87a22ba7c12401..0c068d0708fa61 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/boss_darkmaster_gandling.cpp @@ -389,7 +389,7 @@ class npc_risen_guardian : public CreatureScript void IsSummonedBy(WorldObject* summoner) override { - if (summoner->GetTypeId() != TYPEID_UNIT) + if (!summoner->IsCreature()) { return; } diff --git a/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp b/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp index 4ed70e573a516b..ce5bd776453389 100644 --- a/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp +++ b/src/server/scripts/EasternKingdoms/SunkenTemple/instance_sunken_temple.cpp @@ -64,7 +64,7 @@ class instance_sunken_temple : public InstanceMapScript void OnUnitDeath(Unit* unit) override { - if (unit->GetTypeId() == TYPEID_UNIT && unit->GetCreatureType() == CREATURE_TYPE_DRAGONKIN && unit->GetEntry() != NPC_SHADE_OF_ERANIKUS) + if (unit->IsCreature() && unit->GetCreatureType() == CREATURE_TYPE_DRAGONKIN && unit->GetEntry() != NPC_SHADE_OF_ERANIKUS) _dragonkinList.remove(unit->GetGUID()); if (unit->GetEntry() == NPC_JAMMAL_AN_THE_PROPHET) { diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp index d832b3088357ba..bce86175dfe40e 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_felmyst.cpp @@ -533,7 +533,7 @@ class DoorsGuidCheck public: bool operator()(WorldObject* object) const { - if (object->GetTypeId() != TYPEID_UNIT) + if (!object->IsCreature()) return true; Creature* cr = object->ToCreature(); diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp index 163b60d6deb7dd..ecf69c19fb1542 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp @@ -1088,7 +1088,7 @@ class spell_kiljaeden_sinister_reflection_clone : public SpellScript WorldObject* target = targets.front(); targets.clear(); - if (target && target->GetTypeId() == TYPEID_UNIT) + if (target && target->IsCreature()) { target->ToCreature()->AI()->SetData(1, GetCaster()->getClass()); targets.push_back(target); @@ -1133,7 +1133,7 @@ class spell_kiljaeden_darkness_aura : public AuraScript void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - if (GetUnitOwner()->GetTypeId() == TYPEID_UNIT) + if (GetUnitOwner()->IsCreature()) GetUnitOwner()->ToCreature()->AI()->DoAction(ACTION_NO_KILL_TALK); GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_DARKNESS_OF_A_THOUSAND_SOULS_DAMAGE, true); diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index 03268f04eb16be..ade6501fa9e159 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -393,7 +393,7 @@ class spell_entropius_negative_energy : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void FilterTargets(std::list& targets) diff --git a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp index 7e597eadaa2f49..6b9916e2aed847 100644 --- a/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp +++ b/src/server/scripts/EasternKingdoms/Uldaman/instance_uldaman.cpp @@ -183,7 +183,7 @@ class spell_uldaman_stoned : public SpellScriptLoader bool Load() override { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT && GetUnitOwner()->GetMapId() == MAP_ULDAMAN; + return GetUnitOwner()->IsCreature() && GetUnitOwner()->GetMapId() == MAP_ULDAMAN; } void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp index 1d14f0ff01e0b1..4698c81db9b75d 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_mandokir.cpp @@ -209,7 +209,7 @@ class boss_mandokir : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; reviveGUID = victim->GetGUID(); @@ -449,7 +449,7 @@ class boss_mandokir : public CreatureScript { if (!me || !target) return false; - if (target->GetTypeId() != TYPEID_PLAYER || !me->IsWithinLOSInMap(target)) + if (!target->IsPlayer() || !me->IsWithinLOSInMap(target)) return false; return true; })) @@ -540,7 +540,7 @@ class npc_ohgan : public CreatureScript void JustEngagedWith(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; _scheduler.Schedule(6s, 12s, [this](TaskContext context) @@ -557,7 +557,7 @@ class npc_ohgan : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; reviveGUID = victim->GetGUID(); diff --git a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp index 60ae3fa1cb7569..f9bd23b6aee832 100644 --- a/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp +++ b/src/server/scripts/EasternKingdoms/ZulGurub/boss_marli.cpp @@ -217,7 +217,7 @@ struct boss_marli : public BossAI { Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [this](Unit* target) -> bool { - if (target->GetTypeId() != TYPEID_PLAYER || target->getPowerType() != Powers::POWER_MANA) + if (!target->IsPlayer() || target->getPowerType() != Powers::POWER_MANA) return false; if (me->IsWithinMeleeRange(target) || me->GetVictim() == target) return false; diff --git a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp index 244d503b7d8dc4..103c17bb937a29 100644 --- a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp @@ -239,7 +239,7 @@ class npc_marzon_silent_blade : public CreatureScript { if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { - if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive() && !summoner->IsInCombat()) + if (summoner->IsCreature() && summoner->IsAlive() && !summoner->IsInCombat()) summoner->ToCreature()->AI()->AttackStart(who); } } @@ -253,7 +253,7 @@ class npc_marzon_silent_blade : public CreatureScript { if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { - if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive()) + if (summoner->IsCreature() && summoner->IsAlive()) summoner->ToCreature()->DisappearAndDie(); } } @@ -267,7 +267,7 @@ class npc_marzon_silent_blade : public CreatureScript if (me->IsSummon()) { Unit* summoner = me->ToTempSummon()->GetSummonerUnit(); - if (summoner && summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAIEnabled) + if (summoner && summoner->IsCreature() && summoner->IsAIEnabled) { npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI* ai = CAST_AI(npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI, summoner->GetAI()); diff --git a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp index 6e888f62204117..ad8d4a73c94519 100644 --- a/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_western_plaguelands.cpp @@ -140,7 +140,7 @@ class npc_andorhal_tower : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (!who || who->GetTypeId() != TYPEID_PLAYER) + if (!who || !who->IsPlayer()) return; if (me->FindNearestGameObject(GO_BEACON_TORCH, 10.0f)) diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp index b04f327015fddd..4a0c96b4a24e3b 100644 --- a/src/server/scripts/Events/brewfest.cpp +++ b/src/server/scripts/Events/brewfest.cpp @@ -1584,7 +1584,7 @@ struct npc_coren_direbrew : public ScriptedAI void MoveInLineOfSight(Unit* who) override { - if (!_events.IsInPhase(PHASE_ALL) || who->GetTypeId() != TYPEID_PLAYER) + if (!_events.IsInPhase(PHASE_ALL) || !who->IsPlayer()) { return; } diff --git a/src/server/scripts/Events/midsummer.cpp b/src/server/scripts/Events/midsummer.cpp index 3e4eacfc1dac10..314235ab1b756e 100644 --- a/src/server/scripts/Events/midsummer.cpp +++ b/src/server/scripts/Events/midsummer.cpp @@ -332,7 +332,7 @@ struct npc_midsummer_bonfire : public ScriptedAI void SpellHit(Unit* caster, SpellInfo const* spellInfo) override { - if (caster->GetTypeId() != TYPEID_PLAYER) + if (!caster->IsPlayer()) return; switch (spellInfo->Id) @@ -1172,7 +1172,7 @@ class spell_midsummer_juggling_torch : public SpellScript void HandleFinish() { Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) return; if (const WorldLocation* loc = GetExplTargetDest()) diff --git a/src/server/scripts/Events/pilgrims_bounty.cpp b/src/server/scripts/Events/pilgrims_bounty.cpp index 86e7ed523812bd..0a5ee60d4e61a4 100644 --- a/src/server/scripts/Events/pilgrims_bounty.cpp +++ b/src/server/scripts/Events/pilgrims_bounty.cpp @@ -571,7 +571,7 @@ class spell_pilgrims_bounty_serve_generic : public AuraScript void OnAuraRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { Unit* target = GetTarget(); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->AI()->DoAction(GetSpellInfo()->Id); } diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp index 2a21d72053a494..5081432e50694c 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_aeonus.cpp @@ -90,7 +90,7 @@ struct boss_aeonus : public BossAI void MoveInLineOfSight(Unit* who) override { - if (who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_TIME_KEEPER) + if (who->IsCreature() && who->GetEntry() == NPC_TIME_KEEPER) { if (me->IsWithinDistInMap(who, 20.0f)) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp index 3f2aaaf13b2c82..c835be08ef7d53 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_chrono_lord_deja.cpp @@ -79,7 +79,7 @@ enum Spells void MoveInLineOfSight(Unit* who) override { - if (who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_TIME_KEEPER) + if (who->IsCreature() && who->GetEntry() == NPC_TIME_KEEPER) { if (me->IsWithinDistInMap(who, 20.0f)) { diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp index b5ec43ce7e24b6..35b7f2654df81e 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/boss_temporus.cpp @@ -90,7 +90,7 @@ struct boss_temporus : public BossAI void MoveInLineOfSight(Unit* who) override { - if (who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_TIME_KEEPER) + if (who->IsCreature() && who->GetEntry() == NPC_TIME_KEEPER) { if (me->IsWithinDistInMap(who, 20.0f)) { diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp index 18403749218c0e..f7ec9c8380ed67 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_bug_trio.cpp @@ -367,7 +367,7 @@ struct boss_vem : public boss_bug_trio { if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [this](Unit* target) -> bool { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return false; if (me->IsWithinMeleeRange(target) || target == me->GetVictim()) return false; diff --git a/src/server/scripts/Kalimdor/zone_durotar.cpp b/src/server/scripts/Kalimdor/zone_durotar.cpp index b7206f9d9b0ca4..14076a4d5e40a6 100644 --- a/src/server/scripts/Kalimdor/zone_durotar.cpp +++ b/src/server/scripts/Kalimdor/zone_durotar.cpp @@ -180,7 +180,7 @@ class npc_tiger_matriarch : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_UNIT || !victim->IsSummon()) + if (!victim->IsCreature() || !victim->IsSummon()) return; if (Unit* vehSummoner = victim->ToTempSummon()->GetSummonerUnit()) diff --git a/src/server/scripts/Kalimdor/zone_the_barrens.cpp b/src/server/scripts/Kalimdor/zone_the_barrens.cpp index 6d4fc105e6c402..477bbea297412c 100644 --- a/src/server/scripts/Kalimdor/zone_the_barrens.cpp +++ b/src/server/scripts/Kalimdor/zone_the_barrens.cpp @@ -124,7 +124,7 @@ class npc_gilthares : public CreatureScript return; //only aggro text if not player and only in this area - if (who->GetTypeId() != TYPEID_PLAYER && me->GetAreaId() == AREA_MERCHANT_COAST) + if (!who->IsPlayer() && me->GetAreaId() == AREA_MERCHANT_COAST) { //appears to be pretty much random (possible only if escorter not in combat with who yet?) Talk(SAY_GIL_AGGRO, who); @@ -325,7 +325,7 @@ class npc_twiggy_flathead : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (!who->IsAlive() || EventInProgress || who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsAlive() || EventInProgress || !who->IsPlayer()) return; if (me->IsWithinDistInMap(who, 10.0f) && who->ToPlayer()->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp index d599c462cecb1c..c32f6490c249ee 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_krikthir_the_gatewatcher.cpp @@ -95,7 +95,7 @@ class boss_krik_thir : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; if (!_initTalk) diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp index 54a382f5b8ae60..f386515dcac33d 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_herald_volazj.cpp @@ -347,7 +347,7 @@ class spell_herald_volzaj_insanity : public SpellScript { PrepareSpellScript(spell_herald_volzaj_insanity); - bool Load() override { return GetCaster()->GetTypeId() == TYPEID_UNIT; } + bool Load() override { return GetCaster()->IsCreature(); } void HandleDummyEffect(std::list& targets) { @@ -362,7 +362,7 @@ class spell_herald_volzaj_insanity : public SpellScript { targets.remove_if([this](WorldObject* targetObj) -> bool { - return !targetObj || targetObj->GetTypeId() != TYPEID_PLAYER || !targetObj->ToPlayer()->IsInCombatWith(GetCaster()) || + return !targetObj || !targetObj->IsPlayer() || !targetObj->ToPlayer()->IsInCombatWith(GetCaster()) || targetObj->GetDistance(GetCaster()) >= (MAX_VISIBILITY_DISTANCE * 2); }); } @@ -466,7 +466,7 @@ class spell_volazj_whisper : public SpellScript }); } - bool Load() override { return GetCaster()->GetTypeId() == TYPEID_UNIT; } + bool Load() override { return GetCaster()->IsCreature(); } void HandleScriptEffect(SpellEffIndex /* effIndex */) { diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp index 934e4b3e7aec8f..574db0338869e0 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_jedoga_shadowseeker.cpp @@ -333,7 +333,7 @@ struct boss_jedoga_shadowseeker : public BossAI void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) { return; } diff --git a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp index 2bf0969925a47c..c8e970d078c83d 100644 --- a/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/ahnkahet/boss_prince_taldaram.cpp @@ -307,7 +307,7 @@ struct boss_taldaram : public BossAI void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) { return; } diff --git a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp index fe4ad7c8a4bad7..6428031cf4705b 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/ObsidianSanctum/boss_sartharion.cpp @@ -925,7 +925,7 @@ struct boss_sartharion_dragonAI : public BossAI void KilledUnit(Unit* victim) final { - if (victim->GetTypeId() != TYPEID_PLAYER || urand(0, 2)) + if (!victim->IsPlayer() || urand(0, 2)) { return; } diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 7e4e3d92a95892..a63f52bdaa3489 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -1053,7 +1053,7 @@ class spell_halion_twilight_phasing : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void Phase() @@ -1116,7 +1116,7 @@ class spell_halion_twilight_realm_aura : public AuraScript return; target->RemoveAurasDueToSpell(SPELL_FIERY_COMBUSTION, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); - if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + if (!GetTarget()->IsPlayer()) return; GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500)); } @@ -1149,7 +1149,7 @@ class spell_halion_leave_twilight_realm_aura : public AuraScript { GetTarget()->RemoveAurasDueToSpell(SPELL_TWILIGHT_REALM); - if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + if (!GetTarget()->IsPlayer()) return; GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500)); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp index 554ae002c367a2..63b00243582e7a 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp @@ -765,7 +765,7 @@ class spell_toc5_light_rain : public SpellScript { for( std::list::iterator itr = targets.begin(); itr != targets.end(); ) { - if ((*itr)->GetTypeId() == TYPEID_UNIT) + if ((*itr)->IsCreature()) if ((*itr)->ToCreature()->GetEntry() == NPC_FOUNTAIN_OF_LIGHT) { targets.erase(itr); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp index cb8d3be454f2b8..7ed03a36d6a36e 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp @@ -691,7 +691,7 @@ class boss_grand_champion : public CreatureScript if( me->GetExactDist(plr) <= 5.0f ) if( Vehicle* v = plr->GetVehicle() ) if( Unit* c = v->GetBase() ) - if( c->GetTypeId() == TYPEID_UNIT && c->ToCreature()->GetEntry() == (pInstance->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? VEHICLE_ARGENT_BATTLEWORG : VEHICLE_ARGENT_WARHORSE) ) + if( c->IsCreature() && c->ToCreature()->GetEntry() == (pInstance->GetData(DATA_TEAMID_IN_INSTANCE) == TEAM_HORDE ? VEHICLE_ARGENT_BATTLEWORG : VEHICLE_ARGENT_WARHORSE) ) { me->GetMotionMaster()->MovementExpired(); me->GetMotionMaster()->MoveIdle(); diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp index 746728d3e14af7..76b54fe59f88b7 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/instance_trial_of_the_champion.cpp @@ -1156,7 +1156,7 @@ class instance_trial_of_the_champion : public InstanceMapScript { NPC_BlackKnightGUID = bk->GetGUID(); bk->SendMovementFlagUpdate(); // put him on vehicle visually - if( bk->GetTypeId() == TYPEID_UNIT ) + if( bk->IsCreature() ) bk->ToCreature()->SetReactState(REACT_PASSIVE); } diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp index 6dfdf56a081c5c..bb41e7eeee3574 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_anubarak_trial.cpp @@ -400,7 +400,7 @@ class boss_anubarak_trial : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER || me->GetExactDistSq(who) > 6400.0f) // 80yd*80yd + if (!who->IsPlayer() || me->GetExactDistSq(who) > 6400.0f) // 80yd*80yd return; if (me->getStandState() != UNIT_STAND_STATE_STAND) @@ -846,7 +846,7 @@ class spell_pursuing_spikes : public SpellScriptLoader { target->UpdatePosition(*c, false); target->CastCustomSpell(SPELL_SPIKE_FAIL, SPELLVALUE_MAX_TARGETS, 1); - if( target->GetTypeId() == TYPEID_UNIT ) + if( target->IsCreature() ) target->ToCreature()->AI()->DoAction(-1); Remove(); return; diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp index 5423cf88157e07..01a4a72030f40b 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_northrend_beasts.cpp @@ -172,7 +172,7 @@ class npc_snobold_vassal : public CreatureScript break; case EVENT_SPELL_FIRE_BOMB: { - if( t->GetTypeId() != TYPEID_PLAYER && pInstance ) + if( !t->IsPlayer() && pInstance ) { GuidVector validPlayers; Map::PlayerList const& pl = me->GetMap()->GetPlayers(); @@ -342,7 +342,7 @@ class boss_gormok : public CreatureScript if( Vehicle* vk = me->GetVehicleKit() ) if( Unit* snobold = vk->GetPassenger(4) ) { - if( snobold->GetTypeId() == TYPEID_UNIT ) + if( snobold->IsCreature() ) { CAST_AI(npc_snobold_vassal::npc_snobold_vassalAI, snobold->ToCreature()->AI())->TargetGUID = PlayerGUID; snobold->ToCreature()->AI()->AttackStart(p); @@ -357,7 +357,7 @@ class boss_gormok : public CreatureScript { events.RescheduleEvent(EVENT_PICK_SNOBOLD_TARGET, 5s); if( Unit* snobold = vk->GetPassenger(4) ) - if( snobold->GetTypeId() == TYPEID_UNIT ) + if( snobold->IsCreature() ) { bool needDespawn = true; for( uint8 i = 0; i < 4; ++i ) diff --git a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp index 2710c60634c1be..8e872f2ec781be 100644 --- a/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp +++ b/src/server/scripts/Northrend/DraktharonKeep/instance_drak_tharon_keep.cpp @@ -84,7 +84,7 @@ class spell_dtk_raise_dead_aura : public AuraScript bool Load() override { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; + return GetUnitOwner()->IsCreature(); } void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp index 70e2fb391f2c5a..076d0c4ac86f88 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_devourer_of_souls.cpp @@ -258,7 +258,7 @@ class boss_devourer_of_souls : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; int32 textId = 0; @@ -347,7 +347,7 @@ class spell_wailing_souls_periodic_aura : public AuraScript { t->SetControlled(false, UNIT_STATE_ROOT); t->DisableRotate(false); - if (t->GetTypeId() == TYPEID_UNIT) + if (t->IsCreature()) t->ToCreature()->SetReactState(REACT_AGGRESSIVE); if (t->GetVictim()) { diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp index 12fc5a6f0425db..12eb4361cbaf31 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_forgemaster_garfrost.cpp @@ -333,7 +333,7 @@ class spell_garfrost_permafrost : public SpellScript if (valid) { if (Aura* aur = target->ToUnit()->GetAura(70336)) - if (aur->GetStackAmount() >= 10 && caster->GetTypeId() == TYPEID_UNIT) + if (aur->GetStackAmount() >= 10 && caster->IsCreature()) caster->ToCreature()->AI()->SetData(1, aur->GetStackAmount()); targetList.push_back(*itrU); } diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp index d2babe69aa9004..3148377a63df0e 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/boss_krickandick.cpp @@ -470,7 +470,7 @@ class spell_krick_explosive_barrage_aura : public AuraScript { PreventDefaultAction(); if (Unit* caster = GetCaster()) - if (caster->GetTypeId() == TYPEID_UNIT) + if (caster->IsCreature()) { Map::PlayerList const& players = caster->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) @@ -505,7 +505,7 @@ class spell_exploding_orb_auto_grow_aura : public AuraScript target->RemoveAurasDueToSpell(SPELL_HASTY_GROW); target->RemoveAurasDueToSpell(SPELL_AUTO_GROW); target->RemoveAurasDueToSpell(SPELL_EXPLODING_ORB_VISUAL); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->DespawnOrUnsummon(2000); } } diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp index 3dcfa3e4246910..a4cdb067086676 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/pit_of_saron.cpp @@ -1405,7 +1405,7 @@ class spell_pos_rimefang_frost_nova : public SpellScript if (Unit* caster = GetCaster()) { Unit::Kill(caster, target); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->DespawnOrUnsummon(30000); } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp index c1193e442fe82f..b344f352f8b31c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_prince_council.cpp @@ -343,7 +343,7 @@ class boss_prince_keleseth_icc : public CreatureScript void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (damage > RAID_MODE(23000, 25000, 23000, 25000)) @@ -613,7 +613,7 @@ class boss_prince_taldaram_icc : public CreatureScript void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (damage > RAID_MODE(23000, 25000, 23000, 25000)) @@ -907,7 +907,7 @@ class boss_prince_valanar_icc : public CreatureScript void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; if (damage > RAID_MODE(23000, 25000, 23000, 25000)) @@ -1102,7 +1102,7 @@ class npc_blood_queen_lana_thel : public CreatureScript if (_introDone) return; - if (who->GetTypeId() != TYPEID_PLAYER || me->GetExactDist2d(who) > 100.0f) + if (!who->IsPlayer() || me->GetExactDist2d(who) > 100.0f) { return; } @@ -1335,7 +1335,7 @@ class npc_ball_of_flame : public CreatureScript void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) { return; } @@ -1506,7 +1506,7 @@ class spell_taldaram_summon_flame_ball : public SpellScript bool Load() override { - if (GetCaster()->GetTypeId() != TYPEID_UNIT) + if (!GetCaster()->IsCreature()) { return false; } @@ -1573,7 +1573,7 @@ class spell_valanar_kinetic_bomb_aura : public AuraScript void HandleDummyTick(AuraEffect const* /*aurEff*/) { Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT) + if (!target->IsCreature()) return; if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true)) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index 7686841c62eb84..57239edd3c442f 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -823,7 +823,7 @@ class spell_blood_queen_vampiric_bite : public SpellScript return; } - if (GetCaster()->GetTypeId() != TYPEID_PLAYER || GetCaster()->GetMapId() != 631) + if (!GetCaster()->IsPlayer() || GetCaster()->GetMapId() != 631) return; InstanceScript* instance = GetCaster()->GetInstanceScript(); if (!instance || instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) != IN_PROGRESS) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index eb84105c727839..78f23ff952c54b 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -1259,7 +1259,7 @@ class spell_deathbringer_boiling_blood : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void FilterTargets(std::list& targets) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp index 0073e7cb5f4d75..52b5095a9990f1 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_festergut.cpp @@ -290,13 +290,13 @@ class spell_festergut_pungent_blight : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleScript(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_UNIT) + if (!caster->IsCreature()) return; // Get Inhaled Blight id for our difficulty @@ -383,7 +383,7 @@ class achievement_flu_shot_shortage : public AchievementCriteriaScript bool OnCheck(Player* /*source*/, Unit* target, uint32 /*criteria_id*/) override { - if (target && target->GetTypeId() == TYPEID_UNIT) + if (target && target->IsCreature()) return target->ToCreature()->AI()->GetData(DATA_INOCULATED_STACK) < 3; return false; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index cac3574579f90a..c70c69018d6681 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -602,7 +602,7 @@ class npc_gunship : public CreatureScript Transport::PassengerSet const& passengers = t->GetStaticPassengers(); for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr) { - if ((*itr)->GetTypeId() != TYPEID_UNIT || (*itr)->GetEntry() != NPC_GUNSHIP_HULL) + if (!(*itr)->IsCreature() || (*itr)->GetEntry() != NPC_GUNSHIP_HULL) continue; (*itr)->ToCreature()->CastSpell((*itr)->ToCreature(), explosionSpell, true); } @@ -615,7 +615,7 @@ class npc_gunship : public CreatureScript Transport::PassengerSet const& passengers = t->GetStaticPassengers(); for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr) { - if ((*itr)->GetTypeId() != TYPEID_UNIT || (*itr)->GetEntry() != cannonEntry) + if (!(*itr)->IsCreature() || (*itr)->GetEntry() != cannonEntry) continue; Creature* cannon = (*itr)->ToCreature(); cannon->CastSpell(cannon, SPELL_EJECT_ALL_PASSENGERS, true); @@ -661,7 +661,7 @@ class npc_gunship : public CreatureScript Transport::PassengerSet const& passengers = t->GetPassengers(); for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr) { - if ((*itr)->GetTypeId() != TYPEID_UNIT) + if (!(*itr)->IsCreature()) continue; Creature* c = (*itr)->ToCreature(); if (c->GetEntry() == NPC_SKYBREAKER_MARINE || c->GetEntry() == NPC_SKYBREAKER_SERGEANT || c->GetEntry() == NPC_KOR_KRON_REAVER || c->GetEntry() == NPC_KOR_KRON_SERGEANT) @@ -2080,7 +2080,7 @@ class spell_igb_check_for_players : public SpellScript bool Load() override { _playerCount = 0; - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void CountTargets(std::list& targets) @@ -2302,7 +2302,7 @@ class spell_igb_cannon_blast : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void CalculatePower() @@ -2467,7 +2467,7 @@ class IgbArtilleryCheck bool operator()(WorldObject* unit) { - return unit->GetTypeId() != TYPEID_PLAYER || unit->GetPositionZ() > 478.0f || !unit->GetTransport() || unit->GetTransport()->GetEntry() != _entry + return !unit->IsPlayer() || unit->GetPositionZ() > 478.0f || !unit->GetTransport() || unit->GetTransport()->GetEntry() != _entry || unit->GetMapHeight(unit->GetPhaseMask(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()) < 465.0f; } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index 17d68df61e288c..f67ad63330bc8c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -84,7 +84,7 @@ struct BoneStormMoveTargetSelector if (target->GetExactDist(_source) > 175.0f) return false; - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return false; if (target->GetPositionX() > -337.0f) @@ -415,7 +415,7 @@ class npc_bone_spike : public CreatureScript { if (Unit* u = v->GetBase()) { - if (u->GetEntry() == NPC_BONE_SPIKE && u->GetTypeId() == TYPEID_UNIT) + if (u->GetEntry() == NPC_BONE_SPIKE && u->IsCreature()) { u->ToCreature()->AI()->DoAction(-1337); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 8753fefb43483c..64852ccb6ac067 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -209,7 +209,7 @@ struct MalleableGooSelector bool operator()(Unit const* target) const { - if (!me || !target || target->GetTypeId() != TYPEID_PLAYER) + if (!me || !target || !target->IsPlayer()) return false; if (me->IsWithinCombatRange(target, 7.0f)) @@ -952,7 +952,7 @@ class spell_putricide_unstable_experiment : public SpellScript void HandleScript(SpellEffIndex effIndex) { PreventHitDefaultEffect(effIndex); - if (GetCaster()->GetTypeId() != TYPEID_UNIT) + if (!GetCaster()->IsCreature()) return; Creature* creature = GetCaster()->ToCreature(); @@ -1044,7 +1044,7 @@ class spell_putricide_ooze_channel : public SpellScript bool Load() override { _target = nullptr; - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void SelectTarget(std::list& targets) @@ -1318,7 +1318,7 @@ class spell_putricide_mutation_init : public SpellScript if (!GetExplTargetUnit()) return SPELL_FAILED_BAD_TARGETS; - if (GetExplTargetUnit()->GetTypeId() != TYPEID_PLAYER) + if (!GetExplTargetUnit()->IsPlayer()) return SPELL_FAILED_TARGET_NOT_PLAYER; SpellCustomErrors extension = SPELL_CUSTOM_ERROR_NONE; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index b0b845e3d2e2cc..e9e7acfbd4a9ba 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -360,7 +360,7 @@ class npc_little_ooze : public CreatureScript if (!summoner) return; - if (summoner->GetTypeId() != TYPEID_UNIT) + if (!summoner->IsCreature()) { return; } @@ -651,7 +651,7 @@ class spell_rotface_large_ooze_combine : public SpellScript if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE))) if (rotface->IsAlive()) { - if (GetCaster()->GetTypeId() == TYPEID_UNIT) + if (GetCaster()->IsCreature()) GetCaster()->ToCreature()->AI()->Talk(EMOTE_UNSTABLE_EXPLOSION); rotface->AI()->Talk(SAY_UNSTABLE_EXPLOSION); } @@ -708,7 +708,7 @@ class spell_rotface_large_ooze_buff_combine : public SpellScript if (Creature* rotface = ObjectAccessor::GetCreature(*GetCaster(), instance->GetGuidData(DATA_ROTFACE))) if (rotface->IsAlive()) { - if (GetCaster()->GetTypeId() == TYPEID_UNIT) + if (GetCaster()->IsCreature()) GetCaster()->ToCreature()->AI()->Talk(EMOTE_UNSTABLE_EXPLOSION); rotface->AI()->Talk(SAY_UNSTABLE_EXPLOSION); } @@ -792,7 +792,7 @@ class spell_rotface_unstable_ooze_explosion_suicide_aura : public AuraScript { PreventDefaultAction(); Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT) + if (!target->IsCreature()) return; target->SetVisible(false); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 1295c9d1ae47d8..85a564b39883a9 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -252,7 +252,7 @@ struct LastPhaseIceTombTargetSelector if (target->GetExactDist(_source) > 80.0f) return false; - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return false; if (target->HasAura(SPELL_FROST_IMBUED_BLADE)) @@ -1154,7 +1154,7 @@ class spell_sindragosa_soul_preservation_aura : public AuraScript { s->CastSpell(s, 72466, true); s->RemoveAurasDueToSpell(72424); - if (s->GetTypeId() == TYPEID_UNIT) s->ToCreature()->SetLootMode(3); + if (s->IsCreature()) s->ToCreature()->SetLootMode(3); SetDuration(1); } } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index 6285b35003633c..2b99e1127d51ab 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -386,7 +386,7 @@ struct ShadowTrapLKTargetSelector return false; if (!target->IsAlive()) return false; - if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) + if (_playerOnly && !target->IsPlayer()) return false; if (_maxDist && _source->GetExactDist(target) > _maxDist) return false; @@ -412,7 +412,7 @@ struct NonTankLKTargetSelector return false; if (!target->IsAlive()) return false; - if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) + if (_playerOnly && !target->IsPlayer()) return false; if (target == _source->GetVictim()) return false; @@ -446,7 +446,7 @@ struct DefileTargetSelector return false; if (!target->IsAlive()) return false; - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return false; if (_source->GetExactDist(target) > 100.0f) return false; @@ -600,7 +600,7 @@ class NecroticPlagueTargetCheck bool operator()(Unit* unit) const { - if (!unit || unit->GetTypeId() != TYPEID_PLAYER || unit == _sourceObj || _sourceObj->GetVictim() == unit || !unit->isTargetableForAttack()) + if (!unit || !unit->IsPlayer() || unit == _sourceObj || _sourceObj->GetVictim() == unit || !unit->isTargetableForAttack()) return false; if (unit->HasAura(SPELL_PLAGUE_AVOIDANCE) || unit->HasAura(SPELL_BOSS_HITTIN_YA_AURA) || unit->HasAura(_notAura1) || unit->HasAura(_notAura2)) return false; @@ -2078,7 +2078,7 @@ class spell_the_lich_king_shadow_trap_periodic : public SpellScript GetCaster()->CastSpell((Unit*)nullptr, SPELL_SHADOW_TRAP_KNOCKBACK, true); if (Aura* a = GetCaster()->GetAura(SPELL_SHADOW_TRAP_AURA)) a->SetDuration(0); - if (GetCaster()->GetTypeId() == TYPEID_UNIT) + if (GetCaster()->IsCreature()) GetCaster()->ToCreature()->DespawnOrUnsummon(3000); } @@ -2102,7 +2102,7 @@ class spell_the_lich_king_ice_burst_target_search : public SpellScript if (unitList.empty()) return; - if (GetCaster()->GetTypeId() == TYPEID_UNIT) + if (GetCaster()->IsCreature()) GetCaster()->ToCreature()->AI()->DoAction(-1); } @@ -2336,7 +2336,7 @@ class VehicleCheck public: bool operator()(WorldObject* unit) { - return (unit->GetTypeId() != TYPEID_UNIT && unit->GetTypeId() != TYPEID_PLAYER) || unit->ToUnit()->GetVehicle(); + return (!unit->IsCreature() && !unit->IsPlayer()) || unit->ToUnit()->GetVehicle(); } }; @@ -2804,7 +2804,7 @@ class spell_the_lich_king_vile_spirit_move_target_search : public SpellScript bool Load() override { _target = nullptr; - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void SelectTarget(std::list& targets) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index 86adf4725b5c84..df7969c4c36c81 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -967,7 +967,7 @@ class npc_crok_scourgebane : public CreatureScript bool CanAIAttack(Unit const* target) const override { // do not see targets inside Frostwing Halls when we are not there - return target->GetTypeId() != TYPEID_PLAYER && (me->GetPositionY() > 2660.0f) == (target->GetPositionY() > 2660.0f) && target->GetEntry() != NPC_SINDRAGOSA; + return !target->IsPlayer() && (me->GetPositionY() > 2660.0f) == (target->GetPositionY() > 2660.0f) && target->GetEntry() != NPC_SINDRAGOSA; } private: @@ -1757,7 +1757,7 @@ class npc_frostwing_vrykul : public CreatureScript void SpellHitTarget(Unit* c, SpellInfo const* spell) override { - if (spell->Id == 71306 && c->GetTypeId() == TYPEID_UNIT) // Twisted Winds + if (spell->Id == 71306 && c->IsCreature()) // Twisted Winds { Position myPos = me->GetPosition(); me->NearTeleportTo(c->GetPositionX(), c->GetPositionY(), c->GetPositionZ(), c->GetOrientation()); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp index f4f6ca1d6e6fa3..57edeb32ff9f78 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_anubrekhan.cpp @@ -146,7 +146,7 @@ class boss_anubrekhan : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp index db38740c3684da..ad9c534a6a3b7f 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_faerlina.cpp @@ -143,7 +143,7 @@ class boss_faerlina : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; if (!urand(0, 3)) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp index 3ba4157b5101a6..556371bb2db9f1 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_four_horsemen.cpp @@ -258,7 +258,7 @@ class boss_four_horsemen : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index b5211f9132774d..ba1e94e1a3f866 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -323,7 +323,7 @@ class boss_gothik : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; Talk(SAY_KILL); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp index 5dd6374b04a8c0..c91f67ba73022e 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_heigan.cpp @@ -97,7 +97,7 @@ class boss_heigan : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp index 725e0c0f12fa52..72588d466ffa1d 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_kelthuzad.cpp @@ -263,7 +263,7 @@ class boss_kelthuzad : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; Talk(SAY_SLAY); @@ -565,7 +565,7 @@ class boss_kelthuzad_minion : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER && !who->IsPet()) + if (!who->IsPlayer() && !who->IsPet()) return; ScriptedAI::MoveInLineOfSight(who); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp index be528f52973efc..c461384fd88238 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_noth.cpp @@ -206,7 +206,7 @@ class boss_noth : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp index 0ae9feaf574bfa..aa61c5fb1211d1 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_patchwerk.cpp @@ -78,7 +78,7 @@ class boss_patchwerk : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; if (!urand(0, 3)) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp b/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp index 53a488598daad4..77a687572803ca 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_razuvious.cpp @@ -222,7 +222,7 @@ class boss_razuvious : public CreatureScript void DamageTaken(Unit* who, uint32& damage, DamageEffectType, SpellSchoolMask) override { // Damage done by the controlled Death Knight understudies should also count toward damage done by players - if(who && who->GetTypeId() == TYPEID_UNIT && who->GetEntry() == NPC_DEATH_KNIGHT_UNDERSTUDY) + if(who && who->IsCreature() && who->GetEntry() == NPC_DEATH_KNIGHT_UNDERSTUDY) { me->LowerPlayerDamageReq(damage); } diff --git a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp index 58ec8e4ce96a4f..dd25921e90a222 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_thaddius.cpp @@ -210,7 +210,7 @@ class boss_thaddius : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; Talk(SAY_SLAY); @@ -490,7 +490,7 @@ class boss_thaddius_summon : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; if (pInstance) @@ -648,7 +648,7 @@ class spell_thaddius_pos_neg_charge : public SpellScript if (!target) return; - if (target->HasAura(GetTriggeringSpell()->Id) || target->GetTypeId() != TYPEID_PLAYER) + if (target->HasAura(GetTriggeringSpell()->Id) || !target->IsPlayer()) { SetHitDamage(0); } diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp index c3efec7bf4d46c..16257929219518 100644 --- a/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp +++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_magus_telestra.cpp @@ -245,7 +245,7 @@ class spell_boss_magus_telestra_summon_telestra_clones_aura : public AuraScript bool Load() override { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; + return GetUnitOwner()->IsCreature(); } void HandleApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp index 958af946493aad..0e54a5e370b9bb 100644 --- a/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp +++ b/src/server/scripts/Northrend/Nexus/Oculus/oculus.cpp @@ -354,7 +354,7 @@ class npc_oculus_drake : public CreatureScript void IsSummonedBy(WorldObject* summoner) override { - if (summoner->GetTypeId() != TYPEID_PLAYER) + if (!summoner->IsPlayer()) { return; } @@ -392,7 +392,7 @@ class npc_oculus_drake : public CreatureScript void PassengerBoarded(Unit* passenger, int8 /*seatid*/, bool add) override { - if (passenger->GetTypeId() != TYPEID_PLAYER) + if (!passenger->IsPlayer()) return; if (add) diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp index 919cdbcc86a673..9435ba64914214 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_bjarngrim.cpp @@ -197,7 +197,7 @@ class boss_bjarngrim : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp index 2624f55ad79aea..0524fd43fd91b6 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_ionar.cpp @@ -132,7 +132,7 @@ class boss_ionar : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp index e41c57ace08f73..0ad61d242d5a54 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_loken.cpp @@ -162,7 +162,7 @@ class boss_loken : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp index 3de2a126348832..c64594b1146403 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfLightning/boss_volkhan.cpp @@ -183,7 +183,7 @@ class boss_volkhan : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp index 3374fad99bceb4..9eec77e6221d85 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_algalon_the_observer.cpp @@ -401,7 +401,7 @@ class boss_algalon_the_observer : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER || urand(0, 2)) + if (!victim->IsPlayer() || urand(0, 2)) return; Talk(SAY_ALGALON_KILL); @@ -1018,7 +1018,7 @@ class npc_living_constellation : public CreatureScript void SpellHit(Unit* caster, SpellInfo const* spell) override { - if (spell->Id != SPELL_CONSTELLATION_PHASE_EFFECT || caster->GetTypeId() != TYPEID_UNIT) + if (spell->Id != SPELL_CONSTELLATION_PHASE_EFFECT || !caster->IsCreature()) return; if (InstanceScript* instance = me->GetInstanceScript()) diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp index aaef1709be08d3..8007e94d9464c3 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_assembly_of_iron.cpp @@ -310,7 +310,7 @@ class boss_steelbreaker : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; if (_phase == 3) @@ -488,7 +488,7 @@ class boss_runemaster_molgeim : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER) + if (!who->IsPlayer()) return; Talk(SAY_MOLGEIM_SLAY); @@ -706,7 +706,7 @@ class boss_stormcaller_brundir : public CreatureScript void KilledUnit(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER || urand(0, 2)) + if (!who->IsPlayer() || urand(0, 2)) return; Talk(SAY_BRUNDIR_SLAY); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp index b1b8fb589e0ded..10111679870706 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_auriaya.cpp @@ -194,7 +194,7 @@ class boss_auriaya : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER || urand(0, 2)) + if (!victim->IsPlayer() || urand(0, 2)) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp index 471f6784d21533..7b1ebde90611ac 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_flame_leviathan.cpp @@ -447,7 +447,7 @@ class boss_flame_leviathan : public CreatureScript case EVENT_REINSTALL: for (uint8 i = RAID_MODE(0, 2); i < 4; ++i) if (Unit* seat = vehicle->GetPassenger(i)) - if (seat->GetTypeId() == TYPEID_UNIT) + if (seat->IsCreature()) seat->ToCreature()->AI()->EnterEvadeMode(); Talk(FLAME_LEVIATHAN_EMOTE_REACTIVATE); return; @@ -758,7 +758,7 @@ class boss_flame_leviathan_seat : public CreatureScript void PassengerBoarded(Unit* who, int8 seatId, bool apply) override { - if (who->GetTypeId() != TYPEID_PLAYER || !me->GetVehicle()) + if (!who->IsPlayer() || !me->GetVehicle()) return; who->ApplySpellImmune(63847, IMMUNITY_ID, 63847, apply); // SPELL_FLAME_VENTS_TRIGGER @@ -780,7 +780,7 @@ class boss_flame_leviathan_seat : public CreatureScript { turret->ReplaceAllUnitFlags(UNIT_FLAG_NOT_SELECTABLE); turret->SetImmuneToAll(true); - if (turret->GetTypeId() == TYPEID_UNIT) + if (turret->IsCreature()) turret->ToCreature()->AI()->EnterEvadeMode(); } } @@ -829,7 +829,7 @@ class boss_flame_leviathan_defense_turret : public CreatureScript bool CanAIAttack(Unit const* who) const override { - if (!who || who->GetTypeId() != TYPEID_PLAYER || !who->GetVehicle() || who->GetVehicleBase()->GetEntry() != NPC_SEAT) + if (!who || !who->IsPlayer() || !who->GetVehicle() || who->GetVehicleBase()->GetEntry() != NPC_SEAT) return false; return true; } @@ -1231,7 +1231,7 @@ class npc_brann_radio : public CreatureScript { if (!_lock) { - if (who->GetTypeId() != TYPEID_PLAYER && !who->IsVehicle()) + if (!who->IsPlayer() && !who->IsVehicle()) return; // MIMIRON @@ -1753,7 +1753,7 @@ class spell_vehicle_grab_pyrite : public SpellScript GetCaster()->CastSpell(parent, SPELL_ADD_PYRITE, true); target->CastSpell(seat, GetEffectValue()); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->DespawnOrUnsummon(1300); } } @@ -1927,7 +1927,7 @@ class spell_demolisher_ride_vehicle : public SpellScript SpellCastResult CheckCast() { - if (GetCaster()->GetTypeId() != TYPEID_PLAYER) + if (!GetCaster()->IsPlayer()) return SPELL_CAST_OK; Unit* target = this->GetExplTargetUnit(); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp index 92581c758f6ee5..aa441954096aab 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_freya.cpp @@ -307,7 +307,7 @@ class boss_freya : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER || urand(0, 2)) + if (!victim->IsPlayer() || urand(0, 2)) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp index 872d9340dc3016..be71517da32e7e 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_general_vezax.cpp @@ -486,7 +486,7 @@ class spell_aura_of_despair_aura : public AuraScript if (Unit* caster = GetCaster()) if (Unit* target = GetTarget()) { - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; target->CastSpell(target, SPELL_AURA_OF_DESPAIR_2, true); @@ -614,7 +614,7 @@ class achievement_smell_saronite : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_VEZAX && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(1); + return target && target->GetEntry() == NPC_VEZAX && target->IsCreature() && target->ToCreature()->AI()->GetData(1); } }; @@ -625,7 +625,7 @@ class achievement_shadowdodger : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_VEZAX && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(2); + return target && target->GetEntry() == NPC_VEZAX && target->IsCreature() && target->ToCreature()->AI()->GetData(2); } }; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index e526e32991185f..7c1dbd1364dbef 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp @@ -578,7 +578,7 @@ class boss_hodir : public CreatureScript { if (t->IsPlayer()) return !t->HasAura(SPELL_FLASH_FREEZE_TRAPPED_PLAYER); - else if (t->GetTypeId() == TYPEID_UNIT) + else if (t->IsCreature()) return !t->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC); return true; @@ -702,7 +702,7 @@ class npc_ulduar_flash_freeze : public CreatureScript { if (Unit* s = me->ToTempSummon()->GetSummonerUnit()) { - if ((s->IsPlayer() && !s->HasAura(SPELL_FLASH_FREEZE_TRAPPED_PLAYER)) || (s->GetTypeId() == TYPEID_UNIT && !s->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC))) + if ((s->IsPlayer() && !s->HasAura(SPELL_FLASH_FREEZE_TRAPPED_PLAYER)) || (s->IsCreature() && !s->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC))) me->DespawnOrUnsummon(2000); else if (s->IsPlayer()) if (InstanceScript* instanceScript = me->GetInstanceScript()) @@ -1354,14 +1354,14 @@ class spell_hodir_flash_freeze_aura : public AuraScript { Unit* target = GetTarget(); Unit* caster = GetCaster(); - if (!target || !caster || caster->GetTypeId() != TYPEID_UNIT) + if (!target || !caster || !caster->IsCreature()) return; if (Aura* aur = target->GetAura(target->IsPlayer() ? SPELL_FLASH_FREEZE_TRAPPED_PLAYER : SPELL_FLASH_FREEZE_TRAPPED_NPC)) { if (Unit* caster2 = aur->GetCaster()) { - if (caster2->GetTypeId() == TYPEID_UNIT) + if (caster2->IsCreature()) { caster2->ToCreature()->DespawnOrUnsummon(); } @@ -1378,7 +1378,7 @@ class spell_hodir_flash_freeze_aura : public AuraScript caster->ToCreature()->AI()->JustSummoned(c); } } - else if (target->GetTypeId() == TYPEID_UNIT) + else if (target->IsCreature()) { if( Creature* c = target->SummonCreature(NPC_FLASH_FREEZE_NPC, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 2000) ) { @@ -1483,7 +1483,7 @@ class achievement_cheese_the_freeze : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_HODIR && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(1); + return target && target->GetEntry() == NPC_HODIR && target->IsCreature() && target->ToCreature()->AI()->GetData(1); } }; @@ -1494,7 +1494,7 @@ class achievement_getting_cold_in_here : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_HODIR && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(2); + return target && target->GetEntry() == NPC_HODIR && target->IsCreature() && target->ToCreature()->AI()->GetData(2); } }; @@ -1505,7 +1505,7 @@ class achievement_i_could_say_that_this_cache_was_rare : public AchievementCrite bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_HODIR && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(3); + return target && target->GetEntry() == NPC_HODIR && target->IsCreature() && target->ToCreature()->AI()->GetData(3); } }; @@ -1516,7 +1516,7 @@ class achievement_i_have_the_coolest_friends : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_HODIR && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(4); + return target && target->GetEntry() == NPC_HODIR && target->IsCreature() && target->ToCreature()->AI()->GetData(4); } }; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp index 7277c02572311a..f44e278d4bfe8a 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_ignis.cpp @@ -542,7 +542,7 @@ class achievement_ignis_shattered : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - if (!target || target->GetTypeId() != TYPEID_UNIT) + if (!target || !target->IsCreature()) return false; return !!target->ToCreature()->AI()->GetData(1337); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp index f9210e80c16051..fdbebae70d591d 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_kologarn.cpp @@ -707,7 +707,7 @@ class StoneGripTargetSelector if (target == _victim && _me->GetThreatMgr().GetThreatListSize() > 1) return true; - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return true; return false; @@ -724,7 +724,7 @@ class spell_ulduar_stone_grip_cast_target : public SpellScript bool Load() override { - if (GetCaster()->GetTypeId() != TYPEID_UNIT) + if (!GetCaster()->IsCreature()) return false; return true; } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index a80545c36f88d7..5ced2828d8c3ac 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -1342,7 +1342,7 @@ class npc_ulduar_vx001 : public CreatureScript if( Vehicle* vk = me->GetVehicleKit() ) for (uint8 i = 0; i < 2; ++i) if (Unit* r = vk->GetPassenger(5 + i)) - if (r->GetTypeId() == TYPEID_UNIT) + if (r->IsCreature()) r->ToCreature()->DespawnOrUnsummon(1); } @@ -1438,7 +1438,7 @@ class npc_ulduar_vx001 : public CreatureScript exitPos.m_positionZ += 2.0f * Phase; r->_ExitVehicle(&exitPos); me->RemoveAurasByType(SPELL_AURA_CONTROL_VEHICLE, r->GetGUID()); - if (r->GetTypeId() == TYPEID_UNIT) + if (r->IsCreature()) r->ToCreature()->AI()->SetData(0, 0); } } @@ -2155,7 +2155,7 @@ class spell_mimiron_p3wx2_laser_barrage_aura : public AuraScript { if (Unit* caster = GetCaster()) { - if (caster->GetTypeId() != TYPEID_UNIT) + if (!caster->IsCreature()) return; uint32 diff = getMSTimeDiff(_lastMSTime, GameTime::GetGameTimeMS().count()); if (_lastOrientation == -1.0f) @@ -2466,7 +2466,7 @@ class achievement_mimiron_firefighter : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_MIMIRON && target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->AI()->GetData(1); + return target && target->GetEntry() == NPC_MIMIRON && target->IsCreature() && target->ToCreature()->AI()->GetData(1); } }; @@ -2477,7 +2477,7 @@ class achievement_mimiron_set_up_us_the_bomb_11 : public AchievementCriteriaScri bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_MIMIRON && target->GetTypeId() == TYPEID_UNIT && !target->ToCreature()->AI()->GetData(11); + return target && target->GetEntry() == NPC_MIMIRON && target->IsCreature() && !target->ToCreature()->AI()->GetData(11); } }; @@ -2488,7 +2488,7 @@ class achievement_mimiron_set_up_us_the_bomb_12 : public AchievementCriteriaScri bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_MIMIRON && target->GetTypeId() == TYPEID_UNIT && !target->ToCreature()->AI()->GetData(12); + return target && target->GetEntry() == NPC_MIMIRON && target->IsCreature() && !target->ToCreature()->AI()->GetData(12); } }; @@ -2499,7 +2499,7 @@ class achievement_mimiron_set_up_us_the_bomb_13 : public AchievementCriteriaScri bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetEntry() == NPC_MIMIRON && target->GetTypeId() == TYPEID_UNIT && !target->ToCreature()->AI()->GetData(13); + return target && target->GetEntry() == NPC_MIMIRON && target->IsCreature() && !target->ToCreature()->AI()->GetData(13); } }; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp index 1baf2d1ddac463..985c014da5a143 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_razorscale.cpp @@ -711,7 +711,7 @@ class npc_ulduar_expedition_commander : public CreatureScript if (_introSpoken) return; - if (who->GetTypeId() != TYPEID_PLAYER || me->GetExactDist2d(who) > 15.0f) + if (!who->IsPlayer() || me->GetExactDist2d(who) > 15.0f) return; _introSpoken = true; @@ -1153,7 +1153,7 @@ class achievement_quick_shave : public AchievementCriteriaScript bool OnCheck(Player* /*player*/, Unit* target, uint32 /*criteria_id*/) override { - return target && target->GetTypeId() == TYPEID_UNIT && target->GetEntry() == NPC_RAZORSCALE && target->ToCreature()->AI()->GetData(1); + return target && target->IsCreature() && target->GetEntry() == NPC_RAZORSCALE && target->ToCreature()->AI()->GetData(1); } }; diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp index 98e9448880610a..c67299d861d3ad 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_xt002.cpp @@ -427,7 +427,7 @@ class npc_xt002_heart : public CreatureScript { summons.Summon(cr); if (Unit* owner = me->GetVehicleBase()) - if (owner->GetTypeId() == TYPEID_UNIT) + if (owner->IsCreature()) owner->ToCreature()->AI()->JustSummoned(cr); } void DamageTaken(Unit*, uint32& damage, DamageEffectType, SpellSchoolMask) override diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp index df26adcb68d555..bf51c0556df889 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/instance_ulduar.cpp @@ -1103,7 +1103,7 @@ class instance_ulduar : public InstanceMapScript if (Creature* algalon = instance->GetCreature(m_uiAlgalonGUID)) algalon->AI()->DoAction(ACTION_FEEDS_ON_TEARS_FAILED); } - else if (unit->GetTypeId() == TYPEID_UNIT && unit->GetAreaId() == 4656 /*Conservatory of Life*/) + else if (unit->IsCreature() && unit->GetAreaId() == 4656 /*Conservatory of Life*/) { if (GameTime::GetGameTime().count() > (m_conspeedatoryAttempt + DAY)) { diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp index c196312e4d50a5..5222dcae79baab 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_palehoof.cpp @@ -328,7 +328,7 @@ class boss_palehoof : public CreatureScript void KilledUnit(Unit* victim) override { - if (victim->GetTypeId() != TYPEID_PLAYER) + if (!victim->IsPlayer()) return; Talk(SAY_SLAY); diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp index aa7d0e250eb125..35409dd8b5ef9c 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardePinnacle/boss_svala.cpp @@ -404,7 +404,7 @@ class spell_svala_ritual_strike : public SpellScript { if (Unit* unitTarget = GetHitUnit()) { - if (unitTarget->GetTypeId() != TYPEID_UNIT) + if (!unitTarget->IsCreature()) return; Unit::DealDamage(GetCaster(), unitTarget, 7000, nullptr, DIRECT_DAMAGE); diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp index 001b2dfb20e4ab..6b02fe826368bf 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_emalon.cpp @@ -217,7 +217,7 @@ class spell_voa_overcharge : public SpellScriptLoader void HandlePeriodicDummy(AuraEffect const* /*aurEff*/) { Unit* target = GetTarget(); - if (target->GetTypeId() == TYPEID_UNIT && GetAura()->GetStackAmount() >= 10) + if (target->IsCreature() && GetAura()->GetStackAmount() >= 10) { target->CastSpell(target, SPELL_OVERCHARGED_BLAST, true); Unit::Kill(target, target, false); diff --git a/src/server/scripts/Northrend/zone_borean_tundra.cpp b/src/server/scripts/Northrend/zone_borean_tundra.cpp index 4355e2109de1b5..8798a5691c8bdb 100644 --- a/src/server/scripts/Northrend/zone_borean_tundra.cpp +++ b/src/server/scripts/Northrend/zone_borean_tundra.cpp @@ -45,7 +45,7 @@ class spell_q11919_q11940_drake_hunt_aura : public AuraScript bool Load() override { - return GetOwner()->GetTypeId() == TYPEID_UNIT; + return GetOwner()->IsCreature(); } void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) @@ -217,7 +217,7 @@ class npc_khunok_the_behemoth : public CreatureScript { ScriptedAI::MoveInLineOfSight(who); - if (who->GetTypeId() != TYPEID_UNIT) + if (!who->IsCreature()) return; if (who->GetEntry() == NPC_ORPHANED_MAMMOTH_CALF && me->IsWithinDistInMap(who, 10.0f)) @@ -314,7 +314,7 @@ class npc_nerubar_victim : public CreatureScript void JustDied(Unit* killer) override { - if (!killer || killer->GetTypeId() != TYPEID_PLAYER) + if (!killer || !killer->IsPlayer()) { return; } diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index 9d0a4f893eb9b6..c3525a4cd66e36 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -694,7 +694,7 @@ class npc_wintergarde_gryphon : public VehicleAI if (Vehicle* gryphon = me->GetVehicleKit()) if (Unit* villager = gryphon->GetPassenger(1)) { - if (villager->GetTypeId() != TYPEID_UNIT) + if (!villager->IsCreature()) return; if (Creature* seat = villager->ToCreature()) @@ -1296,7 +1296,7 @@ class npc_q24545_lich_king : public CreatureScript if (Unit* vb = c->GetVehicleBase()) { if (Unit* pass = vb->GetVehicleKit()->GetPassenger(0)) - if (pass->GetTypeId() == TYPEID_UNIT) + if (pass->IsCreature()) pass->ToCreature()->DespawnOrUnsummon(1); vb->RemoveAllAuras(); vb->ToCreature()->DespawnOrUnsummon(1); @@ -1323,7 +1323,7 @@ class npc_q24545_lich_king : public CreatureScript void SpellHitTarget(Unit* target, SpellInfo const* spell) override { - if (spell->Id == SPELL_SAC_REPEL_HAMMER && target->GetTypeId() == TYPEID_UNIT) + if (spell->Id == SPELL_SAC_REPEL_HAMMER && target->IsCreature()) { target->CastSpell((Unit*)nullptr, SPELL_SAC_THROW_HAMMER, true); target->ToCreature()->DespawnOrUnsummon(1); @@ -1469,7 +1469,7 @@ class GhoulTargetCheck explicit GhoulTargetCheck(bool alive) : _alive(alive) {} bool operator()(WorldObject* object) const { - return _alive ^ (object->GetTypeId() != TYPEID_UNIT || ((Unit*)object)->GetDisplayId() != 11686); + return _alive ^ (!object->IsCreature() || ((Unit*)object)->GetDisplayId() != 11686); } private: bool _alive; @@ -1489,7 +1489,7 @@ class spell_q24545_aod_special : public SpellScript { PreventHitDefaultEffect(effIndex); if (Unit* target = GetHitUnit()) - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->AI()->DoAction(GetSpellInfo()->Id == 70790 ? -2 : -1); } @@ -1648,7 +1648,7 @@ class npc_spiritual_insight : public CreatureScript void IsSummonedBy(WorldObject* summoner) override { - if (!summoner || summoner->GetTypeId() != TYPEID_PLAYER) + if (!summoner || !summoner->IsPlayer()) return; uint8 id = GetSpeachId(); diff --git a/src/server/scripts/Northrend/zone_grizzly_hills.cpp b/src/server/scripts/Northrend/zone_grizzly_hills.cpp index 06974fad787534..4f925cfef1964a 100644 --- a/src/server/scripts/Northrend/zone_grizzly_hills.cpp +++ b/src/server/scripts/Northrend/zone_grizzly_hills.cpp @@ -967,7 +967,7 @@ class spell_shredder_delivery : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleScript(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Northrend/zone_howling_fjord.cpp b/src/server/scripts/Northrend/zone_howling_fjord.cpp index 79cfb26dac3cf9..e36fe45b50dde8 100644 --- a/src/server/scripts/Northrend/zone_howling_fjord.cpp +++ b/src/server/scripts/Northrend/zone_howling_fjord.cpp @@ -139,7 +139,7 @@ class npc_your_inner_turmoil : public CreatureScript void setphase(short newPhase) { Unit* summoner = me->ToTempSummon() ? me->ToTempSummon()->GetSummonerUnit() : nullptr; - if (!summoner || summoner->GetTypeId() != TYPEID_PLAYER) + if (!summoner || !summoner->IsPlayer()) return; switch (newPhase) diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index 684b6a58ba226b..ab3e632956a51c 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -51,7 +51,7 @@ class npc_black_knight_graveyard : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (who->GetTypeId() != TYPEID_PLAYER || me->GetDistance(who) > 8.0f || who->ToPlayer()->GetQuestStatus(QUEST_BLACK_KNIGHT_CURSE) != QUEST_STATUS_INCOMPLETE) + if (!who->IsPlayer() || me->GetDistance(who) > 8.0f || who->ToPlayer()->GetQuestStatus(QUEST_BLACK_KNIGHT_CURSE) != QUEST_STATUS_INCOMPLETE) return; if (me->FindNearestCreature(NPC_CULT_ASSASSIN, 30.0f)) @@ -1248,7 +1248,7 @@ class npc_infra_green_bomber_generic : public CreatureScript if (!summoner) return; - if (summoner->GetTypeId() != TYPEID_PLAYER) + if (!summoner->IsPlayer()) return; Player* player = summoner->ToPlayer(); @@ -1493,7 +1493,7 @@ class npc_guardian_pavilion : public CreatureScript if (me->GetAreaId() != AREA_SUNREAVER_PAVILION && me->GetAreaId() != AREA_SILVER_COVENANT_PAVILION) return; - if (!who || who->GetTypeId() != TYPEID_PLAYER || !me->IsHostileTo(who) || !me->isInBackInMap(who, 5.0f)) + if (!who || !who->IsPlayer() || !me->IsHostileTo(who) || !me->isInBackInMap(who, 5.0f)) return; if (who->HasAura(SPELL_TRESPASSER_H) || who->HasAura(SPELL_TRESPASSER_A)) diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp index 8ab42c3f98478b..5c82da7a9b696f 100644 --- a/src/server/scripts/Northrend/zone_storm_peaks.cpp +++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp @@ -875,7 +875,7 @@ class npc_freed_protodrake : public CreatureScript for (uint8 i = 1; i < 4; ++i) if (Unit* prisoner = me->GetVehicleKit()->GetPassenger(i)) { - if (prisoner->GetTypeId() != TYPEID_UNIT) + if (!prisoner->IsCreature()) return; prisoner->CastSpell(player, SPELL_KILL_CREDIT_PRISONER, true); prisoner->CastSpell(prisoner, SPELL_SUMMON_LIBERATED, true); diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp index 403fafd97ac9e2..1fb4a1231f96a6 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp @@ -322,7 +322,7 @@ void OPvPCapturePointHP::HandlePlayerLeave(Player* player) void OutdoorPvPHP::HandleKillImpl(Player* player, Unit* killed) { - if (killed->GetTypeId() != TYPEID_PLAYER) + if (!killed->IsPlayer()) return; if (player->GetTeamId() == TEAM_ALLIANCE && killed->ToPlayer()->GetTeamId() != TEAM_ALLIANCE) diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp index f8b8664d76b597..6db94e28772f2b 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp @@ -56,7 +56,7 @@ void OutdoorPvPNA::HandleKill(Player* killer, Unit* killed) // creature kills must be notified, even if not inside objective / not outdoor pvp active // player kills only count if active and inside objective - if ((groupGuy->IsOutdoorPvPActive() && groupGuy->GetAreaId() == NA_HALAA_ZONE_ID) || killed->GetTypeId() == TYPEID_UNIT) + if ((groupGuy->IsOutdoorPvPActive() && groupGuy->GetAreaId() == NA_HALAA_ZONE_ID) || killed->IsCreature()) { HandleKillImpl(groupGuy, killed); } @@ -65,7 +65,7 @@ void OutdoorPvPNA::HandleKill(Player* killer, Unit* killed) else { // creature kills must be notified, even if not inside objective / not outdoor pvp active - if (killer && ((killer->IsOutdoorPvPActive() && killer->ToPlayer()->GetAreaId() == NA_HALAA_ZONE_ID) || killed->GetTypeId() == TYPEID_UNIT)) + if (killer && ((killer->IsOutdoorPvPActive() && killer->ToPlayer()->GetAreaId() == NA_HALAA_ZONE_ID) || killed->IsCreature())) { HandleKillImpl(killer, killed); } diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp index ab0325b9b78e67..3ecf6d9e7713c7 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp @@ -199,7 +199,7 @@ bool OutdoorPvPZM::SetupOutdoorPvP() void OutdoorPvPZM::HandleKillImpl(Player* player, Unit* killed) { - if (killed->GetTypeId() != TYPEID_PLAYER) + if (!killed->IsPlayer()) return; if (player->GetTeamId() == TEAM_ALLIANCE && killed->ToPlayer()->GetTeamId() != TEAM_ALLIANCE) diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp index 70e1c3fa05caca..7c165d68ed0def 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidan.cpp @@ -1194,7 +1194,7 @@ class spell_illidan_demon_transform1_aura : public AuraScript bool Load() override { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; + return GetUnitOwner()->IsCreature(); } void OnPeriodic(AuraEffect const* /*aurEff*/) @@ -1222,7 +1222,7 @@ class spell_illidan_demon_transform2_aura : public AuraScript bool Load() override { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; + return GetUnitOwner()->IsCreature(); } void OnPeriodic(AuraEffect const* aurEff) @@ -1313,7 +1313,7 @@ class spell_illidan_cage_trap : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleScriptEffect(SpellEffIndex effIndex) diff --git a/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp b/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp index 807bc0d73e52ab..407506228f2747 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_illidari_council.cpp @@ -607,7 +607,7 @@ class spell_illidari_council_empyreal_balance : public SpellScript bool Load() override { _targetCount = 0; - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleDummy(SpellEffIndex effIndex) @@ -652,7 +652,7 @@ class spell_illidari_council_empyreal_equivalency : public SpellScript bool Load() override { _targetCount = 0; - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleDummy(SpellEffIndex effIndex) diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index 50b6f7359f2b9b..79d68ebfa01a12 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -141,7 +141,7 @@ class boss_reliquary_of_souls : public CreatureScript void MoveInLineOfSight(Unit* who) override { - if (!who || me->getStandState() != UNIT_STAND_STATE_SLEEP || who->GetTypeId() != TYPEID_PLAYER || me->GetDistance2d(who) > 90.0f || who->ToPlayer()->IsGameMaster()) + if (!who || me->getStandState() != UNIT_STAND_STATE_SLEEP || !who->IsPlayer() || me->GetDistance2d(who) > 90.0f || who->ToPlayer()->IsGameMaster()) return; me->SetInCombatWithZone(); diff --git a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp index 91ee4a3ae89781..392cbecde305f1 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_teron_gorefiend.cpp @@ -264,7 +264,7 @@ class spell_teron_gorefiend_shadowy_construct : public AuraScript bool Load() override { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; + return GetUnitOwner()->IsCreature(); } void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp index e98daa3e1b6a0f..d429e6d8452f94 100644 --- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp @@ -82,7 +82,7 @@ class instance_blood_furnace : public InstanceMapScript void OnUnitDeath(Unit* unit) override { - if (unit && unit->GetTypeId() == TYPEID_UNIT && unit->GetEntry() == NPC_NASCENT_FEL_ORC) + if (unit && unit->IsCreature() && unit->GetEntry() == NPC_NASCENT_FEL_ORC) PrisonerDied(unit->GetGUID()); } diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index 825b21ed008570..23226e22555a15 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -1078,7 +1078,7 @@ class spell_kaelthas_kael_phase_two : public SpellScript bool Load() override { - if (GetCaster()->GetTypeId() == TYPEID_UNIT) + if (GetCaster()->IsCreature()) if (InstanceScript* instance = GetCaster()->GetInstanceScript()) if (Creature* kael = instance->GetCreature(DATA_KAELTHAS)) kael->AI()->SummonedCreatureDies(GetCaster()->ToCreature(), nullptr); @@ -1196,7 +1196,7 @@ class spell_kaelthas_flame_strike : public AuraScript bool Load() override { - return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; + return GetUnitOwner()->IsCreature(); } void OnRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index 4134a6931657d8..b16a931eff5b14 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -606,7 +606,7 @@ class spell_dk_dancing_rune_weapon : public AuraScript bool CheckProc(ProcEventInfo& eventInfo) { - if (!eventInfo.GetActor() || !eventInfo.GetActionTarget() || !eventInfo.GetActionTarget()->IsAlive() || eventInfo.GetActor()->GetTypeId() != TYPEID_PLAYER) + if (!eventInfo.GetActor() || !eventInfo.GetActionTarget() || !eventInfo.GetActionTarget()->IsAlive() || !eventInfo.GetActor()->IsPlayer()) return false; SpellInfo const* spellInfo = eventInfo.GetSpellInfo(); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 3bca708830221d..35488441df47b7 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -136,7 +136,7 @@ class spell_the_flag_of_ownership : public SpellScript void HandleScript(SpellEffIndex /*effIndex*/) { Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) return; Player* target = GetHitPlayer(); if (!target) @@ -155,7 +155,7 @@ class spell_the_flag_of_ownership : public SpellScript { for( std::list::iterator itr = targets.begin(); itr != targets.end(); ) { - if ((*itr)->GetTypeId() != TYPEID_PLAYER || (*itr)->ToPlayer()->IsAlive()) + if (!(*itr)->IsPlayer() || (*itr)->ToPlayer()->IsAlive()) { targets.erase(itr); itr = targets.begin(); @@ -1835,7 +1835,7 @@ class spell_gen_feign_death_all_flags : public AuraScript target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->SetReactState(REACT_PASSIVE); } @@ -1846,7 +1846,7 @@ class spell_gen_feign_death_all_flags : public AuraScript target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->InitializeReactState(); } @@ -1870,7 +1870,7 @@ class spell_gen_feign_death_no_dyn_flag : public AuraScript target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->SetReactState(REACT_PASSIVE); } @@ -1880,7 +1880,7 @@ class spell_gen_feign_death_no_dyn_flag : public AuraScript target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->InitializeReactState(); } @@ -1903,7 +1903,7 @@ class spell_gen_feign_death_no_prevent_emotes : public AuraScript target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->SetReactState(REACT_PASSIVE); } @@ -1913,7 +1913,7 @@ class spell_gen_feign_death_no_prevent_emotes : public AuraScript target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->ToCreature()->InitializeReactState(); } @@ -1944,7 +1944,7 @@ class spell_gen_teleporting : public SpellScript void HandleScript(SpellEffIndex /* effIndex */) { Unit* target = GetHitUnit(); - if (target->GetTypeId() != TYPEID_PLAYER) + if (!target->IsPlayer()) return; // return from top @@ -2504,7 +2504,7 @@ class spell_gen_vehicle_scaling_aura: public AuraScript bool Load() override { - return GetCaster() && GetCaster()->IsPlayer() && GetOwner()->GetTypeId() == TYPEID_UNIT; + return GetCaster() && GetCaster()->IsPlayer() && GetOwner()->IsCreature(); } void CalculateAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/) @@ -3729,7 +3729,7 @@ class spell_gen_despawn_self : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleDummy(SpellEffIndex effIndex) diff --git a/src/server/scripts/Spells/spell_hunter.cpp b/src/server/scripts/Spells/spell_hunter.cpp index f4bfef0e945dec..284e526542b682 100644 --- a/src/server/scripts/Spells/spell_hunter.cpp +++ b/src/server/scripts/Spells/spell_hunter.cpp @@ -950,7 +950,7 @@ class spell_hun_tame_beast : public SpellScript SpellCastResult CheckCast() { Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) + if (!caster->IsPlayer()) return SPELL_FAILED_DONT_REPORT; Player* player = GetCaster()->ToPlayer(); @@ -1136,7 +1136,7 @@ class spell_hun_volley_trigger : public SpellScript { if (Unit* pet = *itr) { - if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT) + if (pet->IsAlive() && pet->IsCreature()) { pet->ToCreature()->AI()->OwnerAttacked(_target->ToUnit()); } @@ -1295,7 +1295,7 @@ class spell_hun_bestial_wrath : public SpellScript SpellCastResult CheckCast() { Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) { return SPELL_FAILED_NO_VALID_TARGETS; } diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 343a5d514fd6ea..5bf697b96023ba 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -401,7 +401,7 @@ class spell_item_lil_phylactery : public AuraScript bool CheckProc(ProcEventInfo& eventInfo) { - return eventInfo.GetActionTarget() && (eventInfo.GetActionTarget()->GetTypeId() != TYPEID_UNIT || eventInfo.GetActionTarget()->ToCreature()->isWorldBoss()); + return eventInfo.GetActionTarget() && (!eventInfo.GetActionTarget()->IsCreature() || eventInfo.GetActionTarget()->ToCreature()->isWorldBoss()); } void HandleProc(AuraEffect const* /*aurEff*/, ProcEventInfo& /*eventInfo*/) @@ -501,7 +501,7 @@ class spell_item_lil_xt : public SpellScript Creature* target = GetHitCreature(); if (!target) return; - if (GetCaster()->GetTypeId() == TYPEID_UNIT && GetCaster()->ToCreature()->AI()) + if (GetCaster()->IsCreature() && GetCaster()->ToCreature()->AI()) GetCaster()->ToCreature()->AI()->Talk(2); target->DespawnOrUnsummon(500); } @@ -2291,7 +2291,7 @@ class spell_item_unsated_craving : public AuraScript bool CheckProc(ProcEventInfo& procInfo) { Unit* caster = procInfo.GetActor(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + if (!caster || !caster->IsPlayer()) { return false; } @@ -2302,7 +2302,7 @@ class spell_item_unsated_craving : public AuraScript return true; } - if (!target || target->GetTypeId() != TYPEID_UNIT || target->IsCritter() || target->IsSummon()) + if (!target || !target->IsCreature() || target->IsCritter() || target->IsSummon()) { return false; } diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index 13fbefcdd9c430..a708c8044593de 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -884,7 +884,7 @@ class spell_mage_polymorph_cast_visual : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { if (Unit* target = GetCaster()->FindNearestCreature(NPC_AUROSALIA, 30.0f)) - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->CastSpell(target, PolymorhForms[urand(0, 5)], true); } diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 155c6276b3efff..5345782ac2faa9 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -1021,7 +1021,7 @@ class spell_pal_righteous_defense : public SpellScript SpellCastResult CheckCast() { Unit* caster = GetCaster(); - if (caster->GetTypeId() != TYPEID_PLAYER) + if (!caster->IsPlayer()) return SPELL_FAILED_DONT_REPORT; if (Unit* target = GetExplTargetUnit()) diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 0d02279f295720..9253d528763f85 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -379,7 +379,7 @@ class spell_pri_lightwell : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleScriptEffect(SpellEffIndex /* effIndex */) diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index cfcad45ee91523..94b2f6dd765c44 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -691,7 +691,7 @@ class spell_q11653_youre_not_so_big_now : public SpellScript { PreventHitDefaultEffect(effIndex); Unit* target = GetHitUnit(); - if (!target || target->GetTypeId() != TYPEID_UNIT) + if (!target || !target->IsCreature()) return; static uint32 const spellPlayer[5] = @@ -809,7 +809,7 @@ class spell_q1846_bending_shinbone : public SpellScript { Item* target = GetHitItem(); Unit* caster = GetCaster(); - if (!target && caster->GetTypeId() != TYPEID_PLAYER) + if (!target && !caster->IsPlayer()) return; uint32 const spellId = roll_chance_i(20) ? SPELL_BENDING_SHINBONE1 : SPELL_BENDING_SHINBONE2; @@ -1014,7 +1014,7 @@ class spell_q11396_11399_scourging_crystal_controller_dummy : public SpellScript void HandleDummy(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - if (target->GetTypeId() == TYPEID_UNIT) + if (target->IsCreature()) target->RemoveAurasDueToSpell(SPELL_FORCE_SHIELD_ARCANE_PURPLE_X3); } @@ -1704,7 +1704,7 @@ class spell_q12277_wintergarde_mine_explosion : public SpellScript { if (Unit* caster = GetCaster()) { - if (caster->GetTypeId() == TYPEID_UNIT) + if (caster->IsCreature()) { if (Unit* owner = caster->GetOwner()) { @@ -2018,7 +2018,7 @@ enum BearFlankMaster bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleScript(SpellEffIndex /*effIndex*/) @@ -2079,7 +2079,7 @@ class spell_q12690_burst_at_the_seams : public SpellScript bool Load() override { - return GetCaster()->GetTypeId() == TYPEID_UNIT; + return GetCaster()->IsCreature(); } void HandleKnockBack(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/World/boss_emerald_dragons.cpp b/src/server/scripts/World/boss_emerald_dragons.cpp index 2cf8186143a33d..4a1a28325f9e7c 100644 --- a/src/server/scripts/World/boss_emerald_dragons.cpp +++ b/src/server/scripts/World/boss_emerald_dragons.cpp @@ -464,10 +464,8 @@ class npc_spirit_shade : public CreatureScript if (!summoner) return; - if (summoner->GetTypeId() != TYPEID_UNIT) - { + if (!summoner->IsCreature()) return; - } _summonerGuid = summoner->GetGUID(); me->GetMotionMaster()->MoveFollow(summoner->ToUnit(), 0.0f, 0.0f); diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 18c16a4c27a879..92782ae39481bd 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -1513,7 +1513,7 @@ class go_soulwell : public GameObjectScript return true; } - if (owner->GetTypeId() != TYPEID_PLAYER || !player->IsInSameRaidWith(owner->ToPlayer())) + if (!owner->IsPlayer() || !player->IsInSameRaidWith(owner->ToPlayer())) { if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(stoneSpell)) { diff --git a/src/server/scripts/World/npc_stave_of_ancients.cpp b/src/server/scripts/World/npc_stave_of_ancients.cpp index bf80e6bd5fdc22..fede7e6fa3eb3e 100644 --- a/src/server/scripts/World/npc_stave_of_ancients.cpp +++ b/src/server/scripts/World/npc_stave_of_ancients.cpp @@ -200,7 +200,7 @@ void NPCStaveQuestAI::StoreAttackerGuidValue(Unit* attacker) bool isGUIDPresent = std::find(attackerGuids.begin(), attackerGuids.end(), guidValue) != attackerGuids.end(); // don't store snaketrap's snakes and trap triggers - if (isGUIDPresent || (IsAllowedEntry(attacker->GetEntry()) && attacker->GetTypeId() != TYPEID_PLAYER)) + if (isGUIDPresent || (IsAllowedEntry(attacker->GetEntry()) && !attacker->IsPlayer())) { return; } diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index be36753cdcb7a1..440738f96c9a5b 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -2538,7 +2538,7 @@ class npc_venomhide_hatchling : public CreatureScript void IsSummonedBy(WorldObject* summoner) override { - if (summoner->GetTypeId() != TYPEID_PLAYER) + if (!summoner->IsPlayer()) { return; } @@ -2625,7 +2625,7 @@ struct npc_arcanite_dragonling : public ScriptedAI void IsSummonedBy(WorldObject* summoner) override { - if (summoner->GetTypeId() == TYPEID_UNIT || summoner->IsPlayer()) + if (summoner->IsCreature() || summoner->IsPlayer()) me->GetMotionMaster()->MoveFollow(summoner->ToUnit(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); }