feat(Core/Hooks): Added new hook for pvp flag state (#8336)

This commit is contained in:
Nefertumm
2021-10-11 14:40:27 -03:00
committed by GitHub
parent 0769212db5
commit bcec4191e4
4 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
### Added
- Added `OnPlayerPVPFlagChange` hook, it will be executed after the pvp flag from a player gets changed.

View File

@@ -1475,6 +1475,7 @@ void Player::UpdatePvP(bool state, bool _override)
}
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER);
sScriptMgr->OnPlayerPVPFlagChange(this, state);
}
void Player::UpdatePotionCooldown(Spell* spell)

View File

@@ -1366,6 +1366,11 @@ void ScriptMgr::OnPVPKill(Player* killer, Player* killed)
FOREACH_SCRIPT(PlayerScript)->OnPVPKill(killer, killed);
}
void ScriptMgr::OnPlayerPVPFlagChange(Player* player, bool state)
{
FOREACH_SCRIPT(PlayerScript)->OnPlayerPVPFlagChange(player, state);
}
void ScriptMgr::OnCreatureKill(Player* killer, Creature* killed)
{
#ifdef ELUNA

View File

@@ -729,6 +729,9 @@ public:
// Called when a player kills another player
virtual void OnPVPKill(Player* /*killer*/, Player* /*killed*/) { }
// Called when a player toggles pvp
virtual void OnPlayerPVPFlagChange(Player* /*player*/, bool /*state*/) { }
// Called when a player kills a creature
virtual void OnCreatureKill(Player* /*killer*/, Creature* /*killed*/) { }
@@ -1612,6 +1615,7 @@ public: /* PlayerScript */
void OnSendInitialPacketsBeforeAddToMap(Player* player, WorldPacket& data);
void OnPlayerReleasedGhost(Player* player);
void OnPVPKill(Player* killer, Player* killed);
void OnPlayerPVPFlagChange(Player* player, bool state);
void OnCreatureKill(Player* killer, Creature* killed);
void OnCreatureKilledByPet(Player* petOwner, Creature* killed);
void OnPlayerKilledByCreature(Creature* killer, Player* killed);