Skip to content

Commit

Permalink
Added spell scaling.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchyDev committed Mar 8, 2024
1 parent dfef7f4 commit 6d431a7
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 3 deletions.
42 changes: 41 additions & 1 deletion conf/trialofstrength.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,44 @@ TrialOfStrength.Scaling.RewardMoneyScalar = 50
# Default: 1 - Enabled
#

TrialOfStrength.Scaling.RewardMoney = 1
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.Scaling.BaseDamage.Physical = 500

#
# 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)));
# Increasing/decreasing the value of this setting will change the difficulty between waves.
# Default: 15
#

TrialOfStrength.Scaling.BaseDamage.PhysicalDivider = 15

#
# TrialOfStrength.Scaling.BaseDamage.Spell
# Description: Controls the base damage of creatures spell 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: 1000
#

TrialOfStrength.Scaling.BaseDamage.Spell = 1000

#
# TrialOfStrength.Scaling.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
49 changes: 47 additions & 2 deletions src/scripts/ToSUnitScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,53 @@ void ToSUnitScript::ModifyMeleeDamage(Unit* /*target*/, Unit* attacker, uint32&

uint32 currentWave = iScript->GetData(TOS_DATA_ENCOUNTER_CURRENT_WAVE);

uint32 baseDamage = 500;
uint32 damageDivider = 15;
uint32 baseDamage = sConfigMgr->GetOption<uint32>("TrialOfStrength.Scaling.BaseDamage.Physical", 500);
uint32 damageDivider = sConfigMgr->GetOption<uint32>("TrialOfStrength.Scaling.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)
{
return;
}

if (attacker->IsPlayer())
{
return;
}

if (attacker->GetMapId() != TOS_MAP_ID)
{
return;
}

auto map = attacker->GetMap();
if (!map)
{
return;
}

auto instance = map->ToInstanceMap();
if (!instance)
{
return;
}

auto iScript = instance->GetInstanceScript();
if (!iScript)
{
return;
}

uint32 currentWave = iScript->GetData(TOS_DATA_ENCOUNTER_CURRENT_WAVE);

uint32 baseDamage = sConfigMgr->GetOption<uint32>("TrialOfStrength.Scaling.BaseDamage.Spell", 500);
uint32 damageDivider = sConfigMgr->GetOption<uint32>("TrialOfStrength.Scaling.BaseDamage.SpellDivider", 15);;

uint32 newDamage = baseDamage * (1.0f + (float(currentWave) / float(damageDivider)));

Expand Down
1 change: 1 addition & 0 deletions src/scripts/ToSUnitScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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;
};

#endif // MODULE_TRIAL_OF_STRENGTH_UNIT_SCRIPT_H

0 comments on commit 6d431a7

Please sign in to comment.