mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
feat(Core/Scripting): Add OnPlayerGiveReputation script hook (#21869)
This commit is contained in:
@@ -6008,6 +6008,7 @@ void Player::RewardReputation(Unit* victim)
|
||||
if (Rep->RepFaction1 && (!Rep->TeamDependent || teamId == TEAM_ALLIANCE))
|
||||
{
|
||||
float donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->GetLevel(), static_cast<float>(Rep->RepValue1), ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
|
||||
sScriptMgr->OnPlayerGiveReputation(this, Rep->RepFaction1, donerep1, REPUTATION_SOURCE_KILL);
|
||||
|
||||
FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
|
||||
if (factionEntry1)
|
||||
@@ -6019,6 +6020,7 @@ void Player::RewardReputation(Unit* victim)
|
||||
if (Rep->RepFaction2 && (!Rep->TeamDependent || teamId == TEAM_HORDE))
|
||||
{
|
||||
float donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->GetLevel(), static_cast<float>(Rep->RepValue2), ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
|
||||
sScriptMgr->OnPlayerGiveReputation(this, Rep->RepFaction2, donerep2, REPUTATION_SOURCE_KILL);
|
||||
|
||||
FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
|
||||
if (factionEntry2)
|
||||
@@ -6058,22 +6060,27 @@ void Player::RewardReputation(Quest const* quest)
|
||||
if (quest->IsDaily())
|
||||
{
|
||||
rep = CalculateReputationGain(REPUTATION_SOURCE_DAILY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
|
||||
sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_DAILY_QUEST);
|
||||
}
|
||||
else if (quest->IsWeekly())
|
||||
{
|
||||
rep = CalculateReputationGain(REPUTATION_SOURCE_WEEKLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
|
||||
sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_WEEKLY_QUEST);
|
||||
}
|
||||
else if (quest->IsMonthly())
|
||||
{
|
||||
rep = CalculateReputationGain(REPUTATION_SOURCE_MONTHLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
|
||||
sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_MONTHLY_QUEST);
|
||||
}
|
||||
else if (quest->IsRepeatable())
|
||||
{
|
||||
rep = CalculateReputationGain(REPUTATION_SOURCE_REPEATABLE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
|
||||
sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_REPEATABLE_QUEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
|
||||
sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_QUEST);
|
||||
}
|
||||
|
||||
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]))
|
||||
|
||||
@@ -235,17 +235,6 @@ enum ActionButtonType
|
||||
ACTION_BUTTON_ITEM = 0x80
|
||||
};
|
||||
|
||||
enum ReputationSource
|
||||
{
|
||||
REPUTATION_SOURCE_KILL,
|
||||
REPUTATION_SOURCE_QUEST,
|
||||
REPUTATION_SOURCE_DAILY_QUEST,
|
||||
REPUTATION_SOURCE_WEEKLY_QUEST,
|
||||
REPUTATION_SOURCE_MONTHLY_QUEST,
|
||||
REPUTATION_SOURCE_REPEATABLE_QUEST,
|
||||
REPUTATION_SOURCE_SPELL
|
||||
};
|
||||
|
||||
enum QuestSound
|
||||
{
|
||||
QUEST_SOUND_FAILURE = 847
|
||||
|
||||
@@ -139,6 +139,11 @@ void ScriptMgr::OnPlayerReputationRankChange(Player* player, uint32 factionID, R
|
||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_REPUTATION_RANK_CHANGE, script->OnPlayerReputationRankChange(player, factionID, newRank, oldRank, increased));
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerGiveReputation(Player* player, int32 factionID, float& amount, ReputationSource repSource)
|
||||
{
|
||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GIVE_REPUTATION, script->OnPlayerGiveReputation(player, factionID, amount, repSource));
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerLearnSpell(Player* player, uint32 spellID)
|
||||
{
|
||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_LEARN_SPELL, script->OnPlayerLearnSpell(player, spellID));
|
||||
|
||||
@@ -210,6 +210,7 @@ enum PlayerHook
|
||||
PLAYERHOOK_CAN_RESURRECT,
|
||||
PLAYERHOOK_ON_CAN_GIVE_LEVEL,
|
||||
PLAYERHOOK_ON_SEND_LIST_INVENTORY,
|
||||
PLAYERHOOK_ON_GIVE_REPUTATION,
|
||||
PLAYERHOOK_END
|
||||
};
|
||||
|
||||
@@ -283,6 +284,9 @@ public:
|
||||
// Called when a player's reputation rank changes (before it is actually changed)
|
||||
virtual void OnPlayerReputationRankChange(Player* /*player*/, uint32 /*factionID*/, ReputationRank /*newRank*/, ReputationRank /*olRank*/, bool /*increased*/) { }
|
||||
|
||||
// Called when a player gains Reputation (before anything is given)
|
||||
virtual void OnPlayerGiveReputation(Player* /*player*/, int32 /*factionID*/, float& /*amount*/, ReputationSource /*repSource*/) { }
|
||||
|
||||
// Called when a player learned new spell
|
||||
virtual void OnPlayerLearnSpell(Player* /*player*/, uint32 /*spellID*/) {}
|
||||
|
||||
|
||||
@@ -313,6 +313,7 @@ public: /* PlayerScript */
|
||||
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* victim, uint8 xpSource);
|
||||
bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);
|
||||
void OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased);
|
||||
void OnPlayerGiveReputation(Player* player, int32 factionID, float& amount, ReputationSource repSource);
|
||||
void OnPlayerLearnSpell(Player* player, uint32 spellID);
|
||||
void OnPlayerForgotSpell(Player* player, uint32 spellID);
|
||||
void OnPlayerDuelRequest(Player* target, Player* challenger);
|
||||
|
||||
@@ -187,6 +187,17 @@ enum ReputationRank : uint8
|
||||
REP_EXALTED = 7
|
||||
};
|
||||
|
||||
enum ReputationSource
|
||||
{
|
||||
REPUTATION_SOURCE_KILL,
|
||||
REPUTATION_SOURCE_QUEST,
|
||||
REPUTATION_SOURCE_DAILY_QUEST,
|
||||
REPUTATION_SOURCE_WEEKLY_QUEST,
|
||||
REPUTATION_SOURCE_MONTHLY_QUEST,
|
||||
REPUTATION_SOURCE_REPEATABLE_QUEST,
|
||||
REPUTATION_SOURCE_SPELL
|
||||
};
|
||||
|
||||
enum FactionTemplates
|
||||
{
|
||||
FACTION_NONE = 0,
|
||||
|
||||
Reference in New Issue
Block a user