* Implement reputation reward rate for quest / creatures

* Need DB data for this to work
* Original patch by NoFantasy

--HG--
branch : trunk
This commit is contained in:
Brian
2010-07-26 16:21:10 -06:00
parent b69fa7ba25
commit 4565242e94
10 changed files with 149 additions and 4 deletions
+69
View File
@@ -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
+22
View File
@@ -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;