Skip to main content
add parenthesis to make it even more clear they only differ by sign
Source Link
RobH
  • 17.1k
  • 6
  • 38
  • 73

I might be missing something but why do you need your ModificationType at all? Let's look at your maths here:

value * (1.0f + (Get(type) / 100f))
value - ((value * (Get(type) / 100f)))

Let's define value as v and (Get(type) / 100f) as r.

v*(1+r) // Increase
v-(v*r) // Decrease

Rearranging your top formula gives you:

v+v*rv+(v*r) // Increase

Which means your increase and decrease functions are the same apart from the sign (which is what you'd expect).

I think you can drop the ModificationType and instead have a range of -100 to 100 for the modification value.

I might be missing something but why do you need your ModificationType at all? Let's look at your maths here:

value * (1.0f + (Get(type) / 100f))
value - ((value * (Get(type) / 100f)))

Let's define value as v and (Get(type) / 100f) as r.

v*(1+r) // Increase
v-(v*r) // Decrease

Rearranging your top formula gives you:

v+v*r // Increase

Which means your increase and decrease functions are the same apart from the sign (which is what you'd expect).

I think you can drop the ModificationType and instead have a range of -100 to 100 for the modification value.

I might be missing something but why do you need your ModificationType at all? Let's look at your maths here:

value * (1.0f + (Get(type) / 100f))
value - ((value * (Get(type) / 100f)))

Let's define value as v and (Get(type) / 100f) as r.

v*(1+r) // Increase
v-(v*r) // Decrease

Rearranging your top formula gives you:

v+(v*r) // Increase

Which means your increase and decrease functions are the same apart from the sign (which is what you'd expect).

I think you can drop the ModificationType and instead have a range of -100 to 100 for the modification value.

Source Link
RobH
  • 17.1k
  • 6
  • 38
  • 73

I might be missing something but why do you need your ModificationType at all? Let's look at your maths here:

value * (1.0f + (Get(type) / 100f))
value - ((value * (Get(type) / 100f)))

Let's define value as v and (Get(type) / 100f) as r.

v*(1+r) // Increase
v-(v*r) // Decrease

Rearranging your top formula gives you:

v+v*r // Increase

Which means your increase and decrease functions are the same apart from the sign (which is what you'd expect).

I think you can drop the ModificationType and instead have a range of -100 to 100 for the modification value.