Backed out changeset f751065ec933
Spell rep rate was already implemented by QAston --HG-- branch : trunk
This commit is contained in:
@@ -6477,61 +6477,34 @@ ReputationRank Player::GetReputationRank(uint32 faction) const
|
||||
return GetReputationMgr().GetRank(factionEntry);
|
||||
}
|
||||
|
||||
// Calculate total reputation percent player gain with quest/creature level
|
||||
int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 faction, uint32 creatureOrQuestLevel, bool noAuraBonus)
|
||||
//Calculate total reputation percent player gain with quest/creature level
|
||||
int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, int32 faction, bool for_quest, bool noQuestBonus)
|
||||
{
|
||||
float percent = 100.0f;
|
||||
|
||||
float repMod = noAuraBonus ? 0.0f : (float)GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
|
||||
|
||||
// faction specific auras only seem to apply to kills
|
||||
if (source == REPUTATION_SOURCE_KILL)
|
||||
repMod += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, faction);
|
||||
|
||||
percent += rep > 0 ? repMod : -repMod;
|
||||
|
||||
float rate = 1.0f;
|
||||
switch (source)
|
||||
// Get the generic rate first
|
||||
if (RepRewardRate const * repData = sObjectMgr.GetRepRewardRate(faction))
|
||||
{
|
||||
case REPUTATION_SOURCE_KILL:
|
||||
rate = sWorld.getConfig(RATE_REPUTATION_LOWLEVEL_KILL);
|
||||
break;
|
||||
case REPUTATION_SOURCE_QUEST:
|
||||
rate = sWorld.getConfig(RATE_REPUTATION_LOWLEVEL_QUEST);
|
||||
break;
|
||||
float repRate = for_quest ? repData->quest_rate : repData->creature_rate;
|
||||
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 = noQuestBonus ? 0.0f : (float)GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
|
||||
|
||||
if (!for_quest)
|
||||
repMod += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, faction);
|
||||
|
||||
percent += rep > 0 ? repMod : -repMod;
|
||||
|
||||
if (percent <= 0.0f)
|
||||
return 0;
|
||||
|
||||
// Multiply result with the faction specific rate
|
||||
if (const RepRewardRate *repData = sObjectMgr.GetRepRewardRate(faction))
|
||||
{
|
||||
float repRate = 0.0f;
|
||||
switch (source)
|
||||
{
|
||||
case REPUTATION_SOURCE_KILL:
|
||||
repRate = repData->creature_rate;
|
||||
break;
|
||||
case REPUTATION_SOURCE_QUEST:
|
||||
repRate = repData->quest_rate;
|
||||
break;
|
||||
case REPUTATION_SOURCE_SPELL:
|
||||
repRate = repData->spell_rate;
|
||||
break;
|
||||
}
|
||||
|
||||
// for custom, a rate of 0.0 will totally disable reputation gain for this faction/type
|
||||
if (repRate <= 0.0f)
|
||||
return 0;
|
||||
|
||||
percent *= repRate;
|
||||
}
|
||||
|
||||
return int32(sWorld.getConfig(RATE_REPUTATION_GAIN) * rep * percent / 100.0f);
|
||||
return int32(rep*percent/100);
|
||||
}
|
||||
|
||||
//Calculates how many reputation points player gains in victim's enemy factions
|
||||
@@ -6583,7 +6556,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
||||
|
||||
if (Rep->repfaction1 && (!Rep->team_dependent || team == ALLIANCE))
|
||||
{
|
||||
int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue1, Rep->repfaction1, pVictim->getLevel());
|
||||
int32 donerep1 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue1, ChampioningFaction ? ChampioningFaction : Rep->repfaction1, false);
|
||||
donerep1 = int32(donerep1*(rate + favored_rep_mult));
|
||||
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->repfaction1);
|
||||
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
|
||||
@@ -6601,7 +6574,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
||||
|
||||
if (Rep->repfaction2 && (!Rep->team_dependent || team == HORDE))
|
||||
{
|
||||
int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue2, Rep->repfaction2, pVictim->getLevel());
|
||||
int32 donerep2 = CalculateReputationGain(pVictim->getLevel(), Rep->repvalue2, ChampioningFaction ? ChampioningFaction : Rep->repfaction2, false);
|
||||
donerep2 = int32(donerep2*(rate + favored_rep_mult));
|
||||
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->repfaction2);
|
||||
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
|
||||
@@ -6628,7 +6601,7 @@ void Player::RewardReputation(Quest const *pQuest)
|
||||
continue;
|
||||
if (pQuest->RewRepValue[i])
|
||||
{
|
||||
int32 rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, pQuest->RewRepValue[i] / 100, pQuest->RewRepFaction[i], GetQuestLevel(pQuest), 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);
|
||||
}
|
||||
@@ -6639,13 +6612,13 @@ void Player::RewardReputation(Quest const *pQuest)
|
||||
|
||||
if (const QuestFactionRewEntry *pRow = sQuestFactionRewardStore.LookupEntry(row))
|
||||
{
|
||||
int32 repPoints = pRow->QuestRewFactionValue[field];
|
||||
int32 repPoints = pRow->QuestRewFactionValue[field];
|
||||
|
||||
if (!repPoints)
|
||||
continue;
|
||||
if (!repPoints)
|
||||
continue;
|
||||
|
||||
repPoints = CalculateReputationGain(REPUTATION_SOURCE_QUEST, repPoints, pQuest->RewRepFaction[i], GetQuestLevel(pQuest));
|
||||
if (const FactionEntry* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]))
|
||||
repPoints = CalculateReputationGain(GetQuestLevel(pQuest), repPoints, pQuest->RewRepFaction[i], true);
|
||||
if (const FactionEntry* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]))
|
||||
GetReputationMgr().ModifyReputation(factionEntry, repPoints);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,13 +800,6 @@ enum PlayerDelayedOperations
|
||||
DELAYED_END
|
||||
};
|
||||
|
||||
enum ReputationSource
|
||||
{
|
||||
REPUTATION_SOURCE_KILL,
|
||||
REPUTATION_SOURCE_QUEST,
|
||||
REPUTATION_SOURCE_SPELL
|
||||
};
|
||||
|
||||
// Player summoning auto-decline time (in secs)
|
||||
#define MAX_PLAYER_SUMMON_DELAY (2*MINUTE)
|
||||
#define MAX_MONEY_AMOUNT (0x7FFFFFFF-1)
|
||||
@@ -1930,7 +1923,6 @@ class Player : public Unit, public GridObject<Player>
|
||||
ReputationRank GetReputationRank(uint32 faction_id) const;
|
||||
void RewardReputation(Unit *pVictim, float rate);
|
||||
void RewardReputation(Quest const *pQuest);
|
||||
int32 CalculateReputationGain(ReputationSource source, int32 rep, int32 faction, uint32 creatureOrQuestLevel = 0, bool noAuraBonus = false);
|
||||
|
||||
void UpdateSkillsForLevel();
|
||||
void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
|
||||
@@ -2605,6 +2597,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, bool noQuestBonus = false);
|
||||
void AdjustQuestReqItemCount(Quest const* pQuest, QuestStatusData& questStatusData);
|
||||
|
||||
bool IsCanDelayTeleport() const { return m_bCanDelayTeleport; }
|
||||
|
||||
@@ -6536,25 +6536,26 @@ void Spell::EffectLeap(uint32 i)
|
||||
|
||||
void Spell::EffectReputation(uint32 i)
|
||||
{
|
||||
if (!unitTarget)
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
if (Player *_player = unitTarget->ToPlayer())
|
||||
Player *_player = (Player*)unitTarget;
|
||||
|
||||
int32 rep_change = damage;//+1; // field store reputation change -1
|
||||
|
||||
uint32 faction_id = m_spellInfo->EffectMiscValue[i];
|
||||
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
|
||||
|
||||
if (!factionEntry)
|
||||
return;
|
||||
|
||||
if (RepRewardRate const * repData = sObjectMgr.GetRepRewardRate(faction_id))
|
||||
{
|
||||
int32 rep_change = damage;//+1; // field store reputation change -1
|
||||
uint32 faction_id = m_spellInfo->EffectMiscValue[i];
|
||||
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
|
||||
if (!factionEntry)
|
||||
return;
|
||||
|
||||
if (RepRewardRate const * repData = sObjectMgr.GetRepRewardRate(faction_id))
|
||||
rep_change = (float)rep_change * repData->spell_rate;
|
||||
|
||||
rep_change = _player->CalculateReputationGain(REPUTATION_SOURCE_SPELL, rep_change, faction_id);
|
||||
|
||||
_player->GetReputationMgr().ModifyReputation(factionEntry, rep_change);
|
||||
rep_change = (float)rep_change * repData->spell_rate;
|
||||
}
|
||||
|
||||
_player->GetReputationMgr().ModifyReputation(factionEntry, rep_change);
|
||||
}
|
||||
|
||||
void Spell::EffectQuestComplete(uint32 i)
|
||||
|
||||
Reference in New Issue
Block a user