summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2024-07-23 22:57:52 -0300
committerJesusaves <cpntb1@ymail.com>2024-07-23 22:57:52 -0300
commit3f05f8aad14df24a7712cc88e1f8a5d4e524f486 (patch)
tree0bd19980ac623f5bd69297ac0d9c6be786eaca33
parentb0a33af03feb7372d6b4dfe910d32dc6d1b8cfff (diff)
downloadevol-hercules-3f05f8aad14df24a7712cc88e1f8a5d4e524f486.tar.gz
evol-hercules-3f05f8aad14df24a7712cc88e1f8a5d4e524f486.tar.bz2
evol-hercules-3f05f8aad14df24a7712cc88e1f8a5d4e524f486.tar.xz
evol-hercules-3f05f8aad14df24a7712cc88e1f8a5d4e524f486.zip
Dead Homunculus now only receive half of the experience
-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;
}