mirror of
https://github.com/araxiaonline/mod-mythic-plus.git
synced 2026-06-13 03:02:24 -04:00
Added scale to respawn trigger, added creaturehook add to instance when creature is scaled.
This commit is contained in:
@@ -18,11 +18,18 @@ public:
|
||||
sCreatureHooks->RegisterOnSpawn(entry, [this](Creature* creature) {
|
||||
this->OnJustSpawned(creature);
|
||||
});
|
||||
|
||||
sCreatureHooks->RegisterOnAddToInstance(entry, [this](Creature* creature) {
|
||||
this->OnAddToInstance(creature);
|
||||
});
|
||||
}
|
||||
|
||||
// Virtual event handlers to be overridden by bosses
|
||||
virtual void OnJustDied(Creature* creature, Unit* killer) = 0;
|
||||
virtual void OnJustSpawned(Creature* creature) = 0;
|
||||
virtual void OnJustDied(Creature* /*creature*/, Unit* /*killer*/) {}
|
||||
|
||||
virtual void OnJustSpawned(Creature* /*creature*/) {}
|
||||
|
||||
virtual void OnAddToInstance(Creature* /*creature*/) {}
|
||||
|
||||
virtual ~BaseCreatureHandler() {}
|
||||
};
|
||||
|
||||
@@ -154,8 +154,6 @@ public:
|
||||
|
||||
|
||||
handler->PSendSysMessage("Mythic+ difficulty set to: " + difficulty);
|
||||
MpLogger::debug("HandleSetMythic() Set difficulty player: {} {}", player->GetName(), difficulty);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -200,7 +198,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
handler->PSendSysMessage(status);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CreatureHooks.h"
|
||||
#include "MythicPlus.h"
|
||||
#include "MpLogger.h"
|
||||
|
||||
void CreatureHooks::RegisterJustDied(uint32 entry, CreatureHook<Creature*, Unit*> callback) {
|
||||
@@ -9,7 +10,7 @@ void CreatureHooks::RegisterOnSpawn(uint32 entry, CreatureHook<Creature*>callbac
|
||||
(*_OnSpawnHandlers)[entry].push_back(callback);
|
||||
}
|
||||
|
||||
void CreatureHooks::RegisterOnAddToInstance(uint32 entry, uint32 mapId, uint32 instanceId, CreatureHook<Creature*> callback) {
|
||||
void CreatureHooks::RegisterOnAddToInstance(uint32 entry, CreatureHook<Creature*> callback) {
|
||||
(*_OnAddToInstanceHandlers)[entry].push_back(callback);
|
||||
}
|
||||
|
||||
@@ -51,7 +52,17 @@ void CreatureHooks::JustDied(Creature* creature, Unit* killer) {
|
||||
}
|
||||
|
||||
void CreatureHooks::JustSpawned(Creature* creature) {
|
||||
if(!creature) {
|
||||
MpLogger::debug("JustSpawned() called with nullptr for creature");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 entry = creature->GetEntry();
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(creature->GetMapId(), creature->GetInstanceId());
|
||||
|
||||
if(instanceData) {
|
||||
sMythicPlus->AddScaledCreature(creature, instanceData);
|
||||
}
|
||||
|
||||
if (_OnSpawnHandlers->contains(entry)) {
|
||||
for (auto& callback : _OnSpawnHandlers->at(entry)) {
|
||||
@@ -59,6 +70,15 @@ void CreatureHooks::JustSpawned(Creature* creature) {
|
||||
MpLogger::debug("JustSpawned() called in CreatureHook: {}", entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CreatureHooks::AddToInstance(Creature* creature) {
|
||||
uint32 entry = creature->GetEntry();
|
||||
|
||||
if (_OnAddToInstanceHandlers->contains(entry)) {
|
||||
for (auto& callback : _OnAddToInstanceHandlers->at(entry)) {
|
||||
callback(creature);
|
||||
MpLogger::debug("AddedToInstance() called in CreatureHook: {}", entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,11 +78,13 @@ public:
|
||||
// Register events for specific actions
|
||||
void RegisterJustDied(uint32 entry, CreatureHook<Creature*, Unit*> callback);
|
||||
void RegisterOnSpawn(uint32 entry, CreatureHook<Creature*> callback);
|
||||
void RegisterOnAddToInstance(uint32 entry, uint32 mapId, uint32 instanceId, CreatureHook<Creature*> callback);
|
||||
void RegisterOnAddToInstance(uint32 entry, CreatureHook<Creature*> callback);
|
||||
|
||||
|
||||
// Event triggers
|
||||
void JustDied(Creature* creature, Unit* killer);
|
||||
void JustSpawned(Creature* creature);
|
||||
void AddToInstance(Creature* creature);
|
||||
};
|
||||
|
||||
#define sCreatureHooks CreatureHooks::instance()
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
creature->Yell("The flame... it burns out...", LANG_UNIVERSAL, nullptr);
|
||||
}
|
||||
|
||||
void OnJustSpawned(Creature* creature) override {
|
||||
void OnAddToInstance(Creature* creature) override {
|
||||
creature->Yell("The fire rises again!", LANG_UNIVERSAL, nullptr);
|
||||
MpLogger::debug("Ragefire Bazzalan spawned Setting high health");
|
||||
uint32 health = 10000000;
|
||||
|
||||
@@ -100,7 +100,7 @@ void MpDataStore::RemoveInstanceData(uint32 mapId, uint32 instanceId) {
|
||||
}
|
||||
|
||||
void MpDataStore::AddCreatureData(ObjectGuid guid, MpCreatureData creatureData) {
|
||||
MpLogger::debug("AddInstanceCreatureData for creature {}", guid.GetCounter());
|
||||
// MpLogger::debug("AddInstanceCreatureData for creature {}", guid.GetCounter());
|
||||
_instanceCreatureData->emplace(guid, creatureData);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
void Reset() override {
|
||||
sCreatureHooks->JustSpawned(me->ToCreature());
|
||||
|
||||
BaseAI::Reset();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -160,10 +160,10 @@ void MythicPlus::AddCreatureForScaling(Creature* creature)
|
||||
}
|
||||
|
||||
sMpDataStore->AddCreatureData(creature->GetGUID(), MpCreatureData(creature));
|
||||
MpLogger::debug("Added creature {} to instance data for instance {}",
|
||||
creature->GetName(),
|
||||
creature->GetMap()->GetMapName()
|
||||
);
|
||||
// MpLogger::debug("Added creature {} to instance data for instance {}",
|
||||
// creature->GetName(),
|
||||
// creature->GetMap()->GetMapName()
|
||||
// );
|
||||
}
|
||||
|
||||
void MythicPlus::AddScaledCreature(Creature* creature, MpInstanceData* instanceData)
|
||||
@@ -182,6 +182,8 @@ void MythicPlus::AddScaledCreature(Creature* creature, MpInstanceData* instanceD
|
||||
auto ai = new MpScriptAI(creature, instanceData->difficulty);
|
||||
creature->SetAI(ai);
|
||||
|
||||
// We know the creature is scaled and in the instance to fire the event.
|
||||
sCreatureHooks->AddToInstance(creature);
|
||||
std::string name = creature->GetName();
|
||||
|
||||
// Assign random affix for now.
|
||||
|
||||
@@ -87,8 +87,8 @@ public:
|
||||
sMythicPlus->legendaryItemOffset = sConfigMgr->GetOption<uint32>("MythicPlus.Legendary.ItemOffset", 21000000);
|
||||
sMythicPlus->ascendantItemOffset = sConfigMgr->GetOption<uint32>("MythicPlus.Ascendant.ItemOffset", 22000000);
|
||||
|
||||
sMythicPlus->meleeAttackPowerDampener = sConfigMgr->GetOption<uint32>("MythicPlus.MeleeAttackPowerDampener", 800);
|
||||
sMythicPlus->meleeAttackPowerStart = sConfigMgr->GetOption<uint32>("MythicPlus.MeleeAttackPowerStart", 3000);
|
||||
sMythicPlus->meleeAttackPowerDampener = sConfigMgr->GetOption<uint32>("MythicPlus.MeleeAttackPowerDampener", 2000);
|
||||
sMythicPlus->meleeAttackPowerStart = sConfigMgr->GetOption<uint32>("MythicPlus.MeleeAttackPowerStart", 10000);
|
||||
}
|
||||
|
||||
void OnStartup() override
|
||||
|
||||
Reference in New Issue
Block a user