feat(Core/Scripting): Implement OnBeforeSetBossState (#14891)
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include "Opcodes.h"
|
#include "Opcodes.h"
|
||||||
#include "Pet.h"
|
#include "Pet.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include "ScriptMgr.h"
|
||||||
#include "Spell.h"
|
#include "Spell.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
|
|
||||||
@@ -307,6 +308,7 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
|
|||||||
if (id < bosses.size())
|
if (id < bosses.size())
|
||||||
{
|
{
|
||||||
BossInfo* bossInfo = &bosses[id];
|
BossInfo* bossInfo = &bosses[id];
|
||||||
|
sScriptMgr->OnBeforeSetBossState(id, state, bossInfo->state, instance);
|
||||||
if (bossInfo->state == TO_BE_DECIDED) // loading
|
if (bossInfo->state == TO_BE_DECIDED) // loading
|
||||||
{
|
{
|
||||||
bossInfo->state = state;
|
bossInfo->state = state;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "InstanceScript.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "ScriptMgrMacros.h"
|
#include "ScriptMgrMacros.h"
|
||||||
@@ -189,3 +190,20 @@ void ScriptMgr::OnInstanceIdRemoved(uint32 instanceId)
|
|||||||
script->OnInstanceIdRemoved(instanceId);
|
script->OnInstanceIdRemoved(instanceId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Called when any raid boss has their state updated (e.g. pull, reset, kill).
|
||||||
|
* @details Careful checks for old- and newState are required, since it can fire multiple times and not only when combat starts/ends.
|
||||||
|
*
|
||||||
|
* @param id The id of the boss in the [instance]
|
||||||
|
* @param newState The new boss state to be applied to this boss
|
||||||
|
* @param oldState The previously assigned state of this boss
|
||||||
|
* @param instance A pointer to the [map] object of the instance
|
||||||
|
*/
|
||||||
|
void ScriptMgr::OnBeforeSetBossState(uint32 id, EncounterState newState, EncounterState oldState, Map* instance)
|
||||||
|
{
|
||||||
|
ExecuteScript<GlobalScript>([&](GlobalScript* script)
|
||||||
|
{
|
||||||
|
script->OnBeforeSetBossState(id, newState, oldState, instance);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "DynamicObject.h"
|
#include "DynamicObject.h"
|
||||||
#include "GameEventMgr.h"
|
#include "GameEventMgr.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
#include "InstanceScript.h"
|
||||||
#include "LFGMgr.h"
|
#include "LFGMgr.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "PetDefines.h"
|
#include "PetDefines.h"
|
||||||
@@ -1597,6 +1598,9 @@ public:
|
|||||||
|
|
||||||
// Called when instance id is removed from database (e.g. instance reset)
|
// Called when instance id is removed from database (e.g. instance reset)
|
||||||
virtual void OnInstanceIdRemoved(uint32 /*instanceId*/) { }
|
virtual void OnInstanceIdRemoved(uint32 /*instanceId*/) { }
|
||||||
|
|
||||||
|
// Called when any raid boss has their state updated (e.g. pull, reset, kill)
|
||||||
|
virtual void OnBeforeSetBossState(uint32 /*id*/, EncounterState /*newState*/, EncounterState /*oldState*/, Map* /*instance*/) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class BGScript : public ScriptObject
|
class BGScript : public ScriptObject
|
||||||
@@ -2431,6 +2435,7 @@ public: /* GlobalScript */
|
|||||||
void OnLoadSpellCustomAttr(SpellInfo* spell);
|
void OnLoadSpellCustomAttr(SpellInfo* spell);
|
||||||
bool OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid source);
|
bool OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid source);
|
||||||
void OnInstanceIdRemoved(uint32 instanceId);
|
void OnInstanceIdRemoved(uint32 instanceId);
|
||||||
|
void OnBeforeSetBossState(uint32 id, EncounterState newState, EncounterState oldState, Map* instance);
|
||||||
|
|
||||||
public: /* Scheduled scripts */
|
public: /* Scheduled scripts */
|
||||||
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
||||||
|
|||||||
Reference in New Issue
Block a user