aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Player/Player.cpp20
-rw-r--r--src/server/game/Entities/Player/Player.h12
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp22
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h1
4 files changed, 53 insertions, 2 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 0c135e75f99..fb0dad4eefd 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -7229,13 +7229,15 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
void Player::UpdateHostileAreaState(AreaTableEntry const* area)
{
+ ZonePVPTypeOverride overrideZonePvpType = GetOverrideZonePVPType();
+
pvpInfo.IsInHostileArea = false;
if (area->IsSanctuary()) // sanctuary and arena cannot be overriden
pvpInfo.IsInHostileArea = false;
else if (area->Flags[0] & AREA_FLAG_ARENA)
pvpInfo.IsInHostileArea = true;
- else
+ else if (overrideZonePvpType == ZonePVPTypeOverride::None)
{
if (area)
{
@@ -7258,6 +7260,22 @@ void Player::UpdateHostileAreaState(AreaTableEntry const* area)
}
}
}
+ else
+ {
+ switch (overrideZonePvpType)
+ {
+ case ZonePVPTypeOverride::Friendly:
+ pvpInfo.IsInHostileArea = false;
+ break;
+ case ZonePVPTypeOverride::Hostile:
+ case ZonePVPTypeOverride::Contested:
+ case ZonePVPTypeOverride::Combat:
+ pvpInfo.IsInHostileArea = true;
+ break;
+ default:
+ break;
+ }
+ }
// Treat players having a quest flagging for PvP as always in hostile area
pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest();
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 2952253f87f..c2c713d78a9 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -992,6 +992,15 @@ uint32 constexpr PLAYER_MAX_HONOR_LEVEL = 500;
uint8 constexpr PLAYER_LEVEL_MIN_HONOR = 110;
uint32 constexpr SPELL_PVP_RULES_ENABLED = 134735;
+enum class ZonePVPTypeOverride : uint32
+{
+ None = 0,
+ Friendly = 1,
+ Hostile = 2,
+ Contested = 3,
+ Combat = 4
+};
+
class TC_GAME_API Player : public Unit, public GridObject<Player>
{
friend class WorldSession;
@@ -1595,6 +1604,9 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SetLootSpecId(uint32 id) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::LootSpecID), id); }
uint32 GetLootSpecId() const { return m_activePlayerData->LootSpecID; }
+ ZonePVPTypeOverride GetOverrideZonePVPType() const { return ZonePVPTypeOverride(*m_activePlayerData->OverrideZonePVPType); }
+ void SetOverrideZonePVPType(ZonePVPTypeOverride type) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::OverrideZonePVPType), uint32(type)); }
+
// Talents
uint32 GetTalentResetCost() const { return _specializationInfo.ResetTalentsCost; }
void SetTalentResetCost(uint32 cost) { _specializationInfo.ResetTalentsCost = cost; }
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 95e68152182..bf0a98c145d 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -497,7 +497,7 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleLinkedSummon, //428 SPELL_AURA_LINKED_SUMMON
&AuraEffect::HandleNULL, //429
&AuraEffect::HandlePlayScene, //430 SPELL_AURA_PLAY_SCENE
- &AuraEffect::HandleNULL, //431
+ &AuraEffect::HandleModOverrideZonePVPType, //431 SPELL_AURA_MOD_OVERRIDE_ZONE_PVP_TYPE
&AuraEffect::HandleNULL, //432
&AuraEffect::HandleNULL, //433
&AuraEffect::HandleNULL, //434
@@ -6378,6 +6378,26 @@ void AuraEffect::HandleLinkedSummon(AuraApplication const* aurApp, uint8 mode, b
}
}
+void AuraEffect::HandleModOverrideZonePVPType(AuraApplication const* aurApp, uint8 mode, bool apply) const
+{
+ if (!(mode & AURA_EFFECT_HANDLE_REAL))
+ return;
+
+ Player* target = aurApp->GetTarget()->ToPlayer();
+ if (!target)
+ return;
+
+ if (apply)
+ target->SetOverrideZonePVPType(ZonePVPTypeOverride(GetMiscValue()));
+ else if (target->HasAuraType(SPELL_AURA_MOD_OVERRIDE_ZONE_PVP_TYPE))
+ target->SetOverrideZonePVPType(ZonePVPTypeOverride(target->GetAuraEffectsByType(SPELL_AURA_MOD_OVERRIDE_ZONE_PVP_TYPE).back()->GetMiscValue()));
+ else
+ target->SetOverrideZonePVPType(ZonePVPTypeOverride::None);
+
+ target->UpdateHostileAreaState(sAreaTableStore.LookupEntry(target->GetZoneId()));
+ target->UpdatePvPState();
+}
+
template TC_GAME_API void AuraEffect::GetTargetList(std::list<Unit*>&) const;
template TC_GAME_API void AuraEffect::GetTargetList(std::deque<Unit*>&) const;
template TC_GAME_API void AuraEffect::GetTargetList(std::vector<Unit*>&) const;
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index a85879111b3..68b581b03ca 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -322,6 +322,7 @@ class TC_GAME_API AuraEffect
void HandlePlayScene(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleCreateAreaTrigger(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleLinkedSummon(AuraApplication const* aurApp, uint8 mode, bool apply) const;
+ void HandleModOverrideZonePVPType(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// aura effect periodic tick handlers
void HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const;