diff --git a/src/MythicPlus.cpp b/src/MythicPlus.cpp index 6fce105..9782efc 100644 --- a/src/MythicPlus.cpp +++ b/src/MythicPlus.cpp @@ -42,6 +42,37 @@ bool MythicPlus::IsDungeonDisabled(uint32 dungeon) return std::find(disabledDungeons.begin(), disabledDungeons.end(), dungeon) != disabledDungeons.end(); } +bool MythicPlus::EligibleTarget(Unit* target) +{ + if (!target) { + return false; + } + +MpLogger::debug("EligibleTarget: target: {} BOT?{}", target->GetName(), target->IsNPCBot()); + if (target->GetTypeId() == TYPEID_PLAYER) { + return true; + } + + # if defined(MOD_PRESENT_NPCBOTS) + MpLogger::debug("IN BOT DEFINED STUFF: target: {} BOT?{}", target->GetName(), target->IsNPCBot()); + if (target->IsNPCBot()) { + MpLogger::debug("Target {} is an NPC eligible to be smacked hard", target->GetName()); + return true; + } + + if ((target->IsPet() || creature->IsSummon() || creature->IsHunterPet()) && target->GetOwner()->IsNPCBot()) { + return true; + } + # endif + + Creature* creature = target->ToCreature(); + if((creature->IsPet() || creature->IsSummon() || creature->IsHunterPet()) && creature->IsControlledByPlayer()) { + return true; + } + + return false; +} + bool MythicPlus::IsCreatureEligible(Creature* creature) { if (creature->IsDungeonBoss()) { @@ -152,15 +183,19 @@ void MythicPlus::ScaleCreature(uint8 level, Creature* creature, MpMultipliers* m // Scales the creatures hitpoints float healthmod = GetHealthModifier(rank); + // Add some variance to the healthpool so enemies are not all the same + float healthVariation = frand(0.85f, 1.15f); uint32 basehp = uint32(std::ceil(stats->BaseHealth[EXPANSION_WRATH_OF_THE_LICH_KING] * cInfo->ModHealth)); - uint32 health = uint32(basehp * healthmod) * multipliers->health; - + uint32 health = uint32(basehp * healthmod * multipliers->health * healthVariation); creature->SetCreateHealth(health); creature->SetMaxHealth(health); creature->SetHealth(health); creature->ResetPlayerDamageReq(); - creature->SetArmor(stats->GenerateArmor(cInfo) * multipliers->armor); + + // Scale up the armor with some variance also to make some tougher enemies in the mix + uint32 armor = uint32(std::ceil(stats->BaseArmor * cInfo->ModArmor * multipliers->armor)); + creature->SetArmor(armor); // Scales the creatures mana uint32 mana = uint32(std::ceil(stats->BaseMana * cInfo->ModMana)); @@ -187,8 +222,10 @@ void MythicPlus::ScaleCreature(uint8 level, Creature* creature, MpMultipliers* m creature->SetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE, stats->AttackPower * multipliers->melee); creature->SetModifierValue(UNIT_MOD_ATTACK_POWER_RANGED, BASE_VALUE, stats->RangedAttackPower * multipliers->melee); MpLogger::debug("Scaled creature base damage from {} to {}", weaponBaseMinDamage, weaponBaseMaxDamage); + creature->UpdateAllStats(); MpLogger::debug("Scaled creature reported base damage from {} to {}", creature->GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE), creature->GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE)); + } /** diff --git a/src/MythicPlus.h b/src/MythicPlus.h index ae8b522..655814d 100644 --- a/src/MythicPlus.h +++ b/src/MythicPlus.h @@ -61,6 +61,9 @@ public: // if configuration has disabled the specific dungeon return false bool IsDungeonDisabled(uint32 dungeonId); + // Validates if the target of an attack should receive mythic+ damage/heal/dot scaling + bool EligibleTarget(Unit* target); + // The creature should be given Mythic+ scaling and powers check for pets, npcs, etc bool IsCreatureEligible(Creature* creature); @@ -90,6 +93,7 @@ public: }; float GetHealthModifier(int32 rank); +float GetDamageModifier(int32 rank); #define sMythicPlus MythicPlus::instance() diff --git a/src/UnitScript.cpp b/src/UnitScript.cpp index 54d9080..dd25727 100644 --- a/src/UnitScript.cpp +++ b/src/UnitScript.cpp @@ -62,18 +62,23 @@ public: void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage) override { + if (!target && !attacker) { + return; + } + Map *map = target->GetMap(); if(!sMythicPlus->IsMapEligible(map)) { return; } - MpLogger::debug("ModifyMeleeDamage: {} reached for attacker {} attacking {} for {} dmg", map->GetMapName(), attacker->GetName(), target->GetName(), damage); - // 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(sMythicPlus->EligibleTarget(target)) { - MpLogger::debug("ModifyMeleeDamage: {} ", creature->GetName()); + if (!attacker->GetTypeId() == TYPEID_UNIT) { + return; + } + + Creature* creature = attacker->ToCreature(); if(!creature || !sMythicPlus->IsCreatureEligible(creature)) { return; } @@ -85,12 +90,11 @@ public: auto origDamage = damage; if(creature->IsDungeonBoss()) { - damage = damage * instanceData->boss.melee * 10; + damage = damage * instanceData->boss.melee * 5; } else { - damage = damage * instanceData->creature.melee * 10 ; + damage = damage * instanceData->creature.melee; } - - MpLogger::debug("ModifyMeleeDamage: from {} to {} ", damage); + // MpLogger::debug("ModifyMeleeDamage: from {} to {}); ", origDamage, damage); } } @@ -130,6 +134,21 @@ public: // } }; + +bool EligibleTarget(Unit* target, Unit* attacker) { + if (!target && !attacker) { + return false; + } + + #define NPCBots + + if (target->GetTypeId() == TYPEID_PLAYER && attacker->GetTypeId() == TYPEID_UNIT) { + return true; + } + + return false; +} + void Add_MP_UnitScripts() { new MythicPlus_UnitScript();