diff --git a/src/CommandScript.cpp b/src/CommandScript.cpp index 53f56c6..42fea44 100644 --- a/src/CommandScript.cpp +++ b/src/CommandScript.cpp @@ -28,6 +28,7 @@ public: // {"legendary",HandleLegendary, SEC_PLAYER, Console::No}, // {"ascendant",HandleAscendant, SEC_PLAYER, Console::No}, {"set", HandleSetDifficulty, SEC_PLAYER, Console::No}, + {"update", HandleUpdate, SEC_GAMEMASTER,Console::No }, {"disable", HandleDisable, SEC_ADMINISTRATOR, Console::Yes}, {"enable", HandleEnable, SEC_ADMINISTRATOR, Console::Yes} }; @@ -53,6 +54,13 @@ public: return true; } + static bool HandleUpdate(ChatHandler* handler, const std::vector& /*args*/) + { + sMpDataStore->LoadScaleFactors(); + handler->PSendSysMessage("Mythic+ scale factors updated."); + return true; + } + static bool HandleDebug(ChatHandler* handler, const std::vector& args) { diff --git a/src/MythicPlus.cpp b/src/MythicPlus.cpp index 442d739..bbe1c5c 100644 --- a/src/MythicPlus.cpp +++ b/src/MythicPlus.cpp @@ -62,12 +62,15 @@ bool MythicPlus::EligibleHealTarget(Unit* target) return false; } - if ((target->IsPet() || target->IsSummon() || target->IsHunterPet()) && target->GetOwner()->IsNPCBot()) { + // Null check for GetOwner to avoid dereferencing a null pointer + if ((target->IsPet() || target->IsSummon() || target->IsHunterPet()) && target->GetOwner() && target->GetOwner()->IsNPCBot()) { return false; } #endif - if(sMythicPlus->IsCreatureEligible(target->ToCreature())) { + // Ensure target is a valid creature before checking eligibility + Creature* creatureTarget = target->ToCreature(); + if (creatureTarget && sMythicPlus->IsCreatureEligible(creatureTarget)) { return true; } @@ -331,12 +334,16 @@ int32 MythicPlus::ScaleDamageSpell(SpellInfo const * spellInfo, uint32 damage, M MpInstanceData *instanceData = sMpDataStore->GetInstanceData(creature->GetMapId(), creature->GetInstanceId()); int32 spellBonus = sMpDataStore->GetSpellScaleFactor(creature->GetMapId(), instanceData->difficulty); if(creature->IsDungeonBoss()) { - spellBonus *= 1.25; + spellBonus *= 1.15; } - // since we are using logrithmic operation divide the level by the original level + // Calculate the level difference + float levelDifference = creature->GetLevel() - originalLevel; - float scalingFactor = pow(float((creature->GetLevel() - originalLevel) / 10.0f ), float(spellBonus) / 5.0f); + // New formula with adjusted divisor for smoother scaling + float scalingFactor = 1 + (std::log2(levelDifference + 1) * (float(spellBonus) / 10.0f)); + + // float scalingFactor = pow(float((creature->GetLevel() - originalLevel) / 10.0f ), float(spellBonus) / 5.0f); MpLogger::debug("Creature {} original level: {} New Level{} and Scaling level {}", creature->GetName(), originalLevel, creature->GetLevel(), scalingFactor); int32 totalDamage = 0;