feat(Core/Scripting): Implement OnBattlefieldBeforeInvitePlayerToWar() (#24973)
This commit is contained in:
@@ -312,6 +312,8 @@ void Battlefield::InvitePlayerToWar(Player* player)
|
|||||||
if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
|
if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sScriptMgr->OnBattlefieldBeforeInvitePlayerToWar(this, player);
|
||||||
|
|
||||||
m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
|
m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
|
||||||
m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime().count() + m_TimeForAcceptInvite;
|
m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime().count() + m_TimeForAcceptInvite;
|
||||||
player->GetSession()->SendBfInvitePlayerToWar(m_BattleId, m_ZoneId, m_TimeForAcceptInvite);
|
player->GetSession()->SendBfInvitePlayerToWar(m_BattleId, m_ZoneId, m_TimeForAcceptInvite);
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ void ScriptMgr::OnBattlefieldPlayerLeaveWar(Battlefield* bf, Player* player)
|
|||||||
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, script->OnBattlefieldPlayerLeaveWar(bf, player));
|
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, script->OnBattlefieldPlayerLeaveWar(bf, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnBattlefieldBeforeInvitePlayerToWar(Battlefield* bf, Player* player)
|
||||||
|
{
|
||||||
|
CALL_ENABLED_HOOKS(BattlefieldScript, BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, script->OnBattlefieldBeforeInvitePlayerToWar(bf, player));
|
||||||
|
}
|
||||||
|
|
||||||
BattlefieldScript::BattlefieldScript(char const* name, std::vector<uint16> enabledHooks) :
|
BattlefieldScript::BattlefieldScript(char const* name, std::vector<uint16> enabledHooks) :
|
||||||
ScriptObject(name, BATTLEFIELDHOOK_END)
|
ScriptObject(name, BATTLEFIELDHOOK_END)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,10 +23,11 @@
|
|||||||
|
|
||||||
enum BattlefieldHook
|
enum BattlefieldHook
|
||||||
{
|
{
|
||||||
BATTLEFIELDHOOK_ON_PLAYER_ENTER_ZONE, // 0 - fires at start of HandlePlayerEnterZone, before team assignment
|
BATTLEFIELDHOOK_ON_PLAYER_ENTER_ZONE, // 0 - fires at start of HandlePlayerEnterZone, before team assignment
|
||||||
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_ZONE, // 1 - fires at end of HandlePlayerLeaveZone, after all cleanup
|
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_ZONE, // 1 - fires at end of HandlePlayerLeaveZone, after all cleanup
|
||||||
BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR, // 2 - fires after player is added to the active war
|
BATTLEFIELDHOOK_ON_PLAYER_JOIN_WAR, // 2 - fires after player is added to the active war
|
||||||
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, // 3 - fires after player is removed from the active war
|
BATTLEFIELDHOOK_ON_PLAYER_LEAVE_WAR, // 3 - fires after player is removed from the active war
|
||||||
|
BATTLEFIELDHOOK_BEFORE_INVITE_PLAYER_TO_WAR, // 4 - fires in InvitePlayerToWar before InvitedPlayers insert
|
||||||
BATTLEFIELDHOOK_END
|
BATTLEFIELDHOOK_END
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,6 +75,18 @@ public:
|
|||||||
* @param player The player leaving the war
|
* @param player The player leaving the war
|
||||||
*/
|
*/
|
||||||
virtual void OnBattlefieldPlayerLeaveWar(Battlefield* /*bf*/, Player* /*player*/) { }
|
virtual void OnBattlefieldPlayerLeaveWar(Battlefield* /*bf*/, Player* /*player*/) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called inside InvitePlayerToWar after the WillBeKick entry is erased
|
||||||
|
* (using the player's current team) and before the player is inserted into
|
||||||
|
* m_InvitedPlayers. This is the correct place to reassign a player's effective
|
||||||
|
* team for pre-war zone players: the invite bucket write that follows will use
|
||||||
|
* the newly assigned team, keeping all subsequent core operations consistent.
|
||||||
|
*
|
||||||
|
* @param bf The Battlefield instance
|
||||||
|
* @param player The player being invited to war
|
||||||
|
*/
|
||||||
|
virtual void OnBattlefieldBeforeInvitePlayerToWar(Battlefield* /*bf*/, Player* /*player*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCRIPT_OBJECT_BATTLEFIELD_SCRIPT_H_
|
#endif // SCRIPT_OBJECT_BATTLEFIELD_SCRIPT_H_
|
||||||
|
|||||||
@@ -583,6 +583,7 @@ public: /* BattlefieldScript */
|
|||||||
void OnBattlefieldPlayerLeaveZone(Battlefield* bf, Player* player);
|
void OnBattlefieldPlayerLeaveZone(Battlefield* bf, Player* player);
|
||||||
void OnBattlefieldPlayerJoinWar(Battlefield* bf, Player* player);
|
void OnBattlefieldPlayerJoinWar(Battlefield* bf, Player* player);
|
||||||
void OnBattlefieldPlayerLeaveWar(Battlefield* bf, Player* player);
|
void OnBattlefieldPlayerLeaveWar(Battlefield* bf, Player* player);
|
||||||
|
void OnBattlefieldBeforeInvitePlayerToWar(Battlefield* bf, Player* player);
|
||||||
|
|
||||||
public: /* BGScript */
|
public: /* BGScript */
|
||||||
void OnBattlegroundStart(Battleground* bg);
|
void OnBattlegroundStart(Battleground* bg);
|
||||||
|
|||||||
Reference in New Issue
Block a user