mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
Improved ScriptMgr with more hooks
This commit is contained in:
@@ -554,6 +554,8 @@ void AchievementMgr::SaveToDB(SQLTransaction& trans)
|
||||
trans->Append(stmt);
|
||||
|
||||
iter->second.changed = false;
|
||||
|
||||
sScriptMgr->OnAchievementSave(trans, GetPlayer(), iter->first, iter->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,6 +583,8 @@ void AchievementMgr::SaveToDB(SQLTransaction& trans)
|
||||
}
|
||||
|
||||
iter->second.changed = false;
|
||||
|
||||
sScriptMgr->OnCriteriaSave(trans, GetPlayer(), iter->first, iter->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2041,6 +2045,8 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
|
||||
}
|
||||
|
||||
SendCriteriaUpdate(entry, progress, timeElapsed, timedCompleted);
|
||||
|
||||
sScriptMgr->OnCriteriaProgress(GetPlayer(), entry);
|
||||
}
|
||||
|
||||
void AchievementMgr::RemoveCriteriaProgress(const AchievementCriteriaEntry* entry)
|
||||
@@ -2138,6 +2144,8 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
|
||||
ca.date = time(NULL);
|
||||
ca.changed = true;
|
||||
|
||||
sScriptMgr->OnAchievementComplete(GetPlayer(), achievement);
|
||||
|
||||
// pussywizard: set all progress counters to 0, so progress will be deleted from db during save
|
||||
{
|
||||
bool allRefsCompleted = true;
|
||||
|
||||
@@ -6946,6 +6946,12 @@ TeamId Player::TeamIdForRace(uint8 race)
|
||||
void Player::setFactionForRace(uint8 race)
|
||||
{
|
||||
m_team = TeamIdForRace(race);
|
||||
|
||||
sScriptMgr->OnPlayerUpdateFaction(this);
|
||||
|
||||
if (GetTeamId(true) != GetTeamId())
|
||||
return;
|
||||
|
||||
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
|
||||
setFaction(rEntry ? rEntry->FactionID : 0);
|
||||
}
|
||||
|
||||
@@ -681,8 +681,6 @@ void Group::ChangeLeader(uint64 newLeaderGuid)
|
||||
if (!newLeader)
|
||||
return;
|
||||
|
||||
sScriptMgr->OnGroupChangeLeader(this, newLeaderGuid, m_leaderGuid);
|
||||
|
||||
if (!isBGGroup() && !isBFGroup())
|
||||
{
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
@@ -707,6 +705,8 @@ void Group::ChangeLeader(uint64 newLeaderGuid)
|
||||
WorldPacket data(SMSG_GROUP_SET_LEADER, m_leaderName.size()+1);
|
||||
data << slot->name;
|
||||
BroadcastPacket(&data, true);
|
||||
|
||||
sScriptMgr->OnGroupChangeLeader(this, newLeaderGuid, m_leaderGuid); // This hook should be executed at the end - Not used anywhere in the original core
|
||||
}
|
||||
|
||||
void Group::Disband(bool hideDestroy /* = false */)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C)
|
||||
* Copyright (C)
|
||||
* Copyright (C)
|
||||
* Copyright (C)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
@@ -703,6 +703,34 @@ bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
|
||||
return tmpscript->OnExpire(player, proto);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action)
|
||||
{
|
||||
ASSERT(player);
|
||||
ASSERT(item);
|
||||
|
||||
GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
|
||||
tmpscript->OnGossipSelect(player, item, sender, action);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code)
|
||||
{
|
||||
ASSERT(player);
|
||||
ASSERT(item);
|
||||
|
||||
GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript);
|
||||
tmpscript->OnGossipSelectCode(player, item, sender, action, code);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnGossipHello(Player* player, Creature* creature)
|
||||
{
|
||||
ASSERT(player);
|
||||
@@ -1232,6 +1260,36 @@ void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newAre
|
||||
FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerUpdateFaction(Player* player)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnUpdateFaction(player);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerRemoveFromBattleground(Player* player, Battleground* bg)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnPlayerRemoveFromBattleground(player, bg);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAchievementComplete(Player* player, AchievementEntry const* achievement)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAchiComplete(player, achievement);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnCriteriaProgress(Player* player, AchievementCriteriaEntry const* criteria)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnCriteriaProgress(player, criteria);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAchievementSave(SQLTransaction& trans, Player* player, uint16 achiId, CompletedAchievementData achiData)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAchiSave(trans, player, achiId, achiData);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnCriteriaSave(SQLTransaction& trans, Player* player, uint16 critId, CriteriaProgress criteriaData)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnCriteriaSave(trans, player, critId, criteriaData);
|
||||
}
|
||||
|
||||
// Guild
|
||||
void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "SharedDefines.h"
|
||||
#include "World.h"
|
||||
#include "Weather.h"
|
||||
#include "AchievementMgr.h"
|
||||
|
||||
class AuctionHouseObject;
|
||||
class AuraScript;
|
||||
@@ -418,6 +419,12 @@ class ItemScript : public ScriptObject
|
||||
|
||||
// Called when the item expires (is destroyed).
|
||||
virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; }
|
||||
|
||||
// Called when a player selects an option in an item gossip window
|
||||
virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
|
||||
|
||||
// Called when a player selects an option in an item gossip window
|
||||
virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
|
||||
};
|
||||
|
||||
class CreatureScript : public ScriptObject, public UpdatableScript<Creature>
|
||||
@@ -748,6 +755,30 @@ class PlayerScript : public ScriptObject
|
||||
|
||||
// Called when a player changes to a new map (after moving to new map)
|
||||
virtual void OnMapChanged(Player* /*player*/) { }
|
||||
|
||||
// Called when team/faction is set on player
|
||||
virtual void OnUpdateFaction(Player* /*player*/) { }
|
||||
|
||||
// Called when a player is removed from battleground
|
||||
virtual void OnPlayerRemoveFromBattleground(Player* /*player*/, Battleground* /*bg*/) { }
|
||||
|
||||
// Called when a player complete an achievement
|
||||
virtual void OnAchiComplete(Player* /*player*/, AchievementEntry const* /*achievement*/) { }
|
||||
|
||||
// Called when a player complete an achievement criteria
|
||||
virtual void OnCriteriaProgress(Player* /*player*/, AchievementCriteriaEntry const* /*criteria*/) { }
|
||||
|
||||
// Called when an Achievement is saved to DB
|
||||
virtual void OnAchiSave(SQLTransaction& /*trans*/, Player* /*player*/, uint16 /*achId*/, CompletedAchievementData /*achiData*/) { }
|
||||
|
||||
// Called when an Criteria is saved to DB
|
||||
virtual void OnCriteriaSave(SQLTransaction& /*trans*/, Player* /*player*/, uint16 /*achId*/, CriteriaProgress /*criteriaData*/) { }
|
||||
|
||||
// Called when a player selects an option in a player gossip window
|
||||
virtual void OnGossipSelect(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/) { }
|
||||
|
||||
// Called when a player selects an option in a player gossip window
|
||||
virtual void OnGossipSelectCode(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
|
||||
};
|
||||
|
||||
class GuildScript : public ScriptObject
|
||||
@@ -903,6 +934,9 @@ class ScriptMgr
|
||||
bool OnQuestAccept(Player* player, Item* item, Quest const* quest);
|
||||
bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets);
|
||||
bool OnItemExpire(Player* player, ItemTemplate const* proto);
|
||||
void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action);
|
||||
void OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code);
|
||||
|
||||
|
||||
public: /* CreatureScript */
|
||||
|
||||
@@ -1017,6 +1051,14 @@ class ScriptMgr
|
||||
void OnPlayerDelete(uint64 guid);
|
||||
void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent);
|
||||
void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea);
|
||||
void OnPlayerUpdateFaction(Player* player);
|
||||
void OnPlayerRemoveFromBattleground(Player* player, Battleground* bg);
|
||||
void OnAchievementComplete(Player *player, AchievementEntry const* achievement);
|
||||
void OnCriteriaProgress(Player *player, AchievementCriteriaEntry const* criteria);
|
||||
void OnAchievementSave(SQLTransaction& trans, Player* player, uint16 achiId, CompletedAchievementData achiData);
|
||||
void OnCriteriaSave(SQLTransaction& trans, Player* player, uint16 critId, CriteriaProgress criteriaData);
|
||||
void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action);
|
||||
void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code);
|
||||
|
||||
public: /* GuildScript */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user