mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
Core/Hooks: Add new Player hooks (#1481)
* Fix hook OnReputationChange * Add hook OnReputationRankChange * Add hook OnLearnSpell * Add hook OnForgotSpell
This commit is contained in:
committed by
Kargatum
parent
f68fef798d
commit
23d78ce6bc
@@ -4029,10 +4029,13 @@ void Player::learnSpell(uint32 spellId)
|
||||
uint32 firstRankSpellId = sSpellMgr->GetFirstSpellInChain(spellId);
|
||||
bool thisSpec = GetTalentSpellCost(firstRankSpellId) > 0 || sSpellMgr->IsAdditionalTalentSpell(firstRankSpellId);
|
||||
bool added = addSpell(spellId, thisSpec ? GetActiveSpecMask() : SPEC_MASK_ALL, true);
|
||||
if (added && IsInWorld())
|
||||
if (added)
|
||||
{
|
||||
sScriptMgr->OnPlayerLearnSpell(this, spellId);
|
||||
|
||||
// pussywizard: a system message "you have learnt spell X (rank Y)"
|
||||
SendLearnPacket(spellId, true);
|
||||
if (IsInWorld())
|
||||
SendLearnPacket(spellId, true);
|
||||
}
|
||||
|
||||
// pussywizard: rank stuff at the end!
|
||||
@@ -4196,7 +4199,10 @@ void Player::removeSpell(uint32 spellId, uint8 removeSpecMask, bool onlyTemporar
|
||||
|
||||
// pussywizard: remove from spell book (can't be replaced by previous rank, because such spells can't be unlearnt)
|
||||
if (!onlyTemporary || ((!spellInfo->HasAttribute(SpellAttr0(SPELL_ATTR0_PASSIVE | SPELL_ATTR0_HIDDEN_CLIENTSIDE)) || !spellInfo->HasAnyAura()) && !spellInfo->HasEffect(SPELL_EFFECT_LEARN_SPELL)))
|
||||
{
|
||||
sScriptMgr->OnPlayerForgotSpell(this, spellId);
|
||||
SendLearnPacket(spellId, false);
|
||||
}
|
||||
}
|
||||
|
||||
bool Player::Has310Flyer(bool checkAllSpells, uint32 excludeSpellId)
|
||||
|
||||
@@ -271,7 +271,6 @@ void ReputationMgr::Initialize()
|
||||
|
||||
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental, bool spillOverOnly)
|
||||
{
|
||||
sScriptMgr->OnPlayerReputationChange(_player, factionEntry->ID, standing, incremental);
|
||||
bool res = false;
|
||||
// if spillover definition exists in DB, override DBC
|
||||
if (const RepSpilloverTemplate* repTemplate = sObjectMgr->GetRepSpilloverTemplate(factionEntry->ID))
|
||||
@@ -376,6 +375,11 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in
|
||||
if (new_rank > old_rank)
|
||||
_sendFactionIncreased = true;
|
||||
|
||||
sScriptMgr->OnPlayerReputationChange(_player, factionEntry->ID, standing, incremental);
|
||||
|
||||
if (new_rank != old_rank)
|
||||
sScriptMgr->OnPlayerReputationRankChange(_player, factionEntry->ID, new_rank, old_rank, _sendFactionIncreased);
|
||||
|
||||
UpdateRankCounters(old_rank, new_rank);
|
||||
|
||||
_player->ReputationChanged(factionEntry);
|
||||
|
||||
@@ -1464,6 +1464,21 @@ void ScriptMgr::OnPlayerReputationChange(Player* player, uint32 factionID, int32
|
||||
FOREACH_SCRIPT(PlayerScript)->OnReputationChange(player, factionID, standing, incremental);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnReputationRankChange(player, factionID, newRank, oldRank, increased);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerLearnSpell(Player* player, uint32 spellID)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnLearnSpell(player, spellID);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerForgotSpell(Player* player, uint32 spellID)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnForgotSpell(player, spellID);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerDuelRequest(Player* target, Player* challenger)
|
||||
{
|
||||
#ifdef ELUNA
|
||||
|
||||
@@ -814,6 +814,15 @@ class PlayerScript : public ScriptObject
|
||||
// Called when a player's reputation changes (before it is actually changed)
|
||||
virtual void OnReputationChange(Player* /*player*/, uint32 /*factionId*/, int32& /*standing*/, bool /*incremental*/) { }
|
||||
|
||||
// Called when a player's reputation rank changes (before it is actually changed)
|
||||
virtual void OnReputationRankChange(Player* /*player*/, uint32 /*factionID*/, ReputationRank /*newRank*/, ReputationRank /*olRank*/, bool /*increased*/) { }
|
||||
|
||||
// Called when a player learned new spell
|
||||
virtual void OnLearnSpell(Player* /*player*/, uint32 /*spellID*/) {}
|
||||
|
||||
// Called when a player forgot spell
|
||||
virtual void OnForgotSpell(Player* /*player*/, uint32 /*spellID*/) {}
|
||||
|
||||
// Called when a duel is requested
|
||||
virtual void OnDuelRequest(Player* /*target*/, Player* /*challenger*/) { }
|
||||
|
||||
@@ -1319,6 +1328,9 @@ class ScriptMgr
|
||||
void OnPlayerMoneyChanged(Player* player, int32& amount);
|
||||
void OnGivePlayerXP(Player* player, uint32& amount, Unit* victim);
|
||||
void OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);
|
||||
void OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased);
|
||||
void OnPlayerLearnSpell(Player* player, uint32 spellID);
|
||||
void OnPlayerForgotSpell(Player* player, uint32 spellID);
|
||||
void OnPlayerDuelRequest(Player* target, Player* challenger);
|
||||
void OnPlayerDuelStart(Player* player1, Player* player2);
|
||||
void OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type);
|
||||
|
||||
Reference in New Issue
Block a user