mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
feat(Core/Hooks): added collection of hooks to extends AC (#3047)
This collection of hooks comes from the Maelstrom project. It allows to release modules such as : - 3v3-soloqueue - 1v1 arena - pvestats and many others
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "Log.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Player.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "Util.h"
|
||||
@@ -50,6 +51,9 @@ void WorldSession::SendAuctionHello(uint64 guid, Creature* unit)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sScriptMgr->CanSendAuctionHello(this, guid, unit))
|
||||
return;
|
||||
|
||||
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
|
||||
if (!ahEntry)
|
||||
return;
|
||||
|
||||
@@ -388,6 +388,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)
|
||||
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenaType);
|
||||
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
|
||||
|
||||
if (!sScriptMgr->CanBattleFieldPort(_player, arenaType, bgTypeId, action))
|
||||
return;
|
||||
|
||||
// get group info from queue
|
||||
GroupQueueInfo ginfo;
|
||||
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
|
||||
@@ -658,6 +661,14 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
|
||||
// queue result (default ok)
|
||||
GroupJoinBattlegroundResult err = GroupJoinBattlegroundResult(bgt->GetBgTypeID());
|
||||
|
||||
if (!sScriptMgr->CanJoinInArenaQueue(_player, guid, arenaslot, bgTypeId, asGroup, isRated, err) && err <= 0)
|
||||
{
|
||||
WorldPacket data;
|
||||
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
|
||||
SendPacket(&data);
|
||||
return;
|
||||
}
|
||||
|
||||
// check if player can queue:
|
||||
if (!asGroup)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "Opcodes.h"
|
||||
#include "Pet.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "Util.h"
|
||||
@@ -74,6 +75,9 @@ void WorldSession::HandleGroupInviteOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sScriptMgr->CanGroupInvite(GetPlayer(), membername))
|
||||
return;
|
||||
|
||||
if (GetPlayer()->IsSpectator() || player->IsSpectator())
|
||||
{
|
||||
SendPartyResult(PARTY_OP_INVITE, membername, ERR_INVITE_RESTRICTED);
|
||||
@@ -224,6 +228,9 @@ void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sScriptMgr->CanGroupAccept(GetPlayer(), group))
|
||||
return;
|
||||
|
||||
if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
|
||||
{
|
||||
sLog->outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SpellInfo.h"
|
||||
#include "UpdateData.h"
|
||||
#include "WorldPacket.h"
|
||||
@@ -660,6 +661,9 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recvData)
|
||||
Item* pItem = _player->GetItemByGuid(itemguid);
|
||||
if (pItem)
|
||||
{
|
||||
if (!sScriptMgr->CanSellItem(_player, pItem, creature))
|
||||
return;
|
||||
|
||||
// prevent sell not owner item
|
||||
if (_player->GetGUID() != pItem->GetOwnerGUID())
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
@@ -196,9 +197,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
||||
}
|
||||
}*/
|
||||
|
||||
uint32 rc_account = receive
|
||||
? receive->GetSession()->GetAccountId()
|
||||
: sObjectMgr->GetPlayerAccountIdByGUID(rc);
|
||||
uint32 rc_account = receive ? receive->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(rc);
|
||||
|
||||
if (/*!accountBound*/ GetAccountId() != rc_account && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL) && player->GetTeamId() != rc_teamId && AccountMgr::IsPlayerAccount(GetSecurity()))
|
||||
{
|
||||
@@ -255,6 +254,9 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sScriptMgr->CanSendMail(player, rc, mailbox, subject, body, money, COD, item))
|
||||
return;
|
||||
|
||||
items[i] = item;
|
||||
}
|
||||
|
||||
|
||||
@@ -1019,6 +1019,8 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recvData)
|
||||
// reputation discount
|
||||
float discountMod = _player->GetReputationPriceDiscount(unit);
|
||||
|
||||
sScriptMgr->OnBeforePlayerDurabilityRepair(_player, npcGUID, itemGUID, discountMod, guildBank);
|
||||
|
||||
if (itemGUID)
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
|
||||
@@ -15,22 +15,12 @@
|
||||
#include "ObjectMgr.h"
|
||||
#include "Opcodes.h"
|
||||
#include "PetitionMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#define CHARTER_DISPLAY_ID 16161
|
||||
|
||||
// Charters ID in item_template
|
||||
enum CharterItemIDs
|
||||
{
|
||||
GUILD_CHARTER = 5863,
|
||||
ARENA_TEAM_CHARTER_2v2 = 23560,
|
||||
ARENA_TEAM_CHARTER_3v3 = 23561,
|
||||
ARENA_TEAM_CHARTER_5v5 = 23562
|
||||
};
|
||||
|
||||
void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
@@ -136,6 +126,8 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
sScriptMgr->PetitionBuy(_player, creature, charterid, cost, type);
|
||||
|
||||
if (type == GUILD_CHARTER_TYPE)
|
||||
{
|
||||
if (sGuildMgr->GetGuildByName(name))
|
||||
@@ -880,38 +872,65 @@ void WorldSession::SendPetitionShowList(uint64 guid)
|
||||
WorldPacket data(SMSG_PETITION_SHOWLIST, 8 + 1 + 4 * 6);
|
||||
data << guid; // npc guid
|
||||
|
||||
// For guild default
|
||||
uint32 CharterEntry = GUILD_CHARTER;
|
||||
uint32 CharterDispayID = CHARTER_DISPLAY_ID;
|
||||
uint32 CharterCost = sWorld->getIntConfig(CONFIG_CHARTER_COST_GUILD);
|
||||
|
||||
if (creature->IsTabardDesigner())
|
||||
{
|
||||
sScriptMgr->PetitionShowList(_player, creature, CharterEntry, CharterDispayID, CharterCost);
|
||||
|
||||
data << uint8(1); // count
|
||||
data << uint32(1); // index
|
||||
data << uint32(GUILD_CHARTER); // charter entry
|
||||
data << uint32(CHARTER_DISPLAY_ID); // charter display id
|
||||
data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_GUILD)); // charter cost
|
||||
data << CharterEntry; // charter entry
|
||||
data << CharterDispayID; // charter display id
|
||||
data << CharterCost; // charter cost
|
||||
data << uint32(0); // unknown
|
||||
data << uint32(sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS)); // required signs
|
||||
}
|
||||
else
|
||||
{
|
||||
data << uint8(3); // count
|
||||
// For 2v2 default
|
||||
CharterEntry = ARENA_TEAM_CHARTER_2v2;
|
||||
CharterDispayID = CHARTER_DISPLAY_ID;
|
||||
CharterCost = sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_2v2);
|
||||
|
||||
// 2v2
|
||||
data << uint8(3); // count
|
||||
sScriptMgr->PetitionShowList(_player, creature, CharterEntry, CharterDispayID, CharterCost);
|
||||
data << uint32(1); // index
|
||||
data << uint32(ARENA_TEAM_CHARTER_2v2); // charter entry
|
||||
data << uint32(CHARTER_DISPLAY_ID); // charter display id
|
||||
data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_2v2)); // charter cost
|
||||
data << CharterEntry; // charter entry
|
||||
data << CharterDispayID; // charter display id
|
||||
data << CharterCost; // charter cost
|
||||
data << uint32(2); // unknown
|
||||
data << uint32(2); // required signs?
|
||||
|
||||
// For 3v3 default
|
||||
CharterEntry = ARENA_TEAM_CHARTER_3v3;
|
||||
CharterDispayID = CHARTER_DISPLAY_ID;
|
||||
CharterCost = sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_3v3);
|
||||
|
||||
// 3v3
|
||||
sScriptMgr->PetitionShowList(_player, creature, CharterEntry, CharterDispayID, CharterCost);
|
||||
data << uint32(2); // index
|
||||
data << uint32(ARENA_TEAM_CHARTER_3v3); // charter entry
|
||||
data << uint32(CHARTER_DISPLAY_ID); // charter display id
|
||||
data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_3v3)); // charter cost
|
||||
data << CharterEntry; // charter entry
|
||||
data << CharterDispayID; // charter display id
|
||||
data << CharterCost; // charter cost
|
||||
data << uint32(3); // unknown
|
||||
data << uint32(3); // required signs?
|
||||
|
||||
// For 3v3 default
|
||||
CharterEntry = ARENA_TEAM_CHARTER_5v5;
|
||||
CharterDispayID = CHARTER_DISPLAY_ID;
|
||||
CharterCost = sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_5v5);
|
||||
|
||||
// 5v5
|
||||
sScriptMgr->PetitionShowList(_player, creature, CharterEntry, CharterDispayID, CharterCost);
|
||||
data << uint32(3); // index
|
||||
data << uint32(ARENA_TEAM_CHARTER_5v5); // charter entry
|
||||
data << uint32(CHARTER_DISPLAY_ID); // charter display id
|
||||
data << uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_ARENA_5v5)); // charter cost
|
||||
data << CharterEntry; // charter entry
|
||||
data << CharterDispayID; // charter display id
|
||||
data << CharterCost; // charter cost
|
||||
data << uint32(5); // unknown
|
||||
data << uint32(5); // required signs?
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "ScriptMgr.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "TemporarySummon.h"
|
||||
@@ -343,6 +344,8 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
uint8 castCount, castFlags;
|
||||
recvPacket >> castCount >> spellId >> castFlags;
|
||||
|
||||
uint32 oldSpellId = spellId;
|
||||
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: got cast spell packet, castCount: %u, spellId: %u, castFlags: %u, data length = %u", castCount, spellId, castFlags, (uint32)recvPacket.size());
|
||||
#endif
|
||||
@@ -404,6 +407,11 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
}
|
||||
|
||||
sScriptMgr->ValidateSpellAtCastSpell(_player, oldSpellId, spellId, castCount, castFlags);
|
||||
|
||||
if (oldSpellId != spellId)
|
||||
spellInfo = sSpellMgr->GetSpellInfo(spellId);
|
||||
|
||||
// Client is resending autoshot cast opcode when other spell is casted during shoot rotation
|
||||
// Skip it to prevent "interrupt" message
|
||||
if (spellInfo->IsAutoRepeatRangedSpell() && _player->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)
|
||||
@@ -443,6 +451,9 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
|
||||
Spell* spell = new Spell(mover, spellInfo, TRIGGERED_NONE, 0, false);
|
||||
|
||||
sScriptMgr->ValidateSpellAtCastSpellResult(_player, mover, spell, oldSpellId, spellId);
|
||||
|
||||
spell->m_cast_count = castCount; // set count of casts
|
||||
spell->prepare(&targets);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "Spell.h"
|
||||
#include "World.h"
|
||||
@@ -640,6 +641,9 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sScriptMgr->CanInitTrade(_player, pOther))
|
||||
return;
|
||||
|
||||
// OK start trade
|
||||
_player->m_trade = new TradeData(_player, pOther);
|
||||
pOther->m_trade = new TradeData(pOther, _player);
|
||||
|
||||
Reference in New Issue
Block a user