mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[10270] Implement basic system for reputation spillover
* Database table needs data for each faction that should give spillover to other faction(s). One faction may give spillover to max 4 other spillover factions. * The spillover rate is multiplied with the points after bonuses and reward rate is set, Rate is given as: 0.5 for 50% gain, -1.0 for 100% loss, etc * It is possible to restrict spillover faction by rank. If player has a higher rank with the spillover faction given in database, no spillover will be given towards this faction Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
647acd8caa
commit
fb1e8c01ef
13 changed files with 269 additions and 13 deletions
|
|
@ -6576,6 +6576,126 @@ void ObjectMgr::LoadReputationOnKill()
|
|||
sLog.outString(">> Loaded %u creature award reputation definitions", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadReputationSpilloverTemplate()
|
||||
{
|
||||
m_RepSpilloverTemplateMap.clear(); // for reload case
|
||||
|
||||
uint32 count = 0;
|
||||
QueryResult *result = WorldDatabase.Query("SELECT faction, faction1, rate_1, rank_1, faction2, rate_2, rank_2, faction3, rate_3, rank_3, faction4, rate_4, rank_4 FROM reputation_spillover_template");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
barGoLink bar(1);
|
||||
|
||||
bar.step();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outErrorDb(">> Loaded `reputation_spillover_template`, table is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar((int)result->GetRowCount());
|
||||
|
||||
do
|
||||
{
|
||||
bar.step();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
uint32 factionId = fields[0].GetUInt32();
|
||||
|
||||
RepSpilloverTemplate repTemplate;
|
||||
|
||||
repTemplate.faction[0] = fields[1].GetUInt32();
|
||||
repTemplate.faction_rate[0] = fields[2].GetFloat();
|
||||
repTemplate.faction_rank[0] = fields[3].GetUInt32();
|
||||
repTemplate.faction[1] = fields[4].GetUInt32();
|
||||
repTemplate.faction_rate[1] = fields[5].GetFloat();
|
||||
repTemplate.faction_rank[1] = fields[6].GetUInt32();
|
||||
repTemplate.faction[2] = fields[7].GetUInt32();
|
||||
repTemplate.faction_rate[2] = fields[8].GetFloat();
|
||||
repTemplate.faction_rank[2] = fields[9].GetUInt32();
|
||||
repTemplate.faction[3] = fields[10].GetUInt32();
|
||||
repTemplate.faction_rate[3] = fields[11].GetFloat();
|
||||
repTemplate.faction_rank[3] = fields[12].GetUInt32();
|
||||
|
||||
FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId);
|
||||
|
||||
if (!factionEntry)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (factionEntry->team == 0)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u in `reputation_spillover_template` does not belong to any team, skipping", factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i)
|
||||
{
|
||||
if (repTemplate.faction[i])
|
||||
{
|
||||
FactionEntry const *factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]);
|
||||
|
||||
if (!factionSpillover)
|
||||
{
|
||||
sLog.outErrorDb("Spillover faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template` for faction %u, skipping", repTemplate.faction[i], factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (factionSpillover->reputationListID < 0)
|
||||
{
|
||||
sLog.outErrorDb("Spillover faction (faction.dbc) %u for faction %u in `reputation_spillover_template` can not be listed for client, and then useless, skipping", repTemplate.faction[i], factionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK)
|
||||
{
|
||||
sLog.outErrorDb("Rank %u used in `reputation_spillover_template` for spillover faction %u is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FactionEntry const *factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]);
|
||||
if (repTemplate.faction[0] && !factionEntry0)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]);
|
||||
continue;
|
||||
}
|
||||
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]);
|
||||
if (repTemplate.faction[1] && !factionEntry1)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]);
|
||||
continue;
|
||||
}
|
||||
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]);
|
||||
if (repTemplate.faction[2] && !factionEntry2)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]);
|
||||
continue;
|
||||
}
|
||||
FactionEntry const *factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]);
|
||||
if (repTemplate.faction[3] && !factionEntry3)
|
||||
{
|
||||
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_RepSpilloverTemplateMap[factionId] = repTemplate;
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
delete result;
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded %u reputation_spillover_template", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadPointsOfInterest()
|
||||
{
|
||||
mPointsOfInterest.clear(); // need for reload case
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue