diff --git a/conf/trialofstrength.conf.dist b/conf/trialofstrength.conf.dist index 378ca04..de7e708 100644 --- a/conf/trialofstrength.conf.dist +++ b/conf/trialofstrength.conf.dist @@ -71,41 +71,60 @@ TrialOfStrength.Scaling.RewardMoneyScalar = 50 TrialOfStrength.Scaling.RewardMoney = 1 # -# TrialOfStrength.Scaling.BaseDamage.Physical -# Description: Controls the base damage of creatures physical damage in the Trial of Strength waves. -# Note: The formula for the damage is: baseDamage * (1.0f + (float(currentWave) / float(damageDivider))); -# The damage range is calculated as: damage = urand(newDamage / 2, newDamage); -# Default: 500 +# TrialOfStrength.AutoScaling (EXPERIMENTAL) +# Description: Enable/disable auto scaling for the wave creatures level, health and damage. +# Note: Disable this if you want to use your own custom npcs so they don't get auto-scaled. +# Default: 0 - Disabled +# 1 - Enabled # -TrialOfStrength.Scaling.BaseDamage.Physical = 500 +TrialOfStrength.AutoScaling = 0 # -# TrialOfStrength.Scaling.BaseDamage.PhysicalDivider -# Description: Controls the base damage divider of creatures physical damage in the Trial of Strength waves. -# Note: The formula for the damage is: baseDamage * (1.0f + (float(currentWave) / float(damageDivider))); +# TrialOfStrength.AutoScaling.BaseHealth +# Description: Controls the base health of creatures in the Trial of Strength waves. +# Note: The formula for the health is: baseHealth * (1.0f + (float(currentWave) / float(healthDivider))); +# Default: 8000 +# + +TrialOfStrength.AutoScaling.BaseHealth = 8000 + +# +# TrialOfStrength.AutoScaling.HealthDivider +# Description: Controls the base health divider of creatures in the Trial of Strength waves. +# Note: The formula for the health is: baseHealth * (1.0f + (float(currentWave) / float(healthDivider))); # Increasing/decreasing the value of this setting will change the difficulty between waves. # Default: 15 # -TrialOfStrength.Scaling.BaseDamage.PhysicalDivider = 15 +TrialOfStrength.AutoScaling.HealthDivider = 15 # -# TrialOfStrength.Scaling.BaseDamage.Spell -# Description: Controls the base damage of creatures spell damage in the Trial of Strength waves. +# TrialOfStrength.AutoScaling.BaseDamage.Physical +# Description: Controls the base damage of creatures physical damage in the Trial of Strength waves. # Note: The formula for the damage is: baseDamage * (1.0f + (float(currentWave) / float(damageDivider))); # The damage range is calculated as: damage = urand(newDamage / 2, newDamage); -# Default: 2000 +# Default: 500 +# + +TrialOfStrength.AutoScaling.BaseDamage.Physical = 500 + +# +# TrialOfStrength.AutoScaling.BaseDamage.PhysicalDivider +# Description: Controls the base damage divider of creatures physical damage in the Trial of Strength waves. +# Note: The formula for the damage is: baseDamage * (1.0f + (float(currentWave) / float(damageDivider))); +# Increasing/decreasing the value of this setting will change the difficulty between waves. +# Default: 15 # -TrialOfStrength.Scaling.BaseDamage.Spell = 2000 +TrialOfStrength.AutoScaling.BaseDamage.PhysicalDivider = 15 # -# TrialOfStrength.Scaling.BaseDamage.SpellDivider +# TrialOfStrength.AutoScaling.BaseDamage.SpellDivider # Description: Controls the base damage divider of creatures spell damage in the Trial of Strength waves. # Note: The formula for the damage is: baseDamage * (1.0f + (float(currentWave) / float(damageDivider))); # Increasing/decreasing the value of this setting will change the difficulty between waves. # Default: 15 # -TrialOfStrength.Scaling.BaseDamage.SpellDivider = 15 \ No newline at end of file +TrialOfStrength.AutoScaling.BaseDamage.SpellDivider = 15 \ No newline at end of file diff --git a/src/scripts/ToSInstanceScript.cpp b/src/scripts/ToSInstanceScript.cpp index b82bd09..f6d72c4 100644 --- a/src/scripts/ToSInstanceScript.cpp +++ b/src/scripts/ToSInstanceScript.cpp @@ -87,14 +87,7 @@ void ToSInstanceScript::SpawnNextWave(ToSWaveTemplate* waveTemplate = nullptr) if(sConfigMgr->GetOption("TrialOfStrength.AutoScaling", true)) { - summon->SetLevel(80, true); - - uint32 baseHP = 8000; - uint32 hpDivider = 15; - float hpMultiplier = (1.0f + (float(currentWave) / float(hpDivider))); - uint32 health = baseHP * hpMultiplier; - summon->SetMaxHealth(health); - summon->SetHealth(health); + ApplyAutoScaling(summon); } ApplyCurses(summon); @@ -102,7 +95,9 @@ void ToSInstanceScript::SpawnNextWave(ToSWaveTemplate* waveTemplate = nullptr) waveCreatures.push_back(summon); if (currentSubGroup == 1) + { summon->SetFaction(FACTION_FRIENDLY); + } summon->CastSpell(summon, TOS_SPELL_TELEPORT_VISUAL); MakeEntrance(summon, diff); @@ -165,6 +160,52 @@ void ToSInstanceScript::ApplyCursesToPlayers() } } +void ToSInstanceScript::ApplyAutoScaling(Creature* creature) +{ + if (!creature) + { + return; + } + + creature->SetLevel(80, true); + + uint32 baseHP = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseHealth", 8000); + uint32 hpDivider = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.HealthDivider", 15); + + float hpMultiplier = (1.0f + (float(currentWave) / float(hpDivider))); + uint32 health = (baseHP * hpMultiplier) * + frand(1.01, 1.02); // Add a tiny bit of variation to the health + + creature->SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, health); + creature->UpdateMaxHealth(); + creature->SetHealth(creature->GetMaxHealth()); + + uint32 basePhys = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseDamage.Physical", 500); + + // Reduce physical damage for mages. + if (creature->getClass() == CLASS_MAGE) + { + basePhys = basePhys / 5; + } + + uint32 physDivider = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseDamage.PhysicalDivider", 15); + + uint32 newPhysDmg = basePhys * (1.0f + (float(currentWave) / float(physDivider))); + + LOG_INFO("module", "Base mainhand: {}, Pct mainhand: {}, AttackPower: {}", creature->GetModifierValue(UNIT_MOD_DAMAGE_MAINHAND, BASE_VALUE), creature->GetModifierValue(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT), creature->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE)); + + // Remove all attack power + creature->HandleStatModifier(UNIT_MOD_ATTACK_POWER, BASE_VALUE, creature->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE), false); + + creature->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, BASE_VALUE, creature->GetModifierValue(UNIT_MOD_DAMAGE_MAINHAND, BASE_VALUE), false); + creature->HandleStatModifier(UNIT_MOD_DAMAGE_MAINHAND, BASE_VALUE, newPhysDmg, true); + + creature->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, BASE_VALUE, creature->GetModifierValue(UNIT_MOD_DAMAGE_OFFHAND, BASE_VALUE), false); + creature->HandleStatModifier(UNIT_MOD_DAMAGE_OFFHAND, BASE_VALUE, newPhysDmg, true); + + LOG_INFO("module", "Base mainhand: {}, Pct mainhand: {}, AttackPower: {}", creature->GetModifierValue(UNIT_MOD_DAMAGE_MAINHAND, BASE_VALUE), creature->GetModifierValue(UNIT_MOD_DAMAGE_MAINHAND, TOTAL_PCT), creature->GetModifierValue(UNIT_MOD_ATTACK_POWER, BASE_VALUE)); +} + void ToSInstanceScript::ClearCursesFromPlayers() { Map::PlayerList const& players = instance->GetPlayers(); @@ -351,10 +392,18 @@ void ToSInstanceScript::SetCombatantsHostile() creature->SetFaction(FACTION_MONSTER); creature->SetInCombatWithZone(); + if (auto minion = creature->GetFirstMinion()) + { + minion->SetFaction(FACTION_MONSTER); + creature->SetInCombatWithZone(); + } + if (auto player = creature->SelectNearestPlayer(100.0f)) { if (creature->Attack(player, true)) + { creature->GetMotionMaster()->MoveChase(player); + } } } } diff --git a/src/scripts/ToSInstanceScript.h b/src/scripts/ToSInstanceScript.h index aaf508b..12eb589 100644 --- a/src/scripts/ToSInstanceScript.h +++ b/src/scripts/ToSInstanceScript.h @@ -55,6 +55,7 @@ class ToSInstanceScript : public InstanceScript void AddCurse(uint32 curseId); void ApplyCurses(Unit* unit); void ApplyCursesToPlayers(); + void ApplyAutoScaling(Creature* creature); void ClearCursesFromPlayers(); void SpawnCurseCrystals(); void DespawnCurseCrystals(); diff --git a/src/scripts/ToSUnitScript.cpp b/src/scripts/ToSUnitScript.cpp index 6ec377f..b07be41 100644 --- a/src/scripts/ToSUnitScript.cpp +++ b/src/scripts/ToSUnitScript.cpp @@ -3,6 +3,11 @@ void ToSUnitScript::OnUnitDeath(Unit* unit, Unit* /*killer*/) { + if (!sConfigMgr->GetOption("TrialOfStrength.Enable", false)) + { + return; + } + if (!unit) { return; @@ -29,64 +34,29 @@ void ToSUnitScript::OnUnitDeath(Unit* unit, Unit* /*killer*/) iScript->SetData(TOS_DATA_ENCOUNTER_UPDATE_INVADERS, 1); } -void ToSUnitScript::ModifyMeleeDamage(Unit* /*target*/, Unit* attacker, uint32& damage) +void ToSUnitScript::ModifySpellDamageTaken(Unit* /*target*/, Unit* attacker, int32& damage, SpellInfo const* /*spellInfo*/) { - if (!attacker) - { - return; - } - - if (attacker->IsPlayer()) - { - return; - } - - if (attacker->GetMapId() != TOS_MAP_ID) - { - return; - } - - auto map = attacker->GetMap(); - if (!map) + if (!sConfigMgr->GetOption("TrialOfStrength.Enable", false)) { return; } - auto instance = map->ToInstanceMap(); - if (!instance) - { - return; - } - - auto iScript = instance->GetInstanceScript(); - if (!iScript) + if (!attacker) { return; } - uint32 currentWave = iScript->GetData(TOS_DATA_ENCOUNTER_CURRENT_WAVE); - - uint32 baseDamage = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseDamage.Physical", 500); - uint32 damageDivider = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseDamage.PhysicalDivider", 15);; - - uint32 newDamage = baseDamage * (1.0f + (float(currentWave) / float(damageDivider))); - - damage = urand(newDamage / 2, newDamage); -} - -void ToSUnitScript::ModifySpellDamageTaken(Unit* /*target*/, Unit* attacker, int32& damage, SpellInfo const* /*spellInfo*/) -{ - if (!attacker) + if (attacker->IsPlayer()) { return; } - if (attacker->IsPlayer()) + if (attacker->GetMapId() != TOS_MAP_ID) { return; } - if (attacker->GetMapId() != TOS_MAP_ID) + if (!sConfigMgr->GetOption("TrialOfStrength.AutoScaling", true)) { return; } @@ -109,12 +79,10 @@ void ToSUnitScript::ModifySpellDamageTaken(Unit* /*target*/, Unit* attacker, int return; } - uint32 currentWave = iScript->GetData(TOS_DATA_ENCOUNTER_CURRENT_WAVE); + uint32 originalLevel = attacker->ToCreature()->GetCreatureTemplate()->maxlevel; - uint32 baseDamage = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseDamage.Spell", 2000); - uint32 damageDivider = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseDamage.SpellDivider", 15);; - - uint32 newDamage = baseDamage * (1.0f + (float(currentWave) / float(damageDivider))); + uint32 currentWave = iScript->GetData(TOS_DATA_ENCOUNTER_CURRENT_WAVE); + uint32 damageDivider = sConfigMgr->GetOption("TrialOfStrength.AutoScaling.BaseDamage.SpellDivider", 15); - damage = urand(newDamage / 2, newDamage); + uint32 newDamage = ((damage) * ((83 - originalLevel) / 2) / damageDivider) * currentWave; } diff --git a/src/scripts/ToSUnitScript.h b/src/scripts/ToSUnitScript.h index 22b5414..f4b206e 100644 --- a/src/scripts/ToSUnitScript.h +++ b/src/scripts/ToSUnitScript.h @@ -12,7 +12,6 @@ class ToSUnitScript : public UnitScript void OnUnitDeath(Unit* /*unit*/, Unit* /*killer*/) override; - void ModifyMeleeDamage(Unit* /*target*/, Unit* /*attacker*/, uint32& /*damage*/) override; void ModifySpellDamageTaken(Unit* /*target*/, Unit* /*attacker*/, int32& /*damage*/, SpellInfo const* /*spellInfo*/) override; };