aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-03-29 11:30:49 +0200
committerShauren <shauren.trinity@gmail.com>2022-03-29 11:30:49 +0200
commitd611925dc7ab2b3f19c5ee9e0f75b8dfb6de1291 (patch)
tree4428ac0728c043ca1cb4fc55427f87268ab4860c /src/server/game
parentc02b829788cb274a68b125aee4dab35b9a56a2b8 (diff)
Core/Units: Reduce differences between branches part 1 - unit updatefield accessors
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AI/CoreAI/PassiveAI.cpp4
-rw-r--r--src/server/game/AI/CoreAI/PetAI.cpp4
-rw-r--r--src/server/game/AI/CreatureAI.cpp4
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp8
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp2
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp6
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp64
-rw-r--r--src/server/game/Battlefield/Battlefield.cpp6
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp6
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp10
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp4
-rw-r--r--src/server/game/Combat/CombatManager.cpp12
-rw-r--r--src/server/game/Combat/ThreatManager.cpp6
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp111
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp6
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h3
-rw-r--r--src/server/game/Entities/Object/MovementInfo.h2
-rw-r--r--src/server/game/Entities/Object/Object.cpp54
-rw-r--r--src/server/game/Entities/Object/Object.h6
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp50
-rw-r--r--src/server/game/Entities/Pet/Pet.h2
-rw-r--r--src/server/game/Entities/Player/Player.cpp129
-rw-r--r--src/server/game/Entities/Player/Player.h6
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp2
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp58
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp214
-rw-r--r--src/server/game/Entities/Unit/Unit.h233
-rw-r--r--src/server/game/Entities/Unit/UnitDefines.h33
-rwxr-xr-xsrc/server/game/Entities/Vehicle/Vehicle.cpp16
-rw-r--r--src/server/game/Events/GameEventMgr.cpp2
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp4
-rw-r--r--src/server/game/Handlers/LootHandler.cpp4
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp8
-rw-r--r--src/server/game/Handlers/PetHandler.cpp8
-rw-r--r--src/server/game/Handlers/TaxiHandler.cpp2
-rw-r--r--src/server/game/Maps/MapScripts.cpp2
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp6
-rw-r--r--src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp8
-rw-r--r--src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp4
-rw-r--r--src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp120
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp6
-rw-r--r--src/server/game/Spells/Spell.cpp32
-rw-r--r--src/server/game/Spells/SpellEffects.cpp18
-rw-r--r--src/server/game/Spells/SpellInfo.cpp6
46 files changed, 729 insertions, 566 deletions
diff --git a/src/server/game/AI/CoreAI/PassiveAI.cpp b/src/server/game/AI/CoreAI/PassiveAI.cpp
index c11bdc4ed21..d2b5a61dcd7 100644
--- a/src/server/game/AI/CoreAI/PassiveAI.cpp
+++ b/src/server/game/AI/CoreAI/PassiveAI.cpp
@@ -36,7 +36,7 @@ NullCreatureAI::NullCreatureAI(Creature* creature) : CreatureAI(creature)
int32 NullCreatureAI::Permissible(Creature const* creature)
{
- if (creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
+ if (creature->HasNpcFlag(UNIT_NPC_FLAG_SPELLCLICK))
return PERMIT_BASE_PROACTIVE + 50;
if (creature->IsTrigger())
@@ -70,7 +70,7 @@ void PossessedAI::UpdateAI(uint32 /*diff*/)
void PossessedAI::JustDied(Unit* /*u*/)
{
// We died while possessed, disable our loot
- me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ me->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
}
void CritterAI::JustEngagedWith(Unit* /*who*/)
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp
index ee73d4b2b7d..af4a9ed93a4 100644
--- a/src/server/game/AI/CoreAI/PetAI.cpp
+++ b/src/server/game/AI/CoreAI/PetAI.cpp
@@ -402,7 +402,7 @@ void PetAI::HandleReturnMovement()
me->GetMotionMaster()->MoveFollow(me->GetCharmerOrOwner(), PET_FOLLOW_DIST, me->GetFollowAngle());
}
}
- me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); // on player pets, this flag indicates that we're actively going after a target - we're returning, so remove it
+ me->RemoveUnitFlag(UNIT_FLAG_PET_IN_COMBAT); // on player pets, this flag indicates that we're actively going after a target - we're returning, so remove it
}
void PetAI::DoAttack(Unit* target, bool chase)
@@ -412,7 +412,7 @@ void PetAI::DoAttack(Unit* target, bool chase)
if (me->Attack(target, true))
{
- me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); // on player pets, this flag indicates we're actively going after a target - that's what we're doing, so set it
+ me->SetUnitFlag(UNIT_FLAG_PET_IN_COMBAT); // on player pets, this flag indicates we're actively going after a target - that's what we're doing, so set it
// Play sound to let the player know the pet is attacking something it picked on its own
if (me->HasReactState(REACT_AGGRESSIVE) && !me->GetCharmInfo()->IsCommandAttack())
me->SendPetAIReaction(me->GetGUID());
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index 73a67a0a981..c1e57fe9527 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -384,10 +384,10 @@ int32 CreatureAI::VisualizeBoundary(Seconds duration, Unit* owner, bool fill) co
if (TempSummon* point = owner->SummonCreature(BOUNDARY_VISUALIZE_CREATURE, Position(startPosition.GetPositionX() + front.first * BOUNDARY_VISUALIZE_STEP_SIZE, startPosition.GetPositionY() + front.second * BOUNDARY_VISUALIZE_STEP_SIZE, spawnZ), TEMPSUMMON_TIMED_DESPAWN, duration))
{
point->SetObjectScale(BOUNDARY_VISUALIZE_CREATURE_SCALE);
- point->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ point->SetUnitFlag(UNIT_FLAG_STUNNED);
point->SetImmuneToAll(true);
if (!hasOutOfBoundsNeighbor)
- point->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ point->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
}
}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 0f1260bf1fc..4625876abb9 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -305,7 +305,7 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
return nullptr;
// Silenced so we can't cast
- if (me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
+ if (me->HasUnitFlag(UNIT_FLAG_SILENCED))
return nullptr;
// Using the extended script system we first create a list of viable spells
@@ -471,13 +471,13 @@ void ScriptedAI::SetEquipmentSlots(bool loadDefault, int32 mainHand /*= EQUIP_NO
}
if (mainHand >= 0)
- me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(mainHand));
+ me->SetVirtualItem(0, uint32(mainHand));
if (offHand >= 0)
- me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, uint32(offHand));
+ me->SetVirtualItem(1, uint32(offHand));
if (ranged >= 0)
- me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, uint32(ranged));
+ me->SetVirtualItem(2, uint32(ranged));
}
void ScriptedAI::SetCombatMovement(bool allowMovement)
diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
index 4ad42066d77..ca5d4c5484e 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp
@@ -321,7 +321,7 @@ void EscortAI::Start(bool isActiveAttacker /* = true*/, bool run /* = false */,
me->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
// disable npcflags
- me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+ me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
if (me->IsImmuneToNPC())
{
_hasImmuneToNPCFlags = true;
diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
index d945512a9bf..876e1f4b916 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
@@ -185,7 +185,7 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, uint32 q
me->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
me->PauseMovement();
- me->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+ me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
AddFollowState(STATE_FOLLOW_INPROGRESS);
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 751337ca3d1..c7dbdfe6653 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -68,8 +68,8 @@ void SmartAI::StartPath(bool run/* = false*/, uint32 pathId/* = 0*/, bool repeat
if (invoker && invoker->GetTypeId() == TYPEID_PLAYER)
{
- _escortNPCFlags = me->GetUInt32Value(UNIT_NPC_FLAGS);
- me->SetFlag(UNIT_NPC_FLAGS, 0);
+ _escortNPCFlags = me->GetNpcFlags();
+ me->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
}
me->GetMotionMaster()->MovePath(_path, _repeatWaypointPath);
@@ -193,7 +193,7 @@ void SmartAI::EndPath(bool fail)
if (_escortNPCFlags)
{
- me->SetFlag(UNIT_NPC_FLAGS, _escortNPCFlags);
+ me->ReplaceAllNpcFlags((NPCFlags)_escortNPCFlags);
_escortNPCFlags = 0;
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index b9aa990a071..285e736317d 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -727,7 +727,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (IsUnit(target))
{
- target->ToUnit()->SetUInt32Value(UNIT_NPC_EMOTESTATE, e.action.emote.emote);
+ target->ToUnit()->SetEmoteState(Emote(e.action.emote.emote));
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SET_EMOTE_STATE. Unit %s set emotestate to %u",
target->GetGUID().ToString().c_str(), e.action.emote.emote);
}
@@ -1526,7 +1526,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (uint32 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
if (!e.action.equip.mask || (e.action.equip.mask & (1 << i)))
- npc->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, slot[i]);
+ npc->SetVirtualItem(i, slot[i]);
}
}
break;
@@ -1625,21 +1625,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
for (WorldObject* target : targets)
if (IsCreature(target))
- target->ToUnit()->SetUInt32Value(UNIT_NPC_FLAGS, e.action.flag.flag);
+ target->ToUnit()->ReplaceAllNpcFlags(NPCFlags(e.action.flag.flag));
break;
}
case SMART_ACTION_ADD_NPC_FLAG:
{
for (WorldObject* target : targets)
if (IsCreature(target))
- target->ToUnit()->SetFlag(UNIT_NPC_FLAGS, e.action.flag.flag);
+ target->ToUnit()->SetNpcFlag(NPCFlags(e.action.flag.flag));
break;
}
case SMART_ACTION_REMOVE_NPC_FLAG:
{
for (WorldObject* target : targets)
if (IsCreature(target))
- target->ToUnit()->RemoveFlag(UNIT_NPC_FLAGS, e.action.flag.flag);
+ target->ToUnit()->RemoveNpcFlag(NPCFlags(e.action.flag.flag));
break;
}
case SMART_ACTION_CROSS_CAST:
@@ -1768,15 +1768,51 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
case SMART_ACTION_SET_UNIT_FIELD_BYTES_1:
{
for (WorldObject* target : targets)
+ {
if (IsUnit(target))
- target->ToUnit()->SetByteFlag(UNIT_FIELD_BYTES_1, e.action.setunitByte.type, e.action.setunitByte.byte1);
+ {
+ switch (e.action.setunitByte.type)
+ {
+ case 0:
+ target->ToUnit()->SetStandState(UnitStandStateType(e.action.setunitByte.byte1));
+ break;
+ case 1:
+ // pet talent points
+ break;
+ case 2:
+ target->ToUnit()->SetVisFlag(UnitVisFlags(e.action.setunitByte.byte1));
+ break;
+ case 3:
+ target->ToUnit()->SetAnimTier(AnimTier(e.action.setunitByte.byte1));
+ break;
+ }
+ }
+ }
break;
}
case SMART_ACTION_REMOVE_UNIT_FIELD_BYTES_1:
{
for (WorldObject* target : targets)
+ {
if (IsUnit(target))
- target->ToUnit()->RemoveByteFlag(UNIT_FIELD_BYTES_1, e.action.delunitByte.type, e.action.delunitByte.byte1);
+ {
+ switch (e.action.setunitByte.type)
+ {
+ case 0:
+ target->ToUnit()->SetStandState(UNIT_STAND_STATE_STAND);
+ break;
+ case 1:
+ // pet talent points
+ break;
+ case 2:
+ target->ToUnit()->RemoveVisFlag(UnitVisFlags(e.action.setunitByte.byte1));
+ break;
+ case 3:
+ target->ToUnit()->SetAnimTier(AnimTier::Ground);
+ break;
+ }
+ }
+ }
break;
}
case SMART_ACTION_INTERRUPT_SPELL:
@@ -2234,9 +2270,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsUnit(target))
{
if (e.action.setImmunePC.immunePC)
- target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ target->ToUnit()->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
else
- target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ target->ToUnit()->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
}
}
break;
@@ -2248,9 +2284,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsUnit(target))
{
if (e.action.setImmuneNPC.immuneNPC)
- target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
+ target->ToUnit()->SetUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
else
- target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
+ target->ToUnit()->RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
}
}
break;
@@ -2262,9 +2298,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (IsUnit(target))
{
if (e.action.setUninteractible.uninteractible)
- target->ToUnit()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ target->ToUnit()->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
else
- target->ToUnit()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ target->ToUnit()->RemoveUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
}
}
break;
@@ -2767,7 +2803,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
{
if (!me || !me->IsEngaged() || !me->GetMaxPower(POWER_MANA))
return;
- uint32 perc = uint32(100.0f * me->GetPower(POWER_MANA) / me->GetMaxPower(POWER_MANA));
+ uint32 perc = uint32(me->GetPowerPct(POWER_MANA));
if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
return;
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp
index cbe8a6aa313..99fedbaa4f7 100644
--- a/src/server/game/Battlefield/Battlefield.cpp
+++ b/src/server/game/Battlefield/Battlefield.cpp
@@ -478,7 +478,7 @@ void Battlefield::HideNpc(Creature* creature)
{
creature->CombatStop();
creature->SetReactState(REACT_PASSIVE);
- creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
+ creature->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
creature->SetPhaseMask(2, true);
creature->DisappearAndDie();
creature->SetVisible(false);
@@ -488,14 +488,14 @@ void Battlefield::ShowNpc(Creature* creature, bool aggressive)
{
creature->SetPhaseMask(1, true);
creature->SetVisible(true);
- creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
+ creature->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
if (!creature->IsAlive())
creature->Respawn(true);
if (aggressive)
creature->SetReactState(REACT_AGGRESSIVE);
else
{
- creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ creature->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
creature->SetReactState(REACT_PASSIVE);
}
}
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 9594fc82ab3..234148b02fb 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -1568,9 +1568,9 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float
/// @todo Fix display here
// creature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
// casting visual effect
- creature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SPIRIT_HEAL_CHANNEL);
+ creature->SetChannelSpellId(SPELL_SPIRIT_HEAL_CHANNEL);
// correct cast speed
- creature->SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
+ creature->SetModCastingSpeed(1.0f);
//creature->CastSpell(creature, SPELL_SPIRIT_HEAL_CHANNEL, true);
return true;
}
@@ -1692,7 +1692,7 @@ void Battleground::HandleKillPlayer(Player* victim, Player* killer)
if (!isArena())
{
// To be able to remove insignia -- ONLY IN Battlegrounds
- victim->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
+ victim->SetUnitFlag(UNIT_FLAG_SKINNABLE);
RewardXPAtKill(killer, victim);
}
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
index 0e07f0e1b39..daca43f5b57 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
@@ -143,9 +143,9 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
{
if (siege->IsAlive())
{
- if (siege->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE|UNIT_FLAG_CANNOT_SWIM|UNIT_FLAG_IMMUNE_TO_PC))
+ if (siege->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE | UNIT_FLAG_CANNOT_SWIM | UNIT_FLAG_IMMUNE_TO_PC))
// following sniffs the vehicle always has UNIT_FLAG_CANNOT_SWIM
- siege->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE|UNIT_FLAG_IMMUNE_TO_PC);
+ siege->RemoveUnitFlag(UNIT_FLAG_UNINTERACTIBLE | UNIT_FLAG_IMMUNE_TO_PC);
else
siege->SetHealth(siege->GetMaxHealth());
}
@@ -582,7 +582,7 @@ void BattlegroundIC::HandleContestedNodes(ICNodePoint* node)
for (Creature* cannon : cannons)
{
cannon->GetVehicleKit()->RemoveAllPassengers();
- cannon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ cannon->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
}
}
else if (node->nodeType == NODE_TYPE_WORKSHOP)
@@ -614,7 +614,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* node, bool recapture)
gunshipHorde->GetCreatureListWithEntryInGrid(cannons, NPC_HORDE_GUNSHIP_CANNON, 150.0f);
for (Creature* cannon : cannons)
- cannon->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ cannon->RemoveUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
for (uint8 u = 0; u < MAX_HANGAR_TELEPORTERS_SPAWNS; ++u)
{
@@ -769,7 +769,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* node, bool recapture)
if (Creature* siegeEngine = GetBGCreature(siegeType))
{
- siegeEngine->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE|UNIT_FLAG_CANNOT_SWIM);
+ siegeEngine->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE | UNIT_FLAG_CANNOT_SWIM);
siegeEngine->SetImmuneToPC(true);
siegeEngine->SetFaction(BG_IC_Factions[(node->faction == TEAM_ALLIANCE ? 0 : 1)]);
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
index 4484824002b..b3a1c1d0b4d 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
@@ -682,9 +682,9 @@ void BattlegroundSA::DemolisherStartState(bool start)
if (Creature* dem = GetBGCreature(i))
{
if (start)
- dem->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
+ dem->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
else
- dem->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
+ dem->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE);
}
}
}
diff --git a/src/server/game/Combat/CombatManager.cpp b/src/server/game/Combat/CombatManager.cpp
index f35feb7cf92..b5b8b24e068 100644
--- a/src/server/game/Combat/CombatManager.cpp
+++ b/src/server/game/Combat/CombatManager.cpp
@@ -229,8 +229,8 @@ void CombatManager::InheritCombatStatesFrom(Unit const* who)
if (!IsInCombatWith(ref.first))
{
Unit* target = ref.second->GetOther(who);
- if ((_owner->IsImmuneToPC() && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) ||
- (_owner->IsImmuneToNPC() && !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)))
+ if ((_owner->IsImmuneToPC() && target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) ||
+ (_owner->IsImmuneToNPC() && !target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)))
continue;
SetInCombatWith(target);
}
@@ -238,8 +238,8 @@ void CombatManager::InheritCombatStatesFrom(Unit const* who)
for (auto& ref : mgr._pvpRefs)
{
Unit* target = ref.second->GetOther(who);
- if ((_owner->IsImmuneToPC() && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) ||
- (_owner->IsImmuneToNPC() && !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)))
+ if ((_owner->IsImmuneToPC() && target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) ||
+ (_owner->IsImmuneToNPC() && !target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)))
continue;
SetInCombatWith(target);
}
@@ -368,14 +368,14 @@ bool CombatManager::UpdateOwnerCombatState() const
if (combatState)
{
- _owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+ _owner->SetUnitFlag(UNIT_FLAG_IN_COMBAT);
_owner->AtEnterCombat();
if (_owner->GetTypeId() != TYPEID_UNIT)
_owner->AtEngage(GetAnyTarget());
}
else
{
- _owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
+ _owner->RemoveUnitFlag(UNIT_FLAG_IN_COMBAT);
_owner->AtExitCombat();
if (_owner->GetTypeId() != TYPEID_UNIT)
_owner->AtDisengage();
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp
index a40810582f1..d1eaa230139 100644
--- a/src/server/game/Combat/ThreatManager.cpp
+++ b/src/server/game/Combat/ThreatManager.cpp
@@ -85,14 +85,14 @@ void ThreatReference::UpdateOffline()
{
if (a->GetTypeId() == TYPEID_UNIT && a->ToCreature()->IsTrigger())
return false;
- if (a->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (a->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
{
- if (b->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
+ if (b->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC))
return false;
}
else
{
- if (b->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
+ if (b->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC))
return false;
}
return true;
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 3660518b1e8..0fa99cfe2cc 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -508,7 +508,7 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
SetName(normalInfo->Name); // at normal entry always
- SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
+ SetModCastingSpeed(1.0f);
SetSpeedRate(MOVE_WALK, cinfo->speed_walk);
SetSpeedRate(MOVE_RUN, cinfo->speed_run);
@@ -518,7 +518,7 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
// Will set UNIT_FIELD_BOUNDINGRADIUS and UNIT_FIELD_COMBATREACH
SetObjectScale(GetNativeObjectScale());
- SetFloatValue(UNIT_FIELD_HOVERHEIGHT, cinfo->HoverHeight);
+ SetHoverHeight(cinfo->HoverHeight);
SetCanDualWield(cinfo->flags_extra & CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK);
@@ -548,23 +548,23 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
SetFaction(cInfo->faction);
- uint32 npcflag, unit_flags, dynamicflags;
- ObjectMgr::ChooseCreatureFlags(cInfo, &npcflag, &unit_flags, &dynamicflags, data);
+ uint32 npcFlags, unitFlags, dynamicFlags;
+ ObjectMgr::ChooseCreatureFlags(cInfo, &npcFlags, &unitFlags, &dynamicFlags, data);
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_WORLDEVENT)
- SetUInt32Value(UNIT_NPC_FLAGS, npcflag | sGameEventMgr->GetNPCFlag(this));
- else
- SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
+ npcFlags |= sGameEventMgr->GetNPCFlag(this);
+
+ ReplaceAllNpcFlags(NPCFlags(npcFlags));
// if unit is in combat, keep this flag
- unit_flags &= ~UNIT_FLAG_IN_COMBAT;
+ unitFlags &= ~UNIT_FLAG_IN_COMBAT;
if (IsInCombat())
- unit_flags |= UNIT_FLAG_IN_COMBAT;
+ unitFlags |= UNIT_FLAG_IN_COMBAT;
- SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
- SetUInt32Value(UNIT_FIELD_FLAGS_2, cInfo->unit_flags2);
+ ReplaceAllUnitFlags(UnitFlags(unitFlags));
+ ReplaceAllUnitFlags2(UnitFlags2(cInfo->unit_flags2));
- SetUInt32Value(UNIT_DYNAMIC_FLAGS, dynamicflags);
+ ReplaceAllDynamicFlags(dynamicFlags);
SetCanDualWield(cInfo->flags_extra & CREATURE_FLAG_EXTRA_USE_OFFHAND_ATTACK);
@@ -611,7 +611,7 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
// trigger creature is always uninteractible and can not be attacked
if (IsTrigger())
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
InitializeReactState();
@@ -870,7 +870,7 @@ void Creature::Regenerate(Powers power)
uint32 curValue = GetPower(power);
uint32 maxValue = GetMaxPower(power);
- if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER))
+ if (!HasUnitFlag2(UNIT_FLAG2_REGENERATE_POWER))
return;
if (curValue >= maxValue)
@@ -1259,7 +1259,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
{
m_lootRecipient.Clear();
m_lootRecipientGroup = 0;
- RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED);
+ RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE|UNIT_DYNFLAG_TAPPED);
return;
}
@@ -1279,7 +1279,7 @@ void Creature::SetLootRecipient(Unit* unit, bool withGroup)
else
m_lootRecipientGroup = ObjectGuid::Empty;
- SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED);
+ SetDynamicFlag(UNIT_DYNFLAG_TAPPED);
}
// return true if this creature is tapped by the player or by a member of his group.
@@ -1319,9 +1319,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
CreatureData& data = sObjectMgr->NewOrExistCreatureData(m_spawnId);
uint32 displayId = GetNativeDisplayId();
- uint32 npcflag = GetUInt32Value(UNIT_NPC_FLAGS);
- uint32 unit_flags = GetUInt32Value(UNIT_FIELD_FLAGS);
- uint32 dynamicflags = GetUInt32Value(UNIT_DYNAMIC_FLAGS);
+ uint32 npcflag = GetNpcFlags();
+ uint32 unit_flags = GetUnitFlags();
+ uint32 dynamicflags = GetDynamicFlags();
// check if it's a custom model and if not, use 0 for displayId
CreatureTemplate const* cinfo = GetCreatureTemplate();
@@ -1702,7 +1702,7 @@ void Creature::LoadEquipment(int8 id, bool force /*= true*/)
if (force)
{
for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
- SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, 0);
+ SetVirtualItem(i, 0);
m_equipmentId = 0;
}
@@ -1715,7 +1715,7 @@ void Creature::LoadEquipment(int8 id, bool force /*= true*/)
m_equipmentId = id;
for (uint8 i = 0; i < MAX_EQUIPMENT_ITEMS; ++i)
- SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, einfo->ItemEntry[i]);
+ SetVirtualItem(i, einfo->ItemEntry[i]);
}
void Creature::SetSpawnHealth()
@@ -1860,8 +1860,8 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const
return false;
// This set of checks is should be done only for creatures
- if ((IsImmuneToNPC() && !who->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
- || (IsImmuneToPC() && who->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)))
+ if ((IsImmuneToNPC() && !who->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
+ || (IsImmuneToPC() && who->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)))
return false;
// Do not attack non-combat pets
@@ -1923,7 +1923,7 @@ float Creature::GetAttackDistance(Unit const* player) const
// The aggro radius for creatures with equal level as the player is 20 yards.
// The combatreach should not get taken into account for the distance so we drop it from the range (see Supremus as expample)
- float baseAggroDistance = 20.0f - GetFloatValue(UNIT_FIELD_COMBATREACH);
+ float baseAggroDistance = 20.0f - GetCombatReach();
// + - 1 yard for each level difference between player and creature
float aggroRadius = baseAggroDistance + float(levelDifference);
@@ -1984,9 +1984,9 @@ void Creature::setDeathState(DeathState s)
DoNotReacquireSpellFocusTarget(); // cancel delayed re-target
SetTarget(ObjectGuid::Empty); // drop target - dead mobs shouldn't ever target things
- SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+ ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
- SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); // if creature is mounted on a virtual mount, remove it at death
+ SetMountDisplayId(0); // if creature is mounted on a virtual mount, remove it at death
setActive(false);
@@ -2028,9 +2028,9 @@ void Creature::setDeathState(DeathState s)
uint32 npcflag, unit_flags, dynamicflags;
ObjectMgr::ChooseCreatureFlags(cinfo, &npcflag, &unit_flags, &dynamicflags, creatureData);
- SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
- SetUInt32Value(UNIT_FIELD_FLAGS, unit_flags);
- SetUInt32Value(UNIT_DYNAMIC_FLAGS, dynamicflags);
+ ReplaceAllNpcFlags(NPCFlags(npcflag));
+ ReplaceAllUnitFlags(UnitFlags(unit_flags));
+ ReplaceAllDynamicFlags(dynamicflags);
SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool));
@@ -2364,7 +2364,7 @@ bool Creature::CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction /
if (IsCivilian())
return false;
- if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE) || IsImmuneToNPC())
+ if (HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE) || IsImmuneToNPC())
return false;
// skip fighting creature
@@ -2409,7 +2409,7 @@ bool Creature::_IsTargetAcceptable(Unit const* target) const
if (target->HasUnitState(UNIT_STATE_DIED))
{
// some creatures can detect fake death
- if (CanIgnoreFeignDeath() && target->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH))
+ if (CanIgnoreFeignDeath() && target->HasUnitFlag2(UNIT_FLAG2_FEIGN_DEATH))
return true;
else
return false;
@@ -2523,12 +2523,9 @@ bool Creature::LoadCreaturesAddon()
// 2 StandFlags
// 3 StandMiscFlags
- SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, uint8(cainfo->bytes1 & 0xFF));
- //SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_PET_TALENTS, uint8((cainfo->bytes1 >> 8) & 0xFF));
- SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_PET_TALENTS, 0);
- SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, uint8((cainfo->bytes1 >> 16) & 0xFF));
-
- SetAnimTier(static_cast<AnimTier>((cainfo->bytes1 >> 24) & 0xFF));
+ SetStandState(UnitStandStateType(cainfo->bytes1 & 0xFF));
+ ReplaceAllVisFlags(UnitVisFlags((cainfo->bytes1 >> 16) & 0xFF));
+ SetAnimTier(AnimTier((cainfo->bytes1 >> 24) & 0xFF));
//! Suspected correlation between UNIT_FIELD_BYTES_1, offset 3, value 0x2:
//! If no inhabittype_fly (if no MovementFlag_DisableGravity or MovementFlag_CanFly flag found in sniffs)
@@ -2546,16 +2543,14 @@ bool Creature::LoadCreaturesAddon()
// 2 PetFlags Pet only, so always 0 for default creature
// 3 ShapeshiftForm Must be determined/set by shapeshift spell/aura
- SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHEATH_STATE, uint8(cainfo->bytes2 & 0xFF));
- //SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, uint8((cainfo->bytes2 >> 8) & 0xFF));
- //SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, uint8((cainfo->bytes2 >> 16) & 0xFF));
- SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, 0);
- //SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM, uint8((cainfo->bytes2 >> 24) & 0xFF));
- SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM, 0);
+ SetSheath(SheathState(cainfo->bytes2 & 0xFF));
+ ReplaceAllPvpFlags(UNIT_BYTE2_FLAG_NONE);
+ ReplaceAllPetFlags(UNIT_PET_FLAG_NONE);
+ SetShapeshiftForm(FORM_NONE);
}
if (cainfo->emote != 0)
- SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote);
+ SetEmoteState(Emote(cainfo->emote));
// Check if visibility distance different
if (cainfo->visibilityDistanceType != VisibilityDistanceType::Normal)
@@ -2722,19 +2717,19 @@ bool Creature::CanEnterWater() const
void Creature::RefreshCanSwimFlag(bool recheck)
{
if (!_isMissingCanSwimFlagOutOfCombat || recheck)
- _isMissingCanSwimFlagOutOfCombat = !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CAN_SWIM);
+ _isMissingCanSwimFlagOutOfCombat = !HasUnitFlag(UNIT_FLAG_CAN_SWIM);
// Check if the creature has UNIT_FLAG_CAN_SWIM and add it if it's missing
// Creatures must be able to chase a target in water if they can enter water
if (_isMissingCanSwimFlagOutOfCombat && CanEnterWater())
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CAN_SWIM);
+ SetUnitFlag(UNIT_FLAG_CAN_SWIM);
}
void Creature::AllLootRemovedFromCorpse()
{
if (loot.loot_type != LOOT_SKINNING && !IsPet() && GetCreatureTemplate()->SkinLootId && hasLootRecipient())
if (LootTemplates_Skinning.HaveLootFor(GetCreatureTemplate()->SkinLootId))
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
+ SetUnitFlag(UNIT_FLAG_SKINNABLE);
time_t now = GameTime::GetGameTime();
// Do not reset corpse remove time if corpse is already removed
@@ -3109,8 +3104,8 @@ void Creature::SetObjectScale(float scale)
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(GetDisplayId()))
{
- SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (IsPet() ? 1.0f : minfo->bounding_radius) * scale);
- SetFloatValue(UNIT_FIELD_COMBATREACH, (IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : minfo->combat_reach) * scale);
+ SetBoundingRadius((IsPet() ? 1.0f : minfo->bounding_radius) * scale);
+ SetCombatReach((IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : minfo->combat_reach) * scale);
}
}
@@ -3120,8 +3115,8 @@ void Creature::SetDisplayId(uint32 modelId)
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
{
- SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (IsPet() ? 1.0f : minfo->bounding_radius) * GetObjectScale());
- SetFloatValue(UNIT_FIELD_COMBATREACH, (IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : minfo->combat_reach) * GetObjectScale());
+ SetBoundingRadius((IsPet() ? 1.0f : minfo->bounding_radius) * GetObjectScale());
+ SetCombatReach((IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : minfo->combat_reach) * GetObjectScale());
}
}
@@ -3140,11 +3135,11 @@ void Creature::SetSpellFocus(Spell const* focusSpell, WorldObject const* target)
return;
// Prevent dead / feign death creatures from setting a focus target
- if (!IsAlive() || HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH) || HasAuraType(SPELL_AURA_FEIGN_DEATH))
+ if (!IsAlive() || HasUnitFlag2(UNIT_FLAG2_FEIGN_DEATH) || HasAuraType(SPELL_AURA_FEIGN_DEATH))
return;
// Don't allow stunned creatures to set a focus target
- if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED))
+ if (HasUnitFlag(UNIT_FLAG_STUNNED))
return;
// some spells shouldn't track targets
@@ -3173,7 +3168,7 @@ void Creature::SetSpellFocus(Spell const* focusSpell, WorldObject const* target)
_spellFocusInfo.Spell = focusSpell;
bool const noTurnDuringCast = spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST);
- bool const turnDisabled = HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CANNOT_TURN);
+ bool const turnDisabled = HasUnitFlag2(UNIT_FLAG2_CANNOT_TURN);
// set target, then force send update packet to players if it changed to provide appropriate facing
ObjectGuid newTarget = (target && !noTurnDuringCast && !turnDisabled) ? target->GetGUID() : ObjectGuid::Empty;
if (GetGuidValue(UNIT_FIELD_TARGET) != newTarget)
@@ -3219,7 +3214,7 @@ void Creature::ReleaseSpellFocus(Spell const* focusSpell, bool withDelay)
if (IsPet()) // player pets do not use delay system
{
- if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CANNOT_TURN))
+ if (!HasUnitFlag2(UNIT_FLAG2_CANNOT_TURN))
ReacquireSpellFocusTarget();
}
else // don't allow re-target right away to prevent visual bugs
@@ -3238,7 +3233,7 @@ void Creature::ReacquireSpellFocusTarget()
SetGuidValue(UNIT_FIELD_TARGET, _spellFocusInfo.Target);
- if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CANNOT_TURN))
+ if (!HasUnitFlag2(UNIT_FLAG2_CANNOT_TURN))
{
if (_spellFocusInfo.Target)
{
@@ -3371,8 +3366,8 @@ void Creature::AtDisengage()
Unit::AtDisengage();
ClearUnitState(UNIT_STATE_ATTACK_PLAYER);
- if (IsAlive() && HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
- SetUInt32Value(UNIT_DYNAMIC_FLAGS, GetCreatureTemplate()->dynamicflags);
+ if (IsAlive() && HasDynamicFlag(UNIT_DYNFLAG_TAPPED))
+ ReplaceAllDynamicFlags(GetCreatureTemplate()->dynamicflags);
if (IsPet() || IsGuardian()) // update pets' speed for catchup OOC speed
{
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index c955e5d102b..a207088ec5b 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -1567,7 +1567,7 @@ void GameObject::Use(Unit* user)
if (Player* playerUser = user->ToPlayer())
{
- if (m_goInfo->CannotBeUsedUnderImmunity() && playerUser->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE))
+ if (m_goInfo->CannotBeUsedUnderImmunity() && playerUser->HasUnitFlag(UNIT_FLAG_IMMUNE))
return;
if (!m_goInfo->IsUsableMounted())
@@ -1694,7 +1694,7 @@ void GameObject::Use(Unit* user)
{
itr->second = player->GetGUID(); //this slot in now used by player
player->TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
- player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->chair.height);
+ player->SetStandState(UnitStandStateType(UNIT_STAND_STATE_SIT_LOW_CHAIR + info->chair.height));
return;
}
}
@@ -2135,7 +2135,7 @@ void GameObject::Use(Unit* user)
WorldPacket data(SMSG_ENABLE_BARBER_SHOP, 0);
player->SendDirectMessage(&data);
- player->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR+info->barberChair.chairheight);
+ player->SetStandState(UnitStandStateType(UNIT_STAND_STATE_SIT_LOW_CHAIR + info->barberChair.chairheight));
return;
}
default:
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index ec0547c2aaa..84128744eee 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -89,6 +89,9 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
void RemoveFromWorld() override;
void CleanupsBeforeDelete(bool finalCleanup = true) override;
+ uint32 GetDynamicFlags() const override { return GetUInt32Value(GAMEOBJECT_DYNAMIC); }
+ void ReplaceAllDynamicFlags(uint32 flag) override { SetUInt32Value(GAMEOBJECT_DYNAMIC, flag); }
+
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, uint32 phaseMask, Position const& pos, QuaternionData const& rotation, uint32 animprogress, GOState go_state, uint32 artKit = 0, bool dynamic = false, ObjectGuid::LowType spawnid = 0);
void Update(uint32 p_time) override;
GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
diff --git a/src/server/game/Entities/Object/MovementInfo.h b/src/server/game/Entities/Object/MovementInfo.h
index 40cad80f3dc..e399be0ac0c 100644
--- a/src/server/game/Entities/Object/MovementInfo.h
+++ b/src/server/game/Entities/Object/MovementInfo.h
@@ -85,7 +85,9 @@ struct MovementInfo
bool HasMovementFlag(uint32 flag) const { return (flags & flag) != 0; }
uint16 GetExtraMovementFlags() const { return flags2; }
+ void SetExtraMovementFlags(uint16 flag) { flags2 = flag; }
void AddExtraMovementFlag(uint16 flag) { flags2 |= flag; }
+ void RemoveExtraMovementFlag(uint16 flag) { flags2 &= ~flag; }
bool HasExtraMovementFlag(uint16 flag) const { return (flags2 & flag) != 0; }
void SetFallTime(uint32 val) { fallTime = val; }
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 7cc0625c247..cbc5f448e11 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -550,7 +550,7 @@ uint32 Object::GetUpdateFieldData(Player const* target, uint32*& flags) const
if (ToUnit()->GetOwnerGUID() == target->GetGUID())
visibleFlag |= UF_FLAG_OWNER;
- if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO))
+ if (HasDynamicFlag(UNIT_DYNFLAG_SPECIALINFO))
if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()))
visibleFlag |= UF_FLAG_SPECIAL_INFO;
@@ -1941,7 +1941,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
return nullptr;
}
- summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
+ summon->SetCreatedBySpell(spellId);
summon->SetHomePosition(pos);
@@ -2671,9 +2671,9 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const
Unit const* unit = Coalesce<const Unit>(ToUnit(), selfPlayerOwner);
Unit const* targetUnit = Coalesce<const Unit>(target->ToUnit(), targetPlayerOwner);
- if (unit && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
{
- if (targetUnit && targetUnit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (targetUnit && targetUnit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
{
if (selfPlayerOwner && targetPlayerOwner)
{
@@ -2702,7 +2702,7 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const
{
if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry))
return *repRank;
- if (!selfPlayerOwner->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_IGNORE_REPUTATION))
+ if (!selfPlayerOwner->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
{
if (FactionEntry const* targetFactionEntry = sFactionStore.LookupEntry(targetFactionTemplateEntry->Faction))
{
@@ -2747,7 +2747,7 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const
return REP_HOSTILE;
if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry))
return *repRank;
- if (target->ToUnit() && !target->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_IGNORE_REPUTATION))
+ if (target->IsUnit() && !target->ToUnit()->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
{
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->Faction))
{
@@ -2892,7 +2892,7 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const
return false;
// can't attack untargetable
- if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE))
+ if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE))
return false;
if (Player const* playerAttacker = ToPlayer())
@@ -2902,7 +2902,7 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const
}
// check flags
- if (unitTarget && unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_ON_TAXI | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NON_ATTACKABLE_2))
+ if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_ON_TAXI | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NON_ATTACKABLE_2))
return false;
Unit const* unitOrOwner = unit;
@@ -2913,29 +2913,29 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const
// ignore immunity flags when assisting
if (unitOrOwner && unitTarget && !(isPositiveSpell && bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG)))
{
- if (!unitOrOwner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget->IsImmuneToNPC())
+ if (!unitOrOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget->IsImmuneToNPC())
return false;
- if (!unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner->IsImmuneToNPC())
+ if (!unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner->IsImmuneToNPC())
return false;
- if (unitOrOwner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget->IsImmuneToPC())
+ if (unitOrOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget->IsImmuneToPC())
return false;
- if (unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner->IsImmuneToPC())
+ if (unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner->IsImmuneToPC())
return false;
}
// CvC case - can attack each other only when one of them is hostile
- if (unit && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget && !unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (unit && !unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget && !unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
return IsHostileTo(unitTarget) || unitTarget->IsHostileTo(this);
// Traps without owner or with NPC owner versus Creature case - can attack to creature only when one of them is hostile
if (go && go->GetGoType() == GAMEOBJECT_TYPE_TRAP)
{
Unit const* goOwner = go->GetOwner();
- if (!goOwner || !goOwner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
- if (unitTarget && !unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (!goOwner || !goOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
+ if (unitTarget && !unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
return IsHostileTo(unitTarget) || unitTarget->IsHostileTo(this);
}
@@ -2944,8 +2944,8 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const
if (IsFriendlyTo(target) || target->IsFriendlyTo(this))
return false;
- Player const* playerAffectingAttacker = unit && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? GetAffectingPlayer() : go ? GetAffectingPlayer() : nullptr;
- Player const* playerAffectingTarget = unitTarget && unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? unitTarget->GetAffectingPlayer() : nullptr;
+ Player const* playerAffectingAttacker = unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) ? GetAffectingPlayer() : go ? GetAffectingPlayer() : nullptr;
+ Player const* playerAffectingTarget = unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) ? unitTarget->GetAffectingPlayer() : nullptr;
// Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
if ((playerAffectingAttacker && !playerAffectingTarget) || (!playerAffectingAttacker && playerAffectingTarget))
@@ -2979,7 +2979,7 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const
// PvP case - can't attack when attacker or target are in sanctuary
// however, 13850 client doesn't allow to attack when one of the unit's has sanctuary flag and is pvp
- if (unitTarget && unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner && unitOrOwner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && (unitTarget->IsInSanctuary() || unitOrOwner->IsInSanctuary()))
+ if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner && unitOrOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && (unitTarget->IsInSanctuary() || unitOrOwner->IsInSanctuary()))
return false;
// additional checks - only PvP case
@@ -2991,8 +2991,8 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const
if (playerAffectingAttacker->IsFFAPvP() && playerAffectingTarget->IsFFAPvP())
return true;
- return playerAffectingAttacker->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_UNK1) ||
- playerAffectingTarget->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_UNK1);
+ return playerAffectingAttacker->HasPvpFlag(UNIT_BYTE2_FLAG_UNK1) ||
+ playerAffectingTarget->HasPvpFlag(UNIT_BYTE2_FLAG_UNK1);
}
return true;
@@ -3039,16 +3039,16 @@ bool WorldObject::IsValidAssistTarget(WorldObject const* target, SpellInfo const
return false;
// can't assist untargetable
- if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE))
+ if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE))
return false;
// check flags for negative spells
- if (isNegativeSpell && unitTarget && unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_ON_TAXI | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NON_ATTACKABLE_2))
+ if (isNegativeSpell && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_ON_TAXI | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NON_ATTACKABLE_2))
return false;
if (isNegativeSpell || !bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
{
- if (unit && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
{
if (unitTarget && unitTarget->IsImmuneToPC())
return false;
@@ -3065,9 +3065,9 @@ bool WorldObject::IsValidAssistTarget(WorldObject const* target, SpellInfo const
return false;
// PvP case
- if (unitTarget && unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
{
- if (unit && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
{
Player const* selfPlayerOwner = GetAffectingPlayer();
Player const* targetPlayerOwner = unitTarget->GetAffectingPlayer();
@@ -3088,8 +3088,8 @@ bool WorldObject::IsValidAssistTarget(WorldObject const* target, SpellInfo const
}
}
// PvC case - player can assist creature only if has specific type flags
- // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) &&
- else if (unit && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ // !target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) &&
+ else if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
{
if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
if (unitTarget && !unitTarget->IsPvP())
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 907e7b47f35..7a32337a74b 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -82,6 +82,12 @@ class TC_GAME_API Object
float GetObjectScale() const { return GetFloatValue(OBJECT_FIELD_SCALE_X); }
virtual void SetObjectScale(float scale) { SetFloatValue(OBJECT_FIELD_SCALE_X, scale); }
+ virtual uint32 GetDynamicFlags() const { return 0; }
+ bool HasDynamicFlag(uint32 flag) const { return (GetDynamicFlags() & flag) != 0; }
+ virtual void SetDynamicFlag(uint32 flag) { ReplaceAllDynamicFlags(GetDynamicFlags() | flag); }
+ virtual void RemoveDynamicFlag(uint32 flag) { ReplaceAllDynamicFlags(GetDynamicFlags() & ~flag); }
+ virtual void ReplaceAllDynamicFlags([[maybe_unused]] uint32 flag) { }
+
TypeID GetTypeId() const { return m_objectTypeId; }
bool isType(uint16 mask) const { return (mask & m_objectType) != 0; }
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 711feb9718c..26297f26f63 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -228,7 +228,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
setPetType(petInfo->Type);
SetFaction(owner->GetFaction());
- SetUInt32Value(UNIT_CREATED_BY_SPELL, petInfo->CreatedBySpellId);
+ SetCreatedBySpell(petInfo->CreatedBySpellId);
if (IsCritter())
{
@@ -252,26 +252,22 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
SetDisplayId(petInfo->DisplayId);
SetNativeDisplayId(petInfo->DisplayId);
uint8 petlevel = petInfo->Level;
- SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+ ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
SetName(petInfo->Name);
switch (getPetType())
{
case SUMMON_PET:
petlevel = owner->GetLevel();
-
SetClass(CLASS_MAGE);
- SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
- // this enables popup window (pet dismiss, cancel)
+ ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED); // this enables popup window (pet dismiss, cancel)
break;
case HUNTER_PET:
SetClass(CLASS_WARRIOR);
SetGender(GENDER_NONE);
SetSheath(SHEATH_STATE_MELEE);
- SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, petInfo->WasRenamed ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED);
-
- SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
- // this enables popup window (pet abandon, cancel)
+ ReplaceAllPetFlags(petInfo->WasRenamed ? UNIT_PET_FLAG_CAN_BE_ABANDONED : (UNIT_PET_FLAG_CAN_BE_RENAMED | UNIT_PET_FLAG_CAN_BE_ABANDONED));
+ ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED); // this enables popup window (pet abandon, cancel)
SetMaxPower(POWER_HAPPINESS, GetCreatePowerValue(POWER_HAPPINESS));
SetPower(POWER_HAPPINESS, petInfo->Happiness);
break;
@@ -281,11 +277,11 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
break;
}
- SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped here
+ SetPetNameTimestamp(uint32(GameTime::GetGameTime())); // cast can't be helped here
SetCreatorGUID(owner->GetGUID());
InitStatsForLevel(petlevel);
- SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, petInfo->Experience);
+ SetPetExperience(petInfo->Experience);
SynchronizeLevelWithOwner();
@@ -518,7 +514,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
stmt->setUInt8(6, GetReactState());
stmt->setUInt8(7, mode);
stmt->setString(8, m_name);
- stmt->setUInt8(9, HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED) ? 0 : 1);
+ stmt->setUInt8(9, HasPetFlag(UNIT_PET_FLAG_CAN_BE_RENAMED) ? 0 : 1);
stmt->setUInt32(10, curhealth);
stmt->setUInt32(11, curmana);
stmt->setUInt32(12, GetPower(POWER_HAPPINESS));
@@ -547,7 +543,7 @@ void Pet::FillPetInfo(PetStable::PetInfo* petInfo) const
petInfo->Experience = GetUInt32Value(UNIT_FIELD_PETEXPERIENCE);
petInfo->ReactState = GetReactState();
petInfo->Name = GetName();
- petInfo->WasRenamed = !HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED);
+ petInfo->WasRenamed = !HasPetFlag(UNIT_PET_FLAG_CAN_BE_RENAMED);
petInfo->Health = GetHealth();
petInfo->Mana = GetPower(POWER_MANA);
petInfo->Happiness = GetPower(POWER_HAPPINESS);
@@ -592,19 +588,19 @@ void Pet::setDeathState(DeathState s) // overwrite virtual
if (getPetType() == HUNTER_PET)
{
// pet corpse non lootable and non skinnable
- SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
+ ReplaceAllDynamicFlags(UNIT_DYNFLAG_NONE);
+ RemoveUnitFlag(UNIT_FLAG_SKINNABLE);
// lose happiness when died and not in BG/Arena
if (!GetMap()->IsBattlegroundOrArena())
ModifyPower(POWER_HAPPINESS, -HAPPINESS_LEVEL_SIZE);
- //SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ //SetUnitFlag(UNIT_FLAG_STUNNED);
}
}
else if (getDeathState() == ALIVE)
{
- //RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ //RemoveUnitFlag(UNIT_FLAG_STUNNED);
CastPetAuras(true);
}
}
@@ -773,7 +769,7 @@ void Pet::GivePetXP(uint32 xp)
nextLvlXP = GetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP);
}
// Not affected by special conditions - give it new XP
- SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, petlevel < maxlevel ? newXP : 0);
+ SetPetExperience(petlevel < maxlevel ? newXP : 0);
}
void Pet::GivePetLevel(uint8 level)
@@ -783,8 +779,8 @@ void Pet::GivePetLevel(uint8 level)
if (getPetType() == HUNTER_PET)
{
- SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
- SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(level)*PET_XP_FACTOR));
+ SetPetExperience(0);
+ SetPetNextLevelExperience(uint32(sObjectMgr->GetXPForLevel(level)*PET_XP_FACTOR));
}
InitStatsForLevel(level);
@@ -848,17 +844,17 @@ bool Pet::CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phas
SetMaxPower(POWER_HAPPINESS, GetCreatePowerValue(POWER_HAPPINESS));
SetPower(POWER_HAPPINESS, 166500);
- SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, 0);
- SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
- SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32(sObjectMgr->GetXPForLevel(GetLevel()+1)*PET_XP_FACTOR));
- SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
+ SetPetNameTimestamp(0);
+ SetPetExperience(0);
+ SetPetNextLevelExperience(uint32(sObjectMgr->GetXPForLevel(GetLevel()+1)*PET_XP_FACTOR));
+ ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
if (cinfo->type == CREATURE_TYPE_BEAST)
{
SetClass(CLASS_WARRIOR);
SetGender(GENDER_NONE);
SetSheath(SHEATH_STATE_MELEE);
- SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED);
+ ReplaceAllPetFlags(UNIT_PET_FLAG_CAN_BE_RENAMED | UNIT_PET_FLAG_CAN_BE_ABANDONED);
}
return true;
@@ -904,7 +900,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetAttackTime(OFF_ATTACK, BASE_ATTACK_TIME);
SetAttackTime(RANGED_ATTACK, BASE_ATTACK_TIME);
- SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
+ SetModCastingSpeed(1.0f);
//scale
SetObjectScale(GetNativeObjectScale());
@@ -1885,7 +1881,7 @@ bool Pet::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, uint32
return false;
// Force regen flag for player pets, just like we do for players themselves
- SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
+ SetUnitFlag2(UNIT_FLAG2_REGENERATE_POWER);
SetSheath(SHEATH_STATE_MELEE);
GetThreatManager().Initialize();
diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h
index fb669dd943d..7828cdc23cb 100644
--- a/src/server/game/Entities/Pet/Pet.h
+++ b/src/server/game/Entities/Pet/Pet.h
@@ -83,6 +83,8 @@ class TC_GAME_API Pet : public Guardian
HappinessState GetHappinessState();
void GivePetXP(uint32 xp);
void GivePetLevel(uint8 level);
+ void SetPetExperience(uint32 xp) { SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, xp); }
+ void SetPetNextLevelExperience(uint32 xp) { SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, xp); }
void SynchronizeLevelWithOwner();
bool HaveInDiet(ItemTemplate const* item) const;
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 9ec2fc4e1c5..2ab7e8f9b92 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -508,17 +508,17 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
SetRace(createInfo->Race);
SetClass(createInfo->Class);
- SetGender(createInfo->Gender);
+ SetGender(Gender(createInfo->Gender));
SetPowerType(Powers(powertype), false);
InitDisplayIds();
if (sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP)
{
- SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_PVP);
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
+ SetPvpFlag(UNIT_BYTE2_FLAG_PVP);
+ SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
}
- SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);
- SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f); // fix cast time showed in spell tooltip on client
- SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f); // default for players in 3.0.3
+ SetUnitFlag2(UNIT_FLAG2_REGENERATE_POWER);
+ SetModCastingSpeed(1.0f); // fix cast time showed in spell tooltip on client
+ SetHoverHeight(1.0f); // default for players in 3.0.3
SetInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); // -1 is default value
@@ -528,7 +528,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo
SetHairColorId(createInfo->HairColor);
SetFacialStyle(createInfo->FacialHair);
SetRestState((GetSession()->IsARecruiter() || GetSession()->GetRecruiterId() != 0) ? REST_STATE_RAF_LINKED : REST_STATE_NOT_RAF_LINKED);
- SetNativeGender(createInfo->Gender);
+ SetNativeGender(Gender(createInfo->Gender));
SetArenaFaction(0);
SetUInt32Value(PLAYER_GUILDID, 0);
@@ -1972,8 +1972,8 @@ void Player::RemoveFromWorld()
void Player::SetObjectScale(float scale)
{
Unit::SetObjectScale(scale);
- SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, scale * DEFAULT_PLAYER_BOUNDING_RADIUS);
- SetFloatValue(UNIT_FIELD_COMBATREACH, scale * DEFAULT_PLAYER_COMBAT_REACH);
+ SetBoundingRadius(scale * DEFAULT_PLAYER_BOUNDING_RADIUS);
+ SetCombatReach(scale * DEFAULT_PLAYER_COMBAT_REACH);
}
bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, SpellEffectInfo const& spellEffectInfo, WorldObject const* caster) const
@@ -2256,7 +2256,7 @@ bool Player::CanInteractWithQuestGiver(Object* questGiver) const
return false;
}
-Creature* Player::GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask) const
+Creature* Player::GetNPCIfCanInteractWith(ObjectGuid const& guid, NPCFlags npcFlags) const
{
// unit checks
if (!guid)
@@ -2282,7 +2282,7 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflag
return nullptr;
// appropriate npc type
- if (npcflagmask && !creature->HasFlag(UNIT_NPC_FLAGS, npcflagmask))
+ if (npcFlags && !creature->HasNpcFlag(npcFlags))
return nullptr;
// not allow interaction under control, but allow with own pets
@@ -2367,12 +2367,12 @@ void Player::SetGameMaster(bool on)
m_ExtraFlags |= PLAYER_EXTRA_GM_ON;
SetFaction(FACTION_FRIENDLY);
SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
- SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
+ SetUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
if (Pet* pet = GetPet())
pet->SetFaction(FACTION_FRIENDLY);
- RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ RemovePvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
ResetContestedPvP();
CombatStopWithPets();
@@ -2397,14 +2397,14 @@ void Player::SetGameMaster(bool on)
m_ExtraFlags &= ~ PLAYER_EXTRA_GM_ON;
SetFactionForRace(GetRace());
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
- RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
+ RemoveUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS);
if (Pet* pet = GetPet())
pet->SetFaction(GetFaction());
// restore FFA PvP Server state
if (sWorld->IsFFAPvPRealm())
- SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ SetPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
// restore FFA PvP area state, remove not allowed for GM mounts
UpdateArea(m_areaUpdateId);
@@ -2733,7 +2733,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
UpdateSkillsForLevel();
// set default cast time multiplier
- SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
+ SetModCastingSpeed(1.0f);
// reset size before reapply auras
SetObjectScale(1.0f);
@@ -2777,12 +2777,12 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, 0.0f);
SetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, 0.0f);
- SetInt32Value(UNIT_FIELD_ATTACK_POWER, 0);
- SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0);
- SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, 0.0f);
- SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0);
- SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 0);
- SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER, 0.0f);
+ SetAttackPower(0);
+ SetAttackPowerModPos(0);
+ SetAttackPowerMultiplier(0.0f);
+ SetRangedAttackPower(0);
+ SetRangedAttackPowerModPos(0);
+ SetRangedAttackPowerMultiplier(0.0f);
// Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset
SetFloatValue(PLAYER_CRIT_PERCENTAGE, 0.0f);
@@ -2832,25 +2832,25 @@ void Player::InitStatsForLevel(bool reapplyMods)
SetMaxHealth(classInfo.basehealth); // stamina bonus will applied later
// cleanup mounted state (it will set correctly at aura loading if player saved at mount.
- SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0);
+ SetMountDisplayId(0);
// cleanup unit flags (will be re-applied if need at aura load).
- RemoveFlag(UNIT_FIELD_FLAGS,
+ RemoveUnitFlag(
UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_NOT_ATTACKABLE_1 |
UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC | UNIT_FLAG_LOOTING |
UNIT_FLAG_PET_IN_COMBAT | UNIT_FLAG_SILENCED | UNIT_FLAG_PACIFIED |
UNIT_FLAG_STUNNED | UNIT_FLAG_IN_COMBAT | UNIT_FLAG_DISARMED |
UNIT_FLAG_CONFUSED | UNIT_FLAG_FLEEING | UNIT_FLAG_UNINTERACTIBLE |
UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_ON_TAXI );
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); // must be set
+ SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED); // must be set
- SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);// must be set
+ SetUnitFlag2(UNIT_FLAG2_REGENERATE_POWER);// must be set
// cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example.
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_ALLOW_ONLY_ABILITY);
- RemoveStandFlags(UNIT_STAND_FLAGS_ALL); // one form stealth modified bytes
- RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
+ RemoveVisFlag(UNIT_VIS_FLAGS_ALL); // one form stealth modified bytes
+ RemovePvpFlag(UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY);
// restore if need some important flags
SetUInt32Value(PLAYER_FIELD_BYTES2, 0); // flags empty by default
@@ -4530,7 +4530,7 @@ void Player::BuildPlayerRepop()
SetMovement(MOVE_UNROOT);
// BG - remove insignia related
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
+ RemoveUnitFlag(UNIT_FLAG_SKINNABLE);
int32 corpseReclaimDelay = CalculateCorpseReclaimDelay();
@@ -4562,7 +4562,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
RemoveAurasDueToSpell(8326); // SPELL_AURA_GHOST
if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
- SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND);
+ SetDynamicFlag(UNIT_DYNFLAG_REFER_A_FRIEND);
setDeathState(ALIVE);
@@ -4641,9 +4641,9 @@ void Player::KillPlayer()
StopMirrorTimers(); //disable timers(bars)
setDeathState(CORPSE);
- //SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_IN_PVP);
+ //SetUnitFlag(UNIT_FLAG_NOT_IN_PVP);
- SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
+ ReplaceAllDynamicFlags(UNIT_DYNFLAG_NONE);
ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable() && !HasAuraType(SPELL_AURA_PREVENT_RESURRECTION));
// 6 minutes until repop at graveyard
@@ -7010,13 +7010,13 @@ void Player::UpdateArea(uint32 newArea)
pvpInfo.IsInNoPvPArea = false;
if (area && area->IsSanctuary()) // in sanctuary
{
- SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_SANCTUARY);
+ SetPvpFlag(UNIT_BYTE2_FLAG_SANCTUARY);
pvpInfo.IsInNoPvPArea = true;
if (!duel && GetCombatManager().HasPvPCombat())
CombatStopWithPets();
}
else
- RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_SANCTUARY);
+ RemovePvpFlag(UNIT_BYTE2_FLAG_SANCTUARY);
uint32 const areaRestFlag = (GetTeam() == ALLIANCE) ? AREA_FLAG_REST_ZONE_ALLIANCE : AREA_FLAG_REST_ZONE_HORDE;
if (area && area->Flags & areaRestFlag)
@@ -8620,7 +8620,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
else
{
// exploit fix
- if (!creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE))
+ if (!creature->HasDynamicFlag(UNIT_DYNFLAG_LOOTABLE))
{
SendLootError(guid, LOOT_ERROR_DIDNT_KILL);
return;
@@ -8734,7 +8734,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
loot->AddLooter(GetGUID());
if (loot_type == LOOT_CORPSE && !guid.IsItem())
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
+ SetUnitFlag(UNIT_FLAG_LOOTING);
}
else
SendLootError(GetLootGUID(), LOOT_ERROR_DIDNT_KILL);
@@ -13444,7 +13444,7 @@ void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid,
bool Player::IsUseEquipedWeapon(bool mainhand) const
{
// disarm applied only to mainhand weapon
- return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED));
+ return !IsInFeralForm() && (!mainhand || !HasUnitFlag(UNIT_FLAG_DISARMED));
}
void Player::SetCanTitanGrip(bool value, uint32 penaltySpellId /*= 0*/)
@@ -14322,7 +14322,7 @@ void Player::SendPreparedGossip(WorldObject* source)
if (source->GetTypeId() == TYPEID_UNIT)
{
// in case no gossip flag and quest menu not empty, open quest menu (client expect gossip menu with this flag)
- if (!source->ToCreature()->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty())
+ if (!source->ToCreature()->HasNpcFlag(UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty())
{
SendPreparedQuest(source->GetGUID());
return;
@@ -16928,7 +16928,7 @@ void Player::SendQuestGiverStatusMultiple()
Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr);
if (!questgiver || questgiver->IsHostileTo(this))
continue;
- if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
+ if (!questgiver->HasNpcFlag(UNIT_NPC_FLAG_QUESTGIVER))
continue;
questStatus = GetQuestDialogStatus(questgiver);
@@ -17197,10 +17197,10 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
// overwrite possible wrong/corrupted guid
SetGuidValue(OBJECT_FIELD_GUID, guid);
- uint8 gender = fields[5].GetUInt8();
+ Gender gender = Gender(fields[5].GetUInt8());
if (!IsValidGender(gender))
{
- TC_LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player (%s) has wrong gender (%u), can't load.", guid.ToString().c_str(), gender);
+ TC_LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player (%s) has wrong gender (%u), can't load.", guid.ToString().c_str(), uint32(gender));
return false;
}
@@ -17226,7 +17226,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
TC_LOG_WARN("entities.player.loading", "Player::LoadFromDB: Player (%s) has invalid knowntitles mask (%s). Forcing partial load.", guid.ToString().c_str(), fields[69].GetCString());
SetObjectScale(1.0f);
- SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
+ SetHoverHeight(1.0f);
// load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as loading does call UpdateAchievementCriteria)
m_achievementMgr->LoadFromDB(holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS), holder.GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS));
@@ -17243,7 +17243,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
SetFacialStyle(fields[13].GetUInt8());
SetBankBagSlotCount(fields[14].GetUInt8());
SetRestState(fields[15].GetUInt8());
- SetNativeGender(fields[5].GetUInt8());
+ SetNativeGender(Gender(fields[5].GetUInt8()));
SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_INEBRIATION, fields[54].GetUInt8());
if (!ValidateAppearance(
@@ -17660,7 +17660,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
// clear channel spell data (if saved at channel spell casting)
SetChannelObjectGuid(ObjectGuid::Empty);
- SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
+ SetChannelSpellId(0);
// clear charm/summon related fields
SetOwnerGUID(ObjectGuid::Empty);
@@ -17670,7 +17670,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
SetGuidValue(PLAYER_FARSIGHT, ObjectGuid::Empty);
SetCreatorGUID(ObjectGuid::Empty);
- RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT);
+ RemoveUnitFlag2(UNIT_FLAG2_FORCE_MOVEMENT);
// reset some aura modifiers before aura apply
SetUInt32Value(PLAYER_TRACK_CREATURES, 0);
@@ -17857,7 +17857,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
// RaF stuff.
m_grantableLevels = fields[71].GetUInt8();
if (GetSession()->IsARecruiter() || (GetSession()->GetRecruiterId() != 0))
- SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_REFER_A_FRIEND);
+ SetDynamicFlag(UNIT_DYNFLAG_REFER_A_FRIEND);
if (m_grantableLevels > 0)
SetByteValue(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_RAF_GRANTABLE_LEVEL, 0x01);
@@ -21307,7 +21307,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
return false;
}
- if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL))
+ if (HasUnitFlag(UNIT_FLAG_REMOVE_CLIENT_CONTROL))
return false;
// taximaster case
@@ -21502,7 +21502,7 @@ void Player::CleanupAfterTaxiFlight()
{
m_taxi.ClearTaxiDestinations(); // not destinations, clear source node
Dismount();
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_ON_TAXI);
+ RemoveUnitFlag(UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_ON_TAXI);
}
void Player::ContinueTaxiFlight() const
@@ -21564,7 +21564,7 @@ void Player::SendTaxiNodeStatusMultiple()
Creature* creature = ObjectAccessor::GetCreature(*this, *itr);
if (!creature || creature->IsHostileTo(this))
continue;
- if (!creature->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER))
+ if (!creature->HasNpcFlag(UNIT_NPC_FLAG_FLIGHTMASTER))
continue;
uint32 nearestNode = sObjectMgr->GetNearestTaxiNode(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetMapId(), GetTeam());
if (!nearestNode)
@@ -21935,16 +21935,16 @@ void Player::UpdatePvPState(bool onlyFFA)
{
if (!IsFFAPvP())
{
- SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ SetPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
- (*itr)->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ (*itr)->SetPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
}
}
else if (IsFFAPvP())
{
- RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ RemovePvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
- (*itr)->RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ (*itr)->RemovePvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
}
if (onlyFFA)
@@ -22478,7 +22478,7 @@ void Player::UpdateTriggerVisibility()
{
Creature* creature = GetMap()->GetCreature(*itr);
// Update fields of triggers, transformed units or uninteractible units (values dependent on GM state)
- if (!creature || (!creature->IsTrigger() && !creature->HasAuraType(SPELL_AURA_TRANSFORM) && !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE)))
+ if (!creature || (!creature->IsTrigger() && !creature->HasAuraType(SPELL_AURA_TRANSFORM) && !creature->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE)))
continue;
creature->SetFieldNotifyFlag(UF_FLAG_PUBLIC);
@@ -23191,14 +23191,14 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue)
void Player::SendAurasForTarget(Unit* target) const
{
- if (!target || target->GetVisibleAuras()->empty()) // speedup things
+ if (!target || target->GetVisibleAuras().empty()) // speedup things
return;
WorldPacket data(SMSG_AURA_UPDATE_ALL);
data << target->GetPackGUID();
- Unit::VisibleAuraMap const* visibleAuras = target->GetVisibleAuras();
- for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
+ Unit::VisibleAuraMap const& visibleAuras = target->GetVisibleAuras();
+ for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras.begin(); itr != visibleAuras.end(); ++itr)
{
AuraApplication * auraApp = itr->second;
auraApp->BuildUpdatePacket(data, false);
@@ -23551,7 +23551,7 @@ void Player::UpdateVisibleGameobjectsOrSpellClicks()
continue;
// check if this unit requires quest specific flags
- if (!obj->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
+ if (!obj->HasNpcFlag(UNIT_NPC_FLAG_SPELLCLICK))
continue;
auto clickBounds = sObjectMgr->GetSpellClickInfoMapBounds(obj->GetEntry());
@@ -23741,7 +23741,7 @@ bool Player::CanNoReagentCast(SpellInfo const* spellInfo) const
{
// don't take reagents for spells with SPELL_ATTR5_NO_REAGENT_WHILE_PREP
if (spellInfo->HasAttribute(SPELL_ATTR5_NO_REAGENT_WHILE_PREP) &&
- HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION))
+ HasUnitFlag(UNIT_FLAG_PREPARATION))
return true;
// Check no reagent use mask
@@ -25505,7 +25505,7 @@ bool Player::IsPetNeedBeTemporaryUnsummoned() const
bool Player::CanSeeSpellClickOn(Creature const* c) const
{
- if (!c->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK))
+ if (!c->HasNpcFlag(UNIT_NPC_FLAG_SPELLCLICK))
return false;
auto clickBounds = sObjectMgr->GetSpellClickInfoMapBounds(c->GetEntry());
@@ -26780,8 +26780,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
pet->SetCreatorGUID(GetGUID());
pet->SetFaction(GetFaction());
- pet->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
- pet->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
+ pet->ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
pet->InitStatsForLevel(GetLevel());
SetMinion(pet, true);
@@ -26792,11 +26791,11 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
// this enables pet details window (Shift+P)
pet->GetCharmInfo()->SetPetNumber(pet_number, true);
pet->SetClass(CLASS_MAGE);
- pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0);
- pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
+ pet->SetPetExperience(0);
+ pet->SetPetNextLevelExperience(1000);
pet->SetFullHealth();
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
- pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped in this case
+ pet->SetPetNameTimestamp(uint32(GameTime::GetGameTime())); // cast can't be helped in this case
break;
default:
break;
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 376ebe3f72e..b4aafb4c65c 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -926,7 +926,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome) const;
bool CanInteractWithQuestGiver(Object* questGiver) const;
- Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask) const;
+ Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, NPCFlags npcFlags) const;
GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid) const;
GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid, GameobjectTypes type) const;
@@ -996,8 +996,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
uint32 GetTotalPlayedTime() const { return m_Played_time[PLAYED_TIME_TOTAL]; }
uint32 GetLevelPlayedTime() const { return m_Played_time[PLAYED_TIME_LEVEL]; }
- uint8 GetNativeGender() const override { return GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER); }
- void SetNativeGender(uint8 gender) override { SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER, gender); }
+ Gender GetNativeGender() const override { return Gender(GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)); }
+ void SetNativeGender(Gender gender) override { SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER, gender); }
uint8 GetSkinId() const { return GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID); }
void SetSkinId(uint8 skin) { SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID, skin); }
uint8 GetFaceId() const { return GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID); }
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 9364d71e2a6..f1d45b935a4 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -475,7 +475,7 @@ TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSu
return nullptr;
}
- summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
+ summon->SetCreatedBySpell(spellId);
summon->SetTransport(this);
summon->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index c1939f60dd5..142affc27cf 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -341,16 +341,8 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
- uint16 index = UNIT_FIELD_ATTACK_POWER;
- uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS;
- uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;
-
if (ranged)
{
- index = UNIT_FIELD_RANGED_ATTACK_POWER;
- index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
- index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
-
switch (GetClass())
{
case CLASS_HUNTER:
@@ -480,9 +472,18 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
float attPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
- SetInt32Value(index, (uint32)base_attPower); //UNIT_FIELD_(RANGED)_ATTACK_POWER field
- SetInt32Value(index_mod, (uint32)attPowerMod); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
- SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
+ if (ranged)
+ {
+ SetRangedAttackPower(int32(base_attPower));
+ SetRangedAttackPowerModPos(int32(attPowerMod));
+ SetRangedAttackPowerMultiplier(attPowerMultiplier);
+ }
+ else
+ {
+ SetAttackPower(int32(base_attPower));
+ SetAttackPowerModPos(int32(attPowerMod));
+ SetAttackPowerMultiplier(attPowerMultiplier);
+ }
Pet* pet = GetPet(); //update pet's AP
Guardian* guardian = GetGuardianPet();
@@ -1043,24 +1044,22 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged)
{
UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER;
- uint16 index = UNIT_FIELD_ATTACK_POWER;
- uint16 indexMod = UNIT_FIELD_ATTACK_POWER_MODS;
- uint16 indexMulti = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;
-
- if (ranged)
- {
- index = UNIT_FIELD_RANGED_ATTACK_POWER;
- indexMod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
- indexMulti = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
- }
-
float baseAttackPower = GetFlatModifierValue(unitMod, BASE_VALUE) * GetPctModifierValue(unitMod, BASE_PCT);
float attackPowerMod = GetFlatModifierValue(unitMod, TOTAL_VALUE);
float attackPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
- SetInt32Value(index, uint32(baseAttackPower)); // UNIT_FIELD_(RANGED)_ATTACK_POWER
- SetInt32Value(indexMod, uint32(attackPowerMod)); // UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS
- SetFloatValue(indexMulti, attackPowerMultiplier); // UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER
+ if (ranged)
+ {
+ SetRangedAttackPower(int32(baseAttackPower));
+ SetRangedAttackPowerModPos(int32(attackPowerMod));
+ SetRangedAttackPowerMultiplier(attackPowerMultiplier);
+ }
+ else
+ {
+ SetAttackPower(int32(baseAttackPower));
+ SetAttackPowerModPos(int32(attackPowerMod));
+ SetAttackPowerMultiplier(attackPowerMultiplier);
+ }
// automatically update weapon damage after attack power modification
if (ranged)
@@ -1423,12 +1422,9 @@ void Guardian::UpdateAttackPowerAndDamage(bool ranged)
float attPowerMod = GetFlatModifierValue(unitMod, TOTAL_VALUE);
float attPowerMultiplier = GetPctModifierValue(unitMod, TOTAL_PCT) - 1.0f;
- //UNIT_FIELD_(RANGED)_ATTACK_POWER field
- SetInt32Value(UNIT_FIELD_ATTACK_POWER, (int32)base_attPower);
- //UNIT_FIELD_(RANGED)_ATTACK_POWER_MODS field
- SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, (int32)attPowerMod);
- //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
- SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, attPowerMultiplier);
+ SetAttackPower(int32(base_attPower));
+ SetAttackPowerModPos(int32(attPowerMod));
+ SetAttackPowerMultiplier(attPowerMultiplier);
//automatically update weapon damage after attack power modification
UpdateDamagePhysical(BASE_ATTACK);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index ba811094c58..13ef25a631d 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -301,7 +301,7 @@ Unit::Unit(bool isWorldObject) :
m_removedAurasCount(0), m_charmer(nullptr), m_charmed(nullptr),
i_motionMaster(new MotionMaster(this)), m_regenTimer(0), m_vehicle(nullptr), m_vehicleKit(nullptr),
m_unitTypeMask(UNIT_MASK_NONE), m_Diminishing(), m_combatManager(this), m_threatManager(this),
- m_aiLocked(false), m_comboTarget(nullptr), m_comboPoints(0), m_spellHistory(new SpellHistory(this))
+ m_aiLocked(false), m_comboTarget(nullptr), m_comboPoints(0), _spellHistory(new SpellHistory(this))
{
m_objectType |= TYPEMASK_UNIT;
m_objectTypeId = TYPEID_UNIT;
@@ -412,7 +412,7 @@ Unit::~Unit()
delete i_motionMaster;
delete m_charmInfo;
delete movespline;
- delete m_spellHistory;
+ delete _spellHistory;
ASSERT(!m_duringRemoveFromWorld);
ASSERT(!m_attacking);
@@ -659,14 +659,14 @@ void Unit::UpdateInterruptMask()
m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags;
}
-bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const
+bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, flag96 familyFlags) const
{
if (!HasAuraType(auraType))
return false;
AuraEffectList const& auras = GetAuraEffectsByType(auraType);
for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
if (SpellInfo const* iterSpellProto = (*itr)->GetSpellInfo())
- if (iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags)
+ if (iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags & familyFlags)
return true;
return false;
}
@@ -1109,7 +1109,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama
damageInfo->damage = dmgInfo.GetDamage();
}
-void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss)
+void Unit::DealSpellDamage(SpellNonMeleeDamage const* damageInfo, bool durabilityLoss)
{
if (!damageInfo)
return;
@@ -2073,7 +2073,7 @@ void Unit::HandleEmoteCommand(Emote emoteId)
void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extra)
{
- if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
+ if (HasUnitFlag(UNIT_FLAG_PACIFIED))
return;
if (HasUnitState(UNIT_STATE_CANNOT_AUTOATTACK) && !extra)
@@ -2094,7 +2094,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr
if (!extra && _lastExtraAttackSpell)
_lastExtraAttackSpell = 0;
- if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED) && !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CANNOT_TURN))
+ if (GetTypeId() == TYPEID_UNIT && !HasUnitFlag(UNIT_FLAG_POSSESSED) && !HasUnitFlag2(UNIT_FLAG2_CANNOT_TURN))
SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells)
// melee attack spell cast at main hand attack only - no normal melee dmg dealt
@@ -2413,11 +2413,11 @@ bool Unit::CanUseAttackType(uint8 attacktype) const
switch (attacktype)
{
case BASE_ATTACK:
- return !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED);
+ return !HasUnitFlag(UNIT_FLAG_DISARMED);
case OFF_ATTACK:
- return !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_OFFHAND);
+ return !HasUnitFlag2(UNIT_FLAG2_DISARM_OFFHAND);
case RANGED_ATTACK:
- return !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISARM_RANGED);
+ return !HasUnitFlag2(UNIT_FLAG2_DISARM_RANGED);
default:
return true;
}
@@ -2924,7 +2924,7 @@ void Unit::_UpdateSpells(uint32 time)
}
}
- m_spellHistory->Update();
+ _spellHistory->Update();
}
void Unit::_UpdateAutoRepeatSpell()
@@ -5066,17 +5066,20 @@ void Unit::_UnregisterDynObject(DynamicObject* dynObj)
m_dynObj.remove(dynObj);
}
-DynamicObject* Unit::GetDynObject(uint32 spellId)
+DynamicObject* Unit::GetDynObject(uint32 spellId) const
{
- if (m_dynObj.empty())
- return nullptr;
- for (DynObjectList::const_iterator i = m_dynObj.begin(); i != m_dynObj.end();++i)
- {
- DynamicObject* dynObj = *i;
- if (dynObj->GetSpellId() == spellId)
- return dynObj;
- }
- return nullptr;
+ std::vector<DynamicObject*> dynamicobjects = GetDynObjects(spellId);
+ return dynamicobjects.empty() ? nullptr : dynamicobjects.front();
+}
+
+std::vector<DynamicObject*> Unit::GetDynObjects(uint32 spellId) const
+{
+ std::vector<DynamicObject*> dynamicobjects;
+ for (DynObjectList::const_iterator i = m_dynObj.begin(); i != m_dynObj.end(); ++i)
+ if ((*i)->GetSpellId() == spellId)
+ dynamicobjects.push_back(*i);
+
+ return dynamicobjects;
}
void Unit::RemoveDynObject(uint32 spellId)
@@ -5104,11 +5107,18 @@ void Unit::RemoveAllDynObjects()
GameObject* Unit::GetGameObject(uint32 spellId) const
{
+ std::vector<GameObject*> gameobjects = GetGameObjects(spellId);
+ return gameobjects.empty() ? nullptr : gameobjects.front();
+}
+
+std::vector<GameObject*> Unit::GetGameObjects(uint32 spellId) const
+{
+ std::vector<GameObject*> gameobjects;
for (GameObjectList::const_iterator i = m_gameObj.begin(); i != m_gameObj.end(); ++i)
if ((*i)->GetSpellId() == spellId)
- return *i;
+ gameobjects.push_back(*i);
- return nullptr;
+ return gameobjects;
}
void Unit::AddGameObject(GameObject* gameObj)
@@ -5203,7 +5213,7 @@ void Unit::RemoveAllGameObjects()
}
}
-void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log)
+void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const* log)
{
WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+4+1+4+4+1+1+4+4+1)); // we guess size
data << log->target->GetPackGUID();
@@ -5640,7 +5650,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
creature->CallAssistance();
// Remove emote state - will be restored on creature reset
- SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
+ SetEmoteState(EMOTE_ONESHOT_NONE);
}
// delay offhand weapon attack by 50% of the base attack time
@@ -5822,7 +5832,7 @@ void Unit::ModifyAuraState(AuraStateType flag, bool apply)
}
}
-uint32 Unit::BuildAuraStateUpdateForTarget(Unit* target) const
+uint32 Unit::BuildAuraStateUpdateForTarget(Unit const* target) const
{
uint32 auraStates = GetUInt32Value(UNIT_FIELD_AURASTATE) &~(PER_CASTER_AURA_STATE_MASK);
for (AuraStateAurasMap::const_iterator itr = m_auraStateAuras.begin(); itr != m_auraStateAuras.end(); ++itr)
@@ -5950,7 +5960,7 @@ void Unit::SetMinion(Minion *minion, bool apply)
if (GetTypeId() == TYPEID_PLAYER)
{
minion->m_ControlledByPlayer = true;
- minion->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
+ minion->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
}
// Can only have one pet. If a new one is summoned, dismiss the old one.
@@ -5983,7 +5993,7 @@ void Unit::SetMinion(Minion *minion, bool apply)
SetCritterGUID(minion->GetGUID());
// PvP, FFAPvP
- minion->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG));
+ minion->ReplaceAllPvpFlags(GetPvpFlags());
// FIXME: hack, speed must be set only at follow
if (GetTypeId() == TYPEID_PLAYER && minion->IsPet())
@@ -6114,13 +6124,13 @@ void Unit::SetCharm(Unit* charm, bool apply)
charm->m_ControlledByPlayer = true;
/// @todo maybe we can use this flag to check if controlled by player
- charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
+ charm->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
}
else
charm->m_ControlledByPlayer = false;
// PvP, FFAPvP
- charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG));
+ charm->ReplaceAllPvpFlags(GetPvpFlags());
ASSERT_WITH_SIDE_EFFECTS(charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()),
"Unit %u is being charmed, but it already has a charmer %s", charm->GetEntry(), charm->GetCharmerGUID().ToString().c_str());
@@ -6153,20 +6163,20 @@ void Unit::SetCharm(Unit* charm, bool apply)
if (charm->GetTypeId() == TYPEID_PLAYER)
{
charm->m_ControlledByPlayer = true;
- charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
+ charm->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
charm->ToPlayer()->UpdatePvPState();
}
else if (Player* player = charm->GetCharmerOrOwnerPlayerOrPlayerItself())
{
charm->m_ControlledByPlayer = true;
- charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
- charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, player->GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG));
+ charm->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
+ charm->ReplaceAllPvpFlags(player->GetPvpFlags());
}
else
{
charm->m_ControlledByPlayer = false;
- charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
- charm->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, 0);
+ charm->RemoveUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
+ charm->ReplaceAllPvpFlags(UNIT_BYTE2_FLAG_NONE);
}
if (charm->IsWalking() != _isWalkingBeforeCharm)
@@ -6295,7 +6305,7 @@ void Unit::RemoveAllControlled()
if (GetCharmedGUID())
TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmedGUID().ToString().c_str());
if (!IsPet()) // pets don't use the flag for this
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); // m_controlled is now empty, so we know none of our minions are in combat
+ RemoveUnitFlag(UNIT_FLAG_PET_IN_COMBAT); // m_controlled is now empty, so we know none of our minions are in combat
}
bool Unit::isPossessedByPlayer() const
@@ -8148,9 +8158,9 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spe
void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
{
if (mount)
- SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount);
+ SetMountDisplayId(mount);
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT);
+ SetUnitFlag(UNIT_FLAG_MOUNT);
if (Player* player = ToPlayer())
{
@@ -8180,7 +8190,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
Battleground* bg = ToPlayer()->GetBattleground();
// don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface
if (bg && bg->isArena())
- pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ pet->SetUnitFlag(UNIT_FLAG_STUNNED);
else
player->UnsummonPetTemporaryIfAny();
}
@@ -8188,7 +8198,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
// if we have charmed npc, stun him also (everywhere)
if (Unit* charm = player->GetCharmed())
if (charm->GetTypeId() == TYPEID_UNIT)
- charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ charm->SetUnitFlag(UNIT_FLAG_STUNNED);
WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);
data << GetPackGUID();
@@ -8205,8 +8215,8 @@ void Unit::Dismount()
if (!IsMounted())
return;
- SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0);
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT);
+ SetMountDisplayId(0);
+ RemoveUnitFlag(UNIT_FLAG_MOUNT);
if (Player* thisPlayer = ToPlayer())
{
@@ -8242,22 +8252,22 @@ void Unit::Dismount()
{
if (Pet* pPet = player->GetPet())
{
- if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STATE_STUNNED))
- pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ if (pPet->HasUnitFlag(UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STATE_STUNNED))
+ pPet->RemoveUnitFlag(UNIT_FLAG_STUNNED);
}
else
player->ResummonPetTemporaryUnSummonedIfAny();
// if we have charmed npc, remove stun also
if (Unit* charm = player->GetCharmed())
- if (charm->GetTypeId() == TYPEID_UNIT && charm->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !charm->HasUnitState(UNIT_STATE_STUNNED))
- charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ if (charm->GetTypeId() == TYPEID_UNIT && charm->HasUnitFlag(UNIT_FLAG_STUNNED) && !charm->HasUnitState(UNIT_STATE_STUNNED))
+ charm->RemoveUnitFlag(UNIT_FLAG_STUNNED);
}
}
bool Unit::IsServiceProvider() const
{
- return HasFlag(UNIT_NPC_FLAGS,
+ return HasNpcFlag(
UNIT_NPC_FLAG_VENDOR | UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_FLIGHTMASTER |
UNIT_NPC_FLAG_PETITIONER | UNIT_NPC_FLAG_BATTLEMASTER | UNIT_NPC_FLAG_BANKER |
UNIT_NPC_FLAG_INNKEEPER | UNIT_NPC_FLAG_SPIRITHEALER |
@@ -8279,59 +8289,59 @@ void Unit::SetImmuneToAll(bool apply, bool keepCombat)
{
if (apply)
{
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
+ SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
ValidateAttackersAndOwnTarget();
if (!keepCombat)
m_combatManager.EndAllCombat();
}
else
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
+ RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_IMMUNE_TO_NPC);
}
void Unit::SetImmuneToPC(bool apply, bool keepCombat)
{
if (apply)
{
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
ValidateAttackersAndOwnTarget();
if (!keepCombat)
{
std::list<CombatReference*> toEnd;
for (auto const& pair : m_combatManager.GetPvECombatRefs())
- if (pair.second->GetOther(this)->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (pair.second->GetOther(this)->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
toEnd.push_back(pair.second);
for (auto const& pair : m_combatManager.GetPvPCombatRefs())
- if (pair.second->GetOther(this)->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (pair.second->GetOther(this)->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
toEnd.push_back(pair.second);
for (CombatReference* ref : toEnd)
ref->EndCombat();
}
}
else
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
+ RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC);
}
void Unit::SetImmuneToNPC(bool apply, bool keepCombat)
{
if (apply)
{
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
+ SetUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
ValidateAttackersAndOwnTarget();
if (!keepCombat)
{
std::list<CombatReference*> toEnd;
for (auto const& pair : m_combatManager.GetPvECombatRefs())
- if (!pair.second->GetOther(this)->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (!pair.second->GetOther(this)->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
toEnd.push_back(pair.second);
for (auto const& pair : m_combatManager.GetPvPCombatRefs())
- if (!pair.second->GetOther(this)->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
+ if (!pair.second->GetOther(this)->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
toEnd.push_back(pair.second);
for (CombatReference* ref : toEnd)
ref->EndCombat();
}
}
else
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC);
+ RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC);
}
bool Unit::IsThreatened() const
@@ -8344,8 +8354,7 @@ bool Unit::isTargetableForAttack(bool checkFakeDeath) const
if (!IsAlive())
return false;
- if (HasFlag(UNIT_FIELD_FLAGS,
- UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE))
+ if (HasUnitFlag( UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_UNINTERACTIBLE))
return false;
if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->IsGameMaster())
@@ -8740,14 +8749,14 @@ void Unit::setDeathState(DeathState s)
// do not why since in IncreaseMaxHealth currenthealth is checked
SetHealth(0);
SetPower(GetPowerType(), 0);
- SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
+ SetEmoteState(EMOTE_ONESHOT_NONE);
// players in instance don't have ZoneScript, but they have InstanceScript
if (ZoneScript* zoneScript = GetZoneScript() ? GetZoneScript() : GetInstanceScript())
zoneScript->OnUnitDeath(this);
}
else if (s == JUST_RESPAWNED)
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground)
+ RemoveUnitFlag(UNIT_FLAG_SKINNABLE); // clear skinnable for creature and player (at battleground)
}
//======================================================================
@@ -8793,9 +8802,9 @@ void Unit::UpdatePetCombatState()
}
if (state)
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
+ SetUnitFlag(UNIT_FLAG_PET_IN_COMBAT);
else
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
+ RemoveUnitFlag(UNIT_FLAG_PET_IN_COMBAT);
}
//======================================================================
@@ -9908,9 +9917,9 @@ void CharmInfo::SetPetNumber(uint32 petnumber, bool statwindow)
{
_petnumber = petnumber;
if (statwindow)
- _unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, _petnumber);
+ _unit->SetPetNumberForClient(_petnumber);
else
- _unit->SetUInt32Value(UNIT_FIELD_PETNUMBER, 0);
+ _unit->SetPetNumberForClient(0);
}
void CharmInfo::LoadPetActionBar(const std::string& data)
@@ -10322,7 +10331,7 @@ bool Unit::IsStandState() const
return !IsSitState() && s != UNIT_STAND_STATE_SLEEP && s != UNIT_STAND_STATE_KNEEL;
}
-void Unit::SetStandState(uint8 state)
+void Unit::SetStandState(UnitStandStateType state)
{
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, state);
@@ -10371,7 +10380,7 @@ void Unit::SetDisplayId(uint32 modelId)
SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
// Set Gender by modelId
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
- SetGender(minfo->gender);
+ SetGender(Gender(minfo->gender));
}
void Unit::RestoreDisplayId()
@@ -10615,7 +10624,7 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply)
else
ApplyPercentModFloatVar(amount, -val, apply);
- SetFloatValue(UNIT_MOD_CAST_SPEED, amount);
+ SetModCastingSpeed(amount);
}
uint32 Unit::GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const
@@ -10868,10 +10877,10 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
pet->SetCreatorGUID(GetGUID());
pet->SetFaction(GetFaction());
- pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
+ pet->SetCreatedBySpell(spell_id);
if (GetTypeId() == TYPEID_PLAYER)
- pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
+ pet->ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED);
if (!pet->InitStatsForLevel(level))
{
@@ -11110,7 +11119,7 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
{
// must be after setDeathState which resets dynamic flags
if (!creature->loot.isLooted())
- creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ creature->SetDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
else
creature->AllLootRemovedFromCorpse();
}
@@ -11320,7 +11329,7 @@ void Unit::SetStunned(bool apply)
m_rootTimes++;
SetTarget(ObjectGuid::Empty);
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ SetUnitFlag(UNIT_FLAG_STUNNED);
// MOVEMENTFLAG_ROOT cannot be used in conjunction with MOVEMENTFLAG_MASK_MOVING (tested 3.3.5a)
// this will freeze clients. That's why we remove MOVEMENTFLAG_MASK_MOVING before
@@ -11356,7 +11365,7 @@ void Unit::SetStunned(bool apply)
// don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface)
Unit* owner = GetCharmerOrOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER || !owner->ToPlayer()->IsMounted())
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ RemoveUnitFlag(UNIT_FLAG_STUNNED);
if (!HasUnitState(UNIT_STATE_ROOT)) // prevent moving if it also has root effect
{
@@ -11615,13 +11624,13 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
switch (type)
{
case CHARM_TYPE_VEHICLE:
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
+ SetUnitFlag(UNIT_FLAG_POSSESSED);
playerCharmer->SetClientControl(this, true);
playerCharmer->VehicleSpellInitialize();
break;
case CHARM_TYPE_POSSESS:
- SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
- charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL);
+ SetUnitFlag(UNIT_FLAG_POSSESSED);
+ charmer->SetUnitFlag(UNIT_FLAG_REMOVE_CLIENT_CONTROL);
playerCharmer->SetClientControl(this, true);
playerCharmer->PossessSpellInitialize();
AddUnitState(UNIT_STATE_POSSESSED);
@@ -11640,7 +11649,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
// if charmed two demons the same session, the 2nd gets the 1st one's name
- SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped
+ SetPetNameTimestamp(uint32(GameTime::GetGameTime())); // cast can't be helped
}
}
playerCharmer->CharmSpellInitialize();
@@ -11719,14 +11728,14 @@ void Unit::RemoveCharmedBy(Unit* charmer)
case CHARM_TYPE_VEHICLE:
playerCharmer->SetClientControl(this, false);
playerCharmer->SetClientControl(charmer, true);
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
+ RemoveUnitFlag(UNIT_FLAG_POSSESSED);
break;
case CHARM_TYPE_POSSESS:
ClearUnitState(UNIT_STATE_POSSESSED);
playerCharmer->SetClientControl(this, false);
playerCharmer->SetClientControl(charmer, true);
- charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL);
- RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
+ charmer->RemoveUnitFlag(UNIT_FLAG_REMOVE_CLIENT_CONTROL);
+ RemoveUnitFlag(UNIT_FLAG_POSSESSED);
break;
case CHARM_TYPE_CHARM:
if (GetTypeId() == TYPEID_UNIT && charmer->GetClass() == CLASS_WARLOCK)
@@ -11813,7 +11822,7 @@ void Unit::RemoveVehicleKit()
m_updateFlag &= ~UPDATEFLAG_VEHICLE;
m_unitTypeMask &= ~UNIT_MASK_VEHICLE;
- RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK | UNIT_NPC_FLAG_PLAYER_VEHICLE);
+ RemoveNpcFlag(UNIT_NPC_FLAG_SPELLCLICK | UNIT_NPC_FLAG_PLAYER_VEHICLE);
}
bool Unit::IsOnVehicle(Unit const* vehicle) const
@@ -11954,9 +11963,9 @@ bool Unit::IsContestedGuard() const
void Unit::SetPvP(bool state)
{
if (state)
- SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_PVP);
+ SetPvpFlag(UNIT_BYTE2_FLAG_PVP);
else
- RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_PVP);
+ RemovePvpFlag(UNIT_BYTE2_FLAG_PVP);
}
Aura* Unit::AddAura(uint32 spellId, Unit* target)
@@ -12822,15 +12831,15 @@ bool Unit::IsFalling() const
bool Unit::CanSwim() const
{
// Mirror client behavior, if this method returns false then client will not use swimming animation and for players will apply gravity as if there was no water
- if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CANNOT_SWIM))
+ if (HasUnitFlag(UNIT_FLAG_CANNOT_SWIM))
return false;
- if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) // is player
+ if (HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) // is player
return true;
- if (HasFlag(UNIT_FIELD_FLAGS_2, 0x1000000))
+ if (HasUnitFlag2(UNIT_FLAG2_UNUSED_6))
return false;
- if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT))
+ if (HasUnitFlag(UNIT_FLAG_PET_IN_COMBAT))
return true;
- return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_RENAME | UNIT_FLAG_CAN_SWIM);
+ return HasUnitFlag(UNIT_FLAG_RENAME | UNIT_FLAG_CAN_SWIM);
}
void Unit::NearTeleportTo(Position const& pos, bool casting /*= false*/)
@@ -13164,7 +13173,7 @@ void Unit::SendClearTarget()
SendMessageToSet(&data, false);
}
-uint32 Unit::GetResistance(SpellSchoolMask mask) const
+int32 Unit::GetResistance(SpellSchoolMask mask) const
{
int32 resist = -1;
for (int32 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
@@ -13172,7 +13181,7 @@ uint32 Unit::GetResistance(SpellSchoolMask mask) const
resist = int32(GetResistance(SpellSchools(i)));
// resist value will never be negative here
- return uint32(resist);
+ return resist;
}
void CharmInfo::SetIsCommandAttack(bool val)
@@ -13390,6 +13399,11 @@ bool Unit::SetHover(bool enable, bool /*packetOnly = false*/, bool /*updateAnimT
return true;
}
+bool Unit::IsSplineEnabled() const
+{
+ return movespline->Initialized() && !movespline->Finalized();
+}
+
void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) const
{
if (!target)
@@ -13409,7 +13423,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
if (GetOwnerGUID() == target->GetGUID())
visibleFlag |= UF_FLAG_OWNER;
- if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO))
+ if (HasDynamicFlag(UNIT_DYNFLAG_SPECIALINFO))
if (HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID()))
visibleFlag |= UF_FLAG_SPECIAL_INFO;
@@ -13661,6 +13675,22 @@ void Unit::Whisper(std::string_view text, Language language, Player* target, boo
target->SendDirectMessage(&data);
}
+uint32 Unit::GetVirtualItemId(uint32 slot) const
+{
+ if (slot >= MAX_EQUIPMENT_ITEMS)
+ return 0;
+
+ return GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot);
+}
+
+void Unit::SetVirtualItem(uint32 slot, uint32 itemId)
+{
+ if (slot >= MAX_EQUIPMENT_ITEMS)
+ return;
+
+ SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + slot, itemId);
+}
+
void Unit::Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target)
{
if (!sObjectMgr->GetBroadcastText(textId))
@@ -13715,7 +13745,7 @@ float Unit::GetCollisionHeight() const
if (IsMounted())
{
- if (CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID)))
+ if (CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetMountDisplayId()))
{
if (CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelID))
{
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 1eeb501dc26..bf8e2b2753e 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -93,8 +93,13 @@ class UnitAura;
class Vehicle;
class VehicleJoinEvent;
-enum ZLiquidStatus : uint32;
enum MovementGeneratorType : uint8;
+enum ZLiquidStatus : uint32;
+
+namespace Movement
+{
+ class MoveSpline;
+}
typedef std::list<Unit*> UnitList;
@@ -367,10 +372,6 @@ enum UnitTypeMask
UNIT_MASK_ACCESSORY = 0x00000200
};
-namespace Movement{
- class MoveSpline;
-}
-
struct DiminishingReturn
{
DiminishingReturn() : stack(0), hitTime(0), hitCount(DIMINISHING_LEVEL_1) { }
@@ -787,6 +788,7 @@ class TC_GAME_API Unit : public WorldObject
typedef std::list<AuraEffect*> AuraEffectList;
typedef std::list<Aura*> AuraList;
typedef std::list<AuraApplication*> AuraApplicationList;
+ typedef std::array<DiminishingReturn, DIMINISHING_MAX> Diminishing;
typedef std::vector<std::pair<uint8 /*procEffectMask*/, AuraApplication*>> AuraApplicationProcContainer;
@@ -814,6 +816,9 @@ class TC_GAME_API Unit : public WorldObject
void CleanupBeforeRemoveFromMap(bool finalCleanup);
void CleanupsBeforeDelete(bool finalCleanup = true) override; // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
+ uint32 GetDynamicFlags() const override { return GetUInt32Value(UNIT_DYNAMIC_FLAGS); }
+ void ReplaceAllDynamicFlags(uint32 flag) override { SetUInt32Value(UNIT_DYNAMIC_FLAGS, flag); }
+
virtual bool IsAffectedByDiminishingReturns() const { return (GetCharmerOrOwnerPlayerOrPlayerItself() != nullptr); }
DiminishingLevels GetDiminishing(DiminishingGroup group) const;
void IncrDiminishing(SpellInfo const* auraSpellInfo, bool triggered);
@@ -830,7 +835,10 @@ class TC_GAME_API Unit : public WorldObject
bool haveOffhandWeapon() const;
bool CanDualWield() const { return m_canDualWield; }
virtual void SetCanDualWield(bool value) { m_canDualWield = value; }
- float GetCombatReach() const override { return m_floatValues[UNIT_FIELD_COMBATREACH]; }
+ float GetCombatReach() const override { return GetFloatValue(UNIT_FIELD_COMBATREACH); }
+ void SetCombatReach(float combatReach) { SetFloatValue(UNIT_FIELD_COMBATREACH, combatReach); }
+ float GetBoundingRadius() const { return GetFloatValue(UNIT_FIELD_BOUNDINGRADIUS); }
+ void SetBoundingRadius(float boundingRadius) { SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, boundingRadius); }
bool IsWithinCombatRange(Unit const* obj, float dist2compare) const;
bool IsWithinMeleeRange(Unit const* obj) const { return IsWithinMeleeRangeAt(GetPosition(), obj); }
bool IsWithinMeleeRangeAt(Position const& pos, Unit const* obj) const;
@@ -884,21 +892,21 @@ class TC_GAME_API Unit : public WorldObject
void SetRace(uint8 race) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_RACE, race); }
uint32 GetRaceMask() const { return 1 << (GetRace() - 1); }
uint8 GetClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS); }
- void SetClass(uint8 unitClass) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, unitClass); }
+ void SetClass(uint8 classId) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, classId); }
uint32 GetClassMask() const { return 1 << (GetClass() - 1); }
- uint8 GetGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER); }
- void SetGender(uint8 gender) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender); }
- virtual uint8 GetNativeGender() const { return GetGender(); }
- virtual void SetNativeGender(uint8 gender) { SetGender(gender); }
+ Gender GetGender() const { return Gender(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER)); }
+ void SetGender(Gender gender) { SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender); }
+ virtual Gender GetNativeGender() const { return GetGender(); }
+ virtual void SetNativeGender(Gender gender) { SetGender(gender); }
float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); }
void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); }
uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL); }
void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
- uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); }
- uint32 GetResistance(SpellSchoolMask mask) const;
- void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school, val); }
+ int32 GetResistance(SpellSchools school) const { return GetInt32Value(UNIT_FIELD_RESISTANCES + school); }
+ int32 GetResistance(SpellSchoolMask mask) const;
+ void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES + school, val); }
static float CalculateAverageResistReduction(WorldObject const* caster, SpellSchoolMask schoolMask, Unit const* victim, SpellInfo const* spellInfo = nullptr);
uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); }
@@ -924,6 +932,8 @@ class TC_GAME_API Unit : public WorldObject
void UpdateDisplayPower();
uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); }
uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); }
+ float GetPowerPct(Powers power) const { return GetMaxPower(power) ? 100.f * GetPower(power) / GetMaxPower(power) : 0.0f; }
+ int32 CountPctFromMaxPower(Powers power, int32 pct) const { return CalculatePct(GetMaxPower(power), pct); }
void SetPower(Powers power, uint32 val, bool withPowerUpdate = true);
void SetMaxPower(Powers power, uint32 val);
inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); }
@@ -935,6 +945,25 @@ class TC_GAME_API Unit : public WorldObject
void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply);
void ApplyCastTimePercentMod(float val, bool apply);
+ void SetModCastingSpeed(float castingSpeed) { SetFloatValue(UNIT_MOD_CAST_SPEED, castingSpeed); }
+
+ UnitFlags GetUnitFlags() const { return UnitFlags(GetUInt32Value(UNIT_FIELD_FLAGS)); }
+ bool HasUnitFlag(UnitFlags flags) const { return HasFlag(UNIT_FIELD_FLAGS, flags); }
+ void SetUnitFlag(UnitFlags flags) { SetFlag(UNIT_FIELD_FLAGS, flags); }
+ void RemoveUnitFlag(UnitFlags flags) { RemoveFlag(UNIT_FIELD_FLAGS, flags); }
+ void ReplaceAllUnitFlags(UnitFlags flags) { SetUInt32Value(UNIT_FIELD_FLAGS, flags); }
+
+ UnitFlags2 GetUnitFlags2() const { return UnitFlags2(GetUInt32Value(UNIT_FIELD_FLAGS_2)); }
+ bool HasUnitFlag2(UnitFlags2 flags) const { return HasFlag(UNIT_FIELD_FLAGS_2, flags); }
+ void SetUnitFlag2(UnitFlags2 flags) { SetFlag(UNIT_FIELD_FLAGS_2, flags); }
+ void RemoveUnitFlag2(UnitFlags2 flags) { RemoveFlag(UNIT_FIELD_FLAGS_2, flags); }
+ void ReplaceAllUnitFlags2(UnitFlags2 flags) { SetUInt32Value(UNIT_FIELD_FLAGS_2, flags); }
+
+ void SetCreatedBySpell(int32 spellId) { SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId); }
+
+ Emote GetEmoteState() const { return Emote(GetUInt32Value(UNIT_NPC_EMOTESTATE)); }
+ void SetEmoteState(Emote emote) { SetUInt32Value(UNIT_NPC_EMOTESTATE, emote); }
+
SheathState GetSheath() const { return SheathState(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHEATH_STATE)); }
virtual void SetSheath(SheathState sheathed) { SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHEATH_STATE, sheathed); }
@@ -946,27 +975,42 @@ class TC_GAME_API Unit : public WorldObject
bool IsInRaidWith(Unit const* unit) const;
void GetPartyMembers(std::list<Unit*> &units);
bool IsContestedGuard() const;
- bool IsInSanctuary() const { return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_SANCTUARY); }
- bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_PVP); }
- bool IsFFAPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP); }
+
+ UnitPVPStateFlags GetPvpFlags() const { return UnitPVPStateFlags(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG)); }
+ bool HasPvpFlag(UnitPVPStateFlags flags) const { return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, flags); }
+ void SetPvpFlag(UnitPVPStateFlags flags) { SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, flags); }
+ void RemovePvpFlag(UnitPVPStateFlags flags) { RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, flags); }
+ void ReplaceAllPvpFlags(UnitPVPStateFlags flags) { SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, flags); }
+
+ bool IsInSanctuary() const { return HasPvpFlag(UNIT_BYTE2_FLAG_SANCTUARY); }
+ bool IsPvP() const { return HasPvpFlag(UNIT_BYTE2_FLAG_PVP); }
+ bool IsFFAPvP() const { return HasPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP); }
virtual void SetPvP(bool state);
+ UnitPetFlag GetPetFlags() const { return UnitPetFlag(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS)); }
+ bool HasPetFlag(UnitPetFlag flags) const { return HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, flags); }
+ void SetPetFlag(UnitPetFlag flags) { SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, flags); }
+ void RemovePetFlag(UnitPetFlag flags) { RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, flags); }
+ void ReplaceAllPetFlags(UnitPetFlag flags) { SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, flags); }
+
uint32 GetCreatureType() const;
uint32 GetCreatureTypeMask() const;
- uint8 GetStandState() const { return GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE); }
+ UnitStandStateType GetStandState() const { return UnitStandStateType(GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE)); }
bool IsSitState() const;
bool IsStandState() const;
- void SetStandState(uint8 state);
+ void SetStandState(UnitStandStateType state);
- void SetAnimTier(AnimTier tier);
- AnimTier GetAnimTier() const { return static_cast<AnimTier>(GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER)); }
+ void SetVisFlag(UnitVisFlags flags) { SetByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); }
+ void RemoveVisFlag(UnitVisFlags flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); }
+ void ReplaceAllVisFlags(UnitVisFlags flags) { SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); }
- void SetStandFlags(uint8 flags) { SetByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); }
- void RemoveStandFlags(uint8 flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, flags); }
+ AnimTier GetAnimTier() const { return AnimTier(GetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER)); }
+ void SetAnimTier(AnimTier animTier);
- bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); }
- uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); }
+ bool IsMounted() const { return HasUnitFlag(UNIT_FLAG_MOUNT); }
+ uint32 GetMountDisplayId() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); }
+ void SetMountDisplayId(uint32 mountDisplayId) { SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mountDisplayId); }
void Mount(uint32 mount, uint32 vehicleId = 0, uint32 creatureEntry = 0);
void Dismount();
@@ -1001,7 +1045,7 @@ class TC_GAME_API Unit : public WorldObject
ObjectGuid GetLastDamagedTargetGuid() const { return _lastDamagedTargetGuid; }
void CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = BASE_ATTACK, bool crit = false, Spell* spell = nullptr);
- void DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss);
+ void DealSpellDamage(SpellNonMeleeDamage const* damageInfo, bool durabilityLoss);
// player or player's pet resilience (-1%)
float GetMeleeCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_MELEE); }
@@ -1040,27 +1084,34 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetShieldBlockValue(uint32 soft_cap, uint32 hard_cap) const;
uint32 GetDefenseSkillValue(Unit const* target = nullptr) const;
uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = nullptr) const;
+
float GetWeaponProcChance() const;
float GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spellProto) const;
MeleeHitOutcome RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackType attType) const;
- bool IsVendor() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_VENDOR); }
- bool IsTrainer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER); }
- bool IsQuestGiver() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); }
- bool IsGossip() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); }
- bool IsTaxi() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER); }
- bool IsGuildMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PETITIONER); }
- bool IsBattleMaster() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEMASTER); }
- bool IsBanker() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER); }
- bool IsInnkeeper() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER); }
- bool IsSpiritHealer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER); }
- bool IsSpiritGuide() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITGUIDE); }
- bool IsTabardDesigner()const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TABARDDESIGNER); }
- bool IsAuctioner() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_AUCTIONEER); }
- bool IsArmorer() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_REPAIR); }
+ NPCFlags GetNpcFlags() const { return NPCFlags(GetUInt32Value(UNIT_NPC_FLAGS)); }
+ bool HasNpcFlag(NPCFlags flags) const { return HasFlag(UNIT_NPC_FLAGS, flags) != 0; }
+ void SetNpcFlag(NPCFlags flags) { SetFlag(UNIT_NPC_FLAGS, flags); }
+ void RemoveNpcFlag(NPCFlags flags) { RemoveFlag(UNIT_NPC_FLAGS, flags); }
+ void ReplaceAllNpcFlags(NPCFlags flags) { SetUInt32Value(UNIT_NPC_FLAGS, flags); }
+
+ bool IsVendor() const { return HasNpcFlag(UNIT_NPC_FLAG_VENDOR); }
+ bool IsTrainer() const { return HasNpcFlag(UNIT_NPC_FLAG_TRAINER); }
+ bool IsQuestGiver() const { return HasNpcFlag(UNIT_NPC_FLAG_QUESTGIVER); }
+ bool IsGossip() const { return HasNpcFlag(UNIT_NPC_FLAG_GOSSIP); }
+ bool IsTaxi() const { return HasNpcFlag(UNIT_NPC_FLAG_FLIGHTMASTER); }
+ bool IsGuildMaster() const { return HasNpcFlag(UNIT_NPC_FLAG_PETITIONER); }
+ bool IsBattleMaster() const { return HasNpcFlag(UNIT_NPC_FLAG_BATTLEMASTER); }
+ bool IsBanker() const { return HasNpcFlag(UNIT_NPC_FLAG_BANKER); }
+ bool IsInnkeeper() const { return HasNpcFlag(UNIT_NPC_FLAG_INNKEEPER); }
+ bool IsSpiritHealer() const { return HasNpcFlag(UNIT_NPC_FLAG_SPIRITHEALER); }
+ bool IsSpiritGuide() const { return HasNpcFlag(UNIT_NPC_FLAG_SPIRITGUIDE); }
+ bool IsTabardDesigner() const { return HasNpcFlag(UNIT_NPC_FLAG_TABARDDESIGNER); }
+ bool IsAuctioner() const { return HasNpcFlag(UNIT_NPC_FLAG_AUCTIONEER); }
+ bool IsArmorer() const { return HasNpcFlag(UNIT_NPC_FLAG_REPAIR); }
bool IsServiceProvider() const;
- bool IsSpiritService() const { return HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); }
+ bool IsSpiritService() const { return HasNpcFlag(UNIT_NPC_FLAG_SPIRITHEALER | UNIT_NPC_FLAG_SPIRITGUIDE); }
bool IsCritter() const { return GetCreatureType() == CREATURE_TYPE_CRITTER; }
bool IsInFlight() const { return HasUnitState(UNIT_STATE_IN_FLIGHT); }
@@ -1081,14 +1132,14 @@ class TC_GAME_API Unit : public WorldObject
bool IsImmuneToAll() const { return IsImmuneToPC() && IsImmuneToNPC(); }
void SetImmuneToAll(bool apply, bool keepCombat);
virtual void SetImmuneToAll(bool apply) { SetImmuneToAll(apply, false); }
- bool IsImmuneToPC() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); }
+ bool IsImmuneToPC() const { return HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); }
void SetImmuneToPC(bool apply, bool keepCombat);
virtual void SetImmuneToPC(bool apply) { SetImmuneToPC(apply, false); }
- bool IsImmuneToNPC() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); }
+ bool IsImmuneToNPC() const { return HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC); }
void SetImmuneToNPC(bool apply, bool keepCombat);
virtual void SetImmuneToNPC(bool apply) { SetImmuneToNPC(apply, false); }
- bool IsInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); }
+ bool IsInCombat() const { return HasUnitFlag(UNIT_FLAG_IN_COMBAT); }
bool IsInCombatWith(Unit const* who) const { return who && m_combatManager.IsInCombatWith(who); }
void SetInCombatWith(Unit* enemy) { if (enemy) m_combatManager.SetInCombatWith(enemy); }
void ClearInCombat() { m_combatManager.EndAllCombat(); }
@@ -1104,7 +1155,7 @@ class TC_GAME_API Unit : public WorldObject
void SendClearTarget();
- bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const;
+ bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, flag96 familyFlags) const;
bool virtual HasSpell(uint32 /*spellID*/) const { return false; }
bool HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura = 0) const;
bool HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel = nullptr) const;
@@ -1138,7 +1189,7 @@ class TC_GAME_API Unit : public WorldObject
void SendAttackStateUpdate(CalcDamageInfo* damageInfo);
void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount);
- void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log);
+ void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage const* log);
void SendSpellNonMeleeDamageLog(Unit* target, uint32 spellID, uint32 damage, SpellSchoolMask damageSchoolMask, uint32 absorbedDamage, uint32 resist, bool isPeriodic, uint32 blocked, bool criticalHit = false, bool split = false);
void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo);
void SendSpellDamageResist(Unit* target, uint32 spellId);
@@ -1158,10 +1209,10 @@ class TC_GAME_API Unit : public WorldObject
void JumpTo(WorldObject* obj, float speedZ, bool withOrientation = false);
void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false);
- //void SetFacing(float ori, WorldObject* obj = nullptr);
- //void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = nullptr);
void SendMovementFlagUpdate(bool self = false);
+ void SetHoverHeight(float hoverHeight) { SetFloatValue(UNIT_FIELD_HOVERHEIGHT, hoverHeight); }
+
bool IsGravityDisabled() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); }
bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); }
bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); }
@@ -1192,10 +1243,10 @@ class TC_GAME_API Unit : public WorldObject
void SetCreatorGUID(ObjectGuid creator) { SetGuidValue(UNIT_FIELD_CREATEDBY, creator); }
ObjectGuid GetMinionGUID() const { return GetGuidValue(UNIT_FIELD_SUMMON); }
void SetMinionGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_SUMMON, guid); }
- void SetPetGUID(ObjectGuid guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
ObjectGuid GetPetGUID() const { return m_SummonSlot[SUMMON_SLOT_PET]; }
- void SetCritterGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CRITTER, guid); }
+ void SetPetGUID(ObjectGuid guid) { m_SummonSlot[SUMMON_SLOT_PET] = guid; }
ObjectGuid GetCritterGUID() const { return GetGuidValue(UNIT_FIELD_CRITTER); }
+ void SetCritterGUID(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CRITTER, guid); }
ObjectGuid GetCharmerGUID() const { return GetGuidValue(UNIT_FIELD_CHARMEDBY); }
Unit* GetCharmer() const { return m_charmer; }
@@ -1235,6 +1286,8 @@ class TC_GAME_API Unit : public WorldObject
CharmInfo* GetCharmInfo() { return m_charmInfo; }
CharmInfo* InitCharmInfo();
void DeleteCharmInfo();
+ void SetPetNumberForClient(uint32 petNumber) { SetUInt32Value(UNIT_FIELD_PETNUMBER, petNumber); }
+ void SetPetNameTimestamp(uint32 timestamp) { SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, timestamp); }
// base client control of this unit (possess effects, vehicles and similar). Not affected by temporary CC.
bool IsCharmerOrSelfPlayer() const { return GetCharmerOrSelf()->IsPlayer(); }
@@ -1328,6 +1381,7 @@ class TC_GAME_API Unit : public WorldObject
void _ApplyAllAuraStatMods();
AuraEffectList const& GetAuraEffectsByType(AuraType type) const { return m_modAuras[type]; }
+ AuraEffectList& GetAuraEffectsByType(AuraType type) { return m_modAuras[type]; }
AuraList & GetSingleCastAuras() { return m_scAuras; }
AuraList const& GetSingleCastAuras() const { return m_scAuras; }
@@ -1400,6 +1454,8 @@ class TC_GAME_API Unit : public WorldObject
float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); }
float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
+ uint32 GetChannelSpellId() const { return GetUInt32Value(UNIT_CHANNEL_SPELL); }
+ void SetChannelSpellId(uint32 channelSpellId) { SetUInt32Value(UNIT_CHANNEL_SPELL, channelSpellId); }
ObjectGuid GetChannelObjectGuid() const { return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); }
void SetChannelObjectGuid(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, guid); }
@@ -1424,8 +1480,8 @@ class TC_GAME_API Unit : public WorldObject
virtual bool HasSpellFocus(Spell const* /*focusSpell*/ = nullptr) const { return false; }
virtual bool IsMovementPreventedByCasting() const;
- SpellHistory* GetSpellHistory() { return m_spellHistory; }
- SpellHistory const* GetSpellHistory() const { return m_spellHistory; }
+ SpellHistory* GetSpellHistory() { return _spellHistory; }
+ SpellHistory const* GetSpellHistory() const { return _spellHistory; }
ObjectGuid m_SummonSlot[MAX_SUMMON_SLOT];
ObjectGuid m_ObjectSlot[MAX_GAMEOBJECT_SLOT];
@@ -1443,6 +1499,7 @@ class TC_GAME_API Unit : public WorldObject
int32 m_baseSpellCritChance;
float m_modAttackSpeedPct[MAX_ATTACK];
+ uint32 m_attackTimer[MAX_ATTACK];
// stat system
void HandleStatFlatModifier(UnitMods unitMod, UnitModifierFlatType modifierType, float amount, bool apply);
@@ -1480,6 +1537,14 @@ class TC_GAME_API Unit : public WorldObject
virtual void UpdateMaxHealth() = 0;
virtual void UpdateMaxPower(Powers power) = 0;
virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0;
+ void SetAttackPower(int32 attackPower) { SetInt32Value(UNIT_FIELD_ATTACK_POWER, attackPower); }
+ void SetAttackPowerModPos(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_ATTACK_POWER_MODS, 0, attackPowerMod); }
+ void SetAttackPowerModNeg(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_ATTACK_POWER_MODS, 1, attackPowerMod); }
+ void SetAttackPowerMultiplier(float attackPowerMult) { SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, attackPowerMult); }
+ void SetRangedAttackPower(int32 attackPower) { SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, attackPower); }
+ void SetRangedAttackPowerModPos(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 0, attackPowerMod); }
+ void SetRangedAttackPowerModNeg(int32 attackPowerMod) { SetInt16Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 1, attackPowerMod); }
+ void SetRangedAttackPowerMultiplier(float attackPowerMult) { SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER, attackPowerMult); }
virtual void UpdateDamagePhysical(WeaponAttackType attType);
float GetTotalAttackPowerValue(WeaponAttackType attType) const;
float GetWeaponDamageRange(WeaponAttackType attType, WeaponDamageRange type, uint8 damageIndex = 0) const;
@@ -1502,13 +1567,13 @@ class TC_GAME_API Unit : public WorldObject
SpellImmuneContainer m_spellImmune[MAX_SPELL_IMMUNITY];
uint32 m_lastSanctuaryTime;
- VisibleAuraMap const* GetVisibleAuras() { return &m_visibleAuras; }
- AuraApplication * GetVisibleAura(uint8 slot) const;
- void SetVisibleAura(uint8 slot, AuraApplication * aur);
+ VisibleAuraMap const& GetVisibleAuras() const { return m_visibleAuras; }
+ AuraApplication* GetVisibleAura(uint8 slot) const;
+ void SetVisibleAura(uint8 slot, AuraApplication* aurApp);
void RemoveVisibleAura(uint8 slot);
- uint32 GetInterruptMask() const { return m_interruptMask; }
- void AddInterruptMask(uint32 mask) { m_interruptMask |= mask; }
+ bool HasInterruptFlag(uint32 flags) const { return (m_interruptMask & flags) != 0; }
+ void AddInterruptMask(uint32 flags) { m_interruptMask |= flags; }
void UpdateInterruptMask();
virtual float GetNativeObjectScale() const { return 1.0f; }
@@ -1517,25 +1582,27 @@ class TC_GAME_API Unit : public WorldObject
virtual void SetDisplayId(uint32 modelId);
uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
void RestoreDisplayId();
- void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); }
+ void SetNativeDisplayId(uint32 displayId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, displayId); }
void SetTransformSpell(uint32 spellid) { m_transformSpell = spellid;}
uint32 GetTransformSpell() const { return m_transformSpell;}
// DynamicObject management
void _RegisterDynObject(DynamicObject* dynObj);
void _UnregisterDynObject(DynamicObject* dynObj);
- DynamicObject* GetDynObject(uint32 spellId);
+ DynamicObject* GetDynObject(uint32 spellId) const;
+ std::vector<DynamicObject*> GetDynObjects(uint32 spellId) const;
void RemoveDynObject(uint32 spellId);
void RemoveAllDynObjects();
GameObject* GetGameObject(uint32 spellId) const;
+ std::vector<GameObject*> GetGameObjects(uint32 spellId) const;
void AddGameObject(GameObject* gameObj);
void RemoveGameObject(GameObject* gameObj, bool del);
void RemoveGameObject(uint32 spellid, bool del);
void RemoveAllGameObjects();
void ModifyAuraState(AuraStateType flag, bool apply);
- uint32 BuildAuraStateUpdateForTarget(Unit* target) const;
+ uint32 BuildAuraStateUpdateForTarget(Unit const* target) const;
bool HasAuraState(AuraStateType flag, SpellInfo const* spellProto = nullptr, Unit const* Caster = nullptr) const;
void UnsummonAllTotems();
bool IsMagnet() const;
@@ -1606,17 +1673,19 @@ class TC_GAME_API Unit : public WorldObject
void PauseMovement(uint32 timer = 0, uint8 slot = 0, bool forced = true); // timer in ms
void ResumeMovement(uint32 timer = 0, uint8 slot = 0); // timer in ms
- void AddUnitMovementFlag(uint32 f) { m_movementInfo.flags |= f; }
- void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.flags &= ~f; }
- bool HasUnitMovementFlag(uint32 f) const { return (m_movementInfo.flags & f) == f; }
- uint32 GetUnitMovementFlags() const { return m_movementInfo.flags; }
- void SetUnitMovementFlags(uint32 f) { m_movementInfo.flags = f; }
+ void AddUnitMovementFlag(uint32 f) { m_movementInfo.AddMovementFlag(f); }
+ void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.RemoveMovementFlag(f); }
+ bool HasUnitMovementFlag(uint32 f) const { return m_movementInfo.HasMovementFlag(f); }
+ uint32 GetUnitMovementFlags() const { return m_movementInfo.GetMovementFlags(); }
+ void SetUnitMovementFlags(uint32 f) { m_movementInfo.SetMovementFlags(f); }
+
+ void AddExtraUnitMovementFlag(uint32 f) { m_movementInfo.AddExtraMovementFlag(f); }
+ void RemoveExtraUnitMovementFlag(uint32 f) { m_movementInfo.RemoveExtraMovementFlag(f); }
+ bool HasExtraUnitMovementFlag(uint32 f) const { return m_movementInfo.HasExtraMovementFlag(f); }
+ uint32 GetExtraUnitMovementFlags() const { return m_movementInfo.GetExtraMovementFlags(); }
+ void SetExtraUnitMovementFlags(uint32 f) { m_movementInfo.SetExtraMovementFlags(f); }
- void AddExtraUnitMovementFlag(uint16 f) { m_movementInfo.flags2 |= f; }
- void RemoveExtraUnitMovementFlag(uint16 f) { m_movementInfo.flags2 &= ~f; }
- uint16 HasExtraUnitMovementFlag(uint16 f) const { return m_movementInfo.flags2 & f; }
- uint16 GetExtraUnitMovementFlags() const { return m_movementInfo.flags2; }
- void SetExtraUnitMovementFlags(uint16 f) { m_movementInfo.flags2 = f; }
+ bool IsSplineEnabled() const;
void SetControlled(bool apply, UnitState state);
void ApplyControlStatesIfNeeded();
@@ -1637,8 +1706,8 @@ class TC_GAME_API Unit : public WorldObject
void ClearComboPointHolders();
///----------Pet responses methods-----------------
- void SendPetActionFeedback (uint8 msg);
- void SendPetTalk (uint32 pettalk);
+ void SendPetActionFeedback(uint8 msg);
+ void SendPetTalk(uint32 pettalk);
void SendPetAIReaction(ObjectGuid guid);
///----------End of Pet responses methods----------
@@ -1748,6 +1817,8 @@ class TC_GAME_API Unit : public WorldObject
virtual void Whisper(uint32 textId, Player* target, bool isBossWhisper = false);
float GetCollisionHeight() const override;
+ uint32 GetVirtualItemId(uint32 slot) const;
+ void SetVirtualItem(uint32 slot, uint32 itemId);
// returns if the unit can't enter combat
bool IsCombatDisallowed() const { return _isCombatDisallowed; }
@@ -1755,6 +1826,7 @@ class TC_GAME_API Unit : public WorldObject
void SetIsCombatDisallowed(bool apply) { _isCombatDisallowed = apply; }
std::string GetDebugInfo() const override;
+
protected:
explicit Unit (bool isWorldObject);
@@ -1769,8 +1841,6 @@ class TC_GAME_API Unit : public WorldObject
bool m_AutoRepeatFirstCast;
- uint32 m_attackTimer[MAX_ATTACK];
-
float m_createStats[MAX_STATS];
AttackerSet m_attackers;
@@ -1806,6 +1876,7 @@ class TC_GAME_API Unit : public WorldObject
float m_auraPctModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_PCT_END];
float m_weaponDamage[MAX_ATTACK][2][2];
bool m_canModifyStats;
+
VisibleAuraMap m_visibleAuras;
float m_speed_rate[MAX_MOVE_TYPE];
@@ -1856,7 +1927,6 @@ class TC_GAME_API Unit : public WorldObject
void ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMask, uint32 hitMask, WeaponAttackType attType);
protected:
-
void SetFeared(bool apply);
void SetConfused(bool apply);
void SetStunned(bool apply);
@@ -1870,7 +1940,7 @@ class TC_GAME_API Unit : public WorldObject
uint32 m_lastManaUse; // msecs
TimeTracker m_splineSyncTimer;
- DiminishingReturn m_Diminishing[DIMINISHING_MAX];
+ Diminishing m_Diminishing;
// Threat+combat management
friend class CombatManager;
@@ -1902,7 +1972,8 @@ class TC_GAME_API Unit : public WorldObject
uint32 _oldFactionId; ///< faction before charm
bool _isWalkingBeforeCharm; ///< Are we walking before we were charmed?
- SpellHistory* m_spellHistory;
+ SpellHistory* _spellHistory;
+
PositionUpdateInfo _positionUpdateInfo;
bool _isCombatDisallowed;
@@ -1928,15 +1999,15 @@ namespace Trinity
{
Unit const* a = objA->ToUnit();
Unit const* b = objB->ToUnit();
- float rA = (a && a->GetMaxPower(_power)) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
- float rB = (b && b->GetMaxPower(_power)) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
+ float rA = a ? a->GetPowerPct(_power) : 0.0f;
+ float rB = b ? b->GetPowerPct(_power) : 0.0f;
return _ascending ? rA < rB : rA > rB;
}
bool operator()(Unit const* a, Unit const* b) const
{
- float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f;
- float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f;
+ float rA = a->GetPowerPct(_power);
+ float rB = b->GetPowerPct(_power);
return _ascending ? rA < rB : rA > rB;
}
diff --git a/src/server/game/Entities/Unit/UnitDefines.h b/src/server/game/Entities/Unit/UnitDefines.h
index 269798d99bb..b95c0d4c1ac 100644
--- a/src/server/game/Entities/Unit/UnitDefines.h
+++ b/src/server/game/Entities/Unit/UnitDefines.h
@@ -19,6 +19,7 @@
#define UnitDefines_h__
#include "Define.h"
+#include "EnumFlag.h"
#include <string>
#define BASE_MINDAMAGE 1.0f
@@ -43,14 +44,14 @@ enum UnitStandStateType : uint8
};
// byte flag value (UNIT_FIELD_BYTES_1, 2)
-enum UnitStandFlags : uint8
+enum UnitVisFlags : uint8
{
- UNIT_STAND_FLAGS_UNK1 = 0x01,
- UNIT_STAND_FLAGS_CREEP = 0x02,
- UNIT_STAND_FLAGS_UNTRACKABLE = 0x04,
- UNIT_STAND_FLAGS_UNK4 = 0x08,
- UNIT_STAND_FLAGS_UNK5 = 0x10,
- UNIT_STAND_FLAGS_ALL = 0xFF
+ UNIT_VIS_FLAGS_UNK1 = 0x01,
+ UNIT_VIS_FLAGS_CREEP = 0x02,
+ UNIT_VIS_FLAGS_UNTRACKABLE = 0x04,
+ UNIT_VIS_FLAGS_UNK4 = 0x08,
+ UNIT_VIS_FLAGS_UNK5 = 0x10,
+ UNIT_VIS_FLAGS_ALL = 0xFF
};
enum UnitBytes0Offsets : uint8
@@ -100,6 +101,7 @@ enum SheathState : uint8
// byte (1 from 0..3) of UNIT_FIELD_BYTES_2
enum UnitPVPStateFlags : uint8
{
+ UNIT_BYTE2_FLAG_NONE = 0x00,
UNIT_BYTE2_FLAG_PVP = 0x01,
UNIT_BYTE2_FLAG_UNK1 = 0x02,
UNIT_BYTE2_FLAG_FFA_PVP = 0x04,
@@ -110,13 +112,18 @@ enum UnitPVPStateFlags : uint8
UNIT_BYTE2_FLAG_UNK7 = 0x80
};
+DEFINE_ENUM_FLAG(UnitPVPStateFlags);
+
// byte (2 from 0..3) of UNIT_FIELD_BYTES_2
-enum UnitRename : uint8
+enum UnitPetFlag : uint8
{
- UNIT_CAN_BE_RENAMED = 0x01,
- UNIT_CAN_BE_ABANDONED = 0x02
+ UNIT_PET_FLAG_NONE = 0x0,
+ UNIT_PET_FLAG_CAN_BE_RENAMED = 0x01,
+ UNIT_PET_FLAG_CAN_BE_ABANDONED = 0x02
};
+DEFINE_ENUM_FLAG(UnitPetFlag);
+
// Value masks for UNIT_FIELD_FLAGS
// EnumUtils: DESCRIBE THIS
enum UnitFlags : uint32
@@ -165,6 +172,8 @@ enum UnitFlags : uint32
UNIT_FLAG_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG_DISALLOWED)
};
+DEFINE_ENUM_FLAG(UnitFlags);
+
// Value masks for UNIT_FIELD_FLAGS_2
enum UnitFlags2 : uint32
{
@@ -214,6 +223,8 @@ enum UnitFlags2 : uint32
UNIT_FLAG2_ALLOWED = (0xFFFFFFFF & ~UNIT_FLAG2_DISALLOWED)
};
+DEFINE_ENUM_FLAG(UnitFlags2);
+
/// Non Player Character flags
// EnumUtils: DESCRIBE THIS
enum NPCFlags : uint32
@@ -248,6 +259,8 @@ enum NPCFlags : uint32
UNIT_NPC_FLAG_MAILBOX = 0x04000000 // TITLE is mailbox
};
+DEFINE_ENUM_FLAG(NPCFlags);
+
enum MovementFlags : uint32
{
MOVEMENTFLAG_NONE = 0x00000000,
diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp
index 9f8f757e7f2..b2a81e4a12c 100755
--- a/src/server/game/Entities/Vehicle/Vehicle.cpp
+++ b/src/server/game/Entities/Vehicle/Vehicle.cpp
@@ -50,9 +50,9 @@ UsableSeatNum(0), _me(unit), _vehicleInfo(vehInfo), _creatureEntry(creatureEntry
// Set or remove correct flags based on available seats. Will overwrite db data (if wrong).
if (UsableSeatNum)
- _me->SetFlag(UNIT_NPC_FLAGS, (_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
+ _me->SetNpcFlag((_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
else
- _me->RemoveFlag(UNIT_NPC_FLAGS, (_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
+ _me->RemoveNpcFlag((_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
InitMovementInfoForBase();
}
@@ -506,11 +506,11 @@ Vehicle* Vehicle::RemovePassenger(Unit* unit)
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->ID, _me->GetGUID().ToString().c_str(), (int32)seat->first);
if (seat->second.SeatInfo->CanEnterOrExit() && ++UsableSeatNum)
- _me->SetFlag(UNIT_NPC_FLAGS, (_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
+ _me->SetNpcFlag((_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
// Remove UNIT_FLAG_UNINTERACTIBLE if passenger did not have it before entering vehicle
if (seat->second.SeatInfo->Flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE && !seat->second.Passenger.IsUninteractible)
- unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ unit->RemoveUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
seat->second.Passenger.Reset();
@@ -819,7 +819,7 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
Passenger->SetVehicle(Target);
Seat->second.Passenger.Guid = Passenger->GetGUID();
- Seat->second.Passenger.IsUninteractible = Passenger->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ Seat->second.Passenger.IsUninteractible = Passenger->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
if (Seat->second.SeatInfo->CanEnterOrExit())
{
ASSERT(Target->UsableSeatNum);
@@ -827,9 +827,9 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
if (!Target->UsableSeatNum)
{
if (Target->GetBase()->GetTypeId() == TYPEID_PLAYER)
- Target->GetBase()->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE);
+ Target->GetBase()->RemoveNpcFlag(UNIT_NPC_FLAG_PLAYER_VEHICLE);
else
- Target->GetBase()->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
+ Target->GetBase()->RemoveNpcFlag(UNIT_NPC_FLAG_SPELLCLICK);
}
}
@@ -854,7 +854,7 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
}
if (veSeat->HasFlag(VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE))
- Passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE);
+ Passenger->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
float o = veSeatAddon ? veSeatAddon->SeatOrientationOffset : 0.f;
float x = veSeat->AttachmentOffset.X;
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index 88a47de0c40..db842a39461 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -1221,7 +1221,7 @@ void GameEventMgr::UpdateEventNPCFlags(uint16 event_id)
if (CreatureTemplate const* creatureTemplate = creature->GetCreatureTemplate())
npcflag |= creatureTemplate->npcflag;
- creature->SetUInt32Value(UNIT_NPC_FLAGS, npcflag);
+ creature->ReplaceAllNpcFlags(NPCFlags(npcflag));
// reset gossip options, since the flag change might have added / removed some
//cr->ResetGossipOptions();
}
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 5fa661038fc..f6e51d9aeb7 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -883,7 +883,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder const& holder)
// Set FFA PvP for non GM in non-rest mode
if (sWorld->IsFFAPvPRealm() && !pCurrChar->IsGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
- pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ pCurrChar->SetPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
pCurrChar->SetContestedPvP();
@@ -1333,7 +1333,7 @@ void WorldSession::HandleAlterAppearance(WorldPacket& recvData)
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);
- _player->SetStandState(0); // stand up
+ _player->SetStandState(UNIT_STAND_STATE_STAND);
}
void WorldSession::HandleRemoveGlyph(WorldPacket& recvData)
diff --git a/src/server/game/Handlers/LootHandler.cpp b/src/server/game/Handlers/LootHandler.cpp
index b711826f51e..05b25c334b2 100644
--- a/src/server/game/Handlers/LootHandler.cpp
+++ b/src/server/game/Handlers/LootHandler.cpp
@@ -258,7 +258,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
player->SetLootGUID(ObjectGuid::Empty);
player->SendLootRelease(lguid);
- player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
+ player->RemoveUnitFlag(UNIT_FLAG_LOOTING);
if (!player->IsInWorld())
return;
@@ -358,7 +358,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
loot = &creature->loot;
if (loot->isLooted())
{
- creature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ creature->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
// skip pickpocketing loot for speed, skinning timer reduction is no-op in fact
if (!creature->IsAlive())
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index f549f75b49f..ec577cf5f77 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -394,7 +394,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPackets::Character::LogoutRequ
if (GetPlayer()->GetStandState() == UNIT_STAND_STATE_STAND)
GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT);
GetPlayer()->SetRooted(true);
- GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ GetPlayer()->SetUnitFlag(UNIT_FLAG_STUNNED);
}
SetLogoutStartTime(GameTime::GetGameTime());
@@ -424,7 +424,7 @@ void WorldSession::HandleLogoutCancelOpcode(WorldPackets::Character::LogoutCance
GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND);
//! DISABLE_ROTATE
- GetPlayer()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
+ GetPlayer()->RemoveUnitFlag(UNIT_FLAG_STUNNED);
}
}
@@ -491,7 +491,7 @@ void WorldSession::HandleStandStateChangeOpcode(WorldPacket& recvData)
return;
}
- _player->SetStandState(animstate);
+ _player->SetStandState(UnitStandStateType(animstate));
}
void WorldSession::HandleBugOpcode(WorldPacket& recvData)
@@ -635,7 +635,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
player->SetRestFlag(REST_FLAG_IN_TAVERN, atEntry->ID);
if (sWorld->IsFFAPvPRealm())
- player->RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP);
+ player->RemovePvpFlag(UNIT_BYTE2_FLAG_FFA_PVP);
return;
}
diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp
index 95409b0a88d..a068faff376 100644
--- a/src/server/game/Handlers/PetHandler.cpp
+++ b/src/server/game/Handlers/PetHandler.cpp
@@ -598,7 +598,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
PetStable* petStable = _player->GetPetStable();
Pet* pet = ObjectAccessor::GetPet(*_player, petguid);
- if (!pet || !pet->IsPet() || ((Pet*)pet)->getPetType() != HUNTER_PET || !pet->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED) ||
+ if (!pet || !pet->IsPet() || ((Pet*)pet)->getPetType() != HUNTER_PET || !pet->HasPetFlag(UNIT_PET_FLAG_CAN_BE_RENAMED) ||
pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() ||
!petStable || !petStable->CurrentPet || petStable->CurrentPet->PetNumber != pet->GetCharmInfo()->GetPetNumber())
return;
@@ -621,7 +621,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
if (pet->GetOwner()->GetGroup())
pet->GetOwner()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
- pet->RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED);
+ pet->RemovePetFlag(UNIT_PET_FLAG_CAN_BE_RENAMED);
petStable->CurrentPet->Name = name;
petStable->CurrentPet->WasRenamed = true;
@@ -669,7 +669,7 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
CharacterDatabase.CommitTransaction(trans);
- pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(GameTime::GetGameTime())); // cast can't be helped
+ pet->SetPetNameTimestamp(uint32(GameTime::GetGameTime())); // cast can't be helped
}
void WorldSession::HandlePetAbandon(WorldPackets::Pet::PetAbandon& packet)
@@ -901,7 +901,7 @@ void WorldSession::HandleRequestPetInfo(WorldPackets::Pet::RequestPetInfo& /*pac
if (charm->HasUnitState(UNIT_STATE_POSSESSED))
_player->PossessSpellInitialize();
// Packet sent when player controlling a vehicle
- else if (charm->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && charm->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED))
+ else if (charm->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && charm->HasUnitFlag(UNIT_FLAG_POSSESSED))
_player->VehicleSpellInitialize();
// Packet sent when player has a charmed unit
else
diff --git a/src/server/game/Handlers/TaxiHandler.cpp b/src/server/game/Handlers/TaxiHandler.cpp
index a2793fa2e98..1c6cdf1ce89 100644
--- a/src/server/game/Handlers/TaxiHandler.cpp
+++ b/src/server/game/Handlers/TaxiHandler.cpp
@@ -43,7 +43,7 @@ void WorldSession::SendTaxiStatus(ObjectGuid guid)
{
Player* const player = GetPlayer();
Creature* unit = ObjectAccessor::GetCreature(*player, guid);
- if (!unit || unit->IsHostileTo(player) || !unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_FLIGHTMASTER))
+ if (!unit || unit->IsHostileTo(player) || !unit->HasNpcFlag(UNIT_NPC_FLAG_FLIGHTMASTER))
{
TC_LOG_DEBUG("network", "WorldSession::SendTaxiStatus - %s not found or you can't interact with him.", guid.ToString().c_str());
return;
diff --git a/src/server/game/Maps/MapScripts.cpp b/src/server/game/Maps/MapScripts.cpp
index 63c4113348e..76743e9ba33 100644
--- a/src/server/game/Maps/MapScripts.cpp
+++ b/src/server/game/Maps/MapScripts.cpp
@@ -448,7 +448,7 @@ void Map::ScriptsProcess()
if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
{
if (step.script->Emote.Flags & SF_EMOTE_USE_STATE)
- cSource->SetUInt32Value(UNIT_NPC_EMOTESTATE, step.script->Emote.EmoteID);
+ cSource->SetEmoteState(Emote(step.script->Emote.EmoteID));
else
cSource->HandleEmoteCommand(static_cast<Emote>(step.script->Emote.EmoteID));
}
diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
index 983591d6718..77331379a75 100755
--- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp
@@ -49,7 +49,7 @@ void ConfusedMovementGenerator<T>::DoInitialize(T* owner)
return;
// TODO: UNIT_FIELD_FLAGS should not be handled by generators
- owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
+ owner->SetUnitFlag(UNIT_FLAG_CONFUSED);
owner->StopMoving();
_timer.Reset(0);
@@ -144,7 +144,7 @@ void ConfusedMovementGenerator<Player>::DoFinalize(Player* owner, bool active, b
if (active)
{
- owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
+ owner->RemoveUnitFlag(UNIT_FLAG_CONFUSED);
owner->StopMoving();
}
}
@@ -156,7 +156,7 @@ void ConfusedMovementGenerator<Creature>::DoFinalize(Creature* owner, bool activ
if (active)
{
- owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
+ owner->RemoveUnitFlag(UNIT_FLAG_CONFUSED);
owner->ClearUnitState(UNIT_STATE_CONFUSED_MOVE);
if (owner->GetVictim())
owner->SetTarget(owner->EnsureVictim()->GetGUID());
diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
index cf724b38f88..66d596e3c12 100644
--- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
@@ -54,7 +54,7 @@ void FleeingMovementGenerator<T>::DoInitialize(T* owner)
return;
// TODO: UNIT_FIELD_FLAGS should not be handled by generators
- owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
+ owner->SetUnitFlag(UNIT_FLAG_FLEEING);
_path = nullptr;
SetTargetLocation(owner);
@@ -113,7 +113,7 @@ void FleeingMovementGenerator<Player>::DoFinalize(Player* owner, bool active, bo
if (active)
{
- owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
+ owner->RemoveUnitFlag(UNIT_FLAG_FLEEING);
owner->ClearUnitState(UNIT_STATE_FLEEING_MOVE);
owner->StopMoving();
}
@@ -126,7 +126,7 @@ void FleeingMovementGenerator<Creature>::DoFinalize(Creature* owner, bool active
if (active)
{
- owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
+ owner->RemoveUnitFlag(UNIT_FLAG_FLEEING);
owner->ClearUnitState(UNIT_STATE_FLEEING_MOVE);
if (owner->GetVictim())
owner->SetTarget(owner->EnsureVictim()->GetGUID());
@@ -256,7 +256,7 @@ void TimedFleeingMovementGenerator::Finalize(Unit* owner, bool active, bool move
if (!active)
return;
- owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
+ owner->RemoveUnitFlag(UNIT_FLAG_FLEEING);
owner->StopMoving();
if (Unit* victim = owner->GetVictim())
{
diff --git a/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp
index 88237cfc6a7..9c8dd63af2d 100644
--- a/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/FlightPathMovementGenerator.cpp
@@ -72,7 +72,7 @@ void FlightPathMovementGenerator::DoReset(Player* owner)
RemoveFlag(MOVEMENTGENERATOR_FLAG_DEACTIVATED);
owner->CombatStopWithPets();
- owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_ON_TAXI);
+ owner->SetUnitFlag(UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_ON_TAXI);
uint32 end = GetPathAtMapEnd();
uint32 currentNodeId = GetCurrentNode();
@@ -156,7 +156,7 @@ void FlightPathMovementGenerator::DoFinalize(Player* owner, bool active, bool/*
uint32 taxiNodeId = owner->m_taxi.GetTaxiDestination();
owner->m_taxi.ClearTaxiDestinations();
owner->Dismount();
- owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_ON_TAXI);
+ owner->RemoveUnitFlag(UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_ON_TAXI);
if (owner->m_taxi.empty())
{
diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
index 2e44fc4ce3d..9d2f98ac4b4 100644
--- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp
@@ -145,7 +145,7 @@ void HomeMovementGenerator<Creature>::DoFinalize(Creature* owner, bool active, b
if (movementInform && HasFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED))
{
if (!owner->HasCanSwimFlagOutOfCombat())
- owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CAN_SWIM);
+ owner->RemoveUnitFlag(UNIT_FLAG_CAN_SWIM);
owner->SetSpawnHealth();
owner->LoadCreaturesAddon();
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 471d1f059eb..6e4ed60221b 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -1467,7 +1467,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo
target->m_stealth.AddFlag(type);
target->m_stealth.AddValue(type, GetAmount());
- target->SetStandFlags(UNIT_STAND_FLAGS_CREEP);
+ target->SetVisFlag(UNIT_VIS_FLAGS_CREEP);
if (target->GetTypeId() == TYPEID_PLAYER)
target->SetByteFlag(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_AURA_VISION, PLAYER_FIELD_BYTE2_STEALTH);
}
@@ -1479,7 +1479,7 @@ void AuraEffect::HandleModStealth(AuraApplication const* aurApp, uint8 mode, boo
{
target->m_stealth.DelFlag(type);
- target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP);
+ target->RemoveVisFlag(UNIT_VIS_FLAGS_CREEP);
if (target->GetTypeId() == TYPEID_PLAYER)
target->RemoveByteFlag(PLAYER_FIELD_BYTES2, PLAYER_FIELD_BYTES_2_OFFSET_AURA_VISION, PLAYER_FIELD_BYTE2_STEALTH);
}
@@ -2096,8 +2096,8 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
target->SetDisplayId(model_id);
// Dragonmaw Illusion (set mount model also)
- if (GetId() == 42016 && target->GetMountID() && !target->GetAuraEffectsByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED).empty())
- target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 16314);
+ if (GetId() == 42016 && target->GetMountDisplayId() && !target->GetAuraEffectsByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED).empty())
+ target->SetMountDisplayId(16314);
}
}
}
@@ -2124,7 +2124,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
target->RestoreDisplayId();
// Dragonmaw Illusion (restore mount model)
- if (GetId() == 42016 && target->GetMountID() == 16314)
+ if (GetId() == 42016 && target->GetMountDisplayId() == 16314)
{
if (!target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).empty())
{
@@ -2134,7 +2134,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
uint32 displayID = ObjectMgr::ChooseDisplayId(ci);
sObjectMgr->GetCreatureModelRandomGender(&displayID);
- target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, displayID);
+ target->SetMountDisplayId(displayID);
}
}
}
@@ -2165,12 +2165,12 @@ void AuraEffect::HandleAuraCloneCaster(AuraApplication const* aurApp, uint8 mode
// What must be cloned? at least display and scale
target->SetDisplayId(caster->GetDisplayId());
//target->SetObjectScale(caster->GetObjectScale()); // we need retail info about how scaling is handled (aura maybe?)
- target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE);
+ target->SetUnitFlag2(UNIT_FLAG2_MIRROR_IMAGE);
}
else
{
target->SetDisplayId(target->GetNativeDisplayId());
- target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE);
+ target->RemoveUnitFlag2(UNIT_FLAG2_MIRROR_IMAGE);
}
}
@@ -2236,9 +2236,9 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
if (aurApp->GetRemoveMode())
return;
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); // blizz like 2.0.x
- target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); // blizz like 2.0.x
- target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); // blizz like 2.0.x
+ target->SetUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); // blizz like 2.0.x
+ target->SetUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); // blizz like 2.0.x
+ target->SetDynamicFlag(UNIT_DYNFLAG_DEAD); // blizz like 2.0.x
target->AddUnitState(UNIT_STATE_DIED);
if (Creature* creature = target->ToCreature())
@@ -2253,9 +2253,9 @@ void AuraEffect::HandleFeignDeath(AuraApplication const* aurApp, uint8 mode, boo
target->SendMessageToSet(&data, true);
*/
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); // blizz like 2.0.x
- target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH); // blizz like 2.0.x
- target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_DEAD); // blizz like 2.0.x
+ target->RemoveUnitFlag(UNIT_FLAG_PREVENT_EMOTES_FROM_CHAT_TEXT); // blizz like 2.0.x
+ target->RemoveUnitFlag2(UNIT_FLAG2_FEIGN_DEATH); // blizz like 2.0.x
+ target->RemoveDynamicFlag(UNIT_DYNFLAG_DEAD); // blizz like 2.0.x
target->ClearUnitState(UNIT_STATE_DIED);
if (Creature* creature = target->ToCreature())
@@ -2274,7 +2274,10 @@ void AuraEffect::HandleModUnattackable(AuraApplication const* aurApp, uint8 mode
if (!apply && target->HasAuraType(SPELL_AURA_MOD_UNATTACKABLE))
return;
- target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE_2, apply);
+ if (apply)
+ target->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2);
+ else
+ target->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2);
// call functions which may have additional effects after changing state of unit
if (apply && (mode & AURA_EFFECT_HANDLE_REAL))
@@ -2303,26 +2306,34 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode,
if (apply ? target->GetAuraEffectsByType(type).size() > 1 : target->HasAuraType(type))
return;
- uint32 field, flag, slot;
+ void(*flagChangeFunc)(Unit * u) = nullptr;
+
+ uint32 slot;
WeaponAttackType attType;
switch (type)
{
case SPELL_AURA_MOD_DISARM:
- field = UNIT_FIELD_FLAGS;
- flag = UNIT_FLAG_DISARMED;
+ if (apply)
+ flagChangeFunc = [](Unit* u) { u->SetUnitFlag(UNIT_FLAG_DISARMED); };
+ else
+ flagChangeFunc = [](Unit* u) { u->RemoveUnitFlag(UNIT_FLAG_DISARMED); };
slot = EQUIPMENT_SLOT_MAINHAND;
attType = BASE_ATTACK;
break;
case SPELL_AURA_MOD_DISARM_OFFHAND:
- field = UNIT_FIELD_FLAGS_2;
- flag = UNIT_FLAG2_DISARM_OFFHAND;
+ if (apply)
+ flagChangeFunc = [](Unit* u) { u->SetUnitFlag2(UNIT_FLAG2_DISARM_OFFHAND); };
+ else
+ flagChangeFunc = [](Unit* u) { u->RemoveUnitFlag2(UNIT_FLAG2_DISARM_OFFHAND); };
slot = EQUIPMENT_SLOT_OFFHAND;
attType = OFF_ATTACK;
break;
case SPELL_AURA_MOD_DISARM_RANGED:
- field = UNIT_FIELD_FLAGS_2;
- flag = UNIT_FLAG2_DISARM_RANGED;
- slot = EQUIPMENT_SLOT_RANGED;
+ if (apply)
+ flagChangeFunc = [](Unit* u) { u->SetUnitFlag2(UNIT_FLAG2_DISARM_RANGED); };
+ else
+ flagChangeFunc = [](Unit* u) { u->RemoveUnitFlag2(UNIT_FLAG2_DISARM_RANGED); };
+ slot = EQUIPMENT_SLOT_MAINHAND;
attType = RANGED_ATTACK;
break;
default:
@@ -2330,10 +2341,8 @@ void AuraEffect::HandleAuraModDisarm(AuraApplication const* aurApp, uint8 mode,
}
// set/remove flag before weapon bonuses so it's properly reflected in CanUseAttackType
- if (apply)
- target->SetFlag(field, flag);
- else
- target->RemoveFlag(field, flag);
+ if (flagChangeFunc)
+ flagChangeFunc(target);
// Handle damage modification, shapeshifted druids are not affected
if (target->GetTypeId() == TYPEID_PLAYER && !target->IsInFeralForm())
@@ -2366,7 +2375,7 @@ void AuraEffect::HandleAuraModSilence(AuraApplication const* aurApp, uint8 mode,
if (apply)
{
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
+ target->SetUnitFlag(UNIT_FLAG_SILENCED);
// call functions which may have additional effects after changing state of unit
// Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
@@ -2382,7 +2391,7 @@ void AuraEffect::HandleAuraModSilence(AuraApplication const* aurApp, uint8 mode,
if (target->HasAuraType(SPELL_AURA_MOD_SILENCE) || target->HasAuraType(SPELL_AURA_MOD_PACIFY_SILENCE))
return;
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
+ target->RemoveUnitFlag(UNIT_FLAG_SILENCED);
}
}
@@ -2394,13 +2403,13 @@ void AuraEffect::HandleAuraModPacify(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
if (apply)
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
+ target->SetUnitFlag(UNIT_FLAG_PACIFIED);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(SPELL_AURA_MOD_PACIFY) || target->HasAuraType(SPELL_AURA_MOD_PACIFY_SILENCE))
return;
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
+ target->RemoveUnitFlag(UNIT_FLAG_PACIFIED);
}
}
@@ -2416,9 +2425,9 @@ void AuraEffect::HandleAuraModPacifyAndSilence(AuraApplication const* aurApp, ui
if (m_spellInfo->Id == 45839)
{
if (apply)
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ target->SetUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
else
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ target->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
}
if (!(apply))
{
@@ -2515,12 +2524,12 @@ void AuraEffect::HandleAuraModStalked(AuraApplication const* aurApp, uint8 mode,
// used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND
if (apply)
- target->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
+ target->SetDynamicFlag(UNIT_DYNFLAG_TRACK_UNIT);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (!target->HasAuraType(GetAuraType()))
- target->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT);
+ target->RemoveDynamicFlag(UNIT_DYNFLAG_TRACK_UNIT);
}
// call functions which may have additional effects after changing state of unit
@@ -2536,13 +2545,13 @@ void AuraEffect::HandleAuraUntrackable(AuraApplication const* aurApp, uint8 mode
Unit* target = aurApp->GetTarget();
if (apply)
- target->SetByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, UNIT_STAND_FLAGS_UNTRACKABLE);
+ target->SetVisFlag(UNIT_VIS_FLAGS_UNTRACKABLE);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(GetAuraType()))
return;
- target->RemoveByteFlag(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, UNIT_STAND_FLAGS_UNTRACKABLE);
+ target->RemoveVisFlag(UNIT_VIS_FLAGS_UNTRACKABLE);
}
}
@@ -2733,13 +2742,13 @@ void AuraEffect::HandleForceMoveForward(AuraApplication const* aurApp, uint8 mod
Unit* target = aurApp->GetTarget();
if (apply)
- target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT);
+ target->SetUnitFlag2(UNIT_FLAG2_FORCE_MOVEMENT);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(GetAuraType()))
return;
- target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT);
+ target->RemoveUnitFlag2(UNIT_FLAG2_FORCE_MOVEMENT);
}
}
@@ -3056,8 +3065,8 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp,
target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply);
// Dragonmaw Illusion (overwrite mount model, mounted aura already applied)
- if (apply && target->HasAuraEffect(42016, 0) && target->GetMountID())
- target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 16314);
+ if (apply && target->HasAuraEffect(42016, 0) && target->GetMountDisplayId())
+ target->SetMountDisplayId(16314);
}
}
}
@@ -3192,7 +3201,7 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint
if (apply)
{
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE);
+ target->SetUnitFlag(UNIT_FLAG_IMMUNE);
target->GetThreatManager().EvaluateSuppressed();
}
else
@@ -3200,7 +3209,7 @@ void AuraEffect::HandleAuraModSchoolImmunity(AuraApplication const* aurApp, uint
// do not remove unit flag if there are more than this auraEffect of that kind on unit
if (target->HasAuraType(GetAuraType()) || target->HasAuraType(SPELL_AURA_DAMAGE_IMMUNITY))
return;
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE);
+ target->RemoveUnitFlag(UNIT_FLAG_IMMUNE);
}
}
@@ -3214,7 +3223,7 @@ void AuraEffect::HandleAuraModDmgImmunity(AuraApplication const* aurApp, uint8 m
if (apply)
{
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE);
+ target->SetUnitFlag(UNIT_FLAG_IMMUNE);
target->GetThreatManager().EvaluateSuppressed();
}
else
@@ -3222,7 +3231,7 @@ void AuraEffect::HandleAuraModDmgImmunity(AuraApplication const* aurApp, uint8 m
// do not remove unit flag if there are more than this auraEffect of that kind on unit
if (target->HasAuraType(GetAuraType()) || target->HasAuraType(SPELL_AURA_SCHOOL_IMMUNITY))
return;
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE);
+ target->RemoveUnitFlag(UNIT_FLAG_IMMUNE);
}
}
@@ -4290,13 +4299,13 @@ void AuraEffect::HandleArenaPreparation(AuraApplication const* aurApp, uint8 mod
Unit* target = aurApp->GetTarget();
if (apply)
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
+ target->SetUnitFlag(UNIT_FLAG_PREPARATION);
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(GetAuraType()))
return;
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION);
+ target->RemoveUnitFlag(UNIT_FLAG_PREPARATION);
}
}
@@ -4621,7 +4630,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
uint32 displayID = ObjectMgr::ChooseDisplayId(creatureInfo);
sObjectMgr->GetCreatureModelRandomGender(&displayID);
- target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, displayID);
+ target->SetMountDisplayId(displayID);
}
}
break;
@@ -4781,7 +4790,12 @@ void AuraEffect::HandleAuraEmpathy(AuraApplication const* aurApp, uint8 mode, bo
}
if (target->GetCreatureType() == CREATURE_TYPE_BEAST)
- target->ApplyModUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO, apply);
+ {
+ if (apply)
+ target->SetDynamicFlag(UNIT_DYNFLAG_SPECIALINFO);
+ else
+ target->RemoveDynamicFlag(UNIT_DYNFLAG_SPECIALINFO);
+ }
}
void AuraEffect::HandleAuraModFaction(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -4795,13 +4809,13 @@ void AuraEffect::HandleAuraModFaction(AuraApplication const* aurApp, uint8 mode,
{
target->SetFaction(GetMiscValue());
if (target->GetTypeId() == TYPEID_PLAYER)
- target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
+ target->RemoveUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
}
else
{
target->RestoreFaction();
if (target->GetTypeId() == TYPEID_PLAYER)
- target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
+ target->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
}
}
@@ -4813,13 +4827,13 @@ void AuraEffect::HandleComprehendLanguage(AuraApplication const* aurApp, uint8 m
Unit* target = aurApp->GetTarget();
if (apply)
- target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
+ target->SetUnitFlag2(UNIT_FLAG2_COMPREHEND_LANG);
else
{
if (target->HasAuraType(GetAuraType()))
return;
- target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_COMPREHEND_LANG);
+ target->RemoveUnitFlag2(UNIT_FLAG2_COMPREHEND_LANG);
}
}
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 17a0d08bad0..ee58689813f 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -66,12 +66,12 @@ _flags(AFLAG_NONE), _effectsToApply(effMask), _needClientUpdate(false)
}
else
{
- Unit::VisibleAuraMap const* visibleAuras = GetTarget()->GetVisibleAuras();
+ Unit::VisibleAuraMap const& visibleAuras = GetTarget()->GetVisibleAuras();
// lookup for free slots in units visibleAuras
- Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(0);
+ Unit::VisibleAuraMap::const_iterator itr = visibleAuras.find(0);
for (uint32 freeSlot = 0; freeSlot < MAX_AURAS; ++itr, ++freeSlot)
{
- if (itr == visibleAuras->end() || itr->first != freeSlot)
+ if (itr == visibleAuras.end() || itr->first != freeSlot)
{
slot = freeSlot;
break;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 3dff5e0439e..a72bffb6aa3 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2691,7 +2691,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, bool scaleAura, TargetInfo&
if (m_caster != unit)
{
// Recheck UNIT_FLAG_NON_ATTACKABLE for delayed spells
- if (m_spellInfo->Speed > 0.0f && unit->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE) && unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID())
+ if (m_spellInfo->Speed > 0.0f && unit->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE) && unit->GetCharmerOrOwnerGUID() != m_caster->GetGUID())
return SPELL_MISS_EVADE;
if (m_caster->IsValidAttackTarget(unit, m_spellInfo))
@@ -2714,7 +2714,7 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, bool scaleAura, TargetInfo&
if (m_originalCaster && unit->IsInCombat() && m_spellInfo->HasInitialAggro())
{
- if (m_originalCaster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) // only do explicit combat forwarding for PvP enabled units
+ if (m_originalCaster->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)) // only do explicit combat forwarding for PvP enabled units
m_originalCaster->GetCombatManager().InheritCombatStatesFrom(unit); // for creature v creature combat, the threat forward does it for us
unit->GetThreatManager().ForwardThreatForAssistingMe(m_originalCaster, 0.0f, nullptr, true);
}
@@ -3099,7 +3099,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const
}
// Creatures focus their target when possible
- if (m_casttime && m_caster->IsCreature() && !m_spellInfo->IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED))
+ if (m_casttime && m_caster->IsCreature() && !m_spellInfo->IsNextMeleeSwingSpell() && !IsAutoRepeat() && !m_caster->ToUnit()->HasUnitFlag(UNIT_FLAG_POSSESSED))
{
// Channeled spells and some triggered spells do not focus a cast target. They face their target later on via channel object guid and via spell attribute or not at all
bool const focusTarget = !m_spellInfo->IsChanneled() && !(_triggeredCastFlags & TRIGGERED_IGNORE_SET_FACING);
@@ -3352,7 +3352,7 @@ void Spell::_cast(bool skipCheck)
}
// The spell focusing is making sure that we have a valid cast target guid when we need it so only check for a guid value here.
if (Creature* creatureCaster = m_caster->ToCreature())
- if (!creatureCaster->GetTarget().IsEmpty() && !creatureCaster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED))
+ if (!creatureCaster->GetTarget().IsEmpty() && !creatureCaster->HasUnitFlag(UNIT_FLAG_POSSESSED))
if (WorldObject const* target = ObjectAccessor::GetUnit(*creatureCaster, creatureCaster->GetTarget()))
creatureCaster->SetInFront(target);
@@ -4364,13 +4364,13 @@ void Spell::UpdateSpellCastDataAmmo(WorldPackets::Spells::SpellAmmo& ammo)
}
}
}
- else if (m_caster->GetTypeId() == TYPEID_UNIT)
+ else if (Unit const* unitCaster = m_caster->ToUnit())
{
uint32 nonRangedAmmoDisplayID = 0;
uint32 nonRangedAmmoInventoryType = 0;
for (uint8 i = BASE_ATTACK; i < MAX_ATTACK; ++i)
{
- if (uint32 item_id = m_caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i))
+ if (uint32 item_id = unitCaster->GetVirtualItemId(i))
{
if (ItemEntry const* itemEntry = sItemStore.LookupEntry(item_id))
{
@@ -4583,7 +4583,7 @@ void Spell::SendChannelUpdate(uint32 time)
if (time == 0)
{
unitCaster->SetChannelObjectGuid(ObjectGuid::Empty);
- unitCaster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0);
+ unitCaster->SetChannelSpellId(0);
}
WorldPacket data(MSG_CHANNEL_UPDATE, 8+4);
@@ -4622,7 +4622,7 @@ void Spell::SendChannelStart(uint32 duration)
creatureCaster->SetSpellFocus(this, ObjectAccessor::GetWorldObject(*creatureCaster, channelTarget));
}
- unitCaster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id);
+ unitCaster->SetChannelSpellId(m_spellInfo->Id);
}
void Spell::SendResurrectRequest(Player* target)
@@ -5082,7 +5082,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
// Prevent cheating in case the player has an immunity effect and tries to interact with a non-allowed gameobject. The error message is handled by the client so we don't report anything here
if (m_caster->ToPlayer() && m_targets.GetGOTarget())
{
- if (m_targets.GetGOTarget()->GetGOInfo()->CannotBeUsedUnderImmunity() && m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE))
+ if (m_targets.GetGOTarget()->GetGOInfo()->CannotBeUsedUnderImmunity() && m_caster->ToUnit()->HasUnitFlag(UNIT_FLAG_IMMUNE))
return SPELL_FAILED_DONT_REPORT;
}
@@ -5109,7 +5109,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
}
}
- if (m_spellInfo->HasAttribute(SPELL_ATTR7_IS_CHEAT_SPELL) && !m_caster->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS))
+ if (m_spellInfo->HasAttribute(SPELL_ATTR7_IS_CHEAT_SPELL) && m_caster->IsUnit() && !m_caster->ToUnit()->HasUnitFlag2(UNIT_FLAG2_ALLOW_CHEAT_SPELLS))
{
m_customError = SPELL_CUSTOM_ERROR_GM_ONLY;
return SPELL_FAILED_CUSTOM_ERROR;
@@ -5591,7 +5591,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.GetUnitTarget() || m_targets.GetUnitTarget()->GetTypeId() != TYPEID_UNIT)
return SPELL_FAILED_BAD_TARGETS;
- if (!(m_targets.GetUnitTarget()->GetUInt32Value(UNIT_FIELD_FLAGS) & UNIT_FLAG_SKINNABLE))
+ if (!m_targets.GetUnitTarget()->HasUnitFlag(UNIT_FLAG_SKINNABLE))
return SPELL_FAILED_TARGET_UNSKINNABLE;
Creature* creature = m_targets.GetUnitTarget()->ToCreature();
@@ -5843,8 +5843,8 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
dispelMask = SpellInfo::GetDispelMask(DispelType(spellEffectInfo.MiscValue));
bool hasStealableAura = false;
- Unit::VisibleAuraMap const* visibleAuras = m_targets.GetUnitTarget()->GetVisibleAuras();
- for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
+ Unit::VisibleAuraMap const& visibleAuras = m_targets.GetUnitTarget()->GetVisibleAuras();
+ for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras.begin(); itr != visibleAuras.end(); ++itr)
{
if (!itr->second->IsPositive())
continue;
@@ -6159,7 +6159,7 @@ SpellCastResult Spell::CheckCasterAuras(uint32* param1) const
SpellCastResult result = SPELL_CAST_OK;
// Get unit state
- uint32 const unitflag = unitCaster->GetUInt32Value(UNIT_FIELD_FLAGS);
+ uint32 const unitflag = unitCaster->GetUnitFlags();
// this check should only be done when player does cast directly
// (ie not when it's called from a script) Breaks for example PlayerAI when charmed
@@ -7324,7 +7324,7 @@ bool Spell::CheckEffectTarget(Unit const* target, SpellEffectInfo const& spellEf
{
if (!m_targets.GetCorpseTargetGUID())
{
- if (target->IsWithinLOSInMap(m_caster, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE))
+ if (target->IsWithinLOSInMap(m_caster, LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::M2) && target->HasUnitFlag(UNIT_FLAG_SKINNABLE))
return true;
return false;
@@ -7389,7 +7389,7 @@ bool Spell::IsProcDisabled() const
bool Spell::IsChannelActive() const
{
- return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0;
+ return m_caster->IsUnit() && m_caster->ToUnit()->GetChannelSpellId() != 0;
}
bool Spell::IsAutoActionResetSpell() const
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 720aadbb2d0..45e7a53603e 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1793,7 +1793,7 @@ void Spell::EffectOpenLock()
{
GameObjectTemplate const* goInfo = gameObjTarget->GetGOInfo();
- if (goInfo->CannotBeUsedUnderImmunity() && m_caster->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE))
+ if (goInfo->CannotBeUsedUnderImmunity() && player->HasUnitFlag(UNIT_FLAG_IMMUNE))
return;
// Arathi Basin banner opening. /// @todo Verify correctness of this check
@@ -2139,7 +2139,7 @@ void Spell::EffectSummonType()
return;
summon->SelectLevel(); // some summoned creaters have different from 1 DB data for level/hp
- summon->SetUInt32Value(UNIT_NPC_FLAGS, summon->GetCreatureTemplate()->npcflag);
+ summon->ReplaceAllNpcFlags(NPCFlags(summon->GetCreatureTemplate()->npcflag));
summon->SetImmuneToAll(true);
break;
}
@@ -2916,7 +2916,7 @@ void Spell::EffectSummonPet()
pet->SetReactState(REACT_DEFENSIVE);
}
- pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
+ pet->SetCreatedBySpell(m_spellInfo->Id);
// generate new name for summon pet
std::string new_name = sObjectMgr->GeneratePetName(petentry);
@@ -4226,8 +4226,8 @@ void Spell::EffectSkinning()
uint32 skill = creature->GetCreatureTemplate()->GetRequiredLootSkill();
- creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
- creature->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
+ creature->RemoveUnitFlag(UNIT_FLAG_SKINNABLE);
+ creature->SetDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
player->SendLoot(creature->GetGUID(), LOOT_SKINNING);
int32 const reqValue = targetLevel < 10 ? 0 : (targetLevel < 20 ? (targetLevel - 10) * 10 : targetLevel * 5);
@@ -4541,8 +4541,8 @@ void Spell::EffectResurrectPet()
pet->Relocate(x, y, z, player->GetOrientation()); // This is needed so SaveStayPosition() will get the proper coords.
}
- pet->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_NONE);
- pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
+ pet->ReplaceAllDynamicFlags(UNIT_DYNFLAG_NONE);
+ pet->RemoveUnitFlag(UNIT_FLAG_SKINNABLE);
pet->setDeathState(ALIVE);
pet->ClearUnitState(UNIT_STATE_ALL_ERASABLE);
pet->SetHealth(pet->CountPctFromMaxHealth(damage));
@@ -5259,7 +5259,7 @@ void Spell::SummonGuardian(SpellEffectInfo const& spellEffectInfo, uint32 entry,
if (uint32 weapon = unitCaster->GetUInt32Value(PLAYER_VISIBLE_ITEM_16_ENTRYID))
{
summon->SetDisplayId(11686); // modelid2
- summon->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, weapon);
+ summon->SetVirtualItem(0, weapon);
}
else
summon->SetDisplayId(1126); // modelid1
@@ -5278,7 +5278,7 @@ void Spell::EffectRenamePet()
!unitTarget->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET)
return;
- unitTarget->SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED);
+ unitTarget->SetPetFlag(UNIT_PET_FLAG_CAN_BE_RENAMED);
}
void Spell::EffectPlayMusic()
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 0abf694251a..65834d7c741 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -1627,7 +1627,7 @@ SpellCastResult SpellInfo::CheckTarget(WorldObject const* caster, WorldObject co
if (unitTarget)
{
// spells cannot be cast if target has a pet in combat either
- if (HasAttribute(SPELL_ATTR1_CANT_TARGET_IN_COMBAT) && (unitTarget->IsInCombat() || unitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT)))
+ if (HasAttribute(SPELL_ATTR1_CANT_TARGET_IN_COMBAT) && (unitTarget->IsInCombat() || unitTarget->HasUnitFlag(UNIT_FLAG_PET_IN_COMBAT)))
return SPELL_FAILED_TARGET_AFFECTING_COMBAT;
// only spells with SPELL_ATTR3_ONLY_TARGET_GHOSTS can target ghosts
@@ -1666,7 +1666,7 @@ SpellCastResult SpellInfo::CheckTarget(WorldObject const* caster, WorldObject co
if (!player->GetWeaponForAttack(BASE_ATTACK) || !player->IsUseEquipedWeapon(true))
return SPELL_FAILED_TARGET_NO_WEAPONS;
}
- else if (!unitTarget->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID))
+ else if (!unitTarget->GetVirtualItemId(0))
return SPELL_FAILED_TARGET_NO_WEAPONS;
}
}
@@ -1700,7 +1700,7 @@ SpellCastResult SpellInfo::CheckTarget(WorldObject const* caster, WorldObject co
return SPELL_FAILED_BAD_TARGETS;
// checked in Unit::IsValidAttack/AssistTarget, shouldn't be checked for ENTRY targets
- //if (!HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNINTERACTIBLE))
+ //if (!HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE) && target->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE))
// return SPELL_FAILED_BAD_TARGETS;
//if (!HasAttribute(SPELL_ATTR6_CAN_TARGET_POSSESSED_FRIENDS))