Core/Battlegrounds: Implement mercenary system
Port From (https://github.com/TrinityCore/TrinityCore/commit/87723e32e24f03ac1d062e33edcbe935e4e59421)
This commit is contained in:
@@ -88,6 +88,10 @@ namespace Framework.Constants
|
||||
public const uint SpellAuraPlayerInactive = 43681; // Inactive
|
||||
public const uint SpellHonorableDefender25y = 68652; // +50% Honor When Standing At A Capture Point That You Control, 25yards Radius (Added In 3.2)
|
||||
public const uint SpellHonorableDefender60y = 66157; // +50% Honor When Standing At A Capture Point That You Control, 60yards Radius (Added In 3.2), Probably For 40+ Player Battlegrounds
|
||||
public const uint SpellMercenaryHorde1 = 193864;
|
||||
public const uint SpellMercenaryHorde2 = 195838;
|
||||
public const uint SpellMercenaryAlliance1 = 193863;
|
||||
public const uint SpellMercenaryAlliance2 = 195843;
|
||||
}
|
||||
|
||||
public enum BattlegroundEventFlags
|
||||
|
||||
@@ -77,6 +77,10 @@ namespace Framework.Constants
|
||||
|
||||
//Warmode
|
||||
public const uint WarmodeEnlistedSpellOutside = 269083;
|
||||
|
||||
//Mercenary System
|
||||
public const uint SpellMercenaryContractHorde = 193472;
|
||||
public const uint SpellMercenaryContractAlliance = 193475;
|
||||
}
|
||||
|
||||
public struct MoneyConstants
|
||||
|
||||
@@ -510,8 +510,8 @@ namespace Framework.Constants
|
||||
Unk486 = 486,
|
||||
CosmeticMounted = 487,
|
||||
Unk488 = 488,
|
||||
Unk489 = 489,
|
||||
Unk490 = 490,
|
||||
ModAlternativeDefaultLanguage = 489, // NYI
|
||||
SwitchTeam = 490,
|
||||
Unk491 = 491,
|
||||
Unk492 = 492,
|
||||
Unk493 = 493,
|
||||
|
||||
@@ -625,6 +625,9 @@ namespace Game.BattleGrounds
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
if (player.GetNativeTeam() != team)
|
||||
continue;
|
||||
|
||||
uint repGain = Reputation;
|
||||
MathFunctions.AddPct(ref repGain, player.GetTotalAuraModifier(AuraType.ModReputationGain));
|
||||
MathFunctions.AddPct(ref repGain, player.GetTotalAuraModifierByMiscValue(AuraType.ModFactionReputationGain, (int)faction_id));
|
||||
@@ -850,6 +853,8 @@ namespace Game.BattleGrounds
|
||||
player.RemoveAurasByType(AuraType.ModShapeshift);
|
||||
|
||||
player.RemoveAurasByType(AuraType.Mounted);
|
||||
player.RemoveAurasByType(AuraType.SwitchTeam);
|
||||
player.RemoveAurasByType(AuraType.ModFaction);
|
||||
|
||||
if (!player.IsAlive()) // resurrect on exit
|
||||
{
|
||||
@@ -1065,6 +1070,17 @@ namespace Game.BattleGrounds
|
||||
|
||||
player.SendPacket(timer);
|
||||
}
|
||||
|
||||
if (player.HasAura(PlayerConst.SpellMercenaryContractHorde))
|
||||
{
|
||||
player.CastSpell(player, BattlegroundConst.SpellMercenaryHorde1, true);
|
||||
player.CastSpell(player, BattlegroundConst.SpellMercenaryHorde2, true);
|
||||
}
|
||||
else if (player.HasAura(PlayerConst.SpellMercenaryContractAlliance))
|
||||
{
|
||||
player.CastSpell(player, BattlegroundConst.SpellMercenaryAlliance1, true);
|
||||
player.CastSpell(player, BattlegroundConst.SpellMercenaryAlliance2, true);
|
||||
}
|
||||
}
|
||||
|
||||
// reset all map criterias on map enter
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Game.BattleGrounds
|
||||
ginfo.IsInvitedToBGInstanceGUID = 0;
|
||||
ginfo.JoinTime = GameTime.GetGameTimeMS();
|
||||
ginfo.RemoveInviteTime = 0;
|
||||
ginfo.Team = leader.GetTeam();
|
||||
ginfo.Team = leader.GetBgQueueTeam();
|
||||
ginfo.ArenaTeamRating = ArenaRating;
|
||||
ginfo.ArenaMatchmakerRating = MatchmakerRating;
|
||||
ginfo.OpponentsTeamRating = 0;
|
||||
@@ -109,6 +109,14 @@ namespace Game.BattleGrounds
|
||||
m_QueuedPlayers[member.GetGUID()] = pl_info;
|
||||
// add the pinfo to ginfo's list
|
||||
ginfo.Players[member.GetGUID()] = pl_info;
|
||||
|
||||
if (ginfo.Team != member.GetTeam())
|
||||
{
|
||||
if (member.GetTeam() == Team.Alliance)
|
||||
member.CastSpell(member, PlayerConst.SpellMercenaryContractHorde);
|
||||
else
|
||||
member.CastSpell(member, PlayerConst.SpellMercenaryContractAlliance);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3515,6 +3515,29 @@ namespace Game.Entities
|
||||
|
||||
uint GetChampioningFaction() { return m_ChampioningFaction; }
|
||||
public void SetChampioningFaction(uint faction) { m_ChampioningFaction = faction; }
|
||||
|
||||
public void SwitchToOppositeTeam(bool apply)
|
||||
{
|
||||
m_team = GetNativeTeam();
|
||||
|
||||
if (apply)
|
||||
m_team = (m_team == Team.Alliance) ? Team.Horde : Team.Alliance;
|
||||
}
|
||||
|
||||
public Team GetBgQueueTeam()
|
||||
{
|
||||
if (HasAura(PlayerConst.SpellMercenaryContractHorde))
|
||||
return Team.Horde;
|
||||
|
||||
if (HasAura(PlayerConst.SpellMercenaryContractAlliance))
|
||||
return Team.Alliance;
|
||||
|
||||
return GetTeam();
|
||||
}
|
||||
|
||||
public Team GetNativeTeam() { return TeamForRace(GetRace()); }
|
||||
public uint GetNativeTeamId() { return TeamIdForRace(GetRace()); }
|
||||
|
||||
public void SetFactionForRace(Race race)
|
||||
{
|
||||
m_team = TeamForRace(race);
|
||||
|
||||
@@ -403,6 +403,10 @@ namespace Game
|
||||
if (!spellInfo.IsPositive() || spellInfo.IsPassive())
|
||||
return;
|
||||
|
||||
if (spellInfo.Id == PlayerConst.SpellMercenaryContractHorde || spellInfo.Id == PlayerConst.SpellMercenaryContractAlliance)
|
||||
if (_player.InBattlegroundQueue())
|
||||
return;
|
||||
|
||||
GetPlayer().RemoveOwnedAura(cancelAura.SpellID, cancelAura.CasterGUID, 0, AuraRemoveMode.Cancel);
|
||||
}
|
||||
|
||||
|
||||
@@ -5736,6 +5736,17 @@ namespace Game.Spells
|
||||
}
|
||||
}
|
||||
|
||||
[AuraEffectHandler(AuraType.SwitchTeam)]
|
||||
void HandleSwitchTeam(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
|
||||
{
|
||||
if (!mode.HasFlag(AuraEffectHandleModes.Real))
|
||||
return;
|
||||
|
||||
Player player = aurApp.GetTarget().ToPlayer();
|
||||
if (player != null)
|
||||
player.SwitchToOppositeTeam(apply);
|
||||
}
|
||||
|
||||
[AuraEffectHandler(AuraType.SetFFAPvp)]
|
||||
void HandleSetFFAPvP(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
|
||||
{
|
||||
|
||||
@@ -4338,6 +4338,23 @@ namespace Game.Entities
|
||||
spellInfo.Attributes |= SpellAttr0.UnaffectedByInvulnerability;
|
||||
});
|
||||
|
||||
// Horde / Alliance switch (BG mercenary system)
|
||||
ApplySpellFix(new[] { 195838, 195843 }, spellInfo =>
|
||||
{
|
||||
ApplySpellEffectFix(spellInfo, 0, spellEffectInfo =>
|
||||
{
|
||||
spellEffectInfo.Effect = SpellEffectName.ApplyAura;
|
||||
});
|
||||
ApplySpellEffectFix(spellInfo, 1, spellEffectInfo =>
|
||||
{
|
||||
spellEffectInfo.Effect = SpellEffectName.ApplyAura;
|
||||
});
|
||||
ApplySpellEffectFix(spellInfo, 2, spellEffectInfo =>
|
||||
{
|
||||
spellEffectInfo.Effect = SpellEffectName.ApplyAura;
|
||||
});
|
||||
});
|
||||
|
||||
foreach (var spellInfo in mSpellInfoMap.Values)
|
||||
{
|
||||
// Fix range for trajectory triggered spell
|
||||
|
||||
Reference in New Issue
Block a user