From dc5595a91f0c9eb9cf1722fc1c337bce5be43fa8 Mon Sep 17 00:00:00 2001 From: Feanordev Date: Fri, 16 Sep 2011 21:42:10 +0200 Subject: [PATCH] [11794] Add support to start timed achievements in BGs Signed-off-by: Schmoozerd --- src/game/BattleGround.cpp | 7 +++++++ src/game/BattleGround.h | 2 ++ src/game/BattleGroundAB.cpp | 3 +++ src/game/BattleGroundAB.h | 1 + src/game/BattleGroundAV.cpp | 3 +++ src/game/BattleGroundAV.h | 2 ++ src/game/BattleGroundEY.cpp | 3 +++ src/game/BattleGroundEY.h | 1 + src/game/BattleGroundSA.h | 3 +++ src/game/BattleGroundWS.cpp | 3 +++ src/game/BattleGroundWS.h | 1 + src/shared/revision_nr.h | 2 +- 12 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 14a0abbda..601585f14 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -1165,6 +1165,13 @@ void BattleGround::StartBattleGround() sBattleGroundMgr.AddBattleGround(GetInstanceID(), GetTypeID(), this); } +void BattleGround::StartTimedAchievement(AchievementCriteriaTypes type, uint32 entry) +{ + for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) + if (Player* pPlayer = GetBgMap()->GetPlayer(itr->first)) + pPlayer->GetAchievementMgr().StartTimedAchievementCriteria(type, entry); +} + void BattleGround::AddPlayer(Player *plr) { // remove afk from player diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index db705ecb1..2e2801178 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -381,6 +381,8 @@ class BattleGround void StartBattleGround(); + void StartTimedAchievement(AchievementCriteriaTypes type, uint32 entry); + /* Location */ void SetMapId(uint32 MapID) { m_MapId = MapID; } uint32 GetMapId() const { return m_MapId; } diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index f450b28af..ac5bbeb75 100644 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -174,6 +174,9 @@ void BattleGroundAB::StartingEventOpenDoors() SpawnBGObject(m_BgObjects[BG_AB_OBJECT_SPEEDBUFF_STABLES + buff + i * 3], RESPAWN_IMMEDIATELY); } OpenDoorEvent(BG_EVENT_DOOR); + + // Players that join battleground after start are not eligible to get achievement. + StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_AB_EVENT_START_BATTLE); } void BattleGroundAB::AddPlayer(Player *plr) diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h index d014cb9cc..2b3430d58 100644 --- a/src/game/BattleGroundAB.h +++ b/src/game/BattleGroundAB.h @@ -139,6 +139,7 @@ enum BG_AB_Sounds #define BG_AB_ABBGWeekendHonorTicks 200 #define BG_AB_NotABBGWeekendReputationTicks 200 #define BG_AB_ABBGWeekendReputationTicks 150 +#define BG_AB_EVENT_START_BATTLE 9158 // Tick intervals and given points: case 0,1,2,3,4,5 captured nodes const uint32 BG_AB_TickIntervals[6] = {0, 12000, 9000, 6000, 3000, 1000}; diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index c7ff4cb18..55f8ccfdc 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -282,6 +282,9 @@ void BattleGroundAV::StartingEventOpenDoors() UpdateWorldState(BG_AV_SHOW_A_SCORE, 1); OpenDoorEvent(BG_EVENT_DOOR); + + // Players that join battleground after start are not available to get achievement. + StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_AV_EVENT_START_BATTLE); } void BattleGroundAV::AddPlayer(Player *plr) diff --git a/src/game/BattleGroundAV.h b/src/game/BattleGroundAV.h index 092099718..3b0d9f7b0 100644 --- a/src/game/BattleGroundAV.h +++ b/src/game/BattleGroundAV.h @@ -68,6 +68,8 @@ #define BG_AV_REP_OWNED_MINE 24 #define BG_AV_REP_OWNED_MINE_HOLIDAY 36 +#define BG_AV_EVENT_START_BATTLE 9166 + enum BG_AV_Sounds { BG_AV_SOUND_NEAR_LOSE = 8456, // not confirmed yet diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index aea2240e0..54abb2a28 100644 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -109,6 +109,9 @@ void BattleGroundEY::StartingEventOpenDoors() uint8 buff = urand(0, 2); SpawnBGObject(m_BgObjects[BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + buff + i * 3], RESPAWN_IMMEDIATELY); } + + // Players that join battleground after start are not eligible to get achievement. + StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_EY_EVENT_START_BATTLE); } void BattleGroundEY::AddPoints(Team team, uint32 Points) diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h index b9fce80e4..22e2f467b 100644 --- a/src/game/BattleGroundEY.h +++ b/src/game/BattleGroundEY.h @@ -154,6 +154,7 @@ enum EYBattleGroundObjectTypes #define BG_EY_NotEYWeekendHonorTicks 330 #define BG_EY_EYWeekendHonorTicks 200 +#define BG_EY_EVENT_START_BATTLE 13180 enum BG_EY_Score { diff --git a/src/game/BattleGroundSA.h b/src/game/BattleGroundSA.h index 18db802ac..4a5d0962d 100644 --- a/src/game/BattleGroundSA.h +++ b/src/game/BattleGroundSA.h @@ -21,6 +21,9 @@ class BattleGround; +#define BG_SA_EVENT_START_BATTLE_1 23748 // Ally / Horde likely +#define BG_SA_EVENT_START_BATTLE_2 21702 + class BattleGroundSAScore : public BattleGroundScore { public: diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index 47e842b99..4fc3527cf 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -127,6 +127,9 @@ void BattleGroundWS::StartingEventOpenDoors() SpawnEvent(WS_EVENT_SPIRITGUIDES_SPAWN, 0, true); SpawnEvent(WS_EVENT_FLAG_A, 0, true); SpawnEvent(WS_EVENT_FLAG_H, 0, true); + + // Players that join battleground after start are not eligible to get achievement. + StartTimedAchievement(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_WS_EVENT_START_BATTLE); } void BattleGroundWS::AddPlayer(Player *plr) diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h index 43a5d17d9..cfc76a51c 100644 --- a/src/game/BattleGroundWS.h +++ b/src/game/BattleGroundWS.h @@ -25,6 +25,7 @@ #define BG_WS_FLAG_RESPAWN_TIME (23*IN_MILLISECONDS) #define BG_WS_FLAG_DROP_TIME (10*IN_MILLISECONDS) #define BG_WS_TIME_LIMIT (25*MINUTE*IN_MILLISECONDS) +#define BG_WS_EVENT_START_BATTLE 8563 enum BG_WS_Sound { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4570f7194..951350512 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11793" + #define REVISION_NR "11794" #endif // __REVISION_NR_H__