diff options
author | Benjamin Jackson <38561765+heyitsbench@users.noreply.github.com> | 2024-09-03 13:41:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 14:41:31 -0300 |
commit | 1edac37ac37dfbfdc5f4d1ba36140dc077f06236 (patch) | |
tree | 3fcc7413a65a54e9e9508388a1b2991484c14d4f /src/server/game/AI/CreatureAI.cpp | |
parent | e3e4133e883f13a880a7281b66488ee529cf392e (diff) |
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>
Diffstat (limited to 'src/server/game/AI/CreatureAI.cpp')
-rw-r--r-- | src/server/game/AI/CreatureAI.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 1f97131cb1..52c1da79d7 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -107,7 +107,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange Map* map = creature->GetMap(); if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated { - LOG_ERROR("entities.unit.ai", "DoZoneInCombat call for map {} that isn't a dungeon (creature entry = {})", map->GetId(), creature->GetTypeId() == TYPEID_UNIT ? creature->ToCreature()->GetEntry() : 0); + LOG_ERROR("entities.unit.ai", "DoZoneInCombat call for map {} that isn't a dungeon (creature entry = {})", map->GetId(), creature->IsCreature() ? creature->ToCreature()->GetEntry() : 0); return; } @@ -175,10 +175,10 @@ void CreatureAI::MoveInLineOfSight(Unit* who) void CreatureAI::TriggerAlert(Unit const* who) const { // If there's no target, or target isn't a player do nothing - if (!who || who->GetTypeId() != TYPEID_PLAYER) + if (!who || !who->IsPlayer()) return; // If this unit isn't an NPC, is already distracted, is in combat, is confused, stunned or fleeing, do nothing - if (me->GetTypeId() != TYPEID_UNIT || me->IsEngaged() || me->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING | UNIT_STATE_DISTRACTED)) + if (!me->IsCreature() || me->IsEngaged() || me->HasUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING | UNIT_STATE_DISTRACTED)) return; // Only alert for hostiles! if (me->IsCivilian() || me->HasReactState(REACT_PASSIVE) || !me->IsHostileTo(who) || !me->_IsTargetAcceptable(who)) |