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