summaryrefslogtreecommitdiff
path: root/src/map/status.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-21 10:36:26 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-21 10:36:26 +0000
commitc6b0361bd56ee72df8b9b3ee7eca824e0619d407 (patch)
tree8a178d1eff82e4329685dd8130c9b2364412ce4f /src/map/status.c
parent095fe33b1d22e4bc821847b968ac508a983ae50b (diff)
downloadhercules-c6b0361bd56ee72df8b9b3ee7eca824e0619d407.tar.gz
hercules-c6b0361bd56ee72df8b9b3ee7eca824e0619d407.tar.bz2
hercules-c6b0361bd56ee72df8b9b3ee7eca824e0619d407.tar.xz
hercules-c6b0361bd56ee72df8b9b3ee7eca824e0619d407.zip
- 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
Diffstat (limited to 'src/map/status.c')
-rw-r--r--src/map/status.c17
1 files changed, 13 insertions, 4 deletions
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;