summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-01 12:14:06 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-01 12:14:06 +0000
commit5524938f8650e659b3c838df44212de56bf72584 (patch)
tree9696c2ef858b4ebd81eda804389f8ece788a994b /src/map/mob.c
parent3bba210cc5151bfc2971be296ab5c4391ea28639 (diff)
downloadhercules-5524938f8650e659b3c838df44212de56bf72584.tar.gz
hercules-5524938f8650e659b3c838df44212de56bf72584.tar.bz2
hercules-5524938f8650e659b3c838df44212de56bf72584.tar.xz
hercules-5524938f8650e659b3c838df44212de56bf72584.zip
Implemented get_percentage() for compact and safe calculation of percentual values.
Fixed integer arithmetic overflows that were occuring in several supernovice checks (bugreport:1135). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12679 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index a7fc4a783..7278ea043 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2688,7 +2688,7 @@ int mob_class_change (struct mob_data *md, int class_)
if (md->class_ == class_)
return 0; //Nothing to change.
- hp_rate = status_calc_life(md->status.hp, md->status.max_hp);
+ hp_rate = percent(md->status.hp, md->status.max_hp);
md->class_ = class_;
md->db = mob_db(class_);
if (battle_config.override_mob_names==1)
@@ -2823,7 +2823,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,int skill_id)
if (!battle_config.monster_class_change_recover &&
(skill_id == NPC_TRANSFORMATION || skill_id == NPC_METAMORPHOSIS))
- hp_rate = status_calc_life(md2->status.hp, md2->status.max_hp);
+ hp_rate = percent(md2->status.hp, md2->status.max_hp);
for(;k<amount;k++) {
short x,y;
@@ -2927,7 +2927,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap)
if (battle_check_target(&md->bl,bl,BCT_ENEMY)>0)
return 0;
- rate = status_calc_life(status_get_hp(bl), status_get_max_hp(bl));
+ rate = percent(status_get_hp(bl), status_get_max_hp(bl));
if (rate >= min_rate && rate <= max_rate)
(*fr) = bl;
@@ -2954,7 +2954,7 @@ struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int rate)
if( md && md->master_id > 0 )
{
struct block_list *bl = map_id2bl(md->master_id);
- if( bl && status_calc_life(status_get_hp(bl), status_get_max_hp(bl)) < rate )
+ if( bl && percent(status_get_hp(bl), status_get_max_hp(bl)) < rate )
return bl;
}
@@ -3060,11 +3060,11 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
case MSC_ALWAYS:
flag = 1; break;
case MSC_MYHPLTMAXRATE: // HP< maxhp%
- flag = status_calc_life(md->status.hp, md->status.max_hp);
+ flag = percent(md->status.hp, md->status.max_hp);
flag = (flag <= c2);
break;
case MSC_MYHPINRATE:
- flag = status_calc_life(md->status.hp, md->status.max_hp);
+ flag = percent(md->status.hp, md->status.max_hp);
flag = (flag >= c2 && flag <= ms[i].val[0]);
break;
case MSC_MYSTATUSON: // status[num] on