summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emap/homunculus.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/emap/homunculus.c b/src/emap/homunculus.c
index c51a24c..fdf0b9d 100644
--- a/src/emap/homunculus.c
+++ b/src/emap/homunculus.c
@@ -2,6 +2,7 @@
// Copyright (c) 2014 - 2015 Evol developers
#include "common/hercules.h"
+#include "map/status.h"
#include "map/homunculus.h"
#include <stdio.h>
@@ -10,6 +11,7 @@
#include "common/HPMi.h"
#include "common/nullpo.h"
+#include "plugins/HPMHooking.h"
#include "emap/send.h"
@@ -20,7 +22,22 @@ int ehomunculus_gainexp_pre(struct homun_data **hdPtr,
nullpo_ret(hd);
const int exp = *expPtr;
- if (hd->homunculus.vaporize == HOM_ST_ACTIVE)
+ // Handle some cases when EXP is not due
+ if (hd->homunculus.vaporize != HOM_ST_ACTIVE) {
+ // Homunculus is not active, so do nothing
+ hookStop();
+ return 1;
+ } else if (!status->isdead(&hd->bl)) {
+ // Homunculus is active and alive, inform M+ of the EXP gain
send_homun_exp(hd, exp);
+ } else if (exp > 1) {
+ // Homunculus is dead, so give only half the EXP
+ send_homun_exp(hd, exp/2);
+ *expPtr = exp / 2;
+ } else {
+ // Homunculus is dead and the exp to receive is zero
+ hookStop();
+ return 1;
+ }
return 0;
}