[10252] Implement reputation_reward_rate for quests and creatures

* In addition, implement "flat" reputation for quests, where a value in RewRepValueN is given. Human diplomacy will not affect the total. The rate however will be applied, where a faction is defined with a rate for quests. Value in database are expected to be *100 of the actual value given (before rate are applied).
* New database storage can contain rates for quest/creature/spell reputation and will affect the base value given as reward. When for example the quest reward for a faction should receive 30% more reputation points, the rate can be set to 1.3.
* This will fix issues with certain quests that are using the expected RewRepValueId but where the outcome has been lower than expected.
* Note that if the rate is set to 0.0 it will disable reputation gain for the faction and type.
* Reputation rate for spells (spell effect) is not yet implemented

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-07-23 17:49:13 +02:00
parent 50c2e8eca2
commit 61990de6dd
13 changed files with 159 additions and 9 deletions

View file

@ -6427,6 +6427,77 @@ void ObjectMgr::LoadCorpses()
sLog.outString( ">> Loaded %u corpses", count );
}
void ObjectMgr::LoadReputationRewardRate()
{
m_RepRewardRateMap.clear(); // for reload case
uint32 count = 0;
QueryResult *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());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u reputation_reward_rate", count);
}
void ObjectMgr::LoadReputationOnKill()
{
uint32 count = 0;