Core/Achievements: Fixed achievement criteria StartEvent and FailEvent

* Criteria using StartEvent cannot be updated without that event triggering first (not only for timed achievements)
* Implemented most StartEvent and FailEvent types
* Fixed saving criteria removed by RemoveCriteriaProgress
Port From (https://github.com/TrinityCore/TrinityCore/commit/41a20b1e4008d450d075847ef1fe367f0e3a240f)
This commit is contained in:
hondacrx
2024-01-30 10:22:01 -05:00
parent 902b217d88
commit a1cb1d95ee
16 changed files with 148 additions and 211 deletions
+5 -6
View File
@@ -352,9 +352,12 @@ namespace Game.BattleGrounds
foreach (var (guid, _) in GetPlayers())
{
Player player = Global.ObjAccessor.FindPlayer(guid);
Player player = Global.ObjAccessor.GetPlayer(GetBgMap(), guid);
if (player != null)
{
player.StartCriteria(CriteriaStartEvent.StartBattleground, GetBgMap().GetId());
player.AtStartOfEncounter(EncounterType.Battleground);
}
}
// Remove preparation
@@ -874,7 +877,7 @@ namespace Game.BattleGrounds
player.SetBGTeam(0);
// remove all criterias on bg leave
player.ResetCriteria(CriteriaFailEvent.LeaveBattleground, GetMapId(), true);
player.FailCriteria(CriteriaFailEvent.LeaveBattleground, 0);
if (Transport)
player.TeleportToBGEntryPoint();
@@ -1041,10 +1044,6 @@ namespace Game.BattleGrounds
}
}
// reset all map criterias on map enter
if (!isInBattleground)
player.ResetCriteria(CriteriaFailEvent.LeaveBattleground, GetMapId(), true);
// setup BG group membership
PlayerAddedToBGCheckIfBGIsRunning(player);
AddOrSetPlayerToCorrectBgGroup(player, team);
@@ -439,7 +439,7 @@ namespace Game.BattleGrounds.Zones
//update world state to show correct flag carrier
UpdateFlagState(Team.Horde, WSGFlagState.OnPlayer);
player.CastSpell(player, WSGSpellId.SilverwingFlag, true);
player.StartCriteriaTimer(CriteriaStartEvent.BeSpellTarget, WSGSpellId.SilverwingFlagPicked);
//player.StartCriteria(CriteriaStartEvent.BeSpellTarget, WSGSpellId.SilverwingFlagPicked);
if (_flagState[1] == WSGFlagState.OnPlayer)
_bothFlagsKept = true;
@@ -461,7 +461,7 @@ namespace Game.BattleGrounds.Zones
//update world state to show correct flag carrier
UpdateFlagState(Team.Alliance, WSGFlagState.OnPlayer);
player.CastSpell(player, WSGSpellId.WarsongFlag, true);
player.StartCriteriaTimer(CriteriaStartEvent.BeSpellTarget, WSGSpellId.WarsongFlagPicked);
//player.StartCriteriaTimer(CriteriaStartEvent.BeSpellTarget, WSGSpellId.WarsongFlagPicked);
if (_flagState[0] == WSGFlagState.OnPlayer)
_bothFlagsKept = true;