feat(Core/Scripting): Add Battlefield scripting hooks and API (#24957)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "Battlefield.h"
|
||||
#include "BattlefieldMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "CellImpl.h"
|
||||
#include "CreatureTextMgr.h"
|
||||
#include "GameGraveyard.h"
|
||||
@@ -81,6 +82,10 @@ Battlefield::~Battlefield()
|
||||
// Called when a player enters the zone
|
||||
void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
|
||||
{
|
||||
// Allow scripts to adjust the player's effective team or appearance before
|
||||
// any team-based battlefield containers (such as player lists or queues) are updated.
|
||||
sScriptMgr->OnBattlefieldPlayerEnterZone(this, player);
|
||||
|
||||
// Xinef: do not invite players on taxi
|
||||
if (!player->IsInFlight())
|
||||
{
|
||||
@@ -126,6 +131,7 @@ void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
|
||||
group->RemoveMember(player->GetGUID());
|
||||
|
||||
OnPlayerLeaveWar(player);
|
||||
sScriptMgr->OnBattlefieldPlayerLeaveWar(this, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +144,10 @@ void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
|
||||
SendRemoveWorldStates(player);
|
||||
RemovePlayerFromResurrectQueue(player->GetGUID());
|
||||
OnPlayerLeaveZone(player);
|
||||
// Scripts must restore player->GetTeamId() here (e.g. ClearFakePlayer).
|
||||
// All Battlefield data-structure cleanup above has already completed using
|
||||
// the assigned team, so it is safe to restore the real team now.
|
||||
sScriptMgr->OnBattlefieldPlayerLeaveZone(this, player);
|
||||
}
|
||||
|
||||
bool Battlefield::Update(uint32 diff)
|
||||
@@ -434,6 +444,7 @@ void Battlefield::PlayerAcceptInviteToWar(Player* player)
|
||||
player->ToggleAFK();
|
||||
|
||||
OnPlayerJoinWar(player); //for scripting
|
||||
sScriptMgr->OnBattlefieldPlayerJoinWar(this, player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user