summaryrefslogtreecommitdiff
path: root/src/map/status.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-24 14:49:16 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-24 14:49:16 +0000
commit84f83d1034146b36bb3855ef654548f0802093a3 (patch)
tree2f5bf8df97f6556570b7ccdf7baeea0db697c4f4 /src/map/status.c
parent73e0a442e9e9b2366ad68301c2969334d8020738 (diff)
downloadhercules-84f83d1034146b36bb3855ef654548f0802093a3.tar.gz
hercules-84f83d1034146b36bb3855ef654548f0802093a3.tar.bz2
hercules-84f83d1034146b36bb3855ef654548f0802093a3.tar.xz
hercules-84f83d1034146b36bb3855ef654548f0802093a3.zip
- Added setting clear_skills_on_warp to specify when a character's land-based skills are deleted when the caster changes maps. Defaults to all types.
- Should have fixed Brandish Spear not passing the flag to skill_attack, causing it to do miserable damage. - Warp Portal will no longer be removed when caster steps through it (this is left to the new clear_skills_on_warp setting) - Cleaned up status_percent_change to switch equations when the target has high hp to prevent overflows, also it will directly take hp/maxhp when a rate of 100 or higher is passed to prevent calculations. - Traps and Land Elemental fields are no longer automatically removed on map change (handled now by clear_skills_on_warp) - traps_setting &2 no longer does anything (handled now by blah blah) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8469 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/status.c')
-rw-r--r--src/map/status.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/map/status.c b/src/map/status.c
index f4fcf32a2..38a9d382d 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -812,16 +812,34 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe
unsigned int hp =0, sp = 0;
status = status_get_status_data(target);
-
- if (hp_rate > 0)
- hp = (hp_rate*status->hp)/100;
+
+ //Change the equation when the values are high enough to discard the
+ //imprecision in exchange of overflow protection [Skotlex]
+ //Also add 100% checks since those are the most used cases where we don't
+ //want aproximation errors.
+ if (hp_rate > 99)
+ hp = status->hp;
+ else if (hp_rate > 0)
+ hp = status->hp>10000?
+ hp_rate*(status->hp/100):
+ (hp_rate*status->hp)/100;
+ else if (hp_rate < -99)
+ hp = status->max_hp;
else if (hp_rate < 0)
- hp = (-hp_rate)*status->max_hp/100;
+ hp = status->max_hp>10000?
+ (-hp_rate)*(status->max_hp/100):
+ (-hp_rate*status->max_hp)/100;
if (hp_rate && !hp)
hp = 1;
- if (sp_rate > 0)
+ //Should be safe to not do overflow protection here, noone should have
+ //millions upon millions of SP
+ if (sp_rate > 99)
+ sp = status->sp;
+ else if (sp_rate > 0)
sp = (sp_rate*status->sp)/100;
+ else if (sp_rate < -99)
+ sp = status->max_sp;
else if (sp_rate < 0)
sp = (-sp_rate)*status->max_sp/100;
if (sp_rate && !sp)