Welcome to the Builder Academy

Question bug in damage multiplier - Position

More
01 Feb 2018 03:08 - 01 Feb 2018 03:09 #7494 by cunning
After several complaints on my mud about not getting the damage multiplier when using bash or some other skill that sets the mob to a position other than fighting. I logged the crap out of it to find that we are using an integer based formula that really requires a floating one.

In fight.c line 881
Code:
/* Include a damage multiplier if victim isn't ready to fight: * Position sitting 1.33 x normal * Position resting 1.66 x normal * Position sleeping 2.00 x normal * Position stunned 2.33 x normal * Position incap 2.66 x normal * Position mortally 3.00 x normal * Note, this is a hack because it depends on the particular * values of the POSITION_XXX constants. */ if (GET_POS(victim) < POS_FIGHTING) dam *= 1 + (POS_FIGHTING - GET_POS(victim)) / 3;

dam is an integer which is getting rounded down. In this case if GET_POS is Sitting, we have POS-FIGHT - POS-SIT = 1

Now we have 1+ (1/3) - but since this is an integer it gets rounded down. Now we have dam *= 1.

an Excerpt from my logging:
DAMAGE: name = the Statue of Obi-wan Kenobi, Multiplier pre: 53, pos - Resting
Jan 31 21:42:50 2018 :: DAMAGE = 53
Jan 31 21:42:50 2018 :: DAMAGE = 53
Jan 31 21:42:50 2018 :: DAMAGE: name = the Statue of Obi-wan Kenobi, Mutiplier post: 53 pos - Resting

I have changed the formula to
Code:
if (GET_POS(victim) < POS_FIGHTING) dam = (float)dam * (1.0f+((float)(POS_FIGHTING - GET_POS(victim)))/3.0f);


and now you get:

DAMAGE: name = the Statue of Obi-wan Kenobi, Multiplier pre: 53, pos - Resting
DAMAGE = 53
DAMAGE = 88
DAMAGE: name = the Statue of Obi-wan Kenobi, Mutiplier post: 88 pos - Resting
Last edit: 01 Feb 2018 03:09 by cunning.
The following user(s) said Thank You: thomas, Fizban, WhiskyTest

Please Log in or Create an account to join the conversation.

Time to create page: 0.186 seconds