Skip to content

Commit

Permalink
Disable autoscaling by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchyDev committed Mar 9, 2024
1 parent 79442e0 commit bf98ba6
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 72 deletions.
51 changes: 35 additions & 16 deletions conf/trialofstrength.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
TrialOfStrength.AutoScaling.BaseDamage.SpellDivider = 15
65 changes: 57 additions & 8 deletions src/scripts/ToSInstanceScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,17 @@ void ToSInstanceScript::SpawnNextWave(ToSWaveTemplate* waveTemplate = nullptr)

if(sConfigMgr->GetOption<bool>("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);

waveCreatures.push_back(summon);

if (currentSubGroup == 1)
{
summon->SetFaction(FACTION_FRIENDLY);
}

summon->CastSpell(summon, TOS_SPELL_TELEPORT_VISUAL);
MakeEntrance(summon, diff);
Expand Down Expand Up @@ -165,6 +160,52 @@ void ToSInstanceScript::ApplyCursesToPlayers()
}
}

void ToSInstanceScript::ApplyAutoScaling(Creature* creature)
{
if (!creature)
{
return;
}

creature->SetLevel(80, true);

uint32 baseHP = sConfigMgr->GetOption<uint32>("TrialOfStrength.AutoScaling.BaseHealth", 8000);
uint32 hpDivider = sConfigMgr->GetOption<uint32>("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<uint32>("TrialOfStrength.AutoScaling.BaseDamage.Physical", 500);

// Reduce physical damage for mages.
if (creature->getClass() == CLASS_MAGE)
{
basePhys = basePhys / 5;
}

uint32 physDivider = sConfigMgr->GetOption<uint32>("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();
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/scripts/ToSInstanceScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
62 changes: 15 additions & 47 deletions src/scripts/ToSUnitScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

void ToSUnitScript::OnUnitDeath(Unit* unit, Unit* /*killer*/)
{
if (!sConfigMgr->GetOption<bool>("TrialOfStrength.Enable", false))
{
return;
}

if (!unit)
{
return;
Expand All @@ -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<bool>("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<uint32>("TrialOfStrength.AutoScaling.BaseDamage.Physical", 500);
uint32 damageDivider = sConfigMgr->GetOption<uint32>("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<bool>("TrialOfStrength.AutoScaling", true))
{
return;
}
Expand All @@ -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<uint32>("TrialOfStrength.AutoScaling.BaseDamage.Spell", 2000);
uint32 damageDivider = sConfigMgr->GetOption<uint32>("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<uint32>("TrialOfStrength.AutoScaling.BaseDamage.SpellDivider", 15);

damage = urand(newDamage / 2, newDamage);
uint32 newDamage = ((damage) * ((83 - originalLevel) / 2) / damageDivider) * currentWave;
}
1 change: 0 additions & 1 deletion src/scripts/ToSUnitScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit bf98ba6

Please sign in to comment.