From c48558b9701504729939b3d3ca7500196e69125b Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 13 Jan 2021 05:31:58 +0000 Subject: [PATCH 1/2] [Restyler] astyle --- src/server/game/Entities/Object/Object.cpp | 480 +- src/server/game/Entities/Player/Player.cpp | 5879 +++++++++-------- src/server/game/Entities/Player/Player.h | 3142 ++++----- src/server/game/Spells/SpellEffects.cpp | 2054 +++--- .../scripts/Northrend/zone_wintergrasp.cpp | 128 +- src/server/shared/DataStores/DBCEnums.h | 4 +- src/server/shared/SharedDefines.h | 165 +- .../worldserver/CommandLine/CliRunnable.cpp | 22 +- 8 files changed, 6006 insertions(+), 5868 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 2d39b9701dc87..46d54a119de1e 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -61,7 +61,7 @@ constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max MAX_VISIBILITY_DISTANCE }; -Object::Object() : m_PackGUID(sizeof(uint64)+1) +Object::Object() : m_PackGUID(sizeof(uint64) + 1) { m_objectTypeId = TYPEID_OBJECT; m_objectType = TYPEMASK_OBJECT; @@ -84,7 +84,7 @@ WorldObject::~WorldObject() if (GetTypeId() == TYPEID_CORPSE) { LOG_FATAL("misc", "WorldObject::~WorldObject Corpse Type: %d (%s) deleted but still in map!!", - ToCorpse()->GetType(), GetGUID().ToString().c_str()); + ToCorpse()->GetType(), GetGUID().ToString().c_str()); ABORT(); } ResetMap(); @@ -114,7 +114,7 @@ Object::~Object() void Object::_InitValues() { m_uint32Values = new uint32[m_valuesCount]; - memset(m_uint32Values, 0, m_valuesCount*sizeof(uint32)); + memset(m_uint32Values, 0, m_valuesCount * sizeof(uint32)); _changesMask.SetCount(m_valuesCount); @@ -277,7 +277,7 @@ uint32 Object::GetUInt32Value(uint16 index) const uint64 Object::GetUInt64Value(uint16 index) const { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false)); - return *((uint64*)&(m_uint32Values[index])); + return *((uint64*) & (m_uint32Values[index])); } float Object::GetFloatValue(uint16 index) const @@ -290,20 +290,20 @@ uint8 Object::GetByteValue(uint16 index, uint8 offset) const { ASSERT(index < m_valuesCount || PrintIndexError(index, false)); ASSERT(offset < 4); - return *(((uint8*)&m_uint32Values[index])+offset); + return *(((uint8*)&m_uint32Values[index]) + offset); } uint16 Object::GetUInt16Value(uint16 index, uint8 offset) const { ASSERT(index < m_valuesCount || PrintIndexError(index, false)); ASSERT(offset < 2); - return *(((uint16*)&m_uint32Values[index])+offset); + return *(((uint16*)&m_uint32Values[index]) + offset); } ObjectGuid Object::GetGuidValue(uint16 index) const { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, false)); - return *((ObjectGuid*)&(m_uint32Values[index])); + return *((ObjectGuid*) & (m_uint32Values[index])); } void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const @@ -352,7 +352,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const *data << object->GetPositionX(); *data << object->GetPositionY(); - *data << object->GetPositionZ(); + *data << object->GetPositionZ(); if (transport) { @@ -364,7 +364,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const { *data << object->GetPositionX(); *data << object->GetPositionY(); - *data << object->GetPositionZ(); + *data << object->GetPositionZ(); } *data << object->GetOrientation(); @@ -390,37 +390,35 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const // 0x8 if (flags & UPDATEFLAG_UNKNOWN) - { *data << uint32(0); - } // 0x10 if (flags & UPDATEFLAG_LOWGUID) { switch (GetTypeId()) { - case TYPEID_OBJECT: - case TYPEID_ITEM: - case TYPEID_CONTAINER: - case TYPEID_GAMEOBJECT: - case TYPEID_DYNAMICOBJECT: - case TYPEID_CORPSE: - *data << uint32(GetGUID().GetCounter()); // GetGUID().GetCounter() - break; - //! Unit, Player and default here are sending wrong values. - /// @todo Research the proper formula - case TYPEID_UNIT: - *data << uint32(0x0000000B); // unk - break; - case TYPEID_PLAYER: - if (flags & UPDATEFLAG_SELF) - *data << uint32(0x0000002F); // unk - else - *data << uint32(0x00000008); // unk - break; - default: - *data << uint32(0x00000000); // unk - break; + case TYPEID_OBJECT: + case TYPEID_ITEM: + case TYPEID_CONTAINER: + case TYPEID_GAMEOBJECT: + case TYPEID_DYNAMICOBJECT: + case TYPEID_CORPSE: + *data << uint32(GetGUID().GetCounter()); // GetGUID().GetCounter() + break; + //! Unit, Player and default here are sending wrong values. + /// @todo Research the proper formula + case TYPEID_UNIT: + *data << uint32(0x0000000B); // unk + break; + case TYPEID_PLAYER: + if (flags & UPDATEFLAG_SELF) + *data << uint32(0x0000002F); // unk + else + *data << uint32(0x00000008); // unk + break; + default: + *data << uint32(0x00000000); // unk + break; } } @@ -429,7 +427,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 flags) const { ASSERT(unit); if (Unit* victim = unit->GetVictim()) - *data << victim->GetPackGUID(); + * data << victim->GetPackGUID(); else *data << uint8(0); } @@ -484,7 +482,7 @@ void Object::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* targe for (uint16 index = 0; index < m_valuesCount; ++index) { if (_fieldNotifyFlags & flags[index] || - ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag))) + ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag))) { updateMask.SetBit(index); fieldBuffer << m_uint32Values[index]; @@ -538,45 +536,45 @@ uint32 Object::GetUpdateFieldData(Player const* target, uint32*& flags) const switch (GetTypeId()) { - case TYPEID_ITEM: - case TYPEID_CONTAINER: - flags = ItemUpdateFieldFlags; - if (((Item const*)this)->GetOwnerGUID() == target->GetGUID()) - visibleFlag |= UF_FLAG_OWNER | UF_FLAG_ITEM_OWNER; - break; - case TYPEID_UNIT: - case TYPEID_PLAYER: - { - Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself(); - flags = UnitUpdateFieldFlags; - if (ToUnit()->GetOwnerGUID() == target->GetGUID()) - visibleFlag |= UF_FLAG_OWNER; - - if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO)) - if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID())) - visibleFlag |= UF_FLAG_SPECIAL_INFO; - - if (plr && plr->IsInSameRaidWith(target)) - visibleFlag |= UF_FLAG_PARTY_MEMBER; - break; - } - case TYPEID_GAMEOBJECT: - flags = GameObjectUpdateFieldFlags; - if (ToGameObject()->GetOwnerGUID() == target->GetGUID()) - visibleFlag |= UF_FLAG_OWNER; - break; - case TYPEID_DYNAMICOBJECT: - flags = DynamicObjectUpdateFieldFlags; - if (ToDynObject()->GetCasterGUID() == target->GetGUID()) - visibleFlag |= UF_FLAG_OWNER; - break; - case TYPEID_CORPSE: - flags = CorpseUpdateFieldFlags; - if (ToCorpse()->GetOwnerGUID() == target->GetGUID()) - visibleFlag |= UF_FLAG_OWNER; - break; - case TYPEID_OBJECT: - break; + case TYPEID_ITEM: + case TYPEID_CONTAINER: + flags = ItemUpdateFieldFlags; + if (((Item const*)this)->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER | UF_FLAG_ITEM_OWNER; + break; + case TYPEID_UNIT: + case TYPEID_PLAYER: + { + Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself(); + flags = UnitUpdateFieldFlags; + if (ToUnit()->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; + + if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO)) + if (ToUnit()->HasAuraTypeWithCaster(SPELL_AURA_EMPATHY, target->GetGUID())) + visibleFlag |= UF_FLAG_SPECIAL_INFO; + + if (plr && plr->IsInSameRaidWith(target)) + visibleFlag |= UF_FLAG_PARTY_MEMBER; + break; + } + case TYPEID_GAMEOBJECT: + flags = GameObjectUpdateFieldFlags; + if (ToGameObject()->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; + break; + case TYPEID_DYNAMICOBJECT: + flags = DynamicObjectUpdateFieldFlags; + if (ToDynObject()->GetCasterGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; + break; + case TYPEID_CORPSE: + flags = CorpseUpdateFieldFlags; + if (ToCorpse()->GetOwnerGUID() == target->GetGUID()) + visibleFlag |= UF_FLAG_OWNER; + break; + case TYPEID_OBJECT: + break; } return visibleFlag; @@ -640,7 +638,7 @@ void Object::UpdateUInt32Value(uint16 index, uint32 value) void Object::SetUInt64Value(uint16 index, uint64 value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (*((uint64*)&(m_uint32Values[index])) != value) + if (*((uint64*) & (m_uint32Values[index])) != value) { m_uint32Values[index] = PAIR64_LOPART(value); m_uint32Values[index + 1] = PAIR64_HIPART(value); @@ -654,9 +652,9 @@ void Object::SetUInt64Value(uint16 index, uint64 value) bool Object::AddGuidValue(uint16 index, ObjectGuid value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (value && !*((ObjectGuid*)&(m_uint32Values[index]))) + if (value && !*((ObjectGuid*) & (m_uint32Values[index]))) { - *((ObjectGuid*)&(m_uint32Values[index])) = value; + *((ObjectGuid*) & (m_uint32Values[index])) = value; _changesMask.SetBit(index); _changesMask.SetBit(index + 1); @@ -671,7 +669,7 @@ bool Object::AddGuidValue(uint16 index, ObjectGuid value) bool Object::RemoveGuidValue(uint16 index, ObjectGuid value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (value && *((ObjectGuid*)&(m_uint32Values[index])) == value) + if (value && *((ObjectGuid*) & (m_uint32Values[index])) == value) { m_uint32Values[index] = 0; m_uint32Values[index + 1] = 0; @@ -733,9 +731,9 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value) void Object::SetGuidValue(uint16 index, ObjectGuid value) { ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (*((ObjectGuid*)&(m_uint32Values[index])) != value) + if (*((ObjectGuid*) & (m_uint32Values[index])) != value) { - *((ObjectGuid*)&(m_uint32Values[index])) = value; + *((ObjectGuid*) & (m_uint32Values[index])) = value; _changesMask.SetBit(index); _changesMask.SetBit(index + 1); @@ -838,7 +836,8 @@ bool Object::HasFlag(uint16 index, uint32 flag) const void Object::ApplyModFlag(uint16 index, uint32 flag, bool apply) { - if (apply) SetFlag(index, flag); else RemoveFlag(index, flag); + if (apply) SetFlag(index, flag); + else RemoveFlag(index, flag); } void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag) @@ -886,7 +885,8 @@ bool Object::HasByteFlag(uint16 index, uint8 offset, uint8 flag) const void Object::ApplyModByteFlag(uint16 index, uint8 offset, uint8 flag, bool apply) { - if (apply) SetByteFlag(index, offset, flag); else RemoveByteFlag(index, offset, flag); + if (apply) SetByteFlag(index, offset, flag); + else RemoveByteFlag(index, offset, flag); } void Object::SetFlag64(uint16 index, uint64 newFlag) @@ -919,12 +919,14 @@ bool Object::HasFlag64(uint16 index, uint64 flag) const void Object::ApplyModFlag64(uint16 index, uint64 flag, bool apply) { - if (apply) SetFlag64(index, flag); else RemoveFlag64(index, flag); + if (apply) SetFlag64(index, flag); + else RemoveFlag64(index, flag); } bool Object::PrintIndexError(uint32 index, bool set) const { - LOG_ERROR("misc", "Attempt to %s non-existing value field: %u (count: %u) for object typeid: %u type mask: %u", (set ? "set value to" : "get value from"), index, m_valuesCount, GetTypeId(), m_objectType); + LOG_ERROR("misc", "Attempt to %s non-existing value field: %u (count: %u) for object typeid: %u type mask: %u", (set ? "set value to" : "get value from"), index, m_valuesCount, GetTypeId(), + m_objectType); // ASSERT must fail after function call return false; @@ -968,9 +970,9 @@ void MovementInfo::OutDebug() } WorldObject::WorldObject(bool isWorldObject) : Object(), WorldLocation(), LastUsedScriptID(0), -m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr), -m_transport(nullptr), m_zoneId(0), m_areaId(0), m_staticFloorZ(VMAP_INVALID_HEIGHT), m_outdoors(false), m_liquidStatus(LIQUID_MAP_NO_WATER), -m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0) + m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr), + m_transport(nullptr), m_zoneId(0), m_areaId(0), m_staticFloorZ(VMAP_INVALID_HEIGHT), m_outdoors(false), m_liquidStatus(LIQUID_MAP_NO_WATER), + m_currMap(nullptr), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0) { m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST); m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); @@ -1102,10 +1104,10 @@ bool WorldObject::IsInWorldPvpZone() const { switch (GetZoneId()) { - case AREA_WINTERGRASP: // Wintergrasp - return true; - default: - return false; + case AREA_WINTERGRASP: // Wintergrasp + return true; + default: + return false; } } @@ -1286,20 +1288,20 @@ bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* o { float dx1 = GetPositionX() - obj1->GetPositionX(); float dy1 = GetPositionY() - obj1->GetPositionY(); - float distsq1 = dx1*dx1 + dy1*dy1; + float distsq1 = dx1 * dx1 + dy1 * dy1; if (is3D) { float dz1 = GetPositionZ() - obj1->GetPositionZ(); - distsq1 += dz1*dz1; + distsq1 += dz1 * dz1; } float dx2 = GetPositionX() - obj2->GetPositionX(); float dy2 = GetPositionY() - obj2->GetPositionY(); - float distsq2 = dx2*dx2 + dy2*dy2; + float distsq2 = dx2 * dx2 + dy2 * dy2; if (is3D) { float dz2 = GetPositionZ() - obj2->GetPositionZ(); - distsq2 += dz2*dz2; + distsq2 += dz2 * dz2; } return distsq1 < distsq2; @@ -1309,11 +1311,11 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan { float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); - float distsq = dx*dx + dy*dy; + float distsq = dx * dx + dy * dy; if (is3D) { float dz = GetPositionZ() - obj->GetPositionZ(); - distsq += dz*dz; + distsq += dz * dz; } float sizefactor = GetCombatReach() + obj->GetCombatReach(); @@ -1334,7 +1336,7 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange) { float dx = GetPositionX() - x; float dy = GetPositionY() - y; - float distsq = dx*dx + dy*dy; + float distsq = dx * dx + dy * dy; float sizefactor = GetCombatReach(); @@ -1355,7 +1357,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m float dx = GetPositionX() - x; float dy = GetPositionY() - y; float dz = GetPositionZ() - z; - float distsq = dx*dx + dy*dy + dz*dz; + float distsq = dx * dx + dy * dy + dz * dz; float sizefactor = GetCombatReach(); @@ -1407,7 +1409,7 @@ void WorldObject::GetRandomPoint(Position const& pos, float distance, float& ran } // angle to face `obj` to `this` - float angle = (float)rand_norm()*static_cast(2*M_PI); + float angle = (float)rand_norm() * static_cast(2 * M_PI); float new_dist = (float)rand_norm() + (float)rand_norm(); new_dist = distance * (new_dist > 1 ? new_dist - 2 : new_dist); @@ -1427,14 +1429,14 @@ Position WorldObject::GetRandomPoint(Position const& srcPos, float distance) con return Position(x, y, z, GetOrientation()); } -void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const +void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const { float new_z = GetMapHeight(x, y, z); if (new_z > INVALID_HEIGHT) z = new_z + (isType(TYPEMASK_UNIT) ? static_cast(this)->GetHoverOffset() : 0.0f); } -void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z, float* groundZ) const +void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, float* groundZ) const { // TODO: Allow transports to be part of dynamic vmap tree if (GetTransport()) @@ -1480,7 +1482,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z, float* grou z = ground_z; if (groundZ) - *groundZ = ground_z; + *groundZ = ground_z; } } else @@ -1542,9 +1544,7 @@ float WorldObject::GetSightRange(WorldObject const* target) const } if (ToDynObject() && isActiveObject()) - { return GetMap()->GetVisibilityRange(); - } return 0.0f; } @@ -1567,7 +1567,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo if (Player const* thisPlayer = ToPlayer()) { if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state - !(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & GHOST_VISIBILITY_GHOST)) + !(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & GHOST_VISIBILITY_GHOST)) { if (Corpse* corpse = thisPlayer->GetCorpse()) { @@ -1857,53 +1857,54 @@ void WorldObject::AddObjectToRemoveList() map->AddObjectToRemoveList(this); } -TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, WorldObject* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/) +TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, WorldObject* summoner /*= nullptr*/, + uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/) { uint32 mask = UNIT_MASK_SUMMON; if (properties) { switch (properties->Control) { - case SUMMON_CATEGORY_PET: + case SUMMON_CATEGORY_PET: + mask = UNIT_MASK_GUARDIAN; + break; + case SUMMON_CATEGORY_PUPPET: + mask = UNIT_MASK_PUPPET; + break; + case SUMMON_CATEGORY_VEHICLE: + mask = UNIT_MASK_MINION; + break; + case SUMMON_CATEGORY_WILD: + case SUMMON_CATEGORY_ALLY: + case SUMMON_CATEGORY_UNK: + { + switch (properties->Title) + { + case SUMMON_TYPE_MINION: + case SUMMON_TYPE_GUARDIAN: + case SUMMON_TYPE_GUARDIAN2: mask = UNIT_MASK_GUARDIAN; break; - case SUMMON_CATEGORY_PUPPET: - mask = UNIT_MASK_PUPPET; + case SUMMON_TYPE_TOTEM: + case SUMMON_TYPE_LIGHTWELL: + mask = UNIT_MASK_TOTEM; break; - case SUMMON_CATEGORY_VEHICLE: + case SUMMON_TYPE_VEHICLE: + case SUMMON_TYPE_VEHICLE2: + mask = UNIT_MASK_SUMMON; + break; + case SUMMON_TYPE_MINIPET: mask = UNIT_MASK_MINION; break; - case SUMMON_CATEGORY_WILD: - case SUMMON_CATEGORY_ALLY: - case SUMMON_CATEGORY_UNK: - { - switch (properties->Title) - { - case SUMMON_TYPE_MINION: - case SUMMON_TYPE_GUARDIAN: - case SUMMON_TYPE_GUARDIAN2: + default: + if (properties->Flags & 512) // Mirror Image, Summon Gargoyle mask = UNIT_MASK_GUARDIAN; - break; - case SUMMON_TYPE_TOTEM: - case SUMMON_TYPE_LIGHTWELL: - mask = UNIT_MASK_TOTEM; - break; - case SUMMON_TYPE_VEHICLE: - case SUMMON_TYPE_VEHICLE2: - mask = UNIT_MASK_SUMMON; - break; - case SUMMON_TYPE_MINIPET: - mask = UNIT_MASK_MINION; - break; - default: - if (properties->Flags & 512) // Mirror Image, Summon Gargoyle - mask = UNIT_MASK_GUARDIAN; - break; - } break; } - default: - return nullptr; + break; + } + default: + return nullptr; } } @@ -1916,21 +1917,21 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert TempSummon* summon = nullptr; switch (mask) { - case UNIT_MASK_SUMMON: - summon = new TempSummon(properties, summoner, false); - break; - case UNIT_MASK_GUARDIAN: - summon = new Guardian(properties, summonerUnit, false); - break; - case UNIT_MASK_PUPPET: - summon = new Puppet(properties, summonerUnit); - break; - case UNIT_MASK_TOTEM: - summon = new Totem(properties, summonerUnit); - break; - case UNIT_MASK_MINION: - summon = new Minion(properties, summonerUnit, false); - break; + case UNIT_MASK_SUMMON: + summon = new TempSummon(properties, summoner, false); + break; + case UNIT_MASK_GUARDIAN: + summon = new Guardian(properties, summonerUnit, false); + break; + case UNIT_MASK_PUPPET: + summon = new Puppet(properties, summonerUnit); + break; + case UNIT_MASK_TOTEM: + summon = new Totem(properties, summonerUnit); + break; + case UNIT_MASK_MINION: + summon = new Minion(properties, summonerUnit, false); + break; } if (!summon->Create(GenerateLowGuid(), this, phase, entry, pos, nullptr, vehId, true)) @@ -1997,7 +1998,8 @@ void WorldObject::ClearZoneScript() m_zoneScript = nullptr; } -TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, uint32 /*vehId = 0*/, uint32 spellId /*= 0*/, bool visibleBySummonerOnly /*= false*/) +TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, uint32 /*vehId = 0*/, + uint32 spellId /*= 0*/, bool visibleBySummonerOnly /*= false*/) { if (Map* map = FindMap()) { @@ -2011,13 +2013,14 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempS return nullptr; } -TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, bool visibleBySummonerOnly /*= false*/) +TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, + bool visibleBySummonerOnly /*= false*/) { if (!x && !y && !z) GetClosePoint(x, y, z, GetCombatReach()); if (!o) o = GetOrientation(); - return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, 0, visibleBySummonerOnly); + return SummonCreature(id, { x, y, z, o }, despawnType, despawnTime, 0, 0, visibleBySummonerOnly); } GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, Seconds respawnTime, GOSummonType summonType) @@ -2062,7 +2065,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float return SummonGameObject(entry, pos, rot, respawnTime, summonType); } -Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, Milliseconds despawnTime, CreatureAI* (*GetAI)(Creature*)) +Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, Milliseconds despawnTime, CreatureAI * (*GetAI)(Creature*)) { TempSummonType summonType = (despawnTime == 0s) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, despawnTime); @@ -2266,15 +2269,15 @@ float WorldObject::ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effInd modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_ALL_EFFECTS, value); switch (effIndex) { - case EFFECT_0: - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_EFFECT1, value); - break; - case EFFECT_1: - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_EFFECT2, value); - break; - case EFFECT_2: - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_EFFECT3, value); - break; + case EFFECT_0: + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_EFFECT1, value); + break; + case EFFECT_1: + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_EFFECT2, value); + break; + case EFFECT_2: + modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_EFFECT3, value); + break; } } return value; @@ -2316,7 +2319,7 @@ int32 WorldObject::ModSpellDuration(SpellInfo const* spellInfo, WorldObject cons if (!positive) { int32 mechanicMask = spellInfo->GetSpellMechanicMaskByEffectMask(effectMask); - auto mechanicCheck = [mechanicMask](AuraEffect const* aurEff) -> bool + auto mechanicCheck = [mechanicMask](AuraEffect const * aurEff) -> bool { if (mechanicMask & (1 << aurEff->GetMiscValue())) return true; @@ -2350,8 +2353,8 @@ int32 WorldObject::ModSpellDuration(SpellInfo const* spellInfo, WorldObject cons if (unitTarget->GetTypeId() == TYPEID_PLAYER) { if (spellInfo->SpellFamilyName == SPELLFAMILY_POTION && ( - sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_BATTLE) || - sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_GUARDIAN))) + sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_BATTLE) || + sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_GUARDIAN))) { if (unitTarget->HasAura(53042) && unitTarget->HasSpell(spellInfo->Effects[0].TriggerSpell)) duration *= 2; @@ -2364,28 +2367,28 @@ int32 WorldObject::ModSpellDuration(SpellInfo const* spellInfo, WorldObject cons { switch (spellInfo->SpellFamilyName) { - case SPELLFAMILY_DRUID: - if (spellInfo->SpellFamilyFlags[0] & 0x100) - { - // Glyph of Thorns - if (AuraEffect* aurEff = unitTarget->GetAuraEffect(57862, EFFECT_0)) - duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS; - } - break; - case SPELLFAMILY_PALADIN: - if ((spellInfo->SpellFamilyFlags[0] & 0x00000002) && spellInfo->SpellIconID == 298) - { - // Glyph of Blessing of Might - if (AuraEffect* aurEff = unitTarget->GetAuraEffect(57958, EFFECT_0)) - duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS; - } - else if ((spellInfo->SpellFamilyFlags[0] & 0x00010000) && spellInfo->SpellIconID == 306) - { - // Glyph of Blessing of Wisdom - if (AuraEffect* aurEff = unitTarget->GetAuraEffect(57979, EFFECT_0)) - duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS; - } - break; + case SPELLFAMILY_DRUID: + if (spellInfo->SpellFamilyFlags[0] & 0x100) + { + // Glyph of Thorns + if (AuraEffect* aurEff = unitTarget->GetAuraEffect(57862, EFFECT_0)) + duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS; + } + break; + case SPELLFAMILY_PALADIN: + if ((spellInfo->SpellFamilyFlags[0] & 0x00000002) && spellInfo->SpellIconID == 298) + { + // Glyph of Blessing of Might + if (AuraEffect* aurEff = unitTarget->GetAuraEffect(57958, EFFECT_0)) + duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS; + } + else if ((spellInfo->SpellFamilyFlags[0] & 0x00010000) && spellInfo->SpellIconID == 306) + { + // Glyph of Blessing of Wisdom + if (AuraEffect* aurEff = unitTarget->GetAuraEffect(57979, EFFECT_0)) + duration += aurEff->GetAmount() * MINUTE * IN_MILLISECONDS; + } + break; } } @@ -2406,7 +2409,7 @@ void WorldObject::ModSpellCastTime(SpellInfo const* spellInfo, int32& castTime, return; if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && - ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) + ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) castTime = unitCaster->CanInstantCast() ? 0 : int32(float(castTime) * unitCaster->GetFloatValue(UNIT_MOD_CAST_SPEED)); else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG)) castTime = int32(float(castTime) * unitCaster->m_modAttackSpeedPct[RANGED_ATTACK]); @@ -2431,7 +2434,7 @@ void WorldObject::ModSpellDurationTime(SpellInfo const* spellInfo, int32& durati return; if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && - ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) + ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) duration = int32(float(duration) * unitCaster->GetFloatValue(UNIT_MOD_CAST_SPEED)); else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG)) duration = int32(float(duration) * unitCaster->m_modAttackSpeedPct[RANGED_ATTACK]); @@ -2584,13 +2587,13 @@ SpellMissInfo WorldObject::SpellHitResult(Unit* victim, SpellInfo const* spellIn switch (spellInfo->DmgClass) { - case SPELL_DAMAGE_CLASS_RANGED: - case SPELL_DAMAGE_CLASS_MELEE: - return MeleeSpellHitResult(victim, spellInfo); - case SPELL_DAMAGE_CLASS_NONE: - return SPELL_MISS_NONE; - case SPELL_DAMAGE_CLASS_MAGIC: - return MagicSpellHitResult(victim, spellInfo); + case SPELL_DAMAGE_CLASS_RANGED: + case SPELL_DAMAGE_CLASS_MELEE: + return MeleeSpellHitResult(victim, spellInfo); + case SPELL_DAMAGE_CLASS_NONE: + return SPELL_MISS_NONE; + case SPELL_DAMAGE_CLASS_MAGIC: + return MagicSpellHitResult(victim, spellInfo); } return SPELL_MISS_NONE; } @@ -2617,19 +2620,19 @@ FactionTemplateEntry const* WorldObject::GetFactionTemplateEntry() const { switch (GetTypeId()) { - case TYPEID_PLAYER: - LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", ToPlayer()->GetName().c_str(), factionId); - break; - case TYPEID_UNIT: - LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template Id) #%u", ToCreature()->GetCreatureTemplate()->Entry, factionId); - break; - case TYPEID_GAMEOBJECT: - if (factionId) // Gameobjects may have faction template id = 0 - LOG_ERROR("entities.faction", "GameObject (template id: %u) has invalid faction (faction template Id) #%u", ToGameObject()->GetGOInfo()->entry, factionId); - break; - default: - LOG_ERROR("entities.unit", "Object (name=%s, type=%u) has invalid faction (faction template Id) #%u", GetName().c_str(), uint32(GetTypeId()), factionId); - break; + case TYPEID_PLAYER: + LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", ToPlayer()->GetName().c_str(), factionId); + break; + case TYPEID_UNIT: + LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template Id) #%u", ToCreature()->GetCreatureTemplate()->Entry, factionId); + break; + case TYPEID_GAMEOBJECT: + if (factionId) // Gameobjects may have faction template id = 0 + LOG_ERROR("entities.faction", "GameObject (template id: %u) has invalid faction (faction template Id) #%u", ToGameObject()->GetGOInfo()->entry, factionId); + break; + default: + LOG_ERROR("entities.unit", "Object (name=%s, type=%u) has invalid faction (faction template Id) #%u", GetName().c_str(), uint32(GetTypeId()), factionId); + break; } } @@ -2683,8 +2686,8 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const // same group - checks dependant only on our faction - skip FFA_PVP for example if (selfPlayerOwner->IsInRaidWith(targetPlayerOwner)) return REP_FRIENDLY; // return true to allow config option AllowTwoSide.Interaction.Group to work - // however client seems to allow mixed group parties, because in 13850 client it works like: - // return GetFactionReactionTo(GetFactionTemplateEntry(), target); + // however client seems to allow mixed group parties, because in 13850 client it works like: + // return GetFactionReactionTo(GetFactionTemplateEntry(), target); } // check FFA_PVP @@ -2705,7 +2708,7 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const { // check contested flags if ((targetFactionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) && - selfPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) + selfPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) return REP_HOSTILE; // if faction has reputation, hostile state depends only from AtWar state @@ -2738,7 +2741,7 @@ ReputationRank WorldObject::GetReactionTo(WorldObject const* target) const { // check contested flags if ((factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) && - targetPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) + targetPlayerOwner->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) return REP_HOSTILE; if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry)) return *repRank; @@ -2974,7 +2977,8 @@ 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->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner && unitOrOwner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) + && (unitTarget->IsInSanctuary() || unitOrOwner->IsInSanctuary())) return false; // additional checks - only PvP case @@ -2987,7 +2991,7 @@ bool WorldObject::IsValidAttackTarget(WorldObject const* target, SpellInfo const 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); + playerAffectingTarget->HasByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_UNK1); } return true; @@ -3247,7 +3251,7 @@ void WorldObject::GetContactPoint(WorldObject const* obj, float& x, float& y, fl GetNearPoint(obj, x, y, z, distance2d, GetAbsoluteAngle(obj)); } -void WorldObject::MovePosition(Position &pos, float dist, float angle) +void WorldObject::MovePosition(Position& pos, float dist, float angle) { angle += GetOrientation(); float destx, desty, destz, ground, floor; @@ -3258,7 +3262,7 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle) if (!Warhead::IsValidMapCoord(destx, desty, pos.m_positionZ)) { LOG_FATAL("misc", "WorldObject::MovePosition: Object %s has invalid coordinates X: %f and Y: %f were passed!", - GetGUID().ToString().c_str(), destx, desty); + GetGUID().ToString().c_str(), destx, desty); return; } @@ -3266,7 +3270,7 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle) floor = GetMapHeight(destx, desty, pos.m_positionZ); destz = std::fabs(ground - pos.m_positionZ) <= std::fabs(floor - pos.m_positionZ) ? ground : floor; - float step = dist/10.0f; + float step = dist / 10.0f; for (uint8 j = 0; j < 10; ++j) { @@ -3293,7 +3297,7 @@ void WorldObject::MovePosition(Position &pos, float dist, float angle) pos.SetOrientation(GetOrientation()); } -void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float angle) +void WorldObject::MovePositionToFirstCollision(Position& pos, float dist, float angle) { angle += GetOrientation(); float destx, desty, destz; @@ -3331,9 +3335,9 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float if (path.GetPathType() & PATHFIND_NOT_USING_PATH) { col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), - pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, - destx, desty, destz + halfHeight, - destx, desty, destz, -0.5f); + pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, + destx, desty, destz + halfHeight, + destx, desty, destz, -0.5f); destz -= halfHeight; @@ -3348,9 +3352,9 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float // check dynamic collision col = GetMap()->getObjectHitPos(GetPhaseMask(), - pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, - destx, desty, destz + halfHeight, - destx, desty, destz, -0.5f); + pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, + destx, desty, destz + halfHeight, + destx, desty, destz, -0.5f); destz -= halfHeight; @@ -3359,7 +3363,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float { destx -= CONTACT_DISTANCE * std::cos(angle); desty -= CONTACT_DISTANCE * std::sin(angle); - dist = std::sqrt((pos.m_positionX - destx)*(pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty)); + dist = std::sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty)); } float groundZ = VMAP_INVALID_HEIGHT_VALUE; @@ -3462,8 +3466,8 @@ struct WorldObjectChangeAccumulator UpdateDataMapType& i_updateDatas; WorldObject& i_object; GuidSet plr_list; - WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d) : i_updateDatas(d), i_object(obj) { } - void Visit(PlayerMapType &m) + WorldObjectChangeAccumulator(WorldObject& obj, UpdateDataMapType& d) : i_updateDatas(d), i_object(obj) { } + void Visit(PlayerMapType& m) { Player* source = nullptr; for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) @@ -3481,7 +3485,7 @@ struct WorldObjectChangeAccumulator } } - void Visit(CreatureMapType &m) + void Visit(CreatureMapType& m) { Creature* source = nullptr; for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) @@ -3496,7 +3500,7 @@ struct WorldObjectChangeAccumulator } } - void Visit(DynamicObjectMapType &m) + void Visit(DynamicObjectMapType& m) { DynamicObject* source = nullptr; for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter) @@ -3524,7 +3528,7 @@ struct WorldObjectChangeAccumulator } } - template void Visit(GridRefManager &) { } + template void Visit(GridRefManager&) { } }; void WorldObject::BuildUpdate(UpdateDataMapType& data_map) @@ -3564,8 +3568,8 @@ float WorldObject::GetFloorZ() const float WorldObject::GetMapWaterOrGroundLevel(float x, float y, float z, float* ground/* = nullptr*/) const { return GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, ground, - isType(TYPEMASK_UNIT) ? !static_cast(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false, - GetCollisionHeight()); + isType(TYPEMASK_UNIT) ? !static_cast(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false, + GetCollisionHeight()); } float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/, float distanceToSearch/* = DEFAULT_HEIGHT_SEARCH*/) const diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d3d0b6be665f5..d4b500bcf9274 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -259,7 +259,7 @@ Player::Player(WorldSession* session): Unit(true) SetLastRuneGraceTimer(i, 0); } - for (uint8 i=0; i < MAX_TIMERS; i++) + for (uint8 i = 0; i < MAX_TIMERS; i++) m_MirrorTimer[i] = DISABLED_MIRROR_TIMER; m_MirrorTimerFlags = UNDERWATER_NONE; @@ -468,7 +468,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo if (!info) { LOG_ERROR("entities.player.cheat", "Player::Create: Possible hacking attempt: Account %u tried to create a character named '%s' with an invalid race/class pair (%u/%u) - refusing to do so.", - GetSession()->GetAccountId(), m_name.c_str(), createInfo->Race, createInfo->Class); + GetSession()->GetAccountId(), m_name.c_str(), createInfo->Race, createInfo->Class); return false; } @@ -480,8 +480,9 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(createInfo->Class); if (!cEntry) { - LOG_ERROR("entities.player.cheat", "Player::Create: Possible hacking attempt: Account %u tried to create a character named '%s' with an invalid character class (%u) - refusing to do so (wrong DBC-files?)", - GetSession()->GetAccountId(), m_name.c_str(), createInfo->Class); + LOG_ERROR("entities.player.cheat", + "Player::Create: Possible hacking attempt: Account %u tried to create a character named '%s' with an invalid character class (%u) - refusing to do so (wrong DBC-files?)", + GetSession()->GetAccountId(), m_name.c_str(), createInfo->Class); return false; } @@ -496,14 +497,14 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo if (!IsValidGender(createInfo->Gender)) { LOG_ERROR("entities.player.cheat", "Player::Create: Possible hacking attempt: Account %u tried to create a character named '%s' with an invalid gender (%u) - refusing to do so", - GetSession()->GetAccountId(), m_name.c_str(), createInfo->Gender); + GetSession()->GetAccountId(), m_name.c_str(), createInfo->Gender); return false; } if (!ValidateAppearance(createInfo->Race, createInfo->Class, createInfo->Gender, createInfo->HairStyle, createInfo->HairColor, createInfo->Face, createInfo->FacialHair, createInfo->Skin, true)) { LOG_ERROR("entities.player.cheat", "Player::Create: Possible hacking attempt: Account %u tried to create a character named '%s' with invalid appearance attributes - refusing to do so", - GetSession()->GetAccountId(), m_name.c_str()); + GetSession()->GetAccountId(), m_name.c_str()); return false; } @@ -547,8 +548,8 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo // set starting level uint32 start_level = GetClass() != CLASS_DEATH_KNIGHT - ? CONF_GET_INT("StartPlayerLevel") - : CONF_GET_INT("StartDeathKnightPlayerLevel"); + ? CONF_GET_INT("StartPlayerLevel") + : CONF_GET_INT("StartDeathKnightPlayerLevel"); if (m_session->HasPermission(rbac::RBAC_PERM_USE_START_GM_LEVEL)) { @@ -613,12 +614,12 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo { switch (iProto->Spells[0].SpellCategory) { - case SPELL_CATEGORY_FOOD: // food - count = GetClass() == CLASS_DEATH_KNIGHT ? 10 : 4; - break; - case SPELL_CATEGORY_DRINK: // drink - count = 2; - break; + case SPELL_CATEGORY_FOOD: // food + count = GetClass() == CLASS_DEATH_KNIGHT ? 10 : 4; + break; + case SPELL_CATEGORY_DRINK: // drink + count = 2; + break; } if (iProto->GetMaxStackSize() < count) count = iProto->GetMaxStackSize(); @@ -673,7 +674,7 @@ bool Player::Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) { LOG_DEBUG("entities.player.items", "Player::StoreNewItemInBestSlots: Player '%s' (%s) creates initial item (ItemID: %u, Count: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), titem_id, titem_amount); + GetName().c_str(), GetGUID().ToString().c_str(), titem_id, titem_amount); // attempt equip by one while (titem_amount > 0) @@ -703,7 +704,7 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) // item can't be added LOG_ERROR("entities.player.items", "Player::StoreNewItemInBestSlots: Player '%s' (%s) can't equip or store initial item (ItemID: %u, Race: %u, Class: %u, InventoryResult: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), titem_id, GetRace(), GetClass(), msg); + GetName().c_str(), GetGUID().ToString().c_str(), titem_id, GetRace(), GetClass(), msg); return false; } @@ -741,18 +742,18 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) uint32 resist = 0; switch (type) { - case DAMAGE_LAVA: - case DAMAGE_SLIME: - { - DamageInfo dmgInfo(this, this, damage, nullptr, type == DAMAGE_LAVA ? SPELL_SCHOOL_MASK_FIRE : SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, BASE_ATTACK); - Unit::CalcAbsorbResist(dmgInfo); - absorb = dmgInfo.GetAbsorb(); - resist = dmgInfo.GetResist(); - damage = dmgInfo.GetDamage(); - break; - } - default: - break; + case DAMAGE_LAVA: + case DAMAGE_SLIME: + { + DamageInfo dmgInfo(this, this, damage, nullptr, type == DAMAGE_LAVA ? SPELL_SCHOOL_MASK_FIRE : SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, BASE_ATTACK); + Unit::CalcAbsorbResist(dmgInfo); + absorb = dmgInfo.GetAbsorb(); + resist = dmgInfo.GetResist(); + damage = dmgInfo.GetDamage(); + break; + } + default: + break; } Unit::DealDamageMods(this, damage, &absorb); @@ -772,7 +773,7 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) if (type == DAMAGE_FALL) // DealDamage does not apply item durability loss from self-induced damage. { LOG_DEBUG("entities.player", "Player::EnvironmentalDamage: Player '%s' (%s) fall to death, losing %f durability", - GetName().c_str(), GetGUID().ToString().c_str(), CONF_GET_FLOAT("DurabilityLoss.OnDeath")); + GetName().c_str(), GetGUID().ToString().c_str(), CONF_GET_FLOAT("DurabilityLoss.OnDeath")); DurabilityLossAll(CONF_GET_FLOAT("DurabilityLoss.OnDeath"), false); // durability lost message SendDurabilityLoss(); @@ -788,25 +789,25 @@ int32 Player::getMaxTimer(MirrorTimerType timer) const { switch (timer) { - case FATIGUE_TIMER: - return MINUTE * IN_MILLISECONDS; - case BREATH_TIMER: - { - if (!IsAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || GetSession()->GetSecurity() >= AccountTypes(CONF_GET_INT("DisableWaterBreath"))) - return DISABLED_MIRROR_TIMER; + case FATIGUE_TIMER: + return MINUTE * IN_MILLISECONDS; + case BREATH_TIMER: + { + if (!IsAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || GetSession()->GetSecurity() >= AccountTypes(CONF_GET_INT("DisableWaterBreath"))) + return DISABLED_MIRROR_TIMER; - int32 UnderWaterTime = 3 * MINUTE * IN_MILLISECONDS; - UnderWaterTime *= GetTotalAuraMultiplier(SPELL_AURA_MOD_WATER_BREATHING); - return UnderWaterTime; - } - case FIRE_TIMER: - { - if (!IsAlive()) - return DISABLED_MIRROR_TIMER; - return 1 * IN_MILLISECONDS; - } - default: - return 0; + int32 UnderWaterTime = 3 * MINUTE * IN_MILLISECONDS; + UnderWaterTime *= GetTotalAuraMultiplier(SPELL_AURA_MOD_WATER_BREATHING); + return UnderWaterTime; + } + case FIRE_TIMER: + { + if (!IsAlive()) + return DISABLED_MIRROR_TIMER; + return 1 * IN_MILLISECONDS; + } + default: + return 0; } } @@ -1319,7 +1320,7 @@ void Player::Update(uint32 p_time) Pet* pet = GetPet(); if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityRange()) && !pet->isPossessed()) - //if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID()))) + //if (pet && !pet->IsWithinDistInMap(this, GetMap()->GetVisibilityDistance()) && (GetCharmGUID() && (pet->GetGUID() != GetCharmGUID()))) RemovePet(pet, PET_SAVE_NOT_IN_SLOT, true); if (IsAlive()) @@ -1543,7 +1544,7 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) if (!itemId || *itemId) { LOG_WARN("entities.player.loading", "Player %u has invalid equipment '%s' in `equipmentcache` at index %u. Skipped.", - guid, (visualBase < equipment.size()) ? std::string(equipment[visualBase]).c_str() : "", visualBase); + guid, (visualBase < equipment.size()) ? std::string(equipment[visualBase]).c_str() : "", visualBase); } *data << uint32(0); @@ -1556,12 +1557,12 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) SpellItemEnchantmentEntry const* enchant = nullptr; Optional enchants; - if ((visualBase+1) < equipment.size()) + if ((visualBase + 1) < equipment.size()) enchants = Warhead::StringTo(equipment[visualBase + 1]); if (!enchants) { LOG_WARN("entities.player.loading", "Player %u has invalid enchantment info '%s' in `equipmentcache` at index %u. Skipped.", - guid, ((visualBase+1) < equipment.size()) ? std::string(equipment[visualBase + 1]).c_str() : "", visualBase + 1); + guid, ((visualBase + 1) < equipment.size()) ? std::string(equipment[visualBase + 1]).c_str() : "", visualBase + 1); enchants = 0; } for (uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot) @@ -1619,7 +1620,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (!MapManager::IsValidMapCoord(mapid, x, y, z, orientation)) { LOG_ERROR("maps", "Player::TeleportTo: Invalid map (%d) or invalid coordinates (X: %f, Y: %f, Z: %f, O: %f) given when teleporting player '%s' (%s, MapID: %d, X: %f, Y: %f, Z: %f, O: %f).", - mapid, x, y, z, orientation, GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + mapid, x, y, z, orientation, GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); return false; } @@ -1644,7 +1645,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (GetSession()->Expansion() < mEntry->Expansion()) { LOG_DEBUG("maps", "Player '%s' (%s) using client without required expansion tried teleport to non accessible map (MapID: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), mapid); + GetName().c_str(), GetGUID().ToString().c_str(), mapid); if (Transport* transport = GetTransport()) { @@ -1950,7 +1951,7 @@ void Player::RemoveFromWorld() if (WorldObject* viewpoint = GetViewpoint()) { LOG_ERROR("entities.player", "Player::RemoveFromWorld: Player '%s' (%s) has viewpoint (Entry:%u, Type: %u) when removed from world", - GetName().c_str(), GetGUID().ToString().c_str(), viewpoint->GetEntry(), viewpoint->GetTypeId()); + GetName().c_str(), GetGUID().ToString().c_str(), viewpoint->GetEntry(), viewpoint->GetTypeId()); SetViewpoint(viewpoint, false); } } @@ -1996,11 +1997,9 @@ void Player::RegenerateAll() { // Not in combat or they have regeneration if (!IsInCombat() || IsPolymorphed() || m_baseHealthRegen || - HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) || - HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT)) - { + HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT) || + HasAuraType(SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT)) RegenerateHealth(); - } Regenerate(POWER_RAGE); if (GetClass() == CLASS_DEATH_KNIGHT) @@ -2059,46 +2058,49 @@ void Player::Regenerate(Powers power) switch (power) { - case POWER_MANA: - { - bool recentCast = IsUnderLastManaUseEffect(); - float ManaIncreaseRate = CONF_GET_FLOAT("Rate.Mana"); + case POWER_MANA: + { + bool recentCast = IsUnderLastManaUseEffect(); + float ManaIncreaseRate = CONF_GET_FLOAT("Rate.Mana"); - if (GetLevel() < 15) - ManaIncreaseRate = CONF_GET_FLOAT("Rate.Mana") * (2.066f - (GetLevel() * 0.066f)); + if (GetLevel() < 15) + ManaIncreaseRate = CONF_GET_FLOAT("Rate.Mana") * (2.066f - (GetLevel() * 0.066f)); - if (recentCast) // Warhead Updates Mana in intervals of 2s, which is correct - addvalue += GetFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER) * ManaIncreaseRate * 0.001f * m_regenTimer; - else - addvalue += GetFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER) * ManaIncreaseRate * 0.001f * m_regenTimer; - } break; - case POWER_RAGE: // Regenerate rage + if (recentCast) // Warhead Updates Mana in intervals of 2s, which is correct + addvalue += GetFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER) * ManaIncreaseRate * 0.001f * m_regenTimer; + else + addvalue += GetFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER) * ManaIncreaseRate * 0.001f * m_regenTimer; + } + break; + case POWER_RAGE: // Regenerate rage + { + if (!IsInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) { - if (!IsInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) - { - float RageDecreaseRate = CONF_GET_FLOAT("Rate.Rage.Loss"); - addvalue += -20 * RageDecreaseRate; // 2 rage by tick (= 2 seconds => 1 rage/sec) - } - } break; - case POWER_ENERGY: // Regenerate energy (rogue) - addvalue += 0.01f * m_regenTimer * CONF_GET_FLOAT("Rate.Energy"); - break; - case POWER_RUNIC_POWER: + float RageDecreaseRate = CONF_GET_FLOAT("Rate.Rage.Loss"); + addvalue += -20 * RageDecreaseRate; // 2 rage by tick (= 2 seconds => 1 rage/sec) + } + } + break; + case POWER_ENERGY: // Regenerate energy (rogue) + addvalue += 0.01f * m_regenTimer * CONF_GET_FLOAT("Rate.Energy"); + break; + case POWER_RUNIC_POWER: + { + if (!IsInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) { - if (!IsInCombat() && !HasAuraType(SPELL_AURA_INTERRUPT_REGEN)) - { - float RunicPowerDecreaseRate = CONF_GET_FLOAT("Rate.RunicPower.Loss"); - addvalue += -30 * RunicPowerDecreaseRate; // 3 RunicPower by tick - } - } break; - case POWER_RUNE: - case POWER_FOCUS: - case POWER_HAPPINESS: - break; - case POWER_HEALTH: - return; - default: - break; + float RunicPowerDecreaseRate = CONF_GET_FLOAT("Rate.RunicPower.Loss"); + addvalue += -30 * RunicPowerDecreaseRate; // 3 RunicPower by tick + } + } + break; + case POWER_RUNE: + case POWER_FOCUS: + case POWER_HAPPINESS: + break; + case POWER_HEALTH: + return; + default: + break; } // Mana regen calculated in Player::UpdateManaRegen() @@ -2208,20 +2210,20 @@ void Player::ResetAllPowers() SetFullHealth(); switch (GetPowerType()) { - case POWER_MANA: - SetFullPower(POWER_MANA); - break; - case POWER_RAGE: - SetPower(POWER_RAGE, 0); - break; - case POWER_ENERGY: - SetFullPower(POWER_ENERGY); - break; - case POWER_RUNIC_POWER: - SetPower(POWER_RUNIC_POWER, 0); - break; - default: - break; + case POWER_MANA: + SetFullPower(POWER_MANA); + break; + case POWER_RAGE: + SetPower(POWER_RAGE, 0); + break; + case POWER_ENERGY: + SetFullPower(POWER_ENERGY); + break; + case POWER_RUNIC_POWER: + SetPower(POWER_RUNIC_POWER, 0); + break; + default: + break; } } @@ -2229,16 +2231,16 @@ bool Player::CanInteractWithQuestGiver(Object* questGiver) const { switch (questGiver->GetTypeId()) { - case TYPEID_UNIT: - return GetNPCIfCanInteractWith(questGiver->GetGUID(), UNIT_NPC_FLAG_QUESTGIVER) != nullptr; - case TYPEID_GAMEOBJECT: - return GetGameObjectIfCanInteractWith(questGiver->GetGUID(), GAMEOBJECT_TYPE_QUESTGIVER) != nullptr; - case TYPEID_PLAYER: - return IsAlive() && questGiver->ToPlayer()->IsAlive(); - case TYPEID_ITEM: - return IsAlive(); - default: - break; + case TYPEID_UNIT: + return GetNPCIfCanInteractWith(questGiver->GetGUID(), UNIT_NPC_FLAG_QUESTGIVER) != nullptr; + case TYPEID_GAMEOBJECT: + return GetGameObjectIfCanInteractWith(questGiver->GetGUID(), GAMEOBJECT_TYPE_QUESTGIVER) != nullptr; + case TYPEID_PLAYER: + return IsAlive() && questGiver->ToPlayer()->IsAlive(); + case TYPEID_ITEM: + return IsAlive(); + default: + break; } return false; } @@ -2448,18 +2450,22 @@ bool Player::IsGroupVisibleFor(Player const* p) const { switch (CONF_GET_INT("Visibility.GroupMode")) { - default: return IsInSameGroupWith(p); - case 1: return IsInSameRaidWith(p); - case 2: return GetTeam() == p->GetTeam(); - case 3: return false; + default: + return IsInSameGroupWith(p); + case 1: + return IsInSameRaidWith(p); + case 2: + return GetTeam() == p->GetTeam(); + case 3: + return false; } } bool Player::IsInSameGroupWith(Player const* p) const { return p == this || (GetGroup() != nullptr && - GetGroup() == p->GetGroup() && - GetGroup()->SameSubGroup(this, p)); + GetGroup() == p->GetGroup() && + GetGroup()->SameSubGroup(this, p)); } bool Player::IsInSameRaidWith(Player const* p) const @@ -2747,7 +2753,7 @@ void Player::InitStatsForLevel(bool reapplyMods) //set create powers SetCreateMana(classInfo.basemana); - SetArmor(int32(m_createStats[STAT_AGILITY]*2)); + SetArmor(int32(m_createStats[STAT_AGILITY] * 2)); InitStatBuffMods(); @@ -2788,7 +2794,7 @@ void Player::InitStatsForLevel(bool reapplyMods) // Init spell schools (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset for (uint8 i = 0; i < 7; ++i) - SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1+i, 0.0f); + SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1 + i, 0.0f); SetFloatValue(PLAYER_PARRY_PERCENTAGE, 0.0f); SetFloatValue(PLAYER_BLOCK_PERCENTAGE, 0.0f); @@ -2798,7 +2804,7 @@ void Player::InitStatsForLevel(bool reapplyMods) SetFloatValue(PLAYER_DODGE_PERCENTAGE, 0.0f); // set armor (resistance 0) to original value (create_agility*2) - SetArmor(int32(m_createStats[STAT_AGILITY]*2)); + SetArmor(int32(m_createStats[STAT_AGILITY] * 2)); SetFloatValue(UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + SPELL_SCHOOL_NORMAL, 0.0f); SetFloatValue(UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + SPELL_SCHOOL_NORMAL, 0.0f); // set other resistance to original value (0) @@ -2833,12 +2839,12 @@ void Player::InitStatsForLevel(bool reapplyMods) // cleanup unit flags (will be re-applied if need at aura load). RemoveFlag(UNIT_FIELD_FLAGS, - 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_NOT_SELECTABLE | - UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT ); + 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_NOT_SELECTABLE | + UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT ); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); // must be set SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER);// must be set @@ -2892,7 +2898,7 @@ void Player::SendInitialSpells() data << uint32(itr->first); data << uint16(0); // it's not slot id - spellCount +=1; + spellCount += 1; } data.put(countPos, spellCount); // write real count value @@ -3163,7 +3169,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent // not do anything if already known in expected state if (itr->second.state != PLAYERSPELL_REMOVED && itr->second.active == active && - itr->second.dependent == dependent && itr->second.disabled == disabled) + itr->second.dependent == dependent && itr->second.disabled == disabled) { if (!IsInWorld() && !learning) // explicitly load from DB and then exist in it already and set correctly itr->second.state = PLAYERSPELL_UNCHANGED; @@ -3226,7 +3232,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent disabled_case = true; } else switch (itr->second.state) - { + { case PLAYERSPELL_UNCHANGED: // known saved spell return false; case PLAYERSPELL_REMOVED: // re-learning removed not saved spell @@ -3243,7 +3249,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent return false; } - } + } } if (!disabled_case) // skip new spell adding if spell already known (disabled spells case) @@ -3368,7 +3374,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent if (uint32 freeProfs = GetFreePrimaryProfessionPoints()) { if (spellInfo->IsPrimaryProfessionFirstRank()) - SetFreePrimaryProfessions(freeProfs-1); + SetFreePrimaryProfessions(freeProfs - 1); } SkillLineAbilityMapBounds skill_bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellId); @@ -3409,13 +3415,14 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent ///@todo: confirm if rogues start with lockpicking skill at level 1 but only receive the spell to use it at level 16 // Also added for runeforging. It's already confirmed this happens upon learning for Death Knights, not from character creation. - if ((_spell_idx->second->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->ID)) || ((pSkill->ID == SKILL_LOCKPICKING || pSkill->ID == SKILL_RUNEFORGING) && _spell_idx->second->TrivialSkillLineRankHigh == 0)) + if ((_spell_idx->second->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->ID)) || ((pSkill->ID == SKILL_LOCKPICKING || pSkill->ID == SKILL_RUNEFORGING) + && _spell_idx->second->TrivialSkillLineRankHigh == 0)) LearnDefaultSkill(pSkill->ID, 0); if (pSkill->ID == SKILL_MOUNTS && !Has310Flyer(false)) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) + spellInfo->Effects[i].CalcValue() == 310) SetHas310Flyer(true); } } @@ -3481,7 +3488,7 @@ bool Player::HandlePassiveSpellLearn(SpellInfo const* spellInfo) // talent dependent passives activated at form apply have proper stance data ShapeshiftForm form = GetShapeshiftForm(); bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (UI64LIT(1) << (form - 1)))) || - (!form && spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT))); + (!form && spellInfo->HasAttribute(SPELL_ATTR2_NOT_NEED_SHAPESHIFT))); // Check EquippedItemClass // passive spells which apply aura and have an item requirement are to be added manually, instead of casted @@ -3605,7 +3612,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id); if (spellInfo && spellInfo->IsPrimaryProfessionFirstRank()) { - uint32 freeProfs = GetFreePrimaryProfessionPoints()+1; + uint32 freeProfs = GetFreePrimaryProfessionPoints() + 1; if (freeProfs <= CONF_GET_UINT("MaxPrimaryTradeSkill")) SetFreePrimaryProfessions(freeProfs); } @@ -3665,7 +3672,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) + spellInfo->Effects[i].CalcValue() == 310) { Has310Flyer(true, spell_id); // with true as first argument its also used to set/remove the flag break; @@ -3771,7 +3778,7 @@ bool Player::Has310Flyer(bool checkAllSpells, uint32 excludeSpellId) spellInfo = sSpellMgr->AssertSpellInfo(itr->first); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED && - spellInfo->Effects[i].CalcValue() == 310) + spellInfo->Effects[i].CalcValue() == 310) { SetHas310Flyer(true); return true; @@ -3789,7 +3796,7 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns) GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool { SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first); - return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS; + return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && spellInfo->CategoryRecoveryTime < 10 * MINUTE* IN_MILLISECONDS; }, true); // pet cooldowns @@ -3801,31 +3808,31 @@ void Player::RemoveArenaSpellCooldowns(bool removeActivePetCooldowns) uint32 Player::ResetTalentsCost() const { // The first time reset costs 1 gold - if (m_resetTalentsCost < 1*GOLD) - return 1*GOLD; + if (m_resetTalentsCost < 1 * GOLD) + return 1 * GOLD; // then 5 gold - else if (m_resetTalentsCost < 5*GOLD) - return 5*GOLD; + else if (m_resetTalentsCost < 5 * GOLD) + return 5 * GOLD; // After that it increases in increments of 5 gold - else if (m_resetTalentsCost < 10*GOLD) - return 10*GOLD; + else if (m_resetTalentsCost < 10 * GOLD) + return 10 * GOLD; else { - uint64 months = (GameTime::GetGameTime() - m_resetTalentsTime)/MONTH; + uint64 months = (GameTime::GetGameTime() - m_resetTalentsTime) / MONTH; if (months > 0) { // This cost will be reduced by a rate of 5 gold per month - int32 new_cost = int32(m_resetTalentsCost - 5*GOLD*months); + int32 new_cost = int32(m_resetTalentsCost - 5 * GOLD * months); // to a minimum of 10 gold. - return (new_cost < 10*GOLD ? 10*GOLD : new_cost); + return (new_cost < 10 * GOLD ? 10 * GOLD : new_cost); } else { // After that it increases in increments of 5 gold - int32 new_cost = m_resetTalentsCost + 5*GOLD; + int32 new_cost = m_resetTalentsCost + 5 * GOLD; // until it hits a cap of 50 gold. - if (new_cost > 50*GOLD) - new_cost = 50*GOLD; + if (new_cost > 50 * GOLD) + new_cost = 50 * GOLD; return new_cost; } } @@ -3880,7 +3887,7 @@ bool Player::ResetTalents(bool no_cost) if ((GetClassMask() & talentTabInfo->ClassMask) == 0) continue; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { // skip non-existing talent ranks if (talentInfo->SpellRank[rank] == 0) @@ -4000,7 +4007,7 @@ bool Player::HasSpell(uint32 spell) const { PlayerSpellMap::const_iterator itr = m_spells.find(spell); return (itr != m_spells.end() && itr->second.state != PLAYERSPELL_REMOVED && - !itr->second.disabled); + !itr->second.disabled); } bool Player::HasTalent(uint32 spell, uint8 spec) const @@ -4013,7 +4020,7 @@ bool Player::HasActiveSpell(uint32 spell) const { PlayerSpellMap::const_iterator itr = m_spells.find(spell); return (itr != m_spells.end() && itr->second.state != PLAYERSPELL_REMOVED && - itr->second.active && !itr->second.disabled); + itr->second.active && !itr->second.disabled); } /** @@ -4082,218 +4089,218 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe switch (charDelete_method) { - // Completely remove from the database - case CHAR_DELETE_REMOVE: - { - sMailMgr->RemoveAllMailsFor(guid); + // Completely remove from the database + case CHAR_DELETE_REMOVE: + { + sMailMgr->RemoveAllMailsFor(guid); - // Unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet. - // NOW we can finally clear other DB data related to character - CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_IDS); - stmt->setUInt32(0, guid); - PreparedQueryResult resultPets = CharacterDatabase.Query(stmt); + // Unsummon and delete for pets in world is not required: player deleted from CLI or character list with not loaded pet. + // NOW we can finally clear other DB data related to character + CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PET_IDS); + stmt->setUInt32(0, guid); + PreparedQueryResult resultPets = CharacterDatabase.Query(stmt); - if (resultPets) + if (resultPets) + { + do { - do - { - ObjectGuid::LowType petguidlow = (*resultPets)[0].GetUInt32(); - Pet::DeleteFromDB(petguidlow); - } while (resultPets->NextRow()); - } + ObjectGuid::LowType petguidlow = (*resultPets)[0].GetUInt32(); + Pet::DeleteFromDB(petguidlow); + } while (resultPets->NextRow()); + } - // Delete char from social list of online chars - stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_SOCIAL); - stmt->setUInt32(0, guid); + // Delete char from social list of online chars + stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_SOCIAL); + stmt->setUInt32(0, guid); - if (PreparedQueryResult resultFriends = CharacterDatabase.Query(stmt)) + if (PreparedQueryResult resultFriends = CharacterDatabase.Query(stmt)) + { + do { - do + if (Player* playerFriend = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, 0, (*resultFriends)[0].GetUInt32()))) { - if (Player* playerFriend = ObjectAccessor::FindPlayer(ObjectGuid(HighGuid::Player, 0, (*resultFriends)[0].GetUInt32()))) - { - playerFriend->GetSocial()->RemoveFromSocialList(playerguid, SOCIAL_FLAG_ALL); - sSocialMgr->SendFriendStatus(playerFriend, FRIEND_REMOVED, playerguid); - } - } while (resultFriends->NextRow()); - } - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER); - stmt->setUInt32(0, guid); - trans->Append(stmt); + playerFriend->GetSocial()->RemoveFromSocialList(playerguid, SOCIAL_FLAG_ALL); + sSocialMgr->SendFriendStatus(playerFriend, FRIEND_REMOVED, playerguid); + } + } while (resultFriends->NextRow()); + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_ACCOUNT_DATA); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_ARENA_STATS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_ARENA_STATS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_BGDATA); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_BATTLEGROUND_RANDOM); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_BGDATA); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GIFT); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_BATTLEGROUND_RANDOM); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GIFT); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REPUTATION); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REPUTATION); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_COOLDOWNS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL); + stmt->setUInt32(0, guid); + trans->Append(stmt); - if (CONF_GET_BOOL("DeletedCharacterTicketTrace")) - { - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION); - stmt->setUInt32(0, guid); - trans->Append(stmt); - } - else - { - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_GM_TICKETS); - stmt->setUInt32(0, guid); - trans->Append(stmt); - } + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_COOLDOWNS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE_BY_OWNER); + if (CONF_GET_BOOL("DeletedCharacterTicketTrace")) + { + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PLAYER_GM_TICKETS_ON_CHAR_DELETION); stmt->setUInt32(0, guid); trans->Append(stmt); - - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); + } + else + { + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_GM_TICKETS); stmt->setUInt32(0, guid); trans->Append(stmt); + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE_BY_OWNER); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_OWNER); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME_BY_OWNER); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENTS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_OWNER); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME_BY_OWNER); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_EQUIPMENTSETS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENTS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG_BY_PLAYER); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOG_BY_PLAYER); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_EQUIPMENTSETS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GLYPHS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG_BY_PLAYER); + stmt->setUInt32(0, guid); + stmt->setUInt32(1, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_DAILY); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOG_BY_PLAYER); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_WEEKLY); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_GLYPHS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_MONTHLY); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_DAILY); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_SEASONAL); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_WEEKLY); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_TALENT); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_MONTHLY); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILLS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_QUESTSTATUS_SEASONAL); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_STATS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_TALENT); + stmt->setUInt32(0, guid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_FISHINGSTEPS); - stmt->setUInt32(0, guid); - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILLS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - Corpse::DeleteFromDB(playerguid, trans); - break; - } - // The character gets unlinked from the account, the name gets freed up and appears as deleted ingame - case CHAR_DELETE_UNLINK: - { - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_DELETE_INFO); - stmt->setUInt32(0, guid); - trans->Append(stmt); - break; - } - default: - LOG_ERROR("entities.player.cheat", "Player::DeleteFromDB: Tried to delete player (%s) with unsupported delete method (%u).", - playerguid.ToString().c_str(), charDelete_method); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_STATS); + stmt->setUInt32(0, guid); + trans->Append(stmt); - if (trans->GetSize() > 0) - CharacterDatabase.CommitTransaction(trans); - return; + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_FISHINGSTEPS); + stmt->setUInt32(0, guid); + trans->Append(stmt); + + Corpse::DeleteFromDB(playerguid, trans); + break; + } + // The character gets unlinked from the account, the name gets freed up and appears as deleted ingame + case CHAR_DELETE_UNLINK: + { + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_DELETE_INFO); + stmt->setUInt32(0, guid); + trans->Append(stmt); + break; + } + default: + LOG_ERROR("entities.player.cheat", "Player::DeleteFromDB: Tried to delete player (%s) with unsupported delete method (%u).", + playerguid.ToString().c_str(), charDelete_method); + + if (trans->GetSize() > 0) + CharacterDatabase.CommitTransaction(trans); + return; } CharacterDatabase.CommitTransaction(trans); @@ -4335,13 +4342,12 @@ void Player::DeleteOldCharacters(uint32 keepDays) if (result) { - LOG_DEBUG("entities.player", "Player::DeleteOldCharacters: Found " UI64FMTD " character(s) to delete", result->GetRowCount()); - do - { + LOG_DEBUG("entities.player", "Player::DeleteOldCharacters: Found " UI64FMTD " character(s) to delete", result->GetRowCount()); + do + { Field* fields = result->Fetch(); Player::DeleteFromDB(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()), fields[1].GetUInt32(), true, true); - } - while (result->NextRow()); + } while (result->NextRow()); } } @@ -4350,13 +4356,21 @@ void Player::SetMovement(PlayerMovementType pType) WorldPacket data; switch (pType) { - case MOVE_ROOT: data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size()+4); break; - case MOVE_UNROOT: data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size()+4); break; - case MOVE_WATER_WALK: data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size()+4); break; - case MOVE_LAND_WALK: data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size()+4); break; - default: - LOG_ERROR("entities.player", "Player::SetMovement: Unsupported move type (%d), data not sent to client.", pType); - return; + case MOVE_ROOT: + data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size() + 4); + break; + case MOVE_UNROOT: + data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size() + 4); + break; + case MOVE_WATER_WALK: + data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size() + 4); + break; + case MOVE_LAND_WALK: + data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size() + 4); + break; + default: + LOG_ERROR("entities.player", "Player::SetMovement: Unsupported move type (%d), data not sent to client.", pType); + return; } data << GetPackGUID(); data << uint32(0); @@ -4490,14 +4504,12 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) CastSpell(this, raceEntry->ResSicknessSpellID, true); // not full duration - if (int32(GetLevel()) < startLevel+9) + if (int32(GetLevel()) < startLevel + 9) { - int32 delta = (int32(GetLevel()) - startLevel + 1)*MINUTE; + int32 delta = (int32(GetLevel()) - startLevel + 1) * MINUTE; if (Aura* aur = GetAura(raceEntry->ResSicknessSpellID, GetGUID())) - { - aur->SetDuration(delta*IN_MILLISECONDS); - } + aur->SetDuration(delta * IN_MILLISECONDS); } } } @@ -4663,7 +4675,7 @@ void Player::DurabilityLoss(Item* item, double percent) if (!pMaxDurability) return; - uint32 pDurabilityLoss = uint32(pMaxDurability*percent); + uint32 pDurabilityLoss = uint32(pMaxDurability * percent); if (pDurabilityLoss < 1) pDurabilityLoss = 1; @@ -4766,7 +4778,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g if (cost) { uint32 LostDurability = maxDurability - curDurability; - if (LostDurability>0) + if (LostDurability > 0) { ItemTemplate const* ditemProto = item->GetTemplate(); @@ -4774,34 +4786,34 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g if (!dcost) { LOG_ERROR("entities.player.items", "Player::DurabilityRepair: Player '%s' (%s) tried to repair an item (ItemID: %u) with invalid item level %u", - GetName().c_str(), GetGUID().ToString().c_str(), ditemProto->ItemId, ditemProto->ItemLevel); + GetName().c_str(), GetGUID().ToString().c_str(), ditemProto->ItemId, ditemProto->ItemLevel); return TotalCost; } - uint32 dQualitymodEntryId = (ditemProto->Quality+1)*2; + uint32 dQualitymodEntryId = (ditemProto->Quality + 1) * 2; DurabilityQualityEntry const* dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId); if (!dQualitymodEntry) { LOG_ERROR("entities.player.items", "Player::DurabilityRepair: Player '%s' (%s) tried to repair an item (ItemID: %u) with invalid QualitymodEntry %u", - GetName().c_str(), GetGUID().ToString().c_str(), ditemProto->ItemId, dQualitymodEntryId); + GetName().c_str(), GetGUID().ToString().c_str(), ditemProto->ItemId, dQualitymodEntryId); return TotalCost; } uint32 dmultiplier; switch (ditemProto->Class) { - case ITEM_CLASS_WEAPON: - dmultiplier = dcost->WeaponSubClassCost[ditemProto->SubClass]; - break; - case ITEM_CLASS_ARMOR: - dmultiplier = dcost->ArmorSubClassCost[ditemProto->SubClass]; - break; - default: - dmultiplier = 0; - break; + case ITEM_CLASS_WEAPON: + dmultiplier = dcost->WeaponSubClassCost[ditemProto->SubClass]; + break; + case ITEM_CLASS_ARMOR: + dmultiplier = dcost->ArmorSubClassCost[ditemProto->SubClass]; + break; + default: + dmultiplier = 0; + break; } - uint32 costs = uint32(LostDurability*dmultiplier*double(dQualitymodEntry->Data)); + uint32 costs = uint32(LostDurability * dmultiplier * double(dQualitymodEntry->Data)); costs = uint32(costs * discountMod * CONF_GET_FLOAT("Rate.RepairCost")); @@ -4813,7 +4825,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g if (GetGuildId() == 0) { LOG_DEBUG("entities.player.items", "Player::DurabilityRepair: Player '%s' (%s) tried to repair item in a guild bank but is not member of a guild", - GetName().c_str(), GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str()); return TotalCost; } @@ -4829,7 +4841,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g else if (!HasEnoughMoney(costs)) { LOG_DEBUG("entities.player.items", "Player::DurabilityRepair: Player '%s' (%s) has not enough money to repair item", - GetName().c_str(), GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str()); return TotalCost; } else @@ -5030,7 +5042,7 @@ void Player::HandleBaseModFlatValue(BaseModGroup modGroup, float amount, bool ap if (modGroup >= BASEMOD_END) { LOG_ERROR("spells", "Player::HandleBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", - modGroup, FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); + modGroup, FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -5043,7 +5055,7 @@ void Player::ApplyBaseModPctValue(BaseModGroup modGroup, float pct) if (modGroup >= BASEMOD_END) { LOG_ERROR("spells", "Player::HandleBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", - modGroup, FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); + modGroup, FLAT_MOD, GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -5076,18 +5088,18 @@ void Player::UpdateDamageDoneMods(WeaponAttackType attackType, int32 skipEnchant UnitMods unitMod; switch (attackType) { - case BASE_ATTACK: - unitMod = UNIT_MOD_DAMAGE_MAINHAND; - break; - case OFF_ATTACK: - unitMod = UNIT_MOD_DAMAGE_OFFHAND; - break; - case RANGED_ATTACK: - unitMod = UNIT_MOD_DAMAGE_RANGED; - break; - default: - ABORT(); - break; + case BASE_ATTACK: + unitMod = UNIT_MOD_DAMAGE_MAINHAND; + break; + case OFF_ATTACK: + unitMod = UNIT_MOD_DAMAGE_OFFHAND; + break; + case RANGED_ATTACK: + unitMod = UNIT_MOD_DAMAGE_RANGED; + break; + default: + ABORT(); + break; } float amount = 0.0f; @@ -5108,15 +5120,15 @@ void Player::UpdateDamageDoneMods(WeaponAttackType attackType, int32 skipEnchant { switch (enchantmentEntry->Effect[i]) { - case ITEM_ENCHANTMENT_TYPE_DAMAGE: - amount += enchantmentEntry->EffectPointsMin[i]; - break; - case ITEM_ENCHANTMENT_TYPE_TOTEM: - if (GetClass() == CLASS_SHAMAN) - amount += enchantmentEntry->EffectPointsMin[i] * item->GetTemplate()->Delay / 1000.0f; - break; - default: - break; + case ITEM_ENCHANTMENT_TYPE_DAMAGE: + amount += enchantmentEntry->EffectPointsMin[i]; + break; + case ITEM_ENCHANTMENT_TYPE_TOTEM: + if (GetClass() == CLASS_SHAMAN) + amount += enchantmentEntry->EffectPointsMin[i] * item->GetTemplate()->Delay / 1000.0f; + break; + default: + break; } } } @@ -5131,11 +5143,20 @@ void Player::UpdateBaseModGroup(BaseModGroup modGroup) switch (modGroup) { - case CRIT_PERCENTAGE: UpdateCritPercentage(BASE_ATTACK); break; - case RANGED_CRIT_PERCENTAGE: UpdateCritPercentage(RANGED_ATTACK); break; - case OFFHAND_CRIT_PERCENTAGE: UpdateCritPercentage(OFF_ATTACK); break; - case SHIELD_BLOCK_VALUE: UpdateShieldBlockValue(); break; - default: break; + case CRIT_PERCENTAGE: + UpdateCritPercentage(BASE_ATTACK); + break; + case RANGED_CRIT_PERCENTAGE: + UpdateCritPercentage(RANGED_ATTACK); + break; + case OFFHAND_CRIT_PERCENTAGE: + UpdateCritPercentage(OFF_ATTACK); + break; + case SHIELD_BLOCK_VALUE: + UpdateShieldBlockValue(); + break; + default: + break; } } @@ -5144,7 +5165,7 @@ float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const if (modGroup >= BASEMOD_END || modType >= MOD_END) { LOG_ERROR("spells", "Player::GetBaseModValue: Invalid BaseModGroup/BaseModType (%u/%u) for player '%s' (%s)", - modGroup, modType, GetName().c_str(), GetGUID().ToString().c_str()); + modGroup, modType, GetName().c_str(), GetGUID().ToString().c_str()); return 0.0f; } @@ -5156,7 +5177,7 @@ float Player::GetTotalBaseModValue(BaseModGroup modGroup) const if (modGroup >= BASEMOD_END) { LOG_ERROR("spells", "Player::GetTotalBaseModValue: Invalid BaseModGroup (%u) for player '%s' (%s)", - modGroup, GetName().c_str(), GetGUID().ToString().c_str()); + modGroup, GetName().c_str(), GetGUID().ToString().c_str()); return 0.0f; } @@ -5177,46 +5198,46 @@ float Player::GetMeleeCritFromAgility() const if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); - GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass - 1); + GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (critBase == nullptr || critRatio == nullptr) return 0.0f; - float crit = critBase->Data + GetStat(STAT_AGILITY)*critRatio->Data; - return crit*100.0f; + float crit = critBase->Data + GetStat(STAT_AGILITY) * critRatio->Data; + return crit * 100.0f; } -void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) const +void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing) const { // Table for base dodge values const float dodge_base[MAX_CLASSES] = { - 0.036640f, // Warrior - 0.034943f, // Paladin + 0.036640f, // Warrior + 0.034943f, // Paladin -0.040873f, // Hunter - 0.020957f, // Rogue - 0.034178f, // Priest - 0.036640f, // DK - 0.021080f, // Shaman - 0.036587f, // Mage - 0.024211f, // Warlock - 0.0f, // ?? - 0.056097f // Druid + 0.020957f, // Rogue + 0.034178f, // Priest + 0.036640f, // DK + 0.021080f, // Shaman + 0.036587f, // Mage + 0.024211f, // Warlock + 0.0f, // ?? + 0.056097f // Druid }; // Crit/agility to dodge/agility coefficient multipliers; 3.2.0 increased required agility by 15% const float crit_to_dodge[MAX_CLASSES] = { - 0.85f/1.15f, // Warrior - 1.00f/1.15f, // Paladin - 1.11f/1.15f, // Hunter - 2.00f/1.15f, // Rogue - 1.00f/1.15f, // Priest - 0.85f/1.15f, // DK - 1.60f/1.15f, // Shaman - 1.00f/1.15f, // Mage - 0.97f/1.15f, // Warlock (?) - 0.0f, // ?? - 2.00f/1.15f // Druid + 0.85f / 1.15f, // Warrior + 1.00f / 1.15f, // Paladin + 1.11f / 1.15f, // Hunter + 2.00f / 1.15f, // Rogue + 1.00f / 1.15f, // Priest + 0.85f / 1.15f, // DK + 1.60f / 1.15f, // Shaman + 1.00f / 1.15f, // Mage + 0.97f / 1.15f, // Warlock (?) + 0.0f, // ?? + 2.00f / 1.15f // Druid }; uint8 level = GetLevel(); @@ -5226,7 +5247,7 @@ void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) cons level = GT_MAX_LEVEL; // Dodge per agility is proportional to crit per agility, which is available from DBC files - GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (dodgeRatio == nullptr || pclass > MAX_CLASSES) return; @@ -5235,8 +5256,8 @@ void Player::GetDodgeFromAgility(float &diminishing, float &nondiminishing) cons float bonus_agility = GetStat(STAT_AGILITY) - base_agility; // calculate diminishing (green in char screen) and non-diminishing (white) contribution - diminishing = 100.0f * bonus_agility * dodgeRatio->Data * crit_to_dodge[pclass-1]; - nondiminishing = 100.0f * (dodge_base[pclass-1] + base_agility * dodgeRatio->Data * crit_to_dodge[pclass-1]); + diminishing = 100.0f * bonus_agility * dodgeRatio->Data * crit_to_dodge[pclass - 1]; + nondiminishing = 100.0f * (dodge_base[pclass - 1] + base_agility * dodgeRatio->Data * crit_to_dodge[pclass - 1]); } float Player::GetSpellCritFromIntellect() const @@ -5247,8 +5268,8 @@ float Player::GetSpellCritFromIntellect() const if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1); - GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass - 1); + GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (critBase == nullptr || critRatio == nullptr) return 0.0f; @@ -5263,9 +5284,9 @@ float Player::GetRatingMultiplier(CombatRating cr) const if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); + GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr * GT_MAX_LEVEL + level - 1); // gtOCTClassCombatRatingScalarStore.dbc starts with 1, CombatRating with zero, so cr+1 - GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((GetClass()-1)*GT_MAX_RATING+cr+1); + GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((GetClass() - 1) * GT_MAX_RATING + cr + 1); if (!Rating || !classRating) return 1.0f; // By default use minimum coefficient (not must be called) @@ -5281,12 +5302,12 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const { switch (attType) { - case BASE_ATTACK: - return GetUInt32Value(PLAYER_EXPERTISE) / 4.0f; - case OFF_ATTACK: - return GetUInt32Value(PLAYER_OFFHAND_EXPERTISE) / 4.0f; - default: - break; + case BASE_ATTACK: + return GetUInt32Value(PLAYER_EXPERTISE) / 4.0f; + case OFF_ATTACK: + return GetUInt32Value(PLAYER_OFFHAND_EXPERTISE) / 4.0f; + default: + break; } return 0.0f; } @@ -5299,8 +5320,8 @@ float Player::OCTRegenHPPerSpirit() const if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtOCTRegenHPEntry const* baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenHPPerSptEntry const* moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtOCTRegenHPEntry const* baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + GtRegenHPPerSptEntry const* moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (baseRatio == nullptr || moreRatio == nullptr) return 0.0f; @@ -5322,8 +5343,8 @@ float Player::OCTRegenMPPerSpirit() const if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; -// GtOCTRegenMPEntry const* baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + // GtOCTRegenMPEntry const* baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); + GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (moreRatio == nullptr) return 0.0f; @@ -5344,22 +5365,22 @@ void Player::ApplyRatingMod(CombatRating combatRating, int32 value, bool apply) float const newVal = m_baseRatingValue[combatRating] * multiplier; switch (combatRating) { - case CR_HASTE_MELEE: - ApplyAttackTimePercentMod(BASE_ATTACK, oldVal, false); - ApplyAttackTimePercentMod(OFF_ATTACK, oldVal, false); - ApplyAttackTimePercentMod(BASE_ATTACK, newVal, true); - ApplyAttackTimePercentMod(OFF_ATTACK, newVal, true); - break; - case CR_HASTE_RANGED: - ApplyAttackTimePercentMod(RANGED_ATTACK, oldVal, false); - ApplyAttackTimePercentMod(RANGED_ATTACK, newVal, true); - break; - case CR_HASTE_SPELL: - ApplyCastTimePercentMod(oldVal, false); - ApplyCastTimePercentMod(newVal, true); - break; - default: - break; + case CR_HASTE_MELEE: + ApplyAttackTimePercentMod(BASE_ATTACK, oldVal, false); + ApplyAttackTimePercentMod(OFF_ATTACK, oldVal, false); + ApplyAttackTimePercentMod(BASE_ATTACK, newVal, true); + ApplyAttackTimePercentMod(OFF_ATTACK, newVal, true); + break; + case CR_HASTE_RANGED: + ApplyAttackTimePercentMod(RANGED_ATTACK, oldVal, false); + ApplyAttackTimePercentMod(RANGED_ATTACK, newVal, true); + break; + case CR_HASTE_SPELL: + ApplyCastTimePercentMod(oldVal, false); + ApplyCastTimePercentMod(newVal, true); + break; + default: + break; } UpdateRating(combatRating); @@ -5383,72 +5404,72 @@ void Player::UpdateRating(CombatRating cr) switch (cr) { - case CR_WEAPON_SKILL: // Implemented in Unit::RollMeleeOutcomeAgainst - case CR_DEFENSE_SKILL: - UpdateDefenseBonusesMod(); - break; - case CR_DODGE: - UpdateDodgePercentage(); - break; - case CR_PARRY: - UpdateParryPercentage(); - break; - case CR_BLOCK: - UpdateBlockPercentage(); - break; - case CR_HIT_MELEE: - UpdateMeleeHitChances(); - break; - case CR_HIT_RANGED: - UpdateRangedHitChances(); - break; - case CR_HIT_SPELL: - UpdateSpellHitChances(); - break; - case CR_CRIT_MELEE: - if (affectStats) - { - UpdateCritPercentage(BASE_ATTACK); - UpdateCritPercentage(OFF_ATTACK); - } - break; - case CR_CRIT_RANGED: - if (affectStats) - UpdateCritPercentage(RANGED_ATTACK); - break; - case CR_CRIT_SPELL: - if (affectStats) - UpdateAllSpellCritChances(); - break; - case CR_HIT_TAKEN_MELEE: // Implemented in Unit::MeleeMissChanceCalc - case CR_HIT_TAKEN_RANGED: - break; - case CR_HIT_TAKEN_SPELL: // Implemented in Unit::MagicSpellHitResult - break; - case CR_CRIT_TAKEN_MELEE: // Implemented in Unit::RollMeleeOutcomeAgainst (only for chance to crit) - case CR_CRIT_TAKEN_RANGED: - break; - case CR_CRIT_TAKEN_SPELL: // Implemented in Unit::SpellCriticalBonus (only for chance to crit) - break; - case CR_HASTE_MELEE: // Implemented in Player::ApplyRatingMod - case CR_HASTE_RANGED: - case CR_HASTE_SPELL: - break; - case CR_WEAPON_SKILL_MAINHAND: // Implemented in Unit::RollMeleeOutcomeAgainst - case CR_WEAPON_SKILL_OFFHAND: - case CR_WEAPON_SKILL_RANGED: - break; - case CR_EXPERTISE: - if (affectStats) - { - UpdateExpertise(BASE_ATTACK); - UpdateExpertise(OFF_ATTACK); - } - break; - case CR_ARMOR_PENETRATION: - if (affectStats) - UpdateArmorPenetration(amount); - break; + case CR_WEAPON_SKILL: // Implemented in Unit::RollMeleeOutcomeAgainst + case CR_DEFENSE_SKILL: + UpdateDefenseBonusesMod(); + break; + case CR_DODGE: + UpdateDodgePercentage(); + break; + case CR_PARRY: + UpdateParryPercentage(); + break; + case CR_BLOCK: + UpdateBlockPercentage(); + break; + case CR_HIT_MELEE: + UpdateMeleeHitChances(); + break; + case CR_HIT_RANGED: + UpdateRangedHitChances(); + break; + case CR_HIT_SPELL: + UpdateSpellHitChances(); + break; + case CR_CRIT_MELEE: + if (affectStats) + { + UpdateCritPercentage(BASE_ATTACK); + UpdateCritPercentage(OFF_ATTACK); + } + break; + case CR_CRIT_RANGED: + if (affectStats) + UpdateCritPercentage(RANGED_ATTACK); + break; + case CR_CRIT_SPELL: + if (affectStats) + UpdateAllSpellCritChances(); + break; + case CR_HIT_TAKEN_MELEE: // Implemented in Unit::MeleeMissChanceCalc + case CR_HIT_TAKEN_RANGED: + break; + case CR_HIT_TAKEN_SPELL: // Implemented in Unit::MagicSpellHitResult + break; + case CR_CRIT_TAKEN_MELEE: // Implemented in Unit::RollMeleeOutcomeAgainst (only for chance to crit) + case CR_CRIT_TAKEN_RANGED: + break; + case CR_CRIT_TAKEN_SPELL: // Implemented in Unit::SpellCriticalBonus (only for chance to crit) + break; + case CR_HASTE_MELEE: // Implemented in Player::ApplyRatingMod + case CR_HASTE_RANGED: + case CR_HASTE_SPELL: + break; + case CR_WEAPON_SKILL_MAINHAND: // Implemented in Unit::RollMeleeOutcomeAgainst + case CR_WEAPON_SKILL_OFFHAND: + case CR_WEAPON_SKILL_RANGED: + break; + case CR_EXPERTISE: + if (affectStats) + { + UpdateExpertise(BASE_ATTACK); + UpdateExpertise(OFF_ATTACK); + } + break; + case CR_ARMOR_PENETRATION: + if (affectStats) + UpdateArmorPenetration(amount); + break; } } @@ -5518,18 +5539,18 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) inline int SkillGainChance(uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel) { if (SkillValue >= GrayLevel) - return CONF_GET_INT("SkillChance.Grey")*10; + return CONF_GET_INT("SkillChance.Grey") * 10; if (SkillValue >= GreenLevel) - return CONF_GET_INT("SkillChance.Green")*10; + return CONF_GET_INT("SkillChance.Green") * 10; if (SkillValue >= YellowLevel) - return CONF_GET_INT("SkillChance.Yellow")*10; - return CONF_GET_INT("SkillChance.Orange")*10; + return CONF_GET_INT("SkillChance.Yellow") * 10; + return CONF_GET_INT("SkillChance.Orange") * 10; } bool Player::UpdateCraftSkill(uint32 spellid) { LOG_DEBUG("entities.player.skills", "Player::UpdateCraftSkill: Player '%s' (%s), SpellID: %d", - GetName().c_str(), GetGUID().ToString().c_str(), spellid); + GetName().c_str(), GetGUID().ToString().c_str(), spellid); SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellid); @@ -5550,10 +5571,10 @@ bool Player::UpdateCraftSkill(uint32 spellid) uint32 craft_skill_gain = CONF_GET_INT("SkillGain.Crafting"); return UpdateSkillPro(_spell_idx->second->SkillLine, SkillGainChance(SkillValue, - _spell_idx->second->TrivialSkillLineRankHigh, - (_spell_idx->second->TrivialSkillLineRankHigh + _spell_idx->second->TrivialSkillLineRankLow)/2, - _spell_idx->second->TrivialSkillLineRankLow), - craft_skill_gain); + _spell_idx->second->TrivialSkillLineRankHigh, + (_spell_idx->second->TrivialSkillLineRankHigh + _spell_idx->second->TrivialSkillLineRankLow) / 2, + _spell_idx->second->TrivialSkillLineRankLow), + craft_skill_gain); } } return false; @@ -5562,28 +5583,30 @@ bool Player::UpdateCraftSkill(uint32 spellid) bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator) { LOG_DEBUG("entities.player.skills", "Player::UpdateGatherSkill: Player '%s' (%s), SkillID: %u, SkillLevel: %u, RedLevel: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), SkillId, SkillValue, RedLevel); + GetName().c_str(), GetGUID().ToString().c_str(), SkillId, SkillValue, RedLevel); uint32 gathering_skill_gain = CONF_GET_INT("SkillGain.Gathering"); // For skinning and Mining chance decrease with level. 1-74 - no decrease, 75-149 - 2 times, 225-299 - 8 times switch (SkillId) { - case SKILL_HERBALISM: - case SKILL_LOCKPICKING: - case SKILL_JEWELCRAFTING: - case SKILL_INSCRIPTION: - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator, gathering_skill_gain); - case SKILL_SKINNING: - if (CONF_GET_INT("SkillChance.SkinningSteps") == 0) - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator, gathering_skill_gain); - else - return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/CONF_GET_INT("SkillChance.SkinningSteps")), gathering_skill_gain); - case SKILL_MINING: - if (CONF_GET_INT("SkillChance.MiningSteps") == 0) - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator, gathering_skill_gain); - else - return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/CONF_GET_INT("SkillChance.MiningSteps")), gathering_skill_gain); + case SKILL_HERBALISM: + case SKILL_LOCKPICKING: + case SKILL_JEWELCRAFTING: + case SKILL_INSCRIPTION: + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); + case SKILL_SKINNING: + if (CONF_GET_INT("SkillChance.SkinningSteps") == 0) + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); + else + return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / CONF_GET_INT("SkillChance.SkinningSteps")), + gathering_skill_gain); + case SKILL_MINING: + if (CONF_GET_INT("SkillChance.MiningSteps") == 0) + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); + else + return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / CONF_GET_INT("SkillChance.MiningSteps")), + gathering_skill_gain); } return false; } @@ -5617,7 +5640,7 @@ bool Player::UpdateFishingSkill() m_fishingSteps = 0; uint32 gathering_skill_gain = CONF_GET_INT("SkillGain.Gathering"); - return UpdateSkillPro(SKILL_FISHING, 100*10, gathering_skill_gain); + return UpdateSkillPro(SKILL_FISHING, 100 * 10, gathering_skill_gain); } return false; @@ -5632,14 +5655,14 @@ static const size_t bonusSkillLevelsSize = sizeof(bonusSkillLevels) / sizeof(uin bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) { LOG_DEBUG("entities.player.skills", "Player::UpdateSkillPro: Player '%s' (%s), SkillID: %u, Chance: %3.1f%%)", - GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); + GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); if (!SkillId) return false; if (Chance <= 0) // speedup in 0 chance case { LOG_DEBUG("entities.player.skills", "Player::UpdateSkillPro: Player '%s' (%s), SkillID: %u, Chance: %3.1f%% missed", - GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); + GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); return false; } @@ -5660,7 +5683,7 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) if (Roll <= Chance) { - uint32 new_value = SkillValue+step; + uint32 new_value = SkillValue + step; if (new_value > MaxValue) new_value = MaxValue; @@ -5679,12 +5702,12 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) UpdateSkillEnchantments(SkillId, SkillValue, new_value); UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, SkillId); LOG_DEBUG("entities.player.skills", "Player::UpdateSkillPro: Player '%s' (%s), SkillID: %u, Chance: %3.1f%% taken", - GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); + GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); return true; } LOG_DEBUG("entities.player.skills", "Player::UpdateSkillPro: Player '%s' (%s), SkillID: %u, Chance: %3.1f%% missed", - GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); + GetName().c_str(), GetGUID().ToString().c_str(), SkillId, Chance / 10.0f); return false; } @@ -5712,14 +5735,14 @@ void Player::UpdateWeaponSkill(Unit* victim, WeaponAttackType attType) { switch (tmpitem->GetTemplate()->SubClass) { - case ITEM_SUBCLASS_WEAPON_FISHING_POLE: - break; - case ITEM_SUBCLASS_WEAPON_FIST: - UpdateSkill(SKILL_UNARMED, weapon_skill_gain); - [[fallthrough]]; - default: - UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain); - break; + case ITEM_SUBCLASS_WEAPON_FISHING_POLE: + break; + case ITEM_SUBCLASS_WEAPON_FIST: + UpdateSkill(SKILL_UNARMED, weapon_skill_gain); + [[fallthrough]]; + default: + UpdateSkill(tmpitem->GetSkill(), weapon_skill_gain); + break; } } @@ -5774,9 +5797,9 @@ void Player::ModifySkillBonus(uint32 skillid, int32 val, bool talent) int16 perm_bonus = SKILL_PERM_BONUS(bonus_val); if (talent) // permanent bonus stored in high part - SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus, perm_bonus+val)); + SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus, perm_bonus + val)); else // temporary/item bonus stored in low part - SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus+val, perm_bonus)); + SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus + val, perm_bonus)); } void Player::UpdateSkillsForLevel() @@ -5911,7 +5934,7 @@ void Player::SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal) else if (newVal) //add { currVal = 0; - for (int i=0; i < PLAYER_MAX_SKILLS; ++i) + for (int i = 0; i < PLAYER_MAX_SKILLS; ++i) { if (!GetUInt32Value(PLAYER_SKILL_INDEX(i))) { @@ -5919,7 +5942,7 @@ void Player::SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal) if (!pSkill) { LOG_ERROR("misc", "Player::SetSkill: Skill (SkillID: %u) not found in SkillLineStore for player '%s' (%s)", - id, GetName().c_str(), GetGUID().ToString().c_str()); + id, GetName().c_str(), GetGUID().ToString().c_str()); return; } @@ -6080,7 +6103,7 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const void Player::SendActionButtons(uint32 state) const { - WorldPacket data(SMSG_ACTION_BUTTONS, 1+(MAX_ACTION_BUTTONS*4)); + WorldPacket data(SMSG_ACTION_BUTTONS, 1 + (MAX_ACTION_BUTTONS * 4)); data << uint8(state); /* state can be 0, 1, 2 @@ -6109,50 +6132,52 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) co if (button >= MAX_ACTION_BUTTONS) { LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): button must be < %u", - action, button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTONS); + action, button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTONS); return false; } if (action >= MAX_ACTION_BUTTON_ACTION_VALUE) { LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Action %u not added into button %u for player %s (%s): action must be < %u", - action, button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE); + action, button, GetName().c_str(), GetGUID().ToString().c_str(), MAX_ACTION_BUTTON_ACTION_VALUE); return false; } switch (type) { - case ACTION_BUTTON_SPELL: - if (!sSpellMgr->GetSpellInfo(action)) - { - LOG_DEBUG("entities.player", "Player::IsActionButtonDataValid: Spell action %u not added into button %u for player %s (%s): spell does not exist. This can be due to a character imported from a different expansion", - action, button, GetName().c_str(), GetGUID().ToString().c_str()); - return false; - } + case ACTION_BUTTON_SPELL: + if (!sSpellMgr->GetSpellInfo(action)) + { + LOG_DEBUG("entities.player", + "Player::IsActionButtonDataValid: Spell action %u not added into button %u for player %s (%s): spell does not exist. This can be due to a character imported from a different expansion", + action, button, GetName().c_str(), GetGUID().ToString().c_str()); + return false; + } - if (!HasSpell(action)) - { - LOG_DEBUG("entities.player", "Player::IsActionButtonDataValid: Spell action %u not added into button %u for player %s (%s): player does not known this spell, this can be due to a player changing their talents", - action, button, GetName().c_str(), GetGUID().ToString().c_str()); - return false; - } - break; - case ACTION_BUTTON_ITEM: - if (!sObjectMgr->GetItemTemplate(action)) - { - LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Item action %u not added into button %u for player %s (%s): item not exist", - action, button, GetName().c_str(), GetGUID().ToString().c_str()); - return false; - } - break; - case ACTION_BUTTON_C: - case ACTION_BUTTON_CMACRO: - case ACTION_BUTTON_MACRO: - case ACTION_BUTTON_EQSET: - break; - default: - LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Unknown action type %u", type); - return false; // other cases not checked at this moment + if (!HasSpell(action)) + { + LOG_DEBUG("entities.player", + "Player::IsActionButtonDataValid: Spell action %u not added into button %u for player %s (%s): player does not known this spell, this can be due to a player changing their talents", + action, button, GetName().c_str(), GetGUID().ToString().c_str()); + return false; + } + break; + case ACTION_BUTTON_ITEM: + if (!sObjectMgr->GetItemTemplate(action)) + { + LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Item action %u not added into button %u for player %s (%s): item not exist", + action, button, GetName().c_str(), GetGUID().ToString().c_str()); + return false; + } + break; + case ACTION_BUTTON_C: + case ACTION_BUTTON_CMACRO: + case ACTION_BUTTON_MACRO: + case ACTION_BUTTON_EQSET: + break; + default: + LOG_ERROR("entities.player", "Player::IsActionButtonDataValid: Unknown action type %u", type); + return false; // other cases not checked at this moment } return true; @@ -6170,7 +6195,7 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) ab.SetActionAndType(action, ActionButtonType(type)); LOG_DEBUG("entities.player", "Player::AddActionButton: Player '%s' (%s) added action '%u' (type %u) to button '%u'", - GetName().c_str(), GetGUID().ToString().c_str(), action, type, button); + GetName().c_str(), GetGUID().ToString().c_str(), action, type, button); return &ab; } @@ -6186,7 +6211,7 @@ void Player::removeActionButton(uint8 button) buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save LOG_DEBUG("entities.player", "Player::RemoveActionButton: Player '%s' (%s) removed action button '%u'", - GetName().c_str(), GetGUID().ToString().c_str(), button); + GetName().c_str(), GetGUID().ToString().c_str(), button); } ActionButton const* Player::GetActionButton(uint8 button) @@ -6298,7 +6323,7 @@ void Player::CheckAreaExploreAndOutdoor() if (!areaEntry) { LOG_ERROR("entities.player", "Player '%s' (%s) discovered unknown area (x: %f y: %f z: %f map: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId()); + GetName().c_str(), GetGUID().ToString().c_str(), GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId()); return; } @@ -6307,7 +6332,7 @@ void Player::CheckAreaExploreAndOutdoor() if (offset >= PLAYER_EXPLORED_ZONES_SIZE) { LOG_ERROR("entities.player", "Player::CheckAreaExploreAndOutdoor: Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < %u ).", - areaEntry->AreaBit, GetPositionX(), GetPositionY(), offset, offset, PLAYER_EXPLORED_ZONES_SIZE); + areaEntry->AreaBit, GetPositionX(), GetPositionY(), offset, offset, PLAYER_EXPLORED_ZONES_SIZE); return; } @@ -6323,40 +6348,34 @@ void Player::CheckAreaExploreAndOutdoor() if (areaEntry->ExplorationLevel > 0) { if (IsMaxLevel()) - { SendExplorationExperience(areaId, 0); - } else { int32 diff = int32(GetLevel()) - areaEntry->ExplorationLevel; uint32 XP; if (diff < -5) - { - XP = uint32(sObjectMgr->GetBaseXP(GetLevel()+5)*CONF_GET_FLOAT("Rate.XP.Explore")); - } + XP = uint32(sObjectMgr->GetBaseXP(GetLevel() + 5) * CONF_GET_FLOAT("Rate.XP.Explore")); else if (diff > 5) { int32 exploration_percent = 100 - ((diff - 5) * 5); if (exploration_percent < 0) exploration_percent = 0; - XP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel)*exploration_percent/100*CONF_GET_FLOAT("Rate.XP.Explore")); + XP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel) * exploration_percent / 100 * CONF_GET_FLOAT("Rate.XP.Explore")); } else - { - XP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel)*CONF_GET_FLOAT("Rate.XP.Explore")); - } + XP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel) * CONF_GET_FLOAT("Rate.XP.Explore")); if (CONF_GET_INT("MinDiscoveredScaledXPRatio")) { - uint32 minScaledXP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel)*CONF_GET_FLOAT("Rate.XP.Explore")) * CONF_GET_INT("MinDiscoveredScaledXPRatio") / 100; + uint32 minScaledXP = uint32(sObjectMgr->GetBaseXP(areaEntry->ExplorationLevel) * CONF_GET_FLOAT("Rate.XP.Explore")) * CONF_GET_INT("MinDiscoveredScaledXPRatio") / 100; XP = std::max(minScaledXP, XP); } GiveXP(XP, nullptr); SendExplorationExperience(areaId, XP); } - LOG_DEBUG("entities.player", "Player '%s' (%s) discovered a new area: %u", GetName().c_str(),GetGUID().ToString().c_str(), areaId); + LOG_DEBUG("entities.player", "Player '%s' (%s) discovered a new area: %u", GetName().c_str(), GetGUID().ToString().c_str(), areaId); } } } @@ -6367,8 +6386,10 @@ uint32 Player::TeamForRace(uint8 race) { switch (rEntry->BaseLanguage) { - case 1: return HORDE; - case 7: return ALLIANCE; + case 1: + return HORDE; + case 7: + return ALLIANCE; } LOG_ERROR("entities.player", "Race (%u) has wrong teamid (%u) in DBC: wrong DBC files?", uint32(race), rEntry->BaseLanguage); } @@ -6408,20 +6429,20 @@ int32 Player::CalculateReputationGain(ReputationSource source, uint32 creatureOr float rate; switch (source) { - case REPUTATION_SOURCE_KILL: - rate = CONF_GET_FLOAT("Rate.Reputation.LowLevel.Kill"); - break; - case REPUTATION_SOURCE_QUEST: - case REPUTATION_SOURCE_DAILY_QUEST: - case REPUTATION_SOURCE_WEEKLY_QUEST: - case REPUTATION_SOURCE_MONTHLY_QUEST: - case REPUTATION_SOURCE_REPEATABLE_QUEST: - rate = CONF_GET_FLOAT("Rate.Reputation.LowLevel.Quest"); - break; - case REPUTATION_SOURCE_SPELL: - default: - rate = 1.0f; - break; + case REPUTATION_SOURCE_KILL: + rate = CONF_GET_FLOAT("Rate.Reputation.LowLevel.Kill"); + break; + case REPUTATION_SOURCE_QUEST: + case REPUTATION_SOURCE_DAILY_QUEST: + case REPUTATION_SOURCE_WEEKLY_QUEST: + case REPUTATION_SOURCE_MONTHLY_QUEST: + case REPUTATION_SOURCE_REPEATABLE_QUEST: + rate = CONF_GET_FLOAT("Rate.Reputation.LowLevel.Quest"); + break; + case REPUTATION_SOURCE_SPELL: + default: + rate = 1.0f; + break; } if (rate != 1.0f && creatureOrQuestLevel <= Warhead::XP::GetGrayLevel(GetLevel())) @@ -6436,27 +6457,27 @@ int32 Player::CalculateReputationGain(ReputationSource source, uint32 creatureOr float repRate = 0.0f; switch (source) { - case REPUTATION_SOURCE_KILL: - repRate = repData->creatureRate; - break; - case REPUTATION_SOURCE_QUEST: - repRate = repData->questRate; - break; - case REPUTATION_SOURCE_DAILY_QUEST: - repRate = repData->questDailyRate; - break; - case REPUTATION_SOURCE_WEEKLY_QUEST: - repRate = repData->questWeeklyRate; - break; - case REPUTATION_SOURCE_MONTHLY_QUEST: - repRate = repData->questMonthlyRate; - break; - case REPUTATION_SOURCE_REPEATABLE_QUEST: - repRate = repData->questRepeatableRate; - break; - case REPUTATION_SOURCE_SPELL: - repRate = repData->spellRate; - break; + case REPUTATION_SOURCE_KILL: + repRate = repData->creatureRate; + break; + case REPUTATION_SOURCE_QUEST: + repRate = repData->questRate; + break; + case REPUTATION_SOURCE_DAILY_QUEST: + repRate = repData->questDailyRate; + break; + case REPUTATION_SOURCE_WEEKLY_QUEST: + repRate = repData->questWeeklyRate; + break; + case REPUTATION_SOURCE_MONTHLY_QUEST: + repRate = repData->questMonthlyRate; + break; + case REPUTATION_SOURCE_REPEATABLE_QUEST: + repRate = repData->questRepeatableRate; + break; + case REPUTATION_SOURCE_SPELL: + repRate = repData->spellRate; + break; } // for custom, a rate of 0.0 will totally disable reputation gain for this faction/type @@ -6700,7 +6721,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto // [29..38] Other title and player name // [39+] Nothing uint32 victim_title = victim->GetUInt32Value(PLAYER_CHOSEN_TITLE); - // Get Killer titles, CharTitlesEntry::MaskID + // Get Killer titles, CharTitlesEntry::MaskID // Ranks: // title[1..14] -> rank[5..18] // title[15..28] -> rank[5..18] @@ -6754,7 +6775,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto // victim_rank [1..4] HK: // victim_rank [5..19] HK: // victim_rank [0, 20+] HK: <> - WorldPacket data(SMSG_PVP_CREDIT, 4+8+4); + WorldPacket data(SMSG_PVP_CREDIT, 4 + 8 + 4); data << uint32(honor); data << uint64(victim_guid); data << uint32(victim_rank); @@ -6784,8 +6805,8 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto // Check if allowed to receive it in current map uint8 MapType = CONF_GET_INT("PvPToken.MapAllowType"); if ((MapType == 1 && !InBattleground() && !IsFFAPvP()) - || (MapType == 2 && !IsFFAPvP()) - || (MapType == 3 && !InBattleground())) + || (MapType == 2 && !IsFFAPvP()) + || (MapType == 3 && !InBattleground())) return true; uint32 itemId = CONF_GET_INT("PvPToken.ItemID"); @@ -6988,19 +7009,19 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) // in PvE, only opposition team capital switch (zone->FactionGroupMask) { - case AREATEAM_ALLY: - pvpInfo.IsInHostileArea = GetTeam() != ALLIANCE && (sWorld->IsPvPRealm() || zone->Flags & AREA_FLAG_CAPITAL); - break; - case AREATEAM_HORDE: - pvpInfo.IsInHostileArea = GetTeam() != HORDE && (sWorld->IsPvPRealm() || zone->Flags & AREA_FLAG_CAPITAL); - break; - case AREATEAM_NONE: - // overwrite for battlegrounds, maybe batter some zone flags but current known not 100% fit to this - pvpInfo.IsInHostileArea = sWorld->IsPvPRealm() || InBattleground() || zone->Flags & AREA_FLAG_WINTERGRASP; - break; - default: // 6 in fact - pvpInfo.IsInHostileArea = false; - break; + case AREATEAM_ALLY: + pvpInfo.IsInHostileArea = GetTeam() != ALLIANCE && (sWorld->IsPvPRealm() || zone->Flags & AREA_FLAG_CAPITAL); + break; + case AREATEAM_HORDE: + pvpInfo.IsInHostileArea = GetTeam() != HORDE && (sWorld->IsPvPRealm() || zone->Flags & AREA_FLAG_CAPITAL); + break; + case AREATEAM_NONE: + // overwrite for battlegrounds, maybe batter some zone flags but current known not 100% fit to this + pvpInfo.IsInHostileArea = sWorld->IsPvPRealm() || InBattleground() || zone->Flags & AREA_FLAG_WINTERGRASP; + break; + default: // 6 in fact + pvpInfo.IsInHostileArea = false; + break; } // Treat players having a quest flagging for PvP as always in hostile area @@ -7098,7 +7119,7 @@ void Player::DuelComplete(DuelCompleteType type) opponent->duel->State = DUEL_STATE_COMPLETED; LOG_DEBUG("entities.unit", "Player::DuelComplete: Player '%s' (%s), Opponent: '%s' (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), opponent->GetName().c_str(), opponent->GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), opponent->GetName().c_str(), opponent->GetGUID().ToString().c_str()); WorldPacket data(SMSG_DUEL_COMPLETE, (1)); data << uint8((type != DUEL_INTERRUPTED) ? 1 : 0); @@ -7108,7 +7129,7 @@ void Player::DuelComplete(DuelCompleteType type) if (type != DUEL_INTERRUPTED) { - data.Initialize(SMSG_DUEL_WINNER, (1+20)); // we guess size + data.Initialize(SMSG_DUEL_WINNER, (1 + 20)); // we guess size data << uint8(type == DUEL_WON ? 0 : 1); // 0 = just won; 1 = fled data << opponent->GetName(); data << GetName(); @@ -7119,37 +7140,37 @@ void Player::DuelComplete(DuelCompleteType type) switch (type) { - case DUEL_FLED: - // if initiator and opponent are on the same team - // or initiator and opponent are not PvP enabled, forcibly stop attacking - if (GetTeam() == opponent->GetTeam()) - { + case DUEL_FLED: + // if initiator and opponent are on the same team + // or initiator and opponent are not PvP enabled, forcibly stop attacking + if (GetTeam() == opponent->GetTeam()) + { + AttackStop(); + opponent->AttackStop(); + } + else + { + if (!IsPvP()) AttackStop(); + if (!opponent->IsPvP()) opponent->AttackStop(); - } - else - { - if (!IsPvP()) - AttackStop(); - if (!opponent->IsPvP()) - opponent->AttackStop(); - } - break; - case DUEL_WON: - UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, 1); - opponent->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1); + } + break; + case DUEL_WON: + UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL, 1); + opponent->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL, 1); - // Credit for quest Death's Challenge - if (GetClass() == CLASS_DEATH_KNIGHT && opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE) - opponent->CastSpell(opponent, 52994, true); + // Credit for quest Death's Challenge + if (GetClass() == CLASS_DEATH_KNIGHT && opponent->GetQuestStatus(12733) == QUEST_STATUS_INCOMPLETE) + opponent->CastSpell(opponent, 52994, true); - // Honor points after duel (the winner) - ImpConfig - if (uint32 amount = CONF_GET_INT("HonorPointsAfterDuel")) - opponent->RewardHonor(nullptr, 1, amount); + // Honor points after duel (the winner) - ImpConfig + if (uint32 amount = CONF_GET_INT("HonorPointsAfterDuel")) + opponent->RewardHonor(nullptr, 1, amount); - break; - default: - break; + break; + default: + break; } // Victory emote spell @@ -7162,7 +7183,7 @@ void Player::DuelComplete(DuelCompleteType type) duel->Initiator->RemoveGameObject(obj, true); /* remove auras */ - AuraApplicationMap &itsAuras = opponent->GetAppliedAuras(); + AuraApplicationMap& itsAuras = opponent->GetAppliedAuras(); for (AuraApplicationMap::iterator i = itsAuras.begin(); i != itsAuras.end();) { Aura const* aura = i->second->GetBase(); @@ -7172,7 +7193,7 @@ void Player::DuelComplete(DuelCompleteType type) ++i; } - AuraApplicationMap &myAuras = GetAppliedAuras(); + AuraApplicationMap& myAuras = GetAppliedAuras(); for (AuraApplicationMap::iterator i = myAuras.begin(); i != myAuras.end();) { Aura const* aura = i->second->GetBase(); @@ -7296,154 +7317,154 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply switch (statType) { - case ITEM_MOD_MANA: - HandleStatFlatModifier(UNIT_MOD_MANA, BASE_VALUE, float(val), apply); - break; - case ITEM_MOD_HEALTH: // modify HP - HandleStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, float(val), apply); - break; - case ITEM_MOD_AGILITY: // modify agility - HandleStatFlatModifier(UNIT_MOD_STAT_AGILITY, BASE_VALUE, float(val), apply); - UpdateStatBuffMod(STAT_AGILITY); - break; - case ITEM_MOD_STRENGTH: //modify strength - HandleStatFlatModifier(UNIT_MOD_STAT_STRENGTH, BASE_VALUE, float(val), apply); - UpdateStatBuffMod(STAT_STRENGTH); - break; - case ITEM_MOD_INTELLECT: //modify intellect - HandleStatFlatModifier(UNIT_MOD_STAT_INTELLECT, BASE_VALUE, float(val), apply); - UpdateStatBuffMod(STAT_INTELLECT); - break; - case ITEM_MOD_SPIRIT: //modify spirit - HandleStatFlatModifier(UNIT_MOD_STAT_SPIRIT, BASE_VALUE, float(val), apply); - UpdateStatBuffMod(STAT_SPIRIT); - break; - case ITEM_MOD_STAMINA: //modify stamina - HandleStatFlatModifier(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(val), apply); - UpdateStatBuffMod(STAT_STAMINA); - break; - case ITEM_MOD_DEFENSE_SKILL_RATING: - ApplyRatingMod(CR_DEFENSE_SKILL, int32(val), apply); - break; - case ITEM_MOD_DODGE_RATING: - ApplyRatingMod(CR_DODGE, int32(val), apply); - break; - case ITEM_MOD_PARRY_RATING: - ApplyRatingMod(CR_PARRY, int32(val), apply); - break; - case ITEM_MOD_BLOCK_RATING: - ApplyRatingMod(CR_BLOCK, int32(val), apply); - break; - case ITEM_MOD_HIT_MELEE_RATING: - ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); - break; - case ITEM_MOD_HIT_RANGED_RATING: - ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); - break; - case ITEM_MOD_HIT_SPELL_RATING: - ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_MELEE_RATING: - ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); - break; - case ITEM_MOD_CRIT_RANGED_RATING: - ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); - break; - case ITEM_MOD_CRIT_SPELL_RATING: - ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_MELEE_RATING: - ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_RANGED_RATING: - ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_SPELL_RATING: - ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_HASTE_MELEE_RATING: - ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); - break; - case ITEM_MOD_HASTE_RANGED_RATING: - ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); - break; - case ITEM_MOD_HASTE_SPELL_RATING: - ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); - break; - case ITEM_MOD_HIT_RATING: - ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); - ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); - ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_RATING: - ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); - ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); - ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); - break; - case ITEM_MOD_HIT_TAKEN_RATING: - ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); - ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); - ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_CRIT_TAKEN_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_RESILIENCE_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); - ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); - break; - case ITEM_MOD_HASTE_RATING: - ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); - ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); - ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); - break; - case ITEM_MOD_EXPERTISE_RATING: - ApplyRatingMod(CR_EXPERTISE, int32(val), apply); - break; - case ITEM_MOD_ATTACK_POWER: - HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(val), apply); - HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply); - break; - case ITEM_MOD_RANGED_ATTACK_POWER: - HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply); - break; -// case ITEM_MOD_FERAL_ATTACK_POWER: -// ApplyFeralAPBonus(int32(val), apply); -// break; - case ITEM_MOD_MANA_REGENERATION: - ApplyManaRegenBonus(int32(val), apply); - break; - case ITEM_MOD_ARMOR_PENETRATION_RATING: - ApplyRatingMod(CR_ARMOR_PENETRATION, int32(val), apply); - break; - case ITEM_MOD_SPELL_POWER: - ApplySpellPowerBonus(int32(val), apply); - break; - case ITEM_MOD_HEALTH_REGEN: - ApplyHealthRegenBonus(int32(val), apply); - break; - case ITEM_MOD_SPELL_PENETRATION: - ApplySpellPenetrationBonus(val, apply); - break; - case ITEM_MOD_BLOCK_VALUE: - HandleBaseModFlatValue(SHIELD_BLOCK_VALUE, float(val), apply); - break; - // deprecated item mods - case ITEM_MOD_SPELL_HEALING_DONE: - case ITEM_MOD_SPELL_DAMAGE_DONE: - break; + case ITEM_MOD_MANA: + HandleStatFlatModifier(UNIT_MOD_MANA, BASE_VALUE, float(val), apply); + break; + case ITEM_MOD_HEALTH: // modify HP + HandleStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, float(val), apply); + break; + case ITEM_MOD_AGILITY: // modify agility + HandleStatFlatModifier(UNIT_MOD_STAT_AGILITY, BASE_VALUE, float(val), apply); + UpdateStatBuffMod(STAT_AGILITY); + break; + case ITEM_MOD_STRENGTH: //modify strength + HandleStatFlatModifier(UNIT_MOD_STAT_STRENGTH, BASE_VALUE, float(val), apply); + UpdateStatBuffMod(STAT_STRENGTH); + break; + case ITEM_MOD_INTELLECT: //modify intellect + HandleStatFlatModifier(UNIT_MOD_STAT_INTELLECT, BASE_VALUE, float(val), apply); + UpdateStatBuffMod(STAT_INTELLECT); + break; + case ITEM_MOD_SPIRIT: //modify spirit + HandleStatFlatModifier(UNIT_MOD_STAT_SPIRIT, BASE_VALUE, float(val), apply); + UpdateStatBuffMod(STAT_SPIRIT); + break; + case ITEM_MOD_STAMINA: //modify stamina + HandleStatFlatModifier(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(val), apply); + UpdateStatBuffMod(STAT_STAMINA); + break; + case ITEM_MOD_DEFENSE_SKILL_RATING: + ApplyRatingMod(CR_DEFENSE_SKILL, int32(val), apply); + break; + case ITEM_MOD_DODGE_RATING: + ApplyRatingMod(CR_DODGE, int32(val), apply); + break; + case ITEM_MOD_PARRY_RATING: + ApplyRatingMod(CR_PARRY, int32(val), apply); + break; + case ITEM_MOD_BLOCK_RATING: + ApplyRatingMod(CR_BLOCK, int32(val), apply); + break; + case ITEM_MOD_HIT_MELEE_RATING: + ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); + break; + case ITEM_MOD_HIT_RANGED_RATING: + ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); + break; + case ITEM_MOD_HIT_SPELL_RATING: + ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_MELEE_RATING: + ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); + break; + case ITEM_MOD_CRIT_RANGED_RATING: + ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); + break; + case ITEM_MOD_CRIT_SPELL_RATING: + ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_MELEE_RATING: + ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_RANGED_RATING: + ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_SPELL_RATING: + ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_HASTE_MELEE_RATING: + ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); + break; + case ITEM_MOD_HASTE_RANGED_RATING: + ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); + break; + case ITEM_MOD_HASTE_SPELL_RATING: + ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); + break; + case ITEM_MOD_HIT_RATING: + ApplyRatingMod(CR_HIT_MELEE, int32(val), apply); + ApplyRatingMod(CR_HIT_RANGED, int32(val), apply); + ApplyRatingMod(CR_HIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_RATING: + ApplyRatingMod(CR_CRIT_MELEE, int32(val), apply); + ApplyRatingMod(CR_CRIT_RANGED, int32(val), apply); + ApplyRatingMod(CR_CRIT_SPELL, int32(val), apply); + break; + case ITEM_MOD_HIT_TAKEN_RATING: + ApplyRatingMod(CR_HIT_TAKEN_MELEE, int32(val), apply); + ApplyRatingMod(CR_HIT_TAKEN_RANGED, int32(val), apply); + ApplyRatingMod(CR_HIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_CRIT_TAKEN_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_RESILIENCE_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_MELEE, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_RANGED, int32(val), apply); + ApplyRatingMod(CR_CRIT_TAKEN_SPELL, int32(val), apply); + break; + case ITEM_MOD_HASTE_RATING: + ApplyRatingMod(CR_HASTE_MELEE, int32(val), apply); + ApplyRatingMod(CR_HASTE_RANGED, int32(val), apply); + ApplyRatingMod(CR_HASTE_SPELL, int32(val), apply); + break; + case ITEM_MOD_EXPERTISE_RATING: + ApplyRatingMod(CR_EXPERTISE, int32(val), apply); + break; + case ITEM_MOD_ATTACK_POWER: + HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(val), apply); + HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply); + break; + case ITEM_MOD_RANGED_ATTACK_POWER: + HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(val), apply); + break; + // case ITEM_MOD_FERAL_ATTACK_POWER: + // ApplyFeralAPBonus(int32(val), apply); + // break; + case ITEM_MOD_MANA_REGENERATION: + ApplyManaRegenBonus(int32(val), apply); + break; + case ITEM_MOD_ARMOR_PENETRATION_RATING: + ApplyRatingMod(CR_ARMOR_PENETRATION, int32(val), apply); + break; + case ITEM_MOD_SPELL_POWER: + ApplySpellPowerBonus(int32(val), apply); + break; + case ITEM_MOD_HEALTH_REGEN: + ApplyHealthRegenBonus(int32(val), apply); + break; + case ITEM_MOD_SPELL_PENETRATION: + ApplySpellPenetrationBonus(val, apply); + break; + case ITEM_MOD_BLOCK_VALUE: + HandleBaseModFlatValue(SHIELD_BLOCK_VALUE, float(val), apply); + break; + // deprecated item mods + case ITEM_MOD_SPELL_HEALING_DONE: + case ITEM_MOD_SPELL_DAMAGE_DONE: + break; } } @@ -7469,12 +7490,12 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply { switch (proto->SubClass) { - case ITEM_SUBCLASS_ARMOR_CLOTH: - case ITEM_SUBCLASS_ARMOR_LEATHER: - case ITEM_SUBCLASS_ARMOR_MAIL: - case ITEM_SUBCLASS_ARMOR_PLATE: - case ITEM_SUBCLASS_ARMOR_SHIELD: - modType = BASE_VALUE; + case ITEM_SUBCLASS_ARMOR_CLOTH: + case ITEM_SUBCLASS_ARMOR_LEATHER: + case ITEM_SUBCLASS_ARMOR_MAIL: + case ITEM_SUBCLASS_ARMOR_PLATE: + case ITEM_SUBCLASS_ARMOR_SHIELD: + modType = BASE_VALUE; break; } } @@ -7642,18 +7663,18 @@ void Player::UpdateWeaponDependentCritAuras(WeaponAttackType attackType) BaseModGroup modGroup; switch (attackType) { - case BASE_ATTACK: - modGroup = CRIT_PERCENTAGE; - break; - case OFF_ATTACK: - modGroup = OFFHAND_CRIT_PERCENTAGE; - break; - case RANGED_ATTACK: - modGroup = RANGED_CRIT_PERCENTAGE; - break; - default: - ABORT(); - break; + case BASE_ATTACK: + modGroup = CRIT_PERCENTAGE; + break; + case OFF_ATTACK: + modGroup = OFFHAND_CRIT_PERCENTAGE; + break; + case RANGED_ATTACK: + modGroup = RANGED_CRIT_PERCENTAGE; + break; + default: + ABORT(); + break; } float amount = 0.0f; @@ -7760,7 +7781,7 @@ void Player::ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, } LOG_DEBUG("entities.player", "Player::ApplyEquipSpell: Player '%s' (%s) cast %s equip spell (ID: %i)", - GetName().c_str(), GetGUID().ToString().c_str(), (item ? "item" : "itemset"), spellInfo->Id); + GetName().c_str(), GetGUID().ToString().c_str(), (item ? "item" : "itemset"), spellInfo->Id); CastSpell(this, spellInfo->Id, item); } @@ -7832,18 +7853,18 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo) EquipmentSlots slot; switch (damageInfo.GetAttackType()) { - case BASE_ATTACK: - slot = EQUIPMENT_SLOT_MAINHAND; - break; - case OFF_ATTACK: - slot = EQUIPMENT_SLOT_OFFHAND; - break; - case RANGED_ATTACK: - slot = EQUIPMENT_SLOT_RANGED; - break; - default: - slot = EQUIPMENT_SLOT_END; - break; + case BASE_ATTACK: + slot = EQUIPMENT_SLOT_MAINHAND; + break; + case OFF_ATTACK: + slot = EQUIPMENT_SLOT_OFFHAND; + break; + case RANGED_ATTACK: + slot = EQUIPMENT_SLOT_RANGED; + break; + default: + slot = EQUIPMENT_SLOT_END; + break; } if (slot != i) continue; @@ -7883,7 +7904,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT if (!spellInfo) { LOG_ERROR("entities.player.items", "Player::CastItemCombatSpell: Player '%s' (%s) cast unknown item spell (ID: %i)", - GetName().c_str(), GetGUID().ToString().c_str(), spellData.SpellId); + GetName().c_str(), GetGUID().ToString().c_str(), spellData.SpellId); continue; } @@ -7942,7 +7963,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT if (!spellInfo) { LOG_ERROR("entities.player.items", "Player::CastItemCombatSpell: Player '%s' (%s) cast unknown spell (EnchantID: %u, SpellID: %i), ignoring", - GetName().c_str(), GetGUID().ToString().c_str(), pEnchant->ID, pEnchant->EffectArg[s]); + GetName().c_str(), GetGUID().ToString().c_str(), pEnchant->ID, pEnchant->EffectArg[s]); continue; } @@ -8223,17 +8244,17 @@ bool Player::CheckAmmoCompatibility(ItemTemplate const* ammo_proto) const // check ammo ws. weapon compatibility switch (weapon_proto->SubClass) { - case ITEM_SUBCLASS_WEAPON_BOW: - case ITEM_SUBCLASS_WEAPON_CROSSBOW: - if (ammo_proto->SubClass != ITEM_SUBCLASS_ARROW) - return false; - break; - case ITEM_SUBCLASS_WEAPON_GUN: - if (ammo_proto->SubClass != ITEM_SUBCLASS_BULLET) - return false; - break; - default: + case ITEM_SUBCLASS_WEAPON_BOW: + case ITEM_SUBCLASS_WEAPON_CROSSBOW: + if (ammo_proto->SubClass != ITEM_SUBCLASS_ARROW) return false; + break; + case ITEM_SUBCLASS_WEAPON_GUN: + if (ammo_proto->SubClass != ITEM_SUBCLASS_BULLET) + return false; + break; + default: + return false; } return true; @@ -8241,7 +8262,7 @@ bool Player::CheckAmmoCompatibility(ItemTemplate const* ammo_proto) const void Player::SendLootRelease(ObjectGuid guid) const { - WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8+1)); + WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8 + 1)); data << uint64(guid) << uint8(1); SendDirectMessage(&data); } @@ -8255,11 +8276,11 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) PermissionTypes permission = ALL_PERMISSION; LOG_DEBUG("loot", "Player::SendLoot: Player: '%s' (%s), Loot: %s", - GetName().c_str(), GetGUID().ToString().c_str(), guid.ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), guid.ToString().c_str()); if (guid.IsGameObject()) { GameObject* go = GetMap()->GetGameObject(guid); - auto shouldLootRelease = [this](GameObject* go, LootType lootType) -> bool + auto shouldLootRelease = [this](GameObject * go, LootType lootType) -> bool { // not check distance for GO in case owned GO (fishing bobber case, for example) // And permit out of range GO with no owner in case fishing hole @@ -8295,7 +8316,8 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // loot was generated and respawntime has passed since then, allow to recreate loot // to avoid bugs, this rule covers spawned gameobjects only // Don't allow to regenerate chest loot inside instances and raids, to avoid exploits with duplicate boss loot being given for some encounters - if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && !go->GetMap()->Instanceable() && go->GetLootGenerationTime() + go->GetRespawnDelay() < GameTime::GetGameTime()) + if (go->isSpawnedByDefault() && go->getLootState() == GO_ACTIVATED && !go->loot.isLooted() && !go->GetMap()->Instanceable() + && go->GetLootGenerationTime() + go->GetRespawnDelay() < GameTime::GetGameTime()) go->SetLootState(GO_READY); if (go->getLootState() == GO_READY) @@ -8342,18 +8364,18 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) { switch (group->GetLootMethod()) { - case GROUP_LOOT: - // GroupLoot: rolls items over threshold. Items with quality < threshold, round robin - group->GroupLoot(loot, go); - break; - case NEED_BEFORE_GREED: - group->NeedBeforeGreed(loot, go); - break; - case MASTER_LOOT: - group->MasterLoot(loot, go); - break; - default: - break; + case GROUP_LOOT: + // GroupLoot: rolls items over threshold. Items with quality < threshold, round robin + group->GroupLoot(loot, go); + break; + case NEED_BEFORE_GREED: + group->NeedBeforeGreed(loot, go); + break; + case MASTER_LOOT: + group->MasterLoot(loot, go); + break; + default: + break; } } } @@ -8367,18 +8389,18 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) { switch (group->GetLootMethod()) { - case MASTER_LOOT: - permission = group->GetMasterLooterGuid() == GetGUID() ? MASTER_PERMISSION : RESTRICTED_PERMISSION; - break; - case FREE_FOR_ALL: - permission = ALL_PERMISSION; - break; - case ROUND_ROBIN: - permission = ROUND_ROBIN_PERMISSION; - break; - default: - permission = GROUP_PERMISSION; - break; + case MASTER_LOOT: + permission = group->GetMasterLooterGuid() == GetGUID() ? MASTER_PERMISSION : RESTRICTED_PERMISSION; + break; + case FREE_FOR_ALL: + permission = ALL_PERMISSION; + break; + case ROUND_ROBIN: + permission = ROUND_ROBIN_PERMISSION; + break; + default: + permission = GROUP_PERMISSION; + break; } } else @@ -8411,25 +8433,25 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) switch (loot_type) { - case LOOT_DISENCHANTING: - loot->FillLoot(item->GetTemplate()->DisenchantID, LootTemplates_Disenchant, this, true); - break; - case LOOT_PROSPECTING: - loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this, true); - break; - case LOOT_MILLING: - loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this, true); - break; - default: - loot->generateMoneyLoot(item->GetTemplate()->MinMoneyLoot, item->GetTemplate()->MaxMoneyLoot); - loot->FillLoot(item->GetEntry(), LootTemplates_Item, this, true, loot->gold != 0); + case LOOT_DISENCHANTING: + loot->FillLoot(item->GetTemplate()->DisenchantID, LootTemplates_Disenchant, this, true); + break; + case LOOT_PROSPECTING: + loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this, true); + break; + case LOOT_MILLING: + loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this, true); + break; + default: + loot->generateMoneyLoot(item->GetTemplate()->MinMoneyLoot, item->GetTemplate()->MaxMoneyLoot); + loot->FillLoot(item->GetEntry(), LootTemplates_Item, this, true, loot->gold != 0); - // Force save the loot and money items that were just rolled - // Also saves the container item ID in Loot struct (not to DB) - if (loot->gold > 0 || loot->unlootedCount > 0) - sLootItemStorage->AddNewStoredLoot(loot, this); + // Force save the loot and money items that were just rolled + // Also saves the container item ID in Loot struct (not to DB) + if (loot->gold > 0 || loot->unlootedCount > 0) + sLootItemStorage->AddNewStoredLoot(loot, this); - break; + break; } } } @@ -8539,18 +8561,18 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) { switch (group->GetLootMethod()) { - case GROUP_LOOT: - // GroupLoot: rolls items over threshold. Items with quality < threshold, round robin - group->GroupLoot(loot, creature); - break; - case NEED_BEFORE_GREED: - group->NeedBeforeGreed(loot, creature); - break; - case MASTER_LOOT: - group->MasterLoot(loot, creature); - break; - default: - break; + case GROUP_LOOT: + // GroupLoot: rolls items over threshold. Items with quality < threshold, round robin + group->GroupLoot(loot, creature); + break; + case NEED_BEFORE_GREED: + group->NeedBeforeGreed(loot, creature); + break; + case MASTER_LOOT: + group->MasterLoot(loot, creature); + break; + default: + break; } } } @@ -8580,18 +8602,18 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) { switch (group->GetLootMethod()) { - case MASTER_LOOT: - permission = group->GetMasterLooterGuid() == GetGUID() ? MASTER_PERMISSION : RESTRICTED_PERMISSION; - break; - case FREE_FOR_ALL: - permission = ALL_PERMISSION; - break; - case ROUND_ROBIN: - permission = ROUND_ROBIN_PERMISSION; - break; - default: - permission = GROUP_PERMISSION; - break; + case MASTER_LOOT: + permission = group->GetMasterLooterGuid() == GetGUID() ? MASTER_PERMISSION : RESTRICTED_PERMISSION; + break; + case FREE_FOR_ALL: + permission = ALL_PERMISSION; + break; + case ROUND_ROBIN: + permission = ROUND_ROBIN_PERMISSION; + break; + default: + permission = GROUP_PERMISSION; + break; } } else @@ -8608,10 +8630,17 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // LOOT_INSIGNIA and LOOT_FISHINGHOLE unsupported by client switch (loot_type) { - case LOOT_INSIGNIA: loot_type = LOOT_SKINNING; break; - case LOOT_FISHINGHOLE: loot_type = LOOT_FISHING; break; - case LOOT_FISHING_JUNK: loot_type = LOOT_FISHING; break; - default: break; + case LOOT_INSIGNIA: + loot_type = LOOT_SKINNING; + break; + case LOOT_FISHINGHOLE: + loot_type = LOOT_FISHING; + break; + case LOOT_FISHING_JUNK: + loot_type = LOOT_FISHING; + break; + default: + break; } // need know merged fishing/corpse loot type for achievements @@ -8711,564 +8740,564 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId) switch (zoneId) { - case 1: // Dun Morogh - case 11: // Wetlands - case 12: // Elwynn Forest - case 38: // Loch Modan - case 40: // Westfall - case 51: // Searing Gorge - case 1519: // Stormwind City - case 1537: // Ironforge - case 2257: // Deeprun Tram - case 3703: // Shattrath City - break; - case 139: // Eastern Plaguelands - if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_EP) - outdoorPvP->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2426, 0); // GENERAL_WORLDSTATES_01 "Progress: %2427w" - packet.Worldstates.emplace_back(2327, 0); // EP_UI_TOWER_COUNT_A - packet.Worldstates.emplace_back(2328, 0); // EP_UI_TOWER_COUNT_H - packet.Worldstates.emplace_back(2427, 50); // GENERAL_WORLDSTATES_02 - packet.Worldstates.emplace_back(2428, 50); // GENERAL_WORLDSTATES_03 - packet.Worldstates.emplace_back(2355, 1); // EP_CGT_N - packet.Worldstates.emplace_back(2374, 0); // EP_CGT_N_A - packet.Worldstates.emplace_back(2375, 0); // EP_CGT_N_H - packet.Worldstates.emplace_back(2376, 0); // GENERAL_WORLDSTATES_04 - packet.Worldstates.emplace_back(2377, 0); // GENERAL_WORLDSTATES_05 - packet.Worldstates.emplace_back(2378, 0); // EP_CGT_A - packet.Worldstates.emplace_back(2379, 0); // EP_CGT_H - packet.Worldstates.emplace_back(2354, 0); // EP_EWT_A - packet.Worldstates.emplace_back(2356, 0); // EP_EWT_H - packet.Worldstates.emplace_back(2357, 0); // GENERAL_WORLDSTATES_06 - packet.Worldstates.emplace_back(2358, 0); // GENERAL_WORLDSTATES_07 - packet.Worldstates.emplace_back(2359, 0); // EP_EWT_N_A - packet.Worldstates.emplace_back(2360, 0); // EP_EWT_N_H - packet.Worldstates.emplace_back(2361, 1); // EP_EWT_N - packet.Worldstates.emplace_back(2352, 1); // EP_NPT_N - packet.Worldstates.emplace_back(2362, 0); // EP_NPT_N_A - packet.Worldstates.emplace_back(2363, 0); // GENERAL_WORLDSTATES_08 - packet.Worldstates.emplace_back(2364, 0); // GENERAL_WORLDSTATES_09 - packet.Worldstates.emplace_back(2365, 0); // GENERAL_WORLDSTATES_10 - packet.Worldstates.emplace_back(2372, 0); // EP_NPT_A - packet.Worldstates.emplace_back(2373, 0); // EP_NPT_H - packet.Worldstates.emplace_back(2353, 1); // EP_PWT_N - packet.Worldstates.emplace_back(2366, 0); // EP_PWT_N_A - //packet.Worldstates.emplace_back(2367, 1); // GENERAL_WORLDSTATES_13 grey horde not in dbc! - packet.Worldstates.emplace_back(2368, 0); // GENERAL_WORLDSTATES_11 - packet.Worldstates.emplace_back(2369, 0); // GENERAL_WORLDSTATES_12 - packet.Worldstates.emplace_back(2370, 0); // EP_PWT_A - packet.Worldstates.emplace_back(2371, 0); // EP_PWT_H - } - break; - case 1377: // Silithus - if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_SI) - outdoorPvP->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2313, 0); // SI_GATHERED_A - packet.Worldstates.emplace_back(2314, 0); // SI_GATHERED_H - packet.Worldstates.emplace_back(2317, 0); // SI_SILITHYST_MAX - } - // unknown, aq opening? - packet.Worldstates.emplace_back(2322, 0); // AQ_SANDWORM_N - packet.Worldstates.emplace_back(2323, 0); // AQ_SANDWORM_S - packet.Worldstates.emplace_back(2324, 0); // AQ_SANDWORM_SW - packet.Worldstates.emplace_back(2325, 0); // AQ_SANDWORM_E - break; - case 2597: // Alterac Valley - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_AV) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(1966, 1); // AV_SNOWFALL_N - packet.Worldstates.emplace_back(1330, 1); // AV_FROSTWOLFHUT_H_C - packet.Worldstates.emplace_back(1329, 0); // AV_FROSTWOLFHUT_A_C - packet.Worldstates.emplace_back(1326, 0); // AV_AID_A_A - packet.Worldstates.emplace_back(1393, 0); // East Frostwolf Tower Horde Assaulted - UNUSED - packet.Worldstates.emplace_back(1392, 0); // West Frostwolf Tower Horde Assaulted - UNUSED - packet.Worldstates.emplace_back(1383, 1); // AV_FROSTWOLFE_CONTROLLED - packet.Worldstates.emplace_back(1382, 1); // AV_FROSTWOLFW_CONTROLLED - packet.Worldstates.emplace_back(1360, 1); // AV_N_MINE_N - packet.Worldstates.emplace_back(1348, 0); // AV_ICEBLOOD_A_A - packet.Worldstates.emplace_back(1334, 0); // AV_PIKEGRAVE_H_C - packet.Worldstates.emplace_back(1333, 1); // AV_PIKEGRAVE_A_C - packet.Worldstates.emplace_back(1304, 0); // AV_STONEHEART_A_A - packet.Worldstates.emplace_back(1303, 0); // AV_STONEHEART_H_A - packet.Worldstates.emplace_back(1396, 0); // unk - packet.Worldstates.emplace_back(1395, 0); // Iceblood Tower Horde Assaulted - UNUSED - packet.Worldstates.emplace_back(1394, 0); // Towerpoint Horde Assaulted - UNUSED - packet.Worldstates.emplace_back(1391, 0); // unk - packet.Worldstates.emplace_back(1390, 0); // AV_ICEBLOOD_ASSAULTED - packet.Worldstates.emplace_back(1389, 0); // AV_TOWERPOINT_ASSAULTED - packet.Worldstates.emplace_back(1388, 0); // AV_FROSTWOLFE_ASSAULTED - packet.Worldstates.emplace_back(1387, 0); // AV_FROSTWOLFW_ASSAULTED - packet.Worldstates.emplace_back(1386, 1); // unk - packet.Worldstates.emplace_back(1385, 1); // AV_ICEBLOOD_CONTROLLED - packet.Worldstates.emplace_back(1384, 1); // AV_TOWERPOINT_CONTROLLED - packet.Worldstates.emplace_back(1381, 0); // AV_STONEH_ASSAULTED - packet.Worldstates.emplace_back(1380, 0); // AV_ICEWING_ASSAULTED - packet.Worldstates.emplace_back(1379, 0); // AV_DUNN_ASSAULTED - packet.Worldstates.emplace_back(1378, 0); // AV_DUNS_ASSAULTED - packet.Worldstates.emplace_back(1377, 0); // Stoneheart Bunker Alliance Assaulted - UNUSED - packet.Worldstates.emplace_back(1376, 0); // Icewing Bunker Alliance Assaulted - UNUSED - packet.Worldstates.emplace_back(1375, 0); // Dunbaldar South Alliance Assaulted - UNUSED - packet.Worldstates.emplace_back(1374, 0); // Dunbaldar North Alliance Assaulted - UNUSED - packet.Worldstates.emplace_back(1373, 0); // AV_STONEH_DESTROYED - packet.Worldstates.emplace_back(966, 0); // AV_UNK_02 - packet.Worldstates.emplace_back(964, 0); // AV_UNK_01 - packet.Worldstates.emplace_back(962, 0); // AV_STORMPIKE_COMMANDERS - packet.Worldstates.emplace_back(1302, 1); // AV_STONEHEART_A_C - packet.Worldstates.emplace_back(1301, 0); // AV_STONEHEART_H_C - packet.Worldstates.emplace_back(950, 0); // AV_STORMPIKE_LIEUTENANTS - packet.Worldstates.emplace_back(1372, 0); // AV_ICEWING_DESTROYED - packet.Worldstates.emplace_back(1371, 0); // AV_DUNN_DESTROYED - packet.Worldstates.emplace_back(1370, 0); // AV_DUNS_DESTROYED - packet.Worldstates.emplace_back(1369, 0); // unk - packet.Worldstates.emplace_back(1368, 0); // AV_ICEBLOOD_DESTROYED - packet.Worldstates.emplace_back(1367, 0); // AV_TOWERPOINT_DESTROYED - packet.Worldstates.emplace_back(1366, 0); // AV_FROSTWOLFE_DESTROYED - packet.Worldstates.emplace_back(1365, 0); // AV_FROSTWOLFW_DESTROYED - packet.Worldstates.emplace_back(1364, 1); // AV_STONEH_CONTROLLED - packet.Worldstates.emplace_back(1363, 1); // AV_ICEWING_CONTROLLED - packet.Worldstates.emplace_back(1362, 1); // AV_DUNN_CONTROLLED - packet.Worldstates.emplace_back(1361, 1); // AV_DUNS_CONTROLLED - packet.Worldstates.emplace_back(1359, 0); // AV_N_MINE_H - packet.Worldstates.emplace_back(1358, 0); // AV_N_MINE_A - packet.Worldstates.emplace_back(1357, 1); // AV_S_MINE_N - packet.Worldstates.emplace_back(1356, 0); // AV_S_MINE_H - packet.Worldstates.emplace_back(1355, 0); // AV_S_MINE_A - packet.Worldstates.emplace_back(1349, 0); // AV_ICEBLOOD_H_A - packet.Worldstates.emplace_back(1347, 1); // AV_ICEBLOOD_H_C - packet.Worldstates.emplace_back(1346, 0); // AV_ICEBLOOD_A_C - packet.Worldstates.emplace_back(1344, 0); // AV_SNOWFALL_H_A - packet.Worldstates.emplace_back(1343, 0); // AV_SNOWFALL_A_A - packet.Worldstates.emplace_back(1342, 0); // AV_SNOWFALL_H_C - packet.Worldstates.emplace_back(1341, 0); // AV_SNOWFALL_A_C - packet.Worldstates.emplace_back(1340, 0); // AV_FROSTWOLF_H_A - packet.Worldstates.emplace_back(1339, 0); // AV_FROSTWOLF_A_A - packet.Worldstates.emplace_back(1338, 1); // AV_FROSTWOLF_H_C - packet.Worldstates.emplace_back(1337, 0); // AV_FROSTWOLF_A_C - packet.Worldstates.emplace_back(1336, 0); // AV_PIKEGRAVE_H_A - packet.Worldstates.emplace_back(1335, 0); // AV_PIKEGRAVE_A_A - packet.Worldstates.emplace_back(1332, 0); // AV_FROSTWOLFHUT_H_A - packet.Worldstates.emplace_back(1331, 0); // AV_FROSTWOLFHUT_A_A - packet.Worldstates.emplace_back(1328, 0); // AV_AID_H_A - packet.Worldstates.emplace_back(1327, 0); // AV_AID_H_C - packet.Worldstates.emplace_back(1325, 1); // AV_AID_A_C - } - break; - case 3277: // Warsong Gulch - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_WS) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(1581, 0); // alliance flag captures - packet.Worldstates.emplace_back(1582, 0); // horde flag captures - packet.Worldstates.emplace_back(1545, 0); // unk, set to 1 on alliance flag pickup... - packet.Worldstates.emplace_back(1546, 0); // unk, set to 1 on horde flag pickup, after drop it's -1 - packet.Worldstates.emplace_back(1547, 2); // unk - packet.Worldstates.emplace_back(1601, 3); // unk (max flag captures?) - packet.Worldstates.emplace_back(2338, 1); // horde (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) - packet.Worldstates.emplace_back(2339, 1); // alliance (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) - } - break; - case 3358: // Arathi Basin - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_AB) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(1767, 0); // stables alliance - packet.Worldstates.emplace_back(1768, 0); // stables horde - packet.Worldstates.emplace_back(1769, 0); // stables alliance controlled - packet.Worldstates.emplace_back(1770, 0); // stables horde controlled - packet.Worldstates.emplace_back(1772, 0); // farm alliance - packet.Worldstates.emplace_back(1773, 0); // farm horde - packet.Worldstates.emplace_back(1774, 0); // farm alliance controlled - packet.Worldstates.emplace_back(1775, 0); // farm horde controlled - packet.Worldstates.emplace_back(1776, 0); // alliance resources - packet.Worldstates.emplace_back(1777, 0); // horde resources - packet.Worldstates.emplace_back(1778, 0); // horde bases - packet.Worldstates.emplace_back(1779, 0); // alliance bases - packet.Worldstates.emplace_back(1780, 2000); // max resources (2000) - packet.Worldstates.emplace_back(1782, 0); // blacksmith alliance - packet.Worldstates.emplace_back(1783, 0); // blacksmith horde - packet.Worldstates.emplace_back(1784, 0); // blacksmith alliance controlled - packet.Worldstates.emplace_back(1785, 0); // blacksmith horde controlled - packet.Worldstates.emplace_back(1787, 0); // gold mine alliance - packet.Worldstates.emplace_back(1788, 0); // gold mine horde - packet.Worldstates.emplace_back(1789, 0); // gold mine alliance controlled - packet.Worldstates.emplace_back(1790, 0); // gold mine horde controlled - packet.Worldstates.emplace_back(1792, 0); // lumber mill alliance - packet.Worldstates.emplace_back(1793, 0); // lumber mill horde - packet.Worldstates.emplace_back(1794, 0); // lumber mill alliance controlled - packet.Worldstates.emplace_back(1795, 0); // lumber mill horde controlled - packet.Worldstates.emplace_back(1842, 1); // stables (1 - uncontrolled) - packet.Worldstates.emplace_back(1843, 1); // gold mine (1 - uncontrolled) - packet.Worldstates.emplace_back(1844, 1); // lumber mill (1 - uncontrolled) - packet.Worldstates.emplace_back(1845, 1); // farm (1 - uncontrolled) - packet.Worldstates.emplace_back(1846, 1); // blacksmith (1 - uncontrolled) - packet.Worldstates.emplace_back(1861, 2); // unk - packet.Worldstates.emplace_back(1955, 1800); // warning limit (1800) - } - break; - case 3820: // Eye of the Storm - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_EY) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2753, 0); // Horde Bases - packet.Worldstates.emplace_back(2752, 0); // Alliance Bases - packet.Worldstates.emplace_back(2742, 0); // Mage Tower - Horde conflict - packet.Worldstates.emplace_back(2741, 0); // Mage Tower - Alliance conflict - packet.Worldstates.emplace_back(2740, 0); // Fel Reaver - Horde conflict - packet.Worldstates.emplace_back(2739, 0); // Fel Reaver - Alliance conflict - packet.Worldstates.emplace_back(2738, 0); // Draenei - Alliance conflict - packet.Worldstates.emplace_back(2737, 0); // Draenei - Horde conflict - packet.Worldstates.emplace_back(2736, 0); // unk (0 at start) - packet.Worldstates.emplace_back(2735, 0); // unk (0 at start) - packet.Worldstates.emplace_back(2733, 0); // Draenei - Horde control - packet.Worldstates.emplace_back(2732, 0); // Draenei - Alliance control - packet.Worldstates.emplace_back(2731, 1); // Draenei uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(2730, 0); // Mage Tower - Alliance control - packet.Worldstates.emplace_back(2729, 0); // Mage Tower - Horde control - packet.Worldstates.emplace_back(2728, 1); // Mage Tower uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(2727, 0); // Fel Reaver - Horde control - packet.Worldstates.emplace_back(2726, 0); // Fel Reaver - Alliance control - packet.Worldstates.emplace_back(2725, 1); // Fel Reaver uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(2724, 0); // Boold Elf - Horde control - packet.Worldstates.emplace_back(2723, 0); // Boold Elf - Alliance control - packet.Worldstates.emplace_back(2722, 1); // Boold Elf uncontrolled (1 - yes, 0 - no) - packet.Worldstates.emplace_back(2757, 1); // Flag (1 - show, 0 - hide) - doesn't work exactly this way! - packet.Worldstates.emplace_back(2770, 1); // Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag - packet.Worldstates.emplace_back(2769, 1); // Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag - packet.Worldstates.emplace_back(2750, 0); // Horde resources - packet.Worldstates.emplace_back(2749, 0); // Alliance resources - packet.Worldstates.emplace_back(2565, 142); // unk, constant? - packet.Worldstates.emplace_back(2720, 0); // Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0) - packet.Worldstates.emplace_back(2719, 0); // Capturing progress-bar (0 - left, 100 - right) - packet.Worldstates.emplace_back(2718, 0); // Capturing progress-bar (1 - show, 0 - hide) - packet.Worldstates.emplace_back(3085, 379); // unk, constant? - // missing unknowns - } - break; - case 3483: // Hellfire Peninsula - if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_HP) - outdoorPvP->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2490, 1); // add ally tower main gui icon - packet.Worldstates.emplace_back(2489, 1); // add horde tower main gui icon - packet.Worldstates.emplace_back(2485, 0); // show neutral broken hill icon - packet.Worldstates.emplace_back(2484, 1); // show icon above broken hill - packet.Worldstates.emplace_back(2483, 0); // show ally broken hill icon - packet.Worldstates.emplace_back(2482, 0); // show neutral overlook icon - packet.Worldstates.emplace_back(2481, 1); // show the overlook arrow - packet.Worldstates.emplace_back(2480, 0); // show ally overlook icon - packet.Worldstates.emplace_back(2478, 0); // horde pvp objectives captured - packet.Worldstates.emplace_back(2476, 0); // ally pvp objectives captured - packet.Worldstates.emplace_back(2475, 100); // horde slider grey area - packet.Worldstates.emplace_back(2474, 50); // horde slider percentage, 100 for ally, 0 for horde - packet.Worldstates.emplace_back(2473, 0); // horde slider display - packet.Worldstates.emplace_back(2472, 0); // show the neutral stadium icon - packet.Worldstates.emplace_back(2471, 0); // show the ally stadium icon - packet.Worldstates.emplace_back(2470, 1); // show the horde stadium icon - } - break; - case 3518: // Nagrand - if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_NA) - outdoorPvP->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2503, 0); // NA_UI_HORDE_GUARDS_SHOW - packet.Worldstates.emplace_back(2502, 0); // NA_UI_ALLIANCE_GUARDS_SHOW - packet.Worldstates.emplace_back(2493, 0); // NA_UI_GUARDS_MAX - packet.Worldstates.emplace_back(2491, 0); // NA_UI_GUARDS_LEFT - packet.Worldstates.emplace_back(2495, 0); // NA_UI_OUTLAND_01 - packet.Worldstates.emplace_back(2494, 0); // NA_UI_UNK_1 - packet.Worldstates.emplace_back(2497, 0); // NA_UI_UNK_2 - packet.Worldstates.emplace_back(2762, 0); // NA_MAP_WYVERN_NORTH_NEU_H - packet.Worldstates.emplace_back(2662, 0); // NA_MAP_WYVERN_NORTH_NEU_A - packet.Worldstates.emplace_back(2663, 0); // NA_MAP_WYVERN_NORTH_H - packet.Worldstates.emplace_back(2664, 0); // NA_MAP_WYVERN_NORTH_A - packet.Worldstates.emplace_back(2760, 0); // NA_MAP_WYVERN_SOUTH_NEU_H - packet.Worldstates.emplace_back(2670, 0); // NA_MAP_WYVERN_SOUTH_NEU_A - packet.Worldstates.emplace_back(2668, 0); // NA_MAP_WYVERN_SOUTH_H - packet.Worldstates.emplace_back(2669, 0); // NA_MAP_WYVERN_SOUTH_A - packet.Worldstates.emplace_back(2761, 0); // NA_MAP_WYVERN_WEST_NEU_H - packet.Worldstates.emplace_back(2667, 0); // NA_MAP_WYVERN_WEST_NEU_A - packet.Worldstates.emplace_back(2665, 0); // NA_MAP_WYVERN_WEST_H - packet.Worldstates.emplace_back(2666, 0); // NA_MAP_WYVERN_WEST_A - packet.Worldstates.emplace_back(2763, 0); // NA_MAP_WYVERN_EAST_NEU_H - packet.Worldstates.emplace_back(2659, 0); // NA_MAP_WYVERN_EAST_NEU_A - packet.Worldstates.emplace_back(2660, 0); // NA_MAP_WYVERN_EAST_H - packet.Worldstates.emplace_back(2661, 0); // NA_MAP_WYVERN_EAST_A - packet.Worldstates.emplace_back(2671, 0); // NA_MAP_HALAA_NEUTRAL - packet.Worldstates.emplace_back(2676, 0); // NA_MAP_HALAA_NEU_A - packet.Worldstates.emplace_back(2677, 0); // NA_MAP_HALAA_NEU_H - packet.Worldstates.emplace_back(2672, 0); // NA_MAP_HALAA_HORDE - packet.Worldstates.emplace_back(2673, 0); // NA_MAP_HALAA_ALLIANCE - } - break; - case 3519: // Terokkar Forest - if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_TF) - outdoorPvP->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2625, 0); // TF_UI_CAPTURE_BAR_POS - packet.Worldstates.emplace_back(2624, 20); // TF_UI_CAPTURE_BAR_NEUTRAL - packet.Worldstates.emplace_back(2623, 0); // TF_UI_SHOW CAPTURE BAR - packet.Worldstates.emplace_back(2622, 0); // TF_UI_TOWER_COUNT_H - packet.Worldstates.emplace_back(2621, 5); // TF_UI_TOWER_COUNT_A - packet.Worldstates.emplace_back(2620, 0); // TF_UI_TOWERS_CONTROLLED_DISPLAY - packet.Worldstates.emplace_back(2696, 0); // TF_TOWER_NUM_15 - SE Neutral - packet.Worldstates.emplace_back(2695, 0); // TF_TOWER_NUM_14 - SE Horde - packet.Worldstates.emplace_back(2694, 0); // TF_TOWER_NUM_13 - SE Alliance - packet.Worldstates.emplace_back(2693, 0); // TF_TOWER_NUM_12 - S Neutral - packet.Worldstates.emplace_back(2692, 0); // TF_TOWER_NUM_11 - S Horde - packet.Worldstates.emplace_back(2691, 0); // TF_TOWER_NUM_10 - S Alliance - packet.Worldstates.emplace_back(2690, 0); // TF_TOWER_NUM_09 - NE Neutral - packet.Worldstates.emplace_back(2689, 0); // TF_TOWER_NUM_08 - NE Horde - packet.Worldstates.emplace_back(2688, 0); // TF_TOWER_NUM_07 - NE Alliance - packet.Worldstates.emplace_back(2687, 0); // TF_TOWER_NUM_16 - unk - packet.Worldstates.emplace_back(2686, 0); // TF_TOWER_NUM_06 - N Neutral - packet.Worldstates.emplace_back(2685, 0); // TF_TOWER_NUM_05 - N Horde - packet.Worldstates.emplace_back(2684, 0); // TF_TOWER_NUM_04 - N Alliance - packet.Worldstates.emplace_back(2683, 0); // TF_TOWER_NUM_03 - NW Alliance - packet.Worldstates.emplace_back(2682, 0); // TF_TOWER_NUM_02 - NW Horde - packet.Worldstates.emplace_back(2681, 0); // TF_TOWER_NUM_01 - NW Neutral - packet.Worldstates.emplace_back(2512, 5); // TF_UI_LOCKED_TIME_MINUTES_FIRST_DIGIT - packet.Worldstates.emplace_back(2510, 0); // TF_UI_LOCKED_TIME_MINUTES_SECOND_DIGIT - packet.Worldstates.emplace_back(2509, 0); // TF_UI_LOCKED_TIME_HOURS - packet.Worldstates.emplace_back(2508, 0); // TF_UI_LOCKED_DISPLAY_NEUTRAL - packet.Worldstates.emplace_back(2768, 0); // TF_UI_LOCKED_DISPLAY_HORDE - packet.Worldstates.emplace_back(2767, 1); // TF_UI_LOCKED_DISPLAY_ALLIANCE - } - break; - case 3521: // Zangarmarsh - if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_ZM) - outdoorPvP->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2529, 0); // ZM_UNK_1 - packet.Worldstates.emplace_back(2528, 0); // ZM_UNK_2 - packet.Worldstates.emplace_back(2527, 0); // ZM_UNK_3 - packet.Worldstates.emplace_back(2653, 1); // ZM_WORLDSTATE_UNK_1 - packet.Worldstates.emplace_back(2652, 0); // ZM_MAP_TOWER_EAST_N - packet.Worldstates.emplace_back(2651, 1); // ZM_MAP_TOWER_EAST_H - packet.Worldstates.emplace_back(2650, 0); // ZM_MAP_TOWER_EAST_A - packet.Worldstates.emplace_back(2649, 1); // ZM_MAP_GRAVEYARD_H - Twin spire graveyard horde - packet.Worldstates.emplace_back(2648, 0); // ZM_MAP_GRAVEYARD_A - packet.Worldstates.emplace_back(2647, 0); // ZM_MAP_GRAVEYARD_N - packet.Worldstates.emplace_back(2646, 0); // ZM_MAP_TOWER_WEST_N - packet.Worldstates.emplace_back(2645, 1); // ZM_MAP_TOWER_WEST_H - packet.Worldstates.emplace_back(2644, 0); // ZM_MAP_TOWER_WEST_A - packet.Worldstates.emplace_back(2535, 0); // ZM_UNK_4 - packet.Worldstates.emplace_back(2534, 0); // ZM_UNK_5 - packet.Worldstates.emplace_back(2533, 0); // ZM_UNK_6 - packet.Worldstates.emplace_back(2560, 0); // ZM_UI_TOWER_EAST_N - packet.Worldstates.emplace_back(2559, 1); // ZM_UI_TOWER_EAST_H - packet.Worldstates.emplace_back(2558, 0); // ZM_UI_TOWER_EAST_A - packet.Worldstates.emplace_back(2557, 0); // ZM_UI_TOWER_WEST_N - packet.Worldstates.emplace_back(2556, 1); // ZM_UI_TOWER_WEST_H - packet.Worldstates.emplace_back(2555, 0); // ZM_UI_TOWER_WEST_A - packet.Worldstates.emplace_back(2658, 0); // ZM_MAP_HORDE_FLAG_READY - packet.Worldstates.emplace_back(2657, 1); // ZM_MAP_HORDE_FLAG_NOT_READY - packet.Worldstates.emplace_back(2656, 1); // ZM_MAP_ALLIANCE_FLAG_NOT_READY - packet.Worldstates.emplace_back(2655, 0); // ZM_MAP_ALLIANCE_FLAG_READY - } - break; - case 3698: // Nagrand Arena - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_NA) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2575, 0); // BATTLEGROUND_NAGRAND_ARENA_GOLD - packet.Worldstates.emplace_back(2576, 0); // BATTLEGROUND_NAGRAND_ARENA_GREEN - packet.Worldstates.emplace_back(2577, 0); // BATTLEGROUND_NAGRAND_ARENA_SHOW - } - break; - case 3702: // Blade's Edge Arena - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_BE) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(2544, 0); // BATTLEGROUND_BLADES_EDGE_ARENA_GOLD - packet.Worldstates.emplace_back(2545, 0); // BATTLEGROUND_BLADES_EDGE_ARENA_GREEN - packet.Worldstates.emplace_back(2547, 0); // BATTLEGROUND_BLADES_EDGE_ARENA_SHOW - } - break; - case 3968: // Ruins of Lordaeron - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_RL) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(3000, 0); // BATTELGROUND_RUINS_OF_LORDAERNON_GOLD - packet.Worldstates.emplace_back(3001, 0); // BATTELGROUND_RUINS_OF_LORDAERNON_GREEN - packet.Worldstates.emplace_back(3002, 0); // BATTELGROUND_RUINS_OF_LORDAERNON_SHOW - } - break; - case 4378: // Dalaran Sewers - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_DS) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(3601, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GOLD - packet.Worldstates.emplace_back(3600, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GREEN - packet.Worldstates.emplace_back(3610, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_SHOW - } - break; - case 4384: // Strand of the Ancients - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_SA) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(3849, 0); // Gate of Temple - packet.Worldstates.emplace_back(3638, 0); // Gate of Yellow Moon - packet.Worldstates.emplace_back(3623, 0); // Gate of Green Emerald - packet.Worldstates.emplace_back(3620, 0); // Gate of Blue Sapphire - packet.Worldstates.emplace_back(3617, 0); // Gate of Red Sun - packet.Worldstates.emplace_back(3614, 0); // Gate of Purple Ametyst - packet.Worldstates.emplace_back(3571, 0); // bonus timer (1 - on, 0 - off) - packet.Worldstates.emplace_back(3565, 0); // Horde Attacker - packet.Worldstates.emplace_back(3564, 0); // Alliance Attacker - - // End Round timer, example: 19:59 -> A:BC - packet.Worldstates.emplace_back(3561, 0); // C - packet.Worldstates.emplace_back(3560, 0); // B - packet.Worldstates.emplace_back(3559, 0); // A - - packet.Worldstates.emplace_back(3637, 0); // BG_SA_CENTER_GY_ALLIANCE - packet.Worldstates.emplace_back(3636, 0); // BG_SA_RIGHT_GY_ALLIANCE - packet.Worldstates.emplace_back(3635, 0); // BG_SA_LEFT_GY_ALLIANCE - packet.Worldstates.emplace_back(3634, 0); // BG_SA_CENTER_GY_HORDE - packet.Worldstates.emplace_back(3633, 0); // BG_SA_LEFT_GY_HORDE - packet.Worldstates.emplace_back(3632, 0); // BG_SA_RIGHT_GY_HORDE - packet.Worldstates.emplace_back(3631, 0); // BG_SA_HORDE_DEFENCE_TOKEN - packet.Worldstates.emplace_back(3630, 0); // BG_SA_ALLIANCE_DEFENCE_TOKEN - packet.Worldstates.emplace_back(3629, 0); // BG_SA_LEFT_ATT_TOKEN_HRD - packet.Worldstates.emplace_back(3628, 0); // BG_SA_RIGHT_ATT_TOKEN_HRD - packet.Worldstates.emplace_back(3627, 0); // BG_SA_RIGHT_ATT_TOKEN_ALL - packet.Worldstates.emplace_back(3626, 0); // BG_SA_LEFT_ATT_TOKEN_ALL - // missing unknowns - } - break; - case 4406: // Ring of Valor - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_RV) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(3600, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GREEN - packet.Worldstates.emplace_back(3601, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GOLD - packet.Worldstates.emplace_back(3610, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_SHOW - } - break; - case 4710: // Isle of Conquest - if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_IC) - battleground->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(4221, 1); // BG_IC_ALLIANCE_RENFORT_SET - packet.Worldstates.emplace_back(4222, 1); // BG_IC_HORDE_RENFORT_SET - packet.Worldstates.emplace_back(4226, 300); // BG_IC_ALLIANCE_RENFORT - packet.Worldstates.emplace_back(4227, 300); // BG_IC_HORDE_RENFORT - packet.Worldstates.emplace_back(4322, 1); // BG_IC_GATE_FRONT_H_WS_OPEN - packet.Worldstates.emplace_back(4321, 1); // BG_IC_GATE_WEST_H_WS_OPEN - packet.Worldstates.emplace_back(4320, 1); // BG_IC_GATE_EAST_H_WS_OPEN - packet.Worldstates.emplace_back(4323, 1); // BG_IC_GATE_FRONT_A_WS_OPEN - packet.Worldstates.emplace_back(4324, 1); // BG_IC_GATE_WEST_A_WS_OPEN - packet.Worldstates.emplace_back(4325, 1); // BG_IC_GATE_EAST_A_WS_OPEN - packet.Worldstates.emplace_back(4317, 1); // unk - packet.Worldstates.emplace_back(4301, 1); // BG_IC_DOCKS_UNCONTROLLED - packet.Worldstates.emplace_back(4296, 1); // BG_IC_HANGAR_UNCONTROLLED - packet.Worldstates.emplace_back(4306, 1); // BG_IC_QUARRY_UNCONTROLLED - packet.Worldstates.emplace_back(4311, 1); // BG_IC_REFINERY_UNCONTROLLED - packet.Worldstates.emplace_back(4294, 1); // BG_IC_WORKSHOP_UNCONTROLLED - packet.Worldstates.emplace_back(4243, 1); // unk - packet.Worldstates.emplace_back(4345, 1); // unk - } - break; - case 4987: // The Ruby Sanctum - if (instance) - instance->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(5049, 50); // WORLDSTATE_CORPOREALITY_MATERIAL - packet.Worldstates.emplace_back(5050, 50); // WORLDSTATE_CORPOREALITY_TWILIGHT - packet.Worldstates.emplace_back(5051, 0); // WORLDSTATE_CORPOREALITY_TOGGLE - } - break; - case 4812: // Icecrown Citadel - if (instance) - instance->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(4903, 0); // WORLDSTATE_SHOW_TIMER (Blood Quickening weekly) - packet.Worldstates.emplace_back(4904, 30); // WORLDSTATE_EXECUTION_TIME - packet.Worldstates.emplace_back(4940, 0); // WORLDSTATE_SHOW_ATTEMPTS - packet.Worldstates.emplace_back(4941, 50); // WORLDSTATE_ATTEMPTS_REMAINING - packet.Worldstates.emplace_back(4942, 50); // WORLDSTATE_ATTEMPTS_MAX - } - break; - case 4100: // The Culling of Stratholme - if (instance) - instance->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(3479, 0); // WORLDSTATE_SHOW_CRATES - packet.Worldstates.emplace_back(3480, 0); // WORLDSTATE_CRATES_REVEALED - packet.Worldstates.emplace_back(3504, 0); // WORLDSTATE_WAVE_COUNT - packet.Worldstates.emplace_back(3931, 25); // WORLDSTATE_TIME_GUARDIAN - packet.Worldstates.emplace_back(3932, 0); // WORLDSTATE_TIME_GUARDIAN_SHOW - } - break; - case 4228: // The Oculus - if (instance) - instance->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(3524, 0); // WORLD_STATE_CENTRIFUGE_CONSTRUCT_SHOW - packet.Worldstates.emplace_back(3486, 0); // WORLD_STATE_CENTRIFUGE_CONSTRUCT_AMOUNT - } - break; - case 4273: // Ulduar - if (instance) - instance->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(4132, 0); // WORLDSTATE_ALGALON_TIMER_ENABLED - packet.Worldstates.emplace_back(4131, 0); // WORLDSTATE_ALGALON_DESPAWN_TIMER - } - break; - case 4415: // Violet Hold - if (instance) - instance->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(3816, 0); // WORLD_STATE_VH_SHOW - packet.Worldstates.emplace_back(3815, 100); // WORLD_STATE_VH_PRISON_STATE - packet.Worldstates.emplace_back(3810, 0); // WORLD_STATE_VH_WAVE_COUNT - } - break; - case 4820: // Halls of Refection - if (instance) - instance->FillInitialWorldStates(packet); - else - { - packet.Worldstates.emplace_back(4884, 0); // WORLD_STATE_HOR_WAVES_ENABLED - packet.Worldstates.emplace_back(4882, 0); // WORLD_STATE_HOR_WAVE_COUNT - } - break; - case AREA_WINTERGRASP: // Wintergrasp - if (battlefield && battlefield->GetTypeId() == BATTLEFIELD_WG) - battlefield->FillInitialWorldStates(packet); - else - { - } - break; - default: - break; + case 1: // Dun Morogh + case 11: // Wetlands + case 12: // Elwynn Forest + case 38: // Loch Modan + case 40: // Westfall + case 51: // Searing Gorge + case 1519: // Stormwind City + case 1537: // Ironforge + case 2257: // Deeprun Tram + case 3703: // Shattrath City + break; + case 139: // Eastern Plaguelands + if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_EP) + outdoorPvP->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2426, 0); // GENERAL_WORLDSTATES_01 "Progress: %2427w" + packet.Worldstates.emplace_back(2327, 0); // EP_UI_TOWER_COUNT_A + packet.Worldstates.emplace_back(2328, 0); // EP_UI_TOWER_COUNT_H + packet.Worldstates.emplace_back(2427, 50); // GENERAL_WORLDSTATES_02 + packet.Worldstates.emplace_back(2428, 50); // GENERAL_WORLDSTATES_03 + packet.Worldstates.emplace_back(2355, 1); // EP_CGT_N + packet.Worldstates.emplace_back(2374, 0); // EP_CGT_N_A + packet.Worldstates.emplace_back(2375, 0); // EP_CGT_N_H + packet.Worldstates.emplace_back(2376, 0); // GENERAL_WORLDSTATES_04 + packet.Worldstates.emplace_back(2377, 0); // GENERAL_WORLDSTATES_05 + packet.Worldstates.emplace_back(2378, 0); // EP_CGT_A + packet.Worldstates.emplace_back(2379, 0); // EP_CGT_H + packet.Worldstates.emplace_back(2354, 0); // EP_EWT_A + packet.Worldstates.emplace_back(2356, 0); // EP_EWT_H + packet.Worldstates.emplace_back(2357, 0); // GENERAL_WORLDSTATES_06 + packet.Worldstates.emplace_back(2358, 0); // GENERAL_WORLDSTATES_07 + packet.Worldstates.emplace_back(2359, 0); // EP_EWT_N_A + packet.Worldstates.emplace_back(2360, 0); // EP_EWT_N_H + packet.Worldstates.emplace_back(2361, 1); // EP_EWT_N + packet.Worldstates.emplace_back(2352, 1); // EP_NPT_N + packet.Worldstates.emplace_back(2362, 0); // EP_NPT_N_A + packet.Worldstates.emplace_back(2363, 0); // GENERAL_WORLDSTATES_08 + packet.Worldstates.emplace_back(2364, 0); // GENERAL_WORLDSTATES_09 + packet.Worldstates.emplace_back(2365, 0); // GENERAL_WORLDSTATES_10 + packet.Worldstates.emplace_back(2372, 0); // EP_NPT_A + packet.Worldstates.emplace_back(2373, 0); // EP_NPT_H + packet.Worldstates.emplace_back(2353, 1); // EP_PWT_N + packet.Worldstates.emplace_back(2366, 0); // EP_PWT_N_A + //packet.Worldstates.emplace_back(2367, 1); // GENERAL_WORLDSTATES_13 grey horde not in dbc! + packet.Worldstates.emplace_back(2368, 0); // GENERAL_WORLDSTATES_11 + packet.Worldstates.emplace_back(2369, 0); // GENERAL_WORLDSTATES_12 + packet.Worldstates.emplace_back(2370, 0); // EP_PWT_A + packet.Worldstates.emplace_back(2371, 0); // EP_PWT_H + } + break; + case 1377: // Silithus + if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_SI) + outdoorPvP->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2313, 0); // SI_GATHERED_A + packet.Worldstates.emplace_back(2314, 0); // SI_GATHERED_H + packet.Worldstates.emplace_back(2317, 0); // SI_SILITHYST_MAX + } + // unknown, aq opening? + packet.Worldstates.emplace_back(2322, 0); // AQ_SANDWORM_N + packet.Worldstates.emplace_back(2323, 0); // AQ_SANDWORM_S + packet.Worldstates.emplace_back(2324, 0); // AQ_SANDWORM_SW + packet.Worldstates.emplace_back(2325, 0); // AQ_SANDWORM_E + break; + case 2597: // Alterac Valley + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_AV) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(1966, 1); // AV_SNOWFALL_N + packet.Worldstates.emplace_back(1330, 1); // AV_FROSTWOLFHUT_H_C + packet.Worldstates.emplace_back(1329, 0); // AV_FROSTWOLFHUT_A_C + packet.Worldstates.emplace_back(1326, 0); // AV_AID_A_A + packet.Worldstates.emplace_back(1393, 0); // East Frostwolf Tower Horde Assaulted - UNUSED + packet.Worldstates.emplace_back(1392, 0); // West Frostwolf Tower Horde Assaulted - UNUSED + packet.Worldstates.emplace_back(1383, 1); // AV_FROSTWOLFE_CONTROLLED + packet.Worldstates.emplace_back(1382, 1); // AV_FROSTWOLFW_CONTROLLED + packet.Worldstates.emplace_back(1360, 1); // AV_N_MINE_N + packet.Worldstates.emplace_back(1348, 0); // AV_ICEBLOOD_A_A + packet.Worldstates.emplace_back(1334, 0); // AV_PIKEGRAVE_H_C + packet.Worldstates.emplace_back(1333, 1); // AV_PIKEGRAVE_A_C + packet.Worldstates.emplace_back(1304, 0); // AV_STONEHEART_A_A + packet.Worldstates.emplace_back(1303, 0); // AV_STONEHEART_H_A + packet.Worldstates.emplace_back(1396, 0); // unk + packet.Worldstates.emplace_back(1395, 0); // Iceblood Tower Horde Assaulted - UNUSED + packet.Worldstates.emplace_back(1394, 0); // Towerpoint Horde Assaulted - UNUSED + packet.Worldstates.emplace_back(1391, 0); // unk + packet.Worldstates.emplace_back(1390, 0); // AV_ICEBLOOD_ASSAULTED + packet.Worldstates.emplace_back(1389, 0); // AV_TOWERPOINT_ASSAULTED + packet.Worldstates.emplace_back(1388, 0); // AV_FROSTWOLFE_ASSAULTED + packet.Worldstates.emplace_back(1387, 0); // AV_FROSTWOLFW_ASSAULTED + packet.Worldstates.emplace_back(1386, 1); // unk + packet.Worldstates.emplace_back(1385, 1); // AV_ICEBLOOD_CONTROLLED + packet.Worldstates.emplace_back(1384, 1); // AV_TOWERPOINT_CONTROLLED + packet.Worldstates.emplace_back(1381, 0); // AV_STONEH_ASSAULTED + packet.Worldstates.emplace_back(1380, 0); // AV_ICEWING_ASSAULTED + packet.Worldstates.emplace_back(1379, 0); // AV_DUNN_ASSAULTED + packet.Worldstates.emplace_back(1378, 0); // AV_DUNS_ASSAULTED + packet.Worldstates.emplace_back(1377, 0); // Stoneheart Bunker Alliance Assaulted - UNUSED + packet.Worldstates.emplace_back(1376, 0); // Icewing Bunker Alliance Assaulted - UNUSED + packet.Worldstates.emplace_back(1375, 0); // Dunbaldar South Alliance Assaulted - UNUSED + packet.Worldstates.emplace_back(1374, 0); // Dunbaldar North Alliance Assaulted - UNUSED + packet.Worldstates.emplace_back(1373, 0); // AV_STONEH_DESTROYED + packet.Worldstates.emplace_back(966, 0); // AV_UNK_02 + packet.Worldstates.emplace_back(964, 0); // AV_UNK_01 + packet.Worldstates.emplace_back(962, 0); // AV_STORMPIKE_COMMANDERS + packet.Worldstates.emplace_back(1302, 1); // AV_STONEHEART_A_C + packet.Worldstates.emplace_back(1301, 0); // AV_STONEHEART_H_C + packet.Worldstates.emplace_back(950, 0); // AV_STORMPIKE_LIEUTENANTS + packet.Worldstates.emplace_back(1372, 0); // AV_ICEWING_DESTROYED + packet.Worldstates.emplace_back(1371, 0); // AV_DUNN_DESTROYED + packet.Worldstates.emplace_back(1370, 0); // AV_DUNS_DESTROYED + packet.Worldstates.emplace_back(1369, 0); // unk + packet.Worldstates.emplace_back(1368, 0); // AV_ICEBLOOD_DESTROYED + packet.Worldstates.emplace_back(1367, 0); // AV_TOWERPOINT_DESTROYED + packet.Worldstates.emplace_back(1366, 0); // AV_FROSTWOLFE_DESTROYED + packet.Worldstates.emplace_back(1365, 0); // AV_FROSTWOLFW_DESTROYED + packet.Worldstates.emplace_back(1364, 1); // AV_STONEH_CONTROLLED + packet.Worldstates.emplace_back(1363, 1); // AV_ICEWING_CONTROLLED + packet.Worldstates.emplace_back(1362, 1); // AV_DUNN_CONTROLLED + packet.Worldstates.emplace_back(1361, 1); // AV_DUNS_CONTROLLED + packet.Worldstates.emplace_back(1359, 0); // AV_N_MINE_H + packet.Worldstates.emplace_back(1358, 0); // AV_N_MINE_A + packet.Worldstates.emplace_back(1357, 1); // AV_S_MINE_N + packet.Worldstates.emplace_back(1356, 0); // AV_S_MINE_H + packet.Worldstates.emplace_back(1355, 0); // AV_S_MINE_A + packet.Worldstates.emplace_back(1349, 0); // AV_ICEBLOOD_H_A + packet.Worldstates.emplace_back(1347, 1); // AV_ICEBLOOD_H_C + packet.Worldstates.emplace_back(1346, 0); // AV_ICEBLOOD_A_C + packet.Worldstates.emplace_back(1344, 0); // AV_SNOWFALL_H_A + packet.Worldstates.emplace_back(1343, 0); // AV_SNOWFALL_A_A + packet.Worldstates.emplace_back(1342, 0); // AV_SNOWFALL_H_C + packet.Worldstates.emplace_back(1341, 0); // AV_SNOWFALL_A_C + packet.Worldstates.emplace_back(1340, 0); // AV_FROSTWOLF_H_A + packet.Worldstates.emplace_back(1339, 0); // AV_FROSTWOLF_A_A + packet.Worldstates.emplace_back(1338, 1); // AV_FROSTWOLF_H_C + packet.Worldstates.emplace_back(1337, 0); // AV_FROSTWOLF_A_C + packet.Worldstates.emplace_back(1336, 0); // AV_PIKEGRAVE_H_A + packet.Worldstates.emplace_back(1335, 0); // AV_PIKEGRAVE_A_A + packet.Worldstates.emplace_back(1332, 0); // AV_FROSTWOLFHUT_H_A + packet.Worldstates.emplace_back(1331, 0); // AV_FROSTWOLFHUT_A_A + packet.Worldstates.emplace_back(1328, 0); // AV_AID_H_A + packet.Worldstates.emplace_back(1327, 0); // AV_AID_H_C + packet.Worldstates.emplace_back(1325, 1); // AV_AID_A_C + } + break; + case 3277: // Warsong Gulch + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_WS) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(1581, 0); // alliance flag captures + packet.Worldstates.emplace_back(1582, 0); // horde flag captures + packet.Worldstates.emplace_back(1545, 0); // unk, set to 1 on alliance flag pickup... + packet.Worldstates.emplace_back(1546, 0); // unk, set to 1 on horde flag pickup, after drop it's -1 + packet.Worldstates.emplace_back(1547, 2); // unk + packet.Worldstates.emplace_back(1601, 3); // unk (max flag captures?) + packet.Worldstates.emplace_back(2338, 1); // horde (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) + packet.Worldstates.emplace_back(2339, 1); // alliance (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) + } + break; + case 3358: // Arathi Basin + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_AB) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(1767, 0); // stables alliance + packet.Worldstates.emplace_back(1768, 0); // stables horde + packet.Worldstates.emplace_back(1769, 0); // stables alliance controlled + packet.Worldstates.emplace_back(1770, 0); // stables horde controlled + packet.Worldstates.emplace_back(1772, 0); // farm alliance + packet.Worldstates.emplace_back(1773, 0); // farm horde + packet.Worldstates.emplace_back(1774, 0); // farm alliance controlled + packet.Worldstates.emplace_back(1775, 0); // farm horde controlled + packet.Worldstates.emplace_back(1776, 0); // alliance resources + packet.Worldstates.emplace_back(1777, 0); // horde resources + packet.Worldstates.emplace_back(1778, 0); // horde bases + packet.Worldstates.emplace_back(1779, 0); // alliance bases + packet.Worldstates.emplace_back(1780, 2000); // max resources (2000) + packet.Worldstates.emplace_back(1782, 0); // blacksmith alliance + packet.Worldstates.emplace_back(1783, 0); // blacksmith horde + packet.Worldstates.emplace_back(1784, 0); // blacksmith alliance controlled + packet.Worldstates.emplace_back(1785, 0); // blacksmith horde controlled + packet.Worldstates.emplace_back(1787, 0); // gold mine alliance + packet.Worldstates.emplace_back(1788, 0); // gold mine horde + packet.Worldstates.emplace_back(1789, 0); // gold mine alliance controlled + packet.Worldstates.emplace_back(1790, 0); // gold mine horde controlled + packet.Worldstates.emplace_back(1792, 0); // lumber mill alliance + packet.Worldstates.emplace_back(1793, 0); // lumber mill horde + packet.Worldstates.emplace_back(1794, 0); // lumber mill alliance controlled + packet.Worldstates.emplace_back(1795, 0); // lumber mill horde controlled + packet.Worldstates.emplace_back(1842, 1); // stables (1 - uncontrolled) + packet.Worldstates.emplace_back(1843, 1); // gold mine (1 - uncontrolled) + packet.Worldstates.emplace_back(1844, 1); // lumber mill (1 - uncontrolled) + packet.Worldstates.emplace_back(1845, 1); // farm (1 - uncontrolled) + packet.Worldstates.emplace_back(1846, 1); // blacksmith (1 - uncontrolled) + packet.Worldstates.emplace_back(1861, 2); // unk + packet.Worldstates.emplace_back(1955, 1800); // warning limit (1800) + } + break; + case 3820: // Eye of the Storm + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_EY) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2753, 0); // Horde Bases + packet.Worldstates.emplace_back(2752, 0); // Alliance Bases + packet.Worldstates.emplace_back(2742, 0); // Mage Tower - Horde conflict + packet.Worldstates.emplace_back(2741, 0); // Mage Tower - Alliance conflict + packet.Worldstates.emplace_back(2740, 0); // Fel Reaver - Horde conflict + packet.Worldstates.emplace_back(2739, 0); // Fel Reaver - Alliance conflict + packet.Worldstates.emplace_back(2738, 0); // Draenei - Alliance conflict + packet.Worldstates.emplace_back(2737, 0); // Draenei - Horde conflict + packet.Worldstates.emplace_back(2736, 0); // unk (0 at start) + packet.Worldstates.emplace_back(2735, 0); // unk (0 at start) + packet.Worldstates.emplace_back(2733, 0); // Draenei - Horde control + packet.Worldstates.emplace_back(2732, 0); // Draenei - Alliance control + packet.Worldstates.emplace_back(2731, 1); // Draenei uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(2730, 0); // Mage Tower - Alliance control + packet.Worldstates.emplace_back(2729, 0); // Mage Tower - Horde control + packet.Worldstates.emplace_back(2728, 1); // Mage Tower uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(2727, 0); // Fel Reaver - Horde control + packet.Worldstates.emplace_back(2726, 0); // Fel Reaver - Alliance control + packet.Worldstates.emplace_back(2725, 1); // Fel Reaver uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(2724, 0); // Boold Elf - Horde control + packet.Worldstates.emplace_back(2723, 0); // Boold Elf - Alliance control + packet.Worldstates.emplace_back(2722, 1); // Boold Elf uncontrolled (1 - yes, 0 - no) + packet.Worldstates.emplace_back(2757, 1); // Flag (1 - show, 0 - hide) - doesn't work exactly this way! + packet.Worldstates.emplace_back(2770, 1); // Horde top-stats (1 - show, 0 - hide) // 02 -> horde picked up the flag + packet.Worldstates.emplace_back(2769, 1); // Alliance top-stats (1 - show, 0 - hide) // 02 -> alliance picked up the flag + packet.Worldstates.emplace_back(2750, 0); // Horde resources + packet.Worldstates.emplace_back(2749, 0); // Alliance resources + packet.Worldstates.emplace_back(2565, 142); // unk, constant? + packet.Worldstates.emplace_back(2720, 0); // Capturing progress-bar (100 -> empty (only grey), 0 -> blue|red (no grey), default 0) + packet.Worldstates.emplace_back(2719, 0); // Capturing progress-bar (0 - left, 100 - right) + packet.Worldstates.emplace_back(2718, 0); // Capturing progress-bar (1 - show, 0 - hide) + packet.Worldstates.emplace_back(3085, 379); // unk, constant? + // missing unknowns + } + break; + case 3483: // Hellfire Peninsula + if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_HP) + outdoorPvP->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2490, 1); // add ally tower main gui icon + packet.Worldstates.emplace_back(2489, 1); // add horde tower main gui icon + packet.Worldstates.emplace_back(2485, 0); // show neutral broken hill icon + packet.Worldstates.emplace_back(2484, 1); // show icon above broken hill + packet.Worldstates.emplace_back(2483, 0); // show ally broken hill icon + packet.Worldstates.emplace_back(2482, 0); // show neutral overlook icon + packet.Worldstates.emplace_back(2481, 1); // show the overlook arrow + packet.Worldstates.emplace_back(2480, 0); // show ally overlook icon + packet.Worldstates.emplace_back(2478, 0); // horde pvp objectives captured + packet.Worldstates.emplace_back(2476, 0); // ally pvp objectives captured + packet.Worldstates.emplace_back(2475, 100); // horde slider grey area + packet.Worldstates.emplace_back(2474, 50); // horde slider percentage, 100 for ally, 0 for horde + packet.Worldstates.emplace_back(2473, 0); // horde slider display + packet.Worldstates.emplace_back(2472, 0); // show the neutral stadium icon + packet.Worldstates.emplace_back(2471, 0); // show the ally stadium icon + packet.Worldstates.emplace_back(2470, 1); // show the horde stadium icon + } + break; + case 3518: // Nagrand + if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_NA) + outdoorPvP->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2503, 0); // NA_UI_HORDE_GUARDS_SHOW + packet.Worldstates.emplace_back(2502, 0); // NA_UI_ALLIANCE_GUARDS_SHOW + packet.Worldstates.emplace_back(2493, 0); // NA_UI_GUARDS_MAX + packet.Worldstates.emplace_back(2491, 0); // NA_UI_GUARDS_LEFT + packet.Worldstates.emplace_back(2495, 0); // NA_UI_OUTLAND_01 + packet.Worldstates.emplace_back(2494, 0); // NA_UI_UNK_1 + packet.Worldstates.emplace_back(2497, 0); // NA_UI_UNK_2 + packet.Worldstates.emplace_back(2762, 0); // NA_MAP_WYVERN_NORTH_NEU_H + packet.Worldstates.emplace_back(2662, 0); // NA_MAP_WYVERN_NORTH_NEU_A + packet.Worldstates.emplace_back(2663, 0); // NA_MAP_WYVERN_NORTH_H + packet.Worldstates.emplace_back(2664, 0); // NA_MAP_WYVERN_NORTH_A + packet.Worldstates.emplace_back(2760, 0); // NA_MAP_WYVERN_SOUTH_NEU_H + packet.Worldstates.emplace_back(2670, 0); // NA_MAP_WYVERN_SOUTH_NEU_A + packet.Worldstates.emplace_back(2668, 0); // NA_MAP_WYVERN_SOUTH_H + packet.Worldstates.emplace_back(2669, 0); // NA_MAP_WYVERN_SOUTH_A + packet.Worldstates.emplace_back(2761, 0); // NA_MAP_WYVERN_WEST_NEU_H + packet.Worldstates.emplace_back(2667, 0); // NA_MAP_WYVERN_WEST_NEU_A + packet.Worldstates.emplace_back(2665, 0); // NA_MAP_WYVERN_WEST_H + packet.Worldstates.emplace_back(2666, 0); // NA_MAP_WYVERN_WEST_A + packet.Worldstates.emplace_back(2763, 0); // NA_MAP_WYVERN_EAST_NEU_H + packet.Worldstates.emplace_back(2659, 0); // NA_MAP_WYVERN_EAST_NEU_A + packet.Worldstates.emplace_back(2660, 0); // NA_MAP_WYVERN_EAST_H + packet.Worldstates.emplace_back(2661, 0); // NA_MAP_WYVERN_EAST_A + packet.Worldstates.emplace_back(2671, 0); // NA_MAP_HALAA_NEUTRAL + packet.Worldstates.emplace_back(2676, 0); // NA_MAP_HALAA_NEU_A + packet.Worldstates.emplace_back(2677, 0); // NA_MAP_HALAA_NEU_H + packet.Worldstates.emplace_back(2672, 0); // NA_MAP_HALAA_HORDE + packet.Worldstates.emplace_back(2673, 0); // NA_MAP_HALAA_ALLIANCE + } + break; + case 3519: // Terokkar Forest + if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_TF) + outdoorPvP->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2625, 0); // TF_UI_CAPTURE_BAR_POS + packet.Worldstates.emplace_back(2624, 20); // TF_UI_CAPTURE_BAR_NEUTRAL + packet.Worldstates.emplace_back(2623, 0); // TF_UI_SHOW CAPTURE BAR + packet.Worldstates.emplace_back(2622, 0); // TF_UI_TOWER_COUNT_H + packet.Worldstates.emplace_back(2621, 5); // TF_UI_TOWER_COUNT_A + packet.Worldstates.emplace_back(2620, 0); // TF_UI_TOWERS_CONTROLLED_DISPLAY + packet.Worldstates.emplace_back(2696, 0); // TF_TOWER_NUM_15 - SE Neutral + packet.Worldstates.emplace_back(2695, 0); // TF_TOWER_NUM_14 - SE Horde + packet.Worldstates.emplace_back(2694, 0); // TF_TOWER_NUM_13 - SE Alliance + packet.Worldstates.emplace_back(2693, 0); // TF_TOWER_NUM_12 - S Neutral + packet.Worldstates.emplace_back(2692, 0); // TF_TOWER_NUM_11 - S Horde + packet.Worldstates.emplace_back(2691, 0); // TF_TOWER_NUM_10 - S Alliance + packet.Worldstates.emplace_back(2690, 0); // TF_TOWER_NUM_09 - NE Neutral + packet.Worldstates.emplace_back(2689, 0); // TF_TOWER_NUM_08 - NE Horde + packet.Worldstates.emplace_back(2688, 0); // TF_TOWER_NUM_07 - NE Alliance + packet.Worldstates.emplace_back(2687, 0); // TF_TOWER_NUM_16 - unk + packet.Worldstates.emplace_back(2686, 0); // TF_TOWER_NUM_06 - N Neutral + packet.Worldstates.emplace_back(2685, 0); // TF_TOWER_NUM_05 - N Horde + packet.Worldstates.emplace_back(2684, 0); // TF_TOWER_NUM_04 - N Alliance + packet.Worldstates.emplace_back(2683, 0); // TF_TOWER_NUM_03 - NW Alliance + packet.Worldstates.emplace_back(2682, 0); // TF_TOWER_NUM_02 - NW Horde + packet.Worldstates.emplace_back(2681, 0); // TF_TOWER_NUM_01 - NW Neutral + packet.Worldstates.emplace_back(2512, 5); // TF_UI_LOCKED_TIME_MINUTES_FIRST_DIGIT + packet.Worldstates.emplace_back(2510, 0); // TF_UI_LOCKED_TIME_MINUTES_SECOND_DIGIT + packet.Worldstates.emplace_back(2509, 0); // TF_UI_LOCKED_TIME_HOURS + packet.Worldstates.emplace_back(2508, 0); // TF_UI_LOCKED_DISPLAY_NEUTRAL + packet.Worldstates.emplace_back(2768, 0); // TF_UI_LOCKED_DISPLAY_HORDE + packet.Worldstates.emplace_back(2767, 1); // TF_UI_LOCKED_DISPLAY_ALLIANCE + } + break; + case 3521: // Zangarmarsh + if (outdoorPvP && outdoorPvP->GetTypeId() == OUTDOOR_PVP_ZM) + outdoorPvP->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2529, 0); // ZM_UNK_1 + packet.Worldstates.emplace_back(2528, 0); // ZM_UNK_2 + packet.Worldstates.emplace_back(2527, 0); // ZM_UNK_3 + packet.Worldstates.emplace_back(2653, 1); // ZM_WORLDSTATE_UNK_1 + packet.Worldstates.emplace_back(2652, 0); // ZM_MAP_TOWER_EAST_N + packet.Worldstates.emplace_back(2651, 1); // ZM_MAP_TOWER_EAST_H + packet.Worldstates.emplace_back(2650, 0); // ZM_MAP_TOWER_EAST_A + packet.Worldstates.emplace_back(2649, 1); // ZM_MAP_GRAVEYARD_H - Twin spire graveyard horde + packet.Worldstates.emplace_back(2648, 0); // ZM_MAP_GRAVEYARD_A + packet.Worldstates.emplace_back(2647, 0); // ZM_MAP_GRAVEYARD_N + packet.Worldstates.emplace_back(2646, 0); // ZM_MAP_TOWER_WEST_N + packet.Worldstates.emplace_back(2645, 1); // ZM_MAP_TOWER_WEST_H + packet.Worldstates.emplace_back(2644, 0); // ZM_MAP_TOWER_WEST_A + packet.Worldstates.emplace_back(2535, 0); // ZM_UNK_4 + packet.Worldstates.emplace_back(2534, 0); // ZM_UNK_5 + packet.Worldstates.emplace_back(2533, 0); // ZM_UNK_6 + packet.Worldstates.emplace_back(2560, 0); // ZM_UI_TOWER_EAST_N + packet.Worldstates.emplace_back(2559, 1); // ZM_UI_TOWER_EAST_H + packet.Worldstates.emplace_back(2558, 0); // ZM_UI_TOWER_EAST_A + packet.Worldstates.emplace_back(2557, 0); // ZM_UI_TOWER_WEST_N + packet.Worldstates.emplace_back(2556, 1); // ZM_UI_TOWER_WEST_H + packet.Worldstates.emplace_back(2555, 0); // ZM_UI_TOWER_WEST_A + packet.Worldstates.emplace_back(2658, 0); // ZM_MAP_HORDE_FLAG_READY + packet.Worldstates.emplace_back(2657, 1); // ZM_MAP_HORDE_FLAG_NOT_READY + packet.Worldstates.emplace_back(2656, 1); // ZM_MAP_ALLIANCE_FLAG_NOT_READY + packet.Worldstates.emplace_back(2655, 0); // ZM_MAP_ALLIANCE_FLAG_READY + } + break; + case 3698: // Nagrand Arena + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_NA) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2575, 0); // BATTLEGROUND_NAGRAND_ARENA_GOLD + packet.Worldstates.emplace_back(2576, 0); // BATTLEGROUND_NAGRAND_ARENA_GREEN + packet.Worldstates.emplace_back(2577, 0); // BATTLEGROUND_NAGRAND_ARENA_SHOW + } + break; + case 3702: // Blade's Edge Arena + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_BE) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(2544, 0); // BATTLEGROUND_BLADES_EDGE_ARENA_GOLD + packet.Worldstates.emplace_back(2545, 0); // BATTLEGROUND_BLADES_EDGE_ARENA_GREEN + packet.Worldstates.emplace_back(2547, 0); // BATTLEGROUND_BLADES_EDGE_ARENA_SHOW + } + break; + case 3968: // Ruins of Lordaeron + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_RL) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(3000, 0); // BATTELGROUND_RUINS_OF_LORDAERNON_GOLD + packet.Worldstates.emplace_back(3001, 0); // BATTELGROUND_RUINS_OF_LORDAERNON_GREEN + packet.Worldstates.emplace_back(3002, 0); // BATTELGROUND_RUINS_OF_LORDAERNON_SHOW + } + break; + case 4378: // Dalaran Sewers + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_DS) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(3601, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GOLD + packet.Worldstates.emplace_back(3600, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GREEN + packet.Worldstates.emplace_back(3610, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_SHOW + } + break; + case 4384: // Strand of the Ancients + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_SA) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(3849, 0); // Gate of Temple + packet.Worldstates.emplace_back(3638, 0); // Gate of Yellow Moon + packet.Worldstates.emplace_back(3623, 0); // Gate of Green Emerald + packet.Worldstates.emplace_back(3620, 0); // Gate of Blue Sapphire + packet.Worldstates.emplace_back(3617, 0); // Gate of Red Sun + packet.Worldstates.emplace_back(3614, 0); // Gate of Purple Ametyst + packet.Worldstates.emplace_back(3571, 0); // bonus timer (1 - on, 0 - off) + packet.Worldstates.emplace_back(3565, 0); // Horde Attacker + packet.Worldstates.emplace_back(3564, 0); // Alliance Attacker + + // End Round timer, example: 19:59 -> A:BC + packet.Worldstates.emplace_back(3561, 0); // C + packet.Worldstates.emplace_back(3560, 0); // B + packet.Worldstates.emplace_back(3559, 0); // A + + packet.Worldstates.emplace_back(3637, 0); // BG_SA_CENTER_GY_ALLIANCE + packet.Worldstates.emplace_back(3636, 0); // BG_SA_RIGHT_GY_ALLIANCE + packet.Worldstates.emplace_back(3635, 0); // BG_SA_LEFT_GY_ALLIANCE + packet.Worldstates.emplace_back(3634, 0); // BG_SA_CENTER_GY_HORDE + packet.Worldstates.emplace_back(3633, 0); // BG_SA_LEFT_GY_HORDE + packet.Worldstates.emplace_back(3632, 0); // BG_SA_RIGHT_GY_HORDE + packet.Worldstates.emplace_back(3631, 0); // BG_SA_HORDE_DEFENCE_TOKEN + packet.Worldstates.emplace_back(3630, 0); // BG_SA_ALLIANCE_DEFENCE_TOKEN + packet.Worldstates.emplace_back(3629, 0); // BG_SA_LEFT_ATT_TOKEN_HRD + packet.Worldstates.emplace_back(3628, 0); // BG_SA_RIGHT_ATT_TOKEN_HRD + packet.Worldstates.emplace_back(3627, 0); // BG_SA_RIGHT_ATT_TOKEN_ALL + packet.Worldstates.emplace_back(3626, 0); // BG_SA_LEFT_ATT_TOKEN_ALL + // missing unknowns + } + break; + case 4406: // Ring of Valor + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_RV) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(3600, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GREEN + packet.Worldstates.emplace_back(3601, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_GOLD + packet.Worldstates.emplace_back(3610, 0); // ARENA_WORLD_STATE_ALIVE_PLAYERS_SHOW + } + break; + case 4710: // Isle of Conquest + if (battleground && battleground->GetTypeID(true) == BATTLEGROUND_IC) + battleground->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(4221, 1); // BG_IC_ALLIANCE_RENFORT_SET + packet.Worldstates.emplace_back(4222, 1); // BG_IC_HORDE_RENFORT_SET + packet.Worldstates.emplace_back(4226, 300); // BG_IC_ALLIANCE_RENFORT + packet.Worldstates.emplace_back(4227, 300); // BG_IC_HORDE_RENFORT + packet.Worldstates.emplace_back(4322, 1); // BG_IC_GATE_FRONT_H_WS_OPEN + packet.Worldstates.emplace_back(4321, 1); // BG_IC_GATE_WEST_H_WS_OPEN + packet.Worldstates.emplace_back(4320, 1); // BG_IC_GATE_EAST_H_WS_OPEN + packet.Worldstates.emplace_back(4323, 1); // BG_IC_GATE_FRONT_A_WS_OPEN + packet.Worldstates.emplace_back(4324, 1); // BG_IC_GATE_WEST_A_WS_OPEN + packet.Worldstates.emplace_back(4325, 1); // BG_IC_GATE_EAST_A_WS_OPEN + packet.Worldstates.emplace_back(4317, 1); // unk + packet.Worldstates.emplace_back(4301, 1); // BG_IC_DOCKS_UNCONTROLLED + packet.Worldstates.emplace_back(4296, 1); // BG_IC_HANGAR_UNCONTROLLED + packet.Worldstates.emplace_back(4306, 1); // BG_IC_QUARRY_UNCONTROLLED + packet.Worldstates.emplace_back(4311, 1); // BG_IC_REFINERY_UNCONTROLLED + packet.Worldstates.emplace_back(4294, 1); // BG_IC_WORKSHOP_UNCONTROLLED + packet.Worldstates.emplace_back(4243, 1); // unk + packet.Worldstates.emplace_back(4345, 1); // unk + } + break; + case 4987: // The Ruby Sanctum + if (instance) + instance->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(5049, 50); // WORLDSTATE_CORPOREALITY_MATERIAL + packet.Worldstates.emplace_back(5050, 50); // WORLDSTATE_CORPOREALITY_TWILIGHT + packet.Worldstates.emplace_back(5051, 0); // WORLDSTATE_CORPOREALITY_TOGGLE + } + break; + case 4812: // Icecrown Citadel + if (instance) + instance->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(4903, 0); // WORLDSTATE_SHOW_TIMER (Blood Quickening weekly) + packet.Worldstates.emplace_back(4904, 30); // WORLDSTATE_EXECUTION_TIME + packet.Worldstates.emplace_back(4940, 0); // WORLDSTATE_SHOW_ATTEMPTS + packet.Worldstates.emplace_back(4941, 50); // WORLDSTATE_ATTEMPTS_REMAINING + packet.Worldstates.emplace_back(4942, 50); // WORLDSTATE_ATTEMPTS_MAX + } + break; + case 4100: // The Culling of Stratholme + if (instance) + instance->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(3479, 0); // WORLDSTATE_SHOW_CRATES + packet.Worldstates.emplace_back(3480, 0); // WORLDSTATE_CRATES_REVEALED + packet.Worldstates.emplace_back(3504, 0); // WORLDSTATE_WAVE_COUNT + packet.Worldstates.emplace_back(3931, 25); // WORLDSTATE_TIME_GUARDIAN + packet.Worldstates.emplace_back(3932, 0); // WORLDSTATE_TIME_GUARDIAN_SHOW + } + break; + case 4228: // The Oculus + if (instance) + instance->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(3524, 0); // WORLD_STATE_CENTRIFUGE_CONSTRUCT_SHOW + packet.Worldstates.emplace_back(3486, 0); // WORLD_STATE_CENTRIFUGE_CONSTRUCT_AMOUNT + } + break; + case 4273: // Ulduar + if (instance) + instance->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(4132, 0); // WORLDSTATE_ALGALON_TIMER_ENABLED + packet.Worldstates.emplace_back(4131, 0); // WORLDSTATE_ALGALON_DESPAWN_TIMER + } + break; + case 4415: // Violet Hold + if (instance) + instance->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(3816, 0); // WORLD_STATE_VH_SHOW + packet.Worldstates.emplace_back(3815, 100); // WORLD_STATE_VH_PRISON_STATE + packet.Worldstates.emplace_back(3810, 0); // WORLD_STATE_VH_WAVE_COUNT + } + break; + case 4820: // Halls of Refection + if (instance) + instance->FillInitialWorldStates(packet); + else + { + packet.Worldstates.emplace_back(4884, 0); // WORLD_STATE_HOR_WAVES_ENABLED + packet.Worldstates.emplace_back(4882, 0); // WORLD_STATE_HOR_WAVE_COUNT + } + break; + case AREA_WINTERGRASP: // Wintergrasp + if (battlefield && battlefield->GetTypeId() == BATTLEFIELD_WG) + battlefield->FillInitialWorldStates(packet); + else + { + } + break; + default: + break; } SendDirectMessage(packet.Write()); @@ -9314,7 +9343,8 @@ uint32 Player::GetXPRestBonus(uint32 xp) SetRestBonus(GetRestBonus() - rested_bonus); - LOG_DEBUG("entities.player", "Player::GetXPRestBonus: Player '%s' (%s) gain %u xp (+%u Rested Bonus). Rested points=%f", GetGUID().ToString().c_str(), GetName().c_str(), xp + rested_bonus, rested_bonus, GetRestBonus()); + LOG_DEBUG("entities.player", "Player::GetXPRestBonus: Player '%s' (%s) gain %u xp (+%u Rested Bonus). Rested points=%f", GetGUID().ToString().c_str(), GetName().c_str(), xp + rested_bonus, + rested_bonus, GetRestBonus()); return rested_bonus; } @@ -9326,7 +9356,7 @@ void Player::SetBindPoint(ObjectGuid guid) const void Player::SendTalentWipeConfirm(ObjectGuid guid) const { - WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4)); + WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8 + 4)); data << uint64(guid); uint32 cost = CONF_GET_BOOL("NoResetTalentsCost") ? 0 : ResetTalentsCost(); data << cost; @@ -9367,7 +9397,7 @@ void Player::SetVirtualItemSlot(uint8 i, Item* item) if (charges == 0) return; if (charges > 1) - item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT, charges-1); + item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT, charges - 1); else { ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, false); @@ -9380,26 +9410,26 @@ void Player::SetSheath(SheathState sheathed) { switch (sheathed) { - case SHEATH_STATE_UNARMED: // no prepared weapon - SetVirtualItemSlot(0, nullptr); - SetVirtualItemSlot(1, nullptr); - SetVirtualItemSlot(2, nullptr); - break; - case SHEATH_STATE_MELEE: // prepared melee weapon - SetVirtualItemSlot(0, GetWeaponForAttack(BASE_ATTACK, true)); - SetVirtualItemSlot(1, GetWeaponForAttack(OFF_ATTACK, true)); - SetVirtualItemSlot(2, nullptr); - break; - case SHEATH_STATE_RANGED: // prepared ranged weapon - SetVirtualItemSlot(0, nullptr); - SetVirtualItemSlot(1, nullptr); - SetVirtualItemSlot(2, GetWeaponForAttack(RANGED_ATTACK, true)); - break; - default: - SetVirtualItemSlot(0, nullptr); - SetVirtualItemSlot(1, nullptr); - SetVirtualItemSlot(2, nullptr); - break; + case SHEATH_STATE_UNARMED: // no prepared weapon + SetVirtualItemSlot(0, nullptr); + SetVirtualItemSlot(1, nullptr); + SetVirtualItemSlot(2, nullptr); + break; + case SHEATH_STATE_MELEE: // prepared melee weapon + SetVirtualItemSlot(0, GetWeaponForAttack(BASE_ATTACK, true)); + SetVirtualItemSlot(1, GetWeaponForAttack(OFF_ATTACK, true)); + SetVirtualItemSlot(2, nullptr); + break; + case SHEATH_STATE_RANGED: // prepared ranged weapon + SetVirtualItemSlot(0, nullptr); + SetVirtualItemSlot(1, nullptr); + SetVirtualItemSlot(2, GetWeaponForAttack(RANGED_ATTACK, true)); + break; + default: + SetVirtualItemSlot(0, nullptr); + SetVirtualItemSlot(1, nullptr); + SetVirtualItemSlot(2, nullptr); + break; } Unit::SetSheath(sheathed); // this must visualize Sheath changing for other players... } @@ -9415,144 +9445,144 @@ uint8 Player::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) c slots[3] = NULL_SLOT; switch (proto->InventoryType) { - case INVTYPE_HEAD: - slots[0] = EQUIPMENT_SLOT_HEAD; - break; - case INVTYPE_NECK: - slots[0] = EQUIPMENT_SLOT_NECK; - break; - case INVTYPE_SHOULDERS: - slots[0] = EQUIPMENT_SLOT_SHOULDERS; - break; - case INVTYPE_BODY: - slots[0] = EQUIPMENT_SLOT_BODY; - break; - case INVTYPE_CHEST: - slots[0] = EQUIPMENT_SLOT_CHEST; - break; - case INVTYPE_ROBE: - slots[0] = EQUIPMENT_SLOT_CHEST; - break; - case INVTYPE_WAIST: - slots[0] = EQUIPMENT_SLOT_WAIST; - break; - case INVTYPE_LEGS: - slots[0] = EQUIPMENT_SLOT_LEGS; - break; - case INVTYPE_FEET: - slots[0] = EQUIPMENT_SLOT_FEET; - break; - case INVTYPE_WRISTS: - slots[0] = EQUIPMENT_SLOT_WRISTS; - break; - case INVTYPE_HANDS: - slots[0] = EQUIPMENT_SLOT_HANDS; - break; - case INVTYPE_FINGER: - slots[0] = EQUIPMENT_SLOT_FINGER1; - slots[1] = EQUIPMENT_SLOT_FINGER2; - break; - case INVTYPE_TRINKET: - slots[0] = EQUIPMENT_SLOT_TRINKET1; - slots[1] = EQUIPMENT_SLOT_TRINKET2; - break; - case INVTYPE_CLOAK: - slots[0] = EQUIPMENT_SLOT_BACK; - break; - case INVTYPE_WEAPON: - { - slots[0] = EQUIPMENT_SLOT_MAINHAND; + case INVTYPE_HEAD: + slots[0] = EQUIPMENT_SLOT_HEAD; + break; + case INVTYPE_NECK: + slots[0] = EQUIPMENT_SLOT_NECK; + break; + case INVTYPE_SHOULDERS: + slots[0] = EQUIPMENT_SLOT_SHOULDERS; + break; + case INVTYPE_BODY: + slots[0] = EQUIPMENT_SLOT_BODY; + break; + case INVTYPE_CHEST: + slots[0] = EQUIPMENT_SLOT_CHEST; + break; + case INVTYPE_ROBE: + slots[0] = EQUIPMENT_SLOT_CHEST; + break; + case INVTYPE_WAIST: + slots[0] = EQUIPMENT_SLOT_WAIST; + break; + case INVTYPE_LEGS: + slots[0] = EQUIPMENT_SLOT_LEGS; + break; + case INVTYPE_FEET: + slots[0] = EQUIPMENT_SLOT_FEET; + break; + case INVTYPE_WRISTS: + slots[0] = EQUIPMENT_SLOT_WRISTS; + break; + case INVTYPE_HANDS: + slots[0] = EQUIPMENT_SLOT_HANDS; + break; + case INVTYPE_FINGER: + slots[0] = EQUIPMENT_SLOT_FINGER1; + slots[1] = EQUIPMENT_SLOT_FINGER2; + break; + case INVTYPE_TRINKET: + slots[0] = EQUIPMENT_SLOT_TRINKET1; + slots[1] = EQUIPMENT_SLOT_TRINKET2; + break; + case INVTYPE_CLOAK: + slots[0] = EQUIPMENT_SLOT_BACK; + break; + case INVTYPE_WEAPON: + { + slots[0] = EQUIPMENT_SLOT_MAINHAND; - // suggest offhand slot only if know dual wielding - // (this will be replace mainhand weapon at auto equip instead unwonted "you don't known dual wielding" ... - if (CanDualWield()) - slots[1] = EQUIPMENT_SLOT_OFFHAND; - break; - } - case INVTYPE_SHIELD: - slots[0] = EQUIPMENT_SLOT_OFFHAND; - break; - case INVTYPE_RANGED: - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case INVTYPE_2HWEAPON: - slots[0] = EQUIPMENT_SLOT_MAINHAND; - if (Item* mhWeapon = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) + // suggest offhand slot only if know dual wielding + // (this will be replace mainhand weapon at auto equip instead unwonted "you don't known dual wielding" ... + if (CanDualWield()) + slots[1] = EQUIPMENT_SLOT_OFFHAND; + break; + } + case INVTYPE_SHIELD: + slots[0] = EQUIPMENT_SLOT_OFFHAND; + break; + case INVTYPE_RANGED: + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case INVTYPE_2HWEAPON: + slots[0] = EQUIPMENT_SLOT_MAINHAND; + if (Item* mhWeapon = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) + { + if (ItemTemplate const* mhWeaponProto = mhWeapon->GetTemplate()) { - if (ItemTemplate const* mhWeaponProto = mhWeapon->GetTemplate()) + if (mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) { - if (mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || mhWeaponProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) - { - const_cast(this)->AutoUnequipOffhandIfNeed(true); - break; - } + const_cast(this)->AutoUnequipOffhandIfNeed(true); + break; } } + } - if (GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + if (GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + { + if (proto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || proto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) { - if (proto->SubClass == ITEM_SUBCLASS_WEAPON_POLEARM || proto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF) - { - const_cast(this)->AutoUnequipOffhandIfNeed(true); - break; - } + const_cast(this)->AutoUnequipOffhandIfNeed(true); + break; } - if (CanDualWield() && CanTitanGrip() && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) - slots[1] = EQUIPMENT_SLOT_OFFHAND; - break; - case INVTYPE_TABARD: - slots[0] = EQUIPMENT_SLOT_TABARD; - break; - case INVTYPE_WEAPONMAINHAND: - slots[0] = EQUIPMENT_SLOT_MAINHAND; - break; - case INVTYPE_WEAPONOFFHAND: - slots[0] = EQUIPMENT_SLOT_OFFHAND; - break; - case INVTYPE_HOLDABLE: - slots[0] = EQUIPMENT_SLOT_OFFHAND; + } + if (CanDualWield() && CanTitanGrip() && proto->SubClass != ITEM_SUBCLASS_WEAPON_POLEARM && proto->SubClass != ITEM_SUBCLASS_WEAPON_STAFF) + slots[1] = EQUIPMENT_SLOT_OFFHAND; + break; + case INVTYPE_TABARD: + slots[0] = EQUIPMENT_SLOT_TABARD; + break; + case INVTYPE_WEAPONMAINHAND: + slots[0] = EQUIPMENT_SLOT_MAINHAND; + break; + case INVTYPE_WEAPONOFFHAND: + slots[0] = EQUIPMENT_SLOT_OFFHAND; + break; + case INVTYPE_HOLDABLE: + slots[0] = EQUIPMENT_SLOT_OFFHAND; + break; + case INVTYPE_THROWN: + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case INVTYPE_RANGEDRIGHT: + slots[0] = EQUIPMENT_SLOT_RANGED; + break; + case INVTYPE_BAG: + slots[0] = INVENTORY_SLOT_BAG_START + 0; + slots[1] = INVENTORY_SLOT_BAG_START + 1; + slots[2] = INVENTORY_SLOT_BAG_START + 2; + slots[3] = INVENTORY_SLOT_BAG_START + 3; + break; + case INVTYPE_RELIC: + { + switch (proto->SubClass) + { + case ITEM_SUBCLASS_ARMOR_LIBRAM: + if (playerClass == CLASS_PALADIN) + slots[0] = EQUIPMENT_SLOT_RANGED; break; - case INVTYPE_THROWN: - slots[0] = EQUIPMENT_SLOT_RANGED; + case ITEM_SUBCLASS_ARMOR_IDOL: + if (playerClass == CLASS_DRUID) + slots[0] = EQUIPMENT_SLOT_RANGED; break; - case INVTYPE_RANGEDRIGHT: - slots[0] = EQUIPMENT_SLOT_RANGED; + case ITEM_SUBCLASS_ARMOR_TOTEM: + if (playerClass == CLASS_SHAMAN) + slots[0] = EQUIPMENT_SLOT_RANGED; break; - case INVTYPE_BAG: - slots[0] = INVENTORY_SLOT_BAG_START + 0; - slots[1] = INVENTORY_SLOT_BAG_START + 1; - slots[2] = INVENTORY_SLOT_BAG_START + 2; - slots[3] = INVENTORY_SLOT_BAG_START + 3; + case ITEM_SUBCLASS_ARMOR_MISC: + if (playerClass == CLASS_WARLOCK) + slots[0] = EQUIPMENT_SLOT_RANGED; break; - case INVTYPE_RELIC: - { - switch (proto->SubClass) - { - case ITEM_SUBCLASS_ARMOR_LIBRAM: - if (playerClass == CLASS_PALADIN) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case ITEM_SUBCLASS_ARMOR_IDOL: - if (playerClass == CLASS_DRUID) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case ITEM_SUBCLASS_ARMOR_TOTEM: - if (playerClass == CLASS_SHAMAN) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case ITEM_SUBCLASS_ARMOR_MISC: - if (playerClass == CLASS_WARLOCK) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - case ITEM_SUBCLASS_ARMOR_SIGIL: - if (playerClass == CLASS_DEATH_KNIGHT) - slots[0] = EQUIPMENT_SLOT_RANGED; - break; - } + case ITEM_SUBCLASS_ARMOR_SIGIL: + if (playerClass == CLASS_DEATH_KNIGHT) + slots[0] = EQUIPMENT_SLOT_RANGED; break; } - default: - return NULL_SLOT; + break; + } + default: + return NULL_SLOT; } if (slot != NULL_SLOT) @@ -9776,7 +9806,7 @@ Item* Player::GetUseableItemByPos(uint8 bag, uint8 slot) const Bag* Player::GetBagByPos(uint8 bag) const { if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) - || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END)) + || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END)) if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, bag)) return item->ToBag(); return nullptr; @@ -9809,10 +9839,17 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool useable /*= f uint8 slot; switch (attackType) { - case BASE_ATTACK: slot = EQUIPMENT_SLOT_MAINHAND; break; - case OFF_ATTACK: slot = EQUIPMENT_SLOT_OFFHAND; break; - case RANGED_ATTACK: slot = EQUIPMENT_SLOT_RANGED; break; - default: return nullptr; + case BASE_ATTACK: + slot = EQUIPMENT_SLOT_MAINHAND; + break; + case OFF_ATTACK: + slot = EQUIPMENT_SLOT_OFFHAND; + break; + case RANGED_ATTACK: + slot = EQUIPMENT_SLOT_RANGED; + break; + default: + return nullptr; } Item* item; @@ -9855,10 +9892,14 @@ WeaponAttackType Player::GetAttackBySlot(uint8 slot) { switch (slot) { - case EQUIPMENT_SLOT_MAINHAND: return BASE_ATTACK; - case EQUIPMENT_SLOT_OFFHAND: return OFF_ATTACK; - case EQUIPMENT_SLOT_RANGED: return RANGED_ATTACK; - default: return MAX_ATTACK; + case EQUIPMENT_SLOT_MAINHAND: + return BASE_ATTACK; + case EQUIPMENT_SLOT_OFFHAND: + return OFF_ATTACK; + case EQUIPMENT_SLOT_RANGED: + return RANGED_ATTACK; + default: + return MAX_ATTACK; } } @@ -10229,7 +10270,7 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const return false; } -InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const +InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const { Item* pItem2 = GetItemByPos(bag, slot); @@ -10248,7 +10289,7 @@ InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemP if (bag == INVENTORY_SLOT_BAG_0) { // keyring case - if (slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START+GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS)) + if (slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START + GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; // currencytoken case @@ -10303,7 +10344,8 @@ InventoryResult Player::CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemP return EQUIP_ERR_OK; } -InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, + uint8 skip_slot) const { // skip specific bag already processed in first called CanStoreItem_InBag if (bag == skip_bag) @@ -10365,14 +10407,15 @@ InventoryResult Player::CanStoreItem_InBag(uint8 bag, ItemPosCountVec &dest, Ite dest.push_back(newPosition); count -= need_space; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } return EQUIP_ERR_OK; } -InventoryResult Player::CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec &dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const +InventoryResult Player::CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, + uint8 skip_slot) const { //this is never called for non-bag slots so we can do this if (pSrcItem && pSrcItem->IsNotEmptyBag()) @@ -10415,14 +10458,14 @@ InventoryResult Player::CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 sl dest.push_back(newPosition); count -= need_space; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } return EQUIP_ERR_OK; } -InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 entry, uint32 count, Item* pItem, bool swap, uint32* no_space_count) const +InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem, bool swap, uint32* no_space_count) const { LOG_DEBUG("entities.player.items", "Player::CanStoreItem: Bag: %u, Slot: %u, Item: %u, Count: %u", bag, slot, entry, count); @@ -10567,7 +10610,7 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &des if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START+keyringSize, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START + keyringSize, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10752,7 +10795,7 @@ InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec &des if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START+keyringSize, dest, pProto, count, false, pItem, bag, slot); + res = CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START + keyringSize, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10933,7 +10976,7 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit uint32_t remaining_count = item->GetCount(); LOG_DEBUG("entities.player.items", "Player::CanStoreItems: Player '%s' (%s), Index: %i ItemID: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), k + 1, item->GetEntry(), remaining_count); + GetName().c_str(), GetGUID().ToString().c_str(), k + 1, item->GetEntry(), remaining_count); ItemTemplate const* pProto = item->GetTemplate(); // strange item @@ -10962,11 +11005,11 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit for (uint8 t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; ++t) { - item2 = keyringPointers[t-KEYRING_SLOT_START]; - if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && keyringCounts[t-KEYRING_SLOT_START] < pProto->GetMaxStackSize()) + item2 = keyringPointers[t - KEYRING_SLOT_START]; + if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && keyringCounts[t - KEYRING_SLOT_START] < pProto->GetMaxStackSize()) { - keyringCounts[t-KEYRING_SLOT_START] += remaining_count; - remaining_count = keyringCounts[t-KEYRING_SLOT_START] < pProto->GetMaxStackSize() ? 0 : keyringCounts[t-KEYRING_SLOT_START] - pProto->GetMaxStackSize(); + keyringCounts[t - KEYRING_SLOT_START] += remaining_count; + remaining_count = keyringCounts[t - KEYRING_SLOT_START] < pProto->GetMaxStackSize() ? 0 : keyringCounts[t - KEYRING_SLOT_START] - pProto->GetMaxStackSize(); b_found = remaining_count == 0; @@ -10981,11 +11024,11 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit for (int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { - item2 = currencyPointers[t-CURRENCYTOKEN_SLOT_START]; - if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && currencyCounts[t-CURRENCYTOKEN_SLOT_START] < pProto->GetMaxStackSize()) + item2 = currencyPointers[t - CURRENCYTOKEN_SLOT_START]; + if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && currencyCounts[t - CURRENCYTOKEN_SLOT_START] < pProto->GetMaxStackSize()) { - currencyCounts[t-CURRENCYTOKEN_SLOT_START] += remaining_count; - remaining_count = currencyCounts[t-CURRENCYTOKEN_SLOT_START] < pProto->GetMaxStackSize() ? 0 : currencyCounts[t-CURRENCYTOKEN_SLOT_START] - pProto->GetMaxStackSize(); + currencyCounts[t - CURRENCYTOKEN_SLOT_START] += remaining_count; + remaining_count = currencyCounts[t - CURRENCYTOKEN_SLOT_START] < pProto->GetMaxStackSize() ? 0 : currencyCounts[t - CURRENCYTOKEN_SLOT_START] - pProto->GetMaxStackSize(); b_found = remaining_count == 0; // if no pieces of the stack remain, then stop checking currency 'bag' @@ -10999,11 +11042,11 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit for (int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { - item2 = inventoryPointers[t-INVENTORY_SLOT_ITEM_START]; - if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inventoryCounts[t-INVENTORY_SLOT_ITEM_START] < pProto->GetMaxStackSize()) + item2 = inventoryPointers[t - INVENTORY_SLOT_ITEM_START]; + if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inventoryCounts[t - INVENTORY_SLOT_ITEM_START] < pProto->GetMaxStackSize()) { - inventoryCounts[t-INVENTORY_SLOT_ITEM_START] += remaining_count; - remaining_count = inventoryCounts[t-INVENTORY_SLOT_ITEM_START] < pProto->GetMaxStackSize() ? 0 : inventoryCounts[t-INVENTORY_SLOT_ITEM_START] - pProto->GetMaxStackSize(); + inventoryCounts[t - INVENTORY_SLOT_ITEM_START] += remaining_count; + remaining_count = inventoryCounts[t - INVENTORY_SLOT_ITEM_START] < pProto->GetMaxStackSize() ? 0 : inventoryCounts[t - INVENTORY_SLOT_ITEM_START] - pProto->GetMaxStackSize(); b_found = remaining_count == 0; // if no pieces of the stack remain, then stop checking stock bag @@ -11024,12 +11067,12 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit for (uint32 j = 0; j < bag->GetBagSize(); j++) { - item2 = bagPointers[t-INVENTORY_SLOT_BAG_START][j]; - if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && bagCounts[t-INVENTORY_SLOT_BAG_START][j] < pProto->GetMaxStackSize()) + item2 = bagPointers[t - INVENTORY_SLOT_BAG_START][j]; + if (item2 && item2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && bagCounts[t - INVENTORY_SLOT_BAG_START][j] < pProto->GetMaxStackSize()) { // add count to stack so that later items in the list do not double-book - bagCounts[t-INVENTORY_SLOT_BAG_START][j] += remaining_count; - remaining_count = bagCounts[t-INVENTORY_SLOT_BAG_START][j] < pProto->GetMaxStackSize() ? 0 : bagCounts[t-INVENTORY_SLOT_BAG_START][j] - pProto->GetMaxStackSize(); + bagCounts[t - INVENTORY_SLOT_BAG_START][j] += remaining_count; + remaining_count = bagCounts[t - INVENTORY_SLOT_BAG_START][j] < pProto->GetMaxStackSize() ? 0 : bagCounts[t - INVENTORY_SLOT_BAG_START][j] - pProto->GetMaxStackSize(); b_found = remaining_count == 0; @@ -11052,12 +11095,12 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - for (uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START+keyringSize; ++t) + for (uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START + keyringSize; ++t) { - if (keyringCounts[t-KEYRING_SLOT_START] == 0) + if (keyringCounts[t - KEYRING_SLOT_START] == 0) { - keyringCounts[t-KEYRING_SLOT_START] = remaining_count; - keyringPointers[t-KEYRING_SLOT_START] = item; + keyringCounts[t - KEYRING_SLOT_START] = remaining_count; + keyringPointers[t - KEYRING_SLOT_START] = item; b_found = true; break; @@ -11072,10 +11115,10 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit { for (uint32 t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { - if (currencyCounts[t-CURRENCYTOKEN_SLOT_START] == 0) + if (currencyCounts[t - CURRENCYTOKEN_SLOT_START] == 0) { - currencyCounts[t-CURRENCYTOKEN_SLOT_START] = remaining_count; - currencyPointers [t-CURRENCYTOKEN_SLOT_START] = item; + currencyCounts[t - CURRENCYTOKEN_SLOT_START] = remaining_count; + currencyPointers [t - CURRENCYTOKEN_SLOT_START] = item; b_found = true; break; @@ -11094,14 +11137,14 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit // not plain container check if (pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) && - ItemCanGoIntoBag(pProto, pBagProto)) + ItemCanGoIntoBag(pProto, pBagProto)) { for (uint32 j = 0; j < bag->GetBagSize(); j++) { - if (bagCounts[t-INVENTORY_SLOT_BAG_START][j] == 0) + if (bagCounts[t - INVENTORY_SLOT_BAG_START][j] == 0) { - bagCounts[t-INVENTORY_SLOT_BAG_START][j] = remaining_count; - bagPointers[t-INVENTORY_SLOT_BAG_START][j] = item; + bagCounts[t - INVENTORY_SLOT_BAG_START][j] = remaining_count; + bagPointers[t - INVENTORY_SLOT_BAG_START][j] = item; b_found = true; break; @@ -11119,10 +11162,10 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit bool b_found = false; for (int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { - if (inventoryCounts[t-INVENTORY_SLOT_ITEM_START] == 0) + if (inventoryCounts[t - INVENTORY_SLOT_ITEM_START] == 0) { - inventoryCounts[t-INVENTORY_SLOT_ITEM_START] = remaining_count; - inventoryPointers[t-INVENTORY_SLOT_ITEM_START] = item; + inventoryCounts[t - INVENTORY_SLOT_ITEM_START] = remaining_count; + inventoryPointers[t - INVENTORY_SLOT_ITEM_START] = item; b_found = true; break; @@ -11145,10 +11188,10 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit for (uint32 j = 0; j < bag->GetBagSize(); j++) { - if (bagCounts[t-INVENTORY_SLOT_BAG_START][j] == 0) + if (bagCounts[t - INVENTORY_SLOT_BAG_START][j] == 0) { - bagCounts[t-INVENTORY_SLOT_BAG_START][j] = remaining_count; - bagPointers[t-INVENTORY_SLOT_BAG_START][j] = item; + bagCounts[t - INVENTORY_SLOT_BAG_START][j] = remaining_count; + bagPointers[t - INVENTORY_SLOT_BAG_START][j] = item; b_found = true; break; @@ -11166,7 +11209,7 @@ InventoryResult Player::CanStoreItems(Item** items, int count, uint32* itemLimit } ////////////////////////////////////////////////////////////////////////// -InventoryResult Player::CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, bool swap) const +InventoryResult Player::CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const { dest = 0; Item* pItem = Item::CreateItem(item, 1, this); @@ -11180,13 +11223,13 @@ InventoryResult Player::CanEquipNewItem(uint8 slot, uint16 &dest, uint32 item, b return EQUIP_ERR_ITEM_NOT_FOUND; } -InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool swap, bool not_loading) const +InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading) const { dest = 0; if (pItem) { LOG_DEBUG("entities.player.items", "Player::CanEquipItem: Player '%s' (%s), Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry(), pItem->GetCount()); + GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry(), pItem->GetCount()); ItemTemplate const* pProto = pItem->GetTemplate(); if (pProto) { @@ -11226,7 +11269,7 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool return EQUIP_ERR_NOT_DURING_ARENA_MATCH; } - if (IsInCombat()&& (pProto->Class == ITEM_CLASS_WEAPON || pProto->InventoryType == INVTYPE_RELIC) && m_weaponChangeTimer != 0) + if (IsInCombat() && (pProto->Class == ITEM_CLASS_WEAPON || pProto->InventoryType == INVTYPE_RELIC) && m_weaponChangeTimer != 0) return EQUIP_ERR_CANT_DO_RIGHT_NOW; // maybe exist better err if (IsNonMeleeSpellCast(false)) @@ -11256,24 +11299,24 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool uint8 ignore = uint8(NULL_SLOT); switch (eslot) { - case EQUIPMENT_SLOT_MAINHAND: - ignore = EQUIPMENT_SLOT_OFFHAND; - break; - case EQUIPMENT_SLOT_OFFHAND: - ignore = EQUIPMENT_SLOT_MAINHAND; - break; - case EQUIPMENT_SLOT_FINGER1: - ignore = EQUIPMENT_SLOT_FINGER2; - break; - case EQUIPMENT_SLOT_FINGER2: - ignore = EQUIPMENT_SLOT_FINGER1; - break; - case EQUIPMENT_SLOT_TRINKET1: - ignore = EQUIPMENT_SLOT_TRINKET2; - break; - case EQUIPMENT_SLOT_TRINKET2: - ignore = EQUIPMENT_SLOT_TRINKET1; - break; + case EQUIPMENT_SLOT_MAINHAND: + ignore = EQUIPMENT_SLOT_OFFHAND; + break; + case EQUIPMENT_SLOT_OFFHAND: + ignore = EQUIPMENT_SLOT_MAINHAND; + break; + case EQUIPMENT_SLOT_FINGER1: + ignore = EQUIPMENT_SLOT_FINGER2; + break; + case EQUIPMENT_SLOT_FINGER2: + ignore = EQUIPMENT_SLOT_FINGER1; + break; + case EQUIPMENT_SLOT_TRINKET1: + ignore = EQUIPMENT_SLOT_TRINKET2; + break; + case EQUIPMENT_SLOT_TRINKET2: + ignore = EQUIPMENT_SLOT_TRINKET1; + break; } if (ignore == uint8(NULL_SLOT) || pItem != GetItemByPos(INVENTORY_SLOT_BAG_0, ignore)) @@ -11291,8 +11334,8 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool if (ItemTemplate const* pBagProto = pBag->GetTemplate()) if (pBagProto->Class == pProto->Class && (!swap || pBag->GetSlot() != eslot)) return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH) - ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH - : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; + ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH + : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; uint32 type = pProto->InventoryType; @@ -11334,8 +11377,8 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool Item* offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); ItemPosCountVec off_dest; if (offItem && (!not_loading || - CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND, false) != EQUIP_ERR_OK || - CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false) != EQUIP_ERR_OK)) + CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND, false) != EQUIP_ERR_OK || + CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false) != EQUIP_ERR_OK)) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL; } } @@ -11360,7 +11403,7 @@ InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const return EQUIP_ERR_OK; LOG_DEBUG("entities.player.items", "Player::CanUnequipItem: Player '%s' (%s), Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), pos, pItem->GetEntry(), pItem->GetCount()); + GetName().c_str(), GetGUID().ToString().c_str(), pos, pItem->GetEntry(), pItem->GetCount()); ItemTemplate const* pProto = pItem->GetTemplate(); if (!pProto) @@ -11392,7 +11435,7 @@ InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const return EQUIP_ERR_OK; } -InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, Item* pItem, bool swap, bool not_loading) const +InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading) const { if (!pItem) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; @@ -11400,7 +11443,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest uint32 count = pItem->GetCount(); LOG_DEBUG("entities.player.items", "Player::CanBankItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry(), pItem->GetCount()); + GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry(), pItem->GetCount()); ItemTemplate const* pProto = pItem->GetTemplate(); if (!pProto) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; @@ -11417,7 +11460,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec &dest if (pItemslot >= CURRENCYTOKEN_SLOT_START && pItemslot < CURRENCYTOKEN_SLOT_END) { LOG_ERROR("entities.player.cheat", "Possible hacking attempt: Player %s (%s) tried to move token [%s entry: %u] out of the currency bag!", - GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetGUID().ToString().c_str(), pProto->ItemId); + GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetGUID().ToString().c_str(), pProto->ItemId); return EQUIP_ERR_ITEMS_CANT_BE_SWAPPED; } @@ -11585,7 +11628,7 @@ InventoryResult Player::CanUseItem(Item* pItem, bool not_loading) const if (pItem) { LOG_DEBUG("entities.player.items", "Player::CanUseItem: Player '%s' (%s), Item: %u", - GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry()); + GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry()); if (!IsAlive() && not_loading) return EQUIP_ERR_YOU_ARE_DEAD; @@ -11617,14 +11660,14 @@ InventoryResult Player::CanUseItem(Item* pItem, bool not_loading) const switch (GetClass()) { - case CLASS_HUNTER: - case CLASS_SHAMAN: - allowEquip = (itemSkill == SKILL_MAIL); - break; - case CLASS_PALADIN: - case CLASS_WARRIOR: - allowEquip = (itemSkill == SKILL_PLATE_MAIL); - break; + case CLASS_HUNTER: + case CLASS_SHAMAN: + allowEquip = (itemSkill == SKILL_MAIL); + break; + case CLASS_PALADIN: + case CLASS_WARRIOR: + allowEquip = (itemSkill == SKILL_PLATE_MAIL); + break; } } if (!allowEquip && GetSkillValue(itemSkill) == 0) @@ -11648,7 +11691,7 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const return EQUIP_ERR_ITEM_NOT_FOUND; if (((proto->Flags2 & ITEM_FLAG2_FACTION_HORDE) && GetTeam() != HORDE) || - (((proto->Flags2 & ITEM_FLAG2_FACTION_ALLIANCE) && GetTeam() != ALLIANCE))) + (((proto->Flags2 & ITEM_FLAG2_FACTION_ALLIANCE) && GetTeam() != ALLIANCE))) return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; if ((proto->AllowableClass & GetClassMask()) == 0 || (proto->AllowableRace & GetRaceMask()) == 0) @@ -11692,7 +11735,7 @@ InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObje if (!proto) return EQUIP_ERR_ITEM_NOT_FOUND; - // Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player + // Used by group, function NeedBeforeGreed, to know if a prototype can be used by a player const static uint32 item_weapon_skills[MAX_ITEM_SUBCLASS_WEAPON] = { @@ -11767,7 +11810,7 @@ InventoryResult Player::CanUseAmmo(uint32 item) const ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item); if (pProto) { - if (pProto->InventoryType!= INVTYPE_AMMO) + if (pProto->InventoryType != INVTYPE_AMMO) return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE; InventoryResult res = CanUseItem(pProto); @@ -11894,7 +11937,7 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool uint8 slot = pos & 255; LOG_DEBUG("entities.player.items", "Player::_StoreItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u (%s), Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry(), pItem->GetGUID().ToString().c_str(), count); + GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry(), pItem->GetGUID().ToString().c_str(), count); Item* pItem2 = GetItemByPos(bag, slot); @@ -11909,8 +11952,8 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool return nullptr; if (pItem->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || - pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM || - (pItem->GetTemplate()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) + pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM || + (pItem->GetTemplate()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) pItem->SetBinding(true); Bag* pBag = (bag == INVENTORY_SLOT_BAG_0) ? nullptr : GetBagByPos(bag); @@ -11952,8 +11995,8 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool else { if (pItem2->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || - pItem2->GetTemplate()->Bonding == BIND_QUEST_ITEM || - (pItem2->GetTemplate()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) + pItem2->GetTemplate()->Bonding == BIND_QUEST_ITEM || + (pItem2->GetTemplate()->Bonding == BIND_WHEN_EQUIPED && IsBagPos(pos))) pItem2->SetBinding(true); pItem2->SetCount(pItem2->GetCount() + count); @@ -12034,7 +12077,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) if (!spellProto) LOG_ERROR("entities.player", "Player::EquipItem: Weapon switch cooldown spell %u for player '%s' (%s) couldn't be found in Spell.dbc", - cooldownSpell, GetName().c_str(), GetGUID().ToString().c_str()); + cooldownSpell, GetName().c_str(), GetGUID().ToString().c_str()); else { m_weaponChangeTimer = spellProto->StartRecoveryTime; @@ -12055,7 +12098,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) ApplyEquipCooldown(pItem); - // update expertise and armor penetration - passive auras may need it + // update expertise and armor penetration - passive auras may need it if (slot == EQUIPMENT_SLOT_MAINHAND) UpdateExpertise(BASE_ATTACK); @@ -12065,13 +12108,13 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) switch (slot) { - case EQUIPMENT_SLOT_MAINHAND: - case EQUIPMENT_SLOT_OFFHAND: - case EQUIPMENT_SLOT_RANGED: - RecalculateRating(CR_ARMOR_PENETRATION); - break; - default: - break; + case EQUIPMENT_SLOT_MAINHAND: + case EQUIPMENT_SLOT_OFFHAND: + case EQUIPMENT_SLOT_RANGED: + RecalculateRating(CR_ARMOR_PENETRATION); + break; + default: + break; } } else @@ -12164,7 +12207,7 @@ void Player::VisualizeItem(uint8 slot, Item* pItem) pItem->SetBinding(true); LOG_DEBUG("entities.player.items", "Player::SetVisibleItemSlot: Player '%s' (%s), Slot: %u, Item: %u", - GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry()); + GetName().c_str(), GetGUID().ToString().c_str(), slot, pItem->GetEntry()); m_items[slot] = pItem; SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); @@ -12195,7 +12238,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) if (pItem) { LOG_DEBUG("entities.player.items", "Player::RemoveItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", - GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); + GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); RemoveEnchantmentDurations(pItem); RemoveItemDurations(pItem); @@ -12236,13 +12279,13 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) // update armor penetration - passive auras may need it switch (slot) { - case EQUIPMENT_SLOT_MAINHAND: - case EQUIPMENT_SLOT_OFFHAND: - case EQUIPMENT_SLOT_RANGED: - RecalculateRating(CR_ARMOR_PENETRATION); - break; - default: - break; + case EQUIPMENT_SLOT_MAINHAND: + case EQUIPMENT_SLOT_OFFHAND: + case EQUIPMENT_SLOT_RANGED: + RecalculateRating(CR_ARMOR_PENETRATION); + break; + default: + break; } } } @@ -12323,7 +12366,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) if (pItem) { LOG_DEBUG("entities.player.items", "Player::DestroyItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", - GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); + GetName().c_str(), GetGUID().ToString().c_str(), bag, slot, pItem->GetEntry()); // Also remove all contained items if the item is a bag. // This if () prevents item saving crashes if the condition for a bag to be empty before being destroyed was bypassed somehow. if (pItem->IsNotEmptyBag()) @@ -12370,13 +12413,13 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) // update expertise and armor penetration - passive auras may need it switch (slot) { - case EQUIPMENT_SLOT_MAINHAND: - case EQUIPMENT_SLOT_OFFHAND: - case EQUIPMENT_SLOT_RANGED: - RecalculateRating(CR_ARMOR_PENETRATION); - break; - default: - break; + case EQUIPMENT_SLOT_MAINHAND: + case EQUIPMENT_SLOT_OFFHAND: + case EQUIPMENT_SLOT_RANGED: + RecalculateRating(CR_ARMOR_PENETRATION); + break; + default: + break; } if (slot == EQUIPMENT_SLOT_MAINHAND) @@ -12416,7 +12459,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) uint32 Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, bool unequip_check) { LOG_DEBUG("entities.player.items", "Player::DestroyItemCount: Player '%s' (%s), Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), itemEntry, count); + GetName().c_str(), GetGUID().ToString().c_str(), itemEntry, count); uint32 remcount = 0; // in inventory @@ -12609,7 +12652,7 @@ uint32 Player::DestroyItemCount(uint32 itemEntry, uint32 count, bool update, boo void Player::DestroyZoneLimitedItem(bool update, uint32 new_zone) { LOG_DEBUG("entities.player.items", "Player::DestroyZoneLimitedItem: In map %u and area %u for player '%s' (%s)", - GetMapId(), new_zone, GetName().c_str(), GetGUID().ToString().c_str()); + GetMapId(), new_zone, GetName().c_str(), GetGUID().ToString().c_str()); // in inventory for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) @@ -12642,7 +12685,7 @@ void Player::DestroyConjuredItems(bool update) // used when entering arena // destroys all conjured items LOG_DEBUG("entities.player.items", "Player::DestroyConjuredItems: Player '%s' (%s)", - GetName().c_str(), GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str()); // in inventory for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) @@ -12693,13 +12736,13 @@ Item* Player::GetItemByEntry(uint32 entry) const return nullptr; } -void Player::DestroyItemCount(Item* pItem, uint32 &count, bool update) +void Player::DestroyItemCount(Item* pItem, uint32& count, bool update) { if (!pItem) return; LOG_DEBUG("entities.player.items", "Player::DestroyItemCount: Player '%s' (%s), Item (%s, Entry: %u), Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetGUID().ToString().c_str(), pItem->GetEntry(), count); + GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetGUID().ToString().c_str(), pItem->GetEntry(), count); if (pItem->GetCount() <= count) { @@ -12763,7 +12806,7 @@ void Player::SplitItem(uint16 src, uint16 dst, uint32 count) } LOG_DEBUG("entities.player.items", "Player::SplitItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u, Count: %u", - GetName().c_str(), GetGUID().ToString().c_str(), dstbag, dstslot, pSrcItem->GetEntry(), count); + GetName().c_str(), GetGUID().ToString().c_str(), dstbag, dstslot, pSrcItem->GetEntry(), count); Item* pNewItem = pSrcItem->CloneItem(count, this); if (!pNewItem) { @@ -12849,7 +12892,7 @@ void Player::SwapItem(uint16 src, uint16 dst) return; LOG_DEBUG("entities.player.items", "Player::SwapItem: Player '%s' (%s), Bag: %u, Slot: %u, Item: %u", - GetName().c_str(), GetGUID().ToString().c_str(), dstbag, dstslot, pSrcItem->GetEntry()); + GetName().c_str(), GetGUID().ToString().c_str(), dstbag, dstslot, pSrcItem->GetEntry()); if (!IsAlive()) { @@ -13072,7 +13115,7 @@ void Player::SwapItem(uint16 src, uint16 dst) uint32 count = 0; - for (uint32 i=0; i < fullBag->GetBagSize(); ++i) + for (uint32 i = 0; i < fullBag->GetBagSize(); ++i) { Item* bagItem = fullBag->GetItemByPos(i); if (!bagItem) @@ -13098,7 +13141,7 @@ void Player::SwapItem(uint16 src, uint16 dst) // Items swap count = 0; // will pos in new bag - for (uint32 i = 0; i< fullBag->GetBagSize(); ++i) + for (uint32 i = 0; i < fullBag->GetBagSize(); ++i) { Item* bagItem = fullBag->GetItemByPos(i); if (!bagItem) @@ -13192,7 +13235,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) uint32 oldest_time = GetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1); uint32 oldest_slot = BUYBACK_SLOT_START; - for (uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i) + for (uint32 i = BUYBACK_SLOT_START + 1; i < BUYBACK_SLOT_END; ++i) { // found empty if (!m_items[i]) @@ -13216,7 +13259,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) RemoveItemFromBuyBackSlot(slot, true); LOG_DEBUG("entities.player.items", "Player::AddItemToBuyBackSlot: Player '%s' (%s), Item: %u, Slot: %u", - GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry(), slot); + GetName().c_str(), GetGUID().ToString().c_str(), pItem->GetEntry(), slot); m_items[slot] = pItem; time_t base = GameTime::GetGameTime(); @@ -13239,7 +13282,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) Item* Player::GetItemFromBuyBackSlot(uint32 slot) { LOG_DEBUG("entities.player.items", "Player::GetItemFromBuyBackSlot: Player '%s' (%s), Slot: %u", - GetName().c_str(), GetGUID().ToString().c_str(), slot); + GetName().c_str(), GetGUID().ToString().c_str(), slot); if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) return m_items[slot]; return nullptr; @@ -13248,7 +13291,7 @@ Item* Player::GetItemFromBuyBackSlot(uint32 slot) void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) { LOG_DEBUG("entities.player.items", "Player::RemoveItemFromBuyBackSlot: Player '%s' (%s), Slot: %u", - GetName().c_str(), GetGUID().ToString().c_str(), slot); + GetName().c_str(), GetGUID().ToString().c_str(), slot); if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) { Item* pItem = m_items[slot]; @@ -13292,30 +13335,30 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint switch (msg) { - case EQUIP_ERR_CANT_EQUIP_LEVEL_I: - case EQUIP_ERR_PURCHASE_LEVEL_TOO_LOW: - { - ItemTemplate const* proto = pItem ? pItem->GetTemplate() : sObjectMgr->GetItemTemplate(itemid); - data << uint32(proto ? proto->RequiredLevel : 0); - break; - } - case EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM: // no idea about this one... - { - data << uint64(0); // item guid - data << uint32(0); // slot - data << uint64(0); // container - break; - } - case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED: - case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_SOCKETED_EXCEEDED: - case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED: - { - ItemTemplate const* proto = pItem ? pItem->GetTemplate() : sObjectMgr->GetItemTemplate(itemid); - data << uint32(proto ? proto->ItemLimitCategory : 0); - break; - } - default: - break; + case EQUIP_ERR_CANT_EQUIP_LEVEL_I: + case EQUIP_ERR_PURCHASE_LEVEL_TOO_LOW: + { + ItemTemplate const* proto = pItem ? pItem->GetTemplate() : sObjectMgr->GetItemTemplate(itemid); + data << uint32(proto ? proto->RequiredLevel : 0); + break; + } + case EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM: // no idea about this one... + { + data << uint64(0); // item guid + data << uint32(0); // slot + data << uint64(0); // container + break; + } + case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED: + case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_SOCKETED_EXCEEDED: + case EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED: + { + ItemTemplate const* proto = pItem ? pItem->GetTemplate() : sObjectMgr->GetItemTemplate(itemid); + data << uint32(proto ? proto->ItemLimitCategory : 0); + break; + } + default: + break; } } SendDirectMessage(&data); @@ -13323,7 +13366,7 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param) const { - WorldPacket data(SMSG_BUY_FAILED, (8+4+4+1)); + WorldPacket data(SMSG_BUY_FAILED, (8 + 4 + 4 + 1)); data << uint64(creature ? creature->GetGUID() : ObjectGuid::Empty); data << uint32(item); if (param > 0) @@ -13334,7 +13377,7 @@ void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param) const { - WorldPacket data(SMSG_SELL_ITEM, (8+8+(4)+1)); // last check 2.0.10 + WorldPacket data(SMSG_SELL_ITEM, (8 + 8 + (4) + 1)); // last check 2.0.10 data << uint64(creature ? creature->GetGUID() : ObjectGuid::Empty); data << uint64(guid); if (param > 0) @@ -13444,7 +13487,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) return; LOG_DEBUG("entities.player.items", "Player::UpdateItemDuration: Player '%s' (%s), Time: %u, RealTimeOnly: %u", - GetName().c_str(), GetGUID().ToString().c_str(), time, realtimeonly); + GetName().c_str(), GetGUID().ToString().c_str(), time, realtimeonly); for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end();) { @@ -13463,9 +13506,7 @@ void Player::UpdateEnchantTime(uint32 time) ASSERT(itr->item); next = itr; if (!itr->item->GetEnchantmentId(itr->slot)) - { next = m_enchantDuration.erase(itr); - } else if (itr->leftduration <= time) { ApplyEnchantment(itr->item, itr->slot, false, false); @@ -13584,7 +13625,7 @@ void Player::AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 dur } if (duration > 0) { - GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000)); + GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration / 1000)); m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); } } @@ -13623,12 +13664,12 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool // If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements // rather than the gem requirements itself. If the socket has no color it is a prismatic socket. if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) - && !item->GetTemplate()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color) + && !item->GetTemplate()->Socket[slot - SOCK_ENCHANTMENT_SLOT].Color) { // Check if the requirements for the prismatic socket are met before applying the gem stats - SpellItemEnchantmentEntry const* pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); - if (!pPrismaticEnchant || (pPrismaticEnchant->RequiredSkillID > 0 && pPrismaticEnchant->RequiredSkillRank > GetSkillValue(pPrismaticEnchant->RequiredSkillID))) - return; + SpellItemEnchantmentEntry const* pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(item->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); + if (!pPrismaticEnchant || (pPrismaticEnchant->RequiredSkillID > 0 && pPrismaticEnchant->RequiredSkillRank > GetSkillValue(pPrismaticEnchant->RequiredSkillID))) + return; } if (!item->IsBroken()) @@ -13641,296 +13682,296 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool switch (enchant_display_type) { - case ITEM_ENCHANTMENT_TYPE_NONE: - break; - case ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL: - // processed in Player::CastItemCombatSpell - break; - case ITEM_ENCHANTMENT_TYPE_DAMAGE: + case ITEM_ENCHANTMENT_TYPE_NONE: + break; + case ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL: + // processed in Player::CastItemCombatSpell + break; + case ITEM_ENCHANTMENT_TYPE_DAMAGE: + { + WeaponAttackType const attackType = Player::GetAttackBySlot(item->GetSlot()); + if (attackType != MAX_ATTACK) + UpdateDamageDoneMods(attackType, apply ? -1 : slot); + break; + } + case ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL: + if (enchant_spell_id) { - WeaponAttackType const attackType = Player::GetAttackBySlot(item->GetSlot()); - if (attackType != MAX_ATTACK) - UpdateDamageDoneMods(attackType, apply ? -1 : slot); - break; - } - case ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL: - if (enchant_spell_id) + if (apply) { - if (apply) + int32 basepoints = 0; + // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) + if (item->GetItemRandomPropertyId()) { - int32 basepoints = 0; - // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) - if (item->GetItemRandomPropertyId()) + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if (item_rand) { - ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if (item_rand) + // Search enchant_amount + for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) { - // Search enchant_amount - for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) + if (item_rand->Enchantment[k] == enchant_id) { - if (item_rand->Enchantment[k] == enchant_id) - { - basepoints = int32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); - break; - } + basepoints = int32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); + break; } } } + } - CastSpellExtraArgs args(item); - // Cast custom spell vs all equal basepoints got from enchant_amount - if (basepoints) - for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) - args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), basepoints); + CastSpellExtraArgs args(item); + // Cast custom spell vs all equal basepoints got from enchant_amount + if (basepoints) + for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) + args.AddSpellMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), basepoints); - CastSpell(this, enchant_spell_id, args); - } - else - RemoveAurasDueToItemSpell(enchant_spell_id, item->GetGUID()); + CastSpell(this, enchant_spell_id, args); } - break; - case ITEM_ENCHANTMENT_TYPE_RESISTANCE: - if (!enchant_amount) + else + RemoveAurasDueToItemSpell(enchant_spell_id, item->GetGUID()); + } + break; + case ITEM_ENCHANTMENT_TYPE_RESISTANCE: + if (!enchant_amount) + { + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if (item_rand) { - ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if (item_rand) + for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) { - for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) + if (item_rand->Enchantment[k] == enchant_id) { - if (item_rand->Enchantment[k] == enchant_id) - { - enchant_amount = uint32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); - break; - } + enchant_amount = uint32((item_rand->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); + break; } } } + } - HandleStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); - break; - case ITEM_ENCHANTMENT_TYPE_STAT: + HandleStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + enchant_spell_id), TOTAL_VALUE, float(enchant_amount), apply); + break; + case ITEM_ENCHANTMENT_TYPE_STAT: + { + if (!enchant_amount) { - if (!enchant_amount) + ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + if (item_rand_suffix) { - ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); - if (item_rand_suffix) + for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) { - for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) + if (item_rand_suffix->Enchantment[k] == enchant_id) { - if (item_rand_suffix->Enchantment[k] == enchant_id) - { - enchant_amount = uint32((item_rand_suffix->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); - break; - } + enchant_amount = uint32((item_rand_suffix->AllocationPct[k] * item->GetItemSuffixFactor()) / 10000); + break; } } } - - LOG_DEBUG("entities.player.items", "Adding %u to stat nb %u", enchant_amount, enchant_spell_id); - switch (enchant_spell_id) - { - case ITEM_MOD_MANA: - LOG_DEBUG("entities.player.items", "+ %u MANA", enchant_amount); - HandleStatFlatModifier(UNIT_MOD_MANA, BASE_VALUE, float(enchant_amount), apply); - break; - case ITEM_MOD_HEALTH: - LOG_DEBUG("entities.player.items", "+ %u HEALTH", enchant_amount); - HandleStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, float(enchant_amount), apply); - break; - case ITEM_MOD_AGILITY: - LOG_DEBUG("entities.player.items", "+ %u AGILITY", enchant_amount); - HandleStatFlatModifier(UNIT_MOD_STAT_AGILITY, TOTAL_VALUE, float(enchant_amount), apply); - UpdateStatBuffMod(STAT_AGILITY); - break; - case ITEM_MOD_STRENGTH: - LOG_DEBUG("entities.player.items", "+ %u STRENGTH", enchant_amount); - HandleStatFlatModifier(UNIT_MOD_STAT_STRENGTH, TOTAL_VALUE, float(enchant_amount), apply); - UpdateStatBuffMod(STAT_STRENGTH); - break; - case ITEM_MOD_INTELLECT: - LOG_DEBUG("entities.player.items", "+ %u INTELLECT", enchant_amount); - HandleStatFlatModifier(UNIT_MOD_STAT_INTELLECT, TOTAL_VALUE, float(enchant_amount), apply); - UpdateStatBuffMod(STAT_INTELLECT); - break; - case ITEM_MOD_SPIRIT: - LOG_DEBUG("entities.player.items", "+ %u SPIRIT", enchant_amount); - HandleStatFlatModifier(UNIT_MOD_STAT_SPIRIT, TOTAL_VALUE, float(enchant_amount), apply); - UpdateStatBuffMod(STAT_SPIRIT); - break; - case ITEM_MOD_STAMINA: - LOG_DEBUG("entities.player.items", "+ %u STAMINA", enchant_amount); - HandleStatFlatModifier(UNIT_MOD_STAT_STAMINA, TOTAL_VALUE, float(enchant_amount), apply); - UpdateStatBuffMod(STAT_STAMINA); - break; - case ITEM_MOD_DEFENSE_SKILL_RATING: - ApplyRatingMod(CR_DEFENSE_SKILL, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u DEFENSE", enchant_amount); - break; - case ITEM_MOD_DODGE_RATING: - ApplyRatingMod(CR_DODGE, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u DODGE", enchant_amount); - break; - case ITEM_MOD_PARRY_RATING: - ApplyRatingMod(CR_PARRY, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u PARRY", enchant_amount); - break; - case ITEM_MOD_BLOCK_RATING: - ApplyRatingMod(CR_BLOCK, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u SHIELD_BLOCK", enchant_amount); - break; - case ITEM_MOD_HIT_MELEE_RATING: - ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u MELEE_HIT", enchant_amount); - break; - case ITEM_MOD_HIT_RANGED_RATING: - ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u RANGED_HIT", enchant_amount); - break; - case ITEM_MOD_HIT_SPELL_RATING: - ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u SPELL_HIT", enchant_amount); - break; - case ITEM_MOD_CRIT_MELEE_RATING: - ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u MELEE_CRIT", enchant_amount); - break; - case ITEM_MOD_CRIT_RANGED_RATING: - ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u RANGED_CRIT", enchant_amount); - break; - case ITEM_MOD_CRIT_SPELL_RATING: - ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u SPELL_CRIT", enchant_amount); - break; -// Values from ITEM_STAT_MELEE_HA_RATING to ITEM_MOD_HASTE_RANGED_RATING are never used -// in Enchantments -// case ITEM_MOD_HIT_TAKEN_MELEE_RATING: -// ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_HIT_TAKEN_RANGED_RATING: -// ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); -// break; -// case ITEM_MOD_HIT_TAKEN_SPELL_RATING: -// ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: -// ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: -// ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: -// ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_HASTE_MELEE_RATING: -// ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); -// break; -// case ITEM_MOD_HASTE_RANGED_RATING: -// ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); -// break; - case ITEM_MOD_HASTE_SPELL_RATING: - ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); - break; - case ITEM_MOD_HIT_RATING: - ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); - ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); - ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u HIT", enchant_amount); - break; - case ITEM_MOD_CRIT_RATING: - ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); - ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); - ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u CRITICAL", enchant_amount); - break; -// Values ITEM_MOD_HIT_TAKEN_RATING and ITEM_MOD_CRIT_TAKEN_RATING are never used in Enchantment -// case ITEM_MOD_HIT_TAKEN_RATING: -// ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); -// ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); -// ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); -// break; -// case ITEM_MOD_CRIT_TAKEN_RATING: -// ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); -// ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); -// ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); -// break; - case ITEM_MOD_RESILIENCE_RATING: - ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); - ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); - ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u RESILIENCE", enchant_amount); - break; - case ITEM_MOD_HASTE_RATING: - ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); - ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); - ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u HASTE", enchant_amount); - break; - case ITEM_MOD_EXPERTISE_RATING: - ApplyRatingMod(CR_EXPERTISE, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u EXPERTISE", enchant_amount); - break; - case ITEM_MOD_ATTACK_POWER: - HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(enchant_amount), apply); - HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply); - LOG_DEBUG("entities.player.items", "+ %u ATTACK_POWER", enchant_amount); - break; - case ITEM_MOD_RANGED_ATTACK_POWER: - HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply); - LOG_DEBUG("entities.player.items", "+ %u RANGED_ATTACK_POWER", enchant_amount); - break; -// case ITEM_MOD_FERAL_ATTACK_POWER: -// ApplyFeralAPBonus(enchant_amount, apply); -// LOG_DEBUG("entities.player.items", "+ %u FERAL_ATTACK_POWER", enchant_amount); -// break; - case ITEM_MOD_MANA_REGENERATION: - ApplyManaRegenBonus(enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u MANA_REGENERATION", enchant_amount); - break; - case ITEM_MOD_ARMOR_PENETRATION_RATING: - ApplyRatingMod(CR_ARMOR_PENETRATION, enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u ARMOR PENETRATION", enchant_amount); - break; - case ITEM_MOD_SPELL_POWER: - ApplySpellPowerBonus(enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u SPELL_POWER", enchant_amount); - break; - case ITEM_MOD_HEALTH_REGEN: - ApplyHealthRegenBonus(enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u HEALTH_REGENERATION", enchant_amount); - break; - case ITEM_MOD_SPELL_PENETRATION: - ApplySpellPenetrationBonus(enchant_amount, apply); - LOG_DEBUG("entities.player.items", "+ %u SPELL_PENETRATION", enchant_amount); - break; - case ITEM_MOD_BLOCK_VALUE: - HandleBaseModFlatValue(SHIELD_BLOCK_VALUE, float(enchant_amount), apply); - LOG_DEBUG("entities.player.items", "+ %u BLOCK_VALUE", enchant_amount); - break; - case ITEM_MOD_SPELL_HEALING_DONE: // deprecated - case ITEM_MOD_SPELL_DAMAGE_DONE: // deprecated - default: - break; - } - break; } - case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon + + LOG_DEBUG("entities.player.items", "Adding %u to stat nb %u", enchant_amount, enchant_spell_id); + switch (enchant_spell_id) { - WeaponAttackType const attackType = Player::GetAttackBySlot(item->GetSlot()); - if (attackType != MAX_ATTACK) - UpdateDamageDoneMods(attackType, apply ? -1 : slot); + case ITEM_MOD_MANA: + LOG_DEBUG("entities.player.items", "+ %u MANA", enchant_amount); + HandleStatFlatModifier(UNIT_MOD_MANA, BASE_VALUE, float(enchant_amount), apply); break; - } - case ITEM_ENCHANTMENT_TYPE_USE_SPELL: - // processed in Player::CastItemUseSpell + case ITEM_MOD_HEALTH: + LOG_DEBUG("entities.player.items", "+ %u HEALTH", enchant_amount); + HandleStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, float(enchant_amount), apply); + break; + case ITEM_MOD_AGILITY: + LOG_DEBUG("entities.player.items", "+ %u AGILITY", enchant_amount); + HandleStatFlatModifier(UNIT_MOD_STAT_AGILITY, TOTAL_VALUE, float(enchant_amount), apply); + UpdateStatBuffMod(STAT_AGILITY); + break; + case ITEM_MOD_STRENGTH: + LOG_DEBUG("entities.player.items", "+ %u STRENGTH", enchant_amount); + HandleStatFlatModifier(UNIT_MOD_STAT_STRENGTH, TOTAL_VALUE, float(enchant_amount), apply); + UpdateStatBuffMod(STAT_STRENGTH); + break; + case ITEM_MOD_INTELLECT: + LOG_DEBUG("entities.player.items", "+ %u INTELLECT", enchant_amount); + HandleStatFlatModifier(UNIT_MOD_STAT_INTELLECT, TOTAL_VALUE, float(enchant_amount), apply); + UpdateStatBuffMod(STAT_INTELLECT); + break; + case ITEM_MOD_SPIRIT: + LOG_DEBUG("entities.player.items", "+ %u SPIRIT", enchant_amount); + HandleStatFlatModifier(UNIT_MOD_STAT_SPIRIT, TOTAL_VALUE, float(enchant_amount), apply); + UpdateStatBuffMod(STAT_SPIRIT); + break; + case ITEM_MOD_STAMINA: + LOG_DEBUG("entities.player.items", "+ %u STAMINA", enchant_amount); + HandleStatFlatModifier(UNIT_MOD_STAT_STAMINA, TOTAL_VALUE, float(enchant_amount), apply); + UpdateStatBuffMod(STAT_STAMINA); + break; + case ITEM_MOD_DEFENSE_SKILL_RATING: + ApplyRatingMod(CR_DEFENSE_SKILL, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u DEFENSE", enchant_amount); + break; + case ITEM_MOD_DODGE_RATING: + ApplyRatingMod(CR_DODGE, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u DODGE", enchant_amount); + break; + case ITEM_MOD_PARRY_RATING: + ApplyRatingMod(CR_PARRY, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u PARRY", enchant_amount); break; - case ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET: - // nothing do.. + case ITEM_MOD_BLOCK_RATING: + ApplyRatingMod(CR_BLOCK, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u SHIELD_BLOCK", enchant_amount); break; + case ITEM_MOD_HIT_MELEE_RATING: + ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u MELEE_HIT", enchant_amount); + break; + case ITEM_MOD_HIT_RANGED_RATING: + ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u RANGED_HIT", enchant_amount); + break; + case ITEM_MOD_HIT_SPELL_RATING: + ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u SPELL_HIT", enchant_amount); + break; + case ITEM_MOD_CRIT_MELEE_RATING: + ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u MELEE_CRIT", enchant_amount); + break; + case ITEM_MOD_CRIT_RANGED_RATING: + ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u RANGED_CRIT", enchant_amount); + break; + case ITEM_MOD_CRIT_SPELL_RATING: + ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u SPELL_CRIT", enchant_amount); + break; + // Values from ITEM_STAT_MELEE_HA_RATING to ITEM_MOD_HASTE_RANGED_RATING are never used + // in Enchantments + // case ITEM_MOD_HIT_TAKEN_MELEE_RATING: + // ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); + // break; + // case ITEM_MOD_HIT_TAKEN_RANGED_RATING: + // ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); + // break; + // case ITEM_MOD_HIT_TAKEN_SPELL_RATING: + // ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_MELEE_RATING: + // ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_RANGED_RATING: + // ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_SPELL_RATING: + // ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); + // break; + // case ITEM_MOD_HASTE_MELEE_RATING: + // ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); + // break; + // case ITEM_MOD_HASTE_RANGED_RATING: + // ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); + // break; + case ITEM_MOD_HASTE_SPELL_RATING: + ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); + break; + case ITEM_MOD_HIT_RATING: + ApplyRatingMod(CR_HIT_MELEE, enchant_amount, apply); + ApplyRatingMod(CR_HIT_RANGED, enchant_amount, apply); + ApplyRatingMod(CR_HIT_SPELL, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u HIT", enchant_amount); + break; + case ITEM_MOD_CRIT_RATING: + ApplyRatingMod(CR_CRIT_MELEE, enchant_amount, apply); + ApplyRatingMod(CR_CRIT_RANGED, enchant_amount, apply); + ApplyRatingMod(CR_CRIT_SPELL, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u CRITICAL", enchant_amount); + break; + // Values ITEM_MOD_HIT_TAKEN_RATING and ITEM_MOD_CRIT_TAKEN_RATING are never used in Enchantment + // case ITEM_MOD_HIT_TAKEN_RATING: + // ApplyRatingMod(CR_HIT_TAKEN_MELEE, enchant_amount, apply); + // ApplyRatingMod(CR_HIT_TAKEN_RANGED, enchant_amount, apply); + // ApplyRatingMod(CR_HIT_TAKEN_SPELL, enchant_amount, apply); + // break; + // case ITEM_MOD_CRIT_TAKEN_RATING: + // ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); + // ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); + // ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); + // break; + case ITEM_MOD_RESILIENCE_RATING: + ApplyRatingMod(CR_CRIT_TAKEN_MELEE, enchant_amount, apply); + ApplyRatingMod(CR_CRIT_TAKEN_RANGED, enchant_amount, apply); + ApplyRatingMod(CR_CRIT_TAKEN_SPELL, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u RESILIENCE", enchant_amount); + break; + case ITEM_MOD_HASTE_RATING: + ApplyRatingMod(CR_HASTE_MELEE, enchant_amount, apply); + ApplyRatingMod(CR_HASTE_RANGED, enchant_amount, apply); + ApplyRatingMod(CR_HASTE_SPELL, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u HASTE", enchant_amount); + break; + case ITEM_MOD_EXPERTISE_RATING: + ApplyRatingMod(CR_EXPERTISE, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u EXPERTISE", enchant_amount); + break; + case ITEM_MOD_ATTACK_POWER: + HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER, TOTAL_VALUE, float(enchant_amount), apply); + HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply); + LOG_DEBUG("entities.player.items", "+ %u ATTACK_POWER", enchant_amount); + break; + case ITEM_MOD_RANGED_ATTACK_POWER: + HandleStatFlatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(enchant_amount), apply); + LOG_DEBUG("entities.player.items", "+ %u RANGED_ATTACK_POWER", enchant_amount); + break; + // case ITEM_MOD_FERAL_ATTACK_POWER: + // ApplyFeralAPBonus(enchant_amount, apply); + // LOG_DEBUG("entities.player.items", "+ %u FERAL_ATTACK_POWER", enchant_amount); + // break; + case ITEM_MOD_MANA_REGENERATION: + ApplyManaRegenBonus(enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u MANA_REGENERATION", enchant_amount); + break; + case ITEM_MOD_ARMOR_PENETRATION_RATING: + ApplyRatingMod(CR_ARMOR_PENETRATION, enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u ARMOR PENETRATION", enchant_amount); + break; + case ITEM_MOD_SPELL_POWER: + ApplySpellPowerBonus(enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u SPELL_POWER", enchant_amount); + break; + case ITEM_MOD_HEALTH_REGEN: + ApplyHealthRegenBonus(enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u HEALTH_REGENERATION", enchant_amount); + break; + case ITEM_MOD_SPELL_PENETRATION: + ApplySpellPenetrationBonus(enchant_amount, apply); + LOG_DEBUG("entities.player.items", "+ %u SPELL_PENETRATION", enchant_amount); + break; + case ITEM_MOD_BLOCK_VALUE: + HandleBaseModFlatValue(SHIELD_BLOCK_VALUE, float(enchant_amount), apply); + LOG_DEBUG("entities.player.items", "+ %u BLOCK_VALUE", enchant_amount); + break; + case ITEM_MOD_SPELL_HEALING_DONE: // deprecated + case ITEM_MOD_SPELL_DAMAGE_DONE: // deprecated default: - LOG_ERROR("entities.player", "Player::ApplyEnchantment: Unknown item enchantment (ID: %u, DisplayType: %u) for player '%s' (%s)", - enchant_id, enchant_display_type, GetName().c_str(), GetGUID().ToString().c_str()); break; + } + break; + } + case ITEM_ENCHANTMENT_TYPE_TOTEM: // Shaman Rockbiter Weapon + { + WeaponAttackType const attackType = Player::GetAttackBySlot(item->GetSlot()); + if (attackType != MAX_ATTACK) + UpdateDamageDoneMods(attackType, apply ? -1 : slot); + break; + } + case ITEM_ENCHANTMENT_TYPE_USE_SPELL: + // processed in Player::CastItemUseSpell + break; + case ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET: + // nothing do.. + break; + default: + LOG_ERROR("entities.player", "Player::ApplyEnchantment: Unknown item enchantment (ID: %u, DisplayType: %u) for player '%s' (%s)", + enchant_id, enchant_display_type, GetName().c_str(), GetGUID().ToString().c_str()); + break; } } } @@ -13987,7 +14028,7 @@ void Player::UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 // If we're dealing with a gem inside a prismatic socket we need to check the prismatic socket requirements // rather than the gem requirements itself. If the socket has no color it is a prismatic socket. if ((slot == SOCK_ENCHANTMENT_SLOT || slot == SOCK_ENCHANTMENT_SLOT_2 || slot == SOCK_ENCHANTMENT_SLOT_3) - && !m_items[i]->GetTemplate()->Socket[slot-SOCK_ENCHANTMENT_SLOT].Color) + && !m_items[i]->GetTemplate()->Socket[slot - SOCK_ENCHANTMENT_SLOT].Color) { SpellItemEnchantmentEntry const* pPrismaticEnchant = sSpellItemEnchantmentStore.LookupEntry(m_items[i]->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)); @@ -14007,17 +14048,13 @@ void Player::UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 void Player::SendEnchantmentDurations() { for (EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) - { GetSession()->SendItemEnchantTimeUpdate(GetGUID(), itr->item->GetGUID(), itr->slot, uint32(itr->leftduration) / 1000); - } } void Player::SendItemDurations() { for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) - { (*itr)->SendTimeUpdate(this); - } } void Player::SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast, bool sendChatMessage) @@ -14025,14 +14062,14 @@ void Player::SendNewItem(Item* item, uint32 count, bool received, bool created, if (!item) // prevent crash return; - // last check 2.0.10 - WorldPacket data(SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4)); + // last check 2.0.10 + WorldPacket data(SMSG_ITEM_PUSH_RESULT, (8 + 4 + 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4)); data << uint64(GetGUID()); // player GUID data << uint32(received); // 0=looted, 1=from npc data << uint32(created); // 0=received, 1=created data << uint32(sendChatMessage); // bool print message to chat data << uint8(item->GetBagSlot()); // bagslot - // item slot, but when added to stack: 0xFFFFFFFF + // item slot, but when added to stack: 0xFFFFFFFF data << uint32((item->GetCount() == count) ? item->GetSlot() : -1); data << uint32(item->GetEntry()); // item id data << uint32(item->GetItemSuffixFactor()); // SuffixFactor @@ -14088,91 +14125,92 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool switch (itr->second.OptionType) { - case GOSSIP_OPTION_ARMORER: - canTalk = false; // added in special mode - break; - case GOSSIP_OPTION_SPIRITHEALER: - if (!isDead()) - canTalk = false; - break; - case GOSSIP_OPTION_VENDOR: + case GOSSIP_OPTION_ARMORER: + canTalk = false; // added in special mode + break; + case GOSSIP_OPTION_SPIRITHEALER: + if (!isDead()) + canTalk = false; + break; + case GOSSIP_OPTION_VENDOR: + { + VendorItemData const* vendorItems = itr->second.ActionMenuID ? nullptr : creature->GetVendorItems(); + if (!itr->second.ActionMenuID && (!vendorItems || vendorItems->Empty())) { - VendorItemData const* vendorItems = itr->second.ActionMenuID ? nullptr : creature->GetVendorItems(); - if (!itr->second.ActionMenuID && (!vendorItems || vendorItems->Empty())) - { - LOG_ERROR("sql.sql", "Creature %s (%s DB GUID: %u) has UNIT_NPC_FLAG_VENDOR set, but has an empty trading item list.", creature->GetName().c_str(), creature->GetGUID().ToString().c_str(), creature->GetSpawnId()); - canTalk = false; - } - break; + LOG_ERROR("sql.sql", "Creature %s (%s DB GUID: %u) has UNIT_NPC_FLAG_VENDOR set, but has an empty trading item list.", creature->GetName().c_str(), creature->GetGUID().ToString().c_str(), + creature->GetSpawnId()); + canTalk = false; } - case GOSSIP_OPTION_LEARNDUALSPEC: - case GOSSIP_OPTION_DUALSPEC_INFO: - if (!(GetSpecsCount() == 1 && creature->CanResetTalents(this, false) && !(GetLevel() < CONF_GET_INT("MinDualSpecLevel")))) - canTalk = false; - break; - case GOSSIP_OPTION_UNLEARNTALENTS: - if (!creature->CanResetTalents(this, false)) - canTalk = false; - break; - case GOSSIP_OPTION_UNLEARNPETTALENTS: - if (!GetPet() || GetPet()->getPetType() != HUNTER_PET || GetPet()->m_spells.size() <= 1 || !creature->CanResetTalents(this, true)) - canTalk = false; - break; - case GOSSIP_OPTION_TAXIVENDOR: - if (GetSession()->SendLearnNewTaxiNode(creature)) - return; - break; - case GOSSIP_OPTION_BATTLEFIELD: - if (!creature->isCanInteractWithBattleMaster(this, false)) - canTalk = false; - break; - case GOSSIP_OPTION_STABLEPET: - if (GetClass() != CLASS_HUNTER) - canTalk = false; - break; - case GOSSIP_OPTION_QUESTGIVER: + break; + } + case GOSSIP_OPTION_LEARNDUALSPEC: + case GOSSIP_OPTION_DUALSPEC_INFO: + if (!(GetSpecsCount() == 1 && creature->CanResetTalents(this, false) && !(GetLevel() < CONF_GET_INT("MinDualSpecLevel")))) canTalk = false; - break; - case GOSSIP_OPTION_TRAINER: + break; + case GOSSIP_OPTION_UNLEARNTALENTS: + if (!creature->CanResetTalents(this, false)) + canTalk = false; + break; + case GOSSIP_OPTION_UNLEARNPETTALENTS: + if (!GetPet() || GetPet()->getPetType() != HUNTER_PET || GetPet()->m_spells.size() <= 1 || !creature->CanResetTalents(this, true)) + canTalk = false; + break; + case GOSSIP_OPTION_TAXIVENDOR: + if (GetSession()->SendLearnNewTaxiNode(creature)) + return; + break; + case GOSSIP_OPTION_BATTLEFIELD: + if (!creature->isCanInteractWithBattleMaster(this, false)) + canTalk = false; + break; + case GOSSIP_OPTION_STABLEPET: + if (GetClass() != CLASS_HUNTER) + canTalk = false; + break; + case GOSSIP_OPTION_QUESTGIVER: + canTalk = false; + break; + case GOSSIP_OPTION_TRAINER: + { + Trainer::Trainer const* trainer = sObjectMgr->GetTrainer(creature->GetEntry()); + if (!trainer || !trainer->IsTrainerValidForPlayer(this)) { - Trainer::Trainer const* trainer = sObjectMgr->GetTrainer(creature->GetEntry()); - if (!trainer || !trainer->IsTrainerValidForPlayer(this)) - { - LOG_ERROR("sql.sql", "GOSSIP_OPTION_TRAINER:: Player %s %s requested wrong gossip menu: %u at Creature: %s (Entry: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), menu->GetGossipMenu().GetMenuId(), creature->GetName().c_str(), creature->GetEntry()); - canTalk = false; - } - [[fallthrough]]; + LOG_ERROR("sql.sql", "GOSSIP_OPTION_TRAINER:: Player %s %s requested wrong gossip menu: %u at Creature: %s (Entry: %u)", + GetName().c_str(), GetGUID().ToString().c_str(), menu->GetGossipMenu().GetMenuId(), creature->GetName().c_str(), creature->GetEntry()); + canTalk = false; } - case GOSSIP_OPTION_GOSSIP: - case GOSSIP_OPTION_SPIRITGUIDE: - case GOSSIP_OPTION_INNKEEPER: - case GOSSIP_OPTION_BANKER: - case GOSSIP_OPTION_PETITIONER: - case GOSSIP_OPTION_TABARDDESIGNER: - case GOSSIP_OPTION_AUCTIONEER: - break; // no checks - case GOSSIP_OPTION_OUTDOORPVP: - if (!sOutdoorPvPMgr->CanTalkTo(this, creature, itr->second)) - canTalk = false; - break; - default: - LOG_ERROR("sql.sql", "Creature entry %u has unknown gossip option %u for menu %u.", creature->GetEntry(), itr->second.OptionType, itr->second.MenuID); + [[fallthrough]]; + } + case GOSSIP_OPTION_GOSSIP: + case GOSSIP_OPTION_SPIRITGUIDE: + case GOSSIP_OPTION_INNKEEPER: + case GOSSIP_OPTION_BANKER: + case GOSSIP_OPTION_PETITIONER: + case GOSSIP_OPTION_TABARDDESIGNER: + case GOSSIP_OPTION_AUCTIONEER: + break; // no checks + case GOSSIP_OPTION_OUTDOORPVP: + if (!sOutdoorPvPMgr->CanTalkTo(this, creature, itr->second)) canTalk = false; - break; + break; + default: + LOG_ERROR("sql.sql", "Creature entry %u has unknown gossip option %u for menu %u.", creature->GetEntry(), itr->second.OptionType, itr->second.MenuID); + canTalk = false; + break; } } else if (GameObject* go = source->ToGameObject()) { switch (itr->second.OptionType) { - case GOSSIP_OPTION_GOSSIP: - if (go->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER && go->GetGoType() != GAMEOBJECT_TYPE_GOOBER) - canTalk = false; - break; - default: + case GOSSIP_OPTION_GOSSIP: + if (go->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER && go->GetGoType() != GAMEOBJECT_TYPE_GOOBER) canTalk = false; - break; + break; + default: + canTalk = false; + break; } } @@ -14271,7 +14309,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men if (gossipOptionId > GOSSIP_OPTION_QUESTGIVER) { LOG_ERROR("entities.player", "Player '%s' (%s) requests invalid gossip option for GameObject (Entry: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), source->GetEntry()); + GetName().c_str(), GetGUID().ToString().c_str(), source->GetEntry()); return; } } @@ -14290,100 +14328,100 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men switch (gossipOptionId) { - case GOSSIP_OPTION_GOSSIP: - case GOSSIP_OPTION_DUALSPEC_INFO: - { - if (menuItemData->GossipActionPoi) - PlayerTalkClass->SendPointOfInterest(menuItemData->GossipActionPoi); - - if (menuItemData->GossipActionMenuId) - { - PrepareGossipMenu(source, menuItemData->GossipActionMenuId); - SendPreparedGossip(source); - } + case GOSSIP_OPTION_GOSSIP: + case GOSSIP_OPTION_DUALSPEC_INFO: + { + if (menuItemData->GossipActionPoi) + PlayerTalkClass->SendPointOfInterest(menuItemData->GossipActionPoi); - break; + if (menuItemData->GossipActionMenuId) + { + PrepareGossipMenu(source, menuItemData->GossipActionMenuId); + SendPreparedGossip(source); } - case GOSSIP_OPTION_OUTDOORPVP: - sOutdoorPvPMgr->HandleGossipOption(this, source->ToCreature(), gossipListId); - break; - case GOSSIP_OPTION_SPIRITHEALER: - if (isDead()) - source->ToCreature()->CastSpell(source->ToCreature(), 17251, GetGUID()); - break; - case GOSSIP_OPTION_QUESTGIVER: - PrepareQuestMenu(guid); - SendPreparedQuest(guid); - break; - case GOSSIP_OPTION_VENDOR: - case GOSSIP_OPTION_ARMORER: - GetSession()->SendListInventory(guid, menuItemData->GossipActionMenuId); - break; - case GOSSIP_OPTION_STABLEPET: - GetSession()->SendStablePet(guid); - break; - case GOSSIP_OPTION_TRAINER: - GetSession()->SendTrainerList(source->ToCreature()); - break; - case GOSSIP_OPTION_LEARNDUALSPEC: - if (GetSpecsCount() == 1 && GetLevel() >= CONF_GET_INT("MinDualSpecLevel")) - { - // Cast spells that teach dual spec - // Both are also ImplicitTarget self and must be cast by player - CastSpell(this, 63680, GetGUID()); - CastSpell(this, 63624, GetGUID()); - PrepareGossipMenu(source, menuItemData->GossipActionMenuId); - SendPreparedGossip(source); - } - break; - case GOSSIP_OPTION_UNLEARNTALENTS: - PlayerTalkClass->SendCloseGossip(); - SendTalentWipeConfirm(guid); - break; - case GOSSIP_OPTION_UNLEARNPETTALENTS: - PlayerTalkClass->SendCloseGossip(); - ResetPetTalents(); - break; - case GOSSIP_OPTION_TAXIVENDOR: - GetSession()->SendTaxiMenu(source->ToCreature()); - break; - case GOSSIP_OPTION_INNKEEPER: - PlayerTalkClass->SendCloseGossip(); - SetBindPoint(guid); - break; - case GOSSIP_OPTION_BANKER: - GetSession()->SendShowBank(guid); - break; - case GOSSIP_OPTION_PETITIONER: - PlayerTalkClass->SendCloseGossip(); - GetSession()->SendPetitionShowList(guid); - break; - case GOSSIP_OPTION_TABARDDESIGNER: - PlayerTalkClass->SendCloseGossip(); - GetSession()->SendTabardVendorActivate(guid); - break; - case GOSSIP_OPTION_AUCTIONEER: - GetSession()->SendAuctionHello(guid, source->ToCreature()); - break; - case GOSSIP_OPTION_SPIRITGUIDE: - PrepareGossipMenu(source); - SendPreparedGossip(source); - break; - case GOSSIP_OPTION_BATTLEFIELD: + break; + } + case GOSSIP_OPTION_OUTDOORPVP: + sOutdoorPvPMgr->HandleGossipOption(this, source->ToCreature(), gossipListId); + break; + case GOSSIP_OPTION_SPIRITHEALER: + if (isDead()) + source->ToCreature()->CastSpell(source->ToCreature(), 17251, GetGUID()); + break; + case GOSSIP_OPTION_QUESTGIVER: + PrepareQuestMenu(guid); + SendPreparedQuest(guid); + break; + case GOSSIP_OPTION_VENDOR: + case GOSSIP_OPTION_ARMORER: + GetSession()->SendListInventory(guid, menuItemData->GossipActionMenuId); + break; + case GOSSIP_OPTION_STABLEPET: + GetSession()->SendStablePet(guid); + break; + case GOSSIP_OPTION_TRAINER: + GetSession()->SendTrainerList(source->ToCreature()); + break; + case GOSSIP_OPTION_LEARNDUALSPEC: + if (GetSpecsCount() == 1 && GetLevel() >= CONF_GET_INT("MinDualSpecLevel")) { - BattlegroundTypeId bgTypeId = sBattlegroundMgr->GetBattleMasterBG(source->GetEntry()); + // Cast spells that teach dual spec + // Both are also ImplicitTarget self and must be cast by player + CastSpell(this, 63680, GetGUID()); + CastSpell(this, 63624, GetGUID()); - if (bgTypeId == BATTLEGROUND_TYPE_NONE) - { - LOG_ERROR("entities.player", "Player '%s' (%s) requested battlegroundlist from an invalid creature (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), source->GetGUID().ToString().c_str()); - return; - } + PrepareGossipMenu(source, menuItemData->GossipActionMenuId); + SendPreparedGossip(source); + } + break; + case GOSSIP_OPTION_UNLEARNTALENTS: + PlayerTalkClass->SendCloseGossip(); + SendTalentWipeConfirm(guid); + break; + case GOSSIP_OPTION_UNLEARNPETTALENTS: + PlayerTalkClass->SendCloseGossip(); + ResetPetTalents(); + break; + case GOSSIP_OPTION_TAXIVENDOR: + GetSession()->SendTaxiMenu(source->ToCreature()); + break; + case GOSSIP_OPTION_INNKEEPER: + PlayerTalkClass->SendCloseGossip(); + SetBindPoint(guid); + break; + case GOSSIP_OPTION_BANKER: + GetSession()->SendShowBank(guid); + break; + case GOSSIP_OPTION_PETITIONER: + PlayerTalkClass->SendCloseGossip(); + GetSession()->SendPetitionShowList(guid); + break; + case GOSSIP_OPTION_TABARDDESIGNER: + PlayerTalkClass->SendCloseGossip(); + GetSession()->SendTabardVendorActivate(guid); + break; + case GOSSIP_OPTION_AUCTIONEER: + GetSession()->SendAuctionHello(guid, source->ToCreature()); + break; + case GOSSIP_OPTION_SPIRITGUIDE: + PrepareGossipMenu(source); + SendPreparedGossip(source); + break; + case GOSSIP_OPTION_BATTLEFIELD: + { + BattlegroundTypeId bgTypeId = sBattlegroundMgr->GetBattleMasterBG(source->GetEntry()); - GetSession()->SendBattleGroundList(guid, bgTypeId); - break; + if (bgTypeId == BATTLEGROUND_TYPE_NONE) + { + LOG_ERROR("entities.player", "Player '%s' (%s) requested battlegroundlist from an invalid creature (%s)", + GetName().c_str(), GetGUID().ToString().c_str(), source->GetGUID().ToString().c_str()); + return; } + + GetSession()->SendBattleGroundList(guid, bgTypeId); + break; + } } ModifyMoney(-cost); @@ -14419,12 +14457,12 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject* source) { switch (source->GetTypeId()) { - case TYPEID_UNIT: - return source->ToCreature()->GetCreatureTemplate()->GossipMenuId; - case TYPEID_GAMEOBJECT: - return source->ToGameObject()->GetGOInfo()->GetGossipMenuId(); - default: - break; + case TYPEID_UNIT: + return source->ToCreature()->GetCreatureTemplate()->GossipMenuId; + case TYPEID_GAMEOBJECT: + return source->ToGameObject()->GetGOInfo()->GetGossipMenuId(); + default: + break; } return 0; @@ -14462,7 +14500,7 @@ void Player::PrepareQuestMenu(ObjectGuid guid) return; } - QuestMenu &qm = PlayerTalkClass->GetQuestMenu(); + QuestMenu& qm = PlayerTalkClass->GetQuestMenu(); qm.ClearMenu(); for (uint32 quest_id : objectQIR) @@ -14609,13 +14647,11 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest) const bool Player::CanSeeStartQuest(Quest const* quest) const { if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) && - SatisfyQuestSkill(quest, false) && SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) && - SatisfyQuestDependentQuests(quest, false) && - SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) && - SatisfyQuestMonth(quest, false) && SatisfyQuestSeasonal(quest, false)) - { + SatisfyQuestSkill(quest, false) && SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) && + SatisfyQuestDependentQuests(quest, false) && + SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) && + SatisfyQuestMonth(quest, false) && SatisfyQuestSeasonal(quest, false)) return GetLevel() + CONF_GET_UINT("Quests.HighLevelHideDiff") >= quest->GetMinLevel(); - } return false; } @@ -14623,13 +14659,13 @@ bool Player::CanSeeStartQuest(Quest const* quest) const bool Player::CanTakeQuest(Quest const* quest, bool msg) const { return !DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) - && SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg) - && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) - && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) - && SatisfyQuestDependentQuests(quest, msg) && SatisfyQuestTimed(quest, msg) - && SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg) - && SatisfyQuestMonth(quest, msg) && SatisfyQuestSeasonal(quest, msg) - && SatisfyQuestConditions(quest, msg); + && SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg) + && SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg) + && SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg) + && SatisfyQuestDependentQuests(quest, msg) && SatisfyQuestTimed(quest, msg) + && SatisfyQuestDay(quest, msg) && SatisfyQuestWeek(quest, msg) + && SatisfyQuestMonth(quest, msg) && SatisfyQuestSeasonal(quest, msg) + && SatisfyQuestConditions(quest, msg); } bool Player::CanAddQuest(Quest const* quest, bool msg) const @@ -14675,7 +14711,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) if (itr == m_QuestStatus.end()) return false; - QuestStatusData &q_status = itr->second; + QuestStatusData& q_status = itr->second; if (q_status.Status == QUEST_STATUS_INCOMPLETE) { @@ -14683,7 +14719,7 @@ bool Player::CanCompleteQuest(uint32 quest_id) { for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) { - if (qInfo->RequiredItemCount[i]!= 0 && q_status.ItemCount[i] < qInfo->RequiredItemCount[i]) + if (qInfo->RequiredItemCount[i] != 0 && q_status.ItemCount[i] < qInfo->RequiredItemCount[i]) return false; } } @@ -14772,8 +14808,8 @@ bool Player::CanRewardQuest(Quest const* quest, bool msg) { for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) { - if (quest->RequiredItemCount[i]!= 0 && - GetItemCount(quest->RequiredItemId[i]) < quest->RequiredItemCount[i]) + if (quest->RequiredItemCount[i] != 0 && + GetItemCount(quest->RequiredItemId[i]) < quest->RequiredItemCount[i]) { if (msg) SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr, quest->RequiredItemId[i]); @@ -14801,44 +14837,44 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver) switch (questGiver->GetTypeId()) { - case TYPEID_UNIT: - PlayerTalkClass->ClearMenus(); - questGiver->ToCreature()->AI()->OnQuestAccept(this, quest); - break; - case TYPEID_ITEM: - case TYPEID_CONTAINER: - { - Item* item = static_cast(questGiver); - sScriptMgr->OnQuestAccept(this, item, quest); + case TYPEID_UNIT: + PlayerTalkClass->ClearMenus(); + questGiver->ToCreature()->AI()->OnQuestAccept(this, quest); + break; + case TYPEID_ITEM: + case TYPEID_CONTAINER: + { + Item* item = static_cast(questGiver); + sScriptMgr->OnQuestAccept(this, item, quest); - // There are two cases where the source item is not destroyed when the quest is accepted: - // - It is required to finish the quest, and is an unique item - // - It is the same item present in the source item field (item that would be given on quest accept) - bool destroyItem = true; + // There are two cases where the source item is not destroyed when the quest is accepted: + // - It is required to finish the quest, and is an unique item + // - It is the same item present in the source item field (item that would be given on quest accept) + bool destroyItem = true; - for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + { + if (quest->RequiredItemId[i] == item->GetEntry() && item->GetTemplate()->MaxCount > 0) { - if (quest->RequiredItemId[i] == item->GetEntry() && item->GetTemplate()->MaxCount > 0) - { - destroyItem = false; - break; - } + destroyItem = false; + break; } + } - if (quest->GetSrcItemId() == item->GetEntry()) - destroyItem = false; + if (quest->GetSrcItemId() == item->GetEntry()) + destroyItem = false; - if (destroyItem) - DestroyItem(item->GetBagSlot(), item->GetSlot(), true); + if (destroyItem) + DestroyItem(item->GetBagSlot(), item->GetSlot(), true); - break; - } - case TYPEID_GAMEOBJECT: - PlayerTalkClass->ClearMenus(); - questGiver->ToGameObject()->AI()->OnQuestAccept(this, quest); - break; - default: - break; + break; + } + case TYPEID_GAMEOBJECT: + PlayerTalkClass->ClearMenus(); + questGiver->ToGameObject()->AI()->OnQuestAccept(this, quest); + break; + default: + break; } } @@ -15077,7 +15113,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool rewarded = IsQuestRewarded(quest_id) && !quest->IsDFQuest(); // Not give XP in case already completed once repeatable quest - uint32 XP = rewarded ? 0 : uint32(quest->GetXPReward(this)*CONF_GET_FLOAT("Rate.XP.Quest")); + uint32 XP = rewarded ? 0 : uint32(quest->GetXPReward(this) * CONF_GET_FLOAT("Rate.XP.Quest")); // handle SPELL_AURA_MOD_XP_QUEST_PCT auras XP *= GetTotalAuraMultiplier(SPELL_AURA_MOD_XP_QUEST_PCT); @@ -15283,7 +15319,7 @@ bool Player::SatisfyQuestSkill(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestSkill: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't have the required skill value.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15300,7 +15336,7 @@ bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_QUEST_FAILED_LOW_LEVEL); LOG_DEBUG("misc", "Player::SatisfyQuestLevel: Sent INVALIDREASON_QUEST_FAILED_LOW_LEVEL (QuestID: %u) because player '%s' (%s) doesn't have the required (min) level.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15311,7 +15347,7 @@ bool Player::SatisfyQuestLevel(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); // There doesn't seem to be a specific response for too high player level LOG_DEBUG("misc", "Player::SatisfyQuestLevel: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't have the required (max) level.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15359,7 +15395,7 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestPreviousQuest: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't have required quest %u.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str(), prevId); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str(), prevId); } return false; @@ -15401,7 +15437,7 @@ bool Player::SatisfyQuestDependentPreviousQuests(Quest const* qInfo, bool msg) c { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestDependentPreviousQuests: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't have the required quest (1).", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15417,7 +15453,7 @@ bool Player::SatisfyQuestDependentPreviousQuests(Quest const* qInfo, bool msg) c { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestDependentPreviousQuests: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't have required quest (2).", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15438,7 +15474,7 @@ bool Player::SatisfyQuestBreadcrumbQuest(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestBreadcrumbQuest: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because target quest (QuestID: %u) is not available to player '%s' (%s).", - qInfo->GetQuestId(), breadcrumbTargetQuestId, GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), breadcrumbTargetQuestId, GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15459,7 +15495,7 @@ bool Player::SatisfyQuestDependentBreadcrumbQuests(Quest const* qInfo, bool msg) { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestDependentBreadcrumbQuests: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) has a breadcrumb quest towards this quest in the quest log.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15481,7 +15517,7 @@ bool Player::SatisfyQuestClass(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestClass: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't have required class.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15501,7 +15537,7 @@ bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_QUEST_FAILED_WRONG_RACE); LOG_DEBUG("misc", "Player::SatisfyQuestRace: Sent INVALIDREASON_QUEST_FAILED_WRONG_RACE (QuestID: %u) because player '%s' (%s) doesn't have required race.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15518,7 +15554,7 @@ bool Player::SatisfyQuestReputation(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestReputation: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't required reputation (min).", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15530,7 +15566,7 @@ bool Player::SatisfyQuestReputation(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "SatisfyQuestReputation: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't required reputation (max).", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15559,7 +15595,7 @@ bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_QUEST_ALREADY_DONE); LOG_DEBUG("misc", "Player::SatisfyQuestStatus: Sent QUEST_STATUS_REWARDED (QuestID: %u) because player '%s' (%s) quest status is already REWARDED.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15570,7 +15606,7 @@ bool Player::SatisfyQuestStatus(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_QUEST_ALREADY_ON); LOG_DEBUG("misc", "Player::SatisfyQuestStatus: Sent INVALIDREASON_QUEST_ALREADY_ON (QuestID: %u) because player '%s' (%s) quest status is not NONE.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15585,7 +15621,7 @@ bool Player::SatisfyQuestConditions(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestConditions: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) doesn't meet conditions.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } LOG_DEBUG("condition", "Player::SatisfyQuestConditions: conditions not met for quest %u", qInfo->GetQuestId()); return false; @@ -15601,7 +15637,7 @@ bool Player::SatisfyQuestTimed(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_QUEST_ONLY_ONE_TIMED); LOG_DEBUG("misc", "Player::SatisfyQuestTimed: Sent INVALIDREASON_QUEST_ONLY_ONE_TIMED (QuestID: %u) because player '%s' (%s) is already on a timed quest.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15632,7 +15668,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestExclusiveGroup: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) already did daily quests in exclusive group.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; @@ -15645,7 +15681,7 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const { SendCanTakeQuestResponse(INVALIDREASON_DONT_HAVE_REQ); LOG_DEBUG("misc", "Player::SatisfyQuestExclusiveGroup: Sent INVALIDREASON_DONT_HAVE_REQ (QuestID: %u) because player '%s' (%s) already did quest in exclusive group.", - qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); + qInfo->GetQuestId(), GetName().c_str(), GetGUID().ToString().c_str()); } return false; } @@ -15669,7 +15705,7 @@ bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) const bool have_slot = false; for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { - uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx); + uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx); if (qInfo->GetQuestId() == id) return false; @@ -15951,28 +15987,28 @@ QuestGiverStatus Player::GetQuestDialogStatus(Object* questgiver) switch (questgiver->GetTypeId()) { - case TYPEID_GAMEOBJECT: - { - if (auto ai = questgiver->ToGameObject()->AI()) - if (auto questStatus = ai->GetDialogStatus(this)) - return *questStatus; - qr = sObjectMgr->GetGOQuestRelations(questgiver->GetEntry()); - qir = sObjectMgr->GetGOQuestInvolvedRelations(questgiver->GetEntry()); - break; - } - case TYPEID_UNIT: - { - if (auto ai = questgiver->ToCreature()->AI()) - if (auto questStatus = ai->GetDialogStatus(this)) - return *questStatus; - qr = sObjectMgr->GetCreatureQuestRelations(questgiver->GetEntry()); - qir = sObjectMgr->GetCreatureQuestInvolvedRelations(questgiver->GetEntry()); - break; - } - default: - // it's impossible, but check - LOG_ERROR("entities.player.quest", "GetQuestDialogStatus called for unexpected type %u", questgiver->GetTypeId()); - return DIALOG_STATUS_NONE; + case TYPEID_GAMEOBJECT: + { + if (auto ai = questgiver->ToGameObject()->AI()) + if (auto questStatus = ai->GetDialogStatus(this)) + return *questStatus; + qr = sObjectMgr->GetGOQuestRelations(questgiver->GetEntry()); + qir = sObjectMgr->GetGOQuestInvolvedRelations(questgiver->GetEntry()); + break; + } + case TYPEID_UNIT: + { + if (auto ai = questgiver->ToCreature()->AI()) + if (auto questStatus = ai->GetDialogStatus(this)) + return *questStatus; + qr = sObjectMgr->GetCreatureQuestRelations(questgiver->GetEntry()); + qir = sObjectMgr->GetCreatureQuestInvolvedRelations(questgiver->GetEntry()); + break; + } + default: + // it's impossible, but check + LOG_ERROR("entities.player.quest", "GetQuestDialogStatus called for unexpected type %u", questgiver->GetTypeId()); + return DIALOG_STATUS_NONE; } QuestGiverStatus result = DIALOG_STATUS_NONE; @@ -16497,7 +16533,7 @@ void Player::TalkedToCreature(uint32 entry, ObjectGuid guid) uint32 reqTarget = 0; if (qInfo->RequiredNpcOrGo[j] > 0) // creature activate objectives - // checked at quest_template loading + // checked at quest_template loading reqTarget = qInfo->RequiredNpcOrGo[j]; else continue; @@ -16661,7 +16697,8 @@ bool Player::HasQuestForItem(uint32 itemid, uint32 excludeQuestId /* 0 */, bool { if (ownedCount < qinfo->ItemDropQuantity[j] || turnIn ) return true; - } else if (ownedCount < pProto->GetMaxStackSize()) + } + else if (ownedCount < pProto->GetMaxStackSize()) return true; } } @@ -16684,7 +16721,7 @@ void Player::SendQuestReward(Quest const* quest, uint32 XP) const { uint32 questid = quest->GetQuestId(); sGameEventMgr->HandleQuestComplete(questid); - WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4)); + WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4 + 4 + 4 + 4 + 4)); data << uint32(questid); if (!IsMaxLevel()) @@ -16780,7 +16817,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, // client expected gameobject template id in form (id|0x80000000) entry = (-entry) | 0x80000000; - WorldPacket data(SMSG_QUESTUPDATE_ADD_KILL, (4*4+8)); + WorldPacket data(SMSG_QUESTUPDATE_ADD_KILL, (4 * 4 + 8)); LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTUPDATE_ADD_KILL"); data << uint32(quest->GetQuestId()); data << uint32(entry); @@ -16800,7 +16837,7 @@ void Player::SendQuestUpdateAddPlayer(Quest const* quest, uint16 old_count, uint { ASSERT(old_count + add_count < 65536 && "player count store in 16 bits"); - WorldPacket data(SMSG_QUESTUPDATE_ADD_PVP_KILL, (3*4)); + WorldPacket data(SMSG_QUESTUPDATE_ADD_PVP_KILL, (3 * 4)); data << uint32(quest->GetQuestId()); data << uint32(old_count + add_count); data << uint32(quest->GetPlayersSlain()); @@ -16927,14 +16964,11 @@ void Player::_LoadArenaTeamInfo(PreparedQueryResult result) SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_GAMES_WEEK, uint32(fields[1].GetUInt16())); SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_GAMES_SEASON, uint32(fields[2].GetUInt16())); SetArenaTeamInfoField(arenaSlot, ARENA_TEAM_WINS_SEASON, uint32(fields[3].GetUInt16())); - } - while (result->NextRow()); + } while (result->NextRow()); } for (uint8 slot = 0; slot <= 2; ++slot) - { SetArenaTeamInfoField(slot, ARENA_TEAM_PERSONAL_RATING, uint32(personalRatingCache[slot])); - } } void Player::_LoadEquipmentSets(PreparedQueryResult result) @@ -17085,7 +17119,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol // check name limitations if (ObjectMgr::CheckPlayerName(m_name, GetSession()->GetSessionDbcLocale()) != CHAR_NAME_SUCCESS || - (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(m_name))) + (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(m_name))) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RENAME)); @@ -17147,9 +17181,9 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_INEBRIATION, fields[54].GetUInt8()); if (!ValidateAppearance( - fields[3].GetUInt8(), // race - fields[4].GetUInt8(), // class - gender, GetHairStyleId(), GetHairColorId(), GetFaceId(), GetFacialStyle(), GetSkinId())) + fields[3].GetUInt8(), // race + fields[4].GetUInt8(), // class + gender, GetHairStyleId(), GetHairColorId(), GetFaceId(), GetFacialStyle(), GetSkinId())) { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player (%s) has wrong Appearance values (Hair/Skin/Color), can't load.", guid.ToString().c_str()); return false; @@ -17251,7 +17285,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (!mapEntry || !IsPositionValid()) { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player (%s) has invalid coordinates (MapId: %u X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", - guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); RelocateToHomebind(); } // Player was saved in Arena or Bg @@ -17297,7 +17331,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (int16(mapId) == int16(-1)) // Battleground Entry Point not found (???) { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player (%s) was in BG in database, but BG was not found and entry point was invalid! Teleport to default race/class locations.", - guid.ToString().c_str()); + guid.ToString().c_str()); RelocateToHomebind(); } else @@ -17323,13 +17357,13 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol transport->CalculatePassengerPosition(x, y, z, &o); if (!Warhead::IsValidMapCoord(x, y, z, o) || - // transport size limited - std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f || - std::fabs(m_movementInfo.transport.pos.GetPositionY()) > 250.0f || - std::fabs(m_movementInfo.transport.pos.GetPositionZ()) > 250.0f) + // transport size limited + std::fabs(m_movementInfo.transport.pos.GetPositionX()) > 250.0f || + std::fabs(m_movementInfo.transport.pos.GetPositionY()) > 250.0f || + std::fabs(m_movementInfo.transport.pos.GetPositionZ()) > 250.0f) { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player (%s) has invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to bind location.", - guid.ToString().c_str(), x, y, z, o); + guid.ToString().c_str(), x, y, z, o); m_movementInfo.transport.Reset(); @@ -17346,7 +17380,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol else { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player (%s) has problems with transport guid (%u). Teleport to bind location.", - guid.ToString().c_str(), transLowGUID); + guid.ToString().c_str(), transLowGUID); RelocateToHomebind(); } @@ -17406,7 +17440,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (GetSession()->Expansion() < mapEntry->Expansion()) { LOG_DEBUG("entities.player.loading", "Player::LoadFromDB: Player '%s' (%s) using client without required expansion tried login at non accessible map %u", - GetName().c_str(), GetGUID().ToString().c_str(), mapId); + GetName().c_str(), GetGUID().ToString().c_str(), mapId); RelocateToHomebind(); } @@ -17435,23 +17469,23 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol { switch (denyReason) { - case Map::CANNOT_ENTER_DIFFICULTY_UNAVAILABLE: - SendTransferAborted(map->GetId(), TRANSFER_ABORT_DIFFICULTY, map->GetDifficulty()); - break; - case Map::CANNOT_ENTER_INSTANCE_BIND_MISMATCH: - ChatHandler(GetSession()).PSendSysMessage(GetSession()->GetWarheadString(LANG_INSTANCE_BIND_MISMATCH), map->GetMapName()); - break; - case Map::CANNOT_ENTER_TOO_MANY_INSTANCES: - SendTransferAborted(map->GetId(), TRANSFER_ABORT_TOO_MANY_INSTANCES); - break; - case Map::CANNOT_ENTER_MAX_PLAYERS: - SendTransferAborted(map->GetId(), TRANSFER_ABORT_MAX_PLAYERS); - break; - case Map::CANNOT_ENTER_ZONE_IN_COMBAT: - SendTransferAborted(map->GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); - break; - default: - break; + case Map::CANNOT_ENTER_DIFFICULTY_UNAVAILABLE: + SendTransferAborted(map->GetId(), TRANSFER_ABORT_DIFFICULTY, map->GetDifficulty()); + break; + case Map::CANNOT_ENTER_INSTANCE_BIND_MISMATCH: + ChatHandler(GetSession()).PSendSysMessage(GetSession()->GetWarheadString(LANG_INSTANCE_BIND_MISMATCH), map->GetMapName()); + break; + case Map::CANNOT_ENTER_TOO_MANY_INSTANCES: + SendTransferAborted(map->GetId(), TRANSFER_ABORT_TOO_MANY_INSTANCES); + break; + case Map::CANNOT_ENTER_MAX_PLAYERS: + SendTransferAborted(map->GetId(), TRANSFER_ABORT_MAX_PLAYERS); + break; + case Map::CANNOT_ENTER_ZONE_IN_COMBAT: + SendTransferAborted(map->GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); + break; + default: + break; } areaTrigger = sObjectMgr->GetGoBackTrigger(mapId); check = true; @@ -17477,7 +17511,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol else { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player '%s' (%s) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.", - m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); RelocateToHomebind(); map = nullptr; } @@ -17491,7 +17525,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (!map) { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player '%s' (%s) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Invalid default map coordinates or instance couldn't be created.", - m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); return false; } } @@ -17599,10 +17633,10 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol //speed collect rest bonus in offline, in logout, in tavern, city (section/in hour) float bubble1 = 0.125f; float bubble = fields[28].GetUInt8() > 0 - ? bubble1*CONF_GET_FLOAT("Rate.Rest.Offline.InTavernOrCity") - : bubble0*CONF_GET_FLOAT("Rate.Rest.Offline.InWilderness"); + ? bubble1 * CONF_GET_FLOAT("Rate.Rest.Offline.InTavernOrCity") + : bubble0 * CONF_GET_FLOAT("Rate.Rest.Offline.InWilderness"); - SetRestBonus(GetRestBonus() + time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 72000)*bubble); + SetRestBonus(GetRestBonus() + time_diff * ((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 72000)*bubble); } // load skills after InitStatsForLevel because it triggering aura apply also @@ -17621,7 +17655,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol if (m_specsCount > MAX_TALENT_SPECS || m_activeSpec > MAX_TALENT_SPEC || m_specsCount < MIN_TALENT_SPECS) { LOG_ERROR("entities.player.loading", "Player::LoadFromDB: Player %s (%s) has invalid SpecCount = %u and/or invalid ActiveSpec = %u.", - GetName().c_str(), GetGUID().ToString().c_str(), uint32(m_specsCount), uint32(m_activeSpec)); + GetName().c_str(), GetGUID().ToString().c_str(), uint32(m_specsCount), uint32(m_activeSpec)); m_activeSpec = 0; } @@ -17706,46 +17740,58 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol { switch (CONF_GET_INT("GM.LoginState")) { - default: - case 0: break; // disable - case 1: SetGameMaster(true); break; // enable - case 2: // save state - if (extraflags & PLAYER_EXTRA_GM_ON) - SetGameMaster(true); - break; + default: + case 0: + break; // disable + case 1: + SetGameMaster(true); + break; // enable + case 2: // save state + if (extraflags & PLAYER_EXTRA_GM_ON) + SetGameMaster(true); + break; } switch (CONF_GET_INT("GM.Visible")) { - default: - case 0: SetGMVisible(false); break; // invisible - case 1: break; // visible - case 2: // save state - if (extraflags & PLAYER_EXTRA_GM_INVISIBLE) - SetGMVisible(false); - break; + default: + case 0: + SetGMVisible(false); + break; // invisible + case 1: + break; // visible + case 2: // save state + if (extraflags & PLAYER_EXTRA_GM_INVISIBLE) + SetGMVisible(false); + break; } switch (CONF_GET_INT("GM.Chat")) { - default: - case 0: break; // disable - case 1: SetGMChat(true); break; // enable - case 2: // save state - if (extraflags & PLAYER_EXTRA_GM_CHAT) - SetGMChat(true); - break; + default: + case 0: + break; // disable + case 1: + SetGMChat(true); + break; // enable + case 2: // save state + if (extraflags & PLAYER_EXTRA_GM_CHAT) + SetGMChat(true); + break; } switch (CONF_GET_INT("GM.WhisperingTo")) { - default: - case 0: break; // disable - case 1: SetAcceptWhispers(true); break; // enable - case 2: // save state - if (extraflags & PLAYER_EXTRA_ACCEPT_WHISPERS) - SetAcceptWhispers(true); - break; + default: + case 0: + break; // disable + case 1: + SetAcceptWhispers(true); + break; // enable + case 2: // save state + if (extraflags & PLAYER_EXTRA_ACCEPT_WHISPERS) + SetAcceptWhispers(true); + break; } } @@ -17796,28 +17842,28 @@ bool Player::isAllowedToLoot(Creature const* creature) switch (thisGroup->GetLootMethod()) { - case MASTER_LOOT: - case FREE_FOR_ALL: + case MASTER_LOOT: + case FREE_FOR_ALL: + return true; + case ROUND_ROBIN: + // may only loot if the player is the loot roundrobin player + // or if there are free/quest/conditional item for the player + if (loot->roundRobinPlayer.IsEmpty() || loot->roundRobinPlayer == GetGUID()) return true; - case ROUND_ROBIN: - // may only loot if the player is the loot roundrobin player - // or if there are free/quest/conditional item for the player - if (loot->roundRobinPlayer.IsEmpty() || loot->roundRobinPlayer == GetGUID()) - return true; - return loot->hasItemFor(this); - case GROUP_LOOT: - case NEED_BEFORE_GREED: - // may only loot if the player is the loot roundrobin player - // or item over threshold (so roll(s) can be launched) - // or if there are free/quest/conditional item for the player - if (loot->roundRobinPlayer.IsEmpty() || loot->roundRobinPlayer == GetGUID()) - return true; + return loot->hasItemFor(this); + case GROUP_LOOT: + case NEED_BEFORE_GREED: + // may only loot if the player is the loot roundrobin player + // or item over threshold (so roll(s) can be launched) + // or if there are free/quest/conditional item for the player + if (loot->roundRobinPlayer.IsEmpty() || loot->roundRobinPlayer == GetGUID()) + return true; - if (loot->hasOverThresholdItem()) - return true; + if (loot->hasOverThresholdItem()) + return true; - return loot->hasItemFor(this); + return loot->hasItemFor(this); } return false; @@ -17840,8 +17886,9 @@ void Player::_LoadActions(PreparedQueryResult result) ab->uState = ACTIONBUTTON_UNCHANGED; else { - LOG_DEBUG("entities.player", "Player::_LoadActions: Player '%s' (%s) has an invalid action button (Button: %u, Action: %u, Type: %u). It will be deleted at next save. This can be due to a player changing their talents.", - GetName().c_str(), GetGUID().ToString().c_str(), button, action, type); + LOG_DEBUG("entities.player", + "Player::_LoadActions: Player '%s' (%s) has an invalid action button (Button: %u, Action: %u, Type: %u). It will be deleted at next save. This can be due to a player changing their talents.", + GetName().c_str(), GetGUID().ToString().c_str(), button, action, type); // Will be deleted in DB at next save (it can create data until save but marked as deleted). m_actionButtons[button].uState = ACTIONBUTTON_DELETED; @@ -17889,19 +17936,20 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) if (!spellInfo) { LOG_ERROR("entities.player", "Player::_LoadAuras: Player '%s' (%s) has an invalid aura (SpellID: %u), ignoring.", - GetName().c_str(), GetGUID().ToString().c_str(), spellid); + GetName().c_str(), GetGUID().ToString().c_str(), spellid); continue; } ChrRacesEntry const* raceEntry = sChrRacesStore.AssertEntry(GetRace()); // negative effects should continue counting down after logout - if (remaintime != -1 && ((!spellInfo->IsPositive() && spellInfo->Id != raceEntry->ResSicknessSpellID) || spellInfo->HasAttribute(SPELL_ATTR4_FADES_WHILE_LOGGED_OUT))) // Resurrection sickness should not fade while logged out + if (remaintime != -1 && ((!spellInfo->IsPositive() && spellInfo->Id != raceEntry->ResSicknessSpellID) + || spellInfo->HasAttribute(SPELL_ATTR4_FADES_WHILE_LOGGED_OUT))) // Resurrection sickness should not fade while logged out { - if (remaintime/IN_MILLISECONDS <= int32(timediff)) + if (remaintime / IN_MILLISECONDS <= int32(timediff)) continue; - remaintime -= timediff*IN_MILLISECONDS; + remaintime -= timediff * IN_MILLISECONDS; } // prevent wrong values of remaincharges @@ -17917,9 +17965,9 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) AuraCreateInfo createInfo(spellInfo, effmask, this); createInfo - .SetCasterGUID(caster_guid) - .SetCastItemGUID(itemGuid) - .SetBaseAmount(baseDamage); + .SetCasterGUID(caster_guid) + .SetCastItemGUID(itemGuid) + .SetBaseAmount(baseDamage); if (Aura* aura = Aura::TryCreate(createInfo)) { @@ -17932,10 +17980,9 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, critChance, applyResilience, &damage[0]); aura->ApplyForTargets(); LOG_DEBUG("entities.player", "Player::_LoadAuras: Added aura (SpellID: %u, EffectMask: %u) to player '%s (%s)", - spellInfo->Id, effmask, GetName().c_str(), GetGUID().ToString().c_str()); + spellInfo->Id, effmask, GetName().c_str(), GetGUID().ToString().c_str()); } - } - while (result->NextRow()); + } while (result->NextRow()); } } @@ -17955,7 +18002,8 @@ void Player::_LoadGlyphAuras() continue; } else - LOG_ERROR("entities.player", "Player::_LoadGlyphAuras: Player '%s' (%s) has glyph with typeflags %u in slot with typeflags %u, removing.", GetName().c_str(), GetGUID().ToString().c_str(), gp->GlyphSlotFlags, gs->Type); + LOG_ERROR("entities.player", "Player::_LoadGlyphAuras: Player '%s' (%s) has glyph with typeflags %u in slot with typeflags %u, removing.", GetName().c_str(), GetGUID().ToString().c_str(), + gp->GlyphSlotFlags, gs->Type); } else LOG_ERROR("entities.player", "Player::_LoadGlyphAuras: Player '%s' (%s) has not existing glyph slot entry %u on index %u", GetName().c_str(), GetGUID().ToString().c_str(), GetGlyphSlot(i), i); @@ -18052,10 +18100,9 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) if (Bag* pBag = item->ToBag()) bagMap[item->GetGUID().GetCounter()] = pBag; } - else - if (IsBagPos(item->GetPos())) - if (item->IsBag()) - invalidBagMap[item->GetGUID().GetCounter()] = item; + else if (IsBagPos(item->GetPos())) + if (item->IsBag()) + invalidBagMap[item->GetGUID().GetCounter()] = item; } else { @@ -18078,7 +18125,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) else { LOG_ERROR("entities.player", "Player::_LoadInventory: Player '%s' (%s) has item (%s, entry: %u) which doesnt have a valid bag (Bag %u, slot: %u). Possible cheat?", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot); item->DeleteFromInventoryDB(trans); delete item; continue; @@ -18092,7 +18139,7 @@ void Player::_LoadInventory(PreparedQueryResult result, uint32 timeDiff) else { LOG_ERROR("entities.player", "Player::_LoadInventory: Player '%s' (%s) has item (%s, entry: %u) which can't be loaded into inventory (Bag %u, slot: %u) by reason %u. Item will be sent by mail.", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot, uint32(err)); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), item->GetEntry(), bagGuid, slot, uint32(err)); item->DeleteFromInventoryDB(trans); problematicItems.push_back(item); } @@ -18138,14 +18185,14 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3 if (IsAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zoneId)) { LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s', map: %u) has item (%s) limited to another map (%u). Deleting item.", - GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), item->GetGUID().ToString().c_str(), zoneId); + GetGUID().ToString().c_str(), GetName().c_str(), GetMapId(), item->GetGUID().ToString().c_str(), zoneId); remove = true; } // "Conjured items disappear if you are logged out for more than 15 minutes" else if (timeDiff > 15 * MINUTE && proto->HasFlag(ITEM_FLAG_CONJURED)) { LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s', diff: %u) has conjured item (%s) with expired lifetime (15 minutes). Deleting item.", - GetGUID().ToString().c_str(), GetName().c_str(), timeDiff, item->GetGUID().ToString().c_str()); + GetGUID().ToString().c_str(), GetName().c_str(), timeDiff, item->GetGUID().ToString().c_str()); remove = true; } else if (item->IsRefundable()) @@ -18153,7 +18200,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3 if (item->GetPlayedTime() > (2 * HOUR)) { LOG_DEBUG("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s') has item (%s) with expired refund time (%u). Deleting refund data and removing refundable flag.", - GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetPlayedTime()); + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetPlayedTime()); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE); stmt->setUInt32(0, item->GetGUID().GetCounter()); @@ -18176,7 +18223,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3 else { LOG_WARN("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s') has item (%s) with refundable flags, but without data in item_refund_instance. Removing flag.", - GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str()); + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str()); item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_REFUNDABLE); } } @@ -18207,7 +18254,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3 else { LOG_WARN("entities.player.loading", "Player::_LoadInventory: player (%s, name: '%s') has item (%s) with ITEM_FLAG_BOP_TRADEABLE flag, but without data in item_soulbound_trade_data. Removing flag.", - GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str()); + GetGUID().ToString().c_str(), GetName().c_str(), item->GetGUID().ToString().c_str()); item->RemoveFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE); } } @@ -18229,7 +18276,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3 else { LOG_ERROR("entities.player", "Player::_LoadInventory: player (%s, name: '%s') has a broken item (GUID: %u, entry: %u) in inventory. Deleting item.", - GetGUID().ToString().c_str(), GetName().c_str(), itemGuid, itemEntry); + GetGUID().ToString().c_str(), GetName().c_str(), itemGuid, itemEntry); remove = true; } // Remove item from inventory if necessary @@ -18244,7 +18291,7 @@ Item* Player::_LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint3 else { LOG_ERROR("entities.player", "Player::_LoadInventory: player (%s, name: '%s') has an unknown item (entry: %u) in inventory. Deleting item.", - GetGUID().ToString().c_str(), GetName().c_str(), itemEntry); + GetGUID().ToString().c_str(), GetName().c_str(), itemEntry); Item::DeleteFromInventoryDB(trans, itemGuid); Item::DeleteFromDB(trans, itemGuid); } @@ -18279,7 +18326,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) Field* fields = result->Fetch(); uint32 quest_id = fields[0].GetUInt32(); - // used to be new, no delete? + // used to be new, no delete? Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id); if (quest) { @@ -18293,7 +18340,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) { questStatusData.Status = QUEST_STATUS_INCOMPLETE; LOG_ERROR("entities.player", "Player::_LoadQuestStatus: Player '%s' (%s) has invalid quest %d status (%u), replaced by QUEST_STATUS_INCOMPLETE(3).", - GetName().c_str(), GetGUID().ToString().c_str(), quest_id, qstatus); + GetName().c_str(), GetGUID().ToString().c_str(), quest_id, qstatus); } questStatusData.Explored = (fields[2].GetUInt8() > 0); @@ -18342,8 +18389,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) LOG_DEBUG("entities.player.loading", "Player::_LoadQuestStatus: Quest status is {%u} for quest {%u} for player (%s)", questStatusData.Status, quest_id, GetGUID().ToString().c_str()); } - } - while (result->NextRow()); + } while (result->NextRow()); } // clear quest log tail @@ -18362,7 +18408,7 @@ void Player::_LoadQuestStatusRewarded(PreparedQueryResult result) Field* fields = result->Fetch(); uint32 quest_id = fields[0].GetUInt32(); - // used to be new, no delete? + // used to be new, no delete? Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id); if (quest) { @@ -18382,15 +18428,14 @@ void Player::_LoadQuestStatusRewarded(PreparedQueryResult result) if (quest->CanIncreaseRewardedQuestCounters()) m_RewardedQuests.insert(quest_id); } - } - while (result->NextRow()); + } while (result->NextRow()); } } void Player::_LoadDailyQuestStatus(PreparedQueryResult result) { for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx, 0); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, 0); m_DFQuests.clear(); @@ -18428,13 +18473,12 @@ void Player::_LoadDailyQuestStatus(PreparedQueryResult result) if (!quest) continue; - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx, quest_id); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, quest_id); ++quest_daily_idx; LOG_DEBUG("entities.player.loading", "Player::_LoadDailyQuestStatus: Loaded daily quest cooldown (QuestID: %u) for player '%s' (%s)", - quest_id, GetName().c_str(), GetGUID().ToString().c_str()); - } - while (result->NextRow()); + quest_id, GetName().c_str(), GetGUID().ToString().c_str()); + } while (result->NextRow()); } m_DailyQuestChanged = false; @@ -18457,9 +18501,8 @@ void Player::_LoadWeeklyQuestStatus(PreparedQueryResult result) m_weeklyquests.insert(quest_id); LOG_DEBUG("entities.player.loading", "Player::_LoadWeeklyQuestStatus: Loaded weekly quest cooldown (QuestID: %u) for player '%s' (%s)", - quest_id, GetName().c_str(), GetGUID().ToString().c_str()); - } - while (result->NextRow()); + quest_id, GetName().c_str(), GetGUID().ToString().c_str()); + } while (result->NextRow()); } m_WeeklyQuestChanged = false; @@ -18482,9 +18525,8 @@ void Player::_LoadSeasonalQuestStatus(PreparedQueryResult result) m_seasonalquests[event_id].insert(quest_id); LOG_DEBUG("entities.player.loading", "Player::_LoadSeasonalQuestStatus: Loaded seasonal quest cooldown (QuestID: %u) for player '%s' (%s)", - quest_id, GetName().c_str(), GetGUID().ToString().c_str()); - } - while (result->NextRow()); + quest_id, GetName().c_str(), GetGUID().ToString().c_str()); + } while (result->NextRow()); } m_SeasonalQuestChanged = false; @@ -18506,9 +18548,8 @@ void Player::_LoadMonthlyQuestStatus(PreparedQueryResult result) m_monthlyquests.insert(quest_id); LOG_DEBUG("entities.player.loading", "Player::_LoadMonthlyQuestStatus: Loaded monthly quest cooldown (QuestID: %u) for player '%s' (%s)", - quest_id, GetName().c_str(), GetGUID().ToString().c_str()); - } - while (result->NextRow()); + quest_id, GetName().c_str(), GetGUID().ToString().c_str()); + } while (result->NextRow()); } m_MonthlyQuestChanged = false; @@ -18583,13 +18624,13 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) if (!mapEntry || !mapEntry->IsDungeon()) { LOG_ERROR("entities.player", "Player::_LoadBoundInstances: Player '%s' (%s) has bind to not existed or not dungeon map %d (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), mapId, mapname.c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), mapId, mapname.c_str()); deleteInstance = true; } else if (difficulty >= MAX_DIFFICULTY) { LOG_ERROR("entities.player", "Player::_LoadBoundInstances: player '%s' (%s) has bind to not existed difficulty %d instance for map %u (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), difficulty, mapId, mapname.c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), difficulty, mapId, mapname.c_str()); deleteInstance = true; } else @@ -18598,13 +18639,13 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) if (!mapDiff) { LOG_ERROR("entities.player", "Player::_LoadBoundInstances: player '%s' (%s) has bind to not existed difficulty %d instance for map %u (%s)", - GetName().c_str(), GetGUID().ToString().c_str(), difficulty, mapId, mapname.c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), difficulty, mapId, mapname.c_str()); deleteInstance = true; } else if (!perm && group) { LOG_ERROR("entities.player", "Player::_LoadBoundInstances: player '%s' (%s) is in group %s but has a non-permanent character bind to map %d (%s), %d, %d", - GetName().c_str(), GetGUID().ToString().c_str(), group->GetGUID().ToString().c_str(), mapId, mapname.c_str(), instanceId, difficulty); + GetName().c_str(), GetGUID().ToString().c_str(), group->GetGUID().ToString().c_str(), mapId, mapname.c_str(), instanceId, difficulty); deleteInstance = true; } } @@ -18623,9 +18664,8 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) // since non permanent binds are always solo bind, they can always be reset if (InstanceSave* save = sInstanceSaveMgr->AddInstanceSave(mapId, instanceId, Difficulty(difficulty), resetTime, !perm, true)) - BindToInstance(save, perm, extendState, true); - } - while (result->NextRow()); + BindToInstance(save, perm, extendState, true); + } while (result->NextRow()); } } @@ -18661,7 +18701,7 @@ void Player::UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload) UnbindInstance(itr, difficulty, unload); } -void Player::UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload) +void Player::UnbindInstance(BoundInstancesMap::iterator& itr, Difficulty difficulty, bool unload) { if (itr != m_boundInstances[difficulty].end()) { @@ -18741,7 +18781,7 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave* save, bool permanent, B bind.extendState = extendState; if (!load) LOG_DEBUG("maps", "Player::BindToInstance: Player '%s' (%s) is now bound to map (ID: %d, Instance: %d, Difficulty: %d)", - GetName().c_str(), GetGUID().ToString().c_str(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + GetName().c_str(), GetGUID().ToString().c_str(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); sScriptMgr->OnPlayerBindToInstance(this, save->GetDifficulty(), save->GetMapId(), permanent, extendState); return &bind; } @@ -18872,7 +18912,7 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report if (ar->item) { if (!HasItemCount(ar->item) && - (!ar->item2 || !HasItemCount(ar->item2))) + (!ar->item2 || !HasItemCount(ar->item2))) missingItem = ar->item; } else if (ar->item2 && !HasItemCount(ar->item2)) @@ -19004,7 +19044,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) if (!info) { LOG_ERROR("entities.player", "Player::_LoadHomeBind: Player '%s' (%s) has incorrect race/class (%u/%u) pair. Can't load.", - GetGUID().ToString().c_str(), GetName().c_str(), uint32(GetRace()), uint32(GetClass())); + GetGUID().ToString().c_str(), GetName().c_str(), uint32(GetRace()), uint32(GetClass())); return false; } @@ -19024,7 +19064,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) // accept saved data only for valid position (and non instanceable), and accessable if (MapManager::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ) && - !bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion()) + !bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion()) ok = true; else { @@ -19053,7 +19093,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result) } LOG_DEBUG("entities.player", "Player::_LoadHomeBind: Setting home position (MapID: %u, AreaID: %u, X: %f, Y: %f, Z: %f) of player '%s' (%s)", - m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetName().c_str(), GetGUID().ToString().c_str()); + m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetName().c_str(), GetGUID().ToString().c_str()); return true; } @@ -19207,7 +19247,7 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID)); ss.str(""); - for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) + for (uint32 i = 0; i < KNOWN_TITLES_SIZE * 2; ++i) ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' '; stmt->setString(index++, ss.str()); @@ -19332,7 +19372,7 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false stmt->setUInt32(index++, GetUInt32Value(PLAYER_AMMO_ID)); ss.str(""); - for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) + for (uint32 i = 0; i < KNOWN_TITLES_SIZE * 2; ++i) ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << ' '; stmt->setString(index++, ss.str()); @@ -19408,42 +19448,42 @@ void Player::_SaveActions(CharacterDatabaseTransaction trans) { switch (itr->second.uState) { - case ACTIONBUTTON_NEW: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACTION); - stmt->setUInt32(0, GetGUID().GetCounter()); - stmt->setUInt8(1, m_activeSpec); - stmt->setUInt8(2, itr->first); - stmt->setUInt32(3, itr->second.GetAction()); - stmt->setUInt8(4, uint8(itr->second.GetType())); - trans->Append(stmt); + case ACTIONBUTTON_NEW: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACTION); + stmt->setUInt32(0, GetGUID().GetCounter()); + stmt->setUInt8(1, m_activeSpec); + stmt->setUInt8(2, itr->first); + stmt->setUInt32(3, itr->second.GetAction()); + stmt->setUInt8(4, uint8(itr->second.GetType())); + trans->Append(stmt); - itr->second.uState = ACTIONBUTTON_UNCHANGED; - ++itr; - break; - case ACTIONBUTTON_CHANGED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACTION); - stmt->setUInt32(0, itr->second.GetAction()); - stmt->setUInt8(1, uint8(itr->second.GetType())); - stmt->setUInt32(2, GetGUID().GetCounter()); - stmt->setUInt8(3, itr->first); - stmt->setUInt8(4, m_activeSpec); - trans->Append(stmt); + itr->second.uState = ACTIONBUTTON_UNCHANGED; + ++itr; + break; + case ACTIONBUTTON_CHANGED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACTION); + stmt->setUInt32(0, itr->second.GetAction()); + stmt->setUInt8(1, uint8(itr->second.GetType())); + stmt->setUInt32(2, GetGUID().GetCounter()); + stmt->setUInt8(3, itr->first); + stmt->setUInt8(4, m_activeSpec); + trans->Append(stmt); - itr->second.uState = ACTIONBUTTON_UNCHANGED; - ++itr; - break; - case ACTIONBUTTON_DELETED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION_BY_BUTTON_SPEC); - stmt->setUInt32(0, GetGUID().GetCounter()); - stmt->setUInt8(1, itr->first); - stmt->setUInt8(2, m_activeSpec); - trans->Append(stmt); + itr->second.uState = ACTIONBUTTON_UNCHANGED; + ++itr; + break; + case ACTIONBUTTON_DELETED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACTION_BY_BUTTON_SPEC); + stmt->setUInt32(0, GetGUID().GetCounter()); + stmt->setUInt8(1, itr->first); + stmt->setUInt8(2, m_activeSpec); + trans->Append(stmt); - m_actionButtons.erase(itr++); - break; - default: - ++itr; - break; + m_actionButtons.erase(itr++); + break; + default: + ++itr; + break; } } } @@ -19545,7 +19585,7 @@ void Player::_SaveInventory(CharacterDatabaseTransaction trans) // SMSG_ITEM_REFUND_INFO_RESPONSE packet. // Item::UpdatePlayedTime is only called when needed, which is in DB saves, and item refund info requests. GuidSet::iterator i_next; - for (GuidSet::iterator itr = m_refundableItems.begin(); itr!= m_refundableItems.end(); itr = i_next) + for (GuidSet::iterator itr = m_refundableItems.begin(); itr != m_refundableItems.end(); itr = i_next) { // use copy iterator because itr may be invalid after operations in this loop i_next = itr; @@ -19560,7 +19600,7 @@ void Player::_SaveInventory(CharacterDatabaseTransaction trans) else { LOG_ERROR("entities.player", "Player::_SaveInventory: Can't find item (%s) in refundable storage for player '%s' (%s), removing.", - itr->ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str()); + itr->ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str()); m_refundableItems.erase(itr); } } @@ -19593,7 +19633,7 @@ void Player::_SaveInventory(CharacterDatabaseTransaction trans) bagTestGUID = test2->GetGUID().GetCounter(); LOG_ERROR("entities.player", "Player::_SaveInventory: Player '%s' (%s) has incorrect values (Bag: %u, Slot: %u) for the item (%s, State: %d). The player doesn't have an item at that position.", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), (int32)item->GetState()); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), (int32)item->GetState()); // according to the test that was just performed nothing should be in this slot, delete stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_BAG_SLOT); stmt->setUInt32(0, bagTestGUID); @@ -19614,7 +19654,7 @@ void Player::_SaveInventory(CharacterDatabaseTransaction trans) else if (test != item) { LOG_ERROR("entities.player", "Player::_SaveInventory: Player '%s' (%s) has incorrect values (Bag: %u, Slot: %u) for the item (%s). %s is there instead!", - GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString().c_str(), test->GetGUID().ToString().c_str()); // save all changes to the item... if (item->GetState() != ITEM_NEW) // only for existing items, no duplicates item->SaveToDB(trans); @@ -19625,22 +19665,22 @@ void Player::_SaveInventory(CharacterDatabaseTransaction trans) switch (item->GetState()) { - case ITEM_NEW: - case ITEM_CHANGED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_INVENTORY_ITEM); - stmt->setUInt32(0, lowGuid); - stmt->setUInt32(1, bag_guid); - stmt->setUInt8 (2, item->GetSlot()); - stmt->setUInt32(3, item->GetGUID().GetCounter()); - trans->Append(stmt); - break; - case ITEM_REMOVED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); - stmt->setUInt32(0, item->GetGUID().GetCounter()); - trans->Append(stmt); - break; - case ITEM_UNCHANGED: - break; + case ITEM_NEW: + case ITEM_CHANGED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_INVENTORY_ITEM); + stmt->setUInt32(0, lowGuid); + stmt->setUInt32(1, bag_guid); + stmt->setUInt8 (2, item->GetSlot()); + stmt->setUInt32(3, item->GetGUID().GetCounter()); + trans->Append(stmt); + break; + case ITEM_REMOVED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); + stmt->setUInt32(0, item->GetGUID().GetCounter()); + trans->Append(stmt); + break; + case ITEM_UNCHANGED: + break; } item->SaveToDB(trans); // item have unchanged inventory record and can be save standalone @@ -19674,7 +19714,7 @@ void Player::_SaveQuestStatus(CharacterDatabaseTransaction trans) stmt->setUInt32(index++, statusItr->first); stmt->setUInt8(index++, uint8(statusItr->second.Status)); stmt->setBool(index++, statusItr->second.Explored); - stmt->setUInt32(index++, uint32(statusItr->second.Timer / IN_MILLISECONDS+ GameTime::GetGameTime())); + stmt->setUInt32(index++, uint32(statusItr->second.Timer / IN_MILLISECONDS + GameTime::GetGameTime())); for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) stmt->setUInt16(index++, statusItr->second.CreatureOrGOCount[i]); @@ -19738,11 +19778,11 @@ void Player::_SaveDailyQuestStatus(CharacterDatabaseTransaction trans) for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { - if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) + if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_QUESTSTATUS_DAILY); stmt->setUInt32(0, GetGUID().GetCounter()); - stmt->setUInt32(1, GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)); + stmt->setUInt32(1, GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)); stmt->setUInt64(2, uint64(m_lastDailyQuestTime)); trans->Append(stmt); } @@ -19868,26 +19908,26 @@ void Player::_SaveSkills(CharacterDatabaseTransaction trans) switch (itr->second.uState) { - case SKILL_NEW: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILLS); - stmt->setUInt32(0, GetGUID().GetCounter()); - stmt->setUInt16(1, uint16(itr->first)); - stmt->setUInt16(2, value); - stmt->setUInt16(3, max); - trans->Append(stmt); + case SKILL_NEW: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILLS); + stmt->setUInt32(0, GetGUID().GetCounter()); + stmt->setUInt16(1, uint16(itr->first)); + stmt->setUInt16(2, value); + stmt->setUInt16(3, max); + trans->Append(stmt); - break; - case SKILL_CHANGED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SKILLS); - stmt->setUInt16(0, value); - stmt->setUInt16(1, max); - stmt->setUInt32(2, GetGUID().GetCounter()); - stmt->setUInt16(3, uint16(itr->first)); - trans->Append(stmt); + break; + case SKILL_CHANGED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SKILLS); + stmt->setUInt16(0, value); + stmt->setUInt16(1, max); + stmt->setUInt32(2, GetGUID().GetCounter()); + stmt->setUInt16(3, uint16(itr->first)); + trans->Append(stmt); - break; - default: - break; + break; + default: + break; } itr->second.uState = SKILL_UNCHANGED; @@ -20209,7 +20249,7 @@ void Player::UpdateAfkReport(time_t currTime) if (m_bgData.bgAfkReportedTimer <= currTime) { m_bgData.bgAfkReportedCount = 0; - m_bgData.bgAfkReportedTimer = currTime+5*MINUTE; + m_bgData.bgAfkReportedTimer = currTime + 5 * MINUTE; } } @@ -20318,7 +20358,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) if (pet) { LOG_DEBUG("entities.pet", "Player::RemovePet: Player '%s' (%s), Pet (Entry: %u, Mode: %u, ReturnReagent: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), pet->GetEntry(), mode, returnreagent); + GetName().c_str(), GetGUID().ToString().c_str(), pet->GetEntry(), mode, returnreagent); if (pet->m_removed) return; @@ -20374,13 +20414,13 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) { switch (pet->GetEntry()) { - //warlock pets except imp are removed(?) when logging out - case 1860: - case 1863: - case 417: - case 17252: - mode = PET_SAVE_NOT_IN_SLOT; - break; + //warlock pets except imp are removed(?) when logging out + case 1860: + case 1863: + case 417: + case 17252: + mode = PET_SAVE_NOT_IN_SLOT; + break; } } @@ -20577,7 +20617,7 @@ void Player::PetSpellInitialize() CharmInfo* charmInfo = pet->GetCharmInfo(); - WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1); + WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1); data << uint64(pet->GetGUID()); data << uint16(pet->GetCreatureTemplate()->family); // creature family (required for pet talents) data << uint32(pet->GetDuration()); @@ -20631,7 +20671,7 @@ void Player::PossessSpellInitialize() return; } - WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1); + WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1); data << uint64(charm->GetGUID()); data << uint16(0); data << uint32(0); @@ -20668,22 +20708,22 @@ void Player::VehicleSpellInitialize() SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo) { - data << uint16(0) << uint8(0) << uint8(i+8); + data << uint16(0) << uint8(0) << uint8(i + 8); continue; } if (!sConditionMgr->IsObjectMeetingVehicleSpellConditions(vehicle->GetEntry(), spellId, this, vehicle)) { LOG_DEBUG("condition", "Player::VehicleSpellInitialize: Player '%s' (%s) doesn't meet conditions for vehicle (Entry: %u, Spell: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), vehicle->ToCreature()->GetEntry(), spellId); - data << uint16(0) << uint8(0) << uint8(i+8); + GetName().c_str(), GetGUID().ToString().c_str(), vehicle->ToCreature()->GetEntry(), spellId); + data << uint16(0) << uint8(0) << uint8(i + 8); continue; } if (spellInfo->IsPassive()) vehicle->CastSpell(vehicle, spellId, true); - data << uint32(MAKE_UNIT_ACTION_BUTTON(spellId, i+8)); + data << uint32(MAKE_UNIT_ACTION_BUTTON(spellId, i + 8)); } for (uint32 i = MAX_CREATURE_SPELLS; i < MAX_SPELL_CONTROL_BAR; ++i) @@ -20706,7 +20746,7 @@ void Player::CharmSpellInitialize() if (!charmInfo) { LOG_ERROR("entities.player", "Player::CharmSpellInitialize(): Player '%s' (%s) has a charm (%s) but no no charminfo!", - GetName().c_str(), GetGUID().ToString().c_str(), charm->GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str(), charm->GetGUID().ToString().c_str()); return; } @@ -20722,7 +20762,7 @@ void Player::CharmSpellInitialize() } } - WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+4*addlist+1); + WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 4 * addlist + 1); data << uint64(charm->GetGUID()); data << uint16(0); data << uint32(0); @@ -20788,31 +20828,31 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s float totalmul = 1.0f; int32 totalflat = 0; - auto calculateSpellMod = [&](SpellModifier* mod) + auto calculateSpellMod = [&](SpellModifier * mod) { switch (mod->type) { - case SPELLMOD_FLAT: - totalflat += mod->value; - break; - case SPELLMOD_PCT: - // special case (skip > 10sec spell casts for instant cast setting) - if (op == SPELLMOD_CASTING_TIME && mod->value <= -100 && basevalue >= T(10000)) + case SPELLMOD_FLAT: + totalflat += mod->value; + break; + case SPELLMOD_PCT: + // special case (skip > 10sec spell casts for instant cast setting) + if (op == SPELLMOD_CASTING_TIME && mod->value <= -100 && basevalue >= T(10000)) + return; + else if (!Player::HasSpellModApplied(mod, spell)) + { + // Special case for Surge of Light, do not apply critical chance reduction if others mods was not applied (i.e. procs while casting another spell) + // (Surge of Light is the only PCT_MOD on critical chance) + if (op == SPELLMOD_CRITICAL_CHANCE) return; - else if (!Player::HasSpellModApplied(mod, spell)) - { - // Special case for Surge of Light, do not apply critical chance reduction if others mods was not applied (i.e. procs while casting another spell) - // (Surge of Light is the only PCT_MOD on critical chance) - if (op == SPELLMOD_CRITICAL_CHANCE) - return; - // Special case for Backdraft: do not apply GCD reduction if cast time reduction was not applied (i.e. when Backlash is consumed first). - // (Backdraft is the only PCT_MOD on global cooldown) - else if (op == SPELLMOD_GLOBAL_COOLDOWN) - return; - } + // Special case for Backdraft: do not apply GCD reduction if cast time reduction was not applied (i.e. when Backlash is consumed first). + // (Backdraft is the only PCT_MOD on global cooldown) + else if (op == SPELLMOD_GLOBAL_COOLDOWN) + return; + } - totalmul += CalculatePct(1.0f, mod->value); - break; + totalmul += CalculatePct(1.0f, mod->value); + break; } Player::ApplyModToSpell(mod, spell); @@ -20958,7 +20998,7 @@ void Player::SetRestBonus(float rest_bonus_new) if (rest_bonus_new < 0) rest_bonus_new = 0; - float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)*1.5f/2; + float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) * 1.5f / 2; if (rest_bonus_new > rest_bonus_max) m_rest_bonus = rest_bonus_max; @@ -21141,7 +21181,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc if (CONF_GET_BOOL("InstantFlightPaths")) { - TaxiNodesEntry const* lastPathNode = sTaxiNodesStore.LookupEntry(nodes[nodes.size()-1]); + TaxiNodesEntry const* lastPathNode = sTaxiNodesStore.LookupEntry(nodes[nodes.size() - 1]); ASSERT(lastPathNode); m_taxi.ClearTaxiDestinations(); ModifyMoney(-(int32)totalcost); @@ -21215,7 +21255,7 @@ void Player::ContinueTaxiFlight() const for (uint32 i = 1; i < nodeList.size(); ++i) { TaxiPathNodeEntry const* node = nodeList[i]; - TaxiPathNodeEntry const* prevNode = nodeList[i-1]; + TaxiPathNodeEntry const* prevNode = nodeList[i - 1]; // skip nodes at another map if (node->ContinentID != GetMapId()) @@ -21226,9 +21266,9 @@ void Player::ContinueTaxiFlight() const distNext = GetExactDistSq(node->Loc.X, node->Loc.Y, node->Loc.Z); float distNodes = - (node->Loc.X - prevNode->Loc.X)*(node->Loc.X - prevNode->Loc.X) + - (node->Loc.Y - prevNode->Loc.Y)*(node->Loc.Y - prevNode->Loc.Y) + - (node->Loc.Z - prevNode->Loc.Z)*(node->Loc.Z - prevNode->Loc.Z); + (node->Loc.X - prevNode->Loc.X) * (node->Loc.X - prevNode->Loc.X) + + (node->Loc.Y - prevNode->Loc.Y) * (node->Loc.Y - prevNode->Loc.Y) + + (node->Loc.Z - prevNode->Loc.Z) * (node->Loc.Z - prevNode->Loc.Z); if (distNext + distPrev < distNodes) { @@ -21297,26 +21337,27 @@ void Player::InitDisplayIds() uint8 gender = GetNativeGender(); switch (gender) { - case GENDER_FEMALE: - SetDisplayId(info->displayId_f); - SetNativeDisplayId(info->displayId_f); - break; - case GENDER_MALE: - SetDisplayId(info->displayId_m); - SetNativeDisplayId(info->displayId_m); - break; - default: - LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has invalid gender %u", GetName().c_str(), GetGUID().ToString().c_str(), gender); + case GENDER_FEMALE: + SetDisplayId(info->displayId_f); + SetNativeDisplayId(info->displayId_f); + break; + case GENDER_MALE: + SetDisplayId(info->displayId_m); + SetNativeDisplayId(info->displayId_m); + break; + default: + LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has invalid gender %u", GetName().c_str(), GetGUID().ToString().c_str(), gender); } } -inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore) +inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, + bool bStore) { ItemPosCountVec vDest; uint16 uiDest = 0; InventoryResult msg = bStore ? - CanStoreNewItem(bag, slot, vDest, item, pProto->BuyCount * count) : - CanEquipNewItem(slot, uiDest, item, false); + CanStoreNewItem(bag, slot, vDest, item, pProto->BuyCount * count) : + CanEquipNewItem(slot, uiDest, item, false); if (msg != EQUIP_ERR_OK) { SendEquipError(msg, nullptr, nullptr, item); @@ -21343,13 +21384,13 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c } Item* it = bStore ? - StoreNewItem(vDest, item, true) : - EquipNewItem(uiDest, item, true); + StoreNewItem(vDest, item, true) : + EquipNewItem(uiDest, item, true); if (it) { uint32 new_count = pVendor->UpdateVendorItemCurrentCount(crItem, pProto->BuyCount * count); - WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); + WorldPacket data(SMSG_BUY_ITEM, (8 + 4 + 4 + 4)); data << uint64(pVendor->GetGUID()); data << uint32(vendorslot + 1); // numbered from 1 at client data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); @@ -21406,7 +21447,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin if (!creature) { LOG_DEBUG("network", "Player::BuyItemFromVendorSlot: Vendor (%s) not found or player '%s' (%s) can't interact with him.", - vendorguid.ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str()); + vendorguid.ToString().c_str(), GetName().c_str(), GetGUID().ToString().c_str()); SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, item, 0); return false; } @@ -21414,7 +21455,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin if (!sConditionMgr->IsObjectMeetingVendorItemConditions(creature->GetEntry(), item, this, creature)) { LOG_DEBUG("condition", "Player::BuyItemFromVendorSlot: Player '%s' (%s) doesn't meed conditions for creature (Entry: %u, Item: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), creature->GetEntry(), item); + GetName().c_str(), GetGUID().ToString().c_str(), creature->GetEntry(), item); SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item, 0); return false; } @@ -21509,7 +21550,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin if ((uint32)count > maxCount) { LOG_ERROR("entities.player.cheat", "Player::BuyItemFromVendorSlot: Player '%s' (%s) tried to buy item (ItemID: %u, Count: %u), causing overflow", - GetName().c_str(), GetGUID().ToString().c_str(), pProto->ItemId, (uint32)count); + GetName().c_str(), GetGUID().ToString().c_str(), pProto->ItemId, (uint32)count); count = (uint8)maxCount; } price = pProto->BuyPrice * count; //it should not exceed MAX_MONEY_AMOUNT @@ -21576,7 +21617,7 @@ void Player::UpdateHomebindTime(uint32 time) if (m_HomebindTimer) // instance valid, but timer not reset { // hide reminder - WorldPacket data(SMSG_RAID_GROUP_ONLY, 4+4); + WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4); data << uint32(0); data << uint32(0); SendDirectMessage(&data); @@ -21599,12 +21640,12 @@ void Player::UpdateHomebindTime(uint32 time) // instance is invalid, start homebind timer m_HomebindTimer = 60000; // send message to player - WorldPacket data(SMSG_RAID_GROUP_ONLY, 4+4); + WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4); data << uint32(m_HomebindTimer); data << uint32(1); SendDirectMessage(&data); LOG_DEBUG("maps", "Player::UpdateHomebindTime: Player '%s' (%s) will be teleported to homebind in 60 seconds", - GetName().c_str(), GetGUID().ToString().c_str()); + GetName().c_str(), GetGUID().ToString().c_str()); } } @@ -21620,7 +21661,7 @@ void Player::UpdatePvPState(bool onlyFFA) /// @todo should we always synchronize UNIT_FIELD_BYTES_2, 1 of controller and controlled? // no, we shouldn't, those are checked for affecting player by client if (!pvpInfo.IsInNoPvPArea && !IsGameMaster() - && (pvpInfo.IsInFFAPvPArea || sWorld->IsFFAPvPRealm())) + && (pvpInfo.IsInFFAPvPArea || sWorld->IsFFAPvPRealm())) { if (!IsFFAPvP()) { @@ -21711,7 +21752,7 @@ void Player::SetResurrectRequestData(WorldObject const* caster, uint32 health, u _resurrectionData->Aura = appliedAura; } - //slot to be excluded while counting +//slot to be excluded while counting bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const { if (!enchantmentcondition) @@ -21732,7 +21773,7 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) Item* pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem2 && !pItem2->IsBroken() && pItem2->GetTemplate()->Socket[0].Color) { - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem2->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) @@ -21775,31 +21816,31 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) uint32 _cur_gem = curcount[Condition->LtOperandType[i] - 1]; // if have use them as count, else use from Condition - uint32 _cmp_gem = Condition->RtOperandType[i] ? curcount[Condition->RtOperandType[i] - 1]: Condition->RtOperand[i]; + uint32 _cmp_gem = Condition->RtOperandType[i] ? curcount[Condition->RtOperandType[i] - 1] : Condition->RtOperand[i]; switch (Condition->Operator[i]) { - case 2: // requires less than ( || ) gems - activate &= (_cur_gem < _cmp_gem) ? true : false; - break; - case 3: // requires more than ( || ) gems - activate &= (_cur_gem > _cmp_gem) ? true : false; - break; - case 5: // requires at least than ( || ) gems - activate &= (_cur_gem >= _cmp_gem) ? true : false; - break; + case 2: // requires less than ( || ) gems + activate &= (_cur_gem < _cmp_gem) ? true : false; + break; + case 3: // requires more than ( || ) gems + activate &= (_cur_gem > _cmp_gem) ? true : false; + break; + case 5: // requires at least than ( || ) gems + activate &= (_cur_gem >= _cmp_gem) ? true : false; + break; } } LOG_DEBUG("entities.player.items", "Player::EnchantmentFitsRequirements: Checking Condition %u, there are %u Meta Gems, %u Red Gems, %u Yellow Gems and %u Blue Gems, Activate:%s", - enchantmentcondition, curcount[0], curcount[1], curcount[2], curcount[3], activate ? "yes" : "no"); + enchantmentcondition, curcount[0], curcount[1], curcount[2], curcount[3], activate ? "yes" : "no"); return activate; } void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) { - //cycle all equipped items + //cycle all equipped items for (uint32 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { //enchants for the slot being socketed are handled by Player::ApplyItemMods @@ -21811,7 +21852,7 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) if (!pItem || !pItem->GetTemplate()->Socket[0].Color) continue; - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) @@ -21824,13 +21865,13 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) uint32 condition = enchantEntry->ConditionID; if (condition) { - //was enchant active with/without item? + //was enchant active with/without item? bool wasactive = EnchantmentFitsRequirements(condition, apply ? exceptslot : -1); - //should it now be? + //should it now be? if (wasactive ^ EnchantmentFitsRequirements(condition, apply ? -1 : exceptslot)) { // ignore item gem conditions - //if state changed, (dis)apply enchant + //if state changed, (dis)apply enchant ApplyEnchantment(pItem, EnchantmentSlot(enchant_slot), !wasactive, true, true); } } @@ -21838,7 +21879,7 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) } } - //if false -> then toggled off if was on| if true -> toggled on if was off AND meets requirements +//if false -> then toggled off if was on| if true -> toggled on if was off AND meets requirements void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) { //cycle all equipped items @@ -21854,7 +21895,7 @@ void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) continue; //cycle all (gem)enchants - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) //if no enchant go to next enchant(slot) @@ -22127,9 +22168,9 @@ void Player::UpdateVisibilityOf(WorldObject* target) target->DestroyForPlayer(this); m_clientGUIDs.erase(target->GetGUID()); - #ifdef WARHEAD_DEBUG - LOG_DEBUG("maps", "Object %s out of range for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); - #endif +#ifdef WARHEAD_DEBUG + LOG_DEBUG("maps", "Object %s out of range for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); +#endif } } else @@ -22139,9 +22180,9 @@ void Player::UpdateVisibilityOf(WorldObject* target) target->SendUpdateToPlayer(this); m_clientGUIDs.insert(target->GetGUID()); - #ifdef WARHEAD_DEBUG - LOG_DEBUG("maps", "Object %s is visible now for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); - #endif +#ifdef WARHEAD_DEBUG + LOG_DEBUG("maps", "Object %s is visible now for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); +#endif // target aura duration for caster show only if target exist at caster client // send data at target visibility change (adding to client) @@ -22215,9 +22256,9 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set& vi target->BuildOutOfRangeUpdateBlock(&data); m_clientGUIDs.erase(target->GetGUID()); - #ifdef WARHEAD_DEBUG - LOG_DEBUG("maps", "Object %s is out of range for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); - #endif +#ifdef WARHEAD_DEBUG + LOG_DEBUG("maps", "Object %s is out of range for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); +#endif } } else //if (visibleNow.size() < 30 || target->GetTypeId() == TYPEID_UNIT && target->ToCreature()->IsVehicle()) @@ -22227,9 +22268,9 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set& vi target->BuildCreateUpdateBlockForPlayer(&data, this); UpdateVisibilityOf_helper(m_clientGUIDs, target, visibleNow); - #ifdef WARHEAD_DEBUG - LOG_DEBUG("maps", "Object %s is visible now for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); - #endif +#ifdef WARHEAD_DEBUG + LOG_DEBUG("maps", "Object %s is visible now for player %s. Distance = %f", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str(), GetDistance(target)); +#endif } } } @@ -22365,7 +22406,7 @@ void Player::SendInitialPacketsBeforeAddToMap() SendTalentsInfoData(false); /// SMSG_INSTANCE_DIFFICULTY - WorldPacket data(SMSG_INSTANCE_DIFFICULTY, 4+4); + WorldPacket data(SMSG_INSTANCE_DIFFICULTY, 4 + 4); data << uint32(GetMap()->GetDifficulty()); data << uint32(GetMap()->GetEntry()->IsDynamicDifficultyMap() && GetMap()->IsHeroic()); // Raid dynamic difficulty SendDirectMessage(&data); @@ -22526,19 +22567,19 @@ void Player::SendUpdateToOutOfRangeGroupMembers() void Player::SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg) const { - WorldPacket data(SMSG_TRANSFER_ABORTED, 4+2); + WorldPacket data(SMSG_TRANSFER_ABORTED, 4 + 2); data << uint32(mapid); data << uint8(reason); // transfer abort reason switch (reason) { - case TRANSFER_ABORT_INSUF_EXPAN_LVL: - case TRANSFER_ABORT_DIFFICULTY: - case TRANSFER_ABORT_UNIQUE_MESSAGE: - // these are the ONLY cases that have an extra argument in the packet!!! - data << uint8(arg); - break; - default: - break; + case TRANSFER_ABORT_INSUF_EXPAN_LVL: + case TRANSFER_ABORT_DIFFICULTY: + case TRANSFER_ABORT_UNIQUE_MESSAGE: + // these are the ONLY cases that have an extra argument in the packet!!! + data << uint8(arg); + break; + default: + break; } SendDirectMessage(&data); } @@ -22558,7 +22599,7 @@ void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint3 else type = RAID_INSTANCE_WARNING_MIN_SOON; - WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4+4+4+4); + WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4 + 4 + 4 + 4); data << uint32(type); data << uint32(mapid); data << uint32(difficulty); // difficulty @@ -22682,7 +22723,7 @@ void Player::LearnCustomSpells() { uint32 tspell = *itr; LOG_DEBUG("entities.player.loading", "Player::LearnCustomSpells: Player '%s' (%s, Class: %u Race: %u): Adding initial spell (SpellID: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), uint32(GetClass()), uint32(GetRace()), tspell); + GetName().c_str(), GetGUID().ToString().c_str(), uint32(GetClass()), uint32(GetRace()), tspell); if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add AddSpell(tspell, true, true, true, false); else // but send in normal spell in game learn case @@ -22714,48 +22755,48 @@ void Player::LearnDefaultSkill(uint32 skillId, uint16 rank) LOG_DEBUG("entities.player.loading", "PLAYER (Class: %u Race: %u): Adding initial skill, id = %u", uint32(GetClass()), uint32(GetRace()), skillId); switch (GetSkillRangeType(rcInfo)) { - case SKILL_RANGE_LANGUAGE: - SetSkill(skillId, 0, 300, 300); - break; - case SKILL_RANGE_LEVEL: - { - uint16 skillValue = 1; - uint16 maxValue = GetMaxSkillValueForLevel(); - if (CONF_GET_BOOL("AlwaysMaxWeaponSkill") && !IsProfessionOrRidingSkill(skillId)) - skillValue = maxValue; - else if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE) - skillValue = maxValue; - else if (GetClass() == CLASS_DEATH_KNIGHT) - skillValue = std::min(std::max({ 1, uint16((GetLevel() - 1) * 5) }), maxValue); - else if (skillId == SKILL_FIST_WEAPONS) - skillValue = std::max(1, GetSkillValue(SKILL_UNARMED)); - else if (skillId == SKILL_LOCKPICKING) - skillValue = std::max(1, GetSkillValue(SKILL_LOCKPICKING)); - - SetSkill(skillId, 0, skillValue, maxValue); - break; - } - case SKILL_RANGE_MONO: - SetSkill(skillId, 0, 1, 1); + case SKILL_RANGE_LANGUAGE: + SetSkill(skillId, 0, 300, 300); + break; + case SKILL_RANGE_LEVEL: + { + uint16 skillValue = 1; + uint16 maxValue = GetMaxSkillValueForLevel(); + if (CONF_GET_BOOL("AlwaysMaxWeaponSkill") && !IsProfessionOrRidingSkill(skillId)) + skillValue = maxValue; + else if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE) + skillValue = maxValue; + else if (GetClass() == CLASS_DEATH_KNIGHT) + skillValue = std::min(std::max({ 1, uint16((GetLevel() - 1) * 5) }), maxValue); + else if (skillId == SKILL_FIST_WEAPONS) + skillValue = std::max(1, GetSkillValue(SKILL_UNARMED)); + else if (skillId == SKILL_LOCKPICKING) + skillValue = std::max(1, GetSkillValue(SKILL_LOCKPICKING)); + + SetSkill(skillId, 0, skillValue, maxValue); + break; + } + case SKILL_RANGE_MONO: + SetSkill(skillId, 0, 1, 1); + break; + case SKILL_RANGE_RANK: + { + if (!rank) break; - case SKILL_RANGE_RANK: - { - if (!rank) - break; - SkillTiersEntry const* tier = sSkillTiersStore.LookupEntry(rcInfo->SkillTierID); - uint16 maxValue = tier->Value[std::max(rank - 1, 0)]; - uint16 skillValue = 1; - if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE) - skillValue = maxValue; - else if (GetClass() == CLASS_DEATH_KNIGHT) - skillValue = std::min(std::max({ uint16(1), uint16((GetLevel() - 1) * 5) }), maxValue); + SkillTiersEntry const* tier = sSkillTiersStore.LookupEntry(rcInfo->SkillTierID); + uint16 maxValue = tier->Value[std::max(rank - 1, 0)]; + uint16 skillValue = 1; + if (rcInfo->Flags & SKILL_FLAG_ALWAYS_MAX_VALUE) + skillValue = maxValue; + else if (GetClass() == CLASS_DEATH_KNIGHT) + skillValue = std::min(std::max({ uint16(1), uint16((GetLevel() - 1) * 5) }), maxValue); - SetSkill(skillId, rank, skillValue, maxValue); - break; - } - default: - break; + SetSkill(skillId, rank, skillValue, maxValue); + break; + } + default: + break; } } @@ -22801,9 +22842,9 @@ void Player::LearnQuestRewardedSpells(Quest const* quest) if (!learnedInfo) return; - // profession specialization can be re-learned from npc - if (learnedInfo->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effects[1].Effect == 0 && !learnedInfo->SpellLevel) - return; + // profession specialization can be re-learned from npc + if (learnedInfo->Effects[0].Effect == SPELL_EFFECT_TRADE_SKILL && learnedInfo->Effects[1].Effect == 0 && !learnedInfo->SpellLevel) + return; } CastSpell(this, spell_id, true); @@ -22889,7 +22930,7 @@ void Player::SendAurasForTarget(Unit* target) const Unit::VisibleAuraMap const* visibleAuras = target->GetVisibleAuras(); for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr) { - AuraApplication * auraApp = itr->second; + AuraApplication* auraApp = itr->second; auraApp->BuildUpdatePacket(data, false); } @@ -22904,15 +22945,16 @@ void Player::SetDailyQuestStatus(uint32 quest_id) { for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { - if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) + if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)) { - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx, quest_id); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, quest_id); m_lastDailyQuestTime = GameTime::GetGameTime(); // last daily quest time m_DailyQuestChanged = true; break; } } - } else + } + else { m_DFQuests.insert(quest_id); m_lastDailyQuestTime = GameTime::GetGameTime(); @@ -22964,7 +23006,7 @@ void Player::SetMonthlyQuestStatus(uint32 quest_id) void Player::ResetDailyQuestStatus() { for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx, 0); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, 0); m_DFQuests.clear(); // Dungeon Finder Quests. @@ -23015,9 +23057,9 @@ bool Player::InBattlegroundQueue(bool ignoreArena) const { for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE && (!ignoreArena || - (m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_2v2 && - m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_3v3 && - m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_5v5))) + (m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_2v2 && + m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_3v3 && + m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_5v5))) return true; return false; } @@ -23056,7 +23098,7 @@ void Player::SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId) uint32 Player::AddBattlegroundQueueId(BattlegroundQueueTypeId val) { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattlegroundQueueID[i].bgQueueTypeId == val) { @@ -23070,7 +23112,7 @@ uint32 Player::AddBattlegroundQueueId(BattlegroundQueueTypeId val) bool Player::HasFreeBattlegroundQueueId() const { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE) return true; return false; @@ -23078,7 +23120,7 @@ bool Player::HasFreeBattlegroundQueueId() const void Player::RemoveBattlegroundQueueId(BattlegroundQueueTypeId val) { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { if (m_bgBattlegroundQueueID[i].bgQueueTypeId == val) { @@ -23091,14 +23133,14 @@ void Player::RemoveBattlegroundQueueId(BattlegroundQueueTypeId val) void Player::SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId) { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId) m_bgBattlegroundQueueID[i].invitedToInstance = instanceId; } bool Player::IsInvitedForBattlegroundInstance(uint32 instanceId) const { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattlegroundQueueID[i].invitedToInstance == instanceId) return true; return false; @@ -23145,7 +23187,7 @@ float Player::GetReputationPriceDiscount(FactionTemplateEntry const* factionTemp if (rank <= REP_NEUTRAL) return 1.0f; - return 1.0f - 0.05f* (rank - REP_NEUTRAL); + return 1.0f - 0.05f * (rank - REP_NEUTRAL); } Player* Player::GetTrader() const @@ -23282,7 +23324,7 @@ void Player::SendSummonRequestFrom(Unit* summoner) WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); data << uint64(summoner->GetGUID()); // summoner guid data << uint32(summoner->GetZoneId()); // summoner zone - data << uint32(MAX_PLAYER_SUMMON_DELAY*IN_MILLISECONDS); // auto decline after msecs + data << uint32(MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); // auto decline after msecs SendDirectMessage(&data); } @@ -23340,9 +23382,9 @@ void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/) if (!offItem) return; - // unequip offhand weapon if player doesn't have dual wield anymore - if (!CanDualWield() && (offItem->GetTemplate()->InventoryType == INVTYPE_WEAPONOFFHAND || offItem->GetTemplate()->InventoryType == INVTYPE_WEAPON)) - force = true; + // unequip offhand weapon if player doesn't have dual wield anymore + if (!CanDualWield() && (offItem->GetTemplate()->InventoryType == INVTYPE_WEAPONOFFHAND || offItem->GetTemplate()->InventoryType == INVTYPE_WEAPON)) + force = true; // need unequip offhand for 2h-weapon without TitanGrip (in any from hands) if (!force && (CanTitanGrip() || (offItem->GetTemplate()->InventoryType != INVTYPE_2HWEAPON && !IsTwoHandUsed()))) @@ -23384,47 +23426,47 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons // for optimize check 2 used cases only switch (spellInfo->EquippedItemClass) { - case ITEM_CLASS_WEAPON: - { - for (uint8 i = EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) - if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i)) - if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; - break; - } - case ITEM_CLASS_ARMOR: + case ITEM_CLASS_WEAPON: + { + for (uint8 i = EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) + if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + break; + } + case ITEM_CLASS_ARMOR: + { + // most used check: shield only + if (spellInfo->EquippedItemSubClassMask & ((1 << ITEM_SUBCLASS_ARMOR_BUCKLER) | (1 << ITEM_SUBCLASS_ARMOR_SHIELD))) { - // most used check: shield only - if (spellInfo->EquippedItemSubClassMask & ((1 << ITEM_SUBCLASS_ARMOR_BUCKLER) | (1 << ITEM_SUBCLASS_ARMOR_SHIELD))) + if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + + // special check to filter things like Shield Wall, the aura is not permanent and must stay even without required item + if (!spellInfo->IsPassive()) { - if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (spellInfo->Effects[i].IsAura()) return true; - - // special check to filter things like Shield Wall, the aura is not permanent and must stay even without required item - if (!spellInfo->IsPassive()) - { - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (spellInfo->Effects[i].IsAura()) - return true; - } } + } - // tabard not have dependent spells - for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_MAINHAND; ++i) - if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i)) - if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) - return true; - - // ranged slot can have some armor subclasses - if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + // tabard not have dependent spells + for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_MAINHAND; ++i) + if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i)) if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; - break; - } - default: - LOG_ERROR("entities.player", "Player::HasItemFitToSpellRequirements: Not handled spell requirement for item class %u", spellInfo->EquippedItemClass); - break; + + // ranged slot can have some armor subclasses + if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + return true; + break; + } + default: + LOG_ERROR("entities.player", "Player::HasItemFitToSpellRequirements: Not handled spell requirement for item class %u", spellInfo->EquippedItemClass); + break; } return false; @@ -23434,14 +23476,14 @@ 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)) + HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION)) return true; // Check no reagent use mask flag96 noReagentMask; noReagentMask[0] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1); - noReagentMask[1] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1+1); - noReagentMask[2] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1+2); + noReagentMask[1] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 1); + noReagentMask[2] = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 2); if (spellInfo->SpellFamilyFlags & noReagentMask) return true; @@ -23493,16 +23535,30 @@ uint32 Player::GetResurrectionSpellId() { switch ((*itr)->GetId()) { - case 20707: spell_id = 3026; break; // rank 1 - case 20762: spell_id = 20758; break; // rank 2 - case 20763: spell_id = 20759; break; // rank 3 - case 20764: spell_id = 20760; break; // rank 4 - case 20765: spell_id = 20761; break; // rank 5 - case 27239: spell_id = 27240; break; // rank 6 - case 47883: spell_id = 47882; break; // rank 7 - default: - LOG_ERROR("entities.player", "Unhandled spell %u: S.Resurrection", (*itr)->GetId()); - continue; + case 20707: + spell_id = 3026; + break; // rank 1 + case 20762: + spell_id = 20758; + break; // rank 2 + case 20763: + spell_id = 20759; + break; // rank 3 + case 20764: + spell_id = 20760; + break; // rank 4 + case 20765: + spell_id = 20761; + break; // rank 5 + case 27239: + spell_id = 27240; + break; // rank 6 + case 47883: + spell_id = 47882; + break; // rank 7 + default: + LOG_ERROR("entities.player", "Unhandled spell %u: S.Resurrection", (*itr)->GetId()); + continue; } prio = 3; @@ -23606,7 +23662,7 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar continue; // member (alive or dead) or his corpse at req. distance // quest objectives updated only for alive group member or dead but with not released body - if (player->IsAlive()|| !player->GetCorpse()) + if (player->IsAlive() || !player->GetCorpse()) player->KilledMonsterCredit(creature_id, creature_guid); } } @@ -23702,7 +23758,7 @@ void Player::SetClientControl(Unit* target, bool allowMove) if (target->HasUnitState(UNIT_STATE_CHARMED) && (GetGUID() != target->GetCharmerGUID())) { LOG_ERROR("entities.player", "Player '%s' attempt to client control '%s', which is charmed by GUID %s", - GetName().c_str(), target->GetName().c_str(), target->GetCharmerGUID().ToString().c_str()); + GetName().c_str(), target->GetName().c_str(), target->GetCharmerGUID().ToString().c_str()); return; } @@ -23710,7 +23766,7 @@ void Player::SetClientControl(Unit* target, bool allowMove) if (target->HasUnitState(UNIT_STATE_FLEEING | UNIT_STATE_CONFUSED)) allowMove = false; - WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1); + WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size() + 1); data << target->GetPackGUID(); data << uint8(allowMove ? 1 : 0); SendDirectMessage(&data); @@ -23781,7 +23837,7 @@ void Player::UpdateCorpseReclaimDelay() bool pvp = (m_ExtraFlags & PLAYER_EXTRA_PVP_DEATH) != 0; if ((pvp && !CONF_GET_BOOL("Death.CorpseReclaimDelay.PvP")) || - (!pvp && !CONF_GET_BOOL("Death.CorpseReclaimDelay.PvE"))) + (!pvp && !CONF_GET_BOOL("Death.CorpseReclaimDelay.PvE"))) return; time_t now = GameTime::GetGameTime(); @@ -23792,9 +23848,9 @@ void Player::UpdateCorpseReclaimDelay() uint64 count = (m_deathExpireTime - now) / DEATH_EXPIRE_STEP + 1; if (count < MAX_DEATH_COUNT) - m_deathExpireTime = now+(count + 1) * DEATH_EXPIRE_STEP; + m_deathExpireTime = now + (count + 1) * DEATH_EXPIRE_STEP; else - m_deathExpireTime = now + MAX_DEATH_COUNT*DEATH_EXPIRE_STEP; + m_deathExpireTime = now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP; } else m_deathExpireTime = now + DEATH_EXPIRE_STEP; @@ -23819,7 +23875,7 @@ int32 Player::CalculateCorpseReclaimDelay(bool load) const uint64 count = 0; if ((pvp && CONF_GET_BOOL("Death.CorpseReclaimDelay.PvP")) || - (!pvp && CONF_GET_BOOL("Death.CorpseReclaimDelay.PvE"))) + (!pvp && CONF_GET_BOOL("Death.CorpseReclaimDelay.PvE"))) { count = (m_deathExpireTime - corpse->GetGhostTime()) / DEATH_EXPIRE_STEP; @@ -23863,14 +23919,14 @@ Player* Player::GetNextRandomRaidMember(float radius) // IsHostileTo check duel and controlled by enemy if (Target && Target != this && IsWithinDistInMap(Target, radius) && - !Target->HasInvisibilityAura() && !IsHostileTo(Target)) + !Target->HasInvisibilityAura() && !IsHostileTo(Target)) nearMembers.push_back(Target); } if (nearMembers.empty()) return nullptr; - uint32 randTarget = urand(0, nearMembers.size()-1); + uint32 randTarget = urand(0, nearMembers.size() - 1); return nearMembers[randTarget]; } @@ -24077,7 +24133,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) if (apply) { LOG_DEBUG("maps", "Player::CreateViewpoint: Player '%s' (%s) creates seer (Entry: %u, TypeId: %u).", - GetName().c_str(), GetGUID().ToString().c_str(), target->GetEntry(), target->GetTypeId()); + GetName().c_str(), GetGUID().ToString().c_str(), target->GetEntry(), target->GetTypeId()); if (!AddGuidValue(PLAYER_FARSIGHT, target->GetGUID())) { @@ -24300,7 +24356,7 @@ uint32 Player::GetRuneBaseCooldown(uint8 index) uint32 cooldown = RUNE_BASE_COOLDOWN; AuraEffectList const& regenAura = GetAuraEffectsByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); - for (AuraEffectList::const_iterator i = regenAura.begin();i != regenAura.end(); ++i) + for (AuraEffectList::const_iterator i = regenAura.begin(); i != regenAura.end(); ++i) { if ((*i)->GetMiscValue() == POWER_RUNE && (*i)->GetMiscValueB() == rune) cooldown = cooldown * (100 - (*i)->GetAmount()) / 100; @@ -24363,7 +24419,7 @@ void Player::RestoreBaseRune(uint8 index) std::vector removeList; std::unordered_set& auras = m_runes->runes[index].ConvertAuras; - auto criteria = [&removeList](AuraEffect const* storedAura) -> bool + auto criteria = [&removeList](AuraEffect const * storedAura) -> bool { // AuraEffect already gone if (!storedAura) @@ -24600,7 +24656,7 @@ void Player::StoreLootItem(uint8 lootSlot, Loot* loot) uint32 Player::CalculateTalentsPoints() const { - uint32 base_talent = GetLevel() < 10 ? 0 : GetLevel()-9; + uint32 base_talent = GetLevel() < 10 ? 0 : GetLevel() - 9; if (GetClass() != CLASS_DEATH_KNIGHT || GetMapId() != 609) return uint32(base_talent * CONF_GET_FLOAT("Rate.Talent")); @@ -24645,7 +24701,7 @@ void Player::_LoadSkills(PreparedQueryResult result) if (!rcEntry) { LOG_ERROR("entities.player", "Player::_LoadSkills: Player '%s' (%s, Race: %u, Class: %u) has forbidden skill %u for his race/class combination", - GetName().c_str(), GetGUID().ToString().c_str(), uint32(GetRace()), uint32(GetClass()), skill); + GetName().c_str(), GetGUID().ToString().c_str(), uint32(GetRace()), uint32(GetClass()), skill); mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(0, SKILL_DELETED))); continue; @@ -24654,23 +24710,23 @@ void Player::_LoadSkills(PreparedQueryResult result) // set fixed skill ranges switch (GetSkillRangeType(rcEntry)) { - case SKILL_RANGE_LANGUAGE: // 300..300 - value = max = 300; - break; - case SKILL_RANGE_MONO: // 1..1, grey monolite bar - value = max = 1; - break; - case SKILL_RANGE_LEVEL: - max = GetMaxSkillValueForLevel(); - break; - default: - break; + case SKILL_RANGE_LANGUAGE: // 300..300 + value = max = 300; + break; + case SKILL_RANGE_MONO: // 1..1, grey monolite bar + value = max = 1; + break; + case SKILL_RANGE_LEVEL: + max = GetMaxSkillValueForLevel(); + break; + default: + break; } if (value == 0) { LOG_ERROR("entities.player", "Player::_LoadSkills: Player '%s' (%s) has skill %u with value 0, deleted.", - GetName().c_str(), GetGUID().ToString().c_str(), skill); + GetName().c_str(), GetGUID().ToString().c_str(), skill); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_SKILL); @@ -24708,11 +24764,10 @@ void Player::_LoadSkills(PreparedQueryResult result) if (count >= PLAYER_MAX_SKILLS) // client limit { LOG_ERROR("entities.player", "Player::_LoadSkills: Player '%s' (%s) has more than %u skills.", - GetName().c_str(), GetGUID().ToString().c_str(), PLAYER_MAX_SKILLS); + GetName().c_str(), GetGUID().ToString().c_str(), PLAYER_MAX_SKILLS); break; } - } - while (result->NextRow()); + } while (result->NextRow()); } // Learn skill rewarded spells after all skills have been loaded to prevent learning a skill from them before its loaded with proper value from DB @@ -24758,7 +24813,7 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi return res; // check unique-equipped on gems - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) @@ -24773,7 +24828,7 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi // include for check equip another gems with same limit category for not equipped item (and then not counted) uint32 gem_limit_count = !pItem->IsEquipped() && pGem->ItemLimitCategory - ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1; + ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1; if (InventoryResult res = CanEquipUniqueItem(pGem, eslot, gem_limit_count)) return res; @@ -24829,17 +24884,17 @@ void Player::HandleFall(MovementInfo const& movementInfo) //Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored // 14.57 can be calculated by resolving damageperc formula below to 0 if (z_diff >= 14.57f && !isDead() && !IsGameMaster() && - !HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) && - !HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL)) + !HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) && + !HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL)) { //Safe fall, fall height reduction int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL); - float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f; + float damageperc = 0.018f * (z_diff - safe_fall) - 0.2426f; if (damageperc > 0) { - uint32 damage = (uint32)(damageperc * GetMaxHealth()*CONF_GET_FLOAT("Rate.Damage.Fall")); + uint32 damage = (uint32)(damageperc * GetMaxHealth() * CONF_GET_FLOAT("Rate.Damage.Fall")); if (GetCommandStatus(CHEAT_GOD)) damage = 0; @@ -24855,18 +24910,19 @@ void Player::HandleFall(MovementInfo const& movementInfo) // Gust of Wind if (HasAura(43621)) - damage = GetMaxHealth()/2; + damage = GetMaxHealth() / 2; uint32 original_health = GetHealth(); uint32 final_damage = EnvironmentalDamage(DAMAGE_FALL, damage); // recheck alive, might have died of EnvironmentalDamage, avoid cases when player die in fact like Spirit of Redemption case if (IsAlive() && final_damage < original_health) - UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, uint32(z_diff*100)); + UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, uint32(z_diff * 100)); } // Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction - LOG_DEBUG("entities.player.falldamage", "FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d\nPlayer debug info:\n%s", movementInfo.pos.GetPositionZ(), height, GetPositionZ(), movementInfo.fallTime, height, damage, safe_fall, GetDebugInfo().c_str()); + LOG_DEBUG("entities.player.falldamage", "FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d\nPlayer debug info:\n%s", movementInfo.pos.GetPositionZ(), height, GetPositionZ(), + movementInfo.fallTime, height, damage, safe_fall, GetDebugInfo().c_str()); } } } @@ -24937,7 +24993,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) // find current max talent rank (0~5) uint8 curtalent_maxrank = 0; // 0 = not learned any rank - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { if (talentInfo->SpellRank[rank] && HasSpell(talentInfo->SpellRank[rank])) { @@ -25057,7 +25113,7 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa // find current max talent rank (0~5) uint8 curtalent_maxrank = 0; // 0 = not learned any rank - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { if (talentInfo->SpellRank[rank] && pet->HasSpell(talentInfo->SpellRank[rank])) { @@ -25111,9 +25167,7 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa if (tmpTalent->SpellRank[rank] != 0) { if (pet->HasSpell(tmpTalent->SpellRank[rank])) - { spentPoints += (rank + 1); - } } } } @@ -25148,7 +25202,7 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa void Player::AddKnownCurrency(uint32 itemId) { if (CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(itemId)) - SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (1LL << (ctEntry->BitIndex-1))); + SetFlag64(PLAYER_FIELD_KNOWN_CURRENCIES, (1LL << (ctEntry->BitIndex - 1))); } void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode) @@ -25254,7 +25308,7 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket* data) // find max talent rank (0~4) int8 curtalent_maxrank = -1; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { if (talentInfo->SpellRank[rank] && HasTalent(talentInfo->SpellRank[rank], specIdx)) { @@ -25331,7 +25385,7 @@ void Player::BuildPetTalentsInfoData(WorldPacket* data) // find max talent rank (0~4) int8 curtalent_maxrank = -1; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { if (talentInfo->SpellRank[rank] && pet->HasSpell(talentInfo->SpellRank[rank])) { @@ -25451,7 +25505,7 @@ void Player::SetEquipmentSet(EquipmentSetInfo::EquipmentSetData const& eqSet) if (itr == _equipmentSets.end() || itr->second.Data.Guid != eqSet.Guid) { LOG_ERROR("entities.player", "Player::SetEquipmentSet: Player '%s' (%s) tried to save nonexistent equipment set " UI64FMTD " (index: %u)", - GetName().c_str(), GetGUID().ToString().c_str(), eqSet.Guid, eqSet.SetID); + GetName().c_str(), GetGUID().ToString().c_str(), eqSet.Guid, eqSet.SetID); return; } } @@ -25483,43 +25537,43 @@ void Player::_SaveEquipmentSets(CharacterDatabaseTransaction trans) uint8 j = 0; switch (eqSet.State) { - case EQUIPMENT_SET_UNCHANGED: - ++itr; - break; // nothing do - case EQUIPMENT_SET_CHANGED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_EQUIP_SET); - stmt->setString(j++, eqSet.Data.SetName); - stmt->setString(j++, eqSet.Data.SetIcon); - stmt->setUInt32(j++, eqSet.Data.IgnoreMask); - for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) - stmt->setUInt32(j++, eqSet.Data.Pieces[i].GetCounter()); - stmt->setUInt32(j++, GetGUID().GetCounter()); - stmt->setUInt64(j++, eqSet.Data.Guid); - stmt->setUInt32(j, eqSet.Data.SetID); - trans->Append(stmt); - eqSet.State = EQUIPMENT_SET_UNCHANGED; - ++itr; - break; - case EQUIPMENT_SET_NEW: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_EQUIP_SET); - stmt->setUInt32(j++, GetGUID().GetCounter()); - stmt->setUInt64(j++, eqSet.Data.Guid); - stmt->setUInt32(j++, eqSet.Data.SetID); - stmt->setString(j++, eqSet.Data.SetName); - stmt->setString(j++, eqSet.Data.SetIcon); - stmt->setUInt32(j++, eqSet.Data.IgnoreMask); - for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) - stmt->setUInt32(j++, eqSet.Data.Pieces[i].GetCounter()); - trans->Append(stmt); - eqSet.State = EQUIPMENT_SET_UNCHANGED; - ++itr; - break; - case EQUIPMENT_SET_DELETED: - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EQUIP_SET); - stmt->setUInt64(0, eqSet.Data.Guid); - trans->Append(stmt); - itr = _equipmentSets.erase(itr); - break; + case EQUIPMENT_SET_UNCHANGED: + ++itr; + break; // nothing do + case EQUIPMENT_SET_CHANGED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_EQUIP_SET); + stmt->setString(j++, eqSet.Data.SetName); + stmt->setString(j++, eqSet.Data.SetIcon); + stmt->setUInt32(j++, eqSet.Data.IgnoreMask); + for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) + stmt->setUInt32(j++, eqSet.Data.Pieces[i].GetCounter()); + stmt->setUInt32(j++, GetGUID().GetCounter()); + stmt->setUInt64(j++, eqSet.Data.Guid); + stmt->setUInt32(j, eqSet.Data.SetID); + trans->Append(stmt); + eqSet.State = EQUIPMENT_SET_UNCHANGED; + ++itr; + break; + case EQUIPMENT_SET_NEW: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_EQUIP_SET); + stmt->setUInt32(j++, GetGUID().GetCounter()); + stmt->setUInt64(j++, eqSet.Data.Guid); + stmt->setUInt32(j++, eqSet.Data.SetID); + stmt->setString(j++, eqSet.Data.SetName); + stmt->setString(j++, eqSet.Data.SetIcon); + stmt->setUInt32(j++, eqSet.Data.IgnoreMask); + for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i) + stmt->setUInt32(j++, eqSet.Data.Pieces[i].GetCounter()); + trans->Append(stmt); + eqSet.State = EQUIPMENT_SET_UNCHANGED; + ++itr; + break; + case EQUIPMENT_SET_DELETED: + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_EQUIP_SET); + stmt->setUInt64(0, eqSet.Data.Guid); + trans->Append(stmt); + itr = _equipmentSets.erase(itr); + break; } } } @@ -25614,8 +25668,7 @@ void Player::_LoadGlyphs(PreparedQueryResult result) m_Glyphs[spec][3] = fields[4].GetUInt16(); m_Glyphs[spec][4] = fields[5].GetUInt16(); m_Glyphs[spec][5] = fields[6].GetUInt16(); - } - while (result->NextRow()); + } while (result->NextRow()); } void Player::_SaveGlyphs(CharacterDatabaseTransaction trans) const @@ -25803,7 +25856,7 @@ void Player::ActivateSpec(uint8 spec) if ((GetClassMask() & talentTabInfo->ClassMask) == 0) continue; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { // skip non-existing talent ranks if (talentInfo->SpellRank[rank] == 0) @@ -25847,7 +25900,7 @@ void Player::ActivateSpec(uint8 spec) continue; // learn highest talent rank that exists in newly activated spec - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { // skip non-existing talent ranks if (talentInfo->SpellRank[rank] == 0) @@ -25885,7 +25938,7 @@ void Player::ActivateSpec(uint8 spec) WorldSession* mySess = GetSession(); mySess->GetQueryProcessor().AddCallback(CharacterDatabase.AsyncQuery(stmt) - .WithPreparedCallback([mySess](PreparedQueryResult result) + .WithPreparedCallback([mySess](PreparedQueryResult result) { // safe callback, we can't pass this pointer directly // in case player logs out before db response (player would be deleted in that case) @@ -25974,7 +26027,7 @@ void Player::SendRefundInfo(Item* item) return; } - WorldPacket data(SMSG_ITEM_REFUND_INFO_RESPONSE, 8+4+4+4+4*4+4*4+4+4); + WorldPacket data(SMSG_ITEM_REFUND_INFO_RESPONSE, 8 + 4 + 4 + 4 + 4 * 4 + 4 * 4 + 4 + 4); data << uint64(item->GetGUID()); // item guid data << uint32(item->GetPaidMoney()); // money cost data << uint32(iece->HonorPoints); // honor point cost @@ -26031,7 +26084,7 @@ void Player::RefundItem(Item* item) if (item->IsRefundExpired()) // item refund has expired { item->SetNotRefundable(this); - WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8+4); + WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4); data << uint64(item->GetGUID()); // Guid data << uint32(10); // Error! SendDirectMessage(&data); @@ -26067,19 +26120,19 @@ void Player::RefundItem(Item* item) store_error = true; break; } - } + } } if (store_error) { - WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8+4); + WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4); data << uint64(item->GetGUID()); // Guid data << uint32(10); // Error! SendDirectMessage(&data); return; } - WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8+4+4+4+4+4*4+4*4); + WorldPacket data(SMSG_ITEM_REFUND_RESULT, 8 + 4 + 4 + 4 + 4 + 4 * 4 + 4 * 4); data << uint64(item->GetGUID()); // item guid data << uint32(0); // 0, or error code data << uint32(item->GetPaidMoney()); // money cost @@ -26147,7 +26200,8 @@ void Player::SendItemRetrievalMail(uint32 itemEntry, uint32 count) CharacterDatabase.CommitTransaction(trans); //sMailMgr->SendMailWithItemsBy(ObjectGuid::LowType sender, ObjectGuid::LowType receiver, uint8 m_messageType, std::string const& subject, std::string const& body, uint32 money, std::list const& itemlist, MailCheckMask mask, uint32 deliver_delay, uint32 COD); - sMailMgr->SendMailWithItemsByGUID(34337, this->GetGUID().GetCounter(), MAIL_CREATURE, "Recovered Item", "We recovered a lost item in the twisting nether and noted that it was yours.$B$BPlease find said object enclosed.", 0, maillist); + sMailMgr->SendMailWithItemsByGUID(34337, this->GetGUID().GetCounter(), MAIL_CREATURE, "Recovered Item", + "We recovered a lost item in the twisting nether and noted that it was yours.$B$BPlease find said object enclosed.", 0, maillist); maillist.clear(); } @@ -26214,7 +26268,7 @@ void Player::_LoadPetStable(uint8 petStableSlots, PreparedQueryResult result) if (m_petStable->MaxStabledPets > MAX_PET_STABLES) { LOG_ERROR("entities.player", "Player::LoadFromDB: Player (%s) can't have more stable slots than %u, but has %u in DB", - GetGUID().ToString().c_str(), MAX_PET_STABLES, m_petStable->MaxStabledPets); + GetGUID().ToString().c_str(), MAX_PET_STABLES, m_petStable->MaxStabledPets); m_petStable->MaxStabledPets = MAX_PET_STABLES; } @@ -26453,7 +26507,8 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy pet->Relocate(x, y, z, ang); if (!pet->IsPositionValid()) { - LOG_ERROR("misc", "Player::SummonPet: Pet (%s, Entry: %d) not summoned. Suggested coordinates aren't valid (X: %f Y: %f)", pet->GetGUID().ToString().c_str(), pet->GetEntry(), pet->GetPositionX(), pet->GetPositionY()); + LOG_ERROR("misc", "Player::SummonPet: Pet (%s, Entry: %d) not summoned. Suggested coordinates aren't valid (X: %f Y: %f)", pet->GetGUID().ToString().c_str(), pet->GetEntry(), pet->GetPositionX(), + pet->GetPositionY()); delete pet; return nullptr; } @@ -26478,18 +26533,18 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy switch (petType) { - case SUMMON_PET: - // 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->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 - break; - default: - break; + case SUMMON_PET: + // 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->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 + break; + default: + break; } map->AddToMap(pet->ToCreature()); @@ -26499,14 +26554,14 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy switch (petType) { - case SUMMON_PET: - pet->InitPetCreateSpells(); - pet->InitTalentForLevel(); - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - PetSpellInitialize(); - break; - default: - break; + case SUMMON_PET: + pet->InitPetCreateSpells(); + pet->InitTalentForLevel(); + pet->SavePetToDB(PET_SAVE_AS_CURRENT); + PetSpellInitialize(); + break; + default: + break; } if (petType == SUMMON_PET) @@ -26542,7 +26597,7 @@ void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const bool Player::ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create /*=false*/) { - auto validateCharSection = [class_, create](CharSectionsEntry const* entry) -> bool + auto validateCharSection = [class_, create](CharSectionsEntry const * entry) -> bool { if (!entry) return false; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 8cf7b85be9e50..9f04f43025cac 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -294,7 +294,7 @@ struct EnchantDuration { EnchantDuration() : item(nullptr), slot(MAX_ENCHANTMENT_SLOT), leftduration(0) { } EnchantDuration(Item* _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot), - leftduration(_leftduration){ ASSERT(item); } + leftduration(_leftduration) { ASSERT(item); } Item* item; EnchantmentSlot slot; @@ -779,7 +779,7 @@ enum CharDeleteMethod { CHAR_DELETE_REMOVE = 0, // Completely remove from the database CHAR_DELETE_UNLINK = 1 // The character gets unlinked from the account, - // the name gets freed up and appears as deleted ingame + // the name gets freed up and appears as deleted ingame }; enum CurrencyItems @@ -832,7 +832,7 @@ struct BGData bgTeam(0), mountSpell(0) { ClearTaxiPath(); } uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID, - /// when player is teleported to BG - (it is battleground's GUID) + /// when player is teleported to BG - (it is battleground's GUID) BattlegroundTypeId bgTypeID; std::set bgAfkReporter; @@ -880,1623 +880,1625 @@ class WH_GAME_API Player : public Unit, public GridObject friend class CinematicMgr; friend void AddItemToUpdateQueueOf(Item* item, Player* player); friend void RemoveItemFromUpdateQueueOf(Item* item, Player* player); - public: - explicit Player(WorldSession* session); - ~Player(); - - PlayerAI* AI() const { return reinterpret_cast(GetAI()); } - - void CleanupsBeforeDelete(bool finalCleanup = true) override; - - void AddToWorld() override; - void RemoveFromWorld() override; - - void SetObjectScale(float scale) override; - - bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); - bool TeleportTo(WorldLocation const& loc, uint32 options = 0); - bool TeleportToBGEntryPoint(); - - bool HasSummonPending() const; - void SendSummonRequestFrom(Unit* summoner); - void SummonIfPossible(bool agree); - - bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo); - - void Update(uint32 time) override; - - static bool BuildEnumData(PreparedQueryResult result, WorldPacket* data); - - bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const override; - - void SetInWater(bool apply); - - bool IsInWater() const override { return m_isInWater; } - bool IsFalling() { return GetPositionZ() < m_lastFallZ; } - bool IsInAreaTriggerRadius(AreaTriggerEntry const* trigger) const; - - void SendInitialPacketsBeforeAddToMap(); - void SendInitialPacketsAfterAddToMap(); - void SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const; - void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0) const; - void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome) const; - - bool CanInteractWithQuestGiver(Object* questGiver) const; - Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask) const; - GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid) const; - GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid, GameobjectTypes type) const; - - void ToggleAFK(); - void ToggleDND(); - bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); } - bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); } - uint8 GetChatTag() const; - std::string autoReplyMsg; - - uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin = nullptr) const; - - PlayerSocial* GetSocial() { return m_social; } - void RemoveSocial(); - - PlayerTaxi m_taxi; - void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(GetRace(), GetClass(), GetLevel()); } - bool ActivateTaxiPathTo(std::vector const& nodes, Creature* npc = nullptr, uint32 spellid = 0); - bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0); - void FinishTaxiFlight(); - void CleanupAfterTaxiFlight(); - void ContinueTaxiFlight() const; - void SendTaxiNodeStatusMultiple(); - - bool IsDeveloper() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); } - void SetDeveloper(bool on) { ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER, on); } - bool isAcceptWhispers() const { return (m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS) != 0; } - void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } - bool IsGameMaster() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_ON) != 0; } - bool IsGameMasterAcceptingWhispers() const { return IsGameMaster() && isAcceptWhispers(); } - bool CanBeGameMaster() const; - void SetGameMaster(bool on); - bool isGMChat() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT) != 0; } - void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; } - bool isTaxiCheater() const { return (m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT) != 0; } - void SetTaxiCheater(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } - bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); } - void SetGMVisible(bool on); - bool Has310Flyer(bool checkAllSpells, uint32 excludeSpellId = 0); - void SetHas310Flyer(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_HAS_310_FLYER; else m_ExtraFlags &= ~PLAYER_EXTRA_HAS_310_FLYER; } - void SetPvPDeath(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } - - uint32 GetXP() const { return GetUInt32Value(PLAYER_XP); } - void SetXP(uint32 xp) { SetUInt32Value(PLAYER_XP, xp); } - void GiveXP(uint32 xp, Unit* victim, float group_rate = 1.0f); - void GiveLevel(uint8 level); - bool IsMaxLevel() const; - - void InitStatsForLevel(bool reapplyMods = false); - - // .cheat command related - bool GetCommandStatus(uint32 command) const { return (_activeCheats & command) != 0; } - void SetCommandStatusOn(uint32 command) { _activeCheats |= command; } - void SetCommandStatusOff(uint32 command) { _activeCheats &= ~command; } - - // Played Time Stuff - time_t m_logintime; - time_t m_Last_tick; - uint32 m_Played_time[MAX_PLAYED_TIME_INDEX]; - 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); } - 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); } - void SetFaceId(uint8 face) { SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID, face); } - uint8 GetHairStyleId() const { return GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID); } - void SetHairStyleId(uint8 hairStyle) { SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID, hairStyle); } - uint8 GetHairColorId() const { return GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID); } - void SetHairColorId(uint8 hairColor) { SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID, hairColor); } - uint8 GetFacialStyle() const { return GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE); } - void SetFacialStyle(uint8 facialStyle) { SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE, facialStyle); } - - void setDeathState(DeathState s) override; // overwrite Unit::setDeathState - - float GetRestBonus() const { return m_rest_bonus; } - void SetRestBonus(float rest_bonus_new); - - uint8 GetRestState() const { return GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_REST_STATE); } - void SetRestState(uint8 restState) { SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_REST_STATE, restState); } - - bool HasRestFlag(RestFlag restFlag) const { return (_restFlagMask & restFlag) != 0; } - void SetRestFlag(RestFlag restFlag, uint32 triggerId = 0); - void RemoveRestFlag(RestFlag restFlag); - - uint32 GetXPRestBonus(uint32 xp); - uint32 GetInnTriggerId() const { return inn_triggerId; } - - PetStable* GetPetStable() { return m_petStable.get(); } - PetStable& GetOrInitPetStable(); - PetStable const* GetPetStable() const { return m_petStable.get(); } - - Pet* GetPet() const; - Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime); - void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); - uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn - - // pet auras - std::unordered_set m_petAuras; - void AddPetAura(PetAura const* petSpell); - void RemovePetAura(PetAura const* petSpell); - - /// Handles said message in regular chat based on declared language and in config pre-defined Range. - void Say(std::string_view text, Language language, WorldObject const* = nullptr) override; - void Say(uint32 textId, WorldObject const* target = nullptr) override; - /// Handles yelled message in regular chat based on declared language and in config pre-defined Range. - void Yell(std::string_view text, Language language, WorldObject const* = nullptr) override; - void Yell(uint32 textId, WorldObject const* target = nullptr) override; - /// Outputs an universal text which is supposed to be an action. - void TextEmote(std::string_view text, WorldObject const* = nullptr, bool = false) override; - void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false) override; - /// Handles whispers from Addons and players based on sender, receiver's guid and language. - void Whisper(std::string_view text, Language language, Player* receiver, bool = false) override; - void Whisper(uint32 textId, Player* target, bool isBossWhisper = false) override; - - /*********************************************************/ - /*** STORAGE SYSTEM ***/ - /*********************************************************/ - - void SetVirtualItemSlot(uint8 i, Item* item); - void SetSheath(SheathState sheathed) override; // overwrite Unit version - uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; - uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = nullptr) const; - uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const; - Item* GetItemByGuid(ObjectGuid guid) const; - Item* GetItemByEntry(uint32 entry) const; - Item* GetItemByPos(uint16 pos) const; - Item* GetItemByPos(uint8 bag, uint8 slot) const; - Item* GetUseableItemByPos(uint8 bag, uint8 slot) const; - Bag* GetBagByPos(uint8 slot) const; - uint32 GetFreeInventorySpace() const; - Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; - Item* GetShield(bool useable = false) const; - static WeaponAttackType GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot - std::vector& GetItemUpdateQueue() { return m_itemUpdateQueue; } - static bool IsInventoryPos(uint16 pos) { return IsInventoryPos(pos >> 8, pos & 255); } - static bool IsInventoryPos(uint8 bag, uint8 slot); - static bool IsEquipmentPos(uint16 pos) { return IsEquipmentPos(pos >> 8, pos & 255); } - static bool IsEquipmentPos(uint8 bag, uint8 slot); - static bool IsBagPos(uint16 pos); - static bool IsBankPos(uint16 pos) { return IsBankPos(pos >> 8, pos & 255); } - static bool IsBankPos(uint8 bag, uint8 slot); - bool IsValidPos(uint16 pos, bool explicit_pos) const { return IsValidPos(pos >> 8, pos & 255, explicit_pos); } - bool IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const; - uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_BANK_BAG_SLOTS); } - void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_BANK_BAG_SLOTS, count); } - bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const; - bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = nullptr) const; - bool CanNoReagentCast(SpellInfo const* spellInfo) const; - bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const; - bool HasItemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; - bool HasGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; - InventoryResult CanTakeMoreSimilarItems(Item* pItem, uint32* itemLimitCategory = nullptr) const; - InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, uint32* itemLimitCategory = nullptr) const { return CanTakeMoreSimilarItems(entry, count, nullptr, nullptr, itemLimitCategory); } - InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = nullptr) const; - InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const; - InventoryResult CanStoreItems(Item** items, int count, uint32* itemLimitCategory) const; - InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const; - InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const; - - InventoryResult CanEquipUniqueItem(Item* pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; - InventoryResult CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; - InventoryResult CanUnequipItems(uint32 item, uint32 count) const; - InventoryResult CanUnequipItem(uint16 src, bool swap) const; - InventoryResult CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading = true) const; - InventoryResult CanUseItem(Item* pItem, bool not_loading = true) const; - bool HasItemTotemCategory(uint32 TotemCategory) const; - InventoryResult CanUseItem(ItemTemplate const* pItem) const; - InventoryResult CanUseAmmo(uint32 item) const; - InventoryResult CanRollForItemInLFG(ItemTemplate const* item, WorldObject const* lootedObject) const; - Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0, GuidSet const& allowedLooters = GuidSet()); - Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update); - Item* EquipNewItem(uint16 pos, uint32 item, bool update); - Item* EquipItem(uint16 pos, Item* pItem, bool update); - void AutoUnequipOffhandIfNeed(bool force = false); - bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count); - void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false, bool createdByPlayer = false); - void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false, bool createdByPlayer = false) { AutoStoreLoot(NULL_BAG, NULL_SLOT, loot_id, store, broadcast, createdByPlayer); } - void StoreLootItem(uint8 lootSlot, Loot* loot); - - InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = nullptr, uint32* itemLimitCategory = nullptr) const; - InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = nullptr, bool swap = false, uint32* no_space_count = nullptr) const; - - void AddRefundReference(ObjectGuid it); - void DeleteRefundReference(ObjectGuid it); - - void ApplyEquipCooldown(Item* pItem); - void SetAmmo(uint32 item); - void RemoveAmmo(); - float GetAmmoDPS() const { return m_ammoDPS; } - bool CheckAmmoCompatibility(ItemTemplate const* ammo_proto) const; - void QuickEquipItem(uint16 pos, Item* pItem); - void VisualizeItem(uint8 slot, Item* pItem); - void SetVisibleItemSlot(uint8 slot, Item* pItem); - Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update); - void RemoveItem(uint8 bag, uint8 slot, bool update); - void MoveItemFromInventory(uint8 bag, uint8 slot, bool update); - // in trade, auction, guild bank, mail.... - void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false); - // in trade, guild bank, mail.... - void RemoveItemDependentAurasAndCasts(Item* pItem); - void DestroyItem(uint8 bag, uint8 slot, bool update); - uint32 DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check = false); - void DestroyItemCount(Item* item, uint32& count, bool update); - void DestroyConjuredItems(bool update); - void DestroyZoneLimitedItem(bool update, uint32 new_zone); - void SplitItem(uint16 src, uint16 dst, uint32 count); - void SwapItem(uint16 src, uint16 dst); - void AddItemToBuyBackSlot(Item* pItem); - Item* GetItemFromBuyBackSlot(uint32 slot); - void RemoveItemFromBuyBackSlot(uint32 slot, bool del); - uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; } - void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = nullptr, uint32 itemid = 0) const; - void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param) const; - void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param) const; - void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } - void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } - uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } - uint32 GetArmorProficiency() const { return m_ArmorProficiency; } - bool IsUseEquipedWeapon(bool mainhand) const; - bool IsTwoHandUsed() const; - bool IsUsingTwoHandedWeaponInOneHand() const; - void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false, bool sendChatMessage = true); - bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); - bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore); - - float GetReputationPriceDiscount(Creature const* creature) const; - float GetReputationPriceDiscount(FactionTemplateEntry const* factionTemplate) const; - - Player* GetTrader() const; - TradeData* GetTradeData() const { return m_trade; } - void TradeCancel(bool sendback); - - CinematicMgr* GetCinematicMgr() const { return _cinematicMgr; } - - void UpdateEnchantTime(uint32 time); - void UpdateSoulboundTradeItems(); - void AddTradeableItem(Item* item); - void RemoveTradeableItem(Item* item); - void UpdateItemDuration(uint32 time, bool realtimeonly = false); - void AddEnchantmentDurations(Item* item); - void RemoveEnchantmentDurations(Item* item); - void RemoveEnchantmentDurationsReferences(Item* item); - void RemoveArenaEnchantments(EnchantmentSlot slot); - void AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 duration); - void ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool apply_dur = true, bool ignore_condition = false); - void ApplyEnchantment(Item* item, bool apply); - void UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 new_value); - void SendEnchantmentDurations(); - void BuildEnchantmentsInfoData(WorldPacket* data); - void AddItemDurations(Item* item); - void RemoveItemDurations(Item* item); - void SendItemDurations(); - void LoadCorpse(PreparedQueryResult result); - void LoadPet(); - - bool AddItem(uint32 itemId, uint32 count); - - /*********************************************************/ - /*** GOSSIP SYSTEM ***/ - /*********************************************************/ - - void PrepareGossipMenu(WorldObject* source, uint32 menuId = 0, bool showQuests = false); - void SendPreparedGossip(WorldObject* source); - void OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 menuId); - - uint32 GetGossipTextId(uint32 menuId, WorldObject* source); - uint32 GetGossipTextId(WorldObject* source); - static uint32 GetDefaultGossipMenuForSource(WorldObject* source); - - /*********************************************************/ - /*** QUEST SYSTEM ***/ - /*********************************************************/ - - int32 GetQuestLevel(Quest const* quest) const { return quest && (quest->GetQuestLevel() > 0) ? quest->GetQuestLevel() : GetLevel(); } - - void PrepareQuestMenu(ObjectGuid guid); - void SendPreparedQuest(ObjectGuid guid); - bool IsActiveQuest(uint32 quest_id) const; - Quest const* GetNextQuest(ObjectGuid guid, Quest const* quest) const; - bool CanSeeStartQuest(Quest const* quest) const; - bool CanTakeQuest(Quest const* quest, bool msg) const; - bool CanAddQuest(Quest const* quest, bool msg) const; - bool CanCompleteQuest(uint32 quest_id); - bool CanCompleteRepeatableQuest(Quest const* quest); - bool CanRewardQuest(Quest const* quest, bool msg); - bool CanRewardQuest(Quest const* quest, uint32 reward, bool msg); - void AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver); - void AddQuest(Quest const* quest, Object* questGiver); - void AbandonQuest(uint32 quest_id); - void CompleteQuest(uint32 quest_id); - void IncompleteQuest(uint32 quest_id); - void RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool announce = true); - void SetRewardedQuest(uint32 quest_id); - void FailQuest(uint32 quest_id); - bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const; - bool SatisfyQuestLevel(Quest const* qInfo, bool msg) const; - bool SatisfyQuestLog(bool msg) const; - bool SatisfyQuestDependentQuests(Quest const* qInfo, bool msg) const; - bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const; - bool SatisfyQuestDependentPreviousQuests(Quest const* qInfo, bool msg) const; - bool SatisfyQuestBreadcrumbQuest(Quest const* qInfo, bool msg) const; - bool SatisfyQuestDependentBreadcrumbQuests(Quest const* qInfo, bool msg) const; - bool SatisfyQuestClass(Quest const* qInfo, bool msg) const; - bool SatisfyQuestRace(Quest const* qInfo, bool msg) const; - bool SatisfyQuestReputation(Quest const* qInfo, bool msg) const; - bool SatisfyQuestStatus(Quest const* qInfo, bool msg) const; - bool SatisfyQuestConditions(Quest const* qInfo, bool msg) const; - bool SatisfyQuestTimed(Quest const* qInfo, bool msg) const; - bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const; - bool SatisfyQuestDay(Quest const* qInfo, bool msg) const; - bool SatisfyQuestWeek(Quest const* qInfo, bool msg) const; - bool SatisfyQuestMonth(Quest const* qInfo, bool msg) const; - bool SatisfyQuestSeasonal(Quest const* qInfo, bool msg) const; - bool GiveQuestSourceItem(Quest const* quest); - bool TakeQuestSourceItem(uint32 questId, bool msg); - bool GetQuestRewardStatus(uint32 quest_id) const; - QuestStatus GetQuestStatus(uint32 quest_id) const; - void SetQuestStatus(uint32 questId, QuestStatus status, bool update = true); - void RemoveActiveQuest(uint32 questId, bool update = true); - void RemoveRewardedQuest(uint32 questId, bool update = true); - void SendQuestUpdate(uint32 questId); - QuestGiverStatus GetQuestDialogStatus(Object* questGiver); - - void SetDailyQuestStatus(uint32 quest_id); - bool IsDailyQuestDone(uint32 quest_id); - void SetWeeklyQuestStatus(uint32 quest_id); - void SetMonthlyQuestStatus(uint32 quest_id); - void SetSeasonalQuestStatus(uint32 quest_id); - void ResetDailyQuestStatus(); - void ResetWeeklyQuestStatus(); - void ResetMonthlyQuestStatus(); - void ResetSeasonalQuestStatus(uint16 event_id); - - uint16 FindQuestSlot(uint32 quest_id) const; - uint32 GetQuestSlotQuestId(uint16 slot) const; - uint32 GetQuestSlotState(uint16 slot) const; - uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const; - uint32 GetQuestSlotTime(uint16 slot) const; - void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0); - void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count); - void SetQuestSlotState(uint16 slot, uint32 state); - void RemoveQuestSlotState(uint16 slot, uint32 state); - void SetQuestSlotTimer(uint16 slot, uint32 timer); - void SwapQuestSlot(uint16 slot1, uint16 slot2); - - uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) const; - void AreaExploredOrEventHappens(uint32 questId); - void GroupEventHappens(uint32 questId, WorldObject const* pEventObject); - void ItemAddedQuestCheck(uint32 entry, uint32 count); - void ItemRemovedQuestCheck(uint32 entry, uint32 count); - void KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid); - void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); - void KilledPlayerCredit(uint16 count = 1); - void KilledPlayerCreditForQuest(uint16 count, Quest const* quest); - void KillCreditGO(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); - void TalkedToCreature(uint32 entry, ObjectGuid guid); - void MoneyChanged(uint32 value); - void ReputationChanged(FactionEntry const* factionEntry); - void ReputationChanged2(FactionEntry const* factionEntry); - bool HasQuestForItem(uint32 itemId, uint32 excludeQuestId = 0, bool turnIn = false) const; - bool HasQuestForGO(int32 goId) const; - void UpdateVisibleGameobjectsOrSpellClicks(); - bool CanShareQuest(uint32 questId) const; - - void SendQuestComplete(uint32 questId) const; - void SendQuestReward(Quest const* quest, uint32 XP) const; - void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK) const; - void SendQuestTimerFailed(uint32 questId) const; - void SendCanTakeQuestResponse(QuestFailedReason msg) const; - void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver) const; - void SendPushToPartyResponse(Player const* player, QuestShareMessages msg) const; - void SendQuestUpdateAddItem(Quest const* quest, uint32 itemIdx, uint16 count) const; - void SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGOIdx, uint16 oldCount, uint16 addCount); - void SendQuestUpdateAddPlayer(Quest const* quest, uint16 oldCount, uint16 addCount); - void SendQuestGiverStatusMultiple(); - - uint32 GetSharedQuestID() const { return m_sharedQuestId; } - ObjectGuid GetPlayerSharingQuest() const { return m_playerSharingQuest; } - void SetQuestSharingInfo(ObjectGuid guid, uint32 id) { m_playerSharingQuest = guid; m_sharedQuestId = id; } - void ClearQuestSharingInfo() { m_playerSharingQuest = ObjectGuid::Empty; m_sharedQuestId = 0; } - - uint32 GetInGameTime() const { return m_ingametime; } - void SetInGameTime(uint32 time) { m_ingametime = time; } - - void AddTimedQuest(uint32 questId) { m_timedquests.insert(questId); } - void RemoveTimedQuest(uint32 questId) { m_timedquests.erase(questId); } - - bool HasPvPForcingQuest() const; - - /*********************************************************/ - /*** LOAD SYSTEM ***/ - /*********************************************************/ - - bool LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& holder); - bool IsLoading() const override; - - void Initialize(ObjectGuid::LowType guid); - static uint32 GetZoneIdFromDB(ObjectGuid guid); - static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid); - - static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; } - static bool ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create = false); - - /*********************************************************/ - /*** SAVE SYSTEM ***/ - /*********************************************************/ - - void SaveToDB(bool create = false); - void SaveToDB(CharacterDatabaseTransaction trans, bool create = false); - void SaveInventoryAndGoldToDB(CharacterDatabaseTransaction trans); // fast save function for item/money cheating preventing - void SaveGoldToDB(CharacterDatabaseTransaction trans) const; - - static void Customize(CharacterCustomizeInfo const* customizeInfo, CharacterDatabaseTransaction trans); - static void SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGuid guid, CharacterDatabaseTransaction trans); - - static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); - static void DeleteOldCharacters(); - static void DeleteOldCharacters(uint32 keepDays); - - void SetBindPoint(ObjectGuid guid) const; - void SendTalentWipeConfirm(ObjectGuid guid) const; - void ResetPetTalents(); - void RegenerateAll(); - void Regenerate(Powers power); - void RegenerateHealth(); - void setRegenTimerCount(uint32 time) {m_regenTimerCount = time;} - void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;} - - uint32 GetMoney() const { return GetUInt32Value(PLAYER_FIELD_COINAGE); } - bool ModifyMoney(int32 amount, bool sendError = true); - bool HasEnoughMoney(uint32 amount) const { return (GetMoney() >= amount); } - bool HasEnoughMoney(int32 amount) const { return (amount < 0) || HasEnoughMoney(uint32(amount)); } - void SetMoney(uint32 value); - - RewardedQuestSet const& getRewardedQuests() const { return m_RewardedQuests; } - QuestStatusMap& getQuestStatusMap() { return m_QuestStatus; } - - size_t GetRewardedQuestCount() const { return m_RewardedQuests.size(); } - bool IsQuestRewarded(uint32 quest_id) const; - - Unit* GetSelectedUnit() const; - Player* GetSelectedPlayer() const; - - void SetTarget(ObjectGuid /*guid*/) override { } /// Used for serverside target changes, does not apply to players - void SetSelection(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_TARGET, guid); } - - void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0) const; - void SendNewMail() const; - void UpdateNextMailTimeAndUnreads(); - void AddNewMailDeliverTime(time_t deliver_time); - - void SendItemRetrievalMail(uint32 itemEntry, uint32 count); // Item retrieval mails sent by The Postmaster (34337), used in multiple places. - /*********************************************************/ - /*** MAILED ITEMS SYSTEM ***/ - /*********************************************************/ - - uint32 unReadMails; - time_t m_nextMailDelivereTime; - - void SendOnCancelExpectedVehicleRideAura() const; - void PetSpellInitialize(); - void CharmSpellInitialize(); - void PossessSpellInitialize(); - void VehicleSpellInitialize(); - void SendRemoveControlBar() const; - bool HasSpell(uint32 spell) const override; - bool HasActiveSpell(uint32 spell) const; // show in spellbook - bool IsSpellFitByClassAndRace(uint32 spell_id) const; - bool HandlePassiveSpellLearn(SpellInfo const* spellInfo); - - void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const; - void SendInitialSpells(); - void SendUnlearnSpells(); - bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint32 fromSkill = 0); - void LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill = 0); - void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true); - void ResetSpells(bool myClassOnly = false); - void LearnCustomSpells(); - void LearnDefaultSkills(); - void LearnDefaultSkill(uint32 skillId, uint16 rank); - void LearnQuestRewardedSpells(); - void LearnQuestRewardedSpells(Quest const* quest); - void AddTemporarySpell(uint32 spellId); - void RemoveTemporarySpell(uint32 spellId); - void SetReputation(uint32 factionentry, uint32 value); - uint32 GetReputation(uint32 factionentry) const; - std::string const& GetGuildName() const; - uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } - void SetFreeTalentPoints(uint32 points); - bool ResetTalents(bool no_cost = false); - uint32 ResetTalentsCost() const; - void InitTalentForLevel(); - void BuildPlayerTalentsInfoData(WorldPacket* data); - void BuildPetTalentsInfoData(WorldPacket* data); - void SendTalentsInfoData(bool pet); - void LearnTalent(uint32 talentId, uint32 talentRank); - void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank); - void SendTameFailure(uint8 result); - - bool AddTalent(uint32 spellId, uint8 spec, bool learning); - bool HasTalent(uint32 spell_id, uint8 spec) const; - - uint32 CalculateTalentsPoints() const; - - // Dual Spec - void UpdateSpecCount(uint8 count); - uint32 GetActiveSpec() const { return m_activeSpec; } - void SetActiveSpec(uint8 spec){ m_activeSpec = spec; } - uint8 GetSpecsCount() const { return m_specsCount; } - void SetSpecsCount(uint8 count) { m_specsCount = count; } - void ActivateSpec(uint8 spec); - void LoadActions(PreparedQueryResult result); - - void InitGlyphsForLevel(); - void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); } - uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); } - void SetGlyph(uint8 slot, uint32 glyph); - uint32 GetGlyph(uint8 slot) { return m_Glyphs[m_activeSpec][slot]; } - - uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); } - void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2, profs); } - void InitPrimaryProfessions(); - - PlayerSpellMap const& GetSpellMap() const { return m_spells; } - PlayerSpellMap & GetSpellMap() { return m_spells; } - - void AddSpellMod(SpellModifier* mod, bool apply); - static bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = nullptr); - template - void ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* spell = nullptr) const; - static void ApplyModToSpell(SpellModifier* mod, Spell* spell); - static bool HasSpellModApplied(SpellModifier* mod, Spell* spell); - void SetSpellModTakingSpell(Spell* spell, bool apply); - - void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false); - uint32 GetLastPotionId() const { return m_lastPotionId; } - void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } - void UpdatePotionCooldown(Spell* spell = nullptr); - - void SetResurrectRequestData(WorldObject const* caster, uint32 health, uint32 mana, uint32 appliedAura); - - void ClearResurrectRequestData() - { - _resurrectionData.reset(); - } - - bool IsResurrectRequestedBy(ObjectGuid const& guid) const - { - if (!IsResurrectRequested()) - return false; - - return !_resurrectionData->GUID.IsEmpty() && _resurrectionData->GUID == guid; - } +public: + explicit Player(WorldSession* session); + ~Player(); + + PlayerAI* AI() const { return reinterpret_cast(GetAI()); } + + void CleanupsBeforeDelete(bool finalCleanup = true) override; + + void AddToWorld() override; + void RemoveFromWorld() override; + + void SetObjectScale(float scale) override; + + bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); + bool TeleportTo(WorldLocation const& loc, uint32 options = 0); + bool TeleportToBGEntryPoint(); + + bool HasSummonPending() const; + void SendSummonRequestFrom(Unit* summoner); + void SummonIfPossible(bool agree); + + bool Create(ObjectGuid::LowType guidlow, CharacterCreateInfo* createInfo); + + void Update(uint32 time) override; + + static bool BuildEnumData(PreparedQueryResult result, WorldPacket* data); + + bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const override; + + void SetInWater(bool apply); + + bool IsInWater() const override { return m_isInWater; } + bool IsFalling() { return GetPositionZ() < m_lastFallZ; } + bool IsInAreaTriggerRadius(AreaTriggerEntry const* trigger) const; + + void SendInitialPacketsBeforeAddToMap(); + void SendInitialPacketsAfterAddToMap(); + void SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const; + void SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 arg = 0) const; + void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome) const; + + bool CanInteractWithQuestGiver(Object* questGiver) const; + Creature* GetNPCIfCanInteractWith(ObjectGuid const& guid, uint32 npcflagmask) const; + GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid) const; + GameObject* GetGameObjectIfCanInteractWith(ObjectGuid const& guid, GameobjectTypes type) const; + + void ToggleAFK(); + void ToggleDND(); + bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); } + bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); } + uint8 GetChatTag() const; + std::string autoReplyMsg; + + uint32 GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair, BarberShopStyleEntry const* newSkin = nullptr) const; + + PlayerSocial* GetSocial() { return m_social; } + void RemoveSocial(); + + PlayerTaxi m_taxi; + void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(GetRace(), GetClass(), GetLevel()); } + bool ActivateTaxiPathTo(std::vector const& nodes, Creature* npc = nullptr, uint32 spellid = 0); + bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0); + void FinishTaxiFlight(); + void CleanupAfterTaxiFlight(); + void ContinueTaxiFlight() const; + void SendTaxiNodeStatusMultiple(); + + bool IsDeveloper() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER); } + void SetDeveloper(bool on) { ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER, on); } + bool isAcceptWhispers() const { return (m_ExtraFlags & PLAYER_EXTRA_ACCEPT_WHISPERS) != 0; } + void SetAcceptWhispers(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_ACCEPT_WHISPERS; else m_ExtraFlags &= ~PLAYER_EXTRA_ACCEPT_WHISPERS; } + bool IsGameMaster() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_ON) != 0; } + bool IsGameMasterAcceptingWhispers() const { return IsGameMaster() && isAcceptWhispers(); } + bool CanBeGameMaster() const; + void SetGameMaster(bool on); + bool isGMChat() const { return (m_ExtraFlags & PLAYER_EXTRA_GM_CHAT) != 0; } + void SetGMChat(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_GM_CHAT; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_CHAT; } + bool isTaxiCheater() const { return (m_ExtraFlags & PLAYER_EXTRA_TAXICHEAT) != 0; } + void SetTaxiCheater(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; else m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } + bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); } + void SetGMVisible(bool on); + bool Has310Flyer(bool checkAllSpells, uint32 excludeSpellId = 0); + void SetHas310Flyer(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_HAS_310_FLYER; else m_ExtraFlags &= ~PLAYER_EXTRA_HAS_310_FLYER; } + void SetPvPDeath(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } + + uint32 GetXP() const { return GetUInt32Value(PLAYER_XP); } + void SetXP(uint32 xp) { SetUInt32Value(PLAYER_XP, xp); } + void GiveXP(uint32 xp, Unit* victim, float group_rate = 1.0f); + void GiveLevel(uint8 level); + bool IsMaxLevel() const; + + void InitStatsForLevel(bool reapplyMods = false); + + // .cheat command related + bool GetCommandStatus(uint32 command) const { return (_activeCheats & command) != 0; } + void SetCommandStatusOn(uint32 command) { _activeCheats |= command; } + void SetCommandStatusOff(uint32 command) { _activeCheats &= ~command; } + + // Played Time Stuff + time_t m_logintime; + time_t m_Last_tick; + uint32 m_Played_time[MAX_PLAYED_TIME_INDEX]; + 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); } + 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); } + void SetFaceId(uint8 face) { SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID, face); } + uint8 GetHairStyleId() const { return GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID); } + void SetHairStyleId(uint8 hairStyle) { SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID, hairStyle); } + uint8 GetHairColorId() const { return GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID); } + void SetHairColorId(uint8 hairColor) { SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID, hairColor); } + uint8 GetFacialStyle() const { return GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE); } + void SetFacialStyle(uint8 facialStyle) { SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE, facialStyle); } + + void setDeathState(DeathState s) override; // overwrite Unit::setDeathState + + float GetRestBonus() const { return m_rest_bonus; } + void SetRestBonus(float rest_bonus_new); + + uint8 GetRestState() const { return GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_REST_STATE); } + void SetRestState(uint8 restState) { SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_REST_STATE, restState); } + + bool HasRestFlag(RestFlag restFlag) const { return (_restFlagMask & restFlag) != 0; } + void SetRestFlag(RestFlag restFlag, uint32 triggerId = 0); + void RemoveRestFlag(RestFlag restFlag); + + uint32 GetXPRestBonus(uint32 xp); + uint32 GetInnTriggerId() const { return inn_triggerId; } + + PetStable* GetPetStable() { return m_petStable.get(); } + PetStable& GetOrInitPetStable(); + PetStable const* GetPetStable() const { return m_petStable.get(); } + + Pet* GetPet() const; + Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime); + void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false); + uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn + + // pet auras + std::unordered_set m_petAuras; + void AddPetAura(PetAura const* petSpell); + void RemovePetAura(PetAura const* petSpell); + + /// Handles said message in regular chat based on declared language and in config pre-defined Range. + void Say(std::string_view text, Language language, WorldObject const* = nullptr) override; + void Say(uint32 textId, WorldObject const* target = nullptr) override; + /// Handles yelled message in regular chat based on declared language and in config pre-defined Range. + void Yell(std::string_view text, Language language, WorldObject const* = nullptr) override; + void Yell(uint32 textId, WorldObject const* target = nullptr) override; + /// Outputs an universal text which is supposed to be an action. + void TextEmote(std::string_view text, WorldObject const* = nullptr, bool = false) override; + void TextEmote(uint32 textId, WorldObject const* target = nullptr, bool isBossEmote = false) override; + /// Handles whispers from Addons and players based on sender, receiver's guid and language. + void Whisper(std::string_view text, Language language, Player* receiver, bool = false) override; + void Whisper(uint32 textId, Player* target, bool isBossWhisper = false) override; + + /*********************************************************/ + /*** STORAGE SYSTEM ***/ + /*********************************************************/ + + void SetVirtualItemSlot(uint8 i, Item* item); + void SetSheath(SheathState sheathed) override; // overwrite Unit version + uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; + uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = nullptr) const; + uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const; + Item* GetItemByGuid(ObjectGuid guid) const; + Item* GetItemByEntry(uint32 entry) const; + Item* GetItemByPos(uint16 pos) const; + Item* GetItemByPos(uint8 bag, uint8 slot) const; + Item* GetUseableItemByPos(uint8 bag, uint8 slot) const; + Bag* GetBagByPos(uint8 slot) const; + uint32 GetFreeInventorySpace() const; + Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; + Item* GetShield(bool useable = false) const; + static WeaponAttackType GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot + std::vector& GetItemUpdateQueue() { return m_itemUpdateQueue; } + static bool IsInventoryPos(uint16 pos) { return IsInventoryPos(pos >> 8, pos & 255); } + static bool IsInventoryPos(uint8 bag, uint8 slot); + static bool IsEquipmentPos(uint16 pos) { return IsEquipmentPos(pos >> 8, pos & 255); } + static bool IsEquipmentPos(uint8 bag, uint8 slot); + static bool IsBagPos(uint16 pos); + static bool IsBankPos(uint16 pos) { return IsBankPos(pos >> 8, pos & 255); } + static bool IsBankPos(uint8 bag, uint8 slot); + bool IsValidPos(uint16 pos, bool explicit_pos) const { return IsValidPos(pos >> 8, pos & 255, explicit_pos); } + bool IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const; + uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_BANK_BAG_SLOTS); } + void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_BANK_BAG_SLOTS, count); } + bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const; + bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = nullptr) const; + bool CanNoReagentCast(SpellInfo const* spellInfo) const; + bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const; + bool HasItemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; + bool HasGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; + InventoryResult CanTakeMoreSimilarItems(Item* pItem, uint32* itemLimitCategory = nullptr) const; + InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, uint32* itemLimitCategory = nullptr) const { return CanTakeMoreSimilarItems(entry, count, nullptr, nullptr, itemLimitCategory); } + InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = nullptr) const; + InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const; + InventoryResult CanStoreItems(Item** items, int count, uint32* itemLimitCategory) const; + InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const; + InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const; + + InventoryResult CanEquipUniqueItem(Item* pItem, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; + InventoryResult CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 except_slot = NULL_SLOT, uint32 limit_count = 1) const; + InventoryResult CanUnequipItems(uint32 item, uint32 count) const; + InventoryResult CanUnequipItem(uint16 src, bool swap) const; + InventoryResult CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading = true) const; + InventoryResult CanUseItem(Item* pItem, bool not_loading = true) const; + bool HasItemTotemCategory(uint32 TotemCategory) const; + InventoryResult CanUseItem(ItemTemplate const* pItem) const; + InventoryResult CanUseAmmo(uint32 item) const; + InventoryResult CanRollForItemInLFG(ItemTemplate const* item, WorldObject const* lootedObject) const; + Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0, GuidSet const& allowedLooters = GuidSet()); + Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update); + Item* EquipNewItem(uint16 pos, uint32 item, bool update); + Item* EquipItem(uint16 pos, Item* pItem, bool update); + void AutoUnequipOffhandIfNeed(bool force = false); + bool StoreNewItemInBestSlots(uint32 item_id, uint32 item_count); + void AutoStoreLoot(uint8 bag, uint8 slot, uint32 loot_id, LootStore const& store, bool broadcast = false, bool createdByPlayer = false); + void AutoStoreLoot(uint32 loot_id, LootStore const& store, bool broadcast = false, bool createdByPlayer = false) { AutoStoreLoot(NULL_BAG, NULL_SLOT, loot_id, store, broadcast, createdByPlayer); } + void StoreLootItem(uint8 lootSlot, Loot* loot); + + InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = nullptr, uint32* itemLimitCategory = nullptr) const; + InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = nullptr, bool swap = false, uint32* no_space_count = nullptr) const; + + void AddRefundReference(ObjectGuid it); + void DeleteRefundReference(ObjectGuid it); + + void ApplyEquipCooldown(Item* pItem); + void SetAmmo(uint32 item); + void RemoveAmmo(); + float GetAmmoDPS() const { return m_ammoDPS; } + bool CheckAmmoCompatibility(ItemTemplate const* ammo_proto) const; + void QuickEquipItem(uint16 pos, Item* pItem); + void VisualizeItem(uint8 slot, Item* pItem); + void SetVisibleItemSlot(uint8 slot, Item* pItem); + Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update); + void RemoveItem(uint8 bag, uint8 slot, bool update); + void MoveItemFromInventory(uint8 bag, uint8 slot, bool update); + // in trade, auction, guild bank, mail.... + void MoveItemToInventory(ItemPosCountVec const& dest, Item* pItem, bool update, bool in_characterInventoryDB = false); + // in trade, guild bank, mail.... + void RemoveItemDependentAurasAndCasts(Item* pItem); + void DestroyItem(uint8 bag, uint8 slot, bool update); + uint32 DestroyItemCount(uint32 item, uint32 count, bool update, bool unequip_check = false); + void DestroyItemCount(Item* item, uint32& count, bool update); + void DestroyConjuredItems(bool update); + void DestroyZoneLimitedItem(bool update, uint32 new_zone); + void SplitItem(uint16 src, uint16 dst, uint32 count); + void SwapItem(uint16 src, uint16 dst); + void AddItemToBuyBackSlot(Item* pItem); + Item* GetItemFromBuyBackSlot(uint32 slot); + void RemoveItemFromBuyBackSlot(uint32 slot, bool del); + uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END - KEYRING_SLOT_START; } + void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = nullptr, uint32 itemid = 0) const; + void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param) const; + void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param) const; + void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } + void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } + uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } + uint32 GetArmorProficiency() const { return m_ArmorProficiency; } + bool IsUseEquipedWeapon(bool mainhand) const; + bool IsTwoHandUsed() const; + bool IsUsingTwoHandedWeaponInOneHand() const; + void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false, bool sendChatMessage = true); + bool BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); + bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore); + + float GetReputationPriceDiscount(Creature const* creature) const; + float GetReputationPriceDiscount(FactionTemplateEntry const* factionTemplate) const; + + Player* GetTrader() const; + TradeData* GetTradeData() const { return m_trade; } + void TradeCancel(bool sendback); + + CinematicMgr* GetCinematicMgr() const { return _cinematicMgr; } + + void UpdateEnchantTime(uint32 time); + void UpdateSoulboundTradeItems(); + void AddTradeableItem(Item* item); + void RemoveTradeableItem(Item* item); + void UpdateItemDuration(uint32 time, bool realtimeonly = false); + void AddEnchantmentDurations(Item* item); + void RemoveEnchantmentDurations(Item* item); + void RemoveEnchantmentDurationsReferences(Item* item); + void RemoveArenaEnchantments(EnchantmentSlot slot); + void AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 duration); + void ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool apply_dur = true, bool ignore_condition = false); + void ApplyEnchantment(Item* item, bool apply); + void UpdateSkillEnchantments(uint16 skill_id, uint16 curr_value, uint16 new_value); + void SendEnchantmentDurations(); + void BuildEnchantmentsInfoData(WorldPacket* data); + void AddItemDurations(Item* item); + void RemoveItemDurations(Item* item); + void SendItemDurations(); + void LoadCorpse(PreparedQueryResult result); + void LoadPet(); + + bool AddItem(uint32 itemId, uint32 count); + + /*********************************************************/ + /*** GOSSIP SYSTEM ***/ + /*********************************************************/ + + void PrepareGossipMenu(WorldObject* source, uint32 menuId = 0, bool showQuests = false); + void SendPreparedGossip(WorldObject* source); + void OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 menuId); + + uint32 GetGossipTextId(uint32 menuId, WorldObject* source); + uint32 GetGossipTextId(WorldObject* source); + static uint32 GetDefaultGossipMenuForSource(WorldObject* source); + + /*********************************************************/ + /*** QUEST SYSTEM ***/ + /*********************************************************/ + + int32 GetQuestLevel(Quest const* quest) const { return quest && (quest->GetQuestLevel() > 0) ? quest->GetQuestLevel() : GetLevel(); } + + void PrepareQuestMenu(ObjectGuid guid); + void SendPreparedQuest(ObjectGuid guid); + bool IsActiveQuest(uint32 quest_id) const; + Quest const* GetNextQuest(ObjectGuid guid, Quest const* quest) const; + bool CanSeeStartQuest(Quest const* quest) const; + bool CanTakeQuest(Quest const* quest, bool msg) const; + bool CanAddQuest(Quest const* quest, bool msg) const; + bool CanCompleteQuest(uint32 quest_id); + bool CanCompleteRepeatableQuest(Quest const* quest); + bool CanRewardQuest(Quest const* quest, bool msg); + bool CanRewardQuest(Quest const* quest, uint32 reward, bool msg); + void AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver); + void AddQuest(Quest const* quest, Object* questGiver); + void AbandonQuest(uint32 quest_id); + void CompleteQuest(uint32 quest_id); + void IncompleteQuest(uint32 quest_id); + void RewardQuest(Quest const* quest, uint32 reward, Object* questGiver, bool announce = true); + void SetRewardedQuest(uint32 quest_id); + void FailQuest(uint32 quest_id); + bool SatisfyQuestSkill(Quest const* qInfo, bool msg) const; + bool SatisfyQuestLevel(Quest const* qInfo, bool msg) const; + bool SatisfyQuestLog(bool msg) const; + bool SatisfyQuestDependentQuests(Quest const* qInfo, bool msg) const; + bool SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const; + bool SatisfyQuestDependentPreviousQuests(Quest const* qInfo, bool msg) const; + bool SatisfyQuestBreadcrumbQuest(Quest const* qInfo, bool msg) const; + bool SatisfyQuestDependentBreadcrumbQuests(Quest const* qInfo, bool msg) const; + bool SatisfyQuestClass(Quest const* qInfo, bool msg) const; + bool SatisfyQuestRace(Quest const* qInfo, bool msg) const; + bool SatisfyQuestReputation(Quest const* qInfo, bool msg) const; + bool SatisfyQuestStatus(Quest const* qInfo, bool msg) const; + bool SatisfyQuestConditions(Quest const* qInfo, bool msg) const; + bool SatisfyQuestTimed(Quest const* qInfo, bool msg) const; + bool SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const; + bool SatisfyQuestDay(Quest const* qInfo, bool msg) const; + bool SatisfyQuestWeek(Quest const* qInfo, bool msg) const; + bool SatisfyQuestMonth(Quest const* qInfo, bool msg) const; + bool SatisfyQuestSeasonal(Quest const* qInfo, bool msg) const; + bool GiveQuestSourceItem(Quest const* quest); + bool TakeQuestSourceItem(uint32 questId, bool msg); + bool GetQuestRewardStatus(uint32 quest_id) const; + QuestStatus GetQuestStatus(uint32 quest_id) const; + void SetQuestStatus(uint32 questId, QuestStatus status, bool update = true); + void RemoveActiveQuest(uint32 questId, bool update = true); + void RemoveRewardedQuest(uint32 questId, bool update = true); + void SendQuestUpdate(uint32 questId); + QuestGiverStatus GetQuestDialogStatus(Object* questGiver); + + void SetDailyQuestStatus(uint32 quest_id); + bool IsDailyQuestDone(uint32 quest_id); + void SetWeeklyQuestStatus(uint32 quest_id); + void SetMonthlyQuestStatus(uint32 quest_id); + void SetSeasonalQuestStatus(uint32 quest_id); + void ResetDailyQuestStatus(); + void ResetWeeklyQuestStatus(); + void ResetMonthlyQuestStatus(); + void ResetSeasonalQuestStatus(uint16 event_id); + + uint16 FindQuestSlot(uint32 quest_id) const; + uint32 GetQuestSlotQuestId(uint16 slot) const; + uint32 GetQuestSlotState(uint16 slot) const; + uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const; + uint32 GetQuestSlotTime(uint16 slot) const; + void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0); + void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count); + void SetQuestSlotState(uint16 slot, uint32 state); + void RemoveQuestSlotState(uint16 slot, uint32 state); + void SetQuestSlotTimer(uint16 slot, uint32 timer); + void SwapQuestSlot(uint16 slot1, uint16 slot2); + + uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) const; + void AreaExploredOrEventHappens(uint32 questId); + void GroupEventHappens(uint32 questId, WorldObject const* pEventObject); + void ItemAddedQuestCheck(uint32 entry, uint32 count); + void ItemRemovedQuestCheck(uint32 entry, uint32 count); + void KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid); + void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); + void KilledPlayerCredit(uint16 count = 1); + void KilledPlayerCreditForQuest(uint16 count, Quest const* quest); + void KillCreditGO(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); + void TalkedToCreature(uint32 entry, ObjectGuid guid); + void MoneyChanged(uint32 value); + void ReputationChanged(FactionEntry const* factionEntry); + void ReputationChanged2(FactionEntry const* factionEntry); + bool HasQuestForItem(uint32 itemId, uint32 excludeQuestId = 0, bool turnIn = false) const; + bool HasQuestForGO(int32 goId) const; + void UpdateVisibleGameobjectsOrSpellClicks(); + bool CanShareQuest(uint32 questId) const; + + void SendQuestComplete(uint32 questId) const; + void SendQuestReward(Quest const* quest, uint32 XP) const; + void SendQuestFailed(uint32 questId, InventoryResult reason = EQUIP_ERR_OK) const; + void SendQuestTimerFailed(uint32 questId) const; + void SendCanTakeQuestResponse(QuestFailedReason msg) const; + void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver) const; + void SendPushToPartyResponse(Player const* player, QuestShareMessages msg) const; + void SendQuestUpdateAddItem(Quest const* quest, uint32 itemIdx, uint16 count) const; + void SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGOIdx, uint16 oldCount, uint16 addCount); + void SendQuestUpdateAddPlayer(Quest const* quest, uint16 oldCount, uint16 addCount); + void SendQuestGiverStatusMultiple(); + + uint32 GetSharedQuestID() const { return m_sharedQuestId; } + ObjectGuid GetPlayerSharingQuest() const { return m_playerSharingQuest; } + void SetQuestSharingInfo(ObjectGuid guid, uint32 id) { m_playerSharingQuest = guid; m_sharedQuestId = id; } + void ClearQuestSharingInfo() { m_playerSharingQuest = ObjectGuid::Empty; m_sharedQuestId = 0; } + + uint32 GetInGameTime() const { return m_ingametime; } + void SetInGameTime(uint32 time) { m_ingametime = time; } + + void AddTimedQuest(uint32 questId) { m_timedquests.insert(questId); } + void RemoveTimedQuest(uint32 questId) { m_timedquests.erase(questId); } + + bool HasPvPForcingQuest() const; + + /*********************************************************/ + /*** LOAD SYSTEM ***/ + /*********************************************************/ + + bool LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& holder); + bool IsLoading() const override; + + void Initialize(ObjectGuid::LowType guid); + static uint32 GetZoneIdFromDB(ObjectGuid guid); + static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid); + + static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; } + static bool ValidateAppearance(uint8 race, uint8 class_, uint8 gender, uint8 hairID, uint8 hairColor, uint8 faceID, uint8 facialHair, uint8 skinColor, bool create = false); + + /*********************************************************/ + /*** SAVE SYSTEM ***/ + /*********************************************************/ + + void SaveToDB(bool create = false); + void SaveToDB(CharacterDatabaseTransaction trans, bool create = false); + void SaveInventoryAndGoldToDB(CharacterDatabaseTransaction trans); // fast save function for item/money cheating preventing + void SaveGoldToDB(CharacterDatabaseTransaction trans) const; + + static void Customize(CharacterCustomizeInfo const* customizeInfo, CharacterDatabaseTransaction trans); + static void SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGuid guid, CharacterDatabaseTransaction trans); + + static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); + static void DeleteOldCharacters(); + static void DeleteOldCharacters(uint32 keepDays); + + void SetBindPoint(ObjectGuid guid) const; + void SendTalentWipeConfirm(ObjectGuid guid) const; + void ResetPetTalents(); + void RegenerateAll(); + void Regenerate(Powers power); + void RegenerateHealth(); + void setRegenTimerCount(uint32 time) {m_regenTimerCount = time;} + void setWeaponChangeTimer(uint32 time) {m_weaponChangeTimer = time;} + + uint32 GetMoney() const { return GetUInt32Value(PLAYER_FIELD_COINAGE); } + bool ModifyMoney(int32 amount, bool sendError = true); + bool HasEnoughMoney(uint32 amount) const { return (GetMoney() >= amount); } + bool HasEnoughMoney(int32 amount) const { return (amount < 0) || HasEnoughMoney(uint32(amount)); } + void SetMoney(uint32 value); + + RewardedQuestSet const& getRewardedQuests() const { return m_RewardedQuests; } + QuestStatusMap& getQuestStatusMap() { return m_QuestStatus; } + + size_t GetRewardedQuestCount() const { return m_RewardedQuests.size(); } + bool IsQuestRewarded(uint32 quest_id) const; + + Unit* GetSelectedUnit() const; + Player* GetSelectedPlayer() const; + + void SetTarget(ObjectGuid /*guid*/) override { } /// Used for serverside target changes, does not apply to players + void SetSelection(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_TARGET, guid); } + + void SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError = 0, ObjectGuid::LowType item_guid = 0, uint32 item_count = 0) const; + void SendNewMail() const; + void UpdateNextMailTimeAndUnreads(); + void AddNewMailDeliverTime(time_t deliver_time); + + void SendItemRetrievalMail(uint32 itemEntry, uint32 count); // Item retrieval mails sent by The Postmaster (34337), used in multiple places. + /*********************************************************/ + /*** MAILED ITEMS SYSTEM ***/ + /*********************************************************/ + + uint32 unReadMails; + time_t m_nextMailDelivereTime; + + void SendOnCancelExpectedVehicleRideAura() const; + void PetSpellInitialize(); + void CharmSpellInitialize(); + void PossessSpellInitialize(); + void VehicleSpellInitialize(); + void SendRemoveControlBar() const; + bool HasSpell(uint32 spell) const override; + bool HasActiveSpell(uint32 spell) const; // show in spellbook + bool IsSpellFitByClassAndRace(uint32 spell_id) const; + bool HandlePassiveSpellLearn(SpellInfo const* spellInfo); + + void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) const; + void SendInitialSpells(); + void SendUnlearnSpells(); + bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, uint32 fromSkill = 0); + void LearnSpell(uint32 spell_id, bool dependent, uint32 fromSkill = 0); + void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true); + void ResetSpells(bool myClassOnly = false); + void LearnCustomSpells(); + void LearnDefaultSkills(); + void LearnDefaultSkill(uint32 skillId, uint16 rank); + void LearnQuestRewardedSpells(); + void LearnQuestRewardedSpells(Quest const* quest); + void AddTemporarySpell(uint32 spellId); + void RemoveTemporarySpell(uint32 spellId); + void SetReputation(uint32 factionentry, uint32 value); + uint32 GetReputation(uint32 factionentry) const; + std::string const& GetGuildName() const; + uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } + void SetFreeTalentPoints(uint32 points); + bool ResetTalents(bool no_cost = false); + uint32 ResetTalentsCost() const; + void InitTalentForLevel(); + void BuildPlayerTalentsInfoData(WorldPacket* data); + void BuildPetTalentsInfoData(WorldPacket* data); + void SendTalentsInfoData(bool pet); + void LearnTalent(uint32 talentId, uint32 talentRank); + void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank); + void SendTameFailure(uint8 result); + + bool AddTalent(uint32 spellId, uint8 spec, bool learning); + bool HasTalent(uint32 spell_id, uint8 spec) const; + + uint32 CalculateTalentsPoints() const; + + // Dual Spec + void UpdateSpecCount(uint8 count); + uint32 GetActiveSpec() const { return m_activeSpec; } + void SetActiveSpec(uint8 spec) { m_activeSpec = spec; } + uint8 GetSpecsCount() const { return m_specsCount; } + void SetSpecsCount(uint8 count) { m_specsCount = count; } + void ActivateSpec(uint8 spec); + void LoadActions(PreparedQueryResult result); + + void InitGlyphsForLevel(); + void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); } + uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); } + void SetGlyph(uint8 slot, uint32 glyph); + uint32 GetGlyph(uint8 slot) { return m_Glyphs[m_activeSpec][slot]; } + + uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); } + void SetFreePrimaryProfessions(uint16 profs) { SetUInt32Value(PLAYER_CHARACTER_POINTS2, profs); } + void InitPrimaryProfessions(); + + PlayerSpellMap const& GetSpellMap() const { return m_spells; } + PlayerSpellMap& GetSpellMap() { return m_spells; } + + void AddSpellMod(SpellModifier* mod, bool apply); + static bool IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell = nullptr); + template + void ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* spell = nullptr) const; + static void ApplyModToSpell(SpellModifier* mod, Spell* spell); + static bool HasSpellModApplied(SpellModifier* mod, Spell* spell); + void SetSpellModTakingSpell(Spell* spell, bool apply); + + void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns = false); + uint32 GetLastPotionId() const { return m_lastPotionId; } + void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } + void UpdatePotionCooldown(Spell* spell = nullptr); + + void SetResurrectRequestData(WorldObject const* caster, uint32 health, uint32 mana, uint32 appliedAura); + + void ClearResurrectRequestData() + { + _resurrectionData.reset(); + } - bool IsResurrectRequested() const { return _resurrectionData.get() != nullptr; } - void ResurrectUsingRequestData(); - void ResurrectUsingRequestDataImpl(); - - uint8 getCinematic() const { return m_cinematic; } - void setCinematic(uint8 cine) { m_cinematic = cine; } - - uint32 GetMovie() const { return m_movie; } - void SetMovie(uint32 movie) { m_movie = movie; } - - ActionButton* addActionButton(uint8 button, uint32 action, uint8 type); - void removeActionButton(uint8 button); - ActionButton const* GetActionButton(uint8 button); - void SendInitialActionButtons() const { SendActionButtons(1); } - void SendActionButtons(uint32 state) const; - bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const; - - PvPInfo pvpInfo; - void InitPvP(); - void UpdatePvPState(bool onlyFFA = false); - void SetPvP(bool state) override; - void UpdatePvP(bool state, bool override = false); - void UpdateZone(uint32 newZone, uint32 newArea); - void UpdateArea(uint32 newArea); - void SetNeedsZoneUpdate(bool needsUpdate) { m_needsZoneUpdate = needsUpdate; } - - void UpdateZoneDependentAuras(uint32 zone_id); // zones - void UpdateAreaDependentAuras(uint32 area_id); // subzones - - void UpdateAfkReport(time_t currTime); - void UpdatePvPFlag(time_t currTime); - void SetContestedPvP(Player* attackedPlayer = nullptr); - void UpdateContestedPvP(uint32 currTime); - void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;} - void ResetContestedPvP(); - - /// @todo: maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler - std::unique_ptr duel; - void UpdateDuelFlag(time_t currTime); - void CheckDuelDistance(time_t currTime); - void DuelComplete(DuelCompleteType type); - void SendDuelCountdown(uint32 counter); - - bool IsGroupVisibleFor(Player const* p) const; - bool IsInSameGroupWith(Player const* p) const; - bool IsInSameRaidWith(Player const* p) const; - void UninviteFromGroup(); - static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, char const* reason = nullptr); - void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); } - void SendUpdateToOutOfRangeGroupMembers(); - - void SetInGuild(uint32 guildId); - void SetRank(uint8 rankId) { SetUInt32Value(PLAYER_GUILDRANK, rankId); } - uint8 GetRank() const { return uint8(GetUInt32Value(PLAYER_GUILDRANK)); } - void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } - uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } - Guild* GetGuild(); - int GetGuildIdInvited() const { return m_GuildIdInvited; } - static void RemovePetitionsAndSigns(ObjectGuid guid, CharterTypes type); - - // Arena Team - void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type); - void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value); - static void LeaveAllArenaTeams(ObjectGuid guid); - uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); } - uint32 GetArenaPersonalRating(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); } - void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; } - uint32 GetArenaTeamIdInvited() const { return m_ArenaTeamIdInvited; } - - Difficulty GetDifficulty(bool isRaid) const { return isRaid ? m_raidDifficulty : m_dungeonDifficulty; } - Difficulty GetDungeonDifficulty() const { return m_dungeonDifficulty; } - Difficulty GetRaidDifficulty() const { return m_raidDifficulty; } - Difficulty GetStoredRaidDifficulty() const { return m_raidMapDifficulty; } // only for use in difficulty packet after exiting to raid map - void SetDungeonDifficulty(Difficulty dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; } - void SetRaidDifficulty(Difficulty raid_difficulty) { m_raidDifficulty = raid_difficulty; } - void StoreRaidMapDifficulty(); - - bool UpdateSkill(uint32 skill_id, uint32 step); - bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step); - - bool UpdateCraftSkill(uint32 spellid); - bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1); - bool UpdateFishingSkill(); - - uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); } - uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const; - - float GetHealthBonusFromStamina(); - float GetManaBonusFromIntellect(); - - bool UpdateStats(Stats stat) override; - bool UpdateAllStats() override; - void ApplySpellPenetrationBonus(int32 amount, bool apply); - void UpdateResistances(uint32 school) override; - void UpdateArmor() override; - void UpdateMaxHealth() override; - void UpdateMaxPower(Powers power) override; - void ApplyFeralAPBonus(int32 amount, bool apply); - void UpdateAttackPowerAndDamage(bool ranged = false) override; - void UpdateShieldBlockValue(); - void ApplySpellPowerBonus(int32 amount, bool apply); - void UpdateSpellDamageAndHealingBonus(); - void ApplyRatingMod(CombatRating cr, int32 value, bool apply); - void UpdateRating(CombatRating cr); - void UpdateAllRatings(); - - void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage, uint8 damageIndex) const override; - - void UpdateDefenseBonusesMod(); - void RecalculateRating(CombatRating cr) { ApplyRatingMod(cr, 0, true);} - float GetMeleeCritFromAgility() const; - void GetDodgeFromAgility(float &diminishing, float &nondiminishing) const; - float GetMissPercentageFromDefense() const; - float GetSpellCritFromIntellect() const; - float OCTRegenHPPerSpirit() const; - float OCTRegenMPPerSpirit() const; - float GetRatingMultiplier(CombatRating cr) const; - float GetRatingBonusValue(CombatRating cr) const; - uint32 GetBaseSpellPowerBonus() const { return m_baseSpellPower; } - int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; } - - bool CanApplyResilience() const override { return true; } - - float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const; - void UpdateBlockPercentage(); - void UpdateCritPercentage(WeaponAttackType attType); - void UpdateAllCritPercentages(); - void UpdateParryPercentage(); - void UpdateDodgePercentage(); - void UpdateMeleeHitChances(); - void UpdateRangedHitChances(); - void UpdateSpellHitChances(); - - void UpdateAllSpellCritChances(); - void UpdateSpellCritChance(uint32 school); - void UpdateArmorPenetration(int32 amount); - void UpdateExpertise(WeaponAttackType attType); - void ApplyManaRegenBonus(int32 amount, bool apply); - void ApplyHealthRegenBonus(int32 amount, bool apply); - void UpdateManaRegen(); - void UpdateRuneRegen(RuneType rune); - uint32 GetRuneTimer(uint8 index) const { return m_runeGraceCooldown[index]; } - void SetRuneTimer(uint8 index, uint32 timer) { m_runeGraceCooldown[index] = timer; } - uint32 GetLastRuneGraceTimer(uint8 index) const { return m_lastRuneGraceTimers[index]; } - void SetLastRuneGraceTimer(uint8 index, uint32 timer) { m_lastRuneGraceTimers[index] = timer; } - - ObjectGuid GetLootGUID() const { return m_lootGuid; } - void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; } - - WorldSession* GetSession() const { return m_session; } - - void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override; - void DestroyForPlayer(Player* target, bool onDeath = false) const override; - void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend = false, float group_rate=1.0f) const; - - // notifiers - void SendAttackSwingCantAttack() const; - void SendAttackSwingCancelAttack() const; - void SendAttackSwingDeadTarget() const; - void SendAttackSwingNotInRange() const; - void SendAttackSwingBadFacingAttack() const; - void SendAutoRepeatCancel(Unit* target); - void SendExplorationExperience(uint32 Area, uint32 Experience) const; - - void SendDungeonDifficulty(bool IsInGroup) const; - void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty = -1) const; - void ResetInstances(uint8 method, bool isRaid); - void SendResetInstanceSuccess(uint32 MapId) const; - void SendResetInstanceFailed(uint32 reason, uint32 MapId) const; - void SendResetFailedNotify(uint32 mapid) const; - - bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override; - bool UpdatePosition(Position const& pos, bool teleport = false) override { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } - void ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional const& liquidData) override; - void AtExitCombat() override; - - void SendMessageToSet(WorldPacket const* data, bool self) const override { SendMessageToSetInRange(data, GetVisibilityRange(), self); } - void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self) const override; - void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool own_team_only) const; - void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const override; - - Corpse* GetCorpse() const; - void SpawnCorpseBones(bool triggerSave = true); - Corpse* CreateCorpse(); - void KillPlayer(); - static void OfflineResurrect(ObjectGuid const& guid, CharacterDatabaseTransaction trans); - bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; } - WorldLocation GetCorpseLocation() const { return _corpseLocation; } - uint32 GetResurrectionSpellId(); - void ResurrectPlayer(float restore_percent, bool applySickness = false); - void BuildPlayerRepop(); - void RepopAtGraveyard(); - - /*********************************************************/ - /*** CUSTOM SYSTEMS ***/ - /*********************************************************/// - - // Auction info - void CalculateAuctionLotsCounter(); - uint32 GetAuctionLotsCount() const { return m_auctionlots; } - void AddLotsCount() { ++m_auctionlots; } - void RemoveLotsCount() { m_auctionlots - 1 > 0 ? --m_auctionlots : m_auctionlots = 0; } - - //End of Custom Systems - - void RemoveGhoul(); - - void SendDurabilityLoss(); - void DurabilityLossAll(double percent, bool inventory); - void DurabilityLoss(Item* item, double percent); - void DurabilityPointsLossAll(int32 points, bool inventory); - void DurabilityPointsLoss(Item* item, int32 points); - void DurabilityPointLossForEquipSlot(EquipmentSlots slot); - uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank); - uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank); - - void UpdateMirrorTimers(); - void StopMirrorTimers(); - bool IsMirrorTimerActive(MirrorTimerType type) const; - - void SetMovement(PlayerMovementType pType); - - bool CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone) const; - - void JoinedChannel(Channel* c); - void LeftChannel(Channel* c); - void CleanupChannels(); - void UpdateLocalChannels(uint32 newZone); - void LeaveLFGChannel(); - - typedef std::list JoinedChannelsList; - JoinedChannelsList const& GetJoinedChannels() const { return m_channels; } - - void UpdateDefense(); - void UpdateWeaponSkill(Unit* victim, WeaponAttackType attType); - void UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defense); - - void SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal); - uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus - uint16 GetPureMaxSkillValue(uint32 skill) const; // max - uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus - uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus - uint16 GetPureSkillValue(uint32 skill) const; // skill value - int16 GetSkillPermBonusValue(uint32 skill) const; - int16 GetSkillTempBonusValue(uint32 skill) const; - uint16 GetSkillStep(uint32 skill) const; // 0...6 - bool HasSkill(uint32 skill) const; - void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue); - - WorldLocation& GetTeleportDest() { return m_teleport_dest; } - uint32 GetTeleportOptions() const { return m_teleport_options; } - bool IsBeingTeleported() const { return IsBeingTeleportedNear() || IsBeingTeleportedFar(); } - bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; } - bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far; } - void SetSemaphoreTeleportNear(bool semphsetting) { mSemaphoreTeleport_Near = semphsetting; } - void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; } - void ProcessDelayedOperations(); - - void CheckAreaExploreAndOutdoor(void); - - static uint32 TeamForRace(uint8 race); - uint32 GetTeam() const { return m_team; } - TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } - void SetFactionForRace(uint8 race); - - void InitDisplayIds(); - - bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; - bool IsAtRecruitAFriendDistance(WorldObject const* pOther) const; - void RewardPlayerAndGroupAtKill(Unit* victim, bool isBattleGround); - void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource); - bool isHonorOrXPTarget(Unit* victim) const; - - bool GetsRecruitAFriendBonus(bool forXP); - uint8 GetGrantableLevels() const { return m_grantableLevels; } - void SetGrantableLevels(uint8 val) { m_grantableLevels = val; } - - ReputationMgr& GetReputationMgr() { return *m_reputationMgr; } - ReputationMgr const& GetReputationMgr() const { return *m_reputationMgr; } - ReputationRank GetReputationRank(uint32 faction_id) const; - void RewardReputation(Unit* victim, float rate); - void RewardReputation(Quest const* quest); - - int32 CalculateReputationGain(ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus = false); - - void UpdateSkillsForLevel(); - void UpdateWeaponsSkillsToMaxSkillsForLevel(); // for .levelup - void ModifySkillBonus(uint32 skillid, int32 val, bool talent); - - /*********************************************************/ - /*** PVP SYSTEM ***/ - /*********************************************************/ - void SetArenaFaction(uint8 arenaFaction) { SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, arenaFaction); } - void RemovePVPInsignia(Player* looter); - void UpdateHonorFields(); - bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false); - uint32 GetHonorPoints() const { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } - uint32 GetArenaPoints() const { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } - void ModifyHonorPoints(int32 value, CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr)); //! If trans is specified, honor save query will be added to trans - void ModifyArenaPoints(int32 value, CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr)); //! If trans is specified, arena point save query will be added to trans - uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const; - void SetHonorPoints(uint32 value); - void SetArenaPoints(uint32 value); - - // duel health and mana reset methods - void SaveHealthBeforeDuel() { healthBeforeDuel = GetHealth(); } - void SaveManaBeforeDuel() { manaBeforeDuel = GetPower(POWER_MANA); } - void RestoreHealthAfterDuel() { SetHealth(healthBeforeDuel); } - void RestoreManaAfterDuel() { SetPower(POWER_MANA, manaBeforeDuel); } - - //End of PvP System - - void SetDrunkValue(uint8 newDrunkValue, uint32 itemId = 0); - uint8 GetDrunkValue() const { return GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_INEBRIATION); } - static DrunkenState GetDrunkenstateByValue(uint8 value); - - uint32 GetDeathTimer() const { return m_deathTimer; } - uint32 GetCorpseReclaimDelay(bool pvp) const; - void UpdateCorpseReclaimDelay(); - int32 CalculateCorpseReclaimDelay(bool load = false) const; - void SendCorpseReclaimDelay(uint32 delay) const; - - uint32 GetShieldBlockValue() const override; // overwrite Unit version (virtual) - bool CanParry() const { return m_canParry; } - void SetCanParry(bool value); - bool CanBlock() const { return m_canBlock; } - void SetCanBlock(bool value); - bool CanTitanGrip() const { return m_canTitanGrip; } - void SetCanTitanGrip(bool value, uint32 penaltySpellId = 0); - void CheckTitanGripPenalty(); - bool CanTameExoticPets() const { return IsGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); } - - void SetRegularAttackTime(); - - void HandleBaseModFlatValue(BaseModGroup modGroup, float amount, bool apply); - void ApplyBaseModPctValue(BaseModGroup modGroup, float pct); - - void SetBaseModFlatValue(BaseModGroup modGroup, float val); - void SetBaseModPctValue(BaseModGroup modGroup, float val); - - void UpdateDamageDoneMods(WeaponAttackType attackType, int32 skipEnchantSlot = -1) override; - void UpdateBaseModGroup(BaseModGroup modGroup); - - float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; - float GetTotalBaseModValue(BaseModGroup modGroup) const; - - void _ApplyAllStatBonuses(); - void _RemoveAllStatBonuses(); - - void ResetAllPowers(); - - SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType attackType = BASE_ATTACK, uint8 damageIndex = 0) const override; - - void CastAllObtainSpells(); - void ApplyItemObtainSpells(Item* item, bool apply); - - void UpdateWeaponDependentCritAuras(WeaponAttackType attackType); - void UpdateAllWeaponDependentCritAuras(); - - void UpdateWeaponDependentAuras(WeaponAttackType attackType); - void ApplyItemDependentAuras(Item* item, bool apply); - - bool CheckAttackFitToAuraRequirement(WeaponAttackType attackType, AuraEffect const* aurEff) const override; - - void _ApplyItemMods(Item* item, uint8 slot, bool apply, bool updateItemAuras = true); - void _RemoveAllItemMods(); - void _ApplyAllItemMods(); - void _ApplyAllLevelScaleItemMods(bool apply); - ScalingStatDistributionEntry const* GetScalingStatDistributionFor(ItemTemplate const& itemTemplate) const; - ScalingStatValuesEntry const* GetScalingStatValuesFor(ItemTemplate const& itemTemplate) const; - void _ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply, bool only_level_scale = false); - void _ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, bool apply); - void _ApplyAmmoBonuses(); - bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const; - void ToggleMetaGemsActive(uint8 exceptslot, bool apply); - void CorrectMetaGemEnchants(uint8 slot, bool apply); - void InitDataForForm(bool reapplyMods = false); - - void ApplyItemEquipSpell(Item* item, bool apply, bool form_change = false); - void ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, bool form_change = false); - void UpdateEquipSpellsAtFormChange(); - void CastItemCombatSpell(DamageInfo const& damageInfo); - void CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemTemplate const* proto); - void CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex); - - void SendEquipmentSetList(); - void SetEquipmentSet(EquipmentSetInfo::EquipmentSetData const& eqset); - void DeleteEquipmentSet(uint64 setGuid); - - void SendInitWorldStates(uint32 zoneId, uint32 areaId); - void SendUpdateWorldState(uint32 variable, uint32 value) const; - void SendDirectMessage(WorldPacket const* data) const; - void SendBGWeekendWorldStates() const; - void SendBattlefieldWorldStates() const; - - void SendAurasForTarget(Unit* target) const; - - PlayerMenu* PlayerTalkClass; - std::vector ItemSetEff; - - void SendLoot(ObjectGuid guid, LootType loot_type); - void SendLootError(ObjectGuid guid, LootError error) const; - void SendLootRelease(ObjectGuid guid) const; - void SendNotifyLootItemRemoved(uint8 lootSlot) const; - void SendNotifyLootMoneyRemoved() const; - - /*********************************************************/ - /*** BATTLEGROUND SYSTEM ***/ - /*********************************************************/ - - bool InBattleground() const { return m_bgData.bgInstanceID != 0; } - bool InArena() const; - uint32 GetBattlegroundId() const { return m_bgData.bgInstanceID; } - BattlegroundTypeId GetBattlegroundTypeId() const { return m_bgData.bgTypeID; } - Battleground* GetBattleground() const; - - bool InBattlegroundQueue(bool ignoreArena = false) const; - bool IsDeserter() const { return HasAura(26013); } - - BattlegroundQueueTypeId GetBattlegroundQueueTypeId(uint32 index) const; - uint32 GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const; - bool IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const; - bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const; - - void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId); - uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val); - bool HasFreeBattlegroundQueueId() const; - void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val); - void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId); - bool IsInvitedForBattlegroundInstance(uint32 instanceId) const; - WorldLocation const& GetBattlegroundEntryPoint() const { return m_bgData.joinPos; } - void SetBattlegroundEntryPoint(); + bool IsResurrectRequestedBy(ObjectGuid const& guid) const + { + if (!IsResurrectRequested()) + return false; - void SetBGTeam(uint32 team); - uint32 GetBGTeam() const; + return !_resurrectionData->GUID.IsEmpty() && _resurrectionData->GUID == guid; + } - void LeaveBattleground(bool teleportToEntryPoint = true); - bool CanJoinToBattleground(Battleground const* bg) const; - bool CanReportAfkDueToLimit(); - void ReportedAfkBy(Player* reporter); - void ClearAfkReports() { m_bgData.bgAfkReporter.clear(); } + bool IsResurrectRequested() const { return _resurrectionData.get() != nullptr; } + void ResurrectUsingRequestData(); + void ResurrectUsingRequestDataImpl(); + + uint8 getCinematic() const { return m_cinematic; } + void setCinematic(uint8 cine) { m_cinematic = cine; } + + uint32 GetMovie() const { return m_movie; } + void SetMovie(uint32 movie) { m_movie = movie; } + + ActionButton* addActionButton(uint8 button, uint32 action, uint8 type); + void removeActionButton(uint8 button); + ActionButton const* GetActionButton(uint8 button); + void SendInitialActionButtons() const { SendActionButtons(1); } + void SendActionButtons(uint32 state) const; + bool IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const; + + PvPInfo pvpInfo; + void InitPvP(); + void UpdatePvPState(bool onlyFFA = false); + void SetPvP(bool state) override; + void UpdatePvP(bool state, bool override = false); + void UpdateZone(uint32 newZone, uint32 newArea); + void UpdateArea(uint32 newArea); + void SetNeedsZoneUpdate(bool needsUpdate) { m_needsZoneUpdate = needsUpdate; } + + void UpdateZoneDependentAuras(uint32 zone_id); // zones + void UpdateAreaDependentAuras(uint32 area_id); // subzones + + void UpdateAfkReport(time_t currTime); + void UpdatePvPFlag(time_t currTime); + void SetContestedPvP(Player* attackedPlayer = nullptr); + void UpdateContestedPvP(uint32 currTime); + void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;} + void ResetContestedPvP(); + + /// @todo: maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler + std::unique_ptr duel; + void UpdateDuelFlag(time_t currTime); + void CheckDuelDistance(time_t currTime); + void DuelComplete(DuelCompleteType type); + void SendDuelCountdown(uint32 counter); + + bool IsGroupVisibleFor(Player const* p) const; + bool IsInSameGroupWith(Player const* p) const; + bool IsInSameRaidWith(Player const* p) const; + void UninviteFromGroup(); + static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, char const* reason = nullptr); + void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); } + void SendUpdateToOutOfRangeGroupMembers(); + + void SetInGuild(uint32 guildId); + void SetRank(uint8 rankId) { SetUInt32Value(PLAYER_GUILDRANK, rankId); } + uint8 GetRank() const { return uint8(GetUInt32Value(PLAYER_GUILDRANK)); } + void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } + uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } + Guild* GetGuild(); + int GetGuildIdInvited() const { return m_GuildIdInvited; } + static void RemovePetitionsAndSigns(ObjectGuid guid, CharterTypes type); + + // Arena Team + void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type); + void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value); + static void LeaveAllArenaTeams(ObjectGuid guid); + uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); } + uint32 GetArenaPersonalRating(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); } + void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; } + uint32 GetArenaTeamIdInvited() const { return m_ArenaTeamIdInvited; } + + Difficulty GetDifficulty(bool isRaid) const { return isRaid ? m_raidDifficulty : m_dungeonDifficulty; } + Difficulty GetDungeonDifficulty() const { return m_dungeonDifficulty; } + Difficulty GetRaidDifficulty() const { return m_raidDifficulty; } + Difficulty GetStoredRaidDifficulty() const { return m_raidMapDifficulty; } // only for use in difficulty packet after exiting to raid map + void SetDungeonDifficulty(Difficulty dungeon_difficulty) { m_dungeonDifficulty = dungeon_difficulty; } + void SetRaidDifficulty(Difficulty raid_difficulty) { m_raidDifficulty = raid_difficulty; } + void StoreRaidMapDifficulty(); + + bool UpdateSkill(uint32 skill_id, uint32 step); + bool UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step); + + bool UpdateCraftSkill(uint32 spellid); + bool UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLevel, uint32 Multiplicator = 1); + bool UpdateFishingSkill(); + + uint32 GetBaseDefenseSkillValue() const { return GetBaseSkillValue(SKILL_DEFENSE); } + uint32 GetBaseWeaponSkillValue(WeaponAttackType attType) const; + + float GetHealthBonusFromStamina(); + float GetManaBonusFromIntellect(); + + bool UpdateStats(Stats stat) override; + bool UpdateAllStats() override; + void ApplySpellPenetrationBonus(int32 amount, bool apply); + void UpdateResistances(uint32 school) override; + void UpdateArmor() override; + void UpdateMaxHealth() override; + void UpdateMaxPower(Powers power) override; + void ApplyFeralAPBonus(int32 amount, bool apply); + void UpdateAttackPowerAndDamage(bool ranged = false) override; + void UpdateShieldBlockValue(); + void ApplySpellPowerBonus(int32 amount, bool apply); + void UpdateSpellDamageAndHealingBonus(); + void ApplyRatingMod(CombatRating cr, int32 value, bool apply); + void UpdateRating(CombatRating cr); + void UpdateAllRatings(); + + void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage, uint8 damageIndex) const override; + + void UpdateDefenseBonusesMod(); + void RecalculateRating(CombatRating cr) { ApplyRatingMod(cr, 0, true);} + float GetMeleeCritFromAgility() const; + void GetDodgeFromAgility(float& diminishing, float& nondiminishing) const; + float GetMissPercentageFromDefense() const; + float GetSpellCritFromIntellect() const; + float OCTRegenHPPerSpirit() const; + float OCTRegenMPPerSpirit() const; + float GetRatingMultiplier(CombatRating cr) const; + float GetRatingBonusValue(CombatRating cr) const; + uint32 GetBaseSpellPowerBonus() const { return m_baseSpellPower; } + int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; } + + bool CanApplyResilience() const override { return true; } + + float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const; + void UpdateBlockPercentage(); + void UpdateCritPercentage(WeaponAttackType attType); + void UpdateAllCritPercentages(); + void UpdateParryPercentage(); + void UpdateDodgePercentage(); + void UpdateMeleeHitChances(); + void UpdateRangedHitChances(); + void UpdateSpellHitChances(); + + void UpdateAllSpellCritChances(); + void UpdateSpellCritChance(uint32 school); + void UpdateArmorPenetration(int32 amount); + void UpdateExpertise(WeaponAttackType attType); + void ApplyManaRegenBonus(int32 amount, bool apply); + void ApplyHealthRegenBonus(int32 amount, bool apply); + void UpdateManaRegen(); + void UpdateRuneRegen(RuneType rune); + uint32 GetRuneTimer(uint8 index) const { return m_runeGraceCooldown[index]; } + void SetRuneTimer(uint8 index, uint32 timer) { m_runeGraceCooldown[index] = timer; } + uint32 GetLastRuneGraceTimer(uint8 index) const { return m_lastRuneGraceTimers[index]; } + void SetLastRuneGraceTimer(uint8 index, uint32 timer) { m_lastRuneGraceTimers[index] = timer; } + + ObjectGuid GetLootGUID() const { return m_lootGuid; } + void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; } + + WorldSession* GetSession() const { return m_session; } + + void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override; + void DestroyForPlayer(Player* target, bool onDeath = false) const override; + void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend = false, float group_rate = 1.0f) const; + + // notifiers + void SendAttackSwingCantAttack() const; + void SendAttackSwingCancelAttack() const; + void SendAttackSwingDeadTarget() const; + void SendAttackSwingNotInRange() const; + void SendAttackSwingBadFacingAttack() const; + void SendAutoRepeatCancel(Unit* target); + void SendExplorationExperience(uint32 Area, uint32 Experience) const; + + void SendDungeonDifficulty(bool IsInGroup) const; + void SendRaidDifficulty(bool IsInGroup, int32 forcedDifficulty = -1) const; + void ResetInstances(uint8 method, bool isRaid); + void SendResetInstanceSuccess(uint32 MapId) const; + void SendResetInstanceFailed(uint32 reason, uint32 MapId) const; + void SendResetFailedNotify(uint32 mapid) const; + + bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override; + bool UpdatePosition(Position const& pos, bool teleport = false) override { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } + void ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional const& liquidData) override; + void AtExitCombat() override; + + void SendMessageToSet(WorldPacket const* data, bool self) const override { SendMessageToSetInRange(data, GetVisibilityRange(), self); } + void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self) const override; + void SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool own_team_only) const; + void SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const override; + + Corpse* GetCorpse() const; + void SpawnCorpseBones(bool triggerSave = true); + Corpse* CreateCorpse(); + void KillPlayer(); + static void OfflineResurrect(ObjectGuid const& guid, CharacterDatabaseTransaction trans); + bool HasCorpse() const { return _corpseLocation.GetMapId() != MAPID_INVALID; } + WorldLocation GetCorpseLocation() const { return _corpseLocation; } + uint32 GetResurrectionSpellId(); + void ResurrectPlayer(float restore_percent, bool applySickness = false); + void BuildPlayerRepop(); + void RepopAtGraveyard(); + + /*********************************************************/ + /*** CUSTOM SYSTEMS ***/ + /*********************************************************/// + + // Auction info + void CalculateAuctionLotsCounter(); + uint32 GetAuctionLotsCount() const { return m_auctionlots; } + void AddLotsCount() { ++m_auctionlots; } + void RemoveLotsCount() { m_auctionlots - 1 > 0 ? --m_auctionlots : m_auctionlots = 0; } + + //End of Custom Systems + + void RemoveGhoul(); + + void SendDurabilityLoss(); + void DurabilityLossAll(double percent, bool inventory); + void DurabilityLoss(Item* item, double percent); + void DurabilityPointsLossAll(int32 points, bool inventory); + void DurabilityPointsLoss(Item* item, int32 points); + void DurabilityPointLossForEquipSlot(EquipmentSlots slot); + uint32 DurabilityRepairAll(bool cost, float discountMod, bool guildBank); + uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank); + + void UpdateMirrorTimers(); + void StopMirrorTimers(); + bool IsMirrorTimerActive(MirrorTimerType type) const; + + void SetMovement(PlayerMovementType pType); + + bool CanJoinConstantChannelInZone(ChatChannelsEntry const* channel, AreaTableEntry const* zone) const; + + void JoinedChannel(Channel* c); + void LeftChannel(Channel* c); + void CleanupChannels(); + void UpdateLocalChannels(uint32 newZone); + void LeaveLFGChannel(); + + typedef std::list JoinedChannelsList; + JoinedChannelsList const& GetJoinedChannels() const { return m_channels; } + + void UpdateDefense(); + void UpdateWeaponSkill(Unit* victim, WeaponAttackType attType); + void UpdateCombatSkills(Unit* victim, WeaponAttackType attType, bool defense); + + void SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal); + uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus + uint16 GetPureMaxSkillValue(uint32 skill) const; // max + uint16 GetSkillValue(uint32 skill) const; // skill value + perm. bonus + temp bonus + uint16 GetBaseSkillValue(uint32 skill) const; // skill value + perm. bonus + uint16 GetPureSkillValue(uint32 skill) const; // skill value + int16 GetSkillPermBonusValue(uint32 skill) const; + int16 GetSkillTempBonusValue(uint32 skill) const; + uint16 GetSkillStep(uint32 skill) const; // 0...6 + bool HasSkill(uint32 skill) const; + void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue); + + WorldLocation& GetTeleportDest() { return m_teleport_dest; } + uint32 GetTeleportOptions() const { return m_teleport_options; } + bool IsBeingTeleported() const { return IsBeingTeleportedNear() || IsBeingTeleportedFar(); } + bool IsBeingTeleportedNear() const { return mSemaphoreTeleport_Near; } + bool IsBeingTeleportedFar() const { return mSemaphoreTeleport_Far; } + void SetSemaphoreTeleportNear(bool semphsetting) { mSemaphoreTeleport_Near = semphsetting; } + void SetSemaphoreTeleportFar(bool semphsetting) { mSemaphoreTeleport_Far = semphsetting; } + void ProcessDelayedOperations(); + + void CheckAreaExploreAndOutdoor(void); + + static uint32 TeamForRace(uint8 race); + uint32 GetTeam() const { return m_team; } + TeamId GetTeamId() const { return m_team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } + void SetFactionForRace(uint8 race); + + void InitDisplayIds(); + + bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; + bool IsAtRecruitAFriendDistance(WorldObject const* pOther) const; + void RewardPlayerAndGroupAtKill(Unit* victim, bool isBattleGround); + void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource); + bool isHonorOrXPTarget(Unit* victim) const; + + bool GetsRecruitAFriendBonus(bool forXP); + uint8 GetGrantableLevels() const { return m_grantableLevels; } + void SetGrantableLevels(uint8 val) { m_grantableLevels = val; } + + ReputationMgr& GetReputationMgr() { return *m_reputationMgr; } + ReputationMgr const& GetReputationMgr() const { return *m_reputationMgr; } + ReputationRank GetReputationRank(uint32 faction_id) const; + void RewardReputation(Unit* victim, float rate); + void RewardReputation(Quest const* quest); + + int32 CalculateReputationGain(ReputationSource source, uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool noQuestBonus = false); + + void UpdateSkillsForLevel(); + void UpdateWeaponsSkillsToMaxSkillsForLevel(); // for .levelup + void ModifySkillBonus(uint32 skillid, int32 val, bool talent); + + /*********************************************************/ + /*** PVP SYSTEM ***/ + /*********************************************************/ + void SetArenaFaction(uint8 arenaFaction) { SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, arenaFaction); } + void RemovePVPInsignia(Player* looter); + void UpdateHonorFields(); + bool RewardHonor(Unit* victim, uint32 groupsize, int32 honor = -1, bool pvptoken = false); + uint32 GetHonorPoints() const { return GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY); } + uint32 GetArenaPoints() const { return GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY); } + void ModifyHonorPoints(int32 value, CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr)); //! If trans is specified, honor save query will be added to trans + void ModifyArenaPoints(int32 value, CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr)); //! If trans is specified, arena point save query will be added to trans + uint32 GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const; + void SetHonorPoints(uint32 value); + void SetArenaPoints(uint32 value); + + // duel health and mana reset methods + void SaveHealthBeforeDuel() { healthBeforeDuel = GetHealth(); } + void SaveManaBeforeDuel() { manaBeforeDuel = GetPower(POWER_MANA); } + void RestoreHealthAfterDuel() { SetHealth(healthBeforeDuel); } + void RestoreManaAfterDuel() { SetPower(POWER_MANA, manaBeforeDuel); } + + //End of PvP System + + void SetDrunkValue(uint8 newDrunkValue, uint32 itemId = 0); + uint8 GetDrunkValue() const { return GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_INEBRIATION); } + static DrunkenState GetDrunkenstateByValue(uint8 value); + + uint32 GetDeathTimer() const { return m_deathTimer; } + uint32 GetCorpseReclaimDelay(bool pvp) const; + void UpdateCorpseReclaimDelay(); + int32 CalculateCorpseReclaimDelay(bool load = false) const; + void SendCorpseReclaimDelay(uint32 delay) const; + + uint32 GetShieldBlockValue() const override; // overwrite Unit version (virtual) + bool CanParry() const { return m_canParry; } + void SetCanParry(bool value); + bool CanBlock() const { return m_canBlock; } + void SetCanBlock(bool value); + bool CanTitanGrip() const { return m_canTitanGrip; } + void SetCanTitanGrip(bool value, uint32 penaltySpellId = 0); + void CheckTitanGripPenalty(); + bool CanTameExoticPets() const { return IsGameMaster() || HasAuraType(SPELL_AURA_ALLOW_TAME_PET_TYPE); } + + void SetRegularAttackTime(); + + void HandleBaseModFlatValue(BaseModGroup modGroup, float amount, bool apply); + void ApplyBaseModPctValue(BaseModGroup modGroup, float pct); + + void SetBaseModFlatValue(BaseModGroup modGroup, float val); + void SetBaseModPctValue(BaseModGroup modGroup, float val); + + void UpdateDamageDoneMods(WeaponAttackType attackType, int32 skipEnchantSlot = -1) override; + void UpdateBaseModGroup(BaseModGroup modGroup); + + float GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const; + float GetTotalBaseModValue(BaseModGroup modGroup) const; + + void _ApplyAllStatBonuses(); + void _RemoveAllStatBonuses(); + + void ResetAllPowers(); + + SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType attackType = BASE_ATTACK, uint8 damageIndex = 0) const override; + + void CastAllObtainSpells(); + void ApplyItemObtainSpells(Item* item, bool apply); + + void UpdateWeaponDependentCritAuras(WeaponAttackType attackType); + void UpdateAllWeaponDependentCritAuras(); + + void UpdateWeaponDependentAuras(WeaponAttackType attackType); + void ApplyItemDependentAuras(Item* item, bool apply); + + bool CheckAttackFitToAuraRequirement(WeaponAttackType attackType, AuraEffect const* aurEff) const override; + + void _ApplyItemMods(Item* item, uint8 slot, bool apply, bool updateItemAuras = true); + void _RemoveAllItemMods(); + void _ApplyAllItemMods(); + void _ApplyAllLevelScaleItemMods(bool apply); + ScalingStatDistributionEntry const* GetScalingStatDistributionFor(ItemTemplate const& itemTemplate) const; + ScalingStatValuesEntry const* GetScalingStatValuesFor(ItemTemplate const& itemTemplate) const; + void _ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply, bool only_level_scale = false); + void _ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, bool apply); + void _ApplyAmmoBonuses(); + bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) const; + void ToggleMetaGemsActive(uint8 exceptslot, bool apply); + void CorrectMetaGemEnchants(uint8 slot, bool apply); + void InitDataForForm(bool reapplyMods = false); + + void ApplyItemEquipSpell(Item* item, bool apply, bool form_change = false); + void ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply, bool form_change = false); + void UpdateEquipSpellsAtFormChange(); + void CastItemCombatSpell(DamageInfo const& damageInfo); + void CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemTemplate const* proto); + void CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex); + + void SendEquipmentSetList(); + void SetEquipmentSet(EquipmentSetInfo::EquipmentSetData const& eqset); + void DeleteEquipmentSet(uint64 setGuid); + + void SendInitWorldStates(uint32 zoneId, uint32 areaId); + void SendUpdateWorldState(uint32 variable, uint32 value) const; + void SendDirectMessage(WorldPacket const* data) const; + void SendBGWeekendWorldStates() const; + void SendBattlefieldWorldStates() const; + + void SendAurasForTarget(Unit* target) const; + + PlayerMenu* PlayerTalkClass; + std::vector ItemSetEff; + + void SendLoot(ObjectGuid guid, LootType loot_type); + void SendLootError(ObjectGuid guid, LootError error) const; + void SendLootRelease(ObjectGuid guid) const; + void SendNotifyLootItemRemoved(uint8 lootSlot) const; + void SendNotifyLootMoneyRemoved() const; + + /*********************************************************/ + /*** BATTLEGROUND SYSTEM ***/ + /*********************************************************/ + + bool InBattleground() const { return m_bgData.bgInstanceID != 0; } + bool InArena() const; + uint32 GetBattlegroundId() const { return m_bgData.bgInstanceID; } + BattlegroundTypeId GetBattlegroundTypeId() const { return m_bgData.bgTypeID; } + Battleground* GetBattleground() const; + + bool InBattlegroundQueue(bool ignoreArena = false) const; + bool IsDeserter() const { return HasAura(26013); } + + BattlegroundQueueTypeId GetBattlegroundQueueTypeId(uint32 index) const; + uint32 GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const; + bool IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const; + bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const; + + void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId); + uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val); + bool HasFreeBattlegroundQueueId() const; + void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val); + void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId); + bool IsInvitedForBattlegroundInstance(uint32 instanceId) const; + WorldLocation const& GetBattlegroundEntryPoint() const { return m_bgData.joinPos; } + void SetBattlegroundEntryPoint(); - bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const; - bool CanUseBattlegroundObject(GameObject* gameobject) const; - bool isTotalImmune() const; - bool CanCaptureTowerPoint() const; - - bool GetRandomWinner() const { return m_IsBGRandomWinner; } - void SetRandomWinner(bool isWinner); - - /*********************************************************/ - /*** OUTDOOR PVP SYSTEM ***/ - /*********************************************************/ - - OutdoorPvP* GetOutdoorPvP() const; - // returns true if the player is in active state for outdoor pvp objective capturing, false otherwise - bool IsOutdoorPvPActive() const; - - /*********************************************************/ - /*** ENVIROMENTAL SYSTEM ***/ - /*********************************************************/ - - bool IsImmuneToEnvironmentalDamage() const; - uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage); - - /*********************************************************/ - /*** FLOOD FILTER SYSTEM ***/ - /*********************************************************/ - - void UpdateSpeakTime(); - - /*********************************************************/ - /*** VARIOUS SYSTEMS ***/ - /*********************************************************/ - void UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode); - // only changed for direct client control (possess, vehicle etc.), not stuff you control using pet commands - WorldObject* m_seer; - void SetFallInformation(uint32 time, float z); - void HandleFall(MovementInfo const& movementInfo); - - bool CanFlyInZone(uint32 mapid, uint32 zone, SpellInfo const* bySpell) const; - - void SetClientControl(Unit* target, bool allowMove); - - void SetSeer(WorldObject* target) { m_seer = target; } - void SetViewpoint(WorldObject* target, bool apply); - WorldObject* GetViewpoint() const; - void StopCastingCharm(); - void StopCastingBindSight() const; - - uint32 GetSaveTimer() const { return m_nextSave; } - void SetSaveTimer(uint32 timer) { m_nextSave = timer; } - - void SaveRecallPosition() { m_recall_location.WorldRelocate(*this); } - void Recall() { TeleportTo(m_recall_location); } - - void SetHomebind(WorldLocation const& loc, uint32 areaId); - void SendBindPointUpdate(); - - // Homebind coordinates - uint32 m_homebindMapId; - uint16 m_homebindAreaId; - float m_homebindX; - float m_homebindY; - float m_homebindZ; - - WorldLocation GetStartPosition() const; - - // currently visible objects at player client - GuidUnorderedSet m_clientGUIDs; - - bool HaveAtClient(Object const* u) const; - - bool IsNeverVisible() const override; - - bool IsVisibleGloballyFor(Player const* player) const; - - void SendInitialVisiblePackets(Unit* target) const; - void UpdateObjectVisibility(bool forced = true) override; - void UpdateVisibilityForPlayer(); - void UpdateVisibilityOf(WorldObject* target); - void UpdateTriggerVisibility(); - void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite Unit::SetPhaseMask - - template - void UpdateVisibilityOf(T* target, UpdateData& data, std::set& visibleNow); - - uint8 m_forced_speed_changes[MAX_MOVE_TYPE]; - - bool HasAtLoginFlag(AtLoginFlags f) const { return (m_atLoginFlags & f) != 0; } - void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; } - void RemoveAtLoginFlag(AtLoginFlags flags, bool persist = false); - - bool isUsingLfg() const; - bool inRandomLfgDungeon() const; - - typedef std::set DFQuestsDoneList; - DFQuestsDoneList m_DFQuests; - - // Temporarily removed pet cache - uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; } - void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; } - void UnsummonPetTemporaryIfAny(); - void ResummonPetTemporaryUnSummonedIfAny(); - bool IsPetNeedBeTemporaryUnsummoned() const; - - void SendCinematicStart(uint32 CinematicSequenceId) const; - void SendMovieStart(uint32 movieId); - - uint32 DoRandomRoll(uint32 minimum, uint32 maximum); - - /*********************************************************/ - /*** INSTANCE SYSTEM ***/ - /*********************************************************/ - - typedef std::unordered_map< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; - - void UpdateHomebindTime(uint32 time); - - uint32 m_HomebindTimer; - bool m_InstanceValid; - // permanent binds and solo binds by difficulty - BoundInstancesMap m_boundInstances[MAX_DIFFICULTY]; - InstancePlayerBind* GetBoundInstance(uint32 mapid, Difficulty difficulty, bool withExpired = false); - BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; } - InstanceSave* GetInstanceSave(uint32 mapid, bool raid); - void UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload = false); - void UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload = false); - InstancePlayerBind* BindToInstance(InstanceSave* save, bool permanent, BindExtensionState extendState = EXTEND_STATE_NORMAL, bool load = false); - void BindToInstance(); - void SetPendingBind(uint32 instanceId, uint32 bindTimer); - bool HasPendingBind() const { return _pendingBindId > 0; } - void SendRaidInfo(); - void SendSavedInstances(); - bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false); - bool CheckInstanceValidity(bool /*isLogin*/); - bool CheckInstanceCount(uint32 instanceId) const; - void AddInstanceEnterTime(uint32 instanceId, time_t enterTime); - - // last used pet number (for BG's) - uint32 GetLastPetNumber() const { return m_lastpetnumber; } - void SetLastPetNumber(uint32 petnumber) { m_lastpetnumber = petnumber; } - - /*********************************************************/ - /*** GROUP SYSTEM ***/ - /*********************************************************/ - - Group* GetGroupInvite() const { return m_groupInvite; } - void SetGroupInvite(Group* group) { m_groupInvite = group; } - Group* GetGroup() { return m_group.getTarget(); } - Group const* GetGroup() const { return const_cast(m_group.getTarget()); } - GroupReference& GetGroupRef() { return m_group; } - void SetGroup(Group* group, int8 subgroup = -1); - uint8 GetSubGroup() const { return m_group.getSubGroup(); } - uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; } - void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; } - uint64 GetAuraUpdateMaskForRaid() const { return m_auraRaidUpdateMask; } - void SetAuraUpdateMaskForRaid(uint8 slot) { m_auraRaidUpdateMask |= (uint64(1) << slot); } - Player* GetNextRandomRaidMember(float radius); - PartyResult CanUninviteFromGroup(ObjectGuid guidMember = ObjectGuid::Empty) const; - - // Battleground / Battlefield Group System - void SetBattlegroundOrBattlefieldRaid(Group* group, int8 subgroup = -1); - void RemoveFromBattlegroundOrBattlefieldRaid(); - Group* GetOriginalGroup() const { return m_originalGroup.getTarget(); } - GroupReference& GetOriginalGroupRef() { return m_originalGroup; } - uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); } - void SetOriginalGroup(Group* group, int8 subgroup = -1); - - void SetPassOnGroupLoot(bool bPassOnGroupLoot) { m_bPassOnGroupLoot = bPassOnGroupLoot; } - bool GetPassOnGroupLoot() const { return m_bPassOnGroupLoot; } - - MapReference &GetMapRef() { return m_mapRef; } - - // Set map to player and add reference - void SetMap(Map* map) override; - void ResetMap() override; - - bool isAllowedToLoot(Creature const* creature); - - DeclinedName const* GetDeclinedNames() const { return m_declinedname; } - uint8 GetRunesState() const { return m_runes->runeState; } - RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); } - RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->runes[index].CurrentRune); } - uint32 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; } - uint32 GetRuneBaseCooldown(uint8 index); - bool IsBaseRuneSlotsOnCooldown(RuneType runeType) const; - RuneType GetLastUsedRune() const { return m_runes->lastUsedRune; } - void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; } - void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; } - void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; } - void SetRuneCooldown(uint8 index, uint32 cooldown, bool casted = false); - void SetRuneConvertAura(uint8 index, AuraEffect const* aura); - void RemoveRuneConvertAura(uint8 index, AuraEffect const* aura); - void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura); - void RemoveRunesByAuraEffect(AuraEffect const* aura); - void RestoreBaseRune(uint8 index); - void ConvertRune(uint8 index, RuneType newType); - void ResyncRunes() const; - void AddRunePower(uint8 index) const; - void InitRunes(); - - void SendRespondInspectAchievements(Player* player) const; - bool HasAchieved(uint32 achievementId) const; - void ResetAchievements(); - void ResetAchievementCriteria(AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete = false); - void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 = 0, uint32 miscValue2 = 0, WorldObject* ref = nullptr); - void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost = 0); - void RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry); - void CompletedAchievement(AchievementEntry const* entry); - - bool HasTitle(uint32 bitIndex) const; - bool HasTitle(CharTitlesEntry const* title) const; - void SetTitle(CharTitlesEntry const* title, bool lost = false); - - //bool isActiveObject() const { return true; } - bool CanSeeSpellClickOn(Creature const* creature) const; - - uint32 GetChampioningFaction() const { return m_ChampioningFaction; } - void SetChampioningFaction(uint32 faction) { m_ChampioningFaction = faction; } - Spell* m_spellModTakingSpell; - - float GetAverageItemLevel() const; - bool isDebugAreaTriggers; - - void ClearWhisperWhiteList() { WhisperList.clear(); } - void AddWhisperWhiteList(ObjectGuid guid) { WhisperList.push_back(guid); } - bool IsInWhisperWhiteList(ObjectGuid guid); - void RemoveFromWhisperWhiteList(ObjectGuid guid) { WhisperList.remove(guid); } - - bool SetDisableGravity(bool disable, bool packetOnly /* = false */, bool updateAnimationTier = true) override; - bool SetCanFly(bool apply, bool packetOnly = false) override; - bool SetWaterWalking(bool apply, bool packetOnly = false) override; - bool SetFeatherFall(bool apply, bool packetOnly = false) override; - bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true) override; - - bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } - bool CanEnterWater() const override { return true; } - - std::string GetMapAreaAndZoneString() const; - std::string GetCoordsMapAreaAndZoneString() const; - - std::string GetDebugInfo() const override; - - protected: - // Gamemaster whisper whitelist - GuidList WhisperList; - uint32 m_regenTimerCount; - uint32 m_foodEmoteTimerCount; - float m_powerFraction[MAX_POWERS]; - uint32 m_contestedPvPTimer; - - /*********************************************************/ - /*** BATTLEGROUND SYSTEM ***/ - /*********************************************************/ - - /* - this is an array of BG queues (BgTypeIDs) in which is player - */ - struct BgBattlegroundQueueID_Rec - { - BattlegroundQueueTypeId bgQueueTypeId; - uint32 invitedToInstance; - }; - - BgBattlegroundQueueID_Rec m_bgBattlegroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES]; - BGData m_bgData; - - bool m_IsBGRandomWinner; - - /*********************************************************/ - /*** QUEST SYSTEM ***/ - /*********************************************************/ - - //We allow only one timed quest active at the same time. Below can then be simple value instead of set. - typedef std::set QuestSet; - typedef std::set SeasonalQuestSet; - typedef std::unordered_map SeasonalEventQuestMap; - QuestSet m_timedquests; - QuestSet m_weeklyquests; - QuestSet m_monthlyquests; - SeasonalEventQuestMap m_seasonalquests; - - ObjectGuid m_playerSharingQuest; - uint32 m_sharedQuestId; - uint32 m_ingametime; - - /*********************************************************/ - /*** LOAD SYSTEM ***/ - /*********************************************************/ - - void _LoadActions(PreparedQueryResult result); - void _LoadAuras(PreparedQueryResult result, uint32 timediff); - void _LoadGlyphAuras(); - void _LoadBoundInstances(PreparedQueryResult result); - void _LoadInventory(PreparedQueryResult result, uint32 timeDiff); - void _LoadQuestStatus(PreparedQueryResult result); - void _LoadQuestStatusRewarded(PreparedQueryResult result); - void _LoadDailyQuestStatus(PreparedQueryResult result); - void _LoadWeeklyQuestStatus(PreparedQueryResult result); - void _LoadMonthlyQuestStatus(PreparedQueryResult result); - void _LoadSeasonalQuestStatus(PreparedQueryResult result); - void _LoadRandomBGStatus(PreparedQueryResult result); - void _LoadGroup(PreparedQueryResult result); - void _LoadSkills(PreparedQueryResult result); - void _LoadSpells(PreparedQueryResult result); - bool _LoadHomeBind(PreparedQueryResult result); - void _LoadDeclinedNames(PreparedQueryResult result); - void _LoadArenaTeamInfo(PreparedQueryResult result); - void _LoadEquipmentSets(PreparedQueryResult result); - void _LoadBGData(PreparedQueryResult result); - void _LoadGlyphs(PreparedQueryResult result); - void _LoadTalents(PreparedQueryResult result); - void _LoadInstanceTimeRestrictions(PreparedQueryResult result); - void _LoadPetStable(uint8 petStableSlots, PreparedQueryResult result); - - /*********************************************************/ - /*** SAVE SYSTEM ***/ - /*********************************************************/ - - void _SaveActions(CharacterDatabaseTransaction trans); - void _SaveAuras(CharacterDatabaseTransaction trans); - void _SaveInventory(CharacterDatabaseTransaction trans); - void _SaveQuestStatus(CharacterDatabaseTransaction trans); - void _SaveDailyQuestStatus(CharacterDatabaseTransaction trans); - void _SaveWeeklyQuestStatus(CharacterDatabaseTransaction trans); - void _SaveMonthlyQuestStatus(CharacterDatabaseTransaction trans); - void _SaveSeasonalQuestStatus(CharacterDatabaseTransaction trans); - void _SaveSkills(CharacterDatabaseTransaction trans); - void _SaveSpells(CharacterDatabaseTransaction trans); - void _SaveEquipmentSets(CharacterDatabaseTransaction trans); - void _SaveBGData(CharacterDatabaseTransaction trans); - void _SaveGlyphs(CharacterDatabaseTransaction trans) const; - void _SaveTalents(CharacterDatabaseTransaction trans); - void _SaveStats(CharacterDatabaseTransaction trans) const; - void _SaveInstanceTimeRestrictions(CharacterDatabaseTransaction trans); - - /*********************************************************/ - /*** ENVIRONMENTAL SYSTEM ***/ - /*********************************************************/ - void HandleSobering(); - void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen); - void StopMirrorTimer(MirrorTimerType Type); - void HandleDrowning(uint32 time_diff); - int32 getMaxTimer(MirrorTimerType timer) const; - - /*********************************************************/ - /*** HONOR SYSTEM ***/ - /*********************************************************/ - time_t m_lastHonorUpdateTime; - - void outDebugValues() const; - ObjectGuid m_lootGuid; - - uint32 m_team; - uint32 m_nextSave; - time_t m_speakTime; - uint32 m_speakCount; - Difficulty m_dungeonDifficulty; - Difficulty m_raidDifficulty; - Difficulty m_raidMapDifficulty; - - uint32 m_atLoginFlags; - - Item* m_items[PLAYER_SLOTS_COUNT]; - uint32 m_currentBuybackSlot; - - std::vector m_itemUpdateQueue; - bool m_itemUpdateQueueBlocked; - - uint32 m_ExtraFlags; - - QuestStatusMap m_QuestStatus; - QuestStatusSaveMap m_QuestStatusSave; - - RewardedQuestSet m_RewardedQuests; - QuestStatusSaveMap m_RewardedQuestsSave; - - SkillStatusMap mSkillStatus; - - uint32 m_GuildIdInvited; - uint32 m_ArenaTeamIdInvited; - - PlayerSpellMap m_spells; - PlayerTalentMap* m_talents[MAX_TALENT_SPECS]; - uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use - - uint8 m_activeSpec; - uint8 m_specsCount; - - uint32 m_Glyphs[MAX_TALENT_SPECS][MAX_GLYPH_SLOT_INDEX]; - - ActionButtonList m_actionButtons; - - float m_auraBaseFlatMod[BASEMOD_END]; - float m_auraBasePctMod[BASEMOD_END]; - int16 m_baseRatingValue[MAX_COMBAT_RATING]; - uint32 m_baseSpellPower; - uint32 m_baseFeralAP; - uint32 m_baseManaRegen; - uint32 m_baseHealthRegen; - int32 m_spellPenetrationItemMod; - - SpellModContainer m_spellMods[MAX_SPELLMOD]; - - EnchantDurationList m_enchantDuration; - ItemDurationList m_itemDuration; - GuidUnorderedSet m_itemSoulboundTradeable; - - std::unique_ptr _resurrectionData; - - WorldSession* m_session; + void SetBGTeam(uint32 team); + uint32 GetBGTeam() const; - JoinedChannelsList m_channels; + void LeaveBattleground(bool teleportToEntryPoint = true); + bool CanJoinToBattleground(Battleground const* bg) const; + bool CanReportAfkDueToLimit(); + void ReportedAfkBy(Player* reporter); + void ClearAfkReports() { m_bgData.bgAfkReporter.clear(); } - uint8 m_cinematic; + bool GetBGAccessByLevel(BattlegroundTypeId bgTypeId) const; + bool CanUseBattlegroundObject(GameObject* gameobject) const; + bool isTotalImmune() const; + bool CanCaptureTowerPoint() const; + + bool GetRandomWinner() const { return m_IsBGRandomWinner; } + void SetRandomWinner(bool isWinner); + + /*********************************************************/ + /*** OUTDOOR PVP SYSTEM ***/ + /*********************************************************/ + + OutdoorPvP* GetOutdoorPvP() const; + // returns true if the player is in active state for outdoor pvp objective capturing, false otherwise + bool IsOutdoorPvPActive() const; + + /*********************************************************/ + /*** ENVIROMENTAL SYSTEM ***/ + /*********************************************************/ + + bool IsImmuneToEnvironmentalDamage() const; + uint32 EnvironmentalDamage(EnviromentalDamage type, uint32 damage); + + /*********************************************************/ + /*** FLOOD FILTER SYSTEM ***/ + /*********************************************************/ + + void UpdateSpeakTime(); + + /*********************************************************/ + /*** VARIOUS SYSTEMS ***/ + /*********************************************************/ + void UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode); + // only changed for direct client control (possess, vehicle etc.), not stuff you control using pet commands + WorldObject* m_seer; + void SetFallInformation(uint32 time, float z); + void HandleFall(MovementInfo const& movementInfo); + + bool CanFlyInZone(uint32 mapid, uint32 zone, SpellInfo const* bySpell) const; + + void SetClientControl(Unit* target, bool allowMove); + + void SetSeer(WorldObject* target) { m_seer = target; } + void SetViewpoint(WorldObject* target, bool apply); + WorldObject* GetViewpoint() const; + void StopCastingCharm(); + void StopCastingBindSight() const; + + uint32 GetSaveTimer() const { return m_nextSave; } + void SetSaveTimer(uint32 timer) { m_nextSave = timer; } + + void SaveRecallPosition() { m_recall_location.WorldRelocate(*this); } + void Recall() { TeleportTo(m_recall_location); } + + void SetHomebind(WorldLocation const& loc, uint32 areaId); + void SendBindPointUpdate(); + + // Homebind coordinates + uint32 m_homebindMapId; + uint16 m_homebindAreaId; + float m_homebindX; + float m_homebindY; + float m_homebindZ; + + WorldLocation GetStartPosition() const; + + // currently visible objects at player client + GuidUnorderedSet m_clientGUIDs; + + bool HaveAtClient(Object const* u) const; + + bool IsNeverVisible() const override; + + bool IsVisibleGloballyFor(Player const* player) const; + + void SendInitialVisiblePackets(Unit* target) const; + void UpdateObjectVisibility(bool forced = true) override; + void UpdateVisibilityForPlayer(); + void UpdateVisibilityOf(WorldObject* target); + void UpdateTriggerVisibility(); + void SetPhaseMask(uint32 newPhaseMask, bool update) override;// overwrite Unit::SetPhaseMask + + template + void UpdateVisibilityOf(T* target, UpdateData& data, std::set& visibleNow); + + uint8 m_forced_speed_changes[MAX_MOVE_TYPE]; + + bool HasAtLoginFlag(AtLoginFlags f) const { return (m_atLoginFlags & f) != 0; } + void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; } + void RemoveAtLoginFlag(AtLoginFlags flags, bool persist = false); + + bool isUsingLfg() const; + bool inRandomLfgDungeon() const; + + typedef std::set DFQuestsDoneList; + DFQuestsDoneList m_DFQuests; + + // Temporarily removed pet cache + uint32 GetTemporaryUnsummonedPetNumber() const { return m_temporaryUnsummonedPetNumber; } + void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; } + void UnsummonPetTemporaryIfAny(); + void ResummonPetTemporaryUnSummonedIfAny(); + bool IsPetNeedBeTemporaryUnsummoned() const; + + void SendCinematicStart(uint32 CinematicSequenceId) const; + void SendMovieStart(uint32 movieId); + + uint32 DoRandomRoll(uint32 minimum, uint32 maximum); + + /*********************************************************/ + /*** INSTANCE SYSTEM ***/ + /*********************************************************/ + + typedef std::unordered_map< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; + + void UpdateHomebindTime(uint32 time); + + uint32 m_HomebindTimer; + bool m_InstanceValid; + // permanent binds and solo binds by difficulty + BoundInstancesMap m_boundInstances[MAX_DIFFICULTY]; + InstancePlayerBind* GetBoundInstance(uint32 mapid, Difficulty difficulty, bool withExpired = false); + BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; } + InstanceSave* GetInstanceSave(uint32 mapid, bool raid); + void UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload = false); + void UnbindInstance(BoundInstancesMap::iterator& itr, Difficulty difficulty, bool unload = false); + InstancePlayerBind* BindToInstance(InstanceSave* save, bool permanent, BindExtensionState extendState = EXTEND_STATE_NORMAL, bool load = false); + void BindToInstance(); + void SetPendingBind(uint32 instanceId, uint32 bindTimer); + bool HasPendingBind() const { return _pendingBindId > 0; } + void SendRaidInfo(); + void SendSavedInstances(); + bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false); + bool CheckInstanceValidity(bool /*isLogin*/); + bool CheckInstanceCount(uint32 instanceId) const; + void AddInstanceEnterTime(uint32 instanceId, time_t enterTime); + + // last used pet number (for BG's) + uint32 GetLastPetNumber() const { return m_lastpetnumber; } + void SetLastPetNumber(uint32 petnumber) { m_lastpetnumber = petnumber; } + + /*********************************************************/ + /*** GROUP SYSTEM ***/ + /*********************************************************/ + + Group* GetGroupInvite() const { return m_groupInvite; } + void SetGroupInvite(Group* group) { m_groupInvite = group; } + Group* GetGroup() { return m_group.getTarget(); } + Group const* GetGroup() const { return const_cast(m_group.getTarget()); } + GroupReference& GetGroupRef() { return m_group; } + void SetGroup(Group* group, int8 subgroup = -1); + uint8 GetSubGroup() const { return m_group.getSubGroup(); } + uint32 GetGroupUpdateFlag() const { return m_groupUpdateMask; } + void SetGroupUpdateFlag(uint32 flag) { m_groupUpdateMask |= flag; } + uint64 GetAuraUpdateMaskForRaid() const { return m_auraRaidUpdateMask; } + void SetAuraUpdateMaskForRaid(uint8 slot) { m_auraRaidUpdateMask |= (uint64(1) << slot); } + Player* GetNextRandomRaidMember(float radius); + PartyResult CanUninviteFromGroup(ObjectGuid guidMember = ObjectGuid::Empty) const; + + // Battleground / Battlefield Group System + void SetBattlegroundOrBattlefieldRaid(Group* group, int8 subgroup = -1); + void RemoveFromBattlegroundOrBattlefieldRaid(); + Group* GetOriginalGroup() const { return m_originalGroup.getTarget(); } + GroupReference& GetOriginalGroupRef() { return m_originalGroup; } + uint8 GetOriginalSubGroup() const { return m_originalGroup.getSubGroup(); } + void SetOriginalGroup(Group* group, int8 subgroup = -1); + + void SetPassOnGroupLoot(bool bPassOnGroupLoot) { m_bPassOnGroupLoot = bPassOnGroupLoot; } + bool GetPassOnGroupLoot() const { return m_bPassOnGroupLoot; } + + MapReference& GetMapRef() { return m_mapRef; } + + // Set map to player and add reference + void SetMap(Map* map) override; + void ResetMap() override; + + bool isAllowedToLoot(Creature const* creature); + + DeclinedName const* GetDeclinedNames() const { return m_declinedname; } + uint8 GetRunesState() const { return m_runes->runeState; } + RuneType GetBaseRune(uint8 index) const { return RuneType(m_runes->runes[index].BaseRune); } + RuneType GetCurrentRune(uint8 index) const { return RuneType(m_runes->runes[index].CurrentRune); } + uint32 GetRuneCooldown(uint8 index) const { return m_runes->runes[index].Cooldown; } + uint32 GetRuneBaseCooldown(uint8 index); + bool IsBaseRuneSlotsOnCooldown(RuneType runeType) const; + RuneType GetLastUsedRune() const { return m_runes->lastUsedRune; } + void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; } + void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; } + void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; } + void SetRuneCooldown(uint8 index, uint32 cooldown, bool casted = false); + void SetRuneConvertAura(uint8 index, AuraEffect const* aura); + void RemoveRuneConvertAura(uint8 index, AuraEffect const* aura); + void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura); + void RemoveRunesByAuraEffect(AuraEffect const* aura); + void RestoreBaseRune(uint8 index); + void ConvertRune(uint8 index, RuneType newType); + void ResyncRunes() const; + void AddRunePower(uint8 index) const; + void InitRunes(); + + void SendRespondInspectAchievements(Player* player) const; + bool HasAchieved(uint32 achievementId) const; + void ResetAchievements(); + void ResetAchievementCriteria(AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete = false); + void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 = 0, uint32 miscValue2 = 0, WorldObject* ref = nullptr); + void StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry, uint32 timeLost = 0); + void RemoveTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry); + void CompletedAchievement(AchievementEntry const* entry); + + bool HasTitle(uint32 bitIndex) const; + bool HasTitle(CharTitlesEntry const* title) const; + void SetTitle(CharTitlesEntry const* title, bool lost = false); + + //bool isActiveObject() const { return true; } + bool CanSeeSpellClickOn(Creature const* creature) const; + + uint32 GetChampioningFaction() const { return m_ChampioningFaction; } + void SetChampioningFaction(uint32 faction) { m_ChampioningFaction = faction; } + Spell* m_spellModTakingSpell; + + float GetAverageItemLevel() const; + bool isDebugAreaTriggers; + + void ClearWhisperWhiteList() { WhisperList.clear(); } + void AddWhisperWhiteList(ObjectGuid guid) { WhisperList.push_back(guid); } + bool IsInWhisperWhiteList(ObjectGuid guid); + void RemoveFromWhisperWhiteList(ObjectGuid guid) { WhisperList.remove(guid); } + + bool SetDisableGravity(bool disable, bool packetOnly /* = false */, bool updateAnimationTier = true) override; + bool SetCanFly(bool apply, bool packetOnly = false) override; + bool SetWaterWalking(bool apply, bool packetOnly = false) override; + bool SetFeatherFall(bool apply, bool packetOnly = false) override; + bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true) override; + + bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } + bool CanEnterWater() const override { return true; } + + std::string GetMapAreaAndZoneString() const; + std::string GetCoordsMapAreaAndZoneString() const; + + std::string GetDebugInfo() const override; + +protected: + // Gamemaster whisper whitelist + GuidList WhisperList; + uint32 m_regenTimerCount; + uint32 m_foodEmoteTimerCount; + float m_powerFraction[MAX_POWERS]; + uint32 m_contestedPvPTimer; + + /*********************************************************/ + /*** BATTLEGROUND SYSTEM ***/ + /*********************************************************/ + + /* + this is an array of BG queues (BgTypeIDs) in which is player + */ + struct BgBattlegroundQueueID_Rec + { + BattlegroundQueueTypeId bgQueueTypeId; + uint32 invitedToInstance; + }; + + BgBattlegroundQueueID_Rec m_bgBattlegroundQueueID[PLAYER_MAX_BATTLEGROUND_QUEUES]; + BGData m_bgData; + + bool m_IsBGRandomWinner; + + /*********************************************************/ + /*** QUEST SYSTEM ***/ + /*********************************************************/ + + //We allow only one timed quest active at the same time. Below can then be simple value instead of set. + typedef std::set QuestSet; + typedef std::set SeasonalQuestSet; + typedef std::unordered_map SeasonalEventQuestMap; + QuestSet m_timedquests; + QuestSet m_weeklyquests; + QuestSet m_monthlyquests; + SeasonalEventQuestMap m_seasonalquests; + + ObjectGuid m_playerSharingQuest; + uint32 m_sharedQuestId; + uint32 m_ingametime; + + /*********************************************************/ + /*** LOAD SYSTEM ***/ + /*********************************************************/ + + void _LoadActions(PreparedQueryResult result); + void _LoadAuras(PreparedQueryResult result, uint32 timediff); + void _LoadGlyphAuras(); + void _LoadBoundInstances(PreparedQueryResult result); + void _LoadInventory(PreparedQueryResult result, uint32 timeDiff); + void _LoadQuestStatus(PreparedQueryResult result); + void _LoadQuestStatusRewarded(PreparedQueryResult result); + void _LoadDailyQuestStatus(PreparedQueryResult result); + void _LoadWeeklyQuestStatus(PreparedQueryResult result); + void _LoadMonthlyQuestStatus(PreparedQueryResult result); + void _LoadSeasonalQuestStatus(PreparedQueryResult result); + void _LoadRandomBGStatus(PreparedQueryResult result); + void _LoadGroup(PreparedQueryResult result); + void _LoadSkills(PreparedQueryResult result); + void _LoadSpells(PreparedQueryResult result); + bool _LoadHomeBind(PreparedQueryResult result); + void _LoadDeclinedNames(PreparedQueryResult result); + void _LoadArenaTeamInfo(PreparedQueryResult result); + void _LoadEquipmentSets(PreparedQueryResult result); + void _LoadBGData(PreparedQueryResult result); + void _LoadGlyphs(PreparedQueryResult result); + void _LoadTalents(PreparedQueryResult result); + void _LoadInstanceTimeRestrictions(PreparedQueryResult result); + void _LoadPetStable(uint8 petStableSlots, PreparedQueryResult result); + + /*********************************************************/ + /*** SAVE SYSTEM ***/ + /*********************************************************/ + + void _SaveActions(CharacterDatabaseTransaction trans); + void _SaveAuras(CharacterDatabaseTransaction trans); + void _SaveInventory(CharacterDatabaseTransaction trans); + void _SaveQuestStatus(CharacterDatabaseTransaction trans); + void _SaveDailyQuestStatus(CharacterDatabaseTransaction trans); + void _SaveWeeklyQuestStatus(CharacterDatabaseTransaction trans); + void _SaveMonthlyQuestStatus(CharacterDatabaseTransaction trans); + void _SaveSeasonalQuestStatus(CharacterDatabaseTransaction trans); + void _SaveSkills(CharacterDatabaseTransaction trans); + void _SaveSpells(CharacterDatabaseTransaction trans); + void _SaveEquipmentSets(CharacterDatabaseTransaction trans); + void _SaveBGData(CharacterDatabaseTransaction trans); + void _SaveGlyphs(CharacterDatabaseTransaction trans) const; + void _SaveTalents(CharacterDatabaseTransaction trans); + void _SaveStats(CharacterDatabaseTransaction trans) const; + void _SaveInstanceTimeRestrictions(CharacterDatabaseTransaction trans); + + /*********************************************************/ + /*** ENVIRONMENTAL SYSTEM ***/ + /*********************************************************/ + void HandleSobering(); + void SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 CurrentValue, int32 Regen); + void StopMirrorTimer(MirrorTimerType Type); + void HandleDrowning(uint32 time_diff); + int32 getMaxTimer(MirrorTimerType timer) const; + + /*********************************************************/ + /*** HONOR SYSTEM ***/ + /*********************************************************/ + time_t m_lastHonorUpdateTime; + + void outDebugValues() const; + ObjectGuid m_lootGuid; + + uint32 m_team; + uint32 m_nextSave; + time_t m_speakTime; + uint32 m_speakCount; + Difficulty m_dungeonDifficulty; + Difficulty m_raidDifficulty; + Difficulty m_raidMapDifficulty; + + uint32 m_atLoginFlags; + + Item* m_items[PLAYER_SLOTS_COUNT]; + uint32 m_currentBuybackSlot; + + std::vector m_itemUpdateQueue; + bool m_itemUpdateQueueBlocked; + + uint32 m_ExtraFlags; + + QuestStatusMap m_QuestStatus; + QuestStatusSaveMap m_QuestStatusSave; + + RewardedQuestSet m_RewardedQuests; + QuestStatusSaveMap m_RewardedQuestsSave; + + SkillStatusMap mSkillStatus; + + uint32 m_GuildIdInvited; + uint32 m_ArenaTeamIdInvited; + + PlayerSpellMap m_spells; + PlayerTalentMap* m_talents[MAX_TALENT_SPECS]; + uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use + + uint8 m_activeSpec; + uint8 m_specsCount; + + uint32 m_Glyphs[MAX_TALENT_SPECS][MAX_GLYPH_SLOT_INDEX]; + + ActionButtonList m_actionButtons; + + float m_auraBaseFlatMod[BASEMOD_END]; + float m_auraBasePctMod[BASEMOD_END]; + int16 m_baseRatingValue[MAX_COMBAT_RATING]; + uint32 m_baseSpellPower; + uint32 m_baseFeralAP; + uint32 m_baseManaRegen; + uint32 m_baseHealthRegen; + int32 m_spellPenetrationItemMod; + + SpellModContainer m_spellMods[MAX_SPELLMOD]; + + EnchantDurationList m_enchantDuration; + ItemDurationList m_itemDuration; + GuidUnorderedSet m_itemSoulboundTradeable; + + std::unique_ptr _resurrectionData; + + WorldSession* m_session; + + JoinedChannelsList m_channels; - uint32 m_movie; + uint8 m_cinematic; - TradeData* m_trade; + uint32 m_movie; - bool m_DailyQuestChanged; - bool m_WeeklyQuestChanged; - bool m_MonthlyQuestChanged; - bool m_SeasonalQuestChanged; - time_t m_lastDailyQuestTime; + TradeData* m_trade; + + bool m_DailyQuestChanged; + bool m_WeeklyQuestChanged; + bool m_MonthlyQuestChanged; + bool m_SeasonalQuestChanged; + time_t m_lastDailyQuestTime; - uint32 m_hostileReferenceCheckTimer; - uint32 m_drunkTimer; - uint32 m_weaponChangeTimer; + uint32 m_hostileReferenceCheckTimer; + uint32 m_drunkTimer; + uint32 m_weaponChangeTimer; - uint32 m_zoneUpdateId; - uint32 m_zoneUpdateTimer; - uint32 m_areaUpdateId; + uint32 m_zoneUpdateId; + uint32 m_zoneUpdateTimer; + uint32 m_areaUpdateId; - uint32 m_deathTimer; - time_t m_deathExpireTime; + uint32 m_deathTimer; + time_t m_deathExpireTime; - uint32 m_WeaponProficiency; - uint32 m_ArmorProficiency; - bool m_canParry; - bool m_canBlock; - bool m_canTitanGrip; - uint32 m_titanGripPenaltySpellId; - uint8 m_swingErrorMsg; - float m_ammoDPS; + uint32 m_WeaponProficiency; + uint32 m_ArmorProficiency; + bool m_canParry; + bool m_canBlock; + bool m_canTitanGrip; + uint32 m_titanGripPenaltySpellId; + uint8 m_swingErrorMsg; + float m_ammoDPS; - ////////////////////Rest System///////////////////// - time_t _restTime; - uint32 inn_triggerId; - float m_rest_bonus; - uint32 _restFlagMask; - ////////////////////Rest System///////////////////// - uint32 m_resetTalentsCost; - time_t m_resetTalentsTime; - uint32 m_usedTalentCount; - uint32 m_questRewardTalentCount; + ////////////////////Rest System///////////////////// + time_t _restTime; + uint32 inn_triggerId; + float m_rest_bonus; + uint32 _restFlagMask; + ////////////////////Rest System///////////////////// + uint32 m_resetTalentsCost; + time_t m_resetTalentsTime; + uint32 m_usedTalentCount; + uint32 m_questRewardTalentCount; - // Social - PlayerSocial* m_social; + // Social + PlayerSocial* m_social; - // Groups - GroupReference m_group; - GroupReference m_originalGroup; - Group* m_groupInvite; - uint32 m_groupUpdateMask; - uint64 m_auraRaidUpdateMask; - bool m_bPassOnGroupLoot; + // Groups + GroupReference m_group; + GroupReference m_originalGroup; + Group* m_groupInvite; + uint32 m_groupUpdateMask; + uint64 m_auraRaidUpdateMask; + bool m_bPassOnGroupLoot; - // last used pet number (for BG's) - uint32 m_lastpetnumber; + // last used pet number (for BG's) + uint32 m_lastpetnumber; - // Player summoning - time_t m_summon_expire; - WorldLocation m_summon_location; + // Player summoning + time_t m_summon_expire; + WorldLocation m_summon_location; - // Recall position - WorldLocation m_recall_location; + // Recall position + WorldLocation m_recall_location; - DeclinedName *m_declinedname; - Runes *m_runes; - EquipmentSetContainer _equipmentSets; + DeclinedName* m_declinedname; + Runes* m_runes; + EquipmentSetContainer _equipmentSets; - bool CanAlwaysSee(WorldObject const* obj) const override; + bool CanAlwaysSee(WorldObject const* obj) const override; - bool IsAlwaysDetectableFor(WorldObject const* seer) const override; + bool IsAlwaysDetectableFor(WorldObject const* seer) const override; - uint8 m_grantableLevels; + uint8 m_grantableLevels; - uint8 m_fishingSteps; + uint8 m_fishingSteps; - bool m_needsZoneUpdate; + bool m_needsZoneUpdate; - TimeTracker m_groupUpdateTimer; + TimeTracker m_groupUpdateTimer; - private: - // internal common parts for CanStore/StoreItem functions - InventoryResult CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const; - InventoryResult CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; - InventoryResult CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, uint8 skip_slot) const; - Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update); - Item* _LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint32 timeDiff, Field* fields); +private: + // internal common parts for CanStore/StoreItem functions + InventoryResult CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const; + InventoryResult CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, bool non_specialized, Item* pSrcItem, uint8 skip_bag, + uint8 skip_slot) const; + InventoryResult CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool merge, Item* pSrcItem, uint8 skip_bag, + uint8 skip_slot) const; + Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update); + Item* _LoadItem(CharacterDatabaseTransaction trans, uint32 zoneId, uint32 timeDiff, Field* fields); - CinematicMgr* _cinematicMgr; + CinematicMgr* _cinematicMgr; - GuidSet m_refundableItems; - void SendRefundInfo(Item* item); - void RefundItem(Item* item); + GuidSet m_refundableItems; + void SendRefundInfo(Item* item); + void RefundItem(Item* item); - // know currencies are not removed at any point (0 displayed) - void AddKnownCurrency(uint32 itemId); + // know currencies are not removed at any point (0 displayed) + void AddKnownCurrency(uint32 itemId); - void AdjustQuestReqItemCount(Quest const* quest, QuestStatusData& questStatusData); + void AdjustQuestReqItemCount(Quest const* quest, QuestStatusData& questStatusData); - bool IsCanDelayTeleport() const { return m_bCanDelayTeleport; } - void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; } - bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; } - void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; } - void ScheduleDelayedOperation(uint32 operation) { if (operation < DELAYED_END) m_DelayedOperations |= operation; } + bool IsCanDelayTeleport() const { return m_bCanDelayTeleport; } + void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; } + bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; } + void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; } + void ScheduleDelayedOperation(uint32 operation) { if (operation < DELAYED_END) m_DelayedOperations |= operation; } - bool IsInstanceLoginGameMasterException() const; + bool IsInstanceLoginGameMasterException() const; - MapReference m_mapRef; + MapReference m_mapRef; - uint32 m_lastFallTime; - float m_lastFallZ; + uint32 m_lastFallTime; + float m_lastFallZ; - int32 m_MirrorTimer[MAX_TIMERS]; - uint8 m_MirrorTimerFlags; - uint8 m_MirrorTimerFlagsLast; - bool m_isInWater; + int32 m_MirrorTimer[MAX_TIMERS]; + uint8 m_MirrorTimerFlags; + uint8 m_MirrorTimerFlagsLast; + bool m_isInWater; - // Rune type / Rune timer - uint32 m_runeGraceCooldown[MAX_RUNES]; - uint32 m_lastRuneGraceTimers[MAX_RUNES]; + // Rune type / Rune timer + uint32 m_runeGraceCooldown[MAX_RUNES]; + uint32 m_lastRuneGraceTimers[MAX_RUNES]; - // Current teleport data - WorldLocation m_teleport_dest; - uint32 m_teleport_options; - bool mSemaphoreTeleport_Near; - bool mSemaphoreTeleport_Far; + // Current teleport data + WorldLocation m_teleport_dest; + uint32 m_teleport_options; + bool mSemaphoreTeleport_Near; + bool mSemaphoreTeleport_Far; - uint32 m_DelayedOperations; - bool m_bCanDelayTeleport; - bool m_bHasDelayedTeleport; + uint32 m_DelayedOperations; + bool m_bCanDelayTeleport; + bool m_bHasDelayedTeleport; - /*********************************************************/ - /*** Atiesh FEATURES ***/ - /*********************************************************/// + /*********************************************************/ + /*** Atiesh FEATURES ***/ + /*********************************************************/// - // others - uint32 m_auctionlots; // Auction lots count for all auctions + // others + uint32 m_auctionlots; // Auction lots count for all auctions - //End of Atiesh features + //End of Atiesh features - std::unique_ptr m_petStable; + std::unique_ptr m_petStable; - // Temporary removed pet cache - uint32 m_temporaryUnsummonedPetNumber; - uint32 m_oldpetspell; + // Temporary removed pet cache + uint32 m_temporaryUnsummonedPetNumber; + uint32 m_oldpetspell; - AchievementMgr* m_achievementMgr; - ReputationMgr* m_reputationMgr; + AchievementMgr* m_achievementMgr; + ReputationMgr* m_reputationMgr; - uint32 m_ChampioningFaction; + uint32 m_ChampioningFaction; - InstanceTimeMap _instanceResetTimes; - uint32 _pendingBindId; - uint32 _pendingBindTimer; + InstanceTimeMap _instanceResetTimes; + uint32 _pendingBindId; + uint32 _pendingBindTimer; - uint32 _activeCheats; + uint32 _activeCheats; - // variables to save health and mana before duel and restore them after duel - uint32 healthBeforeDuel; - uint32 manaBeforeDuel; + // variables to save health and mana before duel and restore them after duel + uint32 healthBeforeDuel; + uint32 manaBeforeDuel; - WorldLocation _corpseLocation; + WorldLocation _corpseLocation; }; WH_GAME_API void AddItemsSetItem(Player* player, Item* item); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 03a104ed903f8..303b3cc7643aa 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -283,7 +283,7 @@ void Spell::EffectInstaKill(SpellEffIndex /*effIndex*/) if (m_caster == unitTarget) // prevent interrupt message finish(); - WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8+8+4); + WorldPacket data(SMSG_SPELLINSTAKILLLOG, 8 + 8 + 4); data << uint64(m_caster->GetGUID()); data << uint64(unitTarget->GetGUID()); data << uint32(m_spellInfo->Id); @@ -327,361 +327,361 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex) Unit* unitCaster = GetUnitCasterForEffectHandlers(); switch (m_spellInfo->SpellFamilyName) { - case SPELLFAMILY_GENERIC: + case SPELLFAMILY_GENERIC: + { + // Meteor like spells (divided damage to targets) + if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_SHARE_DAMAGE)) { - // Meteor like spells (divided damage to targets) - if (m_spellInfo->HasAttribute(SPELL_ATTR0_CU_SHARE_DAMAGE)) + uint32 count = 0; + for (auto ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { - uint32 count = 0; - for (auto ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - { - if (ihit->MissCondition != SPELL_MISS_NONE) - continue; - - if (ihit->EffectMask & (1 << effIndex)) - ++count; - } + if (ihit->MissCondition != SPELL_MISS_NONE) + continue; - // divide to all targets - if (count) - damage /= count; + if (ihit->EffectMask & (1 << effIndex)) + ++count; } + // divide to all targets + if (count) + damage /= count; + } + + break; + } + case SPELLFAMILY_WARRIOR: + { + if (!unitCaster) break; + + // Shield Slam + if ((m_spellInfo->SpellFamilyFlags[1] & 0x200) && m_spellInfo->GetCategory() == 1209) + { + uint8 level = unitCaster->GetLevel(); + uint32 block_value = unitCaster->GetShieldBlockValue(uint32(float(level) * 24.5f), uint32(float(level) * 34.5f)); + damage += int32(unitCaster->ApplyEffectModifiers(m_spellInfo, effIndex, float(block_value))); } - case SPELLFAMILY_WARRIOR: + // Victory Rush + else if (m_spellInfo->SpellFamilyFlags[1] & 0x100) + ApplyPct(damage, unitCaster->GetTotalAttackPowerValue(BASE_ATTACK)); + // Shockwave + else if (m_spellInfo->Id == 46968) { - if (!unitCaster) - break; + int32 pct = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_2); + if (pct > 0) + damage += int32(CalculatePct(unitCaster->GetTotalAttackPowerValue(BASE_ATTACK), pct)); + break; + } + break; + } + case SPELLFAMILY_WARLOCK: + { + if (!unitCaster) + break; - // Shield Slam - if ((m_spellInfo->SpellFamilyFlags[1] & 0x200) && m_spellInfo->GetCategory() == 1209) - { - uint8 level = unitCaster->GetLevel(); - uint32 block_value = unitCaster->GetShieldBlockValue(uint32(float(level) * 24.5f), uint32(float(level) * 34.5f)); - damage += int32(unitCaster->ApplyEffectModifiers(m_spellInfo, effIndex, float(block_value))); - } - // Victory Rush - else if (m_spellInfo->SpellFamilyFlags[1] & 0x100) - ApplyPct(damage, unitCaster->GetTotalAttackPowerValue(BASE_ATTACK)); - // Shockwave - else if (m_spellInfo->Id == 46968) + // Incinerate Rank 1 & 2 + if ((m_spellInfo->SpellFamilyFlags[1] & 0x000040) && m_spellInfo->SpellIconID == 2128) + { + // Incinerate does more dmg (dmg*0.25) if the target have Immolate debuff. + // Check aura state for speed but aura state set not only for Immolate spell + if (unitTarget->HasAuraState(AURA_STATE_CONFLAGRATE)) { - int32 pct = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_2); - if (pct > 0) - damage += int32(CalculatePct(unitCaster->GetTotalAttackPowerValue(BASE_ATTACK), pct)); - break; + if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x4, 0, 0)) + damage += damage / 4; } - break; } - case SPELLFAMILY_WARLOCK: + // Conflagrate - consumes Immolate or Shadowflame + else if (m_spellInfo->TargetAuraState == AURA_STATE_CONFLAGRATE) { - if (!unitCaster) - break; + AuraEffect const* aura = nullptr; // found req. aura for damage calculation - // Incinerate Rank 1 & 2 - if ((m_spellInfo->SpellFamilyFlags[1] & 0x000040) && m_spellInfo->SpellIconID == 2128) - { - // Incinerate does more dmg (dmg*0.25) if the target have Immolate debuff. - // Check aura state for speed but aura state set not only for Immolate spell - if (unitTarget->HasAuraState(AURA_STATE_CONFLAGRATE)) - { - if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x4, 0, 0)) - damage += damage / 4; - } - } - // Conflagrate - consumes Immolate or Shadowflame - else if (m_spellInfo->TargetAuraState == AURA_STATE_CONFLAGRATE) + Unit::AuraEffectList const& mPeriodic = unitTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); + for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) { - AuraEffect const* aura = nullptr; // found req. aura for damage calculation - - Unit::AuraEffectList const& mPeriodic = unitTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); - for (Unit::AuraEffectList::const_iterator i = mPeriodic.begin(); i != mPeriodic.end(); ++i) - { - // for caster applied auras only - if ((*i)->GetSpellInfo()->SpellFamilyName != SPELLFAMILY_WARLOCK || + // for caster applied auras only + if ((*i)->GetSpellInfo()->SpellFamilyName != SPELLFAMILY_WARLOCK || (*i)->GetCasterGUID() != unitCaster->GetGUID()) - continue; - - // Immolate - if ((*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x4) - { - aura = *i; // it selected always if exist - break; - } + continue; - // Shadowflame - if ((*i)->GetSpellInfo()->SpellFamilyFlags[2] & 0x00000002) - aura = *i; // remember but wait possible Immolate as primary priority + // Immolate + if ((*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x4) + { + aura = *i; // it selected always if exist + break; } - // found Immolate or Shadowflame - if (aura) - { - // Calculate damage of Immolate/Shadowflame tick - int32 pdamage = aura->GetAmount(); - pdamage = unitTarget->SpellDamageBonusTaken(unitCaster, aura->GetSpellInfo(), pdamage, DOT); + // Shadowflame + if ((*i)->GetSpellInfo()->SpellFamilyFlags[2] & 0x00000002) + aura = *i; // remember but wait possible Immolate as primary priority + } - // And multiply by amount of ticks to get damage potential - pdamage *= aura->GetSpellInfo()->GetMaxTicks(); + // found Immolate or Shadowflame + if (aura) + { + // Calculate damage of Immolate/Shadowflame tick + int32 pdamage = aura->GetAmount(); + pdamage = unitTarget->SpellDamageBonusTaken(unitCaster, aura->GetSpellInfo(), pdamage, DOT); - int32 pct_dir = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_1); - damage += CalculatePct(pdamage, pct_dir); + // And multiply by amount of ticks to get damage potential + pdamage *= aura->GetSpellInfo()->GetMaxTicks(); - int32 pct_dot = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_2); - int32 const dotBasePoints = CalculatePct(pdamage, pct_dot); + int32 pct_dir = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_1); + damage += CalculatePct(pdamage, pct_dir); - ASSERT(m_spellInfo->GetMaxTicks() > 0); - m_spellValue->EffectBasePoints[EFFECT_1] = dotBasePoints / m_spellInfo->GetMaxTicks(); + int32 pct_dot = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_2); + int32 const dotBasePoints = CalculatePct(pdamage, pct_dot); - apply_direct_bonus = false; - // Glyph of Conflagrate - if (!unitCaster->HasAura(56235)) - unitTarget->RemoveAurasDueToSpell(aura->GetId(), unitCaster->GetGUID()); + ASSERT(m_spellInfo->GetMaxTicks() > 0); + m_spellValue->EffectBasePoints[EFFECT_1] = dotBasePoints / m_spellInfo->GetMaxTicks(); - break; - } + apply_direct_bonus = false; + // Glyph of Conflagrate + if (!unitCaster->HasAura(56235)) + unitTarget->RemoveAurasDueToSpell(aura->GetId(), unitCaster->GetGUID()); + + break; } - // Shadow Bite - else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000) + } + // Shadow Bite + else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000) + { + if (unitCaster->GetTypeId() == TYPEID_UNIT && unitCaster->IsPet()) { - if (unitCaster->GetTypeId() == TYPEID_UNIT && unitCaster->IsPet()) + if (Player* owner = unitCaster->GetOwner()->ToPlayer()) { - if (Player* owner = unitCaster->GetOwner()->ToPlayer()) + if (AuraEffect* aurEff = owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_WARLOCK, 214, 0)) { - if (AuraEffect* aurEff = owner->GetAuraEffect(SPELL_AURA_ADD_FLAT_MODIFIER, SPELLFAMILY_WARLOCK, 214, 0)) - { - int32 bp0 = aurEff->GetId() == 54037 ? 4 : 8; - CastSpellExtraArgs args(TRIGGERED_FULL_MASK); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, bp0); - unitCaster->CastSpell(nullptr, 54425, args); - } + int32 bp0 = aurEff->GetId() == 54037 ? 4 : 8; + CastSpellExtraArgs args(TRIGGERED_FULL_MASK); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, bp0); + unitCaster->CastSpell(nullptr, 54425, args); } } } - break; } - case SPELLFAMILY_PRIEST: - { - if (!unitCaster) - break; + break; + } + case SPELLFAMILY_PRIEST: + { + if (!unitCaster) + break; - // Improved Mind Blast (Mind Blast in shadow form bonus) - if (unitCaster->GetShapeshiftForm() == FORM_SHADOW && (m_spellInfo->SpellFamilyFlags[0] & 0x00002000)) + // Improved Mind Blast (Mind Blast in shadow form bonus) + if (unitCaster->GetShapeshiftForm() == FORM_SHADOW && (m_spellInfo->SpellFamilyFlags[0] & 0x00002000)) + { + Unit::AuraEffectList const& ImprMindBlast = unitCaster->GetAuraEffectsByType(SPELL_AURA_ADD_FLAT_MODIFIER); + for (Unit::AuraEffectList::const_iterator i = ImprMindBlast.begin(); i != ImprMindBlast.end(); ++i) { - Unit::AuraEffectList const& ImprMindBlast = unitCaster->GetAuraEffectsByType(SPELL_AURA_ADD_FLAT_MODIFIER); - for (Unit::AuraEffectList::const_iterator i = ImprMindBlast.begin(); i != ImprMindBlast.end(); ++i) - { - if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PRIEST && + if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_PRIEST && ((*i)->GetSpellInfo()->SpellIconID == 95)) - { - // Mind Trauma - int32 const chance = (*i)->GetSpellInfo()->Effects[EFFECT_1].CalcValue(unitCaster); - if (roll_chance_i(chance)) - unitCaster->CastSpell(unitTarget, 48301, true); - break; - } + { + // Mind Trauma + int32 const chance = (*i)->GetSpellInfo()->Effects[EFFECT_1].CalcValue(unitCaster); + if (roll_chance_i(chance)) + unitCaster->CastSpell(unitTarget, 48301, true); + break; } } - break; } - case SPELLFAMILY_DRUID: - { - if (!unitCaster) - break; - - // Ferocious Bite - if (unitCaster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags[0] & 0x000800000) && m_spellInfo->SpellVisual[0] == 6587) - { - // converts each extra point of energy into ($f1+$AP/410) additional damage - float ap = unitCaster->GetTotalAttackPowerValue(BASE_ATTACK); - float multiple = ap / 410 + m_spellInfo->Effects[effIndex].DamageMultiplier; - int32 energy = -(unitCaster->ModifyPower(POWER_ENERGY, -30)); - damage += int32(energy * multiple); - damage += int32(CalculatePct(unitCaster->ToPlayer()->GetComboPoints() * ap, 7)); - } - // Wrath - else if (m_spellInfo->SpellFamilyFlags[0] & 0x00000001) - { - // Improved Insect Swarm - if (AuraEffect const* aurEff = unitCaster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 1771, 0)) - if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, 0x00200000, 0, 0)) - AddPct(damage, aurEff->GetAmount()); - } + break; + } + case SPELLFAMILY_DRUID: + { + if (!unitCaster) break; + + // Ferocious Bite + if (unitCaster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags[0] & 0x000800000) && m_spellInfo->SpellVisual[0] == 6587) + { + // converts each extra point of energy into ($f1+$AP/410) additional damage + float ap = unitCaster->GetTotalAttackPowerValue(BASE_ATTACK); + float multiple = ap / 410 + m_spellInfo->Effects[effIndex].DamageMultiplier; + int32 energy = -(unitCaster->ModifyPower(POWER_ENERGY, -30)); + damage += int32(energy * multiple); + damage += int32(CalculatePct(unitCaster->ToPlayer()->GetComboPoints() * ap, 7)); } - case SPELLFAMILY_ROGUE: + // Wrath + else if (m_spellInfo->SpellFamilyFlags[0] & 0x00000001) { - if (!unitCaster) - break; + // Improved Insect Swarm + if (AuraEffect const* aurEff = unitCaster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 1771, 0)) + if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, 0x00200000, 0, 0)) + AddPct(damage, aurEff->GetAmount()); + } + break; + } + case SPELLFAMILY_ROGUE: + { + if (!unitCaster) + break; - // Envenom - if (m_spellInfo->SpellFamilyFlags[1] & 0x00000008) + // Envenom + if (m_spellInfo->SpellFamilyFlags[1] & 0x00000008) + { + if (Player* player = unitCaster->ToPlayer()) { - if (Player* player = unitCaster->ToPlayer()) + // consume from stack dozes not more that have combo-points + if (uint32 combo = player->GetComboPoints()) { - // consume from stack dozes not more that have combo-points - if (uint32 combo = player->GetComboPoints()) + // Lookup for Deadly poison (only attacker applied) + if (AuraEffect const* aurEff = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x00010000, 0, 0, unitCaster->GetGUID())) { - // Lookup for Deadly poison (only attacker applied) - if (AuraEffect const* aurEff = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_ROGUE, 0x00010000, 0, 0, unitCaster->GetGUID())) - { - // count consumed deadly poison doses at target - bool needConsume = true; - uint32 spellId = aurEff->GetId(); + // count consumed deadly poison doses at target + bool needConsume = true; + uint32 spellId = aurEff->GetId(); - uint32 doses = aurEff->GetBase()->GetStackAmount(); - if (doses > combo) - doses = combo; + uint32 doses = aurEff->GetBase()->GetStackAmount(); + if (doses > combo) + doses = combo; - // Master Poisoner - Unit::AuraEffectList const& auraList = player->GetAuraEffectsByType(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK); - for (Unit::AuraEffectList::const_iterator iter = auraList.begin(); iter != auraList.end(); ++iter) + // Master Poisoner + Unit::AuraEffectList const& auraList = player->GetAuraEffectsByType(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK); + for (Unit::AuraEffectList::const_iterator iter = auraList.begin(); iter != auraList.end(); ++iter) + { + if ((*iter)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_ROGUE && (*iter)->GetSpellInfo()->SpellIconID == 1960) { - if ((*iter)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_ROGUE && (*iter)->GetSpellInfo()->SpellIconID == 1960) - { - uint32 chance = (*iter)->GetSpellInfo()->Effects[EFFECT_2].CalcValue(unitCaster); + uint32 chance = (*iter)->GetSpellInfo()->Effects[EFFECT_2].CalcValue(unitCaster); - if (chance && roll_chance_i(chance)) - needConsume = false; + if (chance && roll_chance_i(chance)) + needConsume = false; - break; - } + break; } - - if (needConsume) - for (uint32 i = 0; i < doses; ++i) - unitTarget->RemoveAuraFromStack(spellId, unitCaster->GetGUID()); - - damage *= doses; - damage += int32(player->GetTotalAttackPowerValue(BASE_ATTACK) * 0.09f * combo); } - // Eviscerate and Envenom Bonus Damage (item set effect) - if (unitCaster->HasAura(37169)) - damage += combo * 40; + if (needConsume) + for (uint32 i = 0; i < doses; ++i) + unitTarget->RemoveAuraFromStack(spellId, unitCaster->GetGUID()); + + damage *= doses; + damage += int32(player->GetTotalAttackPowerValue(BASE_ATTACK) * 0.09f * combo); } + + // Eviscerate and Envenom Bonus Damage (item set effect) + if (unitCaster->HasAura(37169)) + damage += combo * 40; } } - // Eviscerate - else if (m_spellInfo->SpellFamilyFlags[0] & 0x00020000) + } + // Eviscerate + else if (m_spellInfo->SpellFamilyFlags[0] & 0x00020000) + { + if (Player* player = unitCaster->ToPlayer()) { - if (Player* player = unitCaster->ToPlayer()) + if (uint32 combo = player->GetComboPoints()) { - if (uint32 combo = player->GetComboPoints()) - { - float ap = unitCaster->GetTotalAttackPowerValue(BASE_ATTACK); - damage += std::lroundf(ap * combo * 0.07f); + float ap = unitCaster->GetTotalAttackPowerValue(BASE_ATTACK); + damage += std::lroundf(ap * combo * 0.07f); - // Eviscerate and Envenom Bonus Damage (item set effect) - if (unitCaster->HasAura(37169)) - damage += combo*40; - } + // Eviscerate and Envenom Bonus Damage (item set effect) + if (unitCaster->HasAura(37169)) + damage += combo * 40; } } + } + break; + } + case SPELLFAMILY_HUNTER: + { + if (!unitCaster) break; + + //Gore + if (m_spellInfo->SpellIconID == 1578) + { + if (unitCaster->HasAura(57627)) // Charge 6 sec post-affect + damage *= 2; } - case SPELLFAMILY_HUNTER: + // Steady Shot + else if (m_spellInfo->SpellFamilyFlags[1] & 0x1) { - if (!unitCaster) - break; - - //Gore - if (m_spellInfo->SpellIconID == 1578) - { - if (unitCaster->HasAura(57627)) // Charge 6 sec post-affect - damage *= 2; - } - // Steady Shot - else if (m_spellInfo->SpellFamilyFlags[1] & 0x1) + bool found = false; + // check dazed affect + Unit::AuraEffectList const& decSpeedList = unitTarget->GetAuraEffectsByType(SPELL_AURA_MOD_DECREASE_SPEED); + for (Unit::AuraEffectList::const_iterator iter = decSpeedList.begin(); iter != decSpeedList.end(); ++iter) { - bool found = false; - // check dazed affect - Unit::AuraEffectList const& decSpeedList = unitTarget->GetAuraEffectsByType(SPELL_AURA_MOD_DECREASE_SPEED); - for (Unit::AuraEffectList::const_iterator iter = decSpeedList.begin(); iter != decSpeedList.end(); ++iter) + if ((*iter)->GetSpellInfo()->SpellIconID == 15 && (*iter)->GetSpellInfo()->Dispel == 0) { - if ((*iter)->GetSpellInfo()->SpellIconID == 15 && (*iter)->GetSpellInfo()->Dispel == 0) - { - found = true; - break; - } - } - - /// @todo should this be put on taken but not done? - if (found) - damage += m_spellInfo->Effects[EFFECT_1].CalcValue(); - - if (Player* caster = unitCaster->ToPlayer()) - { - // Add Ammo and Weapon damage plus RAP * 0.1 - float dmg_min = 0.f; - float dmg_max = 0.f; - for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) - { - dmg_min += caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE, i); - dmg_max += caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE, i); - } - - if (dmg_max == 0.0f && dmg_min > dmg_max) - damage += int32(dmg_min); - else - damage += irand(int32(dmg_min), int32(dmg_max)); - damage += int32(caster->GetAmmoDPS() * caster->GetAttackTime(RANGED_ATTACK) * 0.001f); + found = true; + break; } } - break; - } - case SPELLFAMILY_PALADIN: - { - if (!unitCaster) - break; - // Hammer of the Righteous - if (m_spellInfo->SpellFamilyFlags[1] & 0x00040000) - { - float minTotal = 0.f; - float maxTotal = 0.f; + /// @todo should this be put on taken but not done? + if (found) + damage += m_spellInfo->Effects[EFFECT_1].CalcValue(); - float tmpMin, tmpMax; + if (Player* caster = unitCaster->ToPlayer()) + { + // Add Ammo and Weapon damage plus RAP * 0.1 + float dmg_min = 0.f; + float dmg_max = 0.f; for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) { - unitCaster->CalculateMinMaxDamage(BASE_ATTACK, false, false, tmpMin, tmpMax, i); - minTotal += tmpMin; - maxTotal += tmpMax; + dmg_min += caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE, i); + dmg_max += caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE, i); } - float average = (minTotal + maxTotal) / 2; - // Add main hand dps * effect[2] amount - int32 count = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_2); - damage += count * int32(average * IN_MILLISECONDS) / unitCaster->GetAttackTime(BASE_ATTACK); - break; + if (dmg_max == 0.0f && dmg_min > dmg_max) + damage += int32(dmg_min); + else + damage += irand(int32(dmg_min), int32(dmg_max)); + damage += int32(caster->GetAmmoDPS() * caster->GetAttackTime(RANGED_ATTACK) * 0.001f); } - // Shield of Righteousness - if (m_spellInfo->SpellFamilyFlags[EFFECT_1] & 0x100000) + } + break; + } + case SPELLFAMILY_PALADIN: + { + if (!unitCaster) + break; + + // Hammer of the Righteous + if (m_spellInfo->SpellFamilyFlags[1] & 0x00040000) + { + float minTotal = 0.f; + float maxTotal = 0.f; + + float tmpMin, tmpMax; + for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) { - uint8 level = unitCaster->GetLevel(); - uint32 block_value = unitCaster->GetShieldBlockValue(uint32(float(level) * 29.5f), uint32(float(level) * 39.5f)); - damage += CalculatePct(block_value, m_spellInfo->Effects[EFFECT_1].CalcValue()); - break; + unitCaster->CalculateMinMaxDamage(BASE_ATTACK, false, false, tmpMin, tmpMax, i); + minTotal += tmpMin; + maxTotal += tmpMax; } + + float average = (minTotal + maxTotal) / 2; + // Add main hand dps * effect[2] amount + int32 count = unitCaster->CalculateSpellDamage(m_spellInfo, EFFECT_2); + damage += count * int32(average * IN_MILLISECONDS) / unitCaster->GetAttackTime(BASE_ATTACK); break; } - case SPELLFAMILY_DEATHKNIGHT: + // Shield of Righteousness + if (m_spellInfo->SpellFamilyFlags[EFFECT_1] & 0x100000) { - if (!unitCaster) - break; + uint8 level = unitCaster->GetLevel(); + uint32 block_value = unitCaster->GetShieldBlockValue(uint32(float(level) * 29.5f), uint32(float(level) * 39.5f)); + damage += CalculatePct(block_value, m_spellInfo->Effects[EFFECT_1].CalcValue()); + break; + } + break; + } + case SPELLFAMILY_DEATHKNIGHT: + { + if (!unitCaster) + break; - // Blood Boil - bonus for diseased targets - if (m_spellInfo->SpellFamilyFlags[0] & 0x00040000) + // Blood Boil - bonus for diseased targets + if (m_spellInfo->SpellFamilyFlags[0] & 0x00040000) + { + if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, 0, 0, 0x00000002, unitCaster->GetGUID())) { - if (unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, 0, 0, 0x00000002, unitCaster->GetGUID())) - { - damage += m_damage / 2; - damage += int32(unitCaster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.035f); - } + damage += m_damage / 2; + damage += int32(unitCaster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.035f); } - break; } + break; + } } if (unitCaster && damage > 0 && apply_direct_bonus) @@ -720,69 +720,69 @@ void Spell::EffectDummy(SpellEffIndex effIndex) void Spell::EffectTriggerSpell(SpellEffIndex effIndex) { if (effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH_TARGET - && effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH) + && effectHandleMode != SPELL_EFFECT_HANDLE_LAUNCH) return; uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; /// @todo move those to spell scripts if (m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_TRIGGER_SPELL - && effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET) + && effectHandleMode == SPELL_EFFECT_HANDLE_LAUNCH_TARGET) { Unit* unitCaster = GetUnitCasterForEffectHandlers(); // special cases switch (triggered_spell_id) { - // Mirror Image - case 58832: - { - if (!unitCaster) - break; - - // Glyph of Mirror Image - if (unitCaster->HasAura(63093)) - unitCaster->CastSpell(nullptr, 65047, true); // Mirror Image + // Mirror Image + case 58832: + { + if (!unitCaster) break; - } - // Demonic Empowerment -- succubus - case 54437: - { - unitTarget->RemoveMovementImpairingAuras(true); - unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STALKED); - unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STUN); - // Cast Lesser Invisibility - unitTarget->CastSpell(unitTarget, 7870, true); - return; - } - // just skip - case 23770: // Sayge's Dark Fortune of * - // not exist, common cooldown can be implemented in scripts if need. - return; - // Brittle Armor - (need add max stack of 24575 Brittle Armor) - case 29284: - { - // Brittle Armor - SpellInfo const* spell = sSpellMgr->GetSpellInfo(24575); - if (!spell) - return; + // Glyph of Mirror Image + if (unitCaster->HasAura(63093)) + unitCaster->CastSpell(nullptr, 65047, true); // Mirror Image + break; + } + // Demonic Empowerment -- succubus + case 54437: + { + unitTarget->RemoveMovementImpairingAuras(true); + unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STALKED); + unitTarget->RemoveAurasByType(SPELL_AURA_MOD_STUN); - for (uint32 j = 0; j < spell->StackAmount; ++j) - m_caster->CastSpell(unitTarget, spell->Id, true); + // Cast Lesser Invisibility + unitTarget->CastSpell(unitTarget, 7870, true); + return; + } + // just skip + case 23770: // Sayge's Dark Fortune of * + // not exist, common cooldown can be implemented in scripts if need. + return; + // Brittle Armor - (need add max stack of 24575 Brittle Armor) + case 29284: + { + // Brittle Armor + SpellInfo const* spell = sSpellMgr->GetSpellInfo(24575); + if (!spell) return; - } - // Mercurial Shield - (need add max stack of 26464 Mercurial Shield) - case 29286: - { - // Mercurial Shield - SpellInfo const* spell = sSpellMgr->GetSpellInfo(26464); - if (!spell) - return; - for (uint32 j = 0; j < spell->StackAmount; ++j) - m_caster->CastSpell(unitTarget, spell->Id, true); + for (uint32 j = 0; j < spell->StackAmount; ++j) + m_caster->CastSpell(unitTarget, spell->Id, true); + return; + } + // Mercurial Shield - (need add max stack of 26464 Mercurial Shield) + case 29286: + { + // Mercurial Shield + SpellInfo const* spell = sSpellMgr->GetSpellInfo(26464); + if (!spell) return; - } + + for (uint32 j = 0; j < spell->StackAmount; ++j) + m_caster->CastSpell(unitTarget, spell->Id, true); + return; + } } } @@ -839,7 +839,7 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex) void Spell::EffectTriggerMissileSpell(SpellEffIndex effIndex) { if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET - && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) + && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; uint32 triggered_spell_id = m_spellInfo->Effects[effIndex].TriggerSpell; @@ -916,26 +916,26 @@ void Spell::EffectForceCast(SpellEffIndex effIndex) { switch (m_spellInfo->Id) { - case 52588: // Skeletal Gryphon Escape - case 48598: // Ride Flamebringer Cue - unitTarget->RemoveAura(damage); - break; - case 52463: // Hide In Mine Car - case 52349: // Overtake - { - CastSpellExtraArgs args(m_originalCasterGUID); - args.AddSpellMod(SPELLVALUE_BASE_POINT0, damage); - unitTarget->CastSpell(unitTarget, spellInfo->Id, args); - return; - } + case 52588: // Skeletal Gryphon Escape + case 48598: // Ride Flamebringer Cue + unitTarget->RemoveAura(damage); + break; + case 52463: // Hide In Mine Car + case 52349: // Overtake + { + CastSpellExtraArgs args(m_originalCasterGUID); + args.AddSpellMod(SPELLVALUE_BASE_POINT0, damage); + unitTarget->CastSpell(unitTarget, spellInfo->Id, args); + return; + } } } switch (spellInfo->Id) { - case 72298: // Malleable Goo Summon - unitTarget->CastSpell(unitTarget, spellInfo->Id, m_originalCasterGUID); - return; + case 72298: // Malleable Goo Summon + unitTarget->CastSpell(unitTarget, spellInfo->Id, m_originalCasterGUID); + return; } CastSpellExtraArgs args(TRIGGERED_FULL_MASK); @@ -1148,7 +1148,7 @@ void Spell::EffectSendEvent(SpellEffIndex effIndex) { // we do not handle a flag dropping or clicking on flag in battleground by sendevent system if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET - && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) + && effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; WorldObject* target = nullptr; @@ -1267,7 +1267,7 @@ void Spell::EffectHeal(SpellEffIndex effIndex) for (Unit::AuraEffectList::const_iterator i = RejorRegr.begin(); i != RejorRegr.end(); ++i) { if ((*i)->GetSpellInfo()->SpellFamilyName == SPELLFAMILY_DRUID - && (*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x50) + && (*i)->GetSpellInfo()->SpellFamilyFlags[0] & 0x50) { if (!targetAura || (*i)->GetBase()->GetDuration() < targetAura->GetBase()->GetDuration()) targetAura = *i; @@ -1406,20 +1406,20 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) uint32 bgType = 0; switch (m_spellInfo->Id) { - case SPELL_AV_MARK_WINNER: - case SPELL_AV_MARK_LOSER: - bgType = BATTLEGROUND_AV; - break; - case SPELL_WS_MARK_WINNER: - case SPELL_WS_MARK_LOSER: - bgType = BATTLEGROUND_WS; - break; - case SPELL_AB_MARK_WINNER: - case SPELL_AB_MARK_LOSER: - bgType = BATTLEGROUND_AB; - break; - default: - break; + case SPELL_AV_MARK_WINNER: + case SPELL_AV_MARK_LOSER: + bgType = BATTLEGROUND_AV; + break; + case SPELL_WS_MARK_WINNER: + case SPELL_WS_MARK_LOSER: + bgType = BATTLEGROUND_WS; + break; + case SPELL_AB_MARK_WINNER: + case SPELL_AB_MARK_LOSER: + bgType = BATTLEGROUND_AB; + break; + default: + break; } uint32 num_to_add = damage; @@ -1445,11 +1445,11 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) /* == profession specialization handling == */ // init items_count to 1, since 1 item will be created regardless of specialization - int items_count=1; + int items_count = 1; // the chance to create additional items - float additionalCreateChance=0.0f; + float additionalCreateChance = 0.0f; // the maximum number of created additional items - uint8 additionalMaxNum=0; + uint8 additionalMaxNum = 0; // get the chance and maximum number for creating extra items if (CanCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum)) // roll with this chance till we roll not to create or we create the max num @@ -1502,14 +1502,14 @@ void Spell::DoCreateItem(uint32 /*i*/, uint32 itemtype) player->UpdateCraftSkill(m_spellInfo->Id); } -/* - // for battleground marks send by mail if not add all expected - if (no_space > 0 && bgType) - { - if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(bgType))) - bg->SendRewardMarkByMail(player, newitemid, no_space); - } -*/ + /* + // for battleground marks send by mail if not add all expected + if (no_space > 0 && bgType) + { + if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(bgType))) + bg->SendRewardMarkByMail(player, newitemid, no_space); + } + */ } void Spell::EffectCreateItem(SpellEffIndex effIndex) @@ -1593,8 +1593,8 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex) AuraCreateInfo createInfo(m_spellInfo, MAX_EFFECT_MASK, dynObj); createInfo - .SetCaster(unitCaster) - .SetBaseAmount(m_spellValue->EffectBasePoints); + .SetCaster(unitCaster) + .SetBaseAmount(m_spellValue->EffectBasePoints); if (Aura* aura = Aura::TryCreate(createInfo)) { @@ -1625,7 +1625,7 @@ void Spell::EffectEnergize(SpellEffIndex effIndex) Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue); if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetPowerType() != power && m_spellInfo->SpellFamilyName != SPELLFAMILY_POTION - && !m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER)) + && !m_spellInfo->HasAttribute(SPELL_ATTR7_CAN_RESTORE_SECONDARY_POWER)) return; if (unitTarget->GetMaxPower(power) == 0) @@ -1637,38 +1637,38 @@ void Spell::EffectEnergize(SpellEffIndex effIndex) int32 level_diff = 0; switch (m_spellInfo->Id) { - case 9512: // Restore Energy - level_diff = unitCaster->GetLevel() - 40; - level_multiplier = 2; - break; - case 24571: // Blood Fury - level_diff = unitCaster->GetLevel() - 60; - level_multiplier = 10; - break; - case 24532: // Burst of Energy - level_diff = unitCaster->GetLevel() - 60; - level_multiplier = 4; - break; - case 31930: // Judgements of the Wise - case 63375: // Improved Stormstrike - case 68082: // Glyph of Seal of Command - damage = int32(CalculatePct(unitTarget->GetCreateMana(), damage)); - break; - case 48542: // Revitalize - damage = int32(CalculatePct(unitTarget->GetMaxPower(power), damage)); - break; - case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change) - { - if (Player* player = unitCaster->ToPlayer()) - if (player->HasSkill(SKILL_ENGINEERING)) - AddPct(damage, 25); - break; - } - case 71132: // Glyph of Shadow Word: Pain - damage = int32(CalculatePct(unitTarget->GetCreateMana(), 1)); // set 1 as value, missing in dbc - break; - default: - break; + case 9512: // Restore Energy + level_diff = unitCaster->GetLevel() - 40; + level_multiplier = 2; + break; + case 24571: // Blood Fury + level_diff = unitCaster->GetLevel() - 60; + level_multiplier = 10; + break; + case 24532: // Burst of Energy + level_diff = unitCaster->GetLevel() - 60; + level_multiplier = 4; + break; + case 31930: // Judgements of the Wise + case 63375: // Improved Stormstrike + case 68082: // Glyph of Seal of Command + damage = int32(CalculatePct(unitTarget->GetCreateMana(), damage)); + break; + case 48542: // Revitalize + damage = int32(CalculatePct(unitTarget->GetMaxPower(power), damage)); + break; + case 67490: // Runic Mana Injector (mana gain increased by 25% for engineers - 3.2.0 patch change) + { + if (Player* player = unitCaster->ToPlayer()) + if (player->HasSkill(SKILL_ENGINEERING)) + AddPct(damage, 25); + break; + } + case 71132: // Glyph of Shadow Word: Pain + damage = int32(CalculatePct(unitTarget->GetCreateMana(), 1)); // set 1 as value, missing in dbc + break; + default: + break; } if (level_diff > 0) @@ -1720,7 +1720,7 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype) if (!gameObjTarget->isSpawned() && !player->IsGameMaster()) { LOG_ERROR("entities.player.cheat", "Possible hacking attempt: Player %s %s tried to loot a gameobject %s which is on respawn timer without being in GM mode!", - player->GetName().c_str(), player->GetGUID().ToString().c_str(), gameObjTarget->GetGUID().ToString().c_str()); + player->GetName().c_str(), player->GetGUID().ToString().c_str(), gameObjTarget->GetGUID().ToString().c_str()); return; } // special case, already has GossipHello inside so return and avoid calling twice @@ -1736,38 +1736,38 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype) switch (gameObjTarget->GetGoType()) { - case GAMEOBJECT_TYPE_DOOR: - case GAMEOBJECT_TYPE_BUTTON: - gameObjTarget->UseDoorOrButton(0, false, player); - return; + case GAMEOBJECT_TYPE_DOOR: + case GAMEOBJECT_TYPE_BUTTON: + gameObjTarget->UseDoorOrButton(0, false, player); + return; - case GAMEOBJECT_TYPE_QUESTGIVER: - player->PrepareGossipMenu(gameObjTarget, gameObjTarget->GetGOInfo()->questgiver.gossipID, true); - player->SendPreparedGossip(gameObjTarget); - return; + case GAMEOBJECT_TYPE_QUESTGIVER: + player->PrepareGossipMenu(gameObjTarget, gameObjTarget->GetGOInfo()->questgiver.gossipID, true); + player->SendPreparedGossip(gameObjTarget); + return; - case GAMEOBJECT_TYPE_SPELL_FOCUS: - // triggering linked GO - if (uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) - gameObjTarget->TriggeringLinkedGameObject(trapEntry, player); - return; + case GAMEOBJECT_TYPE_SPELL_FOCUS: + // triggering linked GO + if (uint32 trapEntry = gameObjTarget->GetGOInfo()->spellFocus.linkedTrapId) + gameObjTarget->TriggeringLinkedGameObject(trapEntry, player); + return; - case GAMEOBJECT_TYPE_CHEST: - /// @todo possible must be moved to loot release (in different from linked triggering) - if (gameObjTarget->GetGOInfo()->chest.eventId) - { - LOG_DEBUG("spells", "Chest ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->chest.eventId, gameObjTarget->GetSpawnId()); - player->GetMap()->ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->chest.eventId, player, gameObjTarget); - } + case GAMEOBJECT_TYPE_CHEST: + /// @todo possible must be moved to loot release (in different from linked triggering) + if (gameObjTarget->GetGOInfo()->chest.eventId) + { + LOG_DEBUG("spells", "Chest ScriptStart id %u for GO %u", gameObjTarget->GetGOInfo()->chest.eventId, gameObjTarget->GetSpawnId()); + player->GetMap()->ScriptsStart(sEventScripts, gameObjTarget->GetGOInfo()->chest.eventId, player, gameObjTarget); + } - // triggering linked GO - if (uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) - gameObjTarget->TriggeringLinkedGameObject(trapEntry, player); + // triggering linked GO + if (uint32 trapEntry = gameObjTarget->GetGOInfo()->chest.linkedTrapId) + gameObjTarget->TriggeringLinkedGameObject(trapEntry, player); - // Don't return, let loots been taken - break; - default: - break; + // Don't return, let loots been taken + break; + default: + break; } } @@ -1801,7 +1801,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) // Arathi Basin banner opening. /// @todo Verify correctness of this check if ((goInfo->type == GAMEOBJECT_TYPE_BUTTON && goInfo->button.noDamageImmune) || - (goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK)) + (goInfo->type == GAMEOBJECT_TYPE_GOOBER && goInfo->goober.losOK)) { //CanUseBattlegroundObject() already called in CheckCast() // in battleground check @@ -1875,7 +1875,7 @@ void Spell::EffectOpenLock(SpellEffIndex effIndex) { // Allow one skill-up until respawned if (!gameObjTarget->IsInSkillupList(player->GetGUID().GetCounter()) && - player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue)) + player->UpdateGatherSkill(skillId, pureSkillValue, reqSkillValue)) gameObjTarget->AddToSkillupList(player->GetGUID().GetCounter()); } else if (itemTarget) @@ -1918,7 +1918,8 @@ void Spell::EffectSummonChangeItem(SpellEffIndex effIndex) for (uint8 j = PERM_ENCHANTMENT_SLOT; j <= TEMP_ENCHANTMENT_SLOT; ++j) if (m_CastItem->GetEnchantmentId(EnchantmentSlot(j))) - pNewItem->SetEnchantment(EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j))); + pNewItem->SetEnchantment(EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), + m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j))); if (m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) { @@ -2059,172 +2060,172 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) // so here's a list of MiscValueB values, which is currently most generic check switch (properties->ID) { - case 64: - case 61: - case 1101: - case 66: - case 648: - case 2301: - case 1061: - case 1261: - case 629: - case 181: - case 715: - case 1562: - case 833: - case 1161: - case 713: - numSummons = (damage > 0) ? damage : 1; - break; - default: - numSummons = 1; - break; + case 64: + case 61: + case 1101: + case 66: + case 648: + case 2301: + case 1061: + case 1261: + case 629: + case 181: + case 715: + case 1562: + case 833: + case 1161: + case 713: + numSummons = (damage > 0) ? damage : 1; + break; + default: + numSummons = 1; + break; } switch (properties->Control) { - case SUMMON_CATEGORY_WILD: - case SUMMON_CATEGORY_ALLY: - case SUMMON_CATEGORY_UNK: + case SUMMON_CATEGORY_WILD: + case SUMMON_CATEGORY_ALLY: + case SUMMON_CATEGORY_UNK: + { + if (properties->Flags & 512) { - if (properties->Flags & 512) - { - SummonGuardian(effIndex, entry, properties, numSummons); - break; - } - - switch (properties->Title) - { - case SUMMON_TYPE_PET: - case SUMMON_TYPE_GUARDIAN: - case SUMMON_TYPE_GUARDIAN2: - case SUMMON_TYPE_MINION: - SummonGuardian(effIndex, entry, properties, numSummons); - break; - // Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE) - case SUMMON_TYPE_VEHICLE: - case SUMMON_TYPE_VEHICLE2: - { - if (!unitCaster) - return; - - summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id); - break; - } - case SUMMON_TYPE_LIGHTWELL: - case SUMMON_TYPE_TOTEM: - { - if (!unitCaster) - return; - - summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id, 0, personalSpawn); - if (!summon || !summon->IsTotem()) - return; - - // Mana Tide Totem - if (m_spellInfo->Id == 16190) - damage = unitCaster->CountPctFromMaxHealth(10); - - if (damage) // if not spell info, DB values used - { - summon->SetMaxHealth(damage); - summon->SetHealth(damage); - } - break; - } - case SUMMON_TYPE_MINIPET: - { - if (!unitCaster) - return; - - summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id, 0, personalSpawn); - if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION)) - return; - - summon->SelectLevel(); // some summoned creaters have different from 1 DB data for level/hp - summon->SetUInt32Value(UNIT_NPC_FLAGS, summon->GetCreatureTemplate()->npcflag); - summon->SetImmuneToAll(true); - break; - } - default: - { - float radius = m_spellInfo->Effects[effIndex].CalcRadius(); - - TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; - - for (uint32 count = 0; count < numSummons; ++count) - { - Position pos; - if (count == 0) - pos = *destTarget; - else - // randomize position for multiple summons - pos = caster->GetRandomPoint(*destTarget, radius); - - summon = caster->SummonCreature(entry, pos, summonType, Milliseconds(duration), 0, m_spellInfo->Id, personalSpawn); - if (!summon) - continue; - - if (properties->Control == SUMMON_CATEGORY_ALLY) - { - summon->SetOwnerGUID(caster->GetGUID()); - summon->SetFaction(caster->GetFaction()); - } - - ExecuteLogEffectSummonObject(effIndex, summon); - } - return; - } - } + SummonGuardian(effIndex, entry, properties, numSummons); break; } - case SUMMON_CATEGORY_PET: + + switch (properties->Title) + { + case SUMMON_TYPE_PET: + case SUMMON_TYPE_GUARDIAN: + case SUMMON_TYPE_GUARDIAN2: + case SUMMON_TYPE_MINION: SummonGuardian(effIndex, entry, properties, numSummons); break; - case SUMMON_CATEGORY_PUPPET: + // Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE) + case SUMMON_TYPE_VEHICLE: + case SUMMON_TYPE_VEHICLE2: + { + if (!unitCaster) + return; + + summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id); + break; + } + case SUMMON_TYPE_LIGHTWELL: + case SUMMON_TYPE_TOTEM: { if (!unitCaster) return; summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id, 0, personalSpawn); + if (!summon || !summon->IsTotem()) + return; + + // Mana Tide Totem + if (m_spellInfo->Id == 16190) + damage = unitCaster->CountPctFromMaxHealth(10); + + if (damage) // if not spell info, DB values used + { + summon->SetMaxHealth(damage); + summon->SetHealth(damage); + } break; } - case SUMMON_CATEGORY_VEHICLE: + case SUMMON_TYPE_MINIPET: { if (!unitCaster) return; - // Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker - // to cast a ride vehicle spell on the summoned unit. - summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id); - if (!summon || !summon->IsVehicle()) + summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id, 0, personalSpawn); + if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION)) return; - // The spell that this effect will trigger. It has SPELL_AURA_CONTROL_VEHICLE - uint32 spellId = VEHICLE_SPELL_RIDE_HARDCODED; - int32 basePoints = m_spellInfo->Effects[effIndex].CalcValue(); - if (basePoints > MAX_VEHICLE_SEATS) + summon->SelectLevel(); // some summoned creaters have different from 1 DB data for level/hp + summon->SetUInt32Value(UNIT_NPC_FLAGS, summon->GetCreatureTemplate()->npcflag); + summon->SetImmuneToAll(true); + break; + } + default: + { + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); + + TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; + + for (uint32 count = 0; count < numSummons; ++count) { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(basePoints); - if (spellInfo && spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE)) - spellId = spellInfo->Id; - } + Position pos; + if (count == 0) + pos = *destTarget; + else + // randomize position for multiple summons + pos = caster->GetRandomPoint(*destTarget, radius); - CastSpellExtraArgs args(TRIGGERED_FULL_MASK); + summon = caster->SummonCreature(entry, pos, summonType, Milliseconds(duration), 0, m_spellInfo->Id, personalSpawn); + if (!summon) + continue; - // if we have small value, it indicates seat position - if (basePoints > 0 && basePoints < MAX_VEHICLE_SEATS) - args.AddSpellMod(SPELLVALUE_BASE_POINT0, basePoints); + if (properties->Control == SUMMON_CATEGORY_ALLY) + { + summon->SetOwnerGUID(caster->GetGUID()); + summon->SetFaction(caster->GetFaction()); + } + + ExecuteLogEffectSummonObject(effIndex, summon); + } + return; + } + } + break; + } + case SUMMON_CATEGORY_PET: + SummonGuardian(effIndex, entry, properties, numSummons); + break; + case SUMMON_CATEGORY_PUPPET: + { + if (!unitCaster) + return; - unitCaster->CastSpell(summon, spellId, args); + summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id, 0, personalSpawn); + break; + } + case SUMMON_CATEGORY_VEHICLE: + { + if (!unitCaster) + return; - uint32 faction = properties->Faction; - if (!faction) - faction = unitCaster->GetFaction(); + // Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker + // to cast a ride vehicle spell on the summoned unit. + summon = unitCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, unitCaster, m_spellInfo->Id); + if (!summon || !summon->IsVehicle()) + return; - summon->SetFaction(faction); - break; + // The spell that this effect will trigger. It has SPELL_AURA_CONTROL_VEHICLE + uint32 spellId = VEHICLE_SPELL_RIDE_HARDCODED; + int32 basePoints = m_spellInfo->Effects[effIndex].CalcValue(); + if (basePoints > MAX_VEHICLE_SEATS) + { + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(basePoints); + if (spellInfo && spellInfo->HasAura(SPELL_AURA_CONTROL_VEHICLE)) + spellId = spellInfo->Id; } + + CastSpellExtraArgs args(TRIGGERED_FULL_MASK); + + // if we have small value, it indicates seat position + if (basePoints > 0 && basePoints < MAX_VEHICLE_SEATS) + args.AddSpellMod(SPELLVALUE_BASE_POINT0, basePoints); + + unitCaster->CastSpell(summon, spellId, args); + + uint32 faction = properties->Faction; + if (!faction) + faction = unitCaster->GetFaction(); + + summon->SetFaction(faction); + break; + } } if (summon) @@ -2291,7 +2292,7 @@ void Spell::EffectDispel(SpellEffIndex effIndex) if (itr->RollDispel()) { - auto successItr = std::find_if(successList.begin(), successList.end(), [&itr](DispelableAura& dispelAura) -> bool + auto successItr = std::find_if(successList.begin(), successList.end(), [&itr](DispelableAura & dispelAura) -> bool { if (dispelAura.GetAura()->GetId() == itr->GetAura()->GetId() && dispelAura.GetAura()->GetCaster() == itr->GetAura()->GetCaster()) return true; @@ -2500,8 +2501,9 @@ void Spell::EffectAddHonor(SpellEffIndex /*effIndex*/) // not scale value for item based reward (/10 value expected) if (m_CastItem) { - unitTarget->ToPlayer()->RewardHonor(nullptr, 1, damage/10); - LOG_DEBUG("spells", "SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player %s", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(), unitTarget->ToPlayer()->GetGUID().ToString().c_str()); + unitTarget->ToPlayer()->RewardHonor(nullptr, 1, damage / 10); + LOG_DEBUG("spells", "SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player %s", m_spellInfo->Id, damage / 10, m_CastItem->GetEntry(), + unitTarget->ToPlayer()->GetGUID().ToString().c_str()); return; } @@ -2578,9 +2580,9 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex) if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE)) { LOG_GM(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - player->GetName().c_str(), player->GetSession()->GetAccountId(), - itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); + player->GetName().c_str(), player->GetSession()->GetAccountId(), + itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2629,8 +2631,9 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) } if (!add_socket) { - LOG_ERROR("spells", "Spell::EffectEnchantItemPrismatic: attempt to apply the enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u), but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not supported yet.", - m_spellInfo->Id, SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC, ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET); + LOG_ERROR("spells", + "Spell::EffectEnchantItemPrismatic: attempt to apply the enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u), but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not supported yet.", + m_spellInfo->Id, SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC, ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET); return; } } @@ -2643,9 +2646,9 @@ void Spell::EffectEnchantItemPrismatic(SpellEffIndex effIndex) if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE)) { LOG_GM(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - player->GetName().c_str(), player->GetSession()->GetAccountId(), - itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); + player->GetName().c_str(), player->GetSession()->GetAccountId(), + itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -2681,21 +2684,37 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) // RW enchantments applied damage int32(float(v)+0.5), this create 0..1 difference sometime switch (damage) { - // Rank 1 - case 2: spell_id = 36744; break; // 0% [ 7% == 2, 14% == 2, 20% == 2] - // Rank 2 - case 4: spell_id = 36753; break; // 0% [ 7% == 4, 14% == 4] - case 5: spell_id = 36751; break; // 20% - // Rank 3 - case 6: spell_id = 36754; break; // 0% [ 7% == 6, 14% == 6] - case 7: spell_id = 36755; break; // 20% - // Rank 4 - case 9: spell_id = 36761; break; // 0% [ 7% == 6] - case 10: spell_id = 36758; break; // 14% - case 11: spell_id = 36760; break; // 20% - default: - LOG_ERROR("spells", "Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW.", damage); - return; + // Rank 1 + case 2: + spell_id = 36744; + break; // 0% [ 7% == 2, 14% == 2, 20% == 2] + // Rank 2 + case 4: + spell_id = 36753; + break; // 0% [ 7% == 4, 14% == 4] + case 5: + spell_id = 36751; + break; // 20% + // Rank 3 + case 6: + spell_id = 36754; + break; // 0% [ 7% == 6, 14% == 6] + case 7: + spell_id = 36755; + break; // 20% + // Rank 4 + case 9: + spell_id = 36761; + break; // 0% [ 7% == 6] + case 10: + spell_id = 36758; + break; // 14% + case 11: + spell_id = 36760; + break; // 20% + default: + LOG_ERROR("spells", "Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW.", damage); + return; } SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id); @@ -2774,9 +2793,9 @@ void Spell::EffectEnchantItemTmp(SpellEffIndex effIndex) if (item_owner != player && player->GetSession()->HasPermission(rbac::RBAC_PERM_LOG_GM_TRADE)) { LOG_GM(player->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", - player->GetName().c_str(), player->GetSession()->GetAccountId(), - itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), - item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); + player->GetName().c_str(), player->GetSession()->GetAccountId(), + itemTarget->GetTemplate()->Name1.c_str(), itemTarget->GetEntry(), + item_owner->GetName().c_str(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped @@ -3018,11 +3037,11 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) { switch (m_spellInfo->Effects[j].Effect) { - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - return; // we must calculate only at last weapon effect + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + return; // we must calculate only at last weapon effect break; } } @@ -3034,180 +3053,180 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) switch (m_spellInfo->SpellFamilyName) { - case SPELLFAMILY_WARRIOR: + case SPELLFAMILY_WARRIOR: + { + // Devastate (player ones) + if (m_spellInfo->SpellFamilyFlags[1] & 0x40) { - // Devastate (player ones) - if (m_spellInfo->SpellFamilyFlags[1] & 0x40) - { + unitCaster->CastSpell(unitTarget, 58567, true); + // 58388 - Glyph of Devastate dummy aura. + if (unitCaster->HasAura(58388)) unitCaster->CastSpell(unitTarget, 58567, true); - // 58388 - Glyph of Devastate dummy aura. - if (unitCaster->HasAura(58388)) - unitCaster->CastSpell(unitTarget, 58567, true); - if (Aura* aur = unitTarget->GetAura(58567, unitCaster->GetGUID())) - fixed_bonus += (aur->GetStackAmount() - 1) * CalculateDamage(EFFECT_2); // subtract 1 so fixed bonus is not applied twice - } - else if (m_spellInfo->SpellFamilyFlags[0] & 0x8000000) // Mocking Blow - { - if (unitTarget->IsImmunedToSpellEffect(m_spellInfo, EFFECT_1, unitCaster) || unitTarget->GetTypeId() == TYPEID_PLAYER) - { - m_damage = 0; - return; - } - } - break; + if (Aura* aur = unitTarget->GetAura(58567, unitCaster->GetGUID())) + fixed_bonus += (aur->GetStackAmount() - 1) * CalculateDamage(EFFECT_2); // subtract 1 so fixed bonus is not applied twice } - case SPELLFAMILY_ROGUE: + else if (m_spellInfo->SpellFamilyFlags[0] & 0x8000000) // Mocking Blow { - // Fan of Knives, Hemorrhage, Ghostly Strike - if ((m_spellInfo->SpellFamilyFlags[1] & 0x40000) - || (m_spellInfo->SpellFamilyFlags[0] & 0x6000000)) + if (unitTarget->IsImmunedToSpellEffect(m_spellInfo, EFFECT_1, unitCaster) || unitTarget->GetTypeId() == TYPEID_PLAYER) { - // Hemorrhage - if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000) - AddComboPointGain(unitTarget, 1); - - // 50% more damage with daggers - if (unitCaster->GetTypeId() == TYPEID_PLAYER) - if (Item* item = unitCaster->ToPlayer()->GetWeaponForAttack(m_attackType, true)) - if (item->GetTemplate()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) - totalDamagePercentMod *= 1.5f; + m_damage = 0; + return; } - // Mutilate (for each hand) - else if (m_spellInfo->SpellFamilyFlags[1] & 0x6) + } + break; + } + case SPELLFAMILY_ROGUE: + { + // Fan of Knives, Hemorrhage, Ghostly Strike + if ((m_spellInfo->SpellFamilyFlags[1] & 0x40000) + || (m_spellInfo->SpellFamilyFlags[0] & 0x6000000)) + { + // Hemorrhage + if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000) + AddComboPointGain(unitTarget, 1); + + // 50% more damage with daggers + if (unitCaster->GetTypeId() == TYPEID_PLAYER) + if (Item* item = unitCaster->ToPlayer()->GetWeaponForAttack(m_attackType, true)) + if (item->GetTemplate()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) + totalDamagePercentMod *= 1.5f; + } + // Mutilate (for each hand) + else if (m_spellInfo->SpellFamilyFlags[1] & 0x6) + { + bool found = false; + // fast check + if (unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON, m_spellInfo, unitCaster)) + found = true; + // full aura scan + else { - bool found = false; - // fast check - if (unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON, m_spellInfo, unitCaster)) - found = true; - // full aura scan - else + Unit::AuraApplicationMap const& auras = unitTarget->GetAppliedAuras(); + for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - Unit::AuraApplicationMap const& auras = unitTarget->GetAppliedAuras(); - for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + if (itr->second->GetBase()->GetSpellInfo()->Dispel == DISPEL_POISON) { - if (itr->second->GetBase()->GetSpellInfo()->Dispel == DISPEL_POISON) - { - found = true; - break; - } + found = true; + break; } } - - if (found) - totalDamagePercentMod *= 1.2f; // 120% if poisoned } + + if (found) + totalDamagePercentMod *= 1.2f; // 120% if poisoned + } + break; + } + case SPELLFAMILY_PALADIN: + { + // Seal of Command Unleashed + if (m_spellInfo->Id == 20467) + { + spell_bonus += int32(0.08f * unitCaster->GetTotalAttackPowerValue(BASE_ATTACK)); + spell_bonus += int32(0.13f * unitCaster->SpellBaseDamageBonusDone(m_spellInfo->GetSchoolMask())); + } + break; + } + case SPELLFAMILY_SHAMAN: + { + // Skyshatter Harness item set bonus + // Stormstrike + if (AuraEffect* aurEff = unitCaster->IsScriptOverriden(m_spellInfo, 5634)) + unitCaster->CastSpell(nullptr, 38430, aurEff); + break; + } + case SPELLFAMILY_DRUID: + { + // Mangle (Cat): CP + if (m_spellInfo->SpellFamilyFlags[1] & 0x400) + AddComboPointGain(unitTarget, 1); + + // Shred, Maul - Rend and Tear + else if (m_spellInfo->SpellFamilyFlags[0] & 0x00008800 && unitTarget->HasAuraState(AURA_STATE_BLEEDING)) + { + if (AuraEffect const* rendAndTear = unitCaster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 0)) + AddPct(totalDamagePercentMod, rendAndTear->GetAmount()); + } + break; + } + case SPELLFAMILY_HUNTER: + { + // Kill Shot - bonus damage from Ranged Attack Power + if (m_spellInfo->SpellFamilyFlags[1] & 0x800000) + spell_bonus += int32(0.4f * unitCaster->GetTotalAttackPowerValue(RANGED_ATTACK)); + break; + } + case SPELLFAMILY_DEATHKNIGHT: + { + // Plague Strike + if (m_spellInfo->SpellFamilyFlags[0] & 0x1) + { + // Glyph of Plague Strike + if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(58657, EFFECT_0)) + AddPct(totalDamagePercentMod, aurEff->GetAmount()); break; } - case SPELLFAMILY_PALADIN: + // Blood Strike + if (m_spellInfo->SpellFamilyFlags[0] & 0x400000) { - // Seal of Command Unleashed - if (m_spellInfo->Id == 20467) - { - spell_bonus += int32(0.08f * unitCaster->GetTotalAttackPowerValue(BASE_ATTACK)); - spell_bonus += int32(0.13f * unitCaster->SpellBaseDamageBonusDone(m_spellInfo->GetSchoolMask())); - } + float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(unitCaster->GetGUID()) / 2.0f; + // Death Knight T8 Melee 4P Bonus + if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(64736, EFFECT_0)) + AddPct(bonusPct, aurEff->GetAmount()); + AddPct(totalDamagePercentMod, bonusPct); + + // Glyph of Blood Strike + if (unitCaster->GetAuraEffect(59332, EFFECT_0)) + if (unitTarget->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED)) + AddPct(totalDamagePercentMod, 20); break; } - case SPELLFAMILY_SHAMAN: + // Death Strike + if (m_spellInfo->SpellFamilyFlags[0] & 0x10) { - // Skyshatter Harness item set bonus - // Stormstrike - if (AuraEffect* aurEff = unitCaster->IsScriptOverriden(m_spellInfo, 5634)) - unitCaster->CastSpell(nullptr, 38430, aurEff); + // Glyph of Death Strike + if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(59336, EFFECT_0)) + if (uint32 runic = std::min(unitCaster->GetPower(POWER_RUNIC_POWER), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue())) + AddPct(totalDamagePercentMod, runic); break; } - case SPELLFAMILY_DRUID: + // Obliterate (12.5% more damage per disease) + if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) { - // Mangle (Cat): CP - if (m_spellInfo->SpellFamilyFlags[1] & 0x400) - AddComboPointGain(unitTarget, 1); - - // Shred, Maul - Rend and Tear - else if (m_spellInfo->SpellFamilyFlags[0] & 0x00008800 && unitTarget->HasAuraState(AURA_STATE_BLEEDING)) - { - if (AuraEffect const* rendAndTear = unitCaster->GetDummyAuraEffect(SPELLFAMILY_DRUID, 2859, 0)) - AddPct(totalDamagePercentMod, rendAndTear->GetAmount()); - } + bool consumeDiseases = true; + // Annihilation + if (AuraEffect const* aurEff = unitCaster->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2710, EFFECT_0)) + // Do not consume diseases if roll sucesses + if (roll_chance_i(aurEff->GetAmount())) + consumeDiseases = false; + + float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(unitCaster->GetGUID(), consumeDiseases) / 2.0f; + // Death Knight T8 Melee 4P Bonus + if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(64736, EFFECT_0)) + AddPct(bonusPct, aurEff->GetAmount()); + AddPct(totalDamagePercentMod, bonusPct); break; } - case SPELLFAMILY_HUNTER: + // Blood-Caked Strike - Blood-Caked Blade + if (m_spellInfo->SpellIconID == 1736) { - // Kill Shot - bonus damage from Ranged Attack Power - if (m_spellInfo->SpellFamilyFlags[1] & 0x800000) - spell_bonus += int32(0.4f * unitCaster->GetTotalAttackPowerValue(RANGED_ATTACK)); + AddPct(totalDamagePercentMod, unitTarget->GetDiseasesByCaster(unitCaster->GetGUID()) * 50.0f); break; } - case SPELLFAMILY_DEATHKNIGHT: + // Heart Strike + if (m_spellInfo->SpellFamilyFlags[0] & 0x1000000) { - // Plague Strike - if (m_spellInfo->SpellFamilyFlags[0] & 0x1) - { - // Glyph of Plague Strike - if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(58657, EFFECT_0)) - AddPct(totalDamagePercentMod, aurEff->GetAmount()); - break; - } - // Blood Strike - if (m_spellInfo->SpellFamilyFlags[0] & 0x400000) - { - float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(unitCaster->GetGUID()) / 2.0f; - // Death Knight T8 Melee 4P Bonus - if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(64736, EFFECT_0)) - AddPct(bonusPct, aurEff->GetAmount()); - AddPct(totalDamagePercentMod, bonusPct); - - // Glyph of Blood Strike - if (unitCaster->GetAuraEffect(59332, EFFECT_0)) - if (unitTarget->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED)) - AddPct(totalDamagePercentMod, 20); - break; - } - // Death Strike - if (m_spellInfo->SpellFamilyFlags[0] & 0x10) - { - // Glyph of Death Strike - if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(59336, EFFECT_0)) - if (uint32 runic = std::min(unitCaster->GetPower(POWER_RUNIC_POWER), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue())) - AddPct(totalDamagePercentMod, runic); - break; - } - // Obliterate (12.5% more damage per disease) - if (m_spellInfo->SpellFamilyFlags[1] & 0x20000) - { - bool consumeDiseases = true; - // Annihilation - if (AuraEffect const* aurEff = unitCaster->GetDummyAuraEffect(SPELLFAMILY_DEATHKNIGHT, 2710, EFFECT_0)) - // Do not consume diseases if roll sucesses - if (roll_chance_i(aurEff->GetAmount())) - consumeDiseases = false; - - float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(unitCaster->GetGUID(), consumeDiseases) / 2.0f; - // Death Knight T8 Melee 4P Bonus - if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(64736, EFFECT_0)) - AddPct(bonusPct, aurEff->GetAmount()); - AddPct(totalDamagePercentMod, bonusPct); - break; - } - // Blood-Caked Strike - Blood-Caked Blade - if (m_spellInfo->SpellIconID == 1736) - { - AddPct(totalDamagePercentMod, unitTarget->GetDiseasesByCaster(unitCaster->GetGUID()) * 50.0f); - break; - } - // Heart Strike - if (m_spellInfo->SpellFamilyFlags[0] & 0x1000000) - { - float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(unitCaster->GetGUID()); - // Death Knight T8 Melee 4P Bonus - if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(64736, EFFECT_0)) - AddPct(bonusPct, aurEff->GetAmount()); + float bonusPct = m_spellInfo->Effects[EFFECT_2].CalcValue() * unitTarget->GetDiseasesByCaster(unitCaster->GetGUID()); + // Death Knight T8 Melee 4P Bonus + if (AuraEffect const* aurEff = unitCaster->GetAuraEffect(64736, EFFECT_0)) + AddPct(bonusPct, aurEff->GetAmount()); - AddPct(totalDamagePercentMod, bonusPct); - break; - } + AddPct(totalDamagePercentMod, bonusPct); break; } + break; + } } bool normalized = false; @@ -3216,19 +3235,19 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) { switch (m_spellInfo->Effects[j].Effect) { - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - fixed_bonus += CalculateDamage(j); - break; - case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - fixed_bonus += CalculateDamage(j); - normalized = true; - break; - case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - ApplyPct(weaponDamagePercentMod, CalculateDamage(j)); - break; - default: - break; // not weapon damage effect, just skip + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + fixed_bonus += CalculateDamage(j); + break; + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + fixed_bonus += CalculateDamage(j); + normalized = true; + break; + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + ApplyPct(weaponDamagePercentMod, CalculateDamage(j)); + break; + default: + break; // not weapon damage effect, just skip } } @@ -3240,10 +3259,16 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) UnitMods unitMod; switch (m_attackType) { - default: - case BASE_ATTACK: unitMod = UNIT_MOD_DAMAGE_MAINHAND; break; - case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; break; - case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; break; + default: + case BASE_ATTACK: + unitMod = UNIT_MOD_DAMAGE_MAINHAND; + break; + case OFF_ATTACK: + unitMod = UNIT_MOD_DAMAGE_OFFHAND; + break; + case RANGED_ATTACK: + unitMod = UNIT_MOD_DAMAGE_RANGED; + break; } float weapon_total_pct = unitCaster->GetPctModifierValue(unitMod, TOTAL_PCT); @@ -3262,16 +3287,16 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex) // and at most one weaponDamagePercentMod switch (m_spellInfo->Effects[j].Effect) { - case SPELL_EFFECT_WEAPON_DAMAGE: - case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: - case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: - weaponDamage += fixed_bonus; - break; - case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - weaponDamage = int32(weaponDamage * weaponDamagePercentMod); - break; - default: - break; // not weapon damage effect, just skip + case SPELL_EFFECT_WEAPON_DAMAGE: + case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: + case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: + weaponDamage += fixed_bonus; + break; + case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: + weaponDamage = int32(weaponDamage * weaponDamagePercentMod); + break; + default: + break; // not weapon damage effect, just skip } } @@ -3349,10 +3374,10 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex) SpellInfo const* curSpellInfo = spell->m_spellInfo; // check if we can interrupt spell if ((spell->getState() == SPELL_STATE_CASTING - || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) - && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE - && ((i == CURRENT_GENERIC_SPELL && curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) - || (i == CURRENT_CHANNELED_SPELL && curSpellInfo->ChannelInterruptFlags & CHANNEL_INTERRUPT_FLAG_INTERRUPT))) + || (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f)) + && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE + && ((i == CURRENT_GENERIC_SPELL && curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) + || (i == CURRENT_CHANNELED_SPELL && curSpellInfo->ChannelInterruptFlags & CHANNEL_INTERRUPT_FLAG_INTERRUPT))) { if (Unit* unitCaster = GetUnitCasterForEffectHandlers()) { @@ -3360,10 +3385,10 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex) unitTarget->GetSpellHistory()->LockSpellSchool(curSpellInfo->GetSchoolMask(), unitTarget->ModSpellDuration(m_spellInfo, unitTarget, duration, false, 1 << effIndex)); if (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) Unit::ProcSkillsAndAuras(unitCaster, unitTarget, PROC_FLAG_DONE_SPELL_MAGIC_DMG_CLASS_NEG, PROC_FLAG_TAKEN_SPELL_MAGIC_DMG_CLASS_NEG, - PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_HIT, PROC_HIT_INTERRUPT, nullptr, nullptr, nullptr); + PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_HIT, PROC_HIT_INTERRUPT, nullptr, nullptr, nullptr); else if (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE) Unit::ProcSkillsAndAuras(unitCaster, unitTarget, PROC_FLAG_DONE_SPELL_MELEE_DMG_CLASS, PROC_FLAG_TAKEN_SPELL_MELEE_DMG_CLASS, - PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_HIT, PROC_HIT_INTERRUPT, nullptr, nullptr, nullptr); + PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_HIT, PROC_HIT_INTERRUPT, nullptr, nullptr, nullptr); } ExecuteLogEffectInterruptCast(effIndex, unitTarget, curSpellInfo->Id); unitTarget->InterruptSpell(CurrentSpellTypes(i), false); @@ -3402,7 +3427,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) int32 duration = m_spellInfo->GetDuration(); - pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); ExecuteLogEffectSummonObject(effIndex, pGameObj); @@ -3413,7 +3438,7 @@ void Spell::EffectSummonObjectWild(SpellEffIndex effIndex) if (pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP) if (Player* player = m_caster->ToPlayer()) if (Battleground* bg = player->GetBattleground()) - bg->SetDroppedFlagGUID(pGameObj->GetGUID(), player->GetTeam() == ALLIANCE ? TEAM_HORDE: TEAM_ALLIANCE); + bg->SetDroppedFlagGUID(pGameObj->GetGUID(), player->GetTeam() == ALLIANCE ? TEAM_HORDE : TEAM_ALLIANCE); if (GameObject* linkedTrap = pGameObj->GetLinkedTrap()) { @@ -3435,141 +3460,141 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex) /// @todo: move this to scripts switch (m_spellInfo->SpellFamilyName) { - case SPELLFAMILY_GENERIC: + case SPELLFAMILY_GENERIC: + { + switch (m_spellInfo->Id) { - switch (m_spellInfo->Id) - { - // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell) - case 22539: - case 22972: - case 22975: - case 22976: - case 22977: - case 22978: - case 22979: - case 22980: - case 22981: - case 22982: - case 22983: - case 22984: - case 22985: - { - if (!unitTarget || !unitTarget->IsAlive()) - return; - - // Onyxia Scale Cloak - if (unitTarget->HasAura(22683)) - return; + // Shadow Flame (All script effects, not just end ones to prevent player from dodging the last triggered spell) + case 22539: + case 22972: + case 22975: + case 22976: + case 22977: + case 22978: + case 22979: + case 22980: + case 22981: + case 22982: + case 22983: + case 22984: + case 22985: + { + if (!unitTarget || !unitTarget->IsAlive()) + return; - // Shadow Flame - m_caster->CastSpell(unitTarget, 22682, true); - return; - } - // Mug Transformation - case 41931: - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; + // Onyxia Scale Cloak + if (unitTarget->HasAura(22683)) + return; - uint8 bag = 19; - uint8 slot = 0; - Item* item = nullptr; + // Shadow Flame + m_caster->CastSpell(unitTarget, 22682, true); + return; + } + // Mug Transformation + case 41931: + { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; - while (bag) // 256 = 0 due to var type - { - item = m_caster->ToPlayer()->GetItemByPos(bag, slot); - if (item && item->GetEntry() == 38587) - break; + uint8 bag = 19; + uint8 slot = 0; + Item* item = nullptr; - ++slot; - if (slot == 39) - { - slot = 0; - ++bag; - } - } - if (bag) - { - if (m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount() == 1) m_caster->ToPlayer()->RemoveItem(bag, slot, true); - else m_caster->ToPlayer()->GetItemByPos(bag, slot)->SetCount(m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount()-1); - // Spell 42518 (Braufest - Gratisprobe des Braufest herstellen) - m_caster->CastSpell(m_caster, 42518, true); - return; - } + while (bag) // 256 = 0 due to var type + { + item = m_caster->ToPlayer()->GetItemByPos(bag, slot); + if (item && item->GetEntry() == 38587) break; - } - // Brutallus - Burn - case 45141: - case 45151: - { - //Workaround for Range ... should be global for every ScriptEffect - float radius = m_spellInfo->Effects[effIndex].CalcRadius(); - if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetDistance(m_caster) >= radius && !unitTarget->HasAura(46394) && unitTarget != m_caster) - unitTarget->CastSpell(unitTarget, 46394, true); - break; - } - // Summon Ghouls On Scarlet Crusade - case 51904: + ++slot; + if (slot == 39) { - if (!m_targets.HasDst()) - return; - - float x, y, z; - float radius = m_spellInfo->Effects[effIndex].CalcRadius(); - for (uint8 i = 0; i < 15; ++i) - { - m_caster->GetRandomPoint(*destTarget, radius, x, y, z); - m_caster->CastSpell({x, y, z}, 54522, true); - } - break; + slot = 0; + ++bag; } - case 52173: // Coyote Spirit Despawn - case 60243: // Blood Parrot Despawn - if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsSummon()) - unitTarget->ToTempSummon()->UnSummon(); - return; - case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) - { - if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) - return; + } + if (bag) + { + if (m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount() == 1) m_caster->ToPlayer()->RemoveItem(bag, slot, true); + else m_caster->ToPlayer()->GetItemByPos(bag, slot)->SetCount(m_caster->ToPlayer()->GetItemByPos(bag, slot)->GetCount() - 1); + // Spell 42518 (Braufest - Gratisprobe des Braufest herstellen) + m_caster->CastSpell(m_caster, 42518, true); + return; + } + break; + } + // Brutallus - Burn + case 45141: + case 45151: + { + //Workaround for Range ... should be global for every ScriptEffect + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); + if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->GetDistance(m_caster) >= radius && !unitTarget->HasAura(46394) && unitTarget != m_caster) + unitTarget->CastSpell(unitTarget, 46394, true); - unitTarget->ToCreature()->DespawnOrUnsummon(); + break; + } + // Summon Ghouls On Scarlet Crusade + case 51904: + { + if (!m_targets.HasDst()) + return; - return; - } - case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) - { - if (m_caster->GetTypeId() != TYPEID_PLAYER) - return; + float x, y, z; + float radius = m_spellInfo->Effects[effIndex].CalcRadius(); + for (uint8 i = 0; i < 15; ++i) + { + m_caster->GetRandomPoint(*destTarget, radius, x, y, z); + m_caster->CastSpell({x, y, z}, 54522, true); + } + break; + } + case 52173: // Coyote Spirit Despawn + case 60243: // Blood Parrot Despawn + if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsSummon()) + unitTarget->ToTempSummon()->UnSummon(); + return; + case 57347: // Retrieving (Wintergrasp RP-GG pickup spell) + { + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + return; - // Delete item from inventory at death - m_caster->ToPlayer()->DestroyItemCount(damage, 5, true); + unitTarget->ToCreature()->DespawnOrUnsummon(); - return; - } - case 62482: // Grab Crate - { - if (!unitCaster) - return; + return; + } + case 57349: // Drop RP-GG (Wintergrasp RP-GG at death drop spell) + { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return; - if (unitTarget) + // Delete item from inventory at death + m_caster->ToPlayer()->DestroyItemCount(damage, 5, true); + + return; + } + case 62482: // Grab Crate + { + if (!unitCaster) + return; + + if (unitTarget) + { + if (Unit* seat = unitCaster->GetVehicleBase()) + { + if (Unit* parent = seat->GetVehicleBase()) { - if (Unit* seat = unitCaster->GetVehicleBase()) - { - if (Unit* parent = seat->GetVehicleBase()) - { - /// @todo a hack, range = 11, should after some time cast, otherwise too far - unitCaster->CastSpell(parent, 62496, true); - unitTarget->CastSpell(parent, m_spellInfo->Effects[EFFECT_0].CalcValue()); - } - } + /// @todo a hack, range = 11, should after some time cast, otherwise too far + unitCaster->CastSpell(parent, 62496, true); + unitTarget->CastSpell(parent, m_spellInfo->Effects[EFFECT_0].CalcValue()); } - return; } } - break; + return; + } } + break; + } } // normal DB scripted effect @@ -3669,7 +3694,7 @@ void Spell::EffectDuel(SpellEffIndex effIndex) pGameObj->SetFaction(caster->GetFaction()); pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, caster->GetLevel() + 1); int32 duration = m_spellInfo->GetDuration(); - pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); ExecuteLogEffectSummonObject(effIndex, pGameObj); @@ -3709,7 +3734,8 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) return; LOG_DEBUG("spells", "Spell Effect: Stuck"); - LOG_DEBUG("spells", "Player %s %s used the auto-unstuck feature at map %u (%f, %f, %f).", player->GetName().c_str(), player->GetGUID().ToString().c_str(), player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + LOG_DEBUG("spells", "Player %s %s used the auto-unstuck feature at map %u (%f, %f, %f).", player->GetName().c_str(), player->GetGUID().ToString().c_str(), player->GetMapId(), player->GetPositionX(), + player->GetPositionY(), player->GetPositionZ()); if (player->IsInFlight()) return; @@ -3739,7 +3765,7 @@ void Spell::EffectStuck(SpellEffIndex /*effIndex*/) } // we have hearthstone not on cooldown, just use it - player->CastSpell(player, 8690, TriggerCastFlags(TRIGGERED_FULL_MASK&~TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD)); + player->CastSpell(player, 8690, TriggerCastFlags(TRIGGERED_FULL_MASK & ~TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD)); } void Spell::EffectSummonPlayer(SpellEffIndex /*effIndex*/) @@ -3770,70 +3796,70 @@ void Spell::EffectActivateObject(SpellEffIndex effIndex) switch (action) { - case GameObjectActions::AnimateCustom0: - case GameObjectActions::AnimateCustom1: - case GameObjectActions::AnimateCustom2: - case GameObjectActions::AnimateCustom3: - gameObjTarget->SendCustomAnim(uint32(action) - uint32(GameObjectActions::AnimateCustom0)); - break; - case GameObjectActions::Disturb: // What's the difference with Open? - case GameObjectActions::Open: - if (Unit* unitCaster = m_caster->ToUnit()) - gameObjTarget->Use(unitCaster); - break; - case GameObjectActions::OpenAndUnlock: - if (Unit* unitCaster = m_caster->ToUnit()) - gameObjTarget->UseDoorOrButton(0, false, unitCaster); - [[fallthrough]]; - case GameObjectActions::Unlock: - case GameObjectActions::Lock: - gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED, action == GameObjectActions::Lock); - break; - case GameObjectActions::Close: - case GameObjectActions::Rebuild: - gameObjTarget->ResetDoorOrButton(); - break; - case GameObjectActions::Despawn: - gameObjTarget->DespawnOrUnsummon(); - break; - case GameObjectActions::MakeInert: - case GameObjectActions::MakeActive: - gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE, action == GameObjectActions::MakeInert); - break; - case GameObjectActions::CloseAndLock: - gameObjTarget->ResetDoorOrButton(); - gameObjTarget->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); - break; - case GameObjectActions::Destroy: - if (Unit* unitCaster = m_caster->ToUnit()) - gameObjTarget->UseDoorOrButton(0, true, unitCaster); - break; - case GameObjectActions::UseArtKit0: - case GameObjectActions::UseArtKit1: - case GameObjectActions::UseArtKit2: - case GameObjectActions::UseArtKit3: - { - GameObjectTemplateAddon const* templateAddon = gameObjTarget->GetTemplateAddon(); - - uint32 artKitIndex = uint32(action) - uint32(GameObjectActions::UseArtKit0); - - uint32 artKitValue = 0; - if (templateAddon != nullptr) - artKitValue = templateAddon->artKits[artKitIndex]; - - if (artKitValue == 0) - LOG_ERROR("sql.sql", "GameObject %d hit by spell %d needs `artkit%d` in `gameobject_template_addon`", gameObjTarget->GetEntry(), m_spellInfo->Id, artKitIndex); - else - gameObjTarget->SetGoArtKit(artKitValue); + case GameObjectActions::AnimateCustom0: + case GameObjectActions::AnimateCustom1: + case GameObjectActions::AnimateCustom2: + case GameObjectActions::AnimateCustom3: + gameObjTarget->SendCustomAnim(uint32(action) - uint32(GameObjectActions::AnimateCustom0)); + break; + case GameObjectActions::Disturb: // What's the difference with Open? + case GameObjectActions::Open: + if (Unit* unitCaster = m_caster->ToUnit()) + gameObjTarget->Use(unitCaster); + break; + case GameObjectActions::OpenAndUnlock: + if (Unit* unitCaster = m_caster->ToUnit()) + gameObjTarget->UseDoorOrButton(0, false, unitCaster); + [[fallthrough]]; + case GameObjectActions::Unlock: + case GameObjectActions::Lock: + gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED, action == GameObjectActions::Lock); + break; + case GameObjectActions::Close: + case GameObjectActions::Rebuild: + gameObjTarget->ResetDoorOrButton(); + break; + case GameObjectActions::Despawn: + gameObjTarget->DespawnOrUnsummon(); + break; + case GameObjectActions::MakeInert: + case GameObjectActions::MakeActive: + gameObjTarget->ApplyModFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE, action == GameObjectActions::MakeInert); + break; + case GameObjectActions::CloseAndLock: + gameObjTarget->ResetDoorOrButton(); + gameObjTarget->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); + break; + case GameObjectActions::Destroy: + if (Unit* unitCaster = m_caster->ToUnit()) + gameObjTarget->UseDoorOrButton(0, true, unitCaster); + break; + case GameObjectActions::UseArtKit0: + case GameObjectActions::UseArtKit1: + case GameObjectActions::UseArtKit2: + case GameObjectActions::UseArtKit3: + { + GameObjectTemplateAddon const* templateAddon = gameObjTarget->GetTemplateAddon(); + + uint32 artKitIndex = uint32(action) - uint32(GameObjectActions::UseArtKit0); + + uint32 artKitValue = 0; + if (templateAddon != nullptr) + artKitValue = templateAddon->artKits[artKitIndex]; + + if (artKitValue == 0) + LOG_ERROR("sql.sql", "GameObject %d hit by spell %d needs `artkit%d` in `gameobject_template_addon`", gameObjTarget->GetEntry(), m_spellInfo->Id, artKitIndex); + else + gameObjTarget->SetGoArtKit(artKitValue); - break; - } - case GameObjectActions::None: - LOG_FATAL("spell", "Spell %d has action type NONE in effect %d", m_spellInfo->Id, int32(effIndex)); - break; - default: - LOG_ERROR("spell", "Spell %d has unhandled action %d in effect %d", m_spellInfo->Id, int32(action), int32(effIndex)); - break; + break; + } + case GameObjectActions::None: + LOG_FATAL("spell", "Spell %d has action type NONE in effect %d", m_spellInfo->Id, int32(effIndex)); + break; + default: + LOG_ERROR("spell", "Spell %d has unhandled action %d in effect %d", m_spellInfo->Id, int32(action), int32(effIndex)); + break; } } @@ -3854,12 +3880,22 @@ void Spell::EffectApplyGlyph(SpellEffIndex effIndex) uint8 minLevel = 0; switch (m_glyphIndex) { - case 0: - case 1: minLevel = 15; break; - case 2: minLevel = 50; break; - case 3: minLevel = 30; break; - case 4: minLevel = 70; break; - case 5: minLevel = 80; break; + case 0: + case 1: + minLevel = 15; + break; + case 2: + minLevel = 50; + break; + case 3: + minLevel = 30; + break; + case 4: + minLevel = 70; + break; + case 5: + minLevel = 80; + break; } if (minLevel && player->GetLevel() < minLevel) { @@ -4422,7 +4458,7 @@ void Spell::EffectLeapBack(SpellEffIndex effIndex) return; float speedxy = m_spellInfo->Effects[effIndex].MiscValue / 10.f; - float speedz = damage/ 10.f; + float speedz = damage / 10.f; //1891: Disengage unitTarget->JumpTo(speedxy, speedz, m_spellInfo->SpellIconID != 1891); @@ -4624,7 +4660,7 @@ void Spell::EffectResurrectPet(SpellEffIndex /*effIndex*/) pet->SetHealth(pet->CountPctFromMaxHealth(damage)); // Reset things for when the AI to takes over - CharmInfo *ci = pet->GetCharmInfo(); + CharmInfo* ci = pet->GetCharmInfo(); if (ci) { // In case the pet was at stay, we don't want it running back @@ -4802,44 +4838,50 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) int32 duration = m_spellInfo->GetDuration(); switch (goinfo->type) { - case GAMEOBJECT_TYPE_FISHINGNODE: - { - unitCaster->SetChannelObjectGuid(pGameObj->GetGUID()); - unitCaster->AddGameObject(pGameObj); // will removed at spell cancel - - // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) - // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) - int32 lastSec = 0; - switch (urand(0, 2)) - { - case 0: lastSec = 3; break; - case 1: lastSec = 7; break; - case 2: lastSec = 13; break; - } + case GAMEOBJECT_TYPE_FISHINGNODE: + { + unitCaster->SetChannelObjectGuid(pGameObj->GetGUID()); + unitCaster->AddGameObject(pGameObj); // will removed at spell cancel - // Duration of the fishing bobber can't be higher than the Fishing channeling duration - duration = std::min(duration, duration - lastSec*IN_MILLISECONDS + FISHING_BOBBER_READY_TIME*IN_MILLISECONDS); - break; - } - case GAMEOBJECT_TYPE_SUMMONING_RITUAL: + // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) + // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) + int32 lastSec = 0; + switch (urand(0, 2)) { - if (unitCaster->GetTypeId() == TYPEID_PLAYER) - { - pGameObj->AddUniqueUse(unitCaster->ToPlayer()); - unitCaster->AddGameObject(pGameObj); // will be removed at spell cancel - } + case 0: + lastSec = 3; break; - } - case GAMEOBJECT_TYPE_DUEL_ARBITER: // 52991 - unitCaster->AddGameObject(pGameObj); + case 1: + lastSec = 7; break; - case GAMEOBJECT_TYPE_FISHINGHOLE: - case GAMEOBJECT_TYPE_CHEST: - default: + case 2: + lastSec = 13; break; + } + + // Duration of the fishing bobber can't be higher than the Fishing channeling duration + duration = std::min(duration, duration - lastSec * IN_MILLISECONDS + FISHING_BOBBER_READY_TIME * IN_MILLISECONDS); + break; + } + case GAMEOBJECT_TYPE_SUMMONING_RITUAL: + { + if (unitCaster->GetTypeId() == TYPEID_PLAYER) + { + pGameObj->AddUniqueUse(unitCaster->ToPlayer()); + unitCaster->AddGameObject(pGameObj); // will be removed at spell cancel + } + break; + } + case GAMEOBJECT_TYPE_DUEL_ARBITER: // 52991 + unitCaster->AddGameObject(pGameObj); + break; + case GAMEOBJECT_TYPE_FISHINGHOLE: + case GAMEOBJECT_TYPE_CHEST: + default: + break; } - pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); pGameObj->SetOwnerGUID(unitCaster->GetGUID()); @@ -4856,7 +4898,7 @@ void Spell::EffectTransmitted(SpellEffIndex effIndex) if (GameObject* linkedTrap = pGameObj->GetLinkedTrap()) { - linkedTrap->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + linkedTrap->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); //linkedTrap->SetUInt32Value(GAMEOBJECT_LEVEL, unitCaster->GetLevel()); linkedTrap->SetSpellId(m_spellInfo->Id); linkedTrap->SetOwnerGUID(unitCaster->GetGUID()); @@ -5351,7 +5393,7 @@ void Spell::EffectRenamePet(SpellEffIndex /*effIndex*/) return; if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || - !unitTarget->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET) + !unitTarget->IsPet() || ((Pet*)unitTarget)->getPetType() != HUNTER_PET) return; unitTarget->SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PET_FLAGS, UNIT_CAN_BE_RENAMED); @@ -5395,7 +5437,7 @@ void Spell::EffectActivateSpec(SpellEffIndex /*effIndex*/) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - unitTarget->ToPlayer()->ActivateSpec(damage-1); // damage is 1 or 2, spec is 0 or 1 + unitTarget->ToPlayer()->ActivateSpec(damage - 1); // damage is 1 or 2, spec is 0 or 1 } void Spell::EffectPlaySound(SpellEffIndex effIndex) @@ -5412,12 +5454,12 @@ void Spell::EffectPlaySound(SpellEffIndex effIndex) switch (m_spellInfo->Id) { - case 58730: // Restricted Flight Area - case 58600: // Restricted Flight Area - player->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE); - break; - default: - break; + case 58730: // Restricted Flight Area + case 58600: // Restricted Flight Area + player->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE); + break; + default: + break; } uint32 soundId = m_spellInfo->Effects[effIndex].MiscValue; @@ -5540,7 +5582,7 @@ void Spell::EffectBind(SpellEffIndex effIndex) player->SendBindPointUpdate(); LOG_DEBUG("spells", "EffectBind: New homebind X: %f, Y: %f, Z: %f, MapId: %u, AreaId: %u", - homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetMapId(), areaId); + homeLoc.GetPositionX(), homeLoc.GetPositionY(), homeLoc.GetPositionZ(), homeLoc.GetMapId(), areaId); // zone update WorldPackets::Misc::PlayerBound packet(m_caster->GetGUID(), areaId); diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index b8a6e7afc1863..fdd6e852b3c43 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -139,15 +139,19 @@ struct npc_wg_demolisher_engineer : public ScriptedAI { if (player->HasAura(SPELL_WINTERGRASP_CORPORAL)) { - AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_CATAPULT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); + AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_CATAPULT, GOSSIP_SENDER_MAIN, + GOSSIP_ACTION_INFO_DEF); SendGossipMenuFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? NPC_TEXT_HORDE_HOW_CAN_I_HELP : NPC_TEXT_ALLIANCE_HOW_CAN_I_HELP, me); return true; } else if (player->HasAura(SPELL_WINTERGRASP_LIEUTENANT)) { - AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_CATAPULT, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF); - AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_DEMOLISHER, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); - AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_SIEGE_ENGINE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2); + AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_CATAPULT, GOSSIP_SENDER_MAIN, + GOSSIP_ACTION_INFO_DEF); + AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_DEMOLISHER, GOSSIP_SENDER_MAIN, + GOSSIP_ACTION_INFO_DEF + 1); + AddGossipItemFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? GOSSIP_MENU_ENGINEER_HORDE : GOSSIP_MENU_ENGINEER_ALLIANCE, GOSSIP_MENU_OPTION_ENGINEER_SIEGE_ENGINE, GOSSIP_SENDER_MAIN, + GOSSIP_ACTION_INFO_DEF + 2); SendGossipMenuFor(player, me->GetEntry() == NPC_WINTERGRASP_GOBLIN_MECHANIC ? NPC_TEXT_HORDE_HOW_CAN_I_HELP : NPC_TEXT_ALLIANCE_HOW_CAN_I_HELP, me); return true; } @@ -175,17 +179,17 @@ struct npc_wg_demolisher_engineer : public ScriptedAI switch (selection) { - case 0: - DoCast(player, SPELL_BUILD_CATAPULT_FORCE, true); - break; - case 1: - DoCast(player, SPELL_BUILD_DEMOLISHER_FORCE, true); - break; - case 2: - DoCast(player, player->GetTeamId() == TEAM_ALLIANCE ? SPELL_BUILD_SIEGE_VEHICLE_FORCE_ALLIANCE : SPELL_BUILD_SIEGE_VEHICLE_FORCE_HORDE, true); - break; - default: - break; + case 0: + DoCast(player, SPELL_BUILD_CATAPULT_FORCE, true); + break; + case 1: + DoCast(player, SPELL_BUILD_DEMOLISHER_FORCE, true); + break; + case 2: + DoCast(player, player->GetTeamId() == TEAM_ALLIANCE ? SPELL_BUILD_SIEGE_VEHICLE_FORCE_ALLIANCE : SPELL_BUILD_SIEGE_VEHICLE_FORCE_HORDE, true); + break; + default: + break; } } return true; @@ -200,12 +204,12 @@ struct npc_wg_demolisher_engineer : public ScriptedAI switch (me->GetEntry()) { - case NPC_WINTERGRASP_GOBLIN_MECHANIC: - //return (wintergrasp->GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H) > wintergrasp->GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); - case NPC_WINTERGRASP_GNOMISH_ENGINEER: - //return (wintergrasp->GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A) > wintergrasp->GetData(BATTLEFIELD_WG_DATA_VEHICLE_A)); - default: - return false; + case NPC_WINTERGRASP_GOBLIN_MECHANIC: + //return (wintergrasp->GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_H) > wintergrasp->GetData(BATTLEFIELD_WG_DATA_VEHICLE_H)); + case NPC_WINTERGRASP_GNOMISH_ENGINEER: + //return (wintergrasp->GetData(BATTLEFIELD_WG_DATA_MAX_VEHICLE_A) > wintergrasp->GetData(BATTLEFIELD_WG_DATA_VEHICLE_A)); + default: + return false; } } }; @@ -273,12 +277,12 @@ class spell_wintergrasp_force_building : public SpellScript bool Validate(SpellInfo const* /*spell*/) override { return ValidateSpellInfo( - { - SPELL_BUILD_CATAPULT_FORCE, - SPELL_BUILD_DEMOLISHER_FORCE, - SPELL_BUILD_SIEGE_VEHICLE_FORCE_HORDE, - SPELL_BUILD_SIEGE_VEHICLE_FORCE_ALLIANCE - }); + { + SPELL_BUILD_CATAPULT_FORCE, + SPELL_BUILD_DEMOLISHER_FORCE, + SPELL_BUILD_SIEGE_VEHICLE_FORCE_HORDE, + SPELL_BUILD_SIEGE_VEHICLE_FORCE_ALLIANCE + }); } void HandleScript(SpellEffIndex effIndex) @@ -389,8 +393,8 @@ class spell_wintergrasp_tenacity_refresh : public AuraScript CastSpellExtraArgs args(aurEff); args - .AddSpellMod(SPELLVALUE_BASE_POINT0, bp) - .AddSpellMod(SPELLVALUE_BASE_POINT1, bp); + .AddSpellMod(SPELLVALUE_BASE_POINT0, bp) + .AddSpellMod(SPELLVALUE_BASE_POINT1, bp); GetTarget()->CastSpell(nullptr, triggeredSpellId, args); } @@ -439,54 +443,54 @@ class spell_wintergrasp_waiting_to_resurrect : public AuraScript class achievement_wg_didnt_stand_a_chance : public AchievementCriteriaScript { - public: - achievement_wg_didnt_stand_a_chance() : AchievementCriteriaScript("achievement_wg_didnt_stand_a_chance") { } +public: + achievement_wg_didnt_stand_a_chance() : AchievementCriteriaScript("achievement_wg_didnt_stand_a_chance") { } + + bool OnCheck(Player* source, Unit* target) override + { + if (!target) + return false; - bool OnCheck(Player* source, Unit* target) override + if (Player* victim = target->ToPlayer()) { - if (!target) + if (!victim->IsMounted()) return false; - if (Player* victim = target->ToPlayer()) - { - if (!victim->IsMounted()) - return false; - - if (Vehicle* vehicle = source->GetVehicle()) - if (vehicle->GetVehicleInfo()->m_ID == 244) // Wintergrasp Tower Cannon - return true; - } - - return false; + if (Vehicle* vehicle = source->GetVehicle()) + if (vehicle->GetVehicleInfo()->m_ID == 244) // Wintergrasp Tower Cannon + return true; } + + return false; + } }; class condition_is_wintergrasp_horde : public ConditionScript { - public: - condition_is_wintergrasp_horde() : ConditionScript("condition_is_wintergrasp_horde") { } +public: + condition_is_wintergrasp_horde() : ConditionScript("condition_is_wintergrasp_horde") { } - bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) - { - Battlefield* wintergrasp = sBattlefieldMgr->GetEnabledBattlefield(BATTLEFIELD_BATTLEID_WINTERGRASP); - if (wintergrasp && wintergrasp->GetControllingTeam() == PVP_TEAM_HORDE) - return true; - return false; - } + bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) + { + Battlefield* wintergrasp = sBattlefieldMgr->GetEnabledBattlefield(BATTLEFIELD_BATTLEID_WINTERGRASP); + if (wintergrasp && wintergrasp->GetControllingTeam() == PVP_TEAM_HORDE) + return true; + return false; + } }; class condition_is_wintergrasp_alliance : public ConditionScript { - public: - condition_is_wintergrasp_alliance() : ConditionScript("condition_is_wintergrasp_alliance") { } +public: + condition_is_wintergrasp_alliance() : ConditionScript("condition_is_wintergrasp_alliance") { } - bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) - { - Battlefield* wintergrasp = sBattlefieldMgr->GetEnabledBattlefield(BATTLEFIELD_BATTLEID_WINTERGRASP); - if (wintergrasp && wintergrasp->GetControllingTeam() == PVP_TEAM_ALLIANCE) - return true; - return false; - } + bool OnConditionCheck(Condition const* /*condition*/, ConditionSourceInfo& /*sourceInfo*/) + { + Battlefield* wintergrasp = sBattlefieldMgr->GetEnabledBattlefield(BATTLEFIELD_BATTLEID_WINTERGRASP); + if (wintergrasp && wintergrasp->GetControllingTeam() == PVP_TEAM_ALLIANCE) + return true; + return false; + } }; void AddSC_wintergrasp() diff --git a/src/server/shared/DataStores/DBCEnums.h b/src/server/shared/DataStores/DBCEnums.h index cc9de2de4de59..3a8ed9ab75e67 100644 --- a/src/server/shared/DataStores/DBCEnums.h +++ b/src/server/shared/DataStores/DBCEnums.h @@ -319,7 +319,7 @@ enum FactionTemplateFlags { FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats - FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT= 0x00002000 + FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT = 0x00002000 }; enum FactionMasks @@ -328,7 +328,7 @@ enum FactionMasks FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team FACTION_MASK_HORDE = 4, // player or creature from horde team FACTION_MASK_MONSTER = 8 // aggressive creature from monster team - // if none flags set then non-aggressive creature + // if none flags set then non-aggressive creature }; enum MapTypes // Lua_IsInInstance diff --git a/src/server/shared/SharedDefines.h b/src/server/shared/SharedDefines.h index 901e65f988f66..e5970f54c808c 100644 --- a/src/server/shared/SharedDefines.h +++ b/src/server/shared/SharedDefines.h @@ -59,14 +59,14 @@ inline uint32 GetMaxLevelForExpansion(uint32 expansion) { switch (expansion) { - case EXPANSION_CLASSIC: - return 60; - case EXPANSION_THE_BURNING_CRUSADE: - return 70; - case EXPANSION_WRATH_OF_THE_LICH_KING: - return 80; - default: - break; + case EXPANSION_CLASSIC: + return 60; + case EXPANSION_THE_BURNING_CRUSADE: + return 70; + case EXPANSION_WRATH_OF_THE_LICH_KING: + return 80; + default: + break; } return DEFAULT_MAX_LEVEL; } @@ -94,16 +94,16 @@ enum Races //RACE_GOBLIN = 9, RACE_BLOODELF = 10, // TITLE Blood Elf RACE_DRAENEI = 11 //, TITLE Draenei - //RACE_FEL_ORC = 12, - //RACE_NAGA = 13, - //RACE_BROKEN = 14, - //RACE_SKELETON = 15, - //RACE_VRYKUL = 16, - //RACE_TUSKARR = 17, - //RACE_FOREST_TROLL = 18, - //RACE_TAUNKA = 19, - //RACE_NORTHREND_SKELETON = 20, - //RACE_ICE_TROLL = 21 + //RACE_FEL_ORC = 12, + //RACE_NAGA = 13, + //RACE_BROKEN = 14, + //RACE_SKELETON = 15, + //RACE_VRYKUL = 16, + //RACE_TUSKARR = 17, + //RACE_FOREST_TROLL = 18, + //RACE_TAUNKA = 19, + //RACE_NORTHREND_SKELETON = 20, + //RACE_ICE_TROLL = 21 }; // max+1 for player race @@ -267,8 +267,8 @@ enum FactionTemplates enum MoneyConstants { COPPER = 1, - SILVER = COPPER*100, - GOLD = SILVER*100 + SILVER = COPPER * 100, + GOLD = SILVER * 100 }; enum Stats @@ -326,8 +326,8 @@ enum SpellSchoolMask : uint32 // 124, not include normal and holy damage SPELL_SCHOOL_MASK_SPELL = (SPELL_SCHOOL_MASK_FIRE | - SPELL_SCHOOL_MASK_NATURE | SPELL_SCHOOL_MASK_FROST | - SPELL_SCHOOL_MASK_SHADOW | SPELL_SCHOOL_MASK_ARCANE), + SPELL_SCHOOL_MASK_NATURE | SPELL_SCHOOL_MASK_FROST | + SPELL_SCHOOL_MASK_SHADOW | SPELL_SCHOOL_MASK_ARCANE), // 126 SPELL_SCHOOL_MASK_MAGIC = (SPELL_SCHOOL_MASK_HOLY | SPELL_SCHOOL_MASK_SPELL), @@ -387,7 +387,8 @@ uint32 constexpr ItemQualityColors[MAX_ITEM_QUALITY] = }; size_t constexpr MAX_QUEST_DIFFICULTY = 5; -uint32 constexpr QuestDifficultyColors[MAX_QUEST_DIFFICULTY] = { +uint32 constexpr QuestDifficultyColors[MAX_QUEST_DIFFICULTY] = +{ 0xff40c040, 0xff808080, 0xffffff00, @@ -1311,7 +1312,8 @@ enum GhostVisibilityType // Spell aura states // EnumUtils: DESCRIBE THIS enum AuraStateType -{ // (C) used in caster aura state (T) used in target aura state +{ + // (C) used in caster aura state (T) used in target aura state // (c) used in caster aura state-not (t) used in target aura state-not AURA_STATE_NONE = 0, // C | AURA_STATE_DEFENSE = 1, // C | @@ -2665,9 +2667,9 @@ enum CreatureType CREATURE_TYPE_GAS_CLOUD = 13 }; -uint32 const CREATURE_TYPEMASK_DEMON_OR_UNDEAD = (1 << (CREATURE_TYPE_DEMON-1)) | (1 << (CREATURE_TYPE_UNDEAD-1)); -uint32 const CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD = (1 << (CREATURE_TYPE_HUMANOID-1)) | (1 << (CREATURE_TYPE_UNDEAD-1)); -uint32 const CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL = (1 << (CREATURE_TYPE_MECHANICAL-1)) | (1 << (CREATURE_TYPE_ELEMENTAL-1)); +uint32 const CREATURE_TYPEMASK_DEMON_OR_UNDEAD = (1 << (CREATURE_TYPE_DEMON - 1)) | (1 << (CREATURE_TYPE_UNDEAD - 1)); +uint32 const CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD = (1 << (CREATURE_TYPE_HUMANOID - 1)) | (1 << (CREATURE_TYPE_UNDEAD - 1)); +uint32 const CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL = (1 << (CREATURE_TYPE_MECHANICAL - 1)) | (1 << (CREATURE_TYPE_ELEMENTAL - 1)); // CreatureFamily.dbc enum CreatureFamily @@ -2861,16 +2863,26 @@ constexpr uint8 ClassByQuestSort(int32 QuestSort) { switch (QuestSort) { - case QUEST_SORT_WARLOCK: return CLASS_WARLOCK; - case QUEST_SORT_WARRIOR: return CLASS_WARRIOR; - case QUEST_SORT_SHAMAN: return CLASS_SHAMAN; - case QUEST_SORT_PALADIN: return CLASS_PALADIN; - case QUEST_SORT_MAGE: return CLASS_MAGE; - case QUEST_SORT_ROGUE: return CLASS_ROGUE; - case QUEST_SORT_HUNTER: return CLASS_HUNTER; - case QUEST_SORT_PRIEST: return CLASS_PRIEST; - case QUEST_SORT_DRUID: return CLASS_DRUID; - case QUEST_SORT_DEATH_KNIGHT: return CLASS_DEATH_KNIGHT; + case QUEST_SORT_WARLOCK: + return CLASS_WARLOCK; + case QUEST_SORT_WARRIOR: + return CLASS_WARRIOR; + case QUEST_SORT_SHAMAN: + return CLASS_SHAMAN; + case QUEST_SORT_PALADIN: + return CLASS_PALADIN; + case QUEST_SORT_MAGE: + return CLASS_MAGE; + case QUEST_SORT_ROGUE: + return CLASS_ROGUE; + case QUEST_SORT_HUNTER: + return CLASS_HUNTER; + case QUEST_SORT_PRIEST: + return CLASS_PRIEST; + case QUEST_SORT_DRUID: + return CLASS_DRUID; + case QUEST_SORT_DEATH_KNIGHT: + return CLASS_DEATH_KNIGHT; } return 0; } @@ -3037,12 +3049,18 @@ constexpr SkillType SkillByLockType(LockType locktype) { switch (locktype) { - case LOCKTYPE_PICKLOCK: return SKILL_LOCKPICKING; - case LOCKTYPE_HERBALISM: return SKILL_HERBALISM; - case LOCKTYPE_MINING: return SKILL_MINING; - case LOCKTYPE_FISHING: return SKILL_FISHING; - case LOCKTYPE_INSCRIPTION: return SKILL_INSCRIPTION; - default: break; + case LOCKTYPE_PICKLOCK: + return SKILL_LOCKPICKING; + case LOCKTYPE_HERBALISM: + return SKILL_HERBALISM; + case LOCKTYPE_MINING: + return SKILL_MINING; + case LOCKTYPE_FISHING: + return SKILL_FISHING; + case LOCKTYPE_INSCRIPTION: + return SKILL_INSCRIPTION; + default: + break; } return SKILL_NONE; } @@ -3051,17 +3069,28 @@ constexpr uint32 SkillByQuestSort(int32 QuestSort) { switch (QuestSort) { - case QUEST_SORT_HERBALISM: return SKILL_HERBALISM; - case QUEST_SORT_FISHING: return SKILL_FISHING; - case QUEST_SORT_BLACKSMITHING: return SKILL_BLACKSMITHING; - case QUEST_SORT_ALCHEMY: return SKILL_ALCHEMY; - case QUEST_SORT_LEATHERWORKING: return SKILL_LEATHERWORKING; - case QUEST_SORT_ENGINEERING: return SKILL_ENGINEERING; - case QUEST_SORT_TAILORING: return SKILL_TAILORING; - case QUEST_SORT_COOKING: return SKILL_COOKING; - case QUEST_SORT_FIRST_AID: return SKILL_FIRST_AID; - case QUEST_SORT_JEWELCRAFTING: return SKILL_JEWELCRAFTING; - case QUEST_SORT_INSCRIPTION: return SKILL_INSCRIPTION; + case QUEST_SORT_HERBALISM: + return SKILL_HERBALISM; + case QUEST_SORT_FISHING: + return SKILL_FISHING; + case QUEST_SORT_BLACKSMITHING: + return SKILL_BLACKSMITHING; + case QUEST_SORT_ALCHEMY: + return SKILL_ALCHEMY; + case QUEST_SORT_LEATHERWORKING: + return SKILL_LEATHERWORKING; + case QUEST_SORT_ENGINEERING: + return SKILL_ENGINEERING; + case QUEST_SORT_TAILORING: + return SKILL_TAILORING; + case QUEST_SORT_COOKING: + return SKILL_COOKING; + case QUEST_SORT_FIRST_AID: + return SKILL_FIRST_AID; + case QUEST_SORT_JEWELCRAFTING: + return SKILL_JEWELCRAFTING; + case QUEST_SORT_INSCRIPTION: + return SKILL_INSCRIPTION; } return 0; } @@ -3293,7 +3322,7 @@ enum SummonCategory SUMMON_CATEGORY_PUPPET = 3, SUMMON_CATEGORY_VEHICLE = 4, SUMMON_CATEGORY_UNK = 5 // as of patch 3.3.5a only Bone Spike in Icecrown Citadel - // uses this category + // uses this category }; enum SummonType @@ -3482,10 +3511,14 @@ constexpr TeamId TeamIdByPvPTeamId(PvPTeamId value) { switch (value) { - case PVP_TEAM_HORDE: return TEAM_HORDE; - case PVP_TEAM_ALLIANCE: return TEAM_ALLIANCE; - case PVP_TEAM_NEUTRAL: return TEAM_NEUTRAL; - default: break; + case PVP_TEAM_HORDE: + return TEAM_HORDE; + case PVP_TEAM_ALLIANCE: + return TEAM_ALLIANCE; + case PVP_TEAM_NEUTRAL: + return TEAM_NEUTRAL; + default: + break; } return TEAM_NEUTRAL; } @@ -3867,14 +3900,14 @@ enum WorldState : uint32 namespace Warhead { -namespace Impl -{ - struct WH_SHARED_API CurrentServerProcessHolder + namespace Impl { - static ServerProcessTypes type() { return _type; } - static ServerProcessTypes _type; - }; -} + struct WH_SHARED_API CurrentServerProcessHolder + { + static ServerProcessTypes type() { return _type; } + static ServerProcessTypes _type; + }; + } } #define THIS_SERVER_PROCESS (Warhead::Impl::CurrentServerProcessHolder::type()) diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index b5c498a37473d..d3ce075820908 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -50,7 +50,7 @@ namespace Warhead::Impl::Readline static std::vector vec; char* cli_unpack_vector(char const*, int state) { - static size_t i=0; + static size_t i = 0; if (!state) i = 0; if (i < vec.size()) @@ -62,15 +62,15 @@ namespace Warhead::Impl::Readline char** cli_completion(char const* text, int /*start*/, int /*end*/) { ::rl_attempted_completion_over = 1; - vec = Warhead::ChatCommands::GetAutoCompletionsFor(CliHandler(nullptr,nullptr), text); + vec = Warhead::ChatCommands::GetAutoCompletionsFor(CliHandler(nullptr, nullptr), text); return ::rl_completion_matches(text, &cli_unpack_vector); } int cli_hook_func() { - if (World::IsStopped()) - ::rl_done = 1; - return 0; + if (World::IsStopped()) + ::rl_done = 1; + return 0; } } #endif @@ -84,10 +84,10 @@ void utf8print(void* /*arg*/, std::string_view str) wprintf(L"%s", wbuf.c_str()); #else -{ - printf(STRING_VIEW_FMT, STRING_VIEW_FMT_ARG(str)); - fflush(stdout); -} + { + printf(STRING_VIEW_FMT, STRING_VIEW_FMT_ARG(str)); + fflush(stdout); + } #endif } @@ -107,7 +107,7 @@ int kb_hit_return() tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); - select(STDIN_FILENO+1, &fds, nullptr, nullptr, &tv); + select(STDIN_FILENO + 1, &fds, nullptr, nullptr, &tv); return FD_ISSET(STDIN_FILENO, &fds); } #endif @@ -181,8 +181,6 @@ void CliThread() #endif } else if (feof(stdin)) - { World::StopNow(SHUTDOWN_EXIT_CODE); - } } } From d3c50f9f86b47582fe56598e1eed4e4fd5f905a3 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 13 Jan 2021 05:32:13 +0000 Subject: [PATCH 2/2] [Restyler] whitespace --- src/server/scripts/Northrend/zone_wintergrasp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index fdd6e852b3c43..2a52ac6cabb63 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -506,4 +506,4 @@ void AddSC_wintergrasp() new achievement_wg_didnt_stand_a_chance(); new condition_is_wintergrasp_horde(); new condition_is_wintergrasp_alliance(); -} \ No newline at end of file +}