mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-21 07:11:59 -04:00
merge
--HG-- branch : trunk
This commit is contained in:
@@ -4660,6 +4660,28 @@ LOCK TABLES `reference_loot_template` WRITE;
|
||||
/*!40000 ALTER TABLE `reference_loot_template` ENABLE KEYS */;
|
||||
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`
|
||||
--
|
||||
|
||||
@@ -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;
|
||||
@@ -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 },
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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...");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user