mirror of
https://github.com/araxiaonline/mod-mythic-plus.git
synced 2026-06-13 03:02:24 -04:00
Added Unit damage code and removed chatty logging
This commit is contained in:
@@ -14,53 +14,11 @@ public:
|
||||
|
||||
}
|
||||
|
||||
void OnBeforeCreatureSelectLevel(const CreatureTemplate* /*creatureTemplate*/, Creature* creature, uint8& level) override {
|
||||
|
||||
Map* map = creature->GetMap();
|
||||
if (!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sMythicPlus->IsCreatureEligible(creature)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if(!instanceData) {
|
||||
return;
|
||||
}
|
||||
|
||||
MpLogger::debug("OnBeforeCreatureSelectLevel({}, {}) for instance {}",
|
||||
creature->GetName(),
|
||||
level,
|
||||
map->GetMapName()
|
||||
);
|
||||
|
||||
// // bail if the creature is not eligible to be scaled
|
||||
// if (!sMythicPlus->IsCreatureEligible(creature)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // if we have instance data set for this map use it otherwise bail
|
||||
// MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
// if(!instanceData) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (creature->IsDungeonBoss()) {
|
||||
// level = instanceData->boss.avgLevel;
|
||||
// } else {
|
||||
// uint8 level = instanceData->creature.avgLevel;
|
||||
// level = uint8(irand(level-1, level+1));
|
||||
// }
|
||||
|
||||
// LOG_DEBUG("module.MythicPlus", "OnBeforeCreatureSelectLevel({}, {}) for instance {}",
|
||||
// creature->GetName(),
|
||||
// level,
|
||||
// map->GetMapName()
|
||||
// );
|
||||
}
|
||||
// void OnBeforeCreatureSelectLevel(const CreatureTemplate* /*creatureTemplate*/, Creature* creature, uint8& level) override
|
||||
// {
|
||||
// }
|
||||
|
||||
// When a new creature is added into a mythic+ map add it to the list of creatures to scale later.
|
||||
void OnCreatureAddWorld(Creature* creature) override
|
||||
{
|
||||
Map* map = creature->GetMap();
|
||||
@@ -69,143 +27,24 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
sMythicPlus->AddCreatureForScaling(creature);
|
||||
|
||||
// MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
// if(!instanceData) {
|
||||
// MpLogger::debug("Creature: {} Could not find instance data for Map {} and InstanceId: {}", creature->GetName(), map->GetMapName(), map->GetInstanceId());
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (creature->IsDungeonBoss()) {
|
||||
// level = instanceData->boss.avgLevel;
|
||||
// } else {
|
||||
// level = uint8(urand(instanceData->creature.avgLevel-1, instanceData->creature.avgLevel+1));
|
||||
// }
|
||||
|
||||
// // Scale the creature to its new level
|
||||
// sMythicPlus->ScaleCreature(level, creature);
|
||||
|
||||
|
||||
MpLogger::debug("SetLevel and Updateded Creature {} Entry {} Id {} level from {}",
|
||||
creature->GetName(),
|
||||
creature->GetEntry(),
|
||||
creature->GetGUID().GetCounter(),
|
||||
creature->GetLevel()
|
||||
);
|
||||
|
||||
|
||||
// creature->SetLevel(level, false);
|
||||
// MpLogger
|
||||
// if (map->IsDungeon()) {
|
||||
// LOG_INFO("modules", "Creature {} added to map {}", creature->GetName(), map->GetMapName());
|
||||
// MpLogger::warn("Creature {} added to map {}", creature->GetName(), map->GetMapName());
|
||||
// }
|
||||
}
|
||||
|
||||
void OnAllCreatureUpdate(Creature* creature, uint32 diff) override
|
||||
{
|
||||
if (!sMythicPlus->IsMapEligible(creature->GetMap())) {
|
||||
return;
|
||||
// if we have instance data about zone then just scale the creature otherwise add to be scaled once we do.
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if(instanceData) {
|
||||
sMythicPlus->AddScaledCreature(creature, instanceData);
|
||||
} else {
|
||||
sMythicPlus->AddCreatureForScaling(creature);
|
||||
}
|
||||
|
||||
sMythicPlus->ScaleOnUpdate(creature, diff);
|
||||
|
||||
// If the config is out of date and the creature was reset, run modify against it
|
||||
// if (ResetCreatureIfNeeded(creature))
|
||||
// {
|
||||
// LOG_DEBUG("module.MythicPlus",
|
||||
// "MythicPlus_AllCreatureScript::OnAllCreatureUpdate(): Creature {} ({}) is reset to its original stats.",
|
||||
// creature->GetName(),
|
||||
// creature->GetLevel()
|
||||
// );
|
||||
|
||||
// // Update the map's level if it is out of date
|
||||
// sMythicPlus->UpdateMapLevelIfNeeded(creature->GetMap());
|
||||
|
||||
// ModifyCreatureAttributes(creature);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// void OnCreatureRemoveWorld(Creature* creature) override
|
||||
// void OnAllCreatureUpdate(Creature* creature, uint32 diff) override
|
||||
// {
|
||||
// Map* map = creature->GetMap();
|
||||
// if (map->IsDungeon()) {
|
||||
// LOG_INFO("modules", "Creature {} removed from map {}", creature->GetName(), map->GetMapName());
|
||||
// MpLogger::warn("Creature {} removed from map {}", creature->GetName(), map->GetMapName());
|
||||
// }
|
||||
// }
|
||||
|
||||
// void OnCreatureAddWorld(Creature* creature) override
|
||||
// {
|
||||
// if(!sMythicPlus->IsMapEligible(creature->GetMap())) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// MpLogger::debug("OnCreatureAddWorld({}, {}) for instance {}",
|
||||
// creature->GetName(),
|
||||
// creature->GetLevel(),
|
||||
// creature->GetMap()->GetMapName()
|
||||
// );
|
||||
|
||||
// sMpDataStore->AddInstanceCreatureData(
|
||||
// creature->GetGUID(),
|
||||
// {
|
||||
// creature,
|
||||
// const_cast<MapEntry*>(creature->GetMap()->GetEntry())
|
||||
// }
|
||||
// );
|
||||
|
||||
// MpLogger::debug("Added creature {} to instance data for instance {}",
|
||||
// creature->GetName(),
|
||||
// creature->GetMap()->GetMapName()
|
||||
// );
|
||||
// }
|
||||
|
||||
// void OnCreatureRemoveWorld(Creature* creature) override
|
||||
// {
|
||||
// if(!sMythicPlus->IsMapEligible(creature->GetMap())) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// MpLogger::debug("AllCreatureScript::OnCreatureRemoveWorld({}, {})", creature->GetName(), creature->GetLevel());
|
||||
|
||||
// sMpDataStore->RemoveInstanceCreatureData(creature->GetGUID());
|
||||
|
||||
// MpLogger::debug("Removed creature {} from instance data for instance {}",
|
||||
// creature->GetName(),
|
||||
// creature->GetMap()->GetMapName()
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
bool UpdateCreature(Creature* creature)
|
||||
// Cleanup the creature from custom data used for mythic+ mod
|
||||
void OnCreatureRemoveWorld(Creature* creature) override
|
||||
{
|
||||
// make sure we have a creature and that it's assigned to a map
|
||||
if (!creature || !creature->GetMap())
|
||||
return false;
|
||||
|
||||
// if this isn't a dungeon or a battleground, make no changes
|
||||
if (!sMythicPlus->IsMapEligible(creature->GetMap()))
|
||||
return false;
|
||||
|
||||
// if this is a pet or summon controlled by the player, make no changes
|
||||
if ((creature->IsHunterPet() || creature->IsPet() || creature->IsSummon()) && creature->IsControlledByPlayer())
|
||||
return false;
|
||||
|
||||
// if this is a non-relevant creature, skip
|
||||
if (creature->IsCritter() || creature->IsTotem() || creature->IsTrigger())
|
||||
return false;
|
||||
|
||||
if (creature->GetMap()->GetEntry()) {
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
sMythicPlus->RemoveCreature(creature);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void Add_MP_AllCreatureScripts()
|
||||
|
||||
@@ -101,6 +101,9 @@ public:
|
||||
instanceData.ToString()
|
||||
);
|
||||
sMpDataStore->AddInstanceData(map->GetId(), map->GetInstanceId(), instanceData);
|
||||
|
||||
// Once we have instance data set we can scale the remaining characters in our instance
|
||||
sMythicPlus->ScaleRemaining(player, &instanceData);
|
||||
}
|
||||
|
||||
// When an instance is destroyed remove the instance data from the data store
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "MpLogger.h"
|
||||
#include "MythicPlus.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Player.h"
|
||||
#include "Map.h"
|
||||
#include "ObjectMgr.h"
|
||||
|
||||
class MythicPlus_GlobalScript : public GlobalScript
|
||||
{
|
||||
@@ -7,21 +11,61 @@ public:
|
||||
|
||||
MythicPlus_GlobalScript() : GlobalScript("MythicPlus_GlobalScript") { }
|
||||
|
||||
// void OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 /*creditEntry*/, Unit* /*source*/, Difficulty /*difficulty_fixed*/, DungeonEncounterList const* /*encounters*/, uint32 /*dungeonCompleted*/, bool updated) override
|
||||
// {
|
||||
// This adds the mythic+ item scaling to the loot table for enemies
|
||||
void OnBeforeDropAddItem(Player const* player, Loot& loot, bool /*canRate*/, uint16 /*lootMode*/, LootStoreItem* LootStoreItem, LootStore const& store) override {
|
||||
|
||||
// }
|
||||
if(LootStoreItem->itemid == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to provide better rewards to players when they complete a dungeon.
|
||||
* The rewards are scaled up versions of the original drop.
|
||||
* @brief Called after a player has looted an item from a creature.
|
||||
*/
|
||||
// void OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, LootStore const& store) override
|
||||
// {
|
||||
// Not playing on mythic+ difficulty skip doing loot
|
||||
if(!sMythicPlus->IsDifficultySet(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Not on an eligible map skip doing loot
|
||||
Map* map = player->GetMap();
|
||||
if (!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// }
|
||||
MpInstanceData* mythicSettings = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
|
||||
// if there are not mythic settings set for this group and map skip
|
||||
if (!mythicSettings) {
|
||||
MpLogger::warn("No mythic settings found for map {} instance {}", map->GetMapName(), map->GetInstanceId());
|
||||
return;
|
||||
}
|
||||
|
||||
// if the item rewards are disabled skip
|
||||
if (mythicSettings->itemRewards == false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the item to scale up
|
||||
ItemTemplate const* origItem = sObjectMgr->GetItemTemplate(LootStoreItem->itemid);
|
||||
if (!origItem) {
|
||||
MpLogger::warn("Item not found for itemid {} in OnBeforeDropAddItem()", LootStoreItem->itemid);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 newItemId = origItem->ItemId + mythicSettings->itemOffset;
|
||||
ItemTemplate const* newItemTempl = sObjectMgr->GetItemTemplate(newItemId);
|
||||
|
||||
if(!newItemTempl) {
|
||||
MpLogger::warn("New Loot Item not found for itemid {} original item: {} ({})", newItemId, origItem->Name1, origItem->ItemId);
|
||||
return;
|
||||
}
|
||||
|
||||
LootStoreItem->itemid = newItemId;
|
||||
|
||||
// Revalidate the LootStoreItem to ensure consistency
|
||||
if (!LootStoreItem->IsValid(store, newItemId)) {
|
||||
MpLogger::info("LootStoreItem is not valid after updating itemid to {} in OnBeforeDropAddItem()", newItemId);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -3,20 +3,6 @@
|
||||
#include "MpLogger.h"
|
||||
#include "Player.h"
|
||||
|
||||
MpDataStore::MpDataStore() {
|
||||
_groupData = new std::unordered_map<ObjectGuid, MpGroupData>();
|
||||
_playerData = new std::unordered_map<ObjectGuid, MpPlayerData>();
|
||||
_instanceData = new std::unordered_map<std::pair<uint32, uint32>, MpInstanceData>();
|
||||
_instanceCreatureData = new std::unordered_map<ObjectGuid, MpCreatureData>();
|
||||
}
|
||||
|
||||
MpDataStore::~MpDataStore() {
|
||||
delete _groupData;
|
||||
delete _playerData;
|
||||
delete _instanceData;
|
||||
delete _instanceCreatureData;
|
||||
}
|
||||
|
||||
// Adds an entry for the group difficult to memory and updats database
|
||||
void MpDataStore::AddGroupData(Group *group, MpGroupData groupData) {
|
||||
ObjectGuid guid = group->GetGUID();
|
||||
@@ -50,6 +36,8 @@ MpGroupData* MpDataStore::GetGroupData(Group* group) {
|
||||
if (auto it = _groupData->find(group->GetGUID()); it != _groupData->end()) {
|
||||
return &(it->second);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +90,6 @@ void MpDataStore::AddInstanceData(uint32 mapId, uint32 instanceId, MpInstanceDat
|
||||
MpInstanceData* MpDataStore::GetInstanceData(uint32 mapId, uint32 instanceId) {
|
||||
|
||||
if (!_instanceData->contains(GetInstanceDataKey(mapId, instanceId))) {
|
||||
MpLogger::debug("No instance data found for map {} instance {}", mapId, instanceId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -120,13 +107,24 @@ void MpDataStore::AddCreatureData(ObjectGuid guid, MpCreatureData creatureData)
|
||||
|
||||
MpCreatureData* MpDataStore::GetCreatureData(ObjectGuid guid) {
|
||||
if (!_instanceCreatureData->contains(guid)) {
|
||||
MpLogger::debug("No instance creature data found for creature {}", guid.GetCounter());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &_instanceCreatureData->at(guid);
|
||||
}
|
||||
|
||||
std::vector<MpCreatureData*> MpDataStore::GetUnscaledCreatures(uint32 mapId, uint32 instanceId) {
|
||||
std::vector<MpCreatureData*> creatures;
|
||||
for (auto& [guid, creatureData] : *_instanceCreatureData) {
|
||||
Creature* creature = creatureData.creature;
|
||||
|
||||
if (creature->GetMapId() == mapId && creature->GetInstanceId() == instanceId && !creatureData.IsScaled()) {
|
||||
creatures.push_back(&creatureData);
|
||||
}
|
||||
}
|
||||
return creatures;
|
||||
}
|
||||
|
||||
void MpDataStore::RemoveCreatureData(ObjectGuid guid) {
|
||||
MpLogger::debug("RemoveInstanceCreatureData data for creature {}", guid.GetCounter());
|
||||
_instanceCreatureData->erase(guid);
|
||||
|
||||
@@ -100,8 +100,7 @@ struct MpCreatureData
|
||||
{
|
||||
if(creature) {
|
||||
originalLevel = creature->GetLevel();
|
||||
|
||||
CreatureBaseStats const* originalStats = sObjectMgr->GetCreatureBaseStats(
|
||||
originalStats = sObjectMgr->GetCreatureBaseStats(
|
||||
originalLevel,
|
||||
creature->GetCreatureTemplate()->unit_class
|
||||
);
|
||||
@@ -121,19 +120,26 @@ struct MpCreatureData
|
||||
|
||||
class MpDataStore {
|
||||
private:
|
||||
MpDataStore();
|
||||
~MpDataStore();
|
||||
MpDataStore()
|
||||
: _playerData(std::make_unique<std::unordered_map<ObjectGuid, MpPlayerData>>()),
|
||||
_instanceData(std::make_unique<std::map<std::pair<uint32, uint32>, MpInstanceData>>()),
|
||||
_groupData(std::make_unique<std::unordered_map<ObjectGuid, MpGroupData>>()),
|
||||
_instanceCreatureData(std::make_unique<std::unordered_map<ObjectGuid, MpCreatureData>>()) {};
|
||||
|
||||
std::unordered_map<ObjectGuid, MpPlayerData>* _playerData;
|
||||
inline ~MpDataStore() {
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<std::unordered_map<ObjectGuid, MpPlayerData>> _playerData;
|
||||
|
||||
// Instance Data map key is unique instance pair and values are modifiers of instance
|
||||
std::unordered_map<std::pair<uint32,uint32>,MpInstanceData>* _instanceData;
|
||||
std::unique_ptr<std::map<std::pair<uint32,uint32>,MpInstanceData>> _instanceData;
|
||||
|
||||
// Group Data map key is group guid and values are mythic settings set by group leader
|
||||
std::unordered_map<ObjectGuid, MpGroupData>* _groupData;
|
||||
std::unique_ptr<std::unordered_map<ObjectGuid, MpGroupData>> _groupData;
|
||||
|
||||
// Instance Creature Data map key is creature guid and values are creature itself from a mythic instance
|
||||
std::unordered_map<ObjectGuid, MpCreatureData>* _instanceCreatureData;
|
||||
std::unique_ptr<std::unordered_map<ObjectGuid, MpCreatureData>> _instanceCreatureData;
|
||||
|
||||
public:
|
||||
|
||||
@@ -180,6 +186,7 @@ public:
|
||||
void AddCreatureData(ObjectGuid guid, MpCreatureData creatureData);
|
||||
MpCreatureData* GetCreatureData(ObjectGuid guid);
|
||||
void RemoveCreatureData(ObjectGuid guid);
|
||||
std::vector<MpCreatureData*> GetUnscaledCreatures(uint32 mapId, uint32 instanceId);
|
||||
|
||||
// creates a unique instance key into the instance data store
|
||||
auto GetInstanceDataKey(uint32 mapId, uint32 instanceId) {
|
||||
|
||||
@@ -17,9 +17,9 @@ bool MythicPlus::IsMapEligible(Map* map)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MythicPlus::IsDifficultySet(Player* player)
|
||||
bool MythicPlus::IsDifficultySet(Player const* player)
|
||||
{
|
||||
Group* group = player->GetGroup();
|
||||
Group const* group = player->GetGroup();
|
||||
if (!group) {
|
||||
return false;
|
||||
}
|
||||
@@ -32,7 +32,6 @@ bool MythicPlus::IsDifficultySet(Player* player)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MythicPlus::IsDifficultyEnabled(std::string difficulty)
|
||||
{
|
||||
return std::find(enabledDifficulties.begin(), enabledDifficulties.end(), difficulty) != enabledDifficulties.end();
|
||||
@@ -94,55 +93,21 @@ void MythicPlus::AddCreatureForScaling(Creature* creature)
|
||||
);
|
||||
}
|
||||
|
||||
void MythicPlus::ScaleOnUpdate(Creature* creature, uint32 diff)
|
||||
void MythicPlus::AddScaledCreature(Creature* creature, MpInstanceData* instanceData)
|
||||
{
|
||||
// Check to see if the creature is in our list to be scaled to mythic+ levels
|
||||
MpCreatureData* creatureData = sMpDataStore->GetCreatureData(creature->GetGUID());
|
||||
if (!creatureData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if it has already been scaled then do nothing.
|
||||
if (creatureData->IsScaled()) {
|
||||
MpLogger::debug("Creature {} Entry {} Id {} already scaled in ScaleOnUpdate()",
|
||||
creature->GetName(),
|
||||
creature->GetEntry(),
|
||||
creature->GetGUID().GetCounter()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise we handle scaling the stats of the creature based on map difficulty set
|
||||
Map* map = creature->GetMap();
|
||||
if(!map) {
|
||||
MpLogger::warn("Map is null for creature {} Entry {} Id {} could not scale in ScaleOnUpdate()",
|
||||
creature->GetName(),
|
||||
creature->GetEntry(),
|
||||
creature->GetGUID().GetCounter()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// The instance data for this map determines how to scale the creature by difficulty set
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if (!instanceData) {
|
||||
MpLogger::warn("Instance data is null for creature {} Entry {} Id {} could not scale in ScaleOnUpdate()",
|
||||
creature->GetName(),
|
||||
creature->GetEntry(),
|
||||
creature->GetGUID().GetCounter()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// allow small variance in level for non-boss creatures
|
||||
uint8 level = uint8(urand(instanceData->creature.avgLevel - 1, instanceData->creature.avgLevel + 1));
|
||||
if(creature->IsDungeonBoss()) {
|
||||
level = instanceData->boss.avgLevel;
|
||||
ScaleCreature(instanceData->boss.avgLevel, creature, &instanceData->boss);
|
||||
} else {
|
||||
ScaleCreature(level, creature, &instanceData->creature);
|
||||
}
|
||||
ScaleCreature(level, creature);
|
||||
creatureData->SetScaled(true); // Since updates happen frequently set the flag so we do not re-scale
|
||||
|
||||
MpLogger::debug("Sca Creature {} Entry {} Id {} level from {} to {}",
|
||||
MpCreatureData creatureData = MpCreatureData(creature);
|
||||
creatureData.SetScaled(true);
|
||||
sMpDataStore->AddCreatureData(creature->GetGUID(), creatureData);
|
||||
|
||||
MpLogger::debug("Scaled Creature {} Entry {} Id {} level from {} to {}",
|
||||
creature->GetName(),
|
||||
creature->GetEntry(),
|
||||
creature->GetGUID().GetCounter(),
|
||||
@@ -151,7 +116,26 @@ void MythicPlus::ScaleOnUpdate(Creature* creature, uint32 diff)
|
||||
);
|
||||
}
|
||||
|
||||
void MythicPlus::ScaleCreature(uint8 level, Creature* creature)
|
||||
void MythicPlus::ScaleRemaining(Player* player, MpInstanceData* instanceData)
|
||||
{
|
||||
std::vector<MpCreatureData*> creatures = sMpDataStore->GetUnscaledCreatures(player->GetMapId(), player->GetInstanceId());
|
||||
for (MpCreatureData* creatureData : creatures) {
|
||||
AddScaledCreature(creatureData->creature, instanceData);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform any memory cleanup when the creature is removed from the world and no longer needed.
|
||||
void MythicPlus::RemoveCreature(Creature* creature)
|
||||
{
|
||||
MpCreatureData* creatureData = sMpDataStore->GetCreatureData(creature->GetGUID());
|
||||
if (!creatureData) {
|
||||
return;
|
||||
}
|
||||
|
||||
sMpDataStore->RemoveCreatureData(creature->GetGUID());
|
||||
}
|
||||
|
||||
void MythicPlus::ScaleCreature(uint8 level, Creature* creature, MpMultipliers* multipliers)
|
||||
{
|
||||
creature->SetLevel(level);
|
||||
CreatureBaseStats const* stats = sObjectMgr->GetCreatureBaseStats(
|
||||
@@ -168,12 +152,13 @@ void MythicPlus::ScaleCreature(uint8 level, Creature* creature)
|
||||
// Scales the creatures hitpoints
|
||||
float healthmod = GetHealthModifier(rank);
|
||||
uint32 basehp = std::max<uint32>(1, stats->GenerateHealth(cInfo));
|
||||
uint32 health = uint32(basehp * healthmod);
|
||||
uint32 health = uint32(basehp * healthmod) * multipliers->health;
|
||||
|
||||
creature->SetCreateHealth(health);
|
||||
creature->SetMaxHealth(health);
|
||||
creature->SetHealth(health);
|
||||
creature->ResetPlayerDamageReq();
|
||||
creature->SetArmor(stats->GenerateArmor(cInfo) * multipliers->armor);
|
||||
|
||||
// Scales the creatures mana
|
||||
uint32 mana = stats->GenerateMana(cInfo);
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
bool IsMapEligible(Map* map);
|
||||
|
||||
// If a player difficulty is set that is eligible for mythic+ scaling
|
||||
bool IsDifficultySet(Player* player);
|
||||
bool IsDifficultySet(Player const* player);
|
||||
|
||||
// Check is difficulty is enabled in the configuration
|
||||
bool IsDifficultyEnabled(std::string difficulty);
|
||||
@@ -67,12 +67,22 @@ public:
|
||||
// Adds the creature if eligible to be scaled
|
||||
void AddCreatureForScaling(Creature* creature);
|
||||
|
||||
// Will make determination on if this creature needs to be scaled and will do so
|
||||
// the diff time is used to determine the last time the creature was modified.
|
||||
void ScaleOnUpdate(Creature* creature, uint32 diff);
|
||||
// Removes the creature from the scaling list and cleans up memory
|
||||
void RemoveCreature(Creature* creature);
|
||||
|
||||
/**
|
||||
* Creatures are added to an instance before a player enter event is fired
|
||||
* therefore it is necessary to scan the instance creature information and
|
||||
* and scale any creatures that were loaded before the first player using
|
||||
* the instance data from the group settings.
|
||||
*/
|
||||
void ScaleRemaining(Player* player, MpInstanceData* instanceData);
|
||||
|
||||
// This will attempt to scale a creature using instancedata
|
||||
void AddScaledCreature(Creature* creature, MpInstanceData* instanceData);
|
||||
|
||||
// Scales the creature based on the level and the creature base stats
|
||||
void ScaleCreature(uint8 level, Creature* creature);
|
||||
void ScaleCreature(uint8 level, Creature* creature, MpMultipliers* multipliers);
|
||||
|
||||
private:
|
||||
MythicPlus() { }
|
||||
|
||||
@@ -16,7 +16,7 @@ void Addmod_mythic_plusScripts()
|
||||
Add_MP_AllCreatureScripts();
|
||||
Add_MP_AllMapScripts();
|
||||
Add_MP_CommandScripts();
|
||||
// Add_MP_GlobalScripts();
|
||||
Add_MP_GlobalScripts();
|
||||
// Add_MP_GroupScripts();
|
||||
// Add_MP_PlayerScripts();
|
||||
Add_MP_UnitScripts();
|
||||
|
||||
@@ -7,55 +7,6 @@ class MythicPlus_PlayerScript : public PlayerScript
|
||||
public:
|
||||
MythicPlus_PlayerScript() : PlayerScript("MythicPlus_PlayerScript") { }
|
||||
|
||||
// void OnLogin(Player *Player) override
|
||||
// {
|
||||
// // if (sMythicPlus->EnableGlobal && sMythicPlus->Announcement) {
|
||||
// // ChatHandler(Player->GetSession()).SendSysMessage("This server is running the |cff4CFF00MythicPlus |rmodule.");
|
||||
// // }
|
||||
// }
|
||||
|
||||
// // virtual void OnPlayerEnterMap(Player* player, Map* map) override
|
||||
// // {
|
||||
// // // if (!map || !map->IsDungeon())
|
||||
// // // return;
|
||||
|
||||
// // // sMythicPlus->UpdateMapPlayerStats(map);
|
||||
// // }
|
||||
|
||||
// virtual void OnLevelChanged(Player* player, uint8 oldlevel) override
|
||||
// {
|
||||
// // Map* map = player->GetMap();
|
||||
|
||||
// // if (!map || !map->IsDungeon())
|
||||
// // return;
|
||||
|
||||
// // first update the map's player stats
|
||||
// // sMythicPlus->UpdateMapPlayerStats(map);
|
||||
|
||||
// // // schedule all creatures for an update
|
||||
// // sMythicPlus->lastConfigTime =
|
||||
// // std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
// // std::chrono::system_clock::now().time_since_epoch()
|
||||
// // ).count();
|
||||
// }
|
||||
|
||||
// void OnGiveXP(Player* player, uint32& amount, Unit* victim, uint8 /*xpSource*/) override
|
||||
// {
|
||||
// // Map* map = player->GetMap();
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// // void OnBeforeDropAddItem
|
||||
// void OnBeforeLootMoney(Player* player, Loot* loot) override
|
||||
// {
|
||||
// // Map* map = player->GetMap();
|
||||
|
||||
// // // If this isn't a dungeon, make no changes
|
||||
// // if (!map->IsDungeon())
|
||||
// // return;
|
||||
|
||||
// }
|
||||
};
|
||||
|
||||
void Add_MP_PlayerScripts()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "MpLogger.h"
|
||||
#include "Player.h"
|
||||
#include "MythicPlus.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
class MythicPlus_UnitScript : public UnitScript
|
||||
@@ -7,29 +8,119 @@ class MythicPlus_UnitScript : public UnitScript
|
||||
public:
|
||||
MythicPlus_UnitScript() : UnitScript("MythicPlus_UnitScript", true) { }
|
||||
|
||||
uint32 DealDamage(Unit* /*AttackerUnit*/, Unit* /*playerVictim*/, uint32 damage, DamageEffectType /*damagetype*/) override {
|
||||
return damage;
|
||||
void ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage, SpellInfo const* /*spellInfo*/) override {
|
||||
Map *map = target->GetMap();
|
||||
if(!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is the enemy then increase the amount of healing by the instance data modifier for spell output.
|
||||
if(target->isType(TYPEID_PLAYER) && attacker->isType(TYPEID_UNIT)) {
|
||||
Creature* creature = target->ToCreature();
|
||||
if(!creature || !sMythicPlus->IsCreatureEligible(creature)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if(!instanceData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(creature->IsDungeonBoss()) {
|
||||
damage = damage * (instanceData->boss.spell * 0.8);
|
||||
} else {
|
||||
damage = damage * (instanceData->creature.spell * 0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModifyPeriodicDamageAurasTick(Unit* /*target */, Unit* /*attacker*/, uint32& /*damage*/, SpellInfo const* /*spellInfo*/) override {
|
||||
void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage, SpellInfo const* /*spellInfo*/) override {
|
||||
Map *map = target->GetMap();
|
||||
if(!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is the enemy then increase the amount of healing by the instance data modifier for spell output.
|
||||
if(target->isType(TYPEID_PLAYER) && attacker->isType(TYPEID_UNIT)) {
|
||||
Creature* creature = target->ToCreature();
|
||||
if(!creature || !sMythicPlus->IsCreatureEligible(creature)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if(!instanceData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(creature->IsDungeonBoss()) {
|
||||
damage = damage * instanceData->boss.spell;
|
||||
} else {
|
||||
damage = damage * instanceData->creature.spell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage) override {
|
||||
|
||||
Map *map = target->GetMap();
|
||||
if(!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is the enemy then increase the amount of healing by the instance data modifier for spell output.
|
||||
if(target->isType(TYPEID_PLAYER) && attacker->isType(TYPEID_UNIT)) {
|
||||
Creature* creature = target->ToCreature();
|
||||
if(!creature || !sMythicPlus->IsCreatureEligible(creature)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if(!instanceData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(creature->IsDungeonBoss()) {
|
||||
damage = damage * instanceData->boss.melee *10;
|
||||
} else {
|
||||
damage = damage * instanceData->creature.melee * 10 ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ModifySpellDamageTaken(Unit* /*target*/, Unit* /*attacker*/, int32& /*damage*/, SpellInfo const* /*spellInfo*/) override {
|
||||
// When a healing spell hits a mythic+ enemy modify based on the modifiers for the difficulty
|
||||
void ModifyHealReceived(Unit* target, Unit* healer, uint32& healing, SpellInfo const* /*spellInfo*/) override {
|
||||
|
||||
Map *map = target->GetMap();
|
||||
if(!sMythicPlus->IsMapEligible(map)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is the enemy then increase the amount of healing by the instance data modifier for spell output.
|
||||
if(target->isType(TYPEID_UNIT)) {
|
||||
Creature* creature = target->ToCreature();
|
||||
if(!creature || !sMythicPlus->IsCreatureEligible(creature)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MpInstanceData* instanceData = sMpDataStore->GetInstanceData(map->GetId(), map->GetInstanceId());
|
||||
if(!instanceData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(creature->IsDungeonBoss()) {
|
||||
healing = healing * instanceData->boss.spell;
|
||||
} else {
|
||||
healing = healing * instanceData->creature.spell;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ModifyMeleeDamage(Unit* /*target*/, Unit* /*attacker*/, uint32& /*damage*/) override {
|
||||
// void OnAuraApply(Unit* unit, Aura* aura) override {
|
||||
|
||||
}
|
||||
|
||||
void ModifyHealReceived(Unit* /*target*/, Unit* /*attacker*/, uint32& /*damage*/, SpellInfo const* /*spellInfo*/) override {
|
||||
|
||||
}
|
||||
|
||||
void OnAuraApply(Unit* unit, Aura* aura) override {
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
};
|
||||
void Add_MP_UnitScripts()
|
||||
|
||||
Reference in New Issue
Block a user