[7432] Fixed BattleGround's bonus_honor based on player level and reputation rewards. Implement functions for BattleGroundWeekends. Patch originally provided by Balrok. Thx

Correctly assigned some comments.

Signed-off-by: Triply <triply@getmangos.com>
This commit is contained in:
balrok 2009-03-09 22:27:35 +01:00 committed by Triply
parent 82e0e0b027
commit aebcf212dc
9 changed files with 116 additions and 35 deletions

View file

@ -30,6 +30,7 @@
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "WorldPacket.h" #include "WorldPacket.h"
#include "Util.h" #include "Util.h"
#include "Formulas.h"
#include "GridNotifiersImpl.h" #include "GridNotifiersImpl.h"
namespace MaNGOS namespace MaNGOS
@ -314,7 +315,13 @@ void BattleGround::Update(uint32 diff)
else if(m_PrematureCountDownTimer < diff) else if(m_PrematureCountDownTimer < diff)
{ {
// time's up! // time's up!
EndBattleGround(0); // noone wins uint32 winner = 0;
if( GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam() )
winner = ALLIANCE;
else if( GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam() )
winner = HORDE;
EndBattleGround(winner);
m_PrematureCountDown = false; m_PrematureCountDown = false;
} }
else else
@ -693,7 +700,6 @@ void BattleGround::EndBattleGround(uint32 winner)
if(team == winner) if(team == winner)
{ {
RewardMark(plr,ITEM_WINNER_COUNT); RewardMark(plr,ITEM_WINNER_COUNT);
UpdatePlayerScore(plr, SCORE_BONUS_HONOR, 20);
RewardQuest(plr); RewardQuest(plr);
} }
else else
@ -735,6 +741,12 @@ void BattleGround::EndBattleGround(uint32 winner)
SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL); SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL);
} }
uint32 BattleGround::GetBonusHonorFromKill(uint32 kills) const
{
//variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
return MaNGOS::Honor::hk_honor_at_level(GetMaxLevel(), kills);
}
uint32 BattleGround::GetBattlemasterEntry() const uint32 BattleGround::GetBattlemasterEntry() const
{ {
switch(GetTypeID()) switch(GetTypeID())

View file

@ -93,7 +93,6 @@ enum BattleGroundTimeIntervals
RESPAWN_ONE_DAY = 86400, // secs RESPAWN_ONE_DAY = 86400, // secs
RESPAWN_IMMEDIATELY = 0, // secs RESPAWN_IMMEDIATELY = 0, // secs
BUFF_RESPAWN_TIME = 180, // secs BUFF_RESPAWN_TIME = 180, // secs
BG_HONOR_SCORE_TICKS = 330 // points
}; };
enum BattleGroundStartTimeIntervals enum BattleGroundStartTimeIntervals
@ -315,6 +314,7 @@ class BattleGround
uint8 GetArenaType() const { return m_ArenaType; } uint8 GetArenaType() const { return m_ArenaType; }
uint8 GetWinner() const { return m_Winner; } uint8 GetWinner() const { return m_Winner; }
uint32 GetBattlemasterEntry() const; uint32 GetBattlemasterEntry() const;
uint32 GetBonusHonorFromKill(uint32 kills) const;
// Set methods: // Set methods:
void SetName(char const* Name) { m_Name = Name; } void SetName(char const* Name) { m_Name = Name; }

View file

@ -117,15 +117,15 @@ void BattleGroundAB::Update(uint32 diff)
m_TeamScores[team] += BG_AB_TickPoints[points]; m_TeamScores[team] += BG_AB_TickPoints[points];
m_HonorScoreTics[team] += BG_AB_TickPoints[points]; m_HonorScoreTics[team] += BG_AB_TickPoints[points];
m_ReputationScoreTics[team] += BG_AB_TickPoints[points]; m_ReputationScoreTics[team] += BG_AB_TickPoints[points];
if( m_ReputationScoreTics[team] >= 200 ) if( m_ReputationScoreTics[team] >= m_ReputationTics )
{ {
(team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE); (team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
m_ReputationScoreTics[team] -= 200; m_ReputationScoreTics[team] -= m_ReputationTics;
} }
if( m_HonorScoreTics[team] >= BG_HONOR_SCORE_TICKS ) if( m_HonorScoreTics[team] >= m_HonorTics )
{ {
(team == BG_TEAM_ALLIANCE) ? RewardHonorToTeam(20, ALLIANCE) : RewardHonorToTeam(20, HORDE); RewardHonorToTeam(GetBonusHonorFromKill(1), (team == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE);
m_HonorScoreTics[team] -= BG_HONOR_SCORE_TICKS; m_HonorScoreTics[team] -= m_HonorTics;
} }
if( !m_IsInformedNearVictory && m_TeamScores[team] > 1800 ) if( !m_IsInformedNearVictory && m_TeamScores[team] > 1800 )
{ {
@ -573,6 +573,10 @@ void BattleGroundAB::Reset()
m_ReputationScoreTics[BG_TEAM_ALLIANCE] = 0; m_ReputationScoreTics[BG_TEAM_ALLIANCE] = 0;
m_ReputationScoreTics[BG_TEAM_HORDE] = 0; m_ReputationScoreTics[BG_TEAM_HORDE] = 0;
m_IsInformedNearVictory = false; m_IsInformedNearVictory = false;
bool isBGWeekend = false; //TODO FIXME - call sBattleGroundMgr.IsBGWeekend(m_TypeID); - you must also implement that call!
m_HonorTics = (isBGWeekend) ? BG_AB_ABBGWeekendHonorTicks : BG_AB_NotABBGWeekendHonorTicks;
m_ReputationTics = (isBGWeekend) ? BG_AB_ABBGWeekendReputationTicks : BG_AB_NotABBGWeekendReputationTicks;
for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i) for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
{ {
m_Nodes[i] = 0; m_Nodes[i] = 0;
@ -586,6 +590,20 @@ void BattleGroundAB::Reset()
DelCreature(i); DelCreature(i);
} }
void BattleGroundAB::EndBattleGround(uint32 winner)
{
//win reward
if( winner == ALLIANCE )
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
if( winner == HORDE )
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
//complete map_end rewards (even if no team wins)
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
BattleGround::EndBattleGround(winner);
}
WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player)
{ {
uint8 teamIndex = GetTeamIndexByTeamId(player->GetTeam()); uint8 teamIndex = GetTeamIndexByTeamId(player->GetTeam());

View file

@ -170,6 +170,11 @@ enum BG_AB_Sounds
SOUND_NEAR_VICTORY = 8456 SOUND_NEAR_VICTORY = 8456
}; };
#define BG_AB_NotABBGWeekendHonorTicks 330
#define BG_AB_ABBGWeekendHonorTicks 200
#define BG_AB_NotABBGWeekendReputationTicks 200
#define BG_AB_ABBGWeekendReputationTicks 150
// x, y, z, o // x, y, z, o
const float BG_AB_NodePositions[BG_AB_DYNAMIC_NODES_COUNT][4] = { const float BG_AB_NodePositions[BG_AB_DYNAMIC_NODES_COUNT][4] = {
{1166.785f, 1200.132f, -56.70859f, 0.9075713f}, // stables {1166.785f, 1200.132f, -56.70859f, 0.9075713f}, // stables
@ -244,6 +249,7 @@ class BattleGroundAB : public BattleGround
void HandleAreaTrigger(Player *Source, uint32 Trigger); void HandleAreaTrigger(Player *Source, uint32 Trigger);
virtual bool SetupBattleGround(); virtual bool SetupBattleGround();
virtual void Reset(); virtual void Reset();
void EndBattleGround(uint32 winner);
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
/* Scorekeeping */ /* Scorekeeping */
@ -282,5 +288,9 @@ class BattleGroundAB : public BattleGround
uint32 m_HonorScoreTics[2]; uint32 m_HonorScoreTics[2];
uint32 m_ReputationScoreTics[2]; uint32 m_ReputationScoreTics[2];
bool m_IsInformedNearVictory; bool m_IsInformedNearVictory;
uint32 m_HonorTics;
uint32 m_ReputationTics;
}; };
#endif #endif

View file

@ -121,10 +121,10 @@ void BattleGroundEY::AddPoints(uint32 Team, uint32 Points)
uint8 team_index = GetTeamIndexByTeamId(Team); uint8 team_index = GetTeamIndexByTeamId(Team);
m_TeamScores[team_index] += Points; m_TeamScores[team_index] += Points;
m_HonorScoreTics[team_index] += Points; m_HonorScoreTics[team_index] += Points;
if (m_HonorScoreTics[team_index] >= BG_HONOR_SCORE_TICKS) if (m_HonorScoreTics[team_index] >= m_HonorTics )
{ {
RewardHonorToTeam(20, Team); RewardHonorToTeam(GetBonusHonorFromKill(1), Team);
m_HonorScoreTics[team_index] -= BG_HONOR_SCORE_TICKS; m_HonorScoreTics[team_index] -= m_HonorTics;
} }
UpdateTeamScore(Team); UpdateTeamScore(Team);
} }
@ -270,6 +270,20 @@ void BattleGroundEY::UpdateTeamScore(uint32 Team)
UpdateWorldState(EY_HORDE_RESOURCES, score); UpdateWorldState(EY_HORDE_RESOURCES, score);
} }
void BattleGroundEY::EndBattleGround(uint32 winner)
{
//win reward
if( winner == ALLIANCE )
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
if( winner == HORDE )
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
//complete map reward
RewardHonorToTeam(GetBonusHonorFromKill(1), ALLIANCE);
RewardHonorToTeam(GetBonusHonorFromKill(1), HORDE);
BattleGround::EndBattleGround(winner);
}
void BattleGroundEY::UpdatePointsCount(uint32 Team) void BattleGroundEY::UpdatePointsCount(uint32 Team)
{ {
if(Team == ALLIANCE) if(Team == ALLIANCE)
@ -494,6 +508,8 @@ void BattleGroundEY::Reset()
m_DroppedFlagGUID = 0; m_DroppedFlagGUID = 0;
m_PointAddingTimer = 0; m_PointAddingTimer = 0;
m_TowerCapCheckTimer = 0; m_TowerCapCheckTimer = 0;
bool isBGWeekend = false; //TODO FIXME - call sBattleGroundMgr.IsBGWeekend(m_TypeID); - you must also implement that call!
uint32 m_HonorTics = (isBGWeekend) ? BG_EY_EYWeekendHonorTicks : BG_EY_NotEYWeekendHonorTicks;
for(uint8 i = 0; i < EY_POINTS_MAX; ++i) for(uint8 i = 0; i < EY_POINTS_MAX; ++i)
{ {

View file

@ -210,6 +210,9 @@ enum EYBattleGroundObjectTypes
BG_EY_OBJECT_MAX = 59 BG_EY_OBJECT_MAX = 59
}; };
#define BG_EY_NotEYWeekendHonorTicks 330
#define BG_EY_EYWeekendHonorTicks 200
enum BG_EY_FlagState enum BG_EY_FlagState
{ {
BG_EY_FLAG_STATE_ON_BASE = 0, BG_EY_FLAG_STATE_ON_BASE = 0,
@ -321,6 +324,7 @@ class BattleGroundEY : public BattleGround
virtual bool SetupBattleGround(); virtual bool SetupBattleGround();
virtual void Reset(); virtual void Reset();
void UpdateTeamScore(uint32 Team); void UpdateTeamScore(uint32 Team);
void EndBattleGround(uint32 winner);
void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
virtual void FillInitialWorldStates(WorldPacket& data); virtual void FillInitialWorldStates(WorldPacket& data);
void SetDroppedFlagGUID(uint64 guid) { m_DroppedFlagGUID = guid;} void SetDroppedFlagGUID(uint64 guid) { m_DroppedFlagGUID = guid;}
@ -370,5 +374,6 @@ class BattleGroundEY : public BattleGround
uint8 m_CurrentPointPlayersCount[2*EY_POINTS_MAX]; uint8 m_CurrentPointPlayersCount[2*EY_POINTS_MAX];
int32 m_PointAddingTimer; int32 m_PointAddingTimer;
uint32 m_HonorTics;
}; };
#endif #endif

View file

@ -184,8 +184,6 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
uint32 winner = 0; uint32 winner = 0;
//TODO FIX reputation and honor gains for low level players!
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if(Source->GetTeam() == ALLIANCE) if(Source->GetTeam() == ALLIANCE)
{ {
@ -199,8 +197,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
if(GetTeamScore(ALLIANCE) < BG_WS_MAX_TEAM_SCORE) if(GetTeamScore(ALLIANCE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(ALLIANCE, 1); AddPoint(ALLIANCE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE); PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
RewardReputationToTeam(890, 35, ALLIANCE); // +35 reputation RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE);
RewardHonorToTeam(40, ALLIANCE); // +40 bonushonor
} }
else else
{ {
@ -214,9 +211,10 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
if(GetTeamScore(HORDE) < BG_WS_MAX_TEAM_SCORE) if(GetTeamScore(HORDE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(HORDE, 1); AddPoint(HORDE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE); PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
RewardReputationToTeam(889, 35, HORDE); // +35 reputation RewardReputationToTeam(889, m_ReputationCapture, HORDE);
RewardHonorToTeam(40, HORDE); // +40 bonushonor
} }
//for flag capture is reward 2 honorable kills
RewardHonorToTeam(GetBonusHonorFromKill(2), Source->GetTeam());
SpawnBGObject(BG_WS_OBJECT_H_FLAG, BG_WS_FLAG_RESPAWN_TIME); SpawnBGObject(BG_WS_OBJECT_H_FLAG, BG_WS_FLAG_RESPAWN_TIME);
SpawnBGObject(BG_WS_OBJECT_A_FLAG, BG_WS_FLAG_RESPAWN_TIME); SpawnBGObject(BG_WS_OBJECT_A_FLAG, BG_WS_FLAG_RESPAWN_TIME);
@ -229,7 +227,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
UpdateFlagState(Source->GetTeam(), 1); // flag state none UpdateFlagState(Source->GetTeam(), 1); // flag state none
UpdateTeamScore(Source->GetTeam()); UpdateTeamScore(Source->GetTeam());
// only flag capture should be updated // only flag capture should be updated
UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1); // +1 flag captures... UpdatePlayerScore(Source, SCORE_FLAG_CAPTURES, 1); // +1 flag captures
if(GetTeamScore(ALLIANCE) == BG_WS_MAX_TEAM_SCORE) if(GetTeamScore(ALLIANCE) == BG_WS_MAX_TEAM_SCORE)
winner = ALLIANCE; winner = ALLIANCE;
@ -593,16 +591,33 @@ void BattleGroundWS::Reset()
m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE; m_FlagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
m_TeamScores[BG_TEAM_ALLIANCE] = 0; m_TeamScores[BG_TEAM_ALLIANCE] = 0;
m_TeamScores[BG_TEAM_HORDE] = 0; m_TeamScores[BG_TEAM_HORDE] = 0;
bool isBGWeekend = false; //TODO FIXME - call sBattleGroundMgr.IsBGWeekend(m_TypeID); - you must also implement that call!
m_ReputationCapture = (isBGWeekend) ? 45 : 35;
m_HonorWinKills = (isBGWeekend) ? 3 : 1;
m_HonorEndKills = (isBGWeekend) ? 4 : 2;
/* Spirit nodes is static at this BG and then not required deleting at BG reset. /* Spirit nodes is static at this BG and then not required deleting at BG reset.
if(m_BgCreatures[WS_SPIRIT_MAIN_ALLIANCE]) if(m_BgCreatures[WS_SPIRIT_MAIN_ALLIANCE])
DelCreature(WS_SPIRIT_MAIN_ALLIANCE); DelCreature(WS_SPIRIT_MAIN_ALLIANCE);
if(m_BgCreatures[WS_SPIRIT_MAIN_HORDE]) if(m_BgCreatures[WS_SPIRIT_MAIN_HORDE])
DelCreature(WS_SPIRIT_MAIN_HORDE); DelCreature(WS_SPIRIT_MAIN_HORDE);
*/ */
} }
void BattleGroundWS::EndBattleGround(uint32 winner)
{
//win reward
if( winner == ALLIANCE )
RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills), ALLIANCE);
if( winner == HORDE )
RewardHonorToTeam(GetBonusHonorFromKill(m_HonorWinKills), HORDE);
//complete map_end rewards (even if no team wins)
RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), ALLIANCE);
RewardHonorToTeam(GetBonusHonorFromKill(m_HonorEndKills), HORDE);
BattleGround::EndBattleGround(winner);
}
void BattleGroundWS::HandleKillPlayer(Player *player, Player *killer) void BattleGroundWS::HandleKillPlayer(Player *player, Player *killer)
{ {
if(GetStatus() != STATUS_IN_PROGRESS) if(GetStatus() != STATUS_IN_PROGRESS)

View file

@ -164,6 +164,7 @@ class BattleGroundWS : public BattleGround
void HandleKillPlayer(Player *player, Player *killer); void HandleKillPlayer(Player *player, Player *killer);
bool SetupBattleGround(); bool SetupBattleGround();
virtual void Reset(); virtual void Reset();
void EndBattleGround(uint32 winner);
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
void UpdateFlagState(uint32 team, uint32 value); void UpdateFlagState(uint32 team, uint32 value);
@ -186,5 +187,9 @@ class BattleGroundWS : public BattleGround
uint32 m_TeamScores[2]; uint32 m_TeamScores[2];
int32 m_FlagsTimer[2]; int32 m_FlagsTimer[2];
int32 m_FlagsDropTimer[2]; int32 m_FlagsDropTimer[2];
uint32 m_ReputationCapture;
uint32 m_HonorWinKills;
uint32 m_HonorEndKills;
}; };
#endif #endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7431" #define REVISION_NR "7432"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__