refactor(Core): Make more use of helpers. (#19835)

* Init.

* Reword.

* Update codestyle script.

Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

* Add gameobject type ID check, reorder checks.

* Add helper/codestyle check for unit type.

* `IsUnit()` -> `IsCreature()`

* Add `IsUnit()` method.

* Use type mask.

https: //github.com/TrinityCore/TrinityCore/commit/cc71da35b5dc74abf71f8691161525a23d870bb5
Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>
Co-Authored-By: Ovahlord <18347559+Ovahlord@users.noreply.github.com>

* Replace instances of `isType` with `IsUnit`.

---------

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
Benjamin Jackson
2024-09-03 13:41:31 -04:00
committed by GitHub
parent e3e4133e88
commit 1edac37ac3
165 changed files with 725 additions and 719 deletions
+12 -6
View File
@@ -108,14 +108,20 @@ def get_typeid_check(file: io, file_path: str) -> None:
check_failed = False check_failed = False
# Parse all the file # Parse all the file
for line_number, line in enumerate(file, start = 1): for line_number, line in enumerate(file, start = 1):
if 'GetTypeId() == TYPEID_PLAYER' in line: if 'GetTypeId() == TYPEID_ITEM' in line or 'GetTypeId() != TYPEID_ITEM' in line:
print(f"Please use IsPlayer() instead GetTypeId(): {file_path} at line {line_number}") print(f"Please use IsItem() instead of GetTypeId(): {file_path} at line {line_number}")
check_failed = True check_failed = True
if 'GetTypeId() == TYPEID_ITEM' in line: if 'GetTypeId() == TYPEID_UNIT' in line or 'GetTypeId() != TYPEID_UNIT' in line:
print(f"Please use IsItem() instead GetTypeId(): {file_path} at line {line_number}") print(f"Please use IsCreature() instead of GetTypeId(): {file_path} at line {line_number}")
check_failed = True check_failed = True
if 'GetTypeId() == TYPEID_DYNOBJECT' in line: if 'GetTypeId() == TYPEID_PLAYER' in line or 'GetTypeId() != TYPEID_PLAYER' in line:
print(f"Please use IsDynamicObject() instead GetTypeId(): {file_path} at line {line_number}") 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 check_failed = True
# Handle the script error and update the result output # Handle the script error and update the result output
if check_failed: if check_failed:
+1 -1
View File
@@ -65,7 +65,7 @@ void PossessedAI::JustDied(Unit* /*u*/)
void PossessedAI::KilledUnit(Unit* /*victim*/) void PossessedAI::KilledUnit(Unit* /*victim*/)
{ {
// We killed a creature, disable victim's loot // We killed a creature, disable victim's loot
//if (victim->GetTypeId() == TYPEID_UNIT) //if (victim->IsCreature())
// victim->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE); // victim->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
} }
+1 -1
View File
@@ -613,7 +613,7 @@ void PetAI::DoAttack(Unit* target, bool chase)
if (_canMeleeAttack()) 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); float tolerance = combatRange == 0.f ? float(M_PI_4) : float(M_PI * 2);
me->GetMotionMaster()->MoveChase(target, ChaseRange(0.f, combatRange), ChaseAngle(angle, tolerance)); me->GetMotionMaster()->MoveChase(target, ChaseRange(0.f, combatRange), ChaseAngle(angle, tolerance));
} }
+1 -1
View File
@@ -427,7 +427,7 @@ bool NonTankTargetSelector::operator()(Unit const* target) const
if (!target) if (!target)
return false; return false;
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) if (_playerOnly && !target->IsPlayer())
return false; return false;
if (Unit* currentVictim = _source->GetThreatMgr().GetCurrentVictim()) if (Unit* currentVictim = _source->GetThreatMgr().GetCurrentVictim())
+3 -3
View File
@@ -76,7 +76,7 @@ struct DefaultTargetSelector : public Acore::unary_function<Unit*, bool>
if (target == except) if (target == except)
return false; return false;
if (m_playerOnly && (target->GetTypeId() != TYPEID_PLAYER)) if (m_playerOnly && (!target->IsPlayer()))
return false; return false;
if (m_dist > 0.0f && !me->IsWithinCombatRange(target, m_dist)) if (m_dist > 0.0f && !me->IsWithinCombatRange(target, m_dist))
@@ -148,7 +148,7 @@ struct PowerUsersSelector : public Acore::unary_function<Unit*, bool>
if (target->getPowerType() != _power) if (target->getPowerType() != _power)
return false; return false;
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) if (_playerOnly && !target->IsPlayer())
return false; return false;
if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist)) if (_dist > 0.0f && !_me->IsWithinCombatRange(target, _dist))
@@ -170,7 +170,7 @@ struct FarthestTargetSelector : public Acore::unary_function<Unit*, bool>
if (!_me || !target) if (!_me || !target)
return false; return false;
if (_playerOnly && target->GetTypeId() != TYPEID_PLAYER) if (_playerOnly && !target->IsPlayer())
return false; return false;
if (_maxDist > 0.0f && !_me->IsInRange(target, _minDist, _maxDist)) if (_maxDist > 0.0f && !_me->IsInRange(target, _minDist, _maxDist))
+3 -3
View File
@@ -107,7 +107,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange
Map* map = creature->GetMap(); Map* map = creature->GetMap();
if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated 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; return;
} }
@@ -175,10 +175,10 @@ void CreatureAI::MoveInLineOfSight(Unit* who)
void CreatureAI::TriggerAlert(Unit const* who) const void CreatureAI::TriggerAlert(Unit const* who) const
{ {
// If there's no target, or target isn't a player do nothing // If there's no target, or target isn't a player do nothing
if (!who || who->GetTypeId() != TYPEID_PLAYER) if (!who || !who->IsPlayer())
return; return;
// If this unit isn't an NPC, is already distracted, is in combat, is confused, stunned or fleeing, do nothing // 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; return;
// Only alert for hostiles! // Only alert for hostiles!
if (me->IsCivilian() || me->HasReactState(REACT_PASSIVE) || !me->IsHostileTo(who) || !me->_IsTargetAcceptable(who)) if (me->IsCivilian() || me->HasReactState(REACT_PASSIVE) || !me->IsHostileTo(who) || !me->_IsTargetAcceptable(who))
@@ -178,7 +178,7 @@ class PlayerOrPetCheck
public: public:
bool operator() (WorldObject* unit) const bool operator() (WorldObject* unit) const
{ {
if (unit->GetTypeId() != TYPEID_PLAYER) if (!unit->IsPlayer())
if (!unit->ToUnit()->GetOwnerGUID().IsPlayer()) if (!unit->ToUnit()->GetOwnerGUID().IsPlayer())
return true; return true;
@@ -111,7 +111,7 @@ bool npc_escortAI::AssistPlayerInCombatAgainst(Unit* who)
} }
// or if enemy is in evade mode // or if enemy is in evade mode
if (who->GetTypeId() == TYPEID_UNIT && who->ToCreature()->IsInEvadeMode()) if (who->IsCreature() && who->ToCreature()->IsInEvadeMode())
{ {
return false; return false;
} }
@@ -4217,7 +4217,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
{ {
if (!me || !unit) if (!me || !unit)
return; return;
if (e.event.kill.playerOnly && unit->GetTypeId() != TYPEID_PLAYER) if (e.event.kill.playerOnly && !unit->IsPlayer())
return; return;
if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature) if (e.event.kill.creature && unit->GetEntry() != e.event.kill.creature)
return; 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::NotHostile && !me->IsHostileTo(unit)) ||
(hostilityMode == SmartEvent::LOSHostilityMode::Hostile && 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; return;
RecalcTimer(e, e.event.los.cooldownMin, e.event.los.cooldownMax); RecalcTimer(e, e.event.los.cooldownMin, e.event.los.cooldownMax);
ProcessAction(e, unit); 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::NotHostile && !me->IsHostileTo(unit)) ||
(hostilityMode == SmartEvent::LOSHostilityMode::Hostile && 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; return;
RecalcTimer(e, e.event.los.cooldownMin, e.event.los.cooldownMax); RecalcTimer(e, e.event.los.cooldownMin, e.event.los.cooldownMax);
ProcessAction(e, unit); ProcessAction(e, unit);
@@ -5269,7 +5269,7 @@ WorldObject* SmartScript::GetLastInvoker(WorldObject* invoker) const
bool SmartScript::IsUnit(WorldObject* obj) bool SmartScript::IsUnit(WorldObject* obj)
{ {
return obj && (obj->GetTypeId() == TYPEID_UNIT || obj->IsPlayer()); return obj && (obj->IsCreature() || obj->IsPlayer());
} }
bool SmartScript::IsPlayer(WorldObject* obj) bool SmartScript::IsPlayer(WorldObject* obj)
@@ -5279,7 +5279,7 @@ bool SmartScript::IsPlayer(WorldObject* obj)
bool SmartScript::IsCreature(WorldObject* obj) bool SmartScript::IsCreature(WorldObject* obj)
{ {
return obj && obj->GetTypeId() == TYPEID_UNIT; return obj && obj->IsCreature();
} }
bool SmartScript::IsCharmedCreature(WorldObject* obj) bool SmartScript::IsCharmedCreature(WorldObject* obj)
@@ -5295,7 +5295,7 @@ bool SmartScript::IsCharmedCreature(WorldObject* obj)
bool SmartScript::IsGameObject(WorldObject* obj) bool SmartScript::IsGameObject(WorldObject* obj)
{ {
return obj && obj->GetTypeId() == TYPEID_GAMEOBJECT; return obj && obj->IsGameObject();
} }
void SmartScript::IncPhase(uint32 p) void SmartScript::IncPhase(uint32 p)
@@ -304,11 +304,11 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
case ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE: case ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE:
return true; return true;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE: case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE:
if (!target || target->GetTypeId() != TYPEID_UNIT) if (!target || !target->IsCreature())
return false; return false;
return target->GetEntry() == creature.id; return target->GetEntry() == creature.id;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE: case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE:
if (!target || target->GetTypeId() != TYPEID_PLAYER) if (!target || !target->IsPlayer())
return false; return false;
if (classRace.class_id && classRace.class_id != target->ToPlayer()->getClass()) if (classRace.class_id && classRace.class_id != target->ToPlayer()->getClass())
return false; return false;
@@ -316,7 +316,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
return false; return false;
return true; return true;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE: case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_PLAYER_CLASS_RACE:
if (!source || source->GetTypeId() != TYPEID_PLAYER) if (!source || !source->IsPlayer())
return false; return false;
if (classRace.class_id && classRace.class_id != source->ToPlayer()->getClass()) if (classRace.class_id && classRace.class_id != source->ToPlayer()->getClass())
return false; return false;
@@ -324,7 +324,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
return false; return false;
return true; return true;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH: case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH:
if (!target || target->GetTypeId() != TYPEID_PLAYER) if (!target || !target->IsPlayer())
return false; return false;
return !target->HealthAbovePct(health.percent); return !target->HealthAbovePct(health.percent);
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD: 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; return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM: case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM:
{ {
if (!target || target->GetTypeId() != TYPEID_PLAYER) if (!target || !target->IsPlayer())
return false; return false;
// DB data compatibility... // DB data compatibility...
@@ -1501,7 +1501,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
continue; continue;
// map specific case (BG in fact) expected player targeted damage/heal // map specific case (BG in fact) expected player targeted damage/heal
if (!unit || unit->GetTypeId() != TYPEID_PLAYER) if (!unit || !unit->IsPlayer())
continue; continue;
} }
+2 -2
View File
@@ -81,7 +81,7 @@ bool ThreatCalcHelper::isValidProcess(Unit* hatedUnit, Unit* hatingUnit, SpellIn
if (threatSpell && threatSpell->HasAttribute(SPELL_ATTR1_NO_THREAT)) if (threatSpell && threatSpell->HasAttribute(SPELL_ATTR1_NO_THREAT))
return false; return false;
ASSERT(hatingUnit->GetTypeId() == TYPEID_UNIT); ASSERT(hatingUnit->IsCreature());
return true; return true;
} }
@@ -190,7 +190,7 @@ void HostileReference::updateOnlineStatus()
// target is no player or not gamemaster // target is no player or not gamemaster
// target is not in flight // target is not in flight
if (isValid() if (isValid()
&& (getTarget()->GetTypeId() != TYPEID_PLAYER || !getTarget()->ToPlayer()->IsGameMaster()) && (!getTarget()->IsPlayer() || !getTarget()->ToPlayer()->IsGameMaster())
&& !getTarget()->IsInFlight() && !getTarget()->IsInFlight()
&& getTarget()->IsInMap(GetSourceUnit()) && getTarget()->IsInMap(GetSourceUnit())
&& getTarget()->InSamePhase(GetSourceUnit()) && getTarget()->InSamePhase(GetSourceUnit())
+1 -1
View File
@@ -326,7 +326,7 @@ namespace DisableMgr
if (unit) if (unit)
{ {
if ((spellFlags & SPELL_DISABLE_PLAYER && unit->IsPlayer()) || 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) if (spellFlags & SPELL_DISABLE_MAP)
{ {
@@ -1904,7 +1904,7 @@ bool Creature::CanStartAttack(Unit const* who) const
return false; return false;
// This set of checks is should be done only for creatures // 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 (IsImmuneToPC() && who->IsPlayer())) // immune to PC and target is a player, return false
{ {
return false; return false;
@@ -1915,7 +1915,7 @@ bool Creature::CanStartAttack(Unit const* who) const
return false; return false;
// Do not attack non-combat pets // 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; return false;
if (!CanFly() && (GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE + m_CombatDistance)) // too much Z difference, skip very costy vmap calculations here 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; return false;
// pussywizard: or if enemy is in evade mode // 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; return false;
// we don't need help from non-combatant ;) // we don't need help from non-combatant ;)
@@ -2636,7 +2636,7 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
return false; return false;
// pussywizard: or if enemy is in evade mode // pussywizard: or if enemy is in evade mode
if (victim->GetTypeId() == TYPEID_UNIT && victim->ToCreature()->IsInEvadeMode()) if (victim->IsCreature() && victim->ToCreature()->IsInEvadeMode())
return false; return false;
// cannot attack if is during 5 second grace period, unless being attacked // cannot attack if is during 5 second grace period, unless being attacked
@@ -254,14 +254,14 @@ void TempSummon::InitSummon()
WorldObject* owner = GetSummoner(); WorldObject* owner = GetSummoner();
if (owner) if (owner)
{ {
if (owner->GetTypeId() == TYPEID_UNIT) if (owner->IsCreature())
{ {
if (owner->ToCreature()->IsAIEnabled) if (owner->ToCreature()->IsAIEnabled)
{ {
owner->ToCreature()->AI()->JustSummoned(this); owner->ToCreature()->AI()->JustSummoned(this);
} }
} }
else if (owner->GetTypeId() == TYPEID_GAMEOBJECT) else if (owner->IsGameObject())
{ {
if (owner->ToGameObject()->AI()) if (owner->ToGameObject()->AI())
{ {
@@ -304,11 +304,11 @@ void TempSummon::UnSummon(uint32 msTime)
if (WorldObject* owner = GetSummoner()) if (WorldObject* owner = GetSummoner())
{ {
if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled) if (owner->IsCreature() && owner->ToCreature()->IsAIEnabled)
{ {
owner->ToCreature()->AI()->SummonedCreatureDespawn(this); 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); owner->ToGameObject()->AI()->SummonedCreatureDespawn(this);
} }
@@ -1280,7 +1280,7 @@ bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (owner) if (owner)
{ {
if (seer->isType(TYPEMASK_UNIT) && owner->IsFriendlyTo(seer->ToUnit())) if (seer->IsUnit() && owner->IsFriendlyTo(seer->ToUnit()))
return true; return true;
} }
} }
@@ -1521,7 +1521,7 @@ void GameObject::Use(Unit* user)
return; return;
case GAMEOBJECT_TYPE_QUESTGIVER: //2 case GAMEOBJECT_TYPE_QUESTGIVER: //2
{ {
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -1550,7 +1550,7 @@ void GameObject::Use(Unit* user)
if (!info) if (!info)
return; return;
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
if (ChairListSlots.empty()) // this is called once at first chair use to make list of available slots 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) if (!info)
return; return;
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -1818,7 +1818,7 @@ void GameObject::Use(Unit* user)
case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18 case GAMEOBJECT_TYPE_SUMMONING_RITUAL: //18
{ {
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -1831,7 +1831,7 @@ void GameObject::Use(Unit* user)
if (owner) if (owner)
{ {
if (owner->GetTypeId() != TYPEID_PLAYER) if (!owner->IsPlayer())
return; return;
// accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect) // 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(); GameObjectTemplate const* info = GetGOInfo();
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -1934,7 +1934,7 @@ void GameObject::Use(Unit* user)
case GAMEOBJECT_TYPE_FLAGSTAND: // 24 case GAMEOBJECT_TYPE_FLAGSTAND: // 24
{ {
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -1966,7 +1966,7 @@ void GameObject::Use(Unit* user)
case GAMEOBJECT_TYPE_FISHINGHOLE: // 25 case GAMEOBJECT_TYPE_FISHINGHOLE: // 25
{ {
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -1978,7 +1978,7 @@ void GameObject::Use(Unit* user)
case GAMEOBJECT_TYPE_FLAGDROP: // 26 case GAMEOBJECT_TYPE_FLAGDROP: // 26
{ {
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -2036,7 +2036,7 @@ void GameObject::Use(Unit* user)
if (!info) if (!info)
return; return;
if (user->GetTypeId() != TYPEID_PLAYER) if (!user->IsPlayer())
return; return;
Player* player = user->ToPlayer(); Player* player = user->ToPlayer();
@@ -2063,7 +2063,7 @@ void GameObject::Use(Unit* user)
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo) 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()); LOG_ERROR("entities.gameobject", "WORLD: unknown spell id {} at use action for gameobject (Entry: {} GoType: {})", spellId, GetEntry(), GetGoType());
else else
LOG_DEBUG("outdoorpvp", "WORLD: {} non-dbc spell was handled by OutdoorPvP", spellId); LOG_DEBUG("outdoorpvp", "WORLD: {} non-dbc spell was handled by OutdoorPvP", spellId);
+25 -25
View File
@@ -226,7 +226,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target)
} }
} }
if (isType(TYPEMASK_UNIT)) if (IsUnit())
{ {
if (((Unit*)this)->GetVictim()) if (((Unit*)this)->GetVictim())
flags |= UPDATEFLAG_HAS_TARGET; flags |= UPDATEFLAG_HAS_TARGET;
@@ -275,7 +275,7 @@ void Object::DestroyForPlayer(Player* target, bool onDeath) const
{ {
ASSERT(target); ASSERT(target);
if (isType(TYPEMASK_UNIT) || isType(TYPEMASK_PLAYER)) if (IsUnit() || isType(TYPEMASK_PLAYER))
{ {
if (Battleground* bg = target->GetBattleground()) if (Battleground* bg = target->GetBattleground())
{ {
@@ -345,7 +345,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
Unit const* unit = nullptr; Unit const* unit = nullptr;
WorldObject const* object = nullptr; WorldObject const* object = nullptr;
if (isType(TYPEMASK_UNIT)) if (IsUnit())
unit = ToUnit(); unit = ToUnit();
else else
object = ((WorldObject*)this); object = ((WorldObject*)this);
@@ -1101,20 +1101,20 @@ void WorldObject::setActive(bool on)
if (on) if (on)
{ {
if (GetTypeId() == TYPEID_UNIT) if (IsCreature())
map->AddToActive(this->ToCreature()); map->AddToActive(this->ToCreature());
else if (IsDynamicObject()) else if (IsDynamicObject())
map->AddToActive((DynamicObject*)this); map->AddToActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT) else if (IsGameObject())
map->AddToActive((GameObject*)this); map->AddToActive((GameObject*)this);
} }
else else
{ {
if (GetTypeId() == TYPEID_UNIT) if (IsCreature())
map->RemoveFromActive(this->ToCreature()); map->RemoveFromActive(this->ToCreature());
else if (IsDynamicObject()) else if (IsDynamicObject())
map->RemoveFromActive((DynamicObject*)this); map->RemoveFromActive((DynamicObject*)this);
else if (GetTypeId() == TYPEID_GAMEOBJECT) else if (IsGameObject())
map->RemoveFromActive((GameObject*)this); map->RemoveFromActive((GameObject*)this);
} }
} }
@@ -1147,7 +1147,7 @@ void WorldObject::SetPositionDataUpdate()
_updatePositionData = true; _updatePositionData = true;
// Calls immediately for charmed units // Calls immediately for charmed units
if (GetTypeId() == TYPEID_UNIT && ToUnit()->IsCharmedOwnedByPlayerOrPlayer()) if (IsCreature() && ToUnit()->IsCharmedOwnedByPlayerOrPlayer())
UpdatePositionData(); UpdatePositionData();
} }
@@ -1531,7 +1531,7 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
{ {
float new_z = GetMapHeight(x, y, z); float new_z = GetMapHeight(x, y, z);
if (new_z > INVALID_HEIGHT) if (new_z > INVALID_HEIGHT)
z = new_z + (isType(TYPEMASK_UNIT) ? static_cast<Unit const*>(this)->GetHoverHeight() : 0.0f); z = new_z + (IsUnit() ? static_cast<Unit const*>(this)->GetHoverHeight() : 0.0f);
} }
/** /**
@@ -1634,7 +1634,7 @@ float WorldObject::GetGridActivationRange() const
{ {
return ToCreature()->m_SightDistance; return ToCreature()->m_SightDistance;
} }
else if (((GetTypeId() == TYPEID_GAMEOBJECT && ToGameObject()->IsTransport()) || IsDynamicObject()) && isActiveObject()) else if (((IsGameObject() && ToGameObject()->IsTransport()) || IsDynamicObject()) && isActiveObject())
{ {
return GetMap()->GetVisibilityRange(); return GetMap()->GetVisibilityRange();
} }
@@ -1644,11 +1644,11 @@ float WorldObject::GetGridActivationRange() const
float WorldObject::GetVisibilityRange() const float WorldObject::GetVisibilityRange() const
{ {
if (IsVisibilityOverridden() && GetTypeId() == TYPEID_UNIT) if (IsVisibilityOverridden() && IsCreature())
{ {
return *m_visibilityDistanceOverride; return *m_visibilityDistanceOverride;
} }
else if (GetTypeId() == TYPEID_GAMEOBJECT) else if (IsGameObject())
{ {
{ {
if (IsInWintergrasp()) if (IsInWintergrasp())
@@ -1677,11 +1677,11 @@ float WorldObject::GetSightRange(WorldObject const* target) const
{ {
if (target) if (target)
{ {
if (target->IsVisibilityOverridden() && target->GetTypeId() == TYPEID_UNIT) if (target->IsVisibilityOverridden() && target->IsCreature())
{ {
return *target->m_visibilityDistanceOverride; return *target->m_visibilityDistanceOverride;
} }
else if (target->GetTypeId() == TYPEID_GAMEOBJECT) else if (target->IsGameObject())
{ {
if (IsInWintergrasp() && target->IsInWintergrasp()) if (IsInWintergrasp() && target->IsInWintergrasp())
{ {
@@ -1872,7 +1872,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
bool WorldObject::CanNeverSee(WorldObject const* obj) const 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) && ToUnit()->GetVehicleBase() != obj && this != obj->ToUnit()->GetVehicleBase());
return GetMap() != obj->GetMap() || !InSamePhase(obj); 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! // xinef: ignore units players have at client, this cant be cheated!
if (checkClient) if (checkClient)
{ {
if (GetTypeId() != TYPEID_PLAYER || !ToPlayer()->HaveAtClient(obj)) if (!IsPlayer() || !ToPlayer()->HaveAtClient(obj))
return false; return false;
} }
else else
@@ -1992,7 +1992,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
float distance = GetExactDist(obj); float distance = GetExactDist(obj);
float combatReach = 0.0f; float combatReach = 0.0f;
if (isType(TYPEMASK_UNIT)) if (IsUnit())
combatReach = ((Unit*)this)->GetCombatReach(); combatReach = ((Unit*)this)->GetCombatReach();
if (distance < combatReach) if (distance < combatReach)
@@ -2006,7 +2006,7 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj, bool checkAlert) co
if (!(obj->m_stealth.GetFlags() & (1 << i))) if (!(obj->m_stealth.GetFlags() & (1 << i)))
continue; continue;
if (isType(TYPEMASK_UNIT)) if (IsUnit())
if (((Unit*)this)->HasAuraTypeWithMiscvalue(SPELL_AURA_DETECT_STEALTH, i)) if (((Unit*)this)->HasAuraTypeWithMiscvalue(SPELL_AURA_DETECT_STEALTH, i))
return true; return true;
@@ -2389,7 +2389,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
if (respawnTime) if (respawnTime)
go->SetSpellId(1); 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); ToUnit()->AddGameObject(go);
else else
go->SetSpawnedByDefault(false); go->SetSpawnedByDefault(false);
@@ -2406,7 +2406,7 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3
return nullptr; return nullptr;
//summon->SetName(GetName()); //summon->SetName(GetName());
if (setLevel && (IsPlayer() || GetTypeId() == TYPEID_UNIT)) if (setLevel && (IsPlayer() || IsCreature()))
{ {
summon->SetFaction(((Unit*)this)->GetFaction()); summon->SetFaction(((Unit*)this)->GetFaction());
summon->SetLevel(((Unit*)this)->GetLevel()); summon->SetLevel(((Unit*)this)->GetLevel());
@@ -2428,9 +2428,9 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3
*/ */
void WorldObject::SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list /*= nullptr*/) void WorldObject::SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list /*= nullptr*/)
{ {
ASSERT((GetTypeId() == TYPEID_GAMEOBJECT || GetTypeId() == TYPEID_UNIT) && "Only GOs and creatures can summon npc groups!"); ASSERT((IsGameObject() || IsCreature()) && "Only GOs and creatures can summon npc groups!");
std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetEntry(), GetTypeId() == TYPEID_GAMEOBJECT ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group); std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetEntry(), IsGameObject() ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group);
if (!data) if (!data)
return; 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)); GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
// Exclude gameobjects from LoS calculations // 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(); x = this->GetPositionX();
y = this->GetPositionY(); y = this->GetPositionY();
@@ -2955,7 +2955,7 @@ void WorldObject::DestroyForNearbyPlayers()
if (!player->HaveAtClient(this)) if (!player->HaveAtClient(this))
continue; 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; continue;
DestroyForPlayer(player); 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 float WorldObject::GetMapWaterOrGroundLevel(float x, float y, float z, float* ground/* = nullptr*/) const
{ {
return GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, ground, return GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, ground,
isType(TYPEMASK_UNIT) ? !static_cast<Unit const*>(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false, IsUnit() ? !static_cast<Unit const*>(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false,
std::max(GetCollisionHeight(), Z_OFFSET_FIND_HEIGHT)); std::max(GetCollisionHeight(), Z_OFFSET_FIND_HEIGHT));
} }
+6 -4
View File
@@ -198,11 +198,13 @@ public:
Player* ToPlayer() { if (IsPlayer()) return reinterpret_cast<Player*>(this); else return nullptr; } Player* ToPlayer() { if (IsPlayer()) return reinterpret_cast<Player*>(this); else return nullptr; }
[[nodiscard]] Player const* ToPlayer() const { if (IsPlayer()) return reinterpret_cast<Player const*>(this); else return nullptr; } [[nodiscard]] Player const* ToPlayer() const { if (IsPlayer()) return reinterpret_cast<Player const*>(this); else return nullptr; }
Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return nullptr; } [[nodiscard]] inline bool IsCreature() const { return GetTypeId() == TYPEID_UNIT; }
[[nodiscard]] Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature const*>(this); else return nullptr; } Creature* ToCreature() { if (IsCreature()) return reinterpret_cast<Creature*>(this); else return nullptr; }
[[nodiscard]] Creature const* ToCreature() const { if (IsCreature()) return reinterpret_cast<Creature const*>(this); else return nullptr; }
Unit* ToUnit() { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast<Unit*>(this); else return nullptr; } [[nodiscard]] inline bool IsUnit() const { return isType(TYPEMASK_UNIT); }
[[nodiscard]] Unit const* ToUnit() const { if (GetTypeId() == TYPEID_UNIT || IsPlayer()) return reinterpret_cast<Unit const*>(this); else return nullptr; } Unit* ToUnit() { if (IsCreature() || IsPlayer()) return reinterpret_cast<Unit*>(this); else return nullptr; }
[[nodiscard]] Unit const* ToUnit() const { if (IsCreature() || IsPlayer()) return reinterpret_cast<Unit const*>(this); else return nullptr; }
[[nodiscard]] inline bool IsGameObject() const { return GetTypeId() == TYPEID_GAMEOBJECT; } [[nodiscard]] inline bool IsGameObject() const { return GetTypeId() == TYPEID_GAMEOBJECT; }
GameObject* ToGameObject() { if (IsGameObject()) return reinterpret_cast<GameObject*>(this); else return nullptr; } GameObject* ToGameObject() { if (IsGameObject()) return reinterpret_cast<GameObject*>(this); else return nullptr; }
+10 -10
View File
@@ -181,20 +181,20 @@ class ObjectGuid
{ {
switch (high) switch (high)
{ {
case HighGuid::Item: return TYPEID_ITEM; case HighGuid::Item: return TYPEID_ITEM;
//case HighGuid::Container: return TYPEID_CONTAINER; HighGuid::Container == HighGuid::Item currently //case HighGuid::Container: return TYPEID_CONTAINER; HighGuid::Container == HighGuid::Item currently
case HighGuid::Unit: return TYPEID_UNIT; case HighGuid::Unit: return TYPEID_UNIT;
case HighGuid::Pet: return TYPEID_UNIT; case HighGuid::Pet: return TYPEID_UNIT;
case HighGuid::Player: return TYPEID_PLAYER; case HighGuid::Player: return TYPEID_PLAYER;
case HighGuid::GameObject: return TYPEID_GAMEOBJECT; case HighGuid::GameObject: return TYPEID_GAMEOBJECT;
case HighGuid::DynamicObject: return TYPEID_DYNAMICOBJECT; case HighGuid::DynamicObject: return TYPEID_DYNAMICOBJECT;
case HighGuid::Corpse: return TYPEID_CORPSE; case HighGuid::Corpse: return TYPEID_CORPSE;
case HighGuid::Mo_Transport: return TYPEID_GAMEOBJECT; case HighGuid::Mo_Transport: return TYPEID_GAMEOBJECT;
case HighGuid::Vehicle: return TYPEID_UNIT; case HighGuid::Vehicle: return TYPEID_UNIT;
// unknown // unknown
case HighGuid::Instance: case HighGuid::Instance:
case HighGuid::Group: case HighGuid::Group:
default: return TYPEID_OBJECT; default: return TYPEID_OBJECT;
} }
} }
+4 -4
View File
@@ -2060,7 +2060,7 @@ void Pet::InitPetCreateSpells()
bool Pet::resetTalents() bool Pet::resetTalents()
{ {
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER) if (!owner || !owner->IsPlayer())
return false; return false;
if (!sScriptMgr->CanResetTalents(this)) if (!sScriptMgr->CanResetTalents(this))
@@ -2228,7 +2228,7 @@ void Pet::InitTalentForLevel()
uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level); uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER) if (!owner || !owner->IsPlayer())
return; return;
// Reset talents in case low level (on level down) or wrong points for level (hunter can unlearn TP increase talent) // 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) void Pet::CastPetAuras(bool current)
{ {
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER) if (!owner || !owner->IsPlayer())
return; return;
if (!IsPermanentPetFor(owner->ToPlayer())) if (!IsPermanentPetFor(owner->ToPlayer()))
@@ -2397,7 +2397,7 @@ void Pet::learnSpellHighRank(uint32 spellid)
void Pet::SynchronizeLevelWithOwner() void Pet::SynchronizeLevelWithOwner()
{ {
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER) if (!owner || !owner->IsPlayer())
return; return;
switch (getPetType()) switch (getPetType())
@@ -130,7 +130,7 @@ void KillRewarder::_InitXP(Player* player)
_xp = Acore::XP::Gain(player, _victim, _isBattleGround); _xp = Acore::XP::Gain(player, _victim, _isBattleGround);
if (_xp && !_isBattleGround && _victim) // pussywizard: npcs with relatively low hp give lower exp 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 (const CreatureTemplate* ct = _victim->ToCreature()->GetCreatureTemplate())
if (ct->ModHealth <= 0.75f && ct->ModHealth >= 0.0f) if (ct->ModHealth <= 0.75f && ct->ModHealth >= 0.0f)
_xp = uint32(_xp * ct->ModHealth); _xp = uint32(_xp * ct->ModHealth);
+13 -13
View File
@@ -2385,7 +2385,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate, bool isLFGReward)
return; return;
} }
if (victim && victim->GetTypeId() == TYPEID_UNIT && !victim->ToCreature()->hasLootRecipient()) if (victim && victim->IsCreature() && !victim->ToCreature()->hasLootRecipient())
{ {
return; 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 // do not reward honor in arenas, but enable onkill spellproc
if (InArena()) if (InArena())
{ {
if (!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER) if (!uVictim || uVictim == this || !uVictim->IsPlayer())
return false; return false;
if (GetBgTeamId() == uVictim->ToPlayer()->GetBgTeamId()) if (GetBgTeamId() == uVictim->ToPlayer()->GetBgTeamId())
@@ -9256,7 +9256,7 @@ void Player::StopCastingCharm(Aura* except /*= nullptr*/)
return; return;
} }
if (charm->GetTypeId() == TYPEID_UNIT) if (charm->IsCreature())
{ {
if (charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET)) if (charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET))
{ {
@@ -9611,7 +9611,7 @@ void Player::CharmSpellInitialize()
} }
uint8 addlist = 0; uint8 addlist = 0;
if (charm->GetTypeId() != TYPEID_PLAYER) if (!charm->IsPlayer())
{ {
//CreatureInfo const* cinfo = charm->ToCreature()->GetCreatureTemplate(); //CreatureInfo const* cinfo = charm->ToCreature()->GetCreatureTemplate();
//if (cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK) //if (cinfo && cinfo->type == CREATURE_TYPE_DEMON && getClass() == CLASS_WARLOCK)
@@ -9627,7 +9627,7 @@ void Player::CharmSpellInitialize()
data << uint16(0); data << uint16(0);
data << uint32(0); data << uint32(0);
if (charm->GetTypeId() != TYPEID_PLAYER) if (!charm->IsPlayer())
data << uint8(charm->ToCreature()->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0); data << uint8(charm->ToCreature()->GetReactState()) << uint8(charmInfo->GetCommandState()) << uint16(0);
else else
data << uint32(0); data << uint32(0);
@@ -12622,7 +12622,7 @@ bool Player::isHonorOrXPTarget(Unit* victim) const
return false; 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)) 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) if (!pRewardSource)
return; 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 // prepare data for near group iteration
if (Group* group = GetGroup()) if (Group* group = GetGroup())
@@ -12818,7 +12818,7 @@ void Player::SetClientControl(Unit* target, bool allowMove, bool packetOnly /*=
SetMover(target); SetMover(target);
// Xinef: disable moving if target has disable move flag // Xinef: disable moving if target has disable move flag
if (target->GetTypeId() != TYPEID_UNIT) if (!target->IsCreature())
return; return;
if (allowMove && target->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE)) 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); 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; m_mover->m_movedByPlayer = nullptr;
if (m_mover->GetTypeId() == TYPEID_UNIT) if (m_mover->IsCreature())
m_mover->GetMotionMaster()->Initialize(); m_mover->GetMotionMaster()->Initialize();
m_mover = target; m_mover = target;
m_mover->m_movedByPlayer = this; m_mover->m_movedByPlayer = this;
if (m_mover->GetTypeId() == TYPEID_UNIT) if (m_mover->IsCreature())
m_mover->GetMotionMaster()->Initialize(); m_mover->GetMotionMaster()->Initialize();
} }
@@ -13105,7 +13105,7 @@ void Player::StopCastingBindSight(Aura* except /*= nullptr*/)
{ {
if (WorldObject* target = GetViewpoint()) 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_BIND_SIGHT, GetGUID(), except);
((Unit*)target)->RemoveAurasByType(SPELL_AURA_MOD_POSSESS, 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 // farsight dynobj or puppet may be very far away
UpdateVisibilityOf(target); UpdateVisibilityOf(target);
if (target->isType(TYPEMASK_UNIT) && !GetVehicle()) if (target->IsUnit() && !GetVehicle())
((Unit*)target)->AddPlayerToVision(this); ((Unit*)target)->AddPlayerToVision(this);
SetSeer(target); SetSeer(target);
} }
@@ -13146,7 +13146,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply)
return; return;
} }
if (target->isType(TYPEMASK_UNIT) && !GetVehicle()) if (target->IsUnit() && !GetVehicle())
static_cast<Unit*>(target)->RemovePlayerFromVision(this); static_cast<Unit*>(target)->RemovePlayerFromVision(this);
// must immediately set seer back otherwise may crash // must immediately set seer back otherwise may crash
@@ -44,13 +44,13 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
uint32 npcflags = 0; uint32 npcflags = 0;
if (source->GetTypeId() == TYPEID_UNIT) if (source->IsCreature())
{ {
npcflags = source->ToUnit()->GetNpcFlags(); npcflags = source->ToUnit()->GetNpcFlags();
if (showQuests && npcflags & UNIT_NPC_FLAG_QUESTGIVER) if (showQuests && npcflags & UNIT_NPC_FLAG_QUESTGIVER)
PrepareQuestMenu(source->GetGUID()); PrepareQuestMenu(source->GetGUID());
} }
else if (source->GetTypeId() == TYPEID_GAMEOBJECT) else if (source->IsGameObject())
if (showQuests && source->ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER) if (showQuests && source->ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_QUESTGIVER)
PrepareQuestMenu(source->GetGUID()); PrepareQuestMenu(source->GetGUID());
@@ -211,7 +211,7 @@ void Player::SendPreparedGossip(WorldObject* source)
if (!source) if (!source)
return; 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) // 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()) if (!source->ToCreature()->HasNpcFlag(UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty())
@@ -220,7 +220,7 @@ void Player::SendPreparedGossip(WorldObject* source)
return; return;
} }
} }
else if (source->GetTypeId() == TYPEID_GAMEOBJECT) else if (source->IsGameObject())
{ {
// probably need to find a better way here // probably need to find a better way here
if (!PlayerTalkClass->GetGossipMenu().GetMenuId() && !PlayerTalkClass->GetQuestMenu().Empty()) if (!PlayerTalkClass->GetGossipMenu().GetMenuId() && !PlayerTalkClass->GetQuestMenu().Empty())
@@ -256,7 +256,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
uint32 gossipOptionId = item->OptionType; uint32 gossipOptionId = item->OptionType;
ObjectGuid guid = source->GetGUID(); 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) 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) if (gossipOptionId > GOSSIP_OPTION_QUESTGIVER)
{ {
@@ -829,7 +829,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
if (quest->GetRewSpellCast() > 0) if (quest->GetRewSpellCast() > 0)
{ {
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpellCast()); 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())) if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID()))
creature->CastSpell(this, quest->GetRewSpellCast(), true); 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) else if (quest->GetRewSpell() > 0)
{ {
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(quest->GetRewSpell()); 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())) if (Creature* creature = GetMap()->GetCreature(questGiver->GetGUID()))
creature->CastSpell(this, quest->GetRewSpell(), true); creature->CastSpell(this, quest->GetRewSpell(), true);
@@ -939,7 +939,7 @@ void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType, Item* ite
if (GetShapeshiftForm() == FORM_TREE) if (GetShapeshiftForm() == FORM_TREE)
return; // use weapon but not skill up return; // use weapon but not skill up
if (victim->GetTypeId() == TYPEID_UNIT && if (victim->IsCreature() &&
(victim->ToCreature()->GetCreatureTemplate()->flags_extra & (victim->ToCreature()->GetCreatureTemplate()->flags_extra &
CREATURE_FLAG_EXTRA_NO_SKILL_GAINS)) CREATURE_FLAG_EXTRA_NO_SKILL_GAINS))
return; return;
@@ -1670,7 +1670,7 @@ void Player::UpdateVisibilityOf(WorldObject* target)
{ {
if (!CanSeeOrDetect(target, false, true)) if (!CanSeeOrDetect(target, false, true))
{ {
if (target->GetTypeId() == TYPEID_UNIT) if (target->IsCreature())
BeforeVisibilityDestroy<Creature>(target->ToCreature(), this); BeforeVisibilityDestroy<Creature>(target->ToCreature(), this);
target->DestroyForPlayer(this); target->DestroyForPlayer(this);
@@ -1687,7 +1687,7 @@ void Player::UpdateVisibilityOf(WorldObject* target)
// target aura duration for caster show only if target exist at // target aura duration for caster show only if target exist at
// caster client send data at target visibility change (adding to // caster client send data at target visibility change (adding to
// client) // client)
if (target->isType(TYPEMASK_UNIT)) if (target->IsUnit())
GetInitialVisiblePackets((Unit*) target); GetInitialVisiblePackets((Unit*) target);
} }
} }
@@ -1913,7 +1913,7 @@ void Player::UpdateCharmedAI()
// Xinef: we should be killed if caster enters evade mode and charm is // Xinef: we should be killed if caster enters evade mode and charm is
// infinite // infinite
if (charmer->GetTypeId() == TYPEID_UNIT && if (charmer->IsCreature() &&
charmer->ToCreature()->IsInEvadeMode()) charmer->ToCreature()->IsInEvadeMode())
{ {
AuraEffectList const& auras = AuraEffectList const& auras =
+2 -2
View File
@@ -34,7 +34,7 @@ CharmInfo::CharmInfo(Unit* unit)
for (uint8 i = 0; i < MAX_SPELL_CHARM; ++i) for (uint8 i = 0; i < MAX_SPELL_CHARM; ++i)
_charmspells[i].SetActionAndType(0, ACT_DISABLED); _charmspells[i].SetActionAndType(0, ACT_DISABLED);
if (_unit->GetTypeId() == TYPEID_UNIT) if (_unit->IsCreature())
{ {
_oldReactState = _unit->ToCreature()->GetReactState(); _oldReactState = _unit->ToCreature()->GetReactState();
_unit->ToCreature()->SetReactState(REACT_PASSIVE); _unit->ToCreature()->SetReactState(REACT_PASSIVE);
@@ -76,7 +76,7 @@ void CharmInfo::InitEmptyActionBar(bool withAttack)
void CharmInfo::InitPossessCreateSpells() void CharmInfo::InitPossessCreateSpells()
{ {
if (_unit->GetTypeId() == TYPEID_UNIT) if (_unit->IsCreature())
{ {
// Adding switch until better way is found. Malcrom // Adding switch until better way is found. Malcrom
// Adding entrys to this switch will prevent COMMAND_ATTACK being added to pet bar. // Adding entrys to this switch will prevent COMMAND_ATTACK being added to pet bar.
File diff suppressed because it is too large Load Diff
+16 -16
View File
@@ -67,7 +67,7 @@ Vehicle::~Vehicle()
void Vehicle::Install() void Vehicle::Install()
{ {
if (_me->GetTypeId() == TYPEID_UNIT) if (_me->IsCreature())
{ {
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId)) if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId))
_me->setPowerType(Powers(powerDisplay->PowerType)); _me->setPowerType(Powers(powerDisplay->PowerType));
@@ -76,7 +76,7 @@ void Vehicle::Install()
} }
_status = STATUS_INSTALLED; _status = STATUS_INSTALLED;
if (GetBase()->GetTypeId() == TYPEID_UNIT) if (GetBase()->IsCreature())
sScriptMgr->OnInstall(this); sScriptMgr->OnInstall(this);
} }
@@ -107,7 +107,7 @@ void Vehicle::Uninstall()
LOG_DEBUG("vehicles", "Vehicle::Uninstall {}", _me->GetGUID().ToString()); LOG_DEBUG("vehicles", "Vehicle::Uninstall {}", _me->GetGUID().ToString());
RemoveAllPassengers(); RemoveAllPassengers();
if (_me && _me->GetTypeId() == TYPEID_UNIT) if (_me && _me->IsCreature())
{ {
sScriptMgr->OnUninstall(this); sScriptMgr->OnUninstall(this);
} }
@@ -129,7 +129,7 @@ void Vehicle::Reset(bool evading /*= false*/)
_me->SetNpcFlag(UNIT_NPC_FLAG_SPELLCLICK); _me->SetNpcFlag(UNIT_NPC_FLAG_SPELLCLICK);
} }
if (GetBase()->GetTypeId() == TYPEID_UNIT) if (GetBase()->IsCreature())
sScriptMgr->OnReset(this); sScriptMgr->OnReset(this);
} }
@@ -274,8 +274,8 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
// already installed // already installed
if (passenger->GetEntry() == entry) if (passenger->GetEntry() == entry)
{ {
ASSERT(passenger->GetTypeId() == TYPEID_UNIT); ASSERT(passenger->IsCreature());
if (_me->GetTypeId() == TYPEID_UNIT) if (_me->IsCreature())
{ {
if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled) if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled)
passenger->ToCreature()->AI()->EnterEvadeMode(); passenger->ToCreature()->AI()->EnterEvadeMode();
@@ -297,7 +297,7 @@ void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 typ
return; return;
} }
if (GetBase()->GetTypeId() == TYPEID_UNIT) if (GetBase()->IsCreature())
sScriptMgr->OnInstallAccessory(this, accessory); sScriptMgr->OnInstallAccessory(this, accessory);
} }
} }
@@ -382,7 +382,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
unit->m_movementInfo.transport.guid = _me->GetGUID(); unit->m_movementInfo.transport.guid = _me->GetGUID();
// xinef: removed seat->first == 0 check... // xinef: removed seat->first == 0 check...
if (_me->GetTypeId() == TYPEID_UNIT if (_me->IsCreature()
&& unit->IsPlayer() && unit->IsPlayer()
&& seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL) && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
{ {
@@ -424,14 +424,14 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
init.SetTransportEnter(); init.SetTransportEnter();
init.Launch(); init.Launch();
if (_me->GetTypeId() == TYPEID_UNIT) if (_me->IsCreature())
{ {
if (_me->ToCreature()->IsAIEnabled) if (_me->ToCreature()->IsAIEnabled)
_me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, true); _me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, true);
} }
} }
if (GetBase()->GetTypeId() == TYPEID_UNIT) if (GetBase()->IsCreature())
sScriptMgr->OnAddPassenger(this, unit, seatId); sScriptMgr->OnAddPassenger(this, unit, seatId);
// Remove parachute on vehicle switch // Remove parachute on vehicle switch
@@ -468,7 +468,7 @@ void Vehicle::RemovePassenger(Unit* unit)
seat->second.Passenger.Reset(); 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); _me->RemoveCharmedBy(unit);
if (_me->IsInWorld()) 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*/) 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); _me->CastSpell(unit, VEHICLE_SPELL_PARACHUTE, true);
if (_me->GetTypeId() == TYPEID_UNIT) if (_me->IsCreature())
sScriptMgr->OnRemovePassenger(this, unit); 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); _me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, false);
} }
@@ -520,7 +520,7 @@ void Vehicle::RelocatePassengers()
void Vehicle::Dismiss() void Vehicle::Dismiss()
{ {
if (GetBase()->GetTypeId() != TYPEID_UNIT) if (!GetBase()->IsCreature())
return; return;
LOG_DEBUG("vehicles", "Vehicle::Dismiss {}", _me->GetGUID().ToString()); LOG_DEBUG("vehicles", "Vehicle::Dismiss {}", _me->GetGUID().ToString());
@@ -535,7 +535,7 @@ bool Vehicle::IsVehicleInUse()
{ {
if (passenger->IsPlayer()) if (passenger->IsPlayer())
return true; return true;
else if (passenger->GetTypeId() == TYPEID_UNIT && passenger->GetVehicleKit() && passenger->GetVehicleKit()->IsVehicleInUse()) else if (passenger->IsCreature() && passenger->GetVehicleKit() && passenger->GetVehicleKit()->IsVehicleInUse())
return true; 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->NearTeleportTo(x, y, z, ang, false, true);
passenger->ToPlayer()->ScheduleDelayedOperation(DELAYED_VEHICLE_TELEPORT); 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); passenger->GetVehicleKit()->TeleportVehicle(x, y, z, ang);
} }
} }
@@ -91,7 +91,7 @@ namespace Acore
{ {
Unit& i_unit; Unit& i_unit;
bool isCreature; 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<class T> void Visit(GridRefMgr<T>&) {} template<class T> void Visit(GridRefMgr<T>&) {}
void Visit(CreatureMapType&); void Visit(CreatureMapType&);
}; };
@@ -864,7 +864,7 @@ namespace Acore
bool operator()(Unit* u) bool operator()(Unit* u)
{ {
if (u->IsAlive() && !u->IsCritter() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(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; return true;
else else
return false; return false;
@@ -887,7 +887,7 @@ namespace Acore
if (u->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET) if (u->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET)
return false; 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; return false;
if (!u->isTargetableForAttack(false, i_funit)) if (!u->isTargetableForAttack(false, i_funit))
@@ -918,7 +918,7 @@ namespace Acore
return false; return false;
} }
if (u->GetTypeId() == TYPEID_UNIT && u->ToCreature()->IsTotem()) if (u->IsCreature() && u->ToCreature()->IsTotem())
{ {
return false; return false;
} }
@@ -930,7 +930,7 @@ namespace Acore
uint32 losChecks = LINEOFSIGHT_ALL_CHECKS; uint32 losChecks = LINEOFSIGHT_ALL_CHECKS;
Optional<float> collisionHeight = { }; Optional<float> collisionHeight = { };
if (i_obj->GetTypeId() == TYPEID_GAMEOBJECT) if (i_obj->IsGameObject())
{ {
losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2; losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2;
collisionHeight = i_owner->GetCollisionHeight(); collisionHeight = i_owner->GetCollisionHeight();
@@ -1203,7 +1203,7 @@ namespace Acore
if (!me->IsValidAttackTarget(u)) if (!me->IsValidAttackTarget(u))
return false; return false;
if (i_playerOnly && u->GetTypeId() != TYPEID_PLAYER) if (i_playerOnly && !u->IsPlayer())
return false; return false;
m_range = me->GetDistance(u); // use found unit range as new range limit for next check m_range = me->GetDistance(u); // use found unit range as new range limit for next check
+1 -1
View File
@@ -791,7 +791,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData)
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit); GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit);
//Send scripted event call //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); ((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(), text_emote);
} }
+1 -1
View File
@@ -410,7 +410,7 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData)
} }
movementInfo.pos.Relocate(mover->GetPositionX(), mover->GetPositionY(), mover->GetPositionZ()); 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.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()); movementInfo.transport.pos.Relocate(mover->m_movementInfo.transport.pos.GetPositionX(), mover->m_movementInfo.transport.pos.GetPositionY(), mover->m_movementInfo.transport.pos.GetPositionZ());
+9 -9
View File
@@ -50,7 +50,7 @@ void WorldSession::HandleDismissCritter(WorldPackets::Pet::DismissCritter& packe
if (_player->GetCritterGUID() == pet->GetGUID()) if (_player->GetCritterGUID() == pet->GetGUID())
{ {
if (pet->GetTypeId() == TYPEID_UNIT && pet->ToCreature()->IsSummon()) if (pet->IsCreature() && pet->ToCreature()->IsSummon())
pet->ToTempSummon()->UnSummon(); pet->ToTempSummon()->UnSummon();
} }
} }
@@ -234,7 +234,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
// Not let attack through obstructions // Not let attack through obstructions
bool checkLos = !DisableMgr::IsPathfindingEnabled(pet->GetMap()) || 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)) if (checkLos && !pet->IsWithinLOSInMap(TargetUnit))
{ {
@@ -252,7 +252,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
{ {
pet->AttackStop(); pet->AttackStop();
if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature()->IsAIEnabled) if (!pet->IsPlayer() && pet->ToCreature()->IsAIEnabled)
{ {
charmInfo->SetIsCommandAttack(true); charmInfo->SetIsCommandAttack(true);
charmInfo->SetIsAtStay(false); charmInfo->SetIsAtStay(false);
@@ -292,7 +292,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
} }
else if (pet->GetOwnerGUID() == GetPlayer()->GetGUID()) else if (pet->GetOwnerGUID() == GetPlayer()->GetGUID())
{ {
ASSERT(pet->GetTypeId() == TYPEID_UNIT); ASSERT(pet->IsCreature());
if (pet->IsPet()) if (pet->IsPet())
{ {
if (pet->ToPet()->getPetType() == HUNTER_PET) 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_DEFENSIVE: //recovery
case REACT_AGGRESSIVE: //activete case REACT_AGGRESSIVE: //activete
if (pet->GetTypeId() == TYPEID_UNIT) if (pet->IsCreature())
pet->ToCreature()->SetReactState(ReactStates(spellId)); pet->ToCreature()->SetReactState(ReactStates(spellId));
else else
charmInfo->SetPlayerReactState(ReactStates(spellId)); charmInfo->SetPlayerReactState(ReactStates(spellId));
@@ -491,7 +491,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
if (pet->GetVictim()) if (pet->GetVictim())
pet->AttackStop(); pet->AttackStop();
if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature() && pet->ToCreature()->IsAIEnabled) if (!pet->IsPlayer() && pet->ToCreature() && pet->ToCreature()->IsAIEnabled)
{ {
charmInfo->SetIsCommandAttack(true); charmInfo->SetIsCommandAttack(true);
charmInfo->SetIsAtStay(false); charmInfo->SetIsAtStay(false);
@@ -537,7 +537,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
else else
victim = nullptr; victim = nullptr;
if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature() && pet->ToCreature()->IsAIEnabled) if (!pet->IsPlayer() && pet->ToCreature() && pet->ToCreature()->IsAIEnabled)
{ {
pet->StopMoving(); pet->StopMoving();
pet->GetMotionMaster()->Clear(); pet->GetMotionMaster()->Clear();
@@ -775,7 +775,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData)
//sign for autocast //sign for autocast
if (act_state == ACT_ENABLED) if (act_state == ACT_ENABLED)
{ {
if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet()) if (pet->IsCreature() && pet->IsPet())
{ {
((Pet*)pet)->ToggleAutocast(spellInfo, true); ((Pet*)pet)->ToggleAutocast(spellInfo, true);
} }
@@ -793,7 +793,7 @@ void WorldSession::HandlePetSetAction(WorldPacket& recvData)
//sign for no/turn off autocast //sign for no/turn off autocast
else if (act_state == ACT_DISABLED) else if (act_state == ACT_DISABLED)
{ {
if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet()) if (pet->IsCreature() && pet->IsPet())
{ {
((Pet*)pet)->ToggleAutocast(spellInfo, false); ((Pet*)pet)->ToggleAutocast(spellInfo, false);
} }
+1 -1
View File
@@ -123,7 +123,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM | TYPEMASK_PLAYER); Object* object = ObjectAccessor::GetObjectByTypeMask(*_player, guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT | TYPEMASK_ITEM | TYPEMASK_PLAYER);
// no or incorrect quest giver // 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))) (object->IsPlayer() && !object->ToPlayer()->CanShareQuest(questId)))
{ {
_player->PlayerTalkClass->SendCloseGossip(); _player->PlayerTalkClass->SendCloseGossip();
+3 -3
View File
@@ -409,7 +409,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
if (Vehicle* veh = mover->GetVehicleKit()) if (Vehicle* veh = mover->GetVehicleKit())
if (const VehicleSeatEntry* seat = veh->GetSeatForPassenger(_player)) 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 (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()) ) 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 // 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; mover = _player;
} }
// not have spell in spellbook or spell passive and not casted by client // 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? //cheater? kick? ban?
recvPacket.rfinish(); // prevent spam at ignore packet recvPacket.rfinish(); // prevent spam at ignore packet
+1 -1
View File
@@ -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) for (auto itr2 = player->m_Controlled.begin(); itr2 != player->m_Controlled.end(); ++itr2)
{ {
if (Unit* controlled = *itr2) if (Unit* controlled = *itr2)
if (controlled->IsInWorld() && controlled->GetTypeId() == TYPEID_UNIT) if (controlled->IsInWorld() && controlled->IsCreature())
controlled->CastSpell(player, spell, true); controlled->CastSpell(player, spell, true);
} }
} }
+4 -4
View File
@@ -587,7 +587,7 @@ bool Map::AddToMap(T* obj, bool checkTransport)
obj->AddToWorld(); obj->AddToWorld();
if (checkTransport) 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)) if (Transport* transport = GetTransportForPos(obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj))
transport->AddPassenger(obj, true); 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 // 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 // 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()) if (Vehicle* vehicle = obj->ToCreature()->GetVehicleKit())
vehicle->Reset(); vehicle->Reset();
return true; return true;
@@ -2662,8 +2662,8 @@ void Map::AddObjectToSwitchList(WorldObject* obj, bool on)
{ {
ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId()); ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
// i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses // 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 // the contained objects only if IsCreature() , so we can return in all other cases
if (obj->GetTypeId() != TYPEID_UNIT && obj->GetTypeId() != TYPEID_GAMEOBJECT) if (!obj->IsCreature() && !obj->IsGameObject())
return; return;
std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj); std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj);
+4 -4
View File
@@ -244,7 +244,7 @@ void MotionMaster::MoveRandom(float wanderDistance)
if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE)) if (_owner->HasUnitFlag(UNIT_FLAG_DISABLE_MOVE))
return; return;
if (_owner->GetTypeId() == TYPEID_UNIT) if (_owner->IsCreature())
{ {
LOG_DEBUG("movement.motionmaster", "Creature ({}) start moving random", _owner->GetGUID().ToString()); LOG_DEBUG("movement.motionmaster", "Creature ({}) start moving random", _owner->GetGUID().ToString());
Mutate(new RandomMovementGenerator<Creature>(wanderDistance), MOTION_SLOT_IDLE); Mutate(new RandomMovementGenerator<Creature>(wanderDistance), MOTION_SLOT_IDLE);
@@ -260,12 +260,12 @@ void MotionMaster::MoveTargetedHome(bool walk /*= false*/)
{ {
Clear(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()); LOG_DEBUG("movement.motionmaster", "Creature ({}) targeted home", _owner->GetGUID().ToString());
Mutate(new HomeMovementGenerator<Creature>(walk), MOTION_SLOT_ACTIVE); Mutate(new HomeMovementGenerator<Creature>(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); _owner->ClearUnitState(UNIT_STATE_EVADE);
@@ -645,7 +645,7 @@ void MotionMaster::MoveFall(uint32 id /*=0*/, bool addFlagForNPC)
_owner->m_movementInfo.SetFallTime(0); _owner->m_movementInfo.SetFallTime(0);
_owner->ToPlayer()->SetFallInformation(GameTime::GetGameTime().count(), _owner->GetPositionZ()); _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_MASK_MOVING);
_owner->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY); _owner->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_CAN_FLY);
@@ -72,7 +72,7 @@ bool RotateMovementGenerator::Update(Unit* owner, uint32 diff)
void RotateMovementGenerator::Finalize(Unit* unit) void RotateMovementGenerator::Finalize(Unit* unit)
{ {
unit->ClearUnitState(UNIT_STATE_ROTATING); unit->ClearUnitState(UNIT_STATE_ROTATING);
if (unit->GetTypeId() == TYPEID_UNIT) if (unit->IsCreature())
unit->ToCreature()->AI()->MovementInform(ROTATE_MOTION_TYPE, 0); unit->ToCreature()->AI()->MovementInform(ROTATE_MOTION_TYPE, 0);
} }
@@ -90,7 +90,7 @@ void DistractMovementGenerator::Finalize(Unit* owner)
owner->ClearUnitState(UNIT_STATE_DISTRACTED); owner->ClearUnitState(UNIT_STATE_DISTRACTED);
// If this is a creature, then return orientation to original position (for idle movement creatures) // 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(); float angle = owner->ToCreature()->GetHomePosition().GetOrientation();
owner->SetFacingTo(angle); owner->SetFacingTo(angle);
@@ -636,7 +636,7 @@ void PathGenerator::CreateFilter()
uint16 includeFlags = 0; uint16 includeFlags = 0;
uint16 excludeFlags = 0; uint16 excludeFlags = 0;
if (_source->GetTypeId() == TYPEID_UNIT) if (_source->IsCreature())
{ {
Creature* creature = (Creature*)_source; Creature* creature = (Creature*)_source;
if (creature->CanWalk()) if (creature->CanWalk())
@@ -231,10 +231,10 @@ bool EffectMovementGenerator::Update(Unit* unit, uint32)
void EffectMovementGenerator::Finalize(Unit* unit) void EffectMovementGenerator::Finalize(Unit* unit)
{ {
if (unit->GetTypeId() != TYPEID_UNIT) if (!unit->IsCreature())
return; 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); unit->RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING);
// Need restore previous movement since we have no proper states system // Need restore previous movement since we have no proper states system
@@ -305,7 +305,7 @@ void ChaseMovementGenerator<T>::DoReset(T* owner)
template<class T> template<class T>
void ChaseMovementGenerator<T>::MovementInform(T* owner) void ChaseMovementGenerator<T>::MovementInform(T* owner)
{ {
if (owner->GetTypeId() != TYPEID_UNIT) if (!owner->IsCreature())
return; return;
// Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle
@@ -385,7 +385,7 @@ bool FollowMovementGenerator<T>::PositionOkay(Unit* target, bool isPlayerPet, bo
float exactDistSq = target->GetExactDistSq(_lastTargetPosition->GetPositionX(), _lastTargetPosition->GetPositionY(), _lastTargetPosition->GetPositionZ()); float exactDistSq = target->GetExactDistSq(_lastTargetPosition->GetPositionX(), _lastTargetPosition->GetPositionY(), _lastTargetPosition->GetPositionZ());
float distanceTolerance = 0.25f; float distanceTolerance = 0.25f;
// For creatures, increase tolerance // For creatures, increase tolerance
if (target->GetTypeId() == TYPEID_UNIT) if (target->IsCreature())
{ {
distanceTolerance += _range + _range; distanceTolerance += _range + _range;
} }
@@ -554,7 +554,7 @@ void FollowMovementGenerator<T>::DoReset(T* owner)
template<class T> template<class T>
void FollowMovementGenerator<T>::MovementInform(T* owner) void FollowMovementGenerator<T>::MovementInform(T* owner)
{ {
if (owner->GetTypeId() != TYPEID_UNIT) if (!owner->IsCreature())
return; return;
// Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle // Pass back the GUIDLow of the target. If it is pet's owner then PetAI will handle
+2 -2
View File
@@ -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 // creature kills must be notified, even if not inside objective / not outdoor pvp active
// player kills only count if active and inside objective // 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); HandleKillImpl(groupGuy, killed);
} }
@@ -522,7 +522,7 @@ void OutdoorPvP::HandleKill(Player* killer, Unit* killed)
else else
{ {
// creature kills must be notified, even if not inside objective / not outdoor pvp active // 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); HandleKillImpl(killer, killed);
} }
+8 -8
View File
@@ -157,7 +157,7 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s
Unit* unit = nullptr; Unit* unit = nullptr;
if (!obj) if (!obj)
LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target"); 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.", LOG_ERROR("maps.script", "{} {} object is not unit (TypeId: {}, Entry: {}, GUID: {}), skipping.",
scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString()); scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString());
else 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()); LOG_ERROR("maps.script", "{} door guid is not specified.", scriptInfo->GetDebugInfo());
else if (!source) else if (!source)
LOG_ERROR("maps.script", "{} source object is nullptr.", scriptInfo->GetDebugInfo()); 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()); LOG_ERROR("maps.script", "{} source object is not unit ({}), skipping.", scriptInfo->GetDebugInfo(), source->GetGUID().ToString());
else else
{ {
@@ -510,7 +510,7 @@ void Map::ScriptsProcess()
Player* player = target->ToPlayer(); Player* player = target->ToPlayer();
if (player) 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()); LOG_ERROR("maps.script", "{} source is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), source->GetGUID().ToString());
break; break;
@@ -522,7 +522,7 @@ void Map::ScriptsProcess()
player = source->ToPlayer(); player = source->ToPlayer();
if (player) 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()); LOG_ERROR("maps.script", "{} target is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString());
break; break;
@@ -538,7 +538,7 @@ void Map::ScriptsProcess()
} }
// quest id and flags checked at script loading // 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)))) (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance))))
player->GroupEventHappens(step.script->QuestExplored.QuestID, worldObject); player->GroupEventHappens(step.script->QuestExplored.QuestID, worldObject);
else else
@@ -641,7 +641,7 @@ void Map::ScriptsProcess()
break; 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()); LOG_ERROR("maps.script", "{} target object is not gameobject ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString());
break; break;
@@ -697,13 +697,13 @@ void Map::ScriptsProcess()
break; 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); LOG_ERROR("maps.script", "{} no source unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID);
break; 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); LOG_ERROR("maps.script", "{} no target unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID);
break; break;
@@ -22,7 +22,7 @@
void ScriptMgr::OnInstall(Vehicle* veh) void ScriptMgr::OnInstall(Vehicle* veh)
{ {
ASSERT(veh); ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); ASSERT(veh->GetBase()->IsCreature());
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{ {
@@ -33,7 +33,7 @@ void ScriptMgr::OnInstall(Vehicle* veh)
void ScriptMgr::OnUninstall(Vehicle* veh) void ScriptMgr::OnUninstall(Vehicle* veh)
{ {
ASSERT(veh); ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); ASSERT(veh->GetBase()->IsCreature());
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{ {
@@ -44,7 +44,7 @@ void ScriptMgr::OnUninstall(Vehicle* veh)
void ScriptMgr::OnReset(Vehicle* veh) void ScriptMgr::OnReset(Vehicle* veh)
{ {
ASSERT(veh); ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); ASSERT(veh->GetBase()->IsCreature());
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{ {
@@ -55,7 +55,7 @@ void ScriptMgr::OnReset(Vehicle* veh)
void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory) void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory)
{ {
ASSERT(veh); ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); ASSERT(veh->GetBase()->IsCreature());
ASSERT(accessory); ASSERT(accessory);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) if (auto tempScript = ScriptRegistry<VehicleScript>::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) void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId)
{ {
ASSERT(veh); ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); ASSERT(veh->GetBase()->IsCreature());
ASSERT(passenger); ASSERT(passenger);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) if (auto tempScript = ScriptRegistry<VehicleScript>::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) void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger)
{ {
ASSERT(veh); ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT); ASSERT(veh->GetBase()->IsCreature());
ASSERT(passenger); ASSERT(passenger);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId())) if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
@@ -798,7 +798,7 @@ void AuraEffect::HandleEffect(Unit* target, uint8 mode, bool apply)
void AuraEffect::ApplySpellMod(Unit* target, bool apply) void AuraEffect::ApplySpellMod(Unit* target, bool apply)
{ {
if (!m_spellmod || target->GetTypeId() != TYPEID_PLAYER) if (!m_spellmod || !target->IsPlayer())
return; return;
target->ToPlayer()->AddSpellMod(m_spellmod, apply); target->ToPlayer()->AddSpellMod(m_spellmod, apply);
@@ -951,7 +951,7 @@ void AuraEffect::UpdatePeriodic(Unit* caster)
case 49472: // Drink Coffee case 49472: // Drink Coffee
case 57073: case 57073:
case 61830: case 61830:
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || !caster->IsPlayer())
return; return;
// Get SPELL_AURA_MOD_POWER_REGEN aura from spell // Get SPELL_AURA_MOD_POWER_REGEN aura from spell
if (AuraEffect* aurEff = GetBase()->GetEffect(0)) if (AuraEffect* aurEff = GetBase()->GetEffect(0))
@@ -1712,7 +1712,7 @@ void AuraEffect::HandleDetectAmore(AuraApplication const* aurApp, uint8 mode, bo
} }
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
{ {
return; return;
} }
@@ -1744,7 +1744,7 @@ void AuraEffect::HandleSpiritOfRedemption(AuraApplication const* aurApp, uint8 m
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// prepare spirit state // prepare spirit state
@@ -1779,7 +1779,7 @@ void AuraEffect::HandleAuraGhost(AuraApplication const* aurApp, uint8 mode, bool
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (apply) if (apply)
@@ -2178,7 +2178,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
// Orb of Deception // Orb of Deception
case 16739: case 16739:
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
switch (target->getRace()) switch (target->getRace())
@@ -2237,7 +2237,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
// Corsair Costume // Corsair Costume
case 51926: case 51926:
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
switch (target->getRace()) switch (target->getRace())
@@ -2811,7 +2811,7 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (Player* targetPlayer = target->ToPlayer()) 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()) if ((*iter)->GetCurrentSpell(i) && (*iter)->GetCurrentSpell(i)->m_targets.GetUnitTargetGUID() == target->GetGUID())
{ {
SpellInfo const* si = (*iter)->GetCurrentSpell(i)->GetSpellInfo(); 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(); Creature* c = (*iter)->ToCreature();
if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss()) 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) if (apply)
target->SetFlag(field, flag); target->SetFlag(field, flag);
if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->GetCurrentEquipmentId()) if (target->IsCreature() && target->ToCreature()->GetCurrentEquipmentId())
target->UpdateDamagePhysical(attType); target->UpdateDamagePhysical(attType);
} }
@@ -3112,7 +3112,7 @@ void AuraEffect::HandleAuraTrackCreatures(AuraApplication const* aurApp, uint8 m
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (apply) if (apply)
@@ -3128,7 +3128,7 @@ void AuraEffect::HandleAuraTrackResources(AuraApplication const* aurApp, uint8 m
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (apply) if (apply)
@@ -3144,7 +3144,7 @@ void AuraEffect::HandleAuraTrackStealthed(AuraApplication const* aurApp, uint8 m
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (!(apply)) if (!(apply))
@@ -3206,7 +3206,7 @@ void AuraEffect::HandleAuraModPetTalentsPoints(AuraApplication const* aurApp, ui
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// Recalculate pet talent points // Recalculate pet talent points
@@ -3220,7 +3220,7 @@ void AuraEffect::HandleAuraModSkill(AuraApplication const* aurApp, uint8 mode, b
return; return;
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
uint32 prot = GetMiscValue(); uint32 prot = GetMiscValue();
@@ -3318,7 +3318,7 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode
target->SetCanFly(apply); target->SetCanFly(apply);
if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsLevitating()) if (!apply && target->IsCreature() && !target->IsLevitating())
target->GetMotionMaster()->MoveFall(); target->GetMotionMaster()->MoveFall();
} }
@@ -3444,7 +3444,7 @@ void AuraEffect::HandleAuraModTotalThreat(AuraApplication const* aurApp, uint8 m
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (!target->IsAlive() || target->GetTypeId() != TYPEID_PLAYER) if (!target->IsAlive() || !target->IsPlayer())
return; return;
Unit* caster = GetCaster(); Unit* caster = GetCaster();
@@ -3547,7 +3547,7 @@ void AuraEffect::HandleModPossess(AuraApplication const* aurApp, uint8 mode, boo
Unit* caster = GetCaster(); Unit* caster = GetCaster();
// no support for posession AI yet // no support for posession AI yet
if (caster && caster->GetTypeId() == TYPEID_UNIT) if (caster && caster->IsCreature())
{ {
HandleModCharm(aurApp, mode, apply); HandleModCharm(aurApp, mode, apply);
return; return;
@@ -3567,7 +3567,7 @@ void AuraEffect::HandleModPossessPet(AuraApplication const* aurApp, uint8 mode,
return; return;
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || !caster->IsPlayer())
return; return;
//seems it may happen that when removing it is no longer owner's pet //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; // return;
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_UNIT || !target->IsPet()) if (!target->IsCreature() || !target->IsPet())
return; return;
Pet* pet = target->ToPet(); Pet* pet = target->ToPet();
@@ -3675,7 +3675,7 @@ void AuraEffect::HandleAuraControlVehicle(AuraApplication const* aurApp, uint8 m
if (GetId() == 53111) // Devour Humanoid if (GetId() == 53111) // Devour Humanoid
{ {
Unit::Kill(target, caster); Unit::Kill(target, caster);
if (caster->GetTypeId() == TYPEID_UNIT) if (caster->IsCreature())
caster->ToCreature()->RemoveCorpse(); caster->ToCreature()->RemoveCorpse();
} }
@@ -3725,7 +3725,7 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
{ {
target->SetCanFly(apply); target->SetCanFly(apply);
if (!apply && target->GetTypeId() == TYPEID_UNIT && !target->IsLevitating()) if (!apply && target->IsCreature() && !target->IsLevitating())
target->GetMotionMaster()->MoveFall(); target->GetMotionMaster()->MoveFall();
} }
@@ -4464,8 +4464,8 @@ void AuraEffect::HandleModPercentStat(AuraApplication const* aurApp, uint8 mode,
return; return;
} }
// only players have base stats // only players currently use base stats
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i)
@@ -4482,7 +4482,7 @@ void AuraEffect::HandleModSpellDamagePercentFromStat(AuraApplication const* aurA
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// Magic damage modifiers implemented in Unit::SpellDamageBonus // Magic damage modifiers implemented in Unit::SpellDamageBonus
@@ -4498,7 +4498,7 @@ void AuraEffect::HandleModSpellHealingPercentFromStat(AuraApplication const* aur
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// Recalculate bonus // Recalculate bonus
@@ -4512,7 +4512,7 @@ void AuraEffect::HandleModSpellDamagePercentFromAttackPower(AuraApplication cons
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// Magic damage modifiers implemented in Unit::SpellDamageBonus // Magic damage modifiers implemented in Unit::SpellDamageBonus
@@ -4528,7 +4528,7 @@ void AuraEffect::HandleModSpellHealingPercentFromAttackPower(AuraApplication con
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// Recalculate bonus // Recalculate bonus
@@ -4542,7 +4542,7 @@ void AuraEffect::HandleModHealingDone(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// implemented in Unit::SpellHealingBonus // implemented in Unit::SpellHealingBonus
// this information is for client side only // this information is for client side only
@@ -4613,7 +4613,7 @@ void AuraEffect::HandleAuraModResistenceOfStatPercent(AuraApplication const* aur
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (GetMiscValue() != SPELL_SCHOOL_MASK_NORMAL) if (GetMiscValue() != SPELL_SCHOOL_MASK_NORMAL)
@@ -4635,7 +4635,7 @@ void AuraEffect::HandleAuraModExpertise(AuraApplication const* aurApp, uint8 mod
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
target->ToPlayer()->UpdateExpertise(BASE_ATTACK); target->ToPlayer()->UpdateExpertise(BASE_ATTACK);
@@ -4652,7 +4652,7 @@ void AuraEffect::HandleModPowerRegen(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// Update manaregen value // Update manaregen value
@@ -4675,7 +4675,7 @@ void AuraEffect::HandleModManaRegen(AuraApplication const* aurApp, uint8 mode, b
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
//Note: an increase in regen does NOT cause threat. //Note: an increase in regen does NOT cause threat.
@@ -4815,7 +4815,7 @@ void AuraEffect::HandleAuraModParryPercent(AuraApplication const* aurApp, uint8
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (!target->ToPlayer()->CanParry()) if (!target->ToPlayer()->CanParry())
@@ -4831,7 +4831,7 @@ void AuraEffect::HandleAuraModDodgePercent(AuraApplication const* aurApp, uint8
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
target->ToPlayer()->UpdateDodgePercentage(); target->ToPlayer()->UpdateDodgePercentage();
@@ -4844,7 +4844,7 @@ void AuraEffect::HandleAuraModBlockPercent(AuraApplication const* aurApp, uint8
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
target->ToPlayer()->UpdateBlockPercentage(); target->ToPlayer()->UpdateBlockPercentage();
@@ -4862,7 +4862,7 @@ void AuraEffect::HandleAuraModWeaponCritPercent(AuraApplication const* aurApp, u
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
for (int i = 0; i < MAX_ATTACK; ++i) for (int i = 0; i < MAX_ATTACK; ++i)
@@ -4937,7 +4937,7 @@ void AuraEffect::HandleModSpellCritChanceShool(AuraApplication const* aurApp, ui
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
for (int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school) 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(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
{ {
target->m_baseSpellCritChance += (apply) ? GetAmount() : -GetAmount(); target->m_baseSpellCritChance += (apply) ? GetAmount() : -GetAmount();
return; return;
@@ -5051,7 +5051,7 @@ void AuraEffect::HandleRangedAmmoHaste(AuraApplication const* aurApp, uint8 mode
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
target->ApplyAttackTimePercentMod(RANGED_ATTACK, (float)GetAmount(), apply); target->ApplyAttackTimePercentMod(RANGED_ATTACK, (float)GetAmount(), apply);
@@ -5068,7 +5068,7 @@ void AuraEffect::HandleModRating(AuraApplication const* aurApp, uint8 mode, bool
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) 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(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// Just recalculate ratings // 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)) if ((GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) != 0 && sScriptMgr->CanModAuraEffectDamageDone(this, target, aurApp, mode, apply))
{ {
// apply generic physical damage bonuses including wand case // 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_MAINHAND, TOTAL_VALUE, float(GetAmount()), apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, 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); 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_MAINHAND, TOTAL_PCT, float(GetAmount()), apply);
target->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, 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(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
flag96 mask; flag96 mask;
@@ -5393,7 +5393,7 @@ void AuraEffect::HandleAuraRetainComboPoints(AuraApplication const* aurApp, uint
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
// combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler // 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; break;
case 43681: // Inactive case 43681: // Inactive
{ {
if (target->GetTypeId() != TYPEID_PLAYER || aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE) if (!target->IsPlayer() || aurApp->GetRemoveMode() != AURA_REMOVE_BY_EXPIRE)
return; return;
if (target->GetMap()->IsBattleground()) if (target->GetMap()->IsBattleground())
@@ -5643,7 +5643,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
break; break;
case 46374: // quest The Power of the Elements (11893) 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(); auto caster2 = GetBase()->GetCaster();
if (caster2 && caster2->IsPlayer()) 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 57821: // Champion of the Kirin Tor
case 57822: // Wyrmrest Champion case 57822: // Wyrmrest Champion
{ {
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || !caster->IsPlayer())
break; break;
uint32 FactionID = 0; uint32 FactionID = 0;
@@ -5860,7 +5860,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || !caster->IsPlayer())
return; return;
Player* plCaster = caster->ToPlayer(); Player* plCaster = caster->ToPlayer();
@@ -5904,7 +5904,7 @@ void AuraEffect::HandleBindSight(AuraApplication const* aurApp, uint8 mode, bool
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || !caster->IsPlayer())
return; return;
caster->ToPlayer()->SetViewpoint(target, apply); caster->ToPlayer()->SetViewpoint(target, apply);
@@ -5918,7 +5918,7 @@ void AuraEffect::HandleFarSight(AuraApplication const* /*aurApp*/, uint8 mode, b
} }
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || !caster->IsPlayer())
{ {
return; return;
} }
@@ -5943,7 +5943,7 @@ void AuraEffect::HandleForceReaction(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
Player* player = target->ToPlayer(); Player* player = target->ToPlayer();
@@ -6023,7 +6023,7 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const* aurApp, uint8 mode
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
Player* player = target->ToPlayer(); Player* player = target->ToPlayer();
@@ -6095,7 +6095,7 @@ void AuraEffect::HandleAuraOpenStable(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER || !target->IsInWorld()) if (!target->IsPlayer() || !target->IsInWorld())
return; return;
if (apply) if (apply)
@@ -6154,7 +6154,7 @@ void AuraEffect::HandleAuraSetVehicle(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget(); Unit* target = aurApp->GetTarget();
if (target->GetTypeId() != TYPEID_PLAYER || !target->IsInWorld()) if (!target->IsPlayer() || !target->IsInWorld())
return; return;
uint32 vehicleId = GetMiscValue(); uint32 vehicleId = GetMiscValue();
@@ -6184,7 +6184,7 @@ void AuraEffect::HandlePreventResurrection(AuraApplication const* aurApp, uint8
if (!(mode & AURA_EFFECT_HANDLE_REAL)) if (!(mode & AURA_EFFECT_HANDLE_REAL))
return; return;
if (aurApp->GetTarget()->GetTypeId() != TYPEID_PLAYER) if (!aurApp->GetTarget()->IsPlayer())
return; return;
if (apply) if (apply)
@@ -6270,7 +6270,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
// Death Rune Mastery // Death Rune Mastery
if (GetSpellInfo()->SpellIconID == 3041 || GetSpellInfo()->SpellIconID == 22 || GetSpellInfo()->SpellIconID == 2622) if (GetSpellInfo()->SpellIconID == 3041 || GetSpellInfo()->SpellIconID == 22 || GetSpellInfo()->SpellIconID == 2622)
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (!target->ToPlayer()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) if (!target->ToPlayer()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY))
return; return;
@@ -6355,7 +6355,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
return; return;
// Inoculate Nestlewood Owlkin // Inoculate Nestlewood Owlkin
case 29528: 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; return;
break; break;
// Feed Captured Animal // Feed Captured Animal
@@ -6367,7 +6367,7 @@ void AuraEffect::HandlePeriodicTriggerSpellAuraTick(Unit* target, Unit* caster)
{ {
// move loot to player inventory and despawn target // move loot to player inventory and despawn target
if (caster && caster->IsPlayer() && if (caster && caster->IsPlayer() &&
target->GetTypeId() == TYPEID_UNIT && target->IsCreature() &&
target->ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_GAS_CLOUD) target->ToCreature()->GetCreatureTemplate()->type == CREATURE_TYPE_GAS_CLOUD)
{ {
Player* player = caster->ToPlayer(); Player* player = caster->ToPlayer();
+3 -3
View File
@@ -380,7 +380,7 @@ Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owne
casterGUID = caster->GetGUID(); casterGUID = caster->GetGUID();
// check if aura can be owned by owner // check if aura can be owned by owner
if (owner->isType(TYPEMASK_UNIT)) if (owner->IsUnit())
if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld()) if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld())
// owner not in world so don't allow to own not self casted single target auras // owner not in world so don't allow to own not self casted single target auras
if (casterGUID != owner->GetGUID() && spellproto->IsSingleTarget()) 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) if (removeMode != AURA_REMOVE_BY_EXPIRE)
break; break;
if (caster->GetTypeId() != TYPEID_PLAYER) if (!caster->IsPlayer())
break; break;
Player* player = caster->ToPlayer(); 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) if (!GetEffect(0) || GetEffect(0)->GetAuraType() != SPELL_AURA_PERIODIC_DUMMY)
break; break;
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
break; break;
if (!target->ToPlayer()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY)) if (!target->ToPlayer()->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_ABILITY))
break; break;
+49 -49
View File
@@ -743,7 +743,7 @@ void Spell::InitExplicitTargets(SpellCastTargets const& targets)
unit = selectedUnit; unit = selectedUnit;
} }
// try to use attacked unit as a target // 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(); unit = m_caster->GetVictim();
// didn't find anything - let's use self as target // 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_5:
case TARGET_UNIT_PASSENGER_6: case TARGET_UNIT_PASSENGER_6:
case TARGET_UNIT_PASSENGER_7: 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); target = m_caster->GetVehicleKit()->GetPassenger(targetType.GetTarget() - TARGET_UNIT_PASSENGER_0);
break; break;
default: default:
@@ -2365,7 +2365,7 @@ void Spell::prepareDataForTriggerSystem(AuraEffect const* /*triggeredByAura*/)
m_procEx |= PROC_EX_INTERNAL_TRIGGERED; m_procEx |= PROC_EX_INTERNAL_TRIGGERED;
} }
// Totem casts require spellfamilymask defined in spell_proc_event to proc // 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; m_procEx |= PROC_EX_INTERNAL_REQ_FAMILY;
} }
@@ -2692,7 +2692,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
{ {
spellHitTarget = m_caster; spellHitTarget = m_caster;
unitTarget = m_caster; unitTarget = m_caster;
if (m_caster->GetTypeId() == TYPEID_UNIT) if (m_caster->IsCreature())
m_caster->ToCreature()->LowerPlayerDamageReq(target->damage); m_caster->ToCreature()->LowerPlayerDamageReq(target->damage);
} }
} }
@@ -2919,7 +2919,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
} }
// Failed Pickpocket, reveal rogue // 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); m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK);
if (unitTarget->ToCreature()->IsAIEnabled) if (unitTarget->ToCreature()->IsAIEnabled)
@@ -2965,19 +2965,19 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target)
} }
// Check for SPELL_ATTR7_CAN_CAUSE_INTERRUPT // 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); caster->CastSpell(effectUnit, SPELL_INTERRUPT_NONPLAYER, true);
if (spellHitTarget) if (spellHitTarget)
{ {
//AI functions //AI functions
if (spellHitTarget->GetTypeId() == TYPEID_UNIT) if (spellHitTarget->IsCreature())
{ {
if (spellHitTarget->ToCreature()->IsAIEnabled) if (spellHitTarget->ToCreature()->IsAIEnabled)
spellHitTarget->ToCreature()->AI()->SpellHit(m_caster, m_spellInfo); 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); m_caster->ToCreature()->AI()->SpellHitTarget(spellHitTarget, m_spellInfo);
// Needs to be called after dealing damage/healing to not remove breaking on damage auras // 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 // Xinef: Also check evade state
if (m_spellInfo->Speed > 0.0f) if (m_spellInfo->Speed > 0.0f)
{ {
if (unit->GetTypeId() == TYPEID_UNIT && unit->ToCreature()->IsInEvadeMode()) if (unit->IsCreature() && unit->ToCreature()->IsInEvadeMode())
return SPELL_MISS_EVADE; return SPELL_MISS_EVADE;
if (unit->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE) && unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID()) 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 // Xinef: Do not increase diminishing level for self cast
m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo, m_triggeredByAuraSpell.spellInfo); m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo, m_triggeredByAuraSpell.spellInfo);
// xinef: do not increase diminish level for bosses (eg. Void Reaver silence is never diminished) // 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); m_diminishLevel = unit->GetDiminishing(m_diminishGroup);
DiminishingReturnsType type = GetDiminishingReturnsGroupType(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 // 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 || 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 // set target for proper facing
if ((m_casttime || m_spellInfo->IsChanneled()) && !HasTriggeredCastFlag(TRIGGERED_IGNORE_SET_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())) ((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 // 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()) if (!playerCaster->m_Controlled.empty())
for (Unit::ControlSet::iterator itr = playerCaster->m_Controlled.begin(); itr != playerCaster->m_Controlled.end(); ++itr) for (Unit::ControlSet::iterator itr = playerCaster->m_Controlled.begin(); itr != playerCaster->m_Controlled.end(); ++itr)
if (Unit* pet = *itr) if (Unit* pet = *itr)
if (pet->IsAlive() && pet->GetTypeId() == TYPEID_UNIT) if (pet->IsAlive() && pet->IsCreature())
pet->ToCreature()->AI()->OwnerAttacked(m_targets.GetUnitTarget()); pet->ToCreature()->AI()->OwnerAttacked(m_targets.GetUnitTarget());
} }
SetExecutedCurrently(true); SetExecutedCurrently(true);
if (!HasTriggeredCastFlag(TRIGGERED_IGNORE_SET_FACING)) 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()); m_caster->SetInFront(m_targets.GetObjectTarget());
CallScriptBeforeCastHandlers(); 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 // 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 (m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_CAUSE_INTERRUPT))
if (Unit* target = m_targets.GetUnitTarget()) if (Unit* target = m_targets.GetUnitTarget())
if (target->GetTypeId() == TYPEID_UNIT) if (target->IsCreature())
m_caster->CastSpell(target, 32747, true); m_caster->CastSpell(target, 32747, true);
// xinef: start combat at cast for delayed spells, only for explicit target // xinef: start combat at cast for delayed spells, only for explicit target
@@ -4346,7 +4346,7 @@ void Spell::_handle_finish_phase()
void Spell::SendSpellCooldown() void Spell::SendSpellCooldown()
{ {
// xinef: properly add creature cooldowns // xinef: properly add creature cooldowns
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
{ {
if (!HasTriggeredCastFlag(TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD)) 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 (m_spellInfo->IsChanneled() && m_caster->IsPlayer())
{ {
if (Unit* charm = m_caster->GetCharm()) if (Unit* charm = m_caster->GetCharm())
if (charm->GetTypeId() == TYPEID_UNIT if (charm->IsCreature()
&& charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET) && charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_PUPPET)
&& charm->GetUInt32Value(UNIT_CREATED_BY_SPELL) == m_spellInfo->Id) && charm->GetUInt32Value(UNIT_CREATED_BY_SPELL) == m_spellInfo->Id)
((Puppet*)charm)->UnSummon(); ((Puppet*)charm)->UnSummon();
@@ -4521,7 +4521,7 @@ void Spell::finish(bool ok)
if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_ENCOUNTER_REWARD) && m_caster->FindMap()) 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); 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 // Unsummon statue
uint32 spell = m_caster->GetUInt32Value(UNIT_CREATED_BY_SPELL); uint32 spell = m_caster->GetUInt32Value(UNIT_CREATED_BY_SPELL);
@@ -4673,7 +4673,7 @@ void Spell::SendCastResult(SpellCastResult result)
if (result == SPELL_CAST_OK) if (result == SPELL_CAST_OK)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER || m_caster->IsCharmed()) if (!m_caster->IsPlayer() || m_caster->IsCharmed())
return; return;
if (m_caster->ToPlayer()->GetSession()->PlayerLoading()) // don't send cast results at loading time 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() void Spell::TakeCastItem()
{ {
if (!m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_CastItem || !m_caster->IsPlayer())
return; return;
// not remove cast item at triggered spell (equipping, weapon damage, etc) // 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) if (m_spellInfo->PowerType != POWER_RUNE || !RuneCostID)
return SPELL_CAST_OK; return SPELL_CAST_OK;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_CAST_OK; return SPELL_CAST_OK;
Player* player = m_caster->ToPlayer(); Player* player = m_caster->ToPlayer();
@@ -5452,7 +5452,7 @@ SpellCastResult Spell::CheckRuneCost(uint32 RuneCostID)
void Spell::TakeRunePower(bool didHit) 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; return;
SpellRuneCostEntry const* runeCostData = sSpellRuneCostStore.LookupEntry(m_spellInfo->RuneCostID); SpellRuneCostEntry const* runeCostData = sSpellRuneCostStore.LookupEntry(m_spellInfo->RuneCostID);
@@ -5521,7 +5521,7 @@ void Spell::TakeRunePower(bool didHit)
void Spell::TakeReagents() void Spell::TakeReagents()
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
ItemTemplate const* castItemTemplate = m_CastItem ? m_CastItem->GetTemplate() : nullptr; 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())) if (m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent()))
return SPELL_FAILED_NOT_READY; 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; return SPELL_FAILED_NOT_READY;
} }
@@ -5987,7 +5987,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_NOT_IN_ARENA; return SPELL_FAILED_NOT_IN_ARENA;
// zone check // zone check
if (m_caster->GetTypeId() == TYPEID_UNIT || !m_caster->ToPlayer()->IsGameMaster()) if (m_caster->IsCreature() || !m_caster->ToPlayer()->IsGameMaster())
{ {
uint32 zone, area; uint32 zone, area;
m_caster->GetZoneAndAreaId(zone, area); m_caster->GetZoneAndAreaId(zone, area);
@@ -6114,7 +6114,7 @@ SpellCastResult Spell::CheckCast(bool strict)
{ {
case SPELL_EFFECT_LEARN_SPELL: case SPELL_EFFECT_LEARN_SPELL:
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
if (m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_UNIT_PET) 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 // check target only for unit target case
if (Unit* unitTarget = m_targets.GetUnitTarget()) if (Unit* unitTarget = m_targets.GetUnitTarget())
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
Pet* pet = unitTarget->ToPet(); Pet* pet = unitTarget->ToPet();
@@ -6167,7 +6167,7 @@ SpellCastResult Spell::CheckCast(bool strict)
} }
case SPELL_EFFECT_FEED_PET: case SPELL_EFFECT_FEED_PET:
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
Item* foodItem = m_targets.GetItemTarget(); Item* foodItem = m_targets.GetItemTarget();
@@ -6260,7 +6260,7 @@ SpellCastResult Spell::CheckCast(bool strict)
} }
case SPELL_EFFECT_SKINNING: 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; return SPELL_FAILED_BAD_TARGETS;
if (!(m_targets.GetUnitTarget()->GetUnitFlags() & UNIT_FLAG_SKINNABLE)) 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) m_spellInfo->Effects[i].TargetA.GetTarget() != TARGET_GAMEOBJECT_ITEM_TARGET)
break; 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 // we need a go target in case of TARGET_GAMEOBJECT_TARGET
|| (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget())) || (m_spellInfo->Effects[i].TargetA.GetTarget() == TARGET_GAMEOBJECT_TARGET && !m_targets.GetGOTarget()))
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
@@ -6410,7 +6410,7 @@ SpellCastResult Spell::CheckCast(bool strict)
{ {
if (m_targets.GetUnitTarget()) if (m_targets.GetUnitTarget())
{ {
if (m_targets.GetUnitTarget()->GetTypeId() != TYPEID_PLAYER) if (!m_targets.GetUnitTarget()->IsPlayer())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
if (m_targets.GetUnitTarget()->GetPetGUID()) if (m_targets.GetUnitTarget()->GetPetGUID())
return SPELL_FAILED_ALREADY_HAVE_SUMMON; return SPELL_FAILED_ALREADY_HAVE_SUMMON;
@@ -6472,7 +6472,7 @@ SpellCastResult Spell::CheckCast(bool strict)
} }
case SPELL_EFFECT_SUMMON_PLAYER: case SPELL_EFFECT_SUMMON_PLAYER:
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
if (!m_caster->GetTarget()) if (!m_caster->GetTarget())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
@@ -6507,7 +6507,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// RETURN HERE // RETURN HERE
case SPELL_EFFECT_SUMMON_RAF_FRIEND: case SPELL_EFFECT_SUMMON_RAF_FRIEND:
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
Player* playerCaster = m_caster->ToPlayer(); Player* playerCaster = m_caster->ToPlayer();
@@ -6602,7 +6602,7 @@ SpellCastResult Spell::CheckCast(bool strict)
break; break;
case SPELL_AURA_MOD_POSSESS_PET: case SPELL_AURA_MOD_POSSESS_PET:
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_NO_PET; return SPELL_FAILED_NO_PET;
Pet* pet = m_caster->ToPlayer()->GetPet(); Pet* pet = m_caster->ToPlayer()->GetPet();
@@ -6637,7 +6637,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (Unit* target = m_targets.GetUnitTarget()) 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; return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
if (target->IsMounted()) if (target->IsMounted())
@@ -6719,7 +6719,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_spellInfo->Effects[i].IsTargetingArea()) if (m_spellInfo->Effects[i].IsTargetingArea())
break; break;
if (m_caster->GetTypeId() != TYPEID_PLAYER || m_CastItem) if (!m_caster->IsPlayer() || m_CastItem)
break; break;
if (!m_targets.GetUnitTarget()) if (!m_targets.GetUnitTarget())
@@ -6757,7 +6757,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_CastItem) if (m_CastItem)
return SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW; return SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_NOT_TRADING; return SPELL_FAILED_NOT_TRADING;
TradeData* my_trade = m_caster->ToPlayer()->GetTradeData(); 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); float min_range = m_caster->GetSpellMinRangeForTarget(target, m_spellInfo);
// xinef: hack for npc shooters // 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; range_type = SPELL_RANGE_RANGED;
if (Player* modOwner = m_caster->GetSpellModOwner()) if (Player* modOwner = m_caster->GetSpellModOwner())
@@ -7076,7 +7076,7 @@ SpellCastResult Spell::CheckRange(bool strict)
if (range_type == SPELL_RANGE_MELEE) if (range_type == SPELL_RANGE_MELEE)
{ {
float real_max_range = max_range; 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) 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 else
real_max_range -= 2 * MIN_MELEE_REACH; real_max_range -= 2 * MIN_MELEE_REACH;
@@ -7255,7 +7255,7 @@ SpellCastResult Spell::CheckItems()
// check target item // check target item
if (m_targets.GetItemTargetGUID()) if (m_targets.GetItemTargetGUID())
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_BAD_TARGETS; return SPELL_FAILED_BAD_TARGETS;
if (!m_targets.GetItemTarget()) if (!m_targets.GetItemTarget())
@@ -7606,7 +7606,7 @@ SpellCastResult Spell::CheckItems()
case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return SPELL_FAILED_TARGET_NOT_PLAYER; return SPELL_FAILED_TARGET_NOT_PLAYER;
if (m_attackType != RANGED_ATTACK) if (m_attackType != RANGED_ATTACK)
@@ -7760,7 +7760,7 @@ SpellCastResult Spell::CheckSpellFocus()
void Spell::Delayed() // only called in DealDamage() void Spell::Delayed() // only called in DealDamage()
{ {
if (!m_caster)// || m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster)// || !m_caster->IsPlayer())
return; return;
//if (m_spellState == SPELL_STATE_DELAYED) //if (m_spellState == SPELL_STATE_DELAYED)
@@ -7805,7 +7805,7 @@ void Spell::Delayed() // only called in DealDamage()
void Spell::DelayedChannel() 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; return;
if (isDelayableNoMore()) // Spells may only be delayed twice 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_CHARM:
case SPELL_AURA_MOD_POSSESS_PET: case SPELL_AURA_MOD_POSSESS_PET:
case SPELL_AURA_AOE_CHARM: case SPELL_AURA_AOE_CHARM:
if (target->GetTypeId() == TYPEID_UNIT && target->IsVehicle()) if (target->IsCreature() && target->IsVehicle())
return false; return false;
if (target->IsMounted()) if (target->IsMounted())
return false; 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 // 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 // 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; return true;
// if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour // 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; break;
case SPELL_EFFECT_SUMMON_RAF_FRIEND: case SPELL_EFFECT_SUMMON_RAF_FRIEND:
if (m_caster->GetTypeId() != TYPEID_PLAYER || target->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer() || !target->IsPlayer())
return false; return false;
if (m_caster->ToPlayer()->GetSession()->IsARecruiter() && target->ToPlayer()->GetSession()->GetRecruiterId() != m_caster->ToPlayer()->GetSession()->GetAccountId()) if (m_caster->ToPlayer()->GetSession()->IsARecruiter() && target->ToPlayer()->GetSession()->GetRecruiterId() != m_caster->ToPlayer()->GetSession()->GetAccountId())
return false; return false;
@@ -8385,7 +8385,7 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk
reqSkillValue = lockInfo->Skill[j]; reqSkillValue = lockInfo->Skill[j];
// castitem check: rogue using skeleton keys. the skill values should not be added in this case. // 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); 0 : m_caster->ToPlayer()->GetSkillValue(skillId);
// skill bonus provided by casting spell (mostly item spells) // skill bonus provided by casting spell (mostly item spells)
@@ -9035,14 +9035,14 @@ namespace Acore
bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target) bool WorldObjectSpellAreaTargetCheck::operator()(WorldObject* target)
{ {
if (target->GetTypeId() == TYPEID_GAMEOBJECT) if (target->IsGameObject())
{ {
if (!target->ToGameObject()->IsInRange(_position->GetPositionX(), _position->GetPositionY(), _position->GetPositionZ(), _range)) if (!target->ToGameObject()->IsInRange(_position->GetPositionX(), _position->GetPositionY(), _position->GetPositionZ(), _range))
return false; return false;
} }
else if (!target->IsWithinDist3d(_position, _range)) else if (!target->IsWithinDist3d(_position, _range))
return false; return false;
else if (target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsAvoidingAOE()) // pussywizard else if (target->IsCreature() && target->ToCreature()->IsAvoidingAOE()) // pussywizard
return false; return false;
return WorldObjectSpellTargetCheck::operator ()(target); return WorldObjectSpellTargetCheck::operator ()(target);
} }
+41 -41
View File
@@ -257,7 +257,7 @@ void Spell::EffectResurrectNew(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->IsAlive()) if (!unitTarget || unitTarget->IsAlive())
return; return;
if (unitTarget->GetTypeId() != TYPEID_PLAYER) if (!unitTarget->IsPlayer())
return; return;
if (!unitTarget->IsInWorld()) if (!unitTarget->IsInWorld())
@@ -435,7 +435,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
// Shadow Bite // Shadow Bite
else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000) 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()) 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); 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()); 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) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
{ {
LOG_DEBUG("spells.aura", "WORLD: Open Lock - No Player Caster!"); LOG_DEBUG("spells.aura", "WORLD: Open Lock - No Player Caster!");
return; return;
@@ -2182,7 +2182,7 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* player = m_caster->ToPlayer(); Player* player = m_caster->ToPlayer();
@@ -2291,7 +2291,7 @@ void Spell::EffectProficiency(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* p_target = m_caster->ToPlayer(); Player* p_target = m_caster->ToPlayer();
@@ -2524,7 +2524,7 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex)
if (!unitTarget) if (!unitTarget)
return; return;
if (unitTarget->GetTypeId() != TYPEID_PLAYER) if (!unitTarget->IsPlayer())
{ {
if (unitTarget->ToPet()) if (unitTarget->ToPet())
EffectLearnPetSpell(effIndex); EffectLearnPetSpell(effIndex);
@@ -2686,7 +2686,7 @@ void Spell::EffectPickPocket(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
m_caster->ToPlayer()->SendLoot(unitTarget->GetGUID(), LOOT_PICKPOCKETING); m_caster->ToPlayer()->SendLoot(unitTarget->GetGUID(), LOOT_PICKPOCKETING);
@@ -2697,7 +2697,7 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
float radius = m_spellInfo->Effects[effIndex].CalcRadius(); float radius = m_spellInfo->Effects[effIndex].CalcRadius();
@@ -2751,7 +2751,7 @@ void Spell::EffectLearnSkill(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (unitTarget->GetTypeId() != TYPEID_PLAYER) if (!unitTarget->IsPlayer())
return; return;
if (damage < 0) if (damage < 0)
@@ -2767,7 +2767,7 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (unitTarget->GetTypeId() != TYPEID_PLAYER) if (!unitTarget->IsPlayer())
return; return;
// not scale value for item based reward (/10 value expected) // 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) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
// uint32 skillid = m_spellInfo->Effects[i].MiscValue; // uint32 skillid = m_spellInfo->Effects[i].MiscValue;
// uint16 skillmax = unitTarget->ToPlayer()->(skillid); // uint16 skillmax = unitTarget->ToPlayer()->(skillid);
@@ -2813,7 +2813,7 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
if (!itemTarget) if (!itemTarget)
return; return;
@@ -2869,7 +2869,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
if (!itemTarget) if (!itemTarget)
return; return;
@@ -2923,7 +2923,7 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* p_caster = m_caster->ToPlayer(); Player* p_caster = m_caster->ToPlayer();
@@ -3070,7 +3070,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/)
if (!unitTarget) if (!unitTarget)
return; return;
if (unitTarget->GetTypeId() != TYPEID_UNIT) if (!unitTarget->IsCreature())
return; return;
Creature* creatureTarget = unitTarget->ToCreature(); Creature* creatureTarget = unitTarget->ToCreature();
@@ -3199,7 +3199,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
if (!pet) if (!pet)
return; return;
if (m_caster->GetTypeId() == TYPEID_UNIT) if (m_caster->IsCreature())
{ {
if (m_caster->ToCreature()->IsTotem()) if (m_caster->ToCreature()->IsTotem())
pet->SetReactState(REACT_AGGRESSIVE); pet->SetReactState(REACT_AGGRESSIVE);
@@ -3831,7 +3831,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
/*// Mug Transformation /*// Mug Transformation
case 41931: case 41931:
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
uint8 bag = 19; uint8 bag = 19;
@@ -3874,12 +3874,12 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
} }
case 52173: // Coyote Spirit Despawn case 52173: // Coyote Spirit Despawn
case 60243: // Blood Parrot Despawn case 60243: // Blood Parrot Despawn
if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->ToCreature()->IsSummon()) if (unitTarget->IsCreature() && unitTarget->ToCreature()->IsSummon())
unitTarget->ToTempSummon()->UnSummon(); unitTarget->ToTempSummon()->UnSummon();
return; return;
case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) 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; return;
unitTarget->ToCreature()->DespawnOrUnsummon(); unitTarget->ToCreature()->DespawnOrUnsummon();
@@ -3888,7 +3888,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
} }
case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell)
{ {
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
// Delete item from inventory at death // Delete item from inventory at death
@@ -3899,7 +3899,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
case 58418: // Portal to Orgrimmar case 58418: // Portal to Orgrimmar
case 58420: // Portal to Stormwind case 58420: // Portal to Stormwind
{ {
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effIndex != 0) if (!unitTarget || !unitTarget->IsPlayer() || effIndex != 0)
return; return;
uint32 spellID = m_spellInfo->Effects[EFFECT_0].CalcValue(); 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()) if ((*iter)->GetCurrentSpell(i) && (*iter)->GetCurrentSpell(i)->m_targets.GetUnitTargetGUID() == unitTarget->GetGUID())
{ {
SpellInfo const* si = (*iter)->GetCurrentSpell(i)->GetSpellInfo(); 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(); Creature* c = (*iter)->ToCreature();
if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss()) 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) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER || unitTarget->GetTypeId() != TYPEID_PLAYER) if (!unitTarget || !m_caster->IsPlayer() || !unitTarget->IsPlayer())
return; return;
Player* caster = m_caster->ToPlayer(); Player* caster = m_caster->ToPlayer();
@@ -4161,7 +4161,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* target = m_caster->ToPlayer(); Player* target = m_caster->ToPlayer();
@@ -4311,7 +4311,7 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX) if (!m_caster->IsPlayer() || m_glyphIndex >= MAX_GLYPH_SLOT_INDEX)
return; return;
Player* player = m_caster->ToPlayer(); 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 // xinef: we should also force pets to remove us from current target
Unit::AttackerSet attackerSet; Unit::AttackerSet attackerSet;
for (Unit::AttackerSet::const_iterator itr = m_caster->getAttackers().begin(); itr != m_caster->getAttackers().end(); ++itr) 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); attackerSet.insert(*itr);
for (Unit::AttackerSet::const_iterator itr = attackerSet.begin(); itr != attackerSet.end(); ++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()) if (spell->m_targets.GetUnitTargetGUID() == m_caster->GetGUID())
{ {
SpellInfo const* si = spell->GetSpellInfo(); 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(); Creature* c = (*iter)->ToCreature();
if ((!c->IsPet() && c->GetCreatureTemplate()->rank == CREATURE_ELITE_WORLDBOSS) || c->isWorldBoss() || c->IsDungeonBoss()) 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()) if (!m_caster || m_caster->IsAlive())
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
if (!m_caster->IsInWorld()) if (!m_caster->IsInWorld())
return; return;
@@ -4870,9 +4870,9 @@ void Spell::EffectSkinning(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (unitTarget->GetTypeId() != TYPEID_UNIT) if (!unitTarget->IsCreature())
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Creature* creature = unitTarget->ToCreature(); Creature* creature = unitTarget->ToCreature();
@@ -5472,7 +5472,7 @@ void Spell::EffectProspecting(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* p_caster = m_caster->ToPlayer(); Player* p_caster = m_caster->ToPlayer();
@@ -5497,7 +5497,7 @@ void Spell::EffectMilling(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* p_caster = m_caster->ToPlayer(); Player* p_caster = m_caster->ToPlayer();
@@ -5535,7 +5535,7 @@ void Spell::EffectSpiritHeal(SpellEffIndex /*effIndex*/)
return; return;
/* /*
if (unitTarget->GetTypeId() != TYPEID_PLAYER) if (!unitTarget->IsPlayer())
return; return;
if (!unitTarget->IsInWorld()) if (!unitTarget->IsInWorld())
return; return;
@@ -5554,7 +5554,7 @@ void Spell::EffectSkinPlayerCorpse(SpellEffIndex /*effIndex*/)
return; return;
LOG_DEBUG("spells.aura", "Effect: SkinPlayerCorpse"); 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; return;
unitTarget->ToPlayer()->RemovedInsignia(m_caster->ToPlayer()); unitTarget->ToPlayer()->RemovedInsignia(m_caster->ToPlayer());
@@ -5747,7 +5747,7 @@ void Spell::EffectActivateRune(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH) if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* player = m_caster->ToPlayer(); Player* player = m_caster->ToPlayer();
@@ -5820,7 +5820,7 @@ void Spell::EffectCreateTamedPet(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; 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; return;
uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue; uint32 creatureEntry = m_spellInfo->Effects[effIndex].MiscValue;
@@ -6088,7 +6088,7 @@ void Spell::EffectRenamePet(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || if (!unitTarget || !unitTarget->IsCreature() ||
!unitTarget->IsPet() || unitTarget->ToPet()->getPetType() != HUNTER_PET) !unitTarget->IsPet() || unitTarget->ToPet()->getPetType() != HUNTER_PET)
return; return;
@@ -6199,7 +6199,7 @@ void Spell::EffectCastButtons(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
Player* p_caster = m_caster->ToPlayer(); Player* p_caster = m_caster->ToPlayer();
@@ -6242,7 +6242,7 @@ void Spell::EffectRechargeManaGem(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) if (!unitTarget || !unitTarget->IsPlayer())
return; return;
Player* player = m_caster->ToPlayer(); Player* player = m_caster->ToPlayer();
@@ -6319,7 +6319,7 @@ void Spell::EffectSummonRaFFriend(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET) if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return; return;
if (m_caster->GetTypeId() != TYPEID_PLAYER) if (!m_caster->IsPlayer())
return; return;
if (!unitTarget) if (!unitTarget)
+2 -2
View File
@@ -343,9 +343,9 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const*
case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_MONSTER_WHISPER:
case CHAT_MSG_RAID_BOSS_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; return;
target->ToPlayer()->GetSession()->SendPacket(data); target->ToPlayer()->GetSession()->SendPacket(data);
+2 -2
View File
@@ -189,9 +189,9 @@ void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder
case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_MONSTER_WHISPER:
case CHAT_MSG_RAID_BOSS_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; return;
localizer(const_cast<Player*>(target->ToPlayer())); localizer(const_cast<Player*>(target->ToPlayer()));
+1 -1
View File
@@ -263,7 +263,7 @@ public:
Unit* unit = handler->getSelectedUnit(); Unit* unit = handler->getSelectedUnit();
Player* player = nullptr; Player* player = nullptr;
if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) if (!unit || (!unit->IsPlayer()))
{ {
player = handler->GetSession()->GetPlayer(); player = handler->GetSession()->GetPlayer();
} }
+4 -4
View File
@@ -1142,7 +1142,7 @@ public:
{ {
if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE)) 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()); target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
} }
@@ -2393,7 +2393,7 @@ public:
Unit* target = handler->getSelectedUnit(); Unit* target = handler->getSelectedUnit();
if (player->GetTarget() && target) if (player->GetTarget() && target)
{ {
if (target->GetTypeId() != TYPEID_UNIT || target->IsPet()) if (!target->IsCreature() || target->IsPet())
{ {
handler->SendErrorMessage(LANG_SELECT_CREATURE); handler->SendErrorMessage(LANG_SELECT_CREATURE);
return false; return false;
@@ -2745,7 +2745,7 @@ public:
} }
case HOME_MOTION_TYPE: case HOME_MOTION_TYPE:
{ {
if (unit->GetTypeId() == TYPEID_UNIT) if (unit->IsCreature())
{ {
handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z);
} }
@@ -2816,7 +2816,7 @@ public:
if (!target->IsAlive() || !damage) if (!target->IsAlive() || !damage)
return true; 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()); target->ToCreature()->LowerPlayerDamageReq(target->GetMaxHealth());
if (percent) if (percent)
+1 -1
View File
@@ -336,7 +336,7 @@ public:
return false; return false;
Unit* unit = handler->getSelectedUnit(); Unit* unit = handler->getSelectedUnit();
if (!unit || unit->GetTypeId() != TYPEID_UNIT) if (!unit || !unit->IsCreature())
{ {
handler->SendErrorMessage(LANG_SELECT_CREATURE); handler->SendErrorMessage(LANG_SELECT_CREATURE);
return false; return false;
@@ -221,7 +221,7 @@ public:
void IsSummonedBy(WorldObject* summoner) override void IsSummonedBy(WorldObject* summoner) override
{ {
if (summoner->GetTypeId() != TYPEID_UNIT) if (!summoner->IsCreature())
{ {
return; return;
} }
@@ -212,7 +212,7 @@ struct ClassCallSelector : public Acore::unary_function<Unit*, bool>
bool operator()(Unit const* target) const bool operator()(Unit const* target) const
{ {
if (!_me || !target || target->GetTypeId() != TYPEID_PLAYER) if (!_me || !target || !target->IsPlayer())
{ {
return false; return false;
} }
@@ -1114,7 +1114,7 @@ class spell_class_call_polymorph : public SpellScript
{ {
targets.remove_if([&](WorldObject const* target) -> bool 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()) if (!targets.empty())
@@ -110,7 +110,7 @@ public:
bool CanAIAttack(Unit const* target) const override bool CanAIAttack(Unit const* target) const override
{ {
if (target->GetTypeId() == TYPEID_UNIT && !secondPhase) if (target->IsCreature() && !secondPhase)
{ {
return false; return false;
} }
@@ -587,7 +587,7 @@ class spell_hate_to_zero : public SpellScript
bool Load() override bool Load() override
{ {
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void HandleHit(SpellEffIndex /*effIndex*/) void HandleHit(SpellEffIndex /*effIndex*/)
@@ -129,7 +129,7 @@ class spell_mc_play_dead_aura : public AuraScript
bool Load() override bool Load() override
{ {
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -155,7 +155,7 @@ struct boss_priestess_delrissa : public ScriptedAI
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() != TYPEID_PLAYER) if (!victim->IsPlayer())
return; return;
if (PlayersKilled < SAY_DEATH) if (PlayersKilled < SAY_DEATH)
@@ -678,7 +678,7 @@ public:
void MoveInLineOfSight(Unit* who) override 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; return;
if (MeetQuestCondition(who->ToPlayer())) if (MeetQuestCondition(who->ToPlayer()))
@@ -458,7 +458,7 @@ public:
{ {
Position pos = LightOfDawnFightPos[urand(0, 9)]; Position pos = LightOfDawnFightPos[urand(0, 9)];
if (Unit* target = cr->SelectNearbyTarget(nullptr, 10.0f)) 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)); 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)); cr->GetMotionMaster()->MoveCharge(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), me->GetSpeed(MOVE_RUN));
} }
@@ -389,7 +389,7 @@ public:
void IsSummonedBy(WorldObject* summoner) override void IsSummonedBy(WorldObject* summoner) override
{ {
if (summoner->GetTypeId() != TYPEID_UNIT) if (!summoner->IsCreature())
{ {
return; return;
} }
@@ -64,7 +64,7 @@ public:
void OnUnitDeath(Unit* unit) override 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()); _dragonkinList.remove(unit->GetGUID());
if (unit->GetEntry() == NPC_JAMMAL_AN_THE_PROPHET) if (unit->GetEntry() == NPC_JAMMAL_AN_THE_PROPHET)
{ {
@@ -533,7 +533,7 @@ class DoorsGuidCheck
public: public:
bool operator()(WorldObject* object) const bool operator()(WorldObject* object) const
{ {
if (object->GetTypeId() != TYPEID_UNIT) if (!object->IsCreature())
return true; return true;
Creature* cr = object->ToCreature(); Creature* cr = object->ToCreature();
@@ -1088,7 +1088,7 @@ class spell_kiljaeden_sinister_reflection_clone : public SpellScript
WorldObject* target = targets.front(); WorldObject* target = targets.front();
targets.clear(); targets.clear();
if (target && target->GetTypeId() == TYPEID_UNIT) if (target && target->IsCreature())
{ {
target->ToCreature()->AI()->SetData(1, GetCaster()->getClass()); target->ToCreature()->AI()->SetData(1, GetCaster()->getClass());
targets.push_back(target); targets.push_back(target);
@@ -1133,7 +1133,7 @@ class spell_kiljaeden_darkness_aura : public AuraScript
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
if (GetUnitOwner()->GetTypeId() == TYPEID_UNIT) if (GetUnitOwner()->IsCreature())
GetUnitOwner()->ToCreature()->AI()->DoAction(ACTION_NO_KILL_TALK); GetUnitOwner()->ToCreature()->AI()->DoAction(ACTION_NO_KILL_TALK);
GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_DARKNESS_OF_A_THOUSAND_SOULS_DAMAGE, true); GetUnitOwner()->CastSpell(GetUnitOwner(), SPELL_DARKNESS_OF_A_THOUSAND_SOULS_DAMAGE, true);
@@ -393,7 +393,7 @@ class spell_entropius_negative_energy : public SpellScript
bool Load() override bool Load() override
{ {
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void FilterTargets(std::list<WorldObject*>& targets) void FilterTargets(std::list<WorldObject*>& targets)
@@ -183,7 +183,7 @@ public:
bool Load() override 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*/) void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -209,7 +209,7 @@ public:
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() != TYPEID_PLAYER) if (!victim->IsPlayer())
return; return;
reviveGUID = victim->GetGUID(); reviveGUID = victim->GetGUID();
@@ -449,7 +449,7 @@ public:
{ {
if (!me || !target) if (!me || !target)
return false; return false;
if (target->GetTypeId() != TYPEID_PLAYER || !me->IsWithinLOSInMap(target)) if (!target->IsPlayer() || !me->IsWithinLOSInMap(target))
return false; return false;
return true; return true;
})) }))
@@ -540,7 +540,7 @@ public:
void JustEngagedWith(Unit* who) override void JustEngagedWith(Unit* who) override
{ {
if (who->GetTypeId() != TYPEID_PLAYER) if (!who->IsPlayer())
return; return;
_scheduler.Schedule(6s, 12s, [this](TaskContext context) _scheduler.Schedule(6s, 12s, [this](TaskContext context)
@@ -557,7 +557,7 @@ public:
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() != TYPEID_PLAYER) if (!victim->IsPlayer())
return; return;
reviveGUID = victim->GetGUID(); reviveGUID = victim->GetGUID();
@@ -217,7 +217,7 @@ private:
{ {
Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [this](Unit* target) -> bool 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; return false;
if (me->IsWithinMeleeRange(target) || me->GetVictim() == target) if (me->IsWithinMeleeRange(target) || me->GetVictim() == target)
return false; return false;
@@ -239,7 +239,7 @@ public:
{ {
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) 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); summoner->ToCreature()->AI()->AttackStart(who);
} }
} }
@@ -253,7 +253,7 @@ public:
{ {
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
{ {
if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive()) if (summoner->IsCreature() && summoner->IsAlive())
summoner->ToCreature()->DisappearAndDie(); summoner->ToCreature()->DisappearAndDie();
} }
} }
@@ -267,7 +267,7 @@ public:
if (me->IsSummon()) if (me->IsSummon())
{ {
Unit* summoner = me->ToTempSummon()->GetSummonerUnit(); 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 = npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI* ai =
CAST_AI(npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI, summoner->GetAI()); CAST_AI(npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI, summoner->GetAI());
@@ -140,7 +140,7 @@ public:
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if (!who || who->GetTypeId() != TYPEID_PLAYER) if (!who || !who->IsPlayer())
return; return;
if (me->FindNearestGameObject(GO_BEACON_TORCH, 10.0f)) if (me->FindNearestGameObject(GO_BEACON_TORCH, 10.0f))
+1 -1
View File
@@ -1584,7 +1584,7 @@ struct npc_coren_direbrew : public ScriptedAI
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if (!_events.IsInPhase(PHASE_ALL) || who->GetTypeId() != TYPEID_PLAYER) if (!_events.IsInPhase(PHASE_ALL) || !who->IsPlayer())
{ {
return; return;
} }
+2 -2
View File
@@ -332,7 +332,7 @@ struct npc_midsummer_bonfire : public ScriptedAI
void SpellHit(Unit* caster, SpellInfo const* spellInfo) override void SpellHit(Unit* caster, SpellInfo const* spellInfo) override
{ {
if (caster->GetTypeId() != TYPEID_PLAYER) if (!caster->IsPlayer())
return; return;
switch (spellInfo->Id) switch (spellInfo->Id)
@@ -1172,7 +1172,7 @@ class spell_midsummer_juggling_torch : public SpellScript
void HandleFinish() void HandleFinish()
{ {
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER) if (!caster || !caster->IsPlayer())
return; return;
if (const WorldLocation* loc = GetExplTargetDest()) if (const WorldLocation* loc = GetExplTargetDest())
@@ -571,7 +571,7 @@ class spell_pilgrims_bounty_serve_generic : public AuraScript
void OnAuraRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void OnAuraRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{ {
Unit* target = GetTarget(); Unit* target = GetTarget();
if (target->GetTypeId() == TYPEID_UNIT) if (target->IsCreature())
target->ToCreature()->AI()->DoAction(GetSpellInfo()->Id); target->ToCreature()->AI()->DoAction(GetSpellInfo()->Id);
} }
@@ -90,7 +90,7 @@ struct boss_aeonus : public BossAI
void MoveInLineOfSight(Unit* who) override 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)) if (me->IsWithinDistInMap(who, 20.0f))
{ {
@@ -79,7 +79,7 @@ enum Spells
void MoveInLineOfSight(Unit* who) override 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)) if (me->IsWithinDistInMap(who, 20.0f))
{ {
@@ -90,7 +90,7 @@ struct boss_temporus : public BossAI
void MoveInLineOfSight(Unit* who) override 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)) if (me->IsWithinDistInMap(who, 20.0f))
{ {
@@ -367,7 +367,7 @@ struct boss_vem : public boss_bug_trio
{ {
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [this](Unit* target) -> bool if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, [this](Unit* target) -> bool
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return false; return false;
if (me->IsWithinMeleeRange(target) || target == me->GetVictim()) if (me->IsWithinMeleeRange(target) || target == me->GetVictim())
return false; return false;
+1 -1
View File
@@ -180,7 +180,7 @@ public:
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() != TYPEID_UNIT || !victim->IsSummon()) if (!victim->IsCreature() || !victim->IsSummon())
return; return;
if (Unit* vehSummoner = victim->ToTempSummon()->GetSummonerUnit()) if (Unit* vehSummoner = victim->ToTempSummon()->GetSummonerUnit())
@@ -124,7 +124,7 @@ public:
return; return;
//only aggro text if not player and only in this area //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?) //appears to be pretty much random (possible only if escorter not in combat with who yet?)
Talk(SAY_GIL_AGGRO, who); Talk(SAY_GIL_AGGRO, who);
@@ -325,7 +325,7 @@ public:
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if (!who->IsAlive() || EventInProgress || who->GetTypeId() != TYPEID_PLAYER) if (!who->IsAlive() || EventInProgress || !who->IsPlayer())
return; return;
if (me->IsWithinDistInMap(who, 10.0f) && who->ToPlayer()->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) if (me->IsWithinDistInMap(who, 10.0f) && who->ToPlayer()->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE)
@@ -95,7 +95,7 @@ public:
void MoveInLineOfSight(Unit* who) override void MoveInLineOfSight(Unit* who) override
{ {
if (who->GetTypeId() != TYPEID_PLAYER) if (!who->IsPlayer())
return; return;
if (!_initTalk) if (!_initTalk)
@@ -347,7 +347,7 @@ class spell_herald_volzaj_insanity : public SpellScript
{ {
PrepareSpellScript(spell_herald_volzaj_insanity); PrepareSpellScript(spell_herald_volzaj_insanity);
bool Load() override { return GetCaster()->GetTypeId() == TYPEID_UNIT; } bool Load() override { return GetCaster()->IsCreature(); }
void HandleDummyEffect(std::list<WorldObject*>& targets) void HandleDummyEffect(std::list<WorldObject*>& targets)
{ {
@@ -362,7 +362,7 @@ class spell_herald_volzaj_insanity : public SpellScript
{ {
targets.remove_if([this](WorldObject* targetObj) -> bool 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); 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 */) void HandleScriptEffect(SpellEffIndex /* effIndex */)
{ {
@@ -333,7 +333,7 @@ struct boss_jedoga_shadowseeker : public BossAI
void KilledUnit(Unit* who) override void KilledUnit(Unit* who) override
{ {
if (who->GetTypeId() != TYPEID_PLAYER) if (!who->IsPlayer())
{ {
return; return;
} }
@@ -307,7 +307,7 @@ struct boss_taldaram : public BossAI
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() != TYPEID_PLAYER) if (!victim->IsPlayer())
{ {
return; return;
} }
@@ -925,7 +925,7 @@ struct boss_sartharion_dragonAI : public BossAI
void KilledUnit(Unit* victim) final void KilledUnit(Unit* victim) final
{ {
if (victim->GetTypeId() != TYPEID_PLAYER || urand(0, 2)) if (!victim->IsPlayer() || urand(0, 2))
{ {
return; return;
} }
@@ -1053,7 +1053,7 @@ class spell_halion_twilight_phasing : public SpellScript
bool Load() override bool Load() override
{ {
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void Phase() void Phase()
@@ -1116,7 +1116,7 @@ class spell_halion_twilight_realm_aura : public AuraScript
return; return;
target->RemoveAurasDueToSpell(SPELL_FIERY_COMBUSTION, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL); target->RemoveAurasDueToSpell(SPELL_FIERY_COMBUSTION, ObjectGuid::Empty, 0, AURA_REMOVE_BY_ENEMY_SPELL);
if (GetTarget()->GetTypeId() != TYPEID_PLAYER) if (!GetTarget()->IsPlayer())
return; return;
GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500)); 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); GetTarget()->RemoveAurasDueToSpell(SPELL_TWILIGHT_REALM);
if (GetTarget()->GetTypeId() != TYPEID_PLAYER) if (!GetTarget()->IsPlayer())
return; return;
GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500)); GetTarget()->m_Events.AddEvent(new SendEncounterUnit(GetTarget()->ToPlayer()), GetTarget()->m_Events.CalculateTime(500));
} }
@@ -765,7 +765,7 @@ class spell_toc5_light_rain : public SpellScript
{ {
for( std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ) for( std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); )
{ {
if ((*itr)->GetTypeId() == TYPEID_UNIT) if ((*itr)->IsCreature())
if ((*itr)->ToCreature()->GetEntry() == NPC_FOUNTAIN_OF_LIGHT) if ((*itr)->ToCreature()->GetEntry() == NPC_FOUNTAIN_OF_LIGHT)
{ {
targets.erase(itr); targets.erase(itr);
@@ -691,7 +691,7 @@ public:
if( me->GetExactDist(plr) <= 5.0f ) if( me->GetExactDist(plr) <= 5.0f )
if( Vehicle* v = plr->GetVehicle() ) if( Vehicle* v = plr->GetVehicle() )
if( Unit* c = v->GetBase() ) 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()->MovementExpired();
me->GetMotionMaster()->MoveIdle(); me->GetMotionMaster()->MoveIdle();
@@ -1156,7 +1156,7 @@ public:
{ {
NPC_BlackKnightGUID = bk->GetGUID(); NPC_BlackKnightGUID = bk->GetGUID();
bk->SendMovementFlagUpdate(); // put him on vehicle visually bk->SendMovementFlagUpdate(); // put him on vehicle visually
if( bk->GetTypeId() == TYPEID_UNIT ) if( bk->IsCreature() )
bk->ToCreature()->SetReactState(REACT_PASSIVE); bk->ToCreature()->SetReactState(REACT_PASSIVE);
} }
@@ -400,7 +400,7 @@ public:
void MoveInLineOfSight(Unit* who) override 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; return;
if (me->getStandState() != UNIT_STAND_STATE_STAND) if (me->getStandState() != UNIT_STAND_STATE_STAND)
@@ -846,7 +846,7 @@ public:
{ {
target->UpdatePosition(*c, false); target->UpdatePosition(*c, false);
target->CastCustomSpell(SPELL_SPIKE_FAIL, SPELLVALUE_MAX_TARGETS, 1); target->CastCustomSpell(SPELL_SPIKE_FAIL, SPELLVALUE_MAX_TARGETS, 1);
if( target->GetTypeId() == TYPEID_UNIT ) if( target->IsCreature() )
target->ToCreature()->AI()->DoAction(-1); target->ToCreature()->AI()->DoAction(-1);
Remove(); Remove();
return; return;
@@ -172,7 +172,7 @@ public:
break; break;
case EVENT_SPELL_FIRE_BOMB: case EVENT_SPELL_FIRE_BOMB:
{ {
if( t->GetTypeId() != TYPEID_PLAYER && pInstance ) if( !t->IsPlayer() && pInstance )
{ {
GuidVector validPlayers; GuidVector validPlayers;
Map::PlayerList const& pl = me->GetMap()->GetPlayers(); Map::PlayerList const& pl = me->GetMap()->GetPlayers();
@@ -342,7 +342,7 @@ public:
if( Vehicle* vk = me->GetVehicleKit() ) if( Vehicle* vk = me->GetVehicleKit() )
if( Unit* snobold = vk->GetPassenger(4) ) 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; CAST_AI(npc_snobold_vassal::npc_snobold_vassalAI, snobold->ToCreature()->AI())->TargetGUID = PlayerGUID;
snobold->ToCreature()->AI()->AttackStart(p); snobold->ToCreature()->AI()->AttackStart(p);
@@ -357,7 +357,7 @@ public:
{ {
events.RescheduleEvent(EVENT_PICK_SNOBOLD_TARGET, 5s); events.RescheduleEvent(EVENT_PICK_SNOBOLD_TARGET, 5s);
if( Unit* snobold = vk->GetPassenger(4) ) if( Unit* snobold = vk->GetPassenger(4) )
if( snobold->GetTypeId() == TYPEID_UNIT ) if( snobold->IsCreature() )
{ {
bool needDespawn = true; bool needDespawn = true;
for( uint8 i = 0; i < 4; ++i ) for( uint8 i = 0; i < 4; ++i )
@@ -84,7 +84,7 @@ class spell_dtk_raise_dead_aura : public AuraScript
bool Load() override bool Load() override
{ {
return GetUnitOwner()->GetTypeId() == TYPEID_UNIT; return GetUnitOwner()->IsCreature();
} }
void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) void HandleEffectRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
@@ -258,7 +258,7 @@ public:
void KilledUnit(Unit* victim) override void KilledUnit(Unit* victim) override
{ {
if (victim->GetTypeId() != TYPEID_PLAYER) if (!victim->IsPlayer())
return; return;
int32 textId = 0; int32 textId = 0;
@@ -347,7 +347,7 @@ class spell_wailing_souls_periodic_aura : public AuraScript
{ {
t->SetControlled(false, UNIT_STATE_ROOT); t->SetControlled(false, UNIT_STATE_ROOT);
t->DisableRotate(false); t->DisableRotate(false);
if (t->GetTypeId() == TYPEID_UNIT) if (t->IsCreature())
t->ToCreature()->SetReactState(REACT_AGGRESSIVE); t->ToCreature()->SetReactState(REACT_AGGRESSIVE);
if (t->GetVictim()) if (t->GetVictim())
{ {
@@ -333,7 +333,7 @@ class spell_garfrost_permafrost : public SpellScript
if (valid) if (valid)
{ {
if (Aura* aur = target->ToUnit()->GetAura(70336)) 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()); caster->ToCreature()->AI()->SetData(1, aur->GetStackAmount());
targetList.push_back(*itrU); targetList.push_back(*itrU);
} }
@@ -470,7 +470,7 @@ class spell_krick_explosive_barrage_aura : public AuraScript
{ {
PreventDefaultAction(); PreventDefaultAction();
if (Unit* caster = GetCaster()) if (Unit* caster = GetCaster())
if (caster->GetTypeId() == TYPEID_UNIT) if (caster->IsCreature())
{ {
Map::PlayerList const& players = caster->GetMap()->GetPlayers(); Map::PlayerList const& players = caster->GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) 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_HASTY_GROW);
target->RemoveAurasDueToSpell(SPELL_AUTO_GROW); target->RemoveAurasDueToSpell(SPELL_AUTO_GROW);
target->RemoveAurasDueToSpell(SPELL_EXPLODING_ORB_VISUAL); target->RemoveAurasDueToSpell(SPELL_EXPLODING_ORB_VISUAL);
if (target->GetTypeId() == TYPEID_UNIT) if (target->IsCreature())
target->ToCreature()->DespawnOrUnsummon(2000); target->ToCreature()->DespawnOrUnsummon(2000);
} }
} }
@@ -1405,7 +1405,7 @@ class spell_pos_rimefang_frost_nova : public SpellScript
if (Unit* caster = GetCaster()) if (Unit* caster = GetCaster())
{ {
Unit::Kill(caster, target); Unit::Kill(caster, target);
if (target->GetTypeId() == TYPEID_UNIT) if (target->IsCreature())
target->ToCreature()->DespawnOrUnsummon(30000); target->ToCreature()->DespawnOrUnsummon(30000);
} }
} }
@@ -343,7 +343,7 @@ public:
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000)) if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000))
@@ -613,7 +613,7 @@ public:
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000)) if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000))
@@ -907,7 +907,7 @@ public:
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
return; return;
if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000)) if (damage > RAID_MODE<uint32>(23000, 25000, 23000, 25000))
@@ -1102,7 +1102,7 @@ public:
if (_introDone) if (_introDone)
return; return;
if (who->GetTypeId() != TYPEID_PLAYER || me->GetExactDist2d(who) > 100.0f) if (!who->IsPlayer() || me->GetExactDist2d(who) > 100.0f)
{ {
return; return;
} }
@@ -1335,7 +1335,7 @@ public:
void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override void DamageDealt(Unit* target, uint32& damage, DamageEffectType /*damageType*/) override
{ {
if (target->GetTypeId() != TYPEID_PLAYER) if (!target->IsPlayer())
{ {
return; return;
} }
@@ -1506,7 +1506,7 @@ class spell_taldaram_summon_flame_ball : public SpellScript
bool Load() override bool Load() override
{ {
if (GetCaster()->GetTypeId() != TYPEID_UNIT) if (!GetCaster()->IsCreature())
{ {
return false; return false;
} }
@@ -1573,7 +1573,7 @@ class spell_valanar_kinetic_bomb_aura : public AuraScript
void HandleDummyTick(AuraEffect const* /*aurEff*/) void HandleDummyTick(AuraEffect const* /*aurEff*/)
{ {
Unit* target = GetTarget(); Unit* target = GetTarget();
if (target->GetTypeId() != TYPEID_UNIT) if (!target->IsCreature())
return; return;
if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true)) if (Creature* bomb = target->FindNearestCreature(NPC_KINETIC_BOMB, 1.0f, true))
@@ -823,7 +823,7 @@ class spell_blood_queen_vampiric_bite : public SpellScript
return; return;
} }
if (GetCaster()->GetTypeId() != TYPEID_PLAYER || GetCaster()->GetMapId() != 631) if (!GetCaster()->IsPlayer() || GetCaster()->GetMapId() != 631)
return; return;
InstanceScript* instance = GetCaster()->GetInstanceScript(); InstanceScript* instance = GetCaster()->GetInstanceScript();
if (!instance || instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) != IN_PROGRESS) if (!instance || instance->GetBossState(DATA_BLOOD_QUEEN_LANA_THEL) != IN_PROGRESS)
@@ -1259,7 +1259,7 @@ class spell_deathbringer_boiling_blood : public SpellScript
bool Load() override bool Load() override
{ {
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void FilterTargets(std::list<WorldObject*>& targets) void FilterTargets(std::list<WorldObject*>& targets)
@@ -290,13 +290,13 @@ class spell_festergut_pungent_blight : public SpellScript
bool Load() override bool Load() override
{ {
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void HandleScript(SpellEffIndex /*effIndex*/) void HandleScript(SpellEffIndex /*effIndex*/)
{ {
Unit* caster = GetCaster(); Unit* caster = GetCaster();
if (caster->GetTypeId() != TYPEID_UNIT) if (!caster->IsCreature())
return; return;
// Get Inhaled Blight id for our difficulty // Get Inhaled Blight id for our difficulty
@@ -383,7 +383,7 @@ public:
bool OnCheck(Player* /*source*/, Unit* target, uint32 /*criteria_id*/) override 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 target->ToCreature()->AI()->GetData(DATA_INOCULATED_STACK) < 3;
return false; return false;
@@ -602,7 +602,7 @@ public:
Transport::PassengerSet const& passengers = t->GetStaticPassengers(); Transport::PassengerSet const& passengers = t->GetStaticPassengers();
for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr) 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; continue;
(*itr)->ToCreature()->CastSpell((*itr)->ToCreature(), explosionSpell, true); (*itr)->ToCreature()->CastSpell((*itr)->ToCreature(), explosionSpell, true);
} }
@@ -615,7 +615,7 @@ public:
Transport::PassengerSet const& passengers = t->GetStaticPassengers(); Transport::PassengerSet const& passengers = t->GetStaticPassengers();
for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr) 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; continue;
Creature* cannon = (*itr)->ToCreature(); Creature* cannon = (*itr)->ToCreature();
cannon->CastSpell(cannon, SPELL_EJECT_ALL_PASSENGERS, true); cannon->CastSpell(cannon, SPELL_EJECT_ALL_PASSENGERS, true);
@@ -661,7 +661,7 @@ public:
Transport::PassengerSet const& passengers = t->GetPassengers(); Transport::PassengerSet const& passengers = t->GetPassengers();
for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr) for (Transport::PassengerSet::const_iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
{ {
if ((*itr)->GetTypeId() != TYPEID_UNIT) if (!(*itr)->IsCreature())
continue; continue;
Creature* c = (*itr)->ToCreature(); 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) 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 bool Load() override
{ {
_playerCount = 0; _playerCount = 0;
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void CountTargets(std::list<WorldObject*>& targets) void CountTargets(std::list<WorldObject*>& targets)
@@ -2302,7 +2302,7 @@ class spell_igb_cannon_blast : public SpellScript
bool Load() override bool Load() override
{ {
return GetCaster()->GetTypeId() == TYPEID_UNIT; return GetCaster()->IsCreature();
} }
void CalculatePower() void CalculatePower()
@@ -2467,7 +2467,7 @@ public:
bool operator()(WorldObject* unit) 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; || unit->GetMapHeight(unit->GetPhaseMask(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()) < 465.0f;
} }

Some files were not shown because too many files have changed in this diff Show More