aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw12x <none@none>2008-10-17 16:36:07 -0500
committerw12x <none@none>2008-10-17 16:36:07 -0500
commitab9eb277b4f001332ef2d0b623f72cfe176130d9 (patch)
treec39e35d77fd89997dc1091910746fd84899fa7a4
parent62409ac2a44b4af071aad765fd60e8281593aad7 (diff)
[svn] Enabled game events to change the honor and reputation gaining speed in battlegrounds. This is done by a new table in the world database, game_event_battleground_holiday. Structure is the following:
event - id of the game event bgflag - bitmask, used to set which battleground(s) give extra honor/reputation when the event is active. To add extra honor on a battleground, use 2 ^ bgTypeId as mask. Multiple battlegrounds can be set by logical 'or' ('|') operation. You will need database data for the table, please check trinitydatabase.org. --HG-- branch : trunk
-rw-r--r--sql/updates/54_world.sql5
-rw-r--r--src/game/BattleGround.cpp10
-rw-r--r--src/game/BattleGround.h12
-rw-r--r--src/game/BattleGroundAB.cpp19
-rw-r--r--src/game/BattleGroundEY.cpp10
-rw-r--r--src/game/BattleGroundMgr.cpp11
-rw-r--r--src/game/BattleGroundMgr.h2
-rw-r--r--src/game/BattleGroundWS.cpp28
-rw-r--r--src/game/GameEvent.cpp57
-rw-r--r--src/game/GameEvent.h3
10 files changed, 144 insertions, 13 deletions
diff --git a/sql/updates/54_world.sql b/sql/updates/54_world.sql
new file mode 100644
index 00000000000..f63e1f8134f
--- /dev/null
+++ b/sql/updates/54_world.sql
@@ -0,0 +1,5 @@
+CREATE TABLE `game_event_battleground_holiday` (
+ `event` int(10) unsigned NOT NULL,
+ `bgflag` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`event`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8; \ No newline at end of file
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 241082b8064..9ef8745fdf3 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -86,6 +86,7 @@ BattleGround::BattleGround()
m_PrematureCountDown = false;
m_PrematureCountDown = 0;
+ m_HonorMode = BG_NORMAL;
}
BattleGround::~BattleGround()
@@ -537,7 +538,6 @@ void BattleGround::EndBattleGround(uint32 winner)
if(!Source)
Source = plr;
RewardMark(plr,ITEM_WINNER_COUNT);
- UpdatePlayerScore(plr, SCORE_BONUS_HONOR, 20);
RewardQuest(plr);
}
else
@@ -1466,3 +1466,11 @@ uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const
}
return count;
}
+
+void BattleGround::SetHoliday(bool is_holiday)
+{
+ if(is_holiday)
+ m_HonorMode = BG_HOLIDAY;
+ else
+ m_HonorMode = BG_NORMAL;
+}
diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h
index a06042653f8..59d722e6222 100644
--- a/src/game/BattleGround.h
+++ b/src/game/BattleGround.h
@@ -95,8 +95,7 @@ enum BattleGroundTimeIntervals
START_DELAY3 = 15000, // ms used only in arena
RESPAWN_ONE_DAY = 86400, // secs
RESPAWN_IMMEDIATELY = 0, // secs
- BUFF_RESPAWN_TIME = 180, // secs
- BG_HONOR_SCORE_TICKS = 330 // points
+ BUFF_RESPAWN_TIME = 180 // secs
};
enum BattleGroundBuffObjects
@@ -239,6 +238,13 @@ class BattleGroundScore
uint32 HealingDone;
};
+enum BGHonorMode
+{
+ BG_NORMAL = 0,
+ BG_HOLIDAY,
+ BG_HONOR_MODE_NUM
+};
+
/*
This class is used to:
1. Add player to battleground
@@ -432,6 +438,7 @@ class BattleGround
// can be extended in in BG subclass
void HandleTriggerBuff(uint64 const& go_guid);
+ void SetHoliday(bool is_holiday);
// TODO: make this protected:
typedef std::vector<uint64> BGObjects;
@@ -479,6 +486,7 @@ class BattleGround
bool m_BuffChange;
+ BGHonorMode m_HonorMode;
private:
/* Battleground */
uint32 m_TypeID; //Battleground type, defined in enum BattleGroundTypeId
diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp
index 74d97a64695..ea40889f7b2 100644
--- a/src/game/BattleGroundAB.cpp
+++ b/src/game/BattleGroundAB.cpp
@@ -30,6 +30,17 @@
#include "World.h"
#include "Util.h"
+// these variables aren't used outside of this file, so declare them only here
+uint32 BG_AB_HonorScoreTicks[BG_HONOR_MODE_NUM] = {
+ 330, // normal honor
+ 200 // holiday
+};
+
+uint32 BG_AB_ReputationScoreTicks[BG_HONOR_MODE_NUM] = {
+ 200, // normal honor
+ 150 // holiday
+};
+
BattleGroundAB::BattleGroundAB()
{
m_BuffChange = true;
@@ -186,15 +197,15 @@ void BattleGroundAB::Update(time_t diff)
m_TeamScores[team] += BG_AB_TickPoints[points];
m_HonorScoreTics[team] += BG_AB_TickPoints[points];
m_ReputationScoreTics[team] += BG_AB_TickPoints[points];
- if( m_ReputationScoreTics[team] >= 200 )
+ if( m_ReputationScoreTics[team] >= BG_AB_ReputationScoreTicks[m_HonorMode] )
{
(team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
- m_ReputationScoreTics[team] -= 200;
+ m_ReputationScoreTics[team] -= BG_AB_ReputationScoreTicks[m_HonorMode];
}
- if( m_HonorScoreTics[team] >= BG_HONOR_SCORE_TICKS )
+ if( m_HonorScoreTics[team] >= BG_AB_HonorScoreTicks[m_HonorMode] )
{
(team == BG_TEAM_ALLIANCE) ? RewardHonorToTeam(20, ALLIANCE) : RewardHonorToTeam(20, HORDE);
- m_HonorScoreTics[team] -= BG_HONOR_SCORE_TICKS;
+ m_HonorScoreTics[team] -= BG_AB_HonorScoreTicks[m_HonorMode];
}
if( !m_IsInformedNearVictory && m_TeamScores[team] > 1800 )
{
diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp
index 003204306f4..c3c4727e8e8 100644
--- a/src/game/BattleGroundEY.cpp
+++ b/src/game/BattleGroundEY.cpp
@@ -30,6 +30,12 @@
#include "World.h"
#include "Util.h"
+// these variables aren't used outside of this file, so declare them only here
+uint32 BG_EY_HonorScoreTicks[BG_HONOR_MODE_NUM] = {
+ 330, // normal honor
+ 200 // holiday
+};
+
BattleGroundEY::BattleGroundEY()
{
m_BuffChange = true;
@@ -159,10 +165,10 @@ void BattleGroundEY::AddPoints(uint32 Team, uint32 Points)
uint8 team_index = GetTeamIndexByTeamId(Team);
m_TeamScores[team_index] += Points;
m_HonorScoreTics[team_index] += Points;
- if (m_HonorScoreTics[team_index] >= BG_HONOR_SCORE_TICKS)
+ if (m_HonorScoreTics[team_index] >= BG_EY_HonorScoreTicks[m_HonorMode])
{
RewardHonorToTeam(20, Team);
- m_HonorScoreTics[team_index] -= BG_HONOR_SCORE_TICKS;
+ m_HonorScoreTics[team_index] -= BG_EY_HonorScoreTicks[m_HonorMode];
}
UpdateTeamScore(Team);
}
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index 23f240721bb..4c6d94f6b10 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -1784,3 +1784,14 @@ void BattleGroundMgr::ToggleArenaTesting()
m_ArenaTesting = !m_ArenaTesting;
sWorld.SendWorldText(LANG_ARENA_TESTING, m_ArenaTesting ? "on" : "off");
}
+
+void BattleGroundMgr::SetHolidayWeekends(uint32 mask)
+{
+ for(uint32 bgtype = 1; bgtype <= 8; ++bgtype)
+ {
+ if(BattleGround * bg = GetBattleGroundTemplate(bgtype))
+ {
+ bg->SetHoliday(mask & (1 << bgtype));
+ }
+ }
+}
diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h
index 1f0b2affeb5..504b4da5f9c 100644
--- a/src/game/BattleGroundMgr.h
+++ b/src/game/BattleGroundMgr.h
@@ -234,6 +234,8 @@ class BattleGroundMgr
void ToggleArenaTesting();
const bool isArenaTesting() const { return m_ArenaTesting; }
+ void SetHolidayWeekends(uint32 mask);
+
private:
/* Battlegrounds */
diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp
index 12b778a5e47..bbfcf0f5596 100644
--- a/src/game/BattleGroundWS.cpp
+++ b/src/game/BattleGroundWS.cpp
@@ -29,6 +29,25 @@
#include "Language.h"
#include "World.h"
+// these variables aren't used outside of this file, so declare them only here
+enum BG_WSG_Rewards
+{
+ BG_WSG_WIN = 0,
+ BG_WSG_FLAG_CAP,
+ BG_WSG_MAP_COMPLETE,
+ BG_WSG_REWARD_NUM
+};
+
+uint32 BG_WSG_Honor[BG_HONOR_MODE_NUM][BG_WSG_REWARD_NUM] = {
+ {20,40,40}, // normal honor
+ {60,40,80} // holiday
+};
+
+uint32 BG_WSG_Reputation[BG_HONOR_MODE_NUM][BG_WSG_REWARD_NUM] = {
+ {0,35,0}, // normal honor
+ {0,45,0} // holiday
+};
+
BattleGroundWS::BattleGroundWS()
{
m_BgObjects.resize(BG_WS_OBJECT_MAX);
@@ -241,8 +260,8 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
if(GetTeamScore(ALLIANCE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(ALLIANCE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
- RewardReputationToTeam(890, 35, ALLIANCE); // +35 reputation
- RewardHonorToTeam(40, ALLIANCE); // +40 bonushonor
+ RewardReputationToTeam(890, BG_WSG_Reputation[m_HonorMode][BG_WSG_FLAG_CAP], ALLIANCE); // +35 reputation
+ RewardHonorToTeam(BG_WSG_Honor[m_HonorMode][BG_WSG_FLAG_CAP], ALLIANCE); // +40 bonushonor
}
else
{
@@ -258,8 +277,8 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
if(GetTeamScore(HORDE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(HORDE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
- RewardReputationToTeam(889, 35, HORDE); // +35 reputation
- RewardHonorToTeam(40, HORDE); // +40 bonushonor
+ RewardReputationToTeam(889, BG_WSG_Reputation[m_HonorMode][BG_WSG_FLAG_CAP], HORDE); // +35 reputation
+ RewardHonorToTeam(BG_WSG_Honor[m_HonorMode][BG_WSG_FLAG_CAP], HORDE); // +40 bonushonor
}
SpawnBGObject(BG_WS_OBJECT_H_FLAG, BG_WS_FLAG_RESPAWN_TIME);
@@ -287,6 +306,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, 1);
UpdateWorldState(BG_WS_FLAG_STATE_HORDE, 1);
+ RewardHonorToTeam(BG_WSG_Honor[m_HonorMode][BG_WSG_WIN], winner);
EndBattleGround(winner);
}
else
diff --git a/src/game/GameEvent.cpp b/src/game/GameEvent.cpp
index 9dd617d6462..2c77c641b0f 100644
--- a/src/game/GameEvent.cpp
+++ b/src/game/GameEvent.cpp
@@ -28,6 +28,7 @@
#include "Policies/SingletonImp.h"
#include "GossipDef.h"
#include "Player.h"
+#include "BattleGroundMgr.h"
INSTANTIATE_SINGLETON_1(GameEvent);
@@ -868,6 +869,50 @@ void GameEvent::LoadFromDB()
delete result;
}
+
+ // set all flags to 0
+ mGameEventBattleGroundHolidays.resize(mGameEvent.size(),0);
+ // load game event battleground flags
+ // 0 1
+ result = WorldDatabase.Query("SELECT event, bgflag FROM game_event_battleground_holiday");
+
+ count = 0;
+ if( !result )
+ {
+ barGoLink bar3(1);
+ bar3.step();
+
+ sLog.outString();
+ sLog.outString(">> Loaded %u battleground holidays in game events", count );
+ }
+ else
+ {
+
+ barGoLink bar3( result->GetRowCount() );
+ do
+ {
+ Field *fields = result->Fetch();
+
+ bar3.step();
+
+ uint16 event_id = fields[0].GetUInt16();
+
+ if(event_id >= mGameEvent.size())
+ {
+ sLog.outErrorDb("`game_event_battleground_holiday` game event id (%u) is out of range compared to max event id in `game_event`",event_id);
+ continue;
+ }
+
+ ++count;
+
+ mGameEventBattleGroundHolidays[event_id] = fields[1].GetUInt32();
+
+ } while( result->NextRow() );
+ sLog.outString();
+ sLog.outString( ">> Loaded %u battleground holidays in game events", count );
+
+ delete result;
+ }
}
uint32 GameEvent::GetNPCFlag(Creature * cr)
@@ -991,6 +1036,8 @@ void GameEvent::UnApplyEvent(uint16 event_id)
UpdateEventNPCFlags(event_id);
// remove vendor items
UpdateEventNPCVendor(event_id, false);
+ // update bg holiday
+ UpdateBattleGroundSettings();
}
void GameEvent::ApplyNewEvent(uint16 event_id)
@@ -1019,6 +1066,8 @@ void GameEvent::ApplyNewEvent(uint16 event_id)
UpdateEventNPCFlags(event_id);
// add vendor items
UpdateEventNPCVendor(event_id, true);
+ // update bg holiday
+ UpdateBattleGroundSettings();
}
void GameEvent::UpdateEventNPCFlags(uint16 event_id)
@@ -1047,6 +1096,14 @@ void GameEvent::UpdateEventNPCFlags(uint16 event_id)
}
}
+void GameEvent::UpdateBattleGroundSettings()
+{
+ uint32 mask = 0;
+ for(ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr )
+ mask |= mGameEventBattleGroundHolidays[*itr];
+ sBattleGroundMgr.SetHolidayWeekends(mask);
+}
+
void GameEvent::UpdateEventNPCVendor(uint16 event_id, bool activate)
{
for(NPCVendorList::iterator itr = mGameEventVendors[event_id].begin(); itr != mGameEventVendors[event_id].end(); ++itr)
diff --git a/src/game/GameEvent.h b/src/game/GameEvent.h
index c49c50ba6cb..875fb3d79fa 100644
--- a/src/game/GameEvent.h
+++ b/src/game/GameEvent.h
@@ -118,6 +118,7 @@ class GameEvent
void UpdateEventQuests(uint16 event_id, bool Activate);
void UpdateEventNPCFlags(uint16 event_id);
void UpdateEventNPCVendor(uint16 event_id, bool activate);
+ void UpdateBattleGroundSettings();
bool CheckOneGameEventConditions(uint16 event_id);
void SaveWorldEventStateToDB(uint16 event_id);
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
@@ -141,6 +142,7 @@ class GameEvent
typedef std::vector<NPCFlagList> GameEventNPCFlagMap;
typedef std::pair<uint16 /*event id*/, uint32 /*gossip id*/> EventNPCGossipIdPair;
typedef std::map<uint32 /*guid*/, EventNPCGossipIdPair> GuidEventNpcGossipIdMap;
+ typedef std::vector<uint32> GameEventBitmask;
GameEventQuestMap mGameEventCreatureQuests;
GameEventQuestMap mGameEventGameObjectQuests;
GameEventNPCVendorMap mGameEventVendors;
@@ -148,6 +150,7 @@ class GameEvent
GameEventGuidMap mGameEventCreatureGuids;
GameEventGuidMap mGameEventGameobjectGuids;
GameEventDataMap mGameEvent;
+ GameEventBitmask mGameEventBattleGroundHolidays;
QuestIdToEventConditionMap mQuestToEventConditions;
GameEventNPCFlagMap mGameEventNPCFlags;
GuidEventNpcGossipIdMap mNPCGossipIds;