// Copyright (c) Copyright (c) Hercules Dev Team, licensed under GNU GPL. // Copyright (c) 2014 - 2015 Evol developers #include "common/hercules.h" #include "map/status.h" #include "map/homunculus.h" #include #include #include #include "common/HPMi.h" #include "common/nullpo.h" #include "plugins/HPMHooking.h" #include "emap/send.h" int ehomunculus_gainexp_pre(struct homun_data **hdPtr, unsigned int *expPtr) { struct homun_data *hd = *hdPtr; nullpo_ret(hd); const int exp = *expPtr; // 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; }