aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsilinoron <none@none>2010-07-26 15:40:40 -0700
committersilinoron <none@none>2010-07-26 15:40:40 -0700
commit3ea0f411d3be47f073232e7fc54e10f5c09de8d8 (patch)
tree0295c88663b21c40bba61b8d1655365f0a50c4ef
parent5977a76d96b03b533f44ad0baed523394e936d29 (diff)
parent4565242e946001f54103d1c2c7ebea0b7ef6437b (diff)
merge
--HG-- branch : trunk
-rw-r--r--sql/base/world_database.sql22
-rw-r--r--sql/updates/9036_world_reputation_reward_rate.sql8
-rw-r--r--src/server/game/Chat/Chat.cpp1
-rw-r--r--src/server/game/Chat/Chat.h1
-rw-r--r--src/server/game/Chat/Commands/Level3.cpp8
-rw-r--r--src/server/game/Entities/Player/Player.cpp17
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp69
-rw-r--r--src/server/game/Globals/ObjectMgr.h22
-rw-r--r--src/server/game/World/World.cpp3
10 files changed, 149 insertions, 4 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql
index 03ce3ba57f2..ebfcb2a0cfa 100644
--- a/sql/base/world_database.sql
+++ b/sql/base/world_database.sql
@@ -4661,6 +4661,28 @@ LOCK TABLES `reference_loot_template` WRITE;
UNLOCK TABLES;
--
+-- Table structure for table `reputation_reward_rate`
+--
+
+DROP TABLE IF EXISTS `reputation_reward_rate`;
+CREATE TABLE `reputation_reward_rate` (
+ `faction` mediumint(8) unsigned NOT NULL default '0',
+ `quest_rate` float NOT NULL default '1',
+ `creature_rate` float NOT NULL default '1',
+ `spell_rate` float NOT NULL default '1',
+ PRIMARY KEY (`faction`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `reputation_reward_rate`
+--
+
+LOCK TABLES `reputation_reward_rate` WRITE;
+/*!40000 ALTER TABLE `reputation_reward_rate` DISABLE KEYS */;
+/*!40000 ALTER TABLE `reputation_reward_rate` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
-- Table structure for table `reserved_name`
--
diff --git a/sql/updates/9036_world_reputation_reward_rate.sql b/sql/updates/9036_world_reputation_reward_rate.sql
new file mode 100644
index 00000000000..5a6d31b8e4d
--- /dev/null
+++ b/sql/updates/9036_world_reputation_reward_rate.sql
@@ -0,0 +1,8 @@
+DROP TABLE IF EXISTS `reputation_reward_rate`;
+CREATE TABLE `reputation_reward_rate` (
+ `faction` mediumint(8) unsigned NOT NULL default '0',
+ `quest_rate` float NOT NULL default '1',
+ `creature_rate` float NOT NULL default '1',
+ `spell_rate` float NOT NULL default '1',
+ PRIMARY KEY (`faction`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index d2f23434f2b..e1480c6d637 100644
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -515,6 +515,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "quest_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestTemplateCommand, "", NULL },
{ "reference_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", NULL },
{ "reserved_name", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadReservedNameCommand, "", NULL },
+ { "reputation_reward_rate", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadReputationRewardRateCommand, "", NULL },
{ "skill_discovery_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSkillDiscoveryTemplateCommand, "", NULL },
{ "skill_extra_item_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSkillExtraItemTemplateCommand, "", NULL },
{ "skill_fishing_base_level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSkillFishingBaseLevelCommand, "", NULL },
diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h
index 71bd82d29b0..bd12e454b56 100644
--- a/src/server/game/Chat/Chat.h
+++ b/src/server/game/Chat/Chat.h
@@ -416,6 +416,7 @@ class ChatHandler
bool HandleReloadQuestStartScriptsCommand(const char* args);
bool HandleReloadQuestTemplateCommand(const char* args);
bool HandleReloadReservedNameCommand(const char*);
+ bool HandleReloadReputationRewardRateCommand(const char* args);
bool HandleReloadSkillDiscoveryTemplateCommand(const char* args);
bool HandleReloadSkillExtraItemTemplateCommand(const char* args);
bool HandleReloadSkillFishingBaseLevelCommand(const char* args);
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index 049df5a342f..72e4dfb4cfd 100644
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -1152,6 +1152,14 @@ bool ChatHandler::HandleReloadReservedNameCommand(const char*)
return true;
}
+bool ChatHandler::HandleReloadReputationRewardRateCommand(const char*)
+{
+ sLog.outString( "Re-Loading `reputation_reward_rate` Table!" );
+ objmgr.LoadReputationRewardRate();
+ SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded.");
+ return true;
+}
+
bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/)
{
sLog.outString("Re-Loading Skill Discovery Table...");
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 44869b67b2f..c6cd332d5c7 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -6488,16 +6488,27 @@ ReputationRank Player::GetReputationRank(uint32 faction) const
}
//Calculate total reputation percent player gain with quest/creature level
-int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest)
+int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest, bool noQuestBonus)
{
float percent = 100.0f;
+ // Get the generic rate first
+ if (const RepRewardRate *repData = objmgr.GetRepRewardRate(faction))
+ {
+ float repRate = for_quest ? repData->quest_rate : repData->creature_rate;
+ percent *= repRate;
+
+ // for custom, a rate of 0.0 will totally disable reputation gain for this faction/type
+ if (repRate <= 0.0f)
+ percent = repRate;
+ }
+
float rate = for_quest ? sWorld.getRate(RATE_REPUTATION_LOWLEVEL_QUEST) : sWorld.getRate(RATE_REPUTATION_LOWLEVEL_KILL);
if (rate != 1.0f && creatureOrQuestLevel <= Trinity::XP::GetGrayLevel(getLevel()))
percent *= rate;
- float repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
+ float repMod = noQuestBonus ? 0.0f : (float)GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
if (!for_quest)
repMod += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, faction);
@@ -6606,7 +6617,7 @@ void Player::RewardReputation(Quest const *pQuest)
continue;
if (pQuest->RewRepValue[i])
{
- int32 rep = CalculateReputationGain(GetQuestLevel(pQuest), pQuest->RewRepValue[i]/100, pQuest->RewRepFaction[i], true);
+ int32 rep = CalculateReputationGain(GetQuestLevel(pQuest), pQuest->RewRepValue[i]/100, pQuest->RewRepFaction[i], true, true);
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]))
GetReputationMgr().ModifyReputation(factionEntry, rep);
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index d263547ed7d..cfe956320af 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -2598,7 +2598,7 @@ class Player : public Unit, public GridObject<Player>
void RefundItem(Item* item);
void UpdateKnownCurrencies(uint32 itemId, bool apply);
- int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest);
+ int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest, bool noQuestBonus = false);
void AdjustQuestReqItemCount(Quest const* pQuest, QuestStatusData& questStatusData);
bool IsCanDelayTeleport() const { return m_bCanDelayTeleport; }
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 31e6c0c0c72..2a51d2f3273 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -6741,6 +6741,75 @@ void ObjectMgr::LoadCorpses()
sLog.outString(">> Loaded %u corpses", count);
}
+void ObjectMgr::LoadReputationRewardRate()
+{
+ m_RepRewardRateMap.clear(); // for reload case
+
+ uint32 count = 0;
+ QueryResult_AutoPtr result = WorldDatabase.Query("SELECT faction, quest_rate, creature_rate, spell_rate FROM reputation_reward_rate");
+
+ if (!result)
+ {
+ barGoLink bar(1);
+
+ bar.step();
+
+ sLog.outString();
+ sLog.outErrorDb(">> Loaded `reputation_reward_rate`, table is empty!");
+ return;
+ }
+
+ barGoLink bar((int)result->GetRowCount());
+
+ do
+ {
+ bar.step();
+
+ Field *fields = result->Fetch();
+
+ uint32 factionId = fields[0].GetUInt32();
+
+ RepRewardRate repRate;
+
+ repRate.quest_rate = fields[1].GetFloat();
+ repRate.creature_rate = fields[2].GetFloat();
+ repRate.spell_rate = fields[3].GetFloat();
+
+ FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId);
+ if (!factionEntry)
+ {
+ sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_reward_rate`", factionId);
+ continue;
+ }
+
+ if (repRate.quest_rate < 0.0f)
+ {
+ sLog.outErrorDb("Table reputation_reward_rate has quest_rate with invalid rate %f, skipping data for faction %u", repRate.quest_rate, factionId);
+ continue;
+ }
+
+ if (repRate.creature_rate < 0.0f)
+ {
+ sLog.outErrorDb("Table reputation_reward_rate has creature_rate with invalid rate %f, skipping data for faction %u", repRate.creature_rate, factionId);
+ continue;
+ }
+
+ if (repRate.spell_rate < 0.0f)
+ {
+ sLog.outErrorDb("Table reputation_reward_rate has spell_rate with invalid rate %f, skipping data for faction %u", repRate.spell_rate, factionId);
+ continue;
+ }
+
+ m_RepRewardRateMap[factionId] = repRate;
+
+ ++count;
+ }
+ while (result->NextRow());
+
+ sLog.outString();
+ sLog.outString(">> Loaded %u reputation_reward_rate", count);
+}
+
void ObjectMgr::LoadReputationOnKill()
{
// For reload case
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index c99a58fe7fb..580034fe703 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -198,6 +198,14 @@ struct MailLevelReward
typedef std::list<MailLevelReward> MailLevelRewardList;
typedef UNORDERED_MAP<uint8,MailLevelRewardList> MailLevelRewardMap;
+// We assume the rate is in general the same for all three types below, but chose to keep three for scalability and customization
+struct RepRewardRate
+{
+ float quest_rate; // We allow rate = 0.0 in database. For this case, it means that
+ float creature_rate; // no reputation are given at all for this faction/rate type.
+ float spell_rate; // not implemented yet (SPELL_EFFECT_REPUTATION)
+};
+
struct ReputationOnKillEntry
{
uint32 repfaction1;
@@ -377,7 +385,9 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, AccessRequirement> AccessRequirementMap;
+ typedef UNORDERED_MAP<uint32, RepRewardRate > RepRewardRateMap;
typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
+
typedef UNORDERED_MAP<uint32, PointOfInterest> PointOfInterestMap;
typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap;
@@ -525,6 +535,15 @@ class ObjectMgr
uint32 GetAreaTriggerScriptId(uint32 trigger_id);
SpellScriptsBounds GetSpellScriptsBounds(uint32 spell_id);
+ RepRewardRate const* GetRepRewardRate(uint32 factionId) const
+ {
+ RepRewardRateMap::const_iterator itr = m_RepRewardRateMap.find(factionId);
+ if (itr != m_RepRewardRateMap.end())
+ return &itr->second;
+
+ return NULL;
+ }
+
ReputationOnKillEntry const* GetReputationOnKilEntry(uint32 id) const
{
RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
@@ -643,7 +662,9 @@ class ObjectMgr
void LoadCorpses();
void LoadFishingBaseSkillLevel();
+ void LoadReputationRewardRate();
void LoadReputationOnKill();
+
void LoadPointsOfInterest();
void LoadQuestPOI();
@@ -986,6 +1007,7 @@ class ObjectMgr
AreaTriggerScriptMap mAreaTriggerScripts;
AccessRequirementMap mAccessRequirements;
+ RepRewardRateMap m_RepRewardRateMap;
RepOnKillMap mRepOnKill;
GossipMenusMap m_mGossipMenusMap;
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 610a34ee5fe..2c082bbd4a6 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1382,6 +1382,9 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading Creature templates...");
objmgr.LoadCreatureTemplates();
+ sLog.outString("Loading Reputation Reward Rates...");
+ objmgr.LoadReputationRewardRate();
+
sLog.outString("Loading Creature Reputation OnKill Data...");
objmgr.LoadReputationOnKill();