summaryrefslogtreecommitdiff
path: root/src/map/status.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-10 22:02:33 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-01-10 22:02:33 +0000
commit234ababd8c1a9df4391c6c54f9167f625e432dc2 (patch)
tree6e7e67c85594893c8aab0730789f36e5c5d4f2ef /src/map/status.c
parentf9e689d36895ff10c03fc3c488da28693636d454 (diff)
downloadhercules-234ababd8c1a9df4391c6c54f9167f625e432dc2.tar.gz
hercules-234ababd8c1a9df4391c6c54f9167f625e432dc2.tar.bz2
hercules-234ababd8c1a9df4391c6c54f9167f625e432dc2.tar.xz
hercules-234ababd8c1a9df4391c6c54f9167f625e432dc2.zip
- Fixed getmonsterinfo to return "null" when returning the name of a non-existing mob instead of -1.
- Extended the status_percent_damage define to include a bolean to specify whether or not the target can be killed from it. - Corrected CR_CULTIVATION to fail when the target cell has some BL_CHAR on it already. - Changed the meaning of 'flag' in status_percent_change, to enable differentiation between damage that can kill the object and damage that cannot. - Script command percentheal will no longer kill the player if the specified amount is negative (and not -100). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12051 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/status.c')
-rw-r--r--src/map/status.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/map/status.c b/src/map/status.c
index 0c06e32b6..768d9fc1d 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -851,7 +851,8 @@ int status_heal(struct block_list *bl,int hp,int sp, int flag)
//no exp/drops will be awarded if there is no src (or src is target)
//If rates are > 0, percent is of current HP/SP
//If rates are < 0, percent is of max HP/SP
-//If flag, this is heal, otherwise it is damage.
+//If !flag, this is heal, otherwise it is damage.
+//Furthermore, if flag==2, then the target must not die from the substraction.
int status_percent_change(struct block_list *src,struct block_list *target,signed char hp_rate, signed char sp_rate, int flag)
{
struct status_data *status;
@@ -878,6 +879,9 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe
if (hp_rate && !hp)
hp = 1;
+ if (flag == 2 && hp >= status->hp)
+ hp = status->hp-1; //Must not kill target.
+
//Should be safe to not do overflow protection here, noone should have
//millions upon millions of SP
if (sp_rate > 99)
@@ -896,19 +900,20 @@ int status_percent_change(struct block_list *src,struct block_list *target,signe
if (hp > INT_MAX) {
hp -= INT_MAX;
if (flag)
- status_heal(target, INT_MAX, 0, 0);
- else
status_damage(src, target, INT_MAX, 0, 0, (!src||src==target?5:1));
+ else
+ status_heal(target, INT_MAX, 0, 0);
}
if (sp > INT_MAX) {
sp -= INT_MAX;
if (flag)
- status_heal(target, 0, INT_MAX, 0);
- else
status_damage(src, target, 0, INT_MAX, 0, (!src||src==target?5:1));
+ else
+ status_heal(target, 0, INT_MAX, 0);
}
- if (flag) return status_heal(target, hp, sp, 0);
- return status_damage(src, target, hp, sp, 0, (!src||src==target?5:1));
+ if (flag)
+ return status_damage(src, target, hp, sp, 0, (!src||src==target?5:1));
+ return status_heal(target, hp, sp, 0);
}
int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp)