Core/Auras: Implemented SPELL_AURA_MOD_OVERRIDE_ZONE_PVP_TYPE

Port From (https://github.com/TrinityCore/TrinityCore/commit/c250a858b91a11736ee0a64c2f120b1d036b5203)
This commit is contained in:
hondacrx
2020-10-09 13:57:32 -04:00
parent 77b08c3fd9
commit a108bb1dbc
3 changed files with 62 additions and 11 deletions
@@ -757,4 +757,13 @@ namespace Framework.Constants
Default = InEquipment | InInventory, Default = InEquipment | InInventory,
Everywhere = InEquipment | InInventory | InBank | InReagentBank Everywhere = InEquipment | InInventory | InBank | InReagentBank
} }
public enum ZonePVPTypeOverride
{
None = 0,
Friendly = 1,
Hostile = 2,
Contested = 3,
Combat = 4
}
} }
+23 -2
View File
@@ -222,15 +222,17 @@ namespace Game.Entities
} }
} }
void UpdateHostileAreaState(AreaTableRecord area) public void UpdateHostileAreaState(AreaTableRecord area)
{ {
ZonePVPTypeOverride overrideZonePvpType = GetOverrideZonePVPType();
pvpInfo.IsInHostileArea = false; pvpInfo.IsInHostileArea = false;
if (area.IsSanctuary()) // sanctuary and arena cannot be overriden if (area.IsSanctuary()) // sanctuary and arena cannot be overriden
pvpInfo.IsInHostileArea = false; pvpInfo.IsInHostileArea = false;
else if (area.Flags[0].HasAnyFlag(AreaFlags.Arena)) else if (area.Flags[0].HasAnyFlag(AreaFlags.Arena))
pvpInfo.IsInHostileArea = true; pvpInfo.IsInHostileArea = true;
else else if (overrideZonePvpType == ZonePVPTypeOverride.None)
{ {
if (area != null) if (area != null)
{ {
@@ -253,11 +255,30 @@ namespace Game.Entities
} }
} }
} }
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 // Treat players having a quest flagging for PvP as always in hostile area
pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest(); pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest();
} }
public ZonePVPTypeOverride GetOverrideZonePVPType() { return (ZonePVPTypeOverride)(uint)m_activePlayerData.OverrideZonePVPType; }
public void SetOverrideZonePVPType(ZonePVPTypeOverride type) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.OverrideZonePVPType), (uint)type); }
public InstanceBind GetBoundInstance(uint mapid, Difficulty difficulty, bool withExpired = false) public InstanceBind GetBoundInstance(uint mapid, Difficulty difficulty, bool withExpired = false)
{ {
// some instances only have one difficulty // some instances only have one difficulty
+30 -9
View File
@@ -888,7 +888,7 @@ namespace Game.Spells
public bool HasAmount() { return m_amount != 0; } public bool HasAmount() { return m_amount != 0; }
public void SetAmount(int _amount) { m_amount = _amount; m_canBeRecalculated = false; } public void SetAmount(int _amount) { m_amount = _amount; m_canBeRecalculated = false; }
int GetPeriodicTimer() { return m_periodicTimer; } public int GetPeriodicTimer() { return m_periodicTimer; }
public void SetPeriodicTimer(int periodicTimer) { m_periodicTimer = periodicTimer; } public void SetPeriodicTimer(int periodicTimer) { m_periodicTimer = periodicTimer; }
void RecalculateAmount() void RecalculateAmount()
@@ -3502,17 +3502,17 @@ namespace Game.Spells
{ {
float amount = target.GetTotalAuraMultiplier(AuraType.ModIncreaseEnergyPercent, aurEff => float amount = target.GetTotalAuraMultiplier(AuraType.ModIncreaseEnergyPercent, aurEff =>
{ {
if (aurEff.GetMiscValue() == (int)powerType) if (aurEff.GetMiscValue() == (int)powerType)
return true; return true;
return false; return false;
}); });
amount *= target.GetTotalAuraMultiplier(AuraType.ModMaxPowerPct, aurEff => amount *= target.GetTotalAuraMultiplier(AuraType.ModMaxPowerPct, aurEff =>
{ {
if (aurEff.GetMiscValue() == (int)powerType) if (aurEff.GetMiscValue() == (int)powerType)
return true; return true;
return false; return false;
}); });
target.SetStatPctModifier(unitMod, UnitModifierPctType.Total, amount); target.SetStatPctModifier(unitMod, UnitModifierPctType.Total, amount);
} }
@@ -6198,6 +6198,27 @@ namespace Game.Spells
} }
} }
} }
[AuraEffectHandler(AuraType.ModOverrideZonePvpType)]
void HandleModOverrideZonePVPType(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{
if (!mode.HasAnyFlag(AuraEffectHandleModes.Real))
return;
Player target = aurApp.GetTarget().ToPlayer();
if (target == null)
return;
if (apply)
target.SetOverrideZonePVPType((ZonePVPTypeOverride)GetMiscValue());
else if (target.HasAuraType(AuraType.ModOverrideZonePvpType))
target.SetOverrideZonePVPType((ZonePVPTypeOverride)target.GetAuraEffectsByType(AuraType.ModOverrideZonePvpType).Last().GetMiscValue());
else
target.SetOverrideZonePVPType(ZonePVPTypeOverride.None);
target.UpdateHostileAreaState(CliDB.AreaTableStorage.LookupByKey(target.GetZoneId()));
target.UpdatePvPState();
}
#endregion #endregion
} }