mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 18:40:28 +00:00
feat(Core/Script): Hooks for custom arena teams/types (#3508)
This commit is contained in:
@@ -59,6 +59,7 @@ template class ScriptRegistry<AllCreatureScript>;
|
||||
template class ScriptRegistry<AllMapScript>;
|
||||
template class ScriptRegistry<MovementHandlerScript>;
|
||||
template class ScriptRegistry<BGScript>;
|
||||
template class ScriptRegistry<ArenaTeamScript>;
|
||||
template class ScriptRegistry<SpellSC>;
|
||||
template class ScriptRegistry<AccountScript>;
|
||||
template class ScriptRegistry<GameEventScript>;
|
||||
@@ -124,6 +125,7 @@ void ScriptMgr::Unload()
|
||||
SCR_CLEAR(GlobalScript);
|
||||
SCR_CLEAR(ModuleScript);
|
||||
SCR_CLEAR(BGScript);
|
||||
SCR_CLEAR(ArenaTeamScript);
|
||||
SCR_CLEAR(SpellSC);
|
||||
SCR_CLEAR(GameEventScript);
|
||||
SCR_CLEAR(MailScript);
|
||||
@@ -197,6 +199,7 @@ void ScriptMgr::CheckIfScriptsInDatabaseExist()
|
||||
!ScriptRegistry<PlayerScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GuildScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<BGScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<ArenaTeamScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<SpellSC>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GroupScript>::GetScriptById(sid))
|
||||
sLog->outErrorDb("Script named '%s' is assigned in the database, but has no code!", (*itr).c_str());
|
||||
@@ -1667,6 +1670,21 @@ void ScriptMgr::OnPlayerJoinArena(Player* player)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnPlayerJoinArena(player);
|
||||
}
|
||||
|
||||
void ScriptMgr::GetCustomGetArenaTeamId(const Player* player, uint8 slot, uint32& teamID) const
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->GetCustomGetArenaTeamId(player, slot, teamID);
|
||||
}
|
||||
|
||||
void ScriptMgr::GetCustomArenaPersonalRating(const Player* player, uint8 slot, uint32& rating) const
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->GetCustomArenaPersonalRating(player, slot, rating);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGetMaxPersonalArenaRatingRequirement(const Player* player, uint32 minSlot, uint32& maxArenaRating) const
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnGetMaxPersonalArenaRatingRequirement(player, minSlot, maxArenaRating);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnLootItem(Player* player, Item* item, uint32 count, uint64 lootguid)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnLootItem(player, item, count, lootguid);
|
||||
@@ -2108,6 +2126,31 @@ bool ScriptMgr::CanSendMessageQueue(BattlegroundQueue* queue, Player* leader, Ba
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGetSlotByType(const uint32 type, uint8& slot)
|
||||
{
|
||||
FOREACH_SCRIPT(ArenaTeamScript)->OnGetSlotByType(type, slot);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGetArenaPoints(ArenaTeam* at, float& points)
|
||||
{
|
||||
FOREACH_SCRIPT(ArenaTeamScript)->OnGetArenaPoints(at, points);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnArenaTypeIDToQueueID(const BattlegroundTypeId bgTypeId, const uint8 arenaType, uint32& queueTypeID)
|
||||
{
|
||||
FOREACH_SCRIPT(ArenaTeamScript)->OnTypeIDToQueueID(bgTypeId, arenaType, queueTypeID);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnArenaQueueIdToArenaType(const BattlegroundQueueTypeId bgQueueTypeId, uint8& ArenaType)
|
||||
{
|
||||
FOREACH_SCRIPT(ArenaTeamScript)->OnQueueIdToArenaType(bgQueueTypeId, ArenaType);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnSetArenaMaxPlayersPerTeam(const uint8 arenaType, uint32& maxPlayerPerTeam)
|
||||
{
|
||||
FOREACH_SCRIPT(ArenaTeamScript)->OnSetArenaMaxPlayersPerTeam(arenaType, maxPlayerPerTeam);
|
||||
}
|
||||
|
||||
// SpellSC
|
||||
void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration)
|
||||
{
|
||||
@@ -2323,6 +2366,12 @@ BGScript::BGScript(char const* name)
|
||||
ScriptRegistry<BGScript>::AddScript(this);
|
||||
}
|
||||
|
||||
ArenaTeamScript::ArenaTeamScript(const char* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
ScriptRegistry<ArenaTeamScript>::AddScript(this);
|
||||
}
|
||||
|
||||
SpellSC::SpellSC(char const* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
|
||||
@@ -960,6 +960,15 @@ public:
|
||||
// After player enters queue for Arena
|
||||
virtual void OnPlayerJoinArena(Player* /*player*/) { }
|
||||
|
||||
//Called when trying to get a team ID of a slot > 2 (This is for custom teams created by modules)
|
||||
virtual void GetCustomGetArenaTeamId(const Player* /*player*/, uint8 /*slot*/, uint32& /*teamID*/) const { }
|
||||
|
||||
//Called when trying to get players personal rating of an arena slot > 2 (This is for custom teams created by modules)
|
||||
virtual void GetCustomArenaPersonalRating(const Player* /*player*/, uint8 /*slot*/, uint32& /*rating*/) const { }
|
||||
|
||||
//Called after the normal slots (0..2) for arena have been evaluated so that custom arena teams could modify it if nececasry
|
||||
virtual void OnGetMaxPersonalArenaRatingRequirement(const Player* /*player*/, uint32 /*minSlot*/, uint32& /*maxArenaRating*/) const {}
|
||||
|
||||
//After looting item
|
||||
virtual void OnLootItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, uint64 /*lootguid*/) { }
|
||||
|
||||
@@ -1173,6 +1182,21 @@ public:
|
||||
virtual bool CanSendMessageQueue(BattlegroundQueue* /*queue*/, Player* /*leader*/, Battleground* /*bg*/, PvPDifficultyEntry const* /*bracketEntry*/) { return true; }
|
||||
};
|
||||
|
||||
class ArenaTeamScript : public ScriptObject
|
||||
{
|
||||
protected:
|
||||
ArenaTeamScript(const char* name);
|
||||
|
||||
public:
|
||||
bool IsDatabaseBound() const { return false; };
|
||||
|
||||
virtual void OnGetSlotByType(const uint32 /*type*/, uint8& /*slot*/) {}
|
||||
virtual void OnGetArenaPoints(ArenaTeam* /*team*/, float& /*points*/) {}
|
||||
virtual void OnTypeIDToQueueID(const BattlegroundTypeId /*bgTypeId*/, const uint8 /*arenaType*/, uint32& /*queueTypeID*/) {}
|
||||
virtual void OnQueueIdToArenaType(const BattlegroundQueueTypeId /*bgQueueTypeId*/, uint8& /*ArenaType*/) {}
|
||||
virtual void OnSetArenaMaxPlayersPerTeam(const uint8 /*arenaType*/, uint32& /*maxPlayerPerTeam*/) {}
|
||||
};
|
||||
|
||||
class SpellSC : public ScriptObject
|
||||
{
|
||||
protected:
|
||||
@@ -1460,6 +1484,9 @@ public: /* PlayerScript */
|
||||
void OnEquip(Player* player, Item* it, uint8 bag, uint8 slot, bool update);
|
||||
void OnPlayerJoinBG(Player* player);
|
||||
void OnPlayerJoinArena(Player* player);
|
||||
void GetCustomGetArenaTeamId(const Player* player, uint8 slot, uint32& teamID) const;
|
||||
void GetCustomArenaPersonalRating(const Player* player, uint8 slot, uint32& rating) const;
|
||||
void OnGetMaxPersonalArenaRatingRequirement(const Player* player, uint32 minSlot, uint32& maxArenaRating) const;
|
||||
void OnLootItem(Player* player, Item* item, uint32 count, uint64 lootguid);
|
||||
void OnCreateItem(Player* player, Item* item, uint32 count);
|
||||
void OnQuestRewardItem(Player* player, Item* item, uint32 count);
|
||||
@@ -1572,6 +1599,14 @@ public: /* BGScript */
|
||||
void OnCheckNormalMatch(BattlegroundQueue* queue, uint32& Coef, Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32& minPlayers, uint32& maxPlayers);
|
||||
bool CanSendMessageQueue(BattlegroundQueue* queue, Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry);
|
||||
|
||||
public: /* Arena Team Script */
|
||||
|
||||
void OnGetSlotByType(const uint32 type, uint8& slot);
|
||||
void OnGetArenaPoints(ArenaTeam* at, float& points);
|
||||
void OnArenaTypeIDToQueueID(const BattlegroundTypeId bgTypeId, const uint8 arenaType, uint32& queueTypeID);
|
||||
void OnArenaQueueIdToArenaType(const BattlegroundQueueTypeId bgQueueTypeId, uint8& ArenaType);
|
||||
void OnSetArenaMaxPlayersPerTeam(const uint8 arenaType, uint32& maxPlayerPerTeam);
|
||||
|
||||
public: /* SpellSC */
|
||||
|
||||
void OnCalcMaxDuration(Aura const* aura, int32& maxDuration);
|
||||
@@ -1643,9 +1678,10 @@ public:
|
||||
|
||||
if (script->IsDatabaseBound())
|
||||
{
|
||||
|
||||
if (!_checkMemory(script))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get an ID for the script. An ID only exists if it's a script that is assigned in the database
|
||||
// through a script name (or similar).
|
||||
|
||||
Reference in New Issue
Block a user