ID:169795
 

Jiskuha attacks G for 25 damage
G attacks Jiskuha for -20 damage


mob/Enemies
Click(mob/M)
if(src in view(1))
var/damage=Strength+Experience/Luck+Agility*Dexterity
view()<<"[usr] attacks [src] for [damage] damage"
src.Strength-=damage
var/edamage=src.Strength*src.Agility
view()<<"[src] attacks [usr] for [edamage] damage"
usr.Strength-=edamage
G
icon='G.dmi'
density=1
Strength=15
Agility=2


See the problem? 15*2 is 30, Why in gods name is it displaying -20?

~>Jiskuha
src.Strength-=damage
In response to DeathAwaitsU
What...? That is already in there.

~>Jiskuha
In response to Jiskuha
Okay, your subtracting the strength by the damage. So src.strength = 4; src.strength-=damage;damage=5; strength=-1

4-5 becomes negative. 5-4 is positive.
In response to Lalibo
Or in terms of what he's got there:

Strength = 15

Damage = 25 (notice you use the strength var there)

strength -= Damage (you decide to subtract 25 from strength(15-25), so strength = -10)

Edamage - strength(-10) * 2

G will atack for -20.
Jiskuha wrote:
var/damage=Strength+Experience/Luck+Agility*Dexterity

Just a question here: The luckier you are, the less damage you inflict?


/Gazoot
In response to Gazoot
Perhaps luck is inverse. If you're normal (say, 5 luck), you get some reduction in damage. If you're lucky (say, 2 luck), your reduction is much less. If you're cursed (9 luck!), your damage reduction is crippling.
In response to PirateHead
Yes, PirateHead is correct on this subject. Thats how my system is setup. High number = bad, Low = Good. In luck, anyways.

~>Jiskuha
In response to Jiskuha
Jiskuha wrote:
Yes, PirateHead is correct on this subject. Thats how my system is setup. High number = bad, Low = Good. In luck, anyways.

Funny way to calculate it, but ok. What's the range of the stats?


/Gazoot
In response to Gazoot
The solution is rather simple, I believe.
finalDamage = max(round(damage, 1), 0)

Make that '0' a '1', and they will always inflict at least one in damage.
Brackets. It's evaluating like this, I bet:

Strength + (Experience / Luck) + (Agility * Dexterity)


Its strength is -10 when it attacks back.

Furthermore, you want to usr usr in the damage calculation.
In response to Jp
Jp wrote:
Brackets. It's evaluating like this, I bet:

> Strength + (Experience / Luck) + (Agility * Dexterity)
>


Division and multiplication have higher precedence than addition and subtraction, so that's not it. Brackets are redundant in this case.


/Gazoot