feat(Core/Hooks): OnBattlegroundDesertion (#4619)
This commit is contained in:
parent
8dbdffab92
commit
a4115862de
@ -1061,13 +1061,17 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime))
|
||||
{
|
||||
// track if player leaves the BG by not clicking enter button
|
||||
if (bg && bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
|
||||
(bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
|
||||
if (bg && bg->isBattleground() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, player->GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, player->GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
sScriptMgr->OnBattlegroundDesertion(player, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
|
||||
}
|
||||
player->RemoveBattlegroundQueueId(m_BgQueueTypeId);
|
||||
bgQueue.RemovePlayer(m_PlayerGuid, false, queueSlot);
|
||||
|
||||
@ -22865,13 +22865,16 @@ void Player::LeaveBattleground(Battleground* bg)
|
||||
return;
|
||||
|
||||
// Deserter tracker - leave BG
|
||||
if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS)
|
||||
&& (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
|
||||
if (bg->isBattleground() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_BG);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_BG);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
sScriptMgr->OnBattlegroundDesertion(this, BG_DESERTION_TYPE_LEAVE_BG);
|
||||
}
|
||||
|
||||
// xinef: reset corpse reclaim time
|
||||
|
||||
@ -471,13 +471,17 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)
|
||||
bgQueue.RemovePlayer(_player->GetGUID(), false, queueSlot);
|
||||
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
|
||||
// track if player refuses to join the BG after being invited
|
||||
if (bg->isBattleground() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS) &&
|
||||
(bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
|
||||
if (bg->isBattleground() && (bg->GetStatus() == STATUS_IN_PROGRESS || bg->GetStatus() == STATUS_WAIT_JOIN))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, _player->GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, _player->GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
sScriptMgr->OnBattlegroundDesertion(_player, BG_DESERTION_TYPE_LEAVE_QUEUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1339,6 +1339,11 @@ void ScriptMgr::OnPlayerCompleteQuest(Player* player, Quest const* quest)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnPlayerCompleteQuest(player, quest);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBattlegroundDesertion(Player* player, BattlegroundDesertionType const desertionType)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBattlegroundDesertion(player, desertionType);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerReleasedGhost(Player* player)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnPlayerReleasedGhost(player);
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#ifndef SC_SCRIPTMGR_H
|
||||
#define SC_SCRIPTMGR_H
|
||||
|
||||
#include "Battleground.h"
|
||||
#include "Common.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "DBCStores.h"
|
||||
@ -744,6 +745,9 @@ protected:
|
||||
public:
|
||||
virtual void OnPlayerReleasedGhost(Player* /*player*/) { }
|
||||
|
||||
// Called when a player does a desertion action (see BattlegroundDesertionType)
|
||||
virtual void OnBattlegroundDesertion(Player* /*player*/, BattlegroundDesertionType const /*desertionType*/) { }
|
||||
|
||||
// Called when a player completes a quest
|
||||
virtual void OnPlayerCompleteQuest(Player* /*player*/, Quest const* /*quest_id*/) { }
|
||||
|
||||
@ -1394,6 +1398,7 @@ public: /* PlayerScript */
|
||||
void OnBeforeInitTalentForLevel(Player* player, uint8& level, uint32& talentPointsForLevel);
|
||||
void OnFirstLogin(Player* player);
|
||||
void OnPlayerCompleteQuest(Player* player, Quest const* quest);
|
||||
void OnBattlegroundDesertion(Player* player, BattlegroundDesertionType const desertionType);
|
||||
bool CanJoinInBattlegroundQueue(Player* player, uint64 BattlemasterGuid, BattlegroundTypeId BGTypeID, uint8 joinAsGroup, GroupJoinBattlegroundResult& err);
|
||||
bool ShouldBeRewardedWithMoneyInsteadOfExp(Player* player);
|
||||
void OnBeforeTempSummonInitStats(Player* player, TempSummon* tempSummon, uint32& duration);
|
||||
|
||||
@ -513,12 +513,16 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
|
||||
sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId).RemovePlayer(_player->GetGUID(), false, i);
|
||||
// track if player logs out after invited to join BG
|
||||
if (_player->IsInvitedForBattlegroundInstance() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
if (_player->IsInvitedForBattlegroundInstance())
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, _player->GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_INVITE_LOGOUT);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, _player->GetGUIDLow());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_INVITE_LOGOUT);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
sScriptMgr->OnBattlegroundDesertion(_player, BG_DESERTION_TYPE_INVITE_LOGOUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user