Praytic/youtd2

Sign of energy infusion not compatible with original game

Closed this issue · 1 comments

The current state of Sign of energy infusion:

# NOTE: original script multiplies damage by (2.0 +
# regen). In original youtd, regen value starts at
# 0.0. In youtd2 regen starts at 1.0. So in original
# game damage was multiplied by 2.0 as baseline?
# Changed it to mutiply by 1.0 or above, so that if
# regen is decreased below 100%, damage is not
# decreased.
event.damage *= max(1.0, regen)

It seems that in original YouTD it had an initial bonus of +100% accounting for the 'base percentual regen'. So the break down of the formula could be:

a. "1" - accounting for the base factor in multiplication (no mana regen means constant damage)
b. another "1" - accounting for the base mana regen of 100% that probably all towers possess - which will account for value of "2" by default
c. "C.getProp_ManaRegPercBonus()" as bonus percentage of mana regen

Current formula in this project seems to merge factors b and c together due to how percentage mana regen properties are stored (starting at 1.0, I assume):

var regen: float = carrier.get_base_mana_regen_bonus_percent()

However, factor "a" seems to be left out. If original behaviour is desired "regen+1.0" should probably be used. Otherwise, it might be a balancing factor not to use "+1" so that Sign of energy infusion starts at 0% bonus every 5 hits for a default tower instead of 100% bonus.

The other part of the formula - the call to the max function with argument "1.0": "max(1.0, ...); also alternates the gameplay/balance by removing the downside of lowered mana regen while using the item i.e. zombie hand item, barbarian warlord builder or mana drain aura creeps:

modifier.add_modification(Modification.Type.MOD_MANA_REGEN_PERC, -2.0, 0.0)
slow_aura_effect.set_buff_modifier(modifier)
slow_aura_effect.set_buff_tooltip("Drain Gang\nDrains mana and reduces mana regeneration.")

Argument of "0.0" in the max function should fix most inconsistencies (I believe) - it will allow damage penalty based on negative mana regen up to 0 damage dealt every 5th hit, while preventing negative damage (not sure if negative damage was possible in original YouTD though or in YouTD2).

So, to mimic the behaviour and balance of original game I'd suggest formula of:
event.damage *= max(0.0, regen+1.0)
with the assumption that no intentional balancing was done here.

There are two points here:

  1. How does this item affect damage when tower has no "mana regen %" bonuses (+0%)?
  2. How does this item affect damage when tower has negative "mana regen %" stat (-50% for example?

Point 1

  • Original game: damage is multiplied by 2.0
  • Youtd2: damage is multiplied by 1.0, no change

This change was intentional, done in this commit: 14acd33
The reason for the change was that I didn't understand why item "increased damage by its percentual mana regeneration" would multiply damage by 2.0 by default. To me, it looked like item behavior didn't match item description.

I thought about it more now and it appears that original behavior does match the item description, even if it's confusing.

the damage is increased by its percentual mana regeneration.

The key here is that description talks about "percentual mana regeneration" stat, which is not the same as "percentual mana regen bonus" stat.

  • "percentual mana regen bonus" starts at +0%
  • "percentual mana regeneration" starts at 100%. This is in terms of gameplay logic, values in code are not important here.

Therefore it makes sense that:

  1. the damage is increased by its percentual mana regeneration
  2. "Percentual mana regeneration" is 100% by default
  3. Damage is increased by 100% by default
  4. Damage is multiplied by 2.0 by default

Point 2

  • Original game: damage is reduced
  • Youtd2: damage is not reduced, no change to damage

I changed this on purpose some time ago because I felt that this item reducing damage would be unfair but I guess it is better to keep it like in original game. The interaction of mana regen debuffs with this item is neat.

In summary, both suggested changes make sense to me. Suggested formula also looks correct.