From c6b0361bd56ee72df8b9b3ee7eca824e0619d407 Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 21 Feb 2008 10:36:26 +0000 Subject: - Added status_calc_life to properly calculate hp/max_hp as a ratio taking into accounts overflows (and for now also avoids divisions by 0). Applied this function around clif.c, mob.c and pet.c - Implemented the correct walk-speed bonus from the Bard/Dancer spirit. - Added a few error messages in case something goes wrong in the new auth db system. - Fixed logarithmic drops turning 0% drop rates into 100%. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12225 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/status.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/map/status.c') diff --git a/src/map/status.c b/src/map/status.c index 10129129a..f7e3157bf 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -951,6 +951,17 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per } return 1; } + +//calculates the base/max ratio as a value between 0->100 (percent), using +//different approaches to avoid overflows. +//NOTE: The -1 case (0 max hp) should never trigger! +char status_calc_life(unsigned int base, unsigned int max) +{ + if (!max) return -1; + if (max < 10000) return 100*base/max; + return base/(max/100); +} + /*========================================== * Checks whether the src can use the skill on the target, * taking into account status/option of both source/target. [Skotlex] @@ -5173,11 +5184,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val clif_status_change(bl,SI_MOONLIT,1); val1|= (val3<<16); val3 = 0; //Tick duration/Speed penalty. - if (sd) { //Store walk speed change in lower part of val3 + //Store walk speed change in lower part of val3 + if (sd && !(sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_BARDDANCER)) val3 = 500-40*pc_checkskill(sd,(sd->status.sex?BA_MUSICALLESSON:DC_DANCINGLESSON)); - if (sc->data[SC_SPIRIT] && sc->data[SC_SPIRIT]->val2 == SL_BARDDANCER) - val3 -= 40; //TODO: Figure out real bonus rate. - } val3|= ((tick/1000)<<16)&0xFFFF0000; //Store tick in upper part of val3 tick = 1000; break; -- cgit v1.2.3-70-g09d2