summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-04-14 07:49:24 +0200
committerKenpachi Developer <Kenpachi.Developer@gmx.de>2020-04-14 07:49:24 +0200
commitc475c1eb2077fa9178561f9ea11c360285d432ee (patch)
tree60c34f13f2a6b84d6640155f28c53818eded2352
parent3d06abbc3b917b2ce1df8245a5856904e7e1fd53 (diff)
downloadhercules-c475c1eb2077fa9178561f9ea11c360285d432ee.tar.gz
hercules-c475c1eb2077fa9178561f9ea11c360285d432ee.tar.bz2
hercules-c475c1eb2077fa9178561f9ea11c360285d432ee.tar.xz
hercules-c475c1eb2077fa9178561f9ea11c360285d432ee.zip
Adjust mob_getfriendstatus() to consider characters as friends for summoned monsters like mob_getfriendhprate() does
-rw-r--r--src/map/mob.c42
-rw-r--r--src/map/mob.h2
-rw-r--r--src/plugins/HPMHooking/HPMHooking.Defs.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc8
4 files changed, 30 insertions, 26 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 51a32abd9..5a20c20d2 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -3393,42 +3393,49 @@ static struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md, int rate
static int mob_getfriendstatus_sub(struct block_list *bl, va_list ap)
{
int cond1,cond2;
- struct mob_data **fr = NULL, *md = NULL, *mmd = NULL;
+ struct block_list **fr = NULL;
+ struct mob_data *md = NULL;
int flag=0;
nullpo_ret(bl);
- Assert_ret(bl->type == BL_MOB);
- md = BL_UCAST(BL_MOB, bl);
- nullpo_ret(mmd=va_arg(ap,struct mob_data *));
+ nullpo_ret(md = va_arg(ap, struct mob_data *));
- if( mmd->bl.id == bl->id && !(battle_config.mob_ai&0x10) )
+ if (md->bl.id == bl->id && (battle_config.mob_ai & 0x10) == 0)
return 0;
- if (battle->check_target(&mmd->bl,bl,BCT_ENEMY)>0)
+ if (battle->check_target(&md->bl, bl, BCT_ENEMY) > 0)
return 0;
cond1=va_arg(ap,int);
cond2=va_arg(ap,int);
- fr=va_arg(ap,struct mob_data **);
+ fr = va_arg(ap, struct block_list **);
+
+ if ((*fr) != NULL) // A friend was already found.
+ return 0;
+
+ struct status_change *sc = status->get_sc(bl);
+
if( cond2==-1 ){
int j;
for(j=SC_COMMON_MIN;j<=SC_COMMON_MAX && !flag;j++){
- if ((flag=(md->sc.data[j] != NULL))) //Once an effect was found, break out. [Skotlex]
+ if ((flag = (sc->data[j] != NULL)) != 0) // Once an effect was found, break out. [Skotlex]
break;
}
}else
- flag=( md->sc.data[cond2] != NULL );
+ flag = (sc->data[cond2] != NULL);
if( flag^( cond1==MSC_FRIENDSTATUSOFF ) )
- (*fr)=md;
+ (*fr) = bl;
return 0;
}
-static struct mob_data *mob_getfriendstatus(struct mob_data *md, int cond1, int cond2)
+static struct block_list *mob_getfriendstatus(struct mob_data *md, int cond1, int cond2)
{
- struct mob_data* fr = NULL;
+ struct block_list *fr = NULL;
nullpo_ret(md);
- map->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr);
+ int type = (md->special_state.ai != AI_NONE) ? BL_PC : BL_MOB;
+
+ map->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8, type, md, cond1, cond2, &fr);
return fr;
}
@@ -3440,7 +3447,6 @@ static int mobskill_use(struct mob_data *md, int64 tick, int event)
struct mob_skill *ms;
struct block_list *fbl = NULL; //Friend bl, which can either be a BL_PC or BL_MOB depending on the situation. [Skotlex]
struct block_list *bl;
- struct mob_data *fmd = NULL;
int i,j,n;
nullpo_ret(md);
@@ -3512,7 +3518,8 @@ static int mobskill_use(struct mob_data *md, int64 tick, int event)
flag = ((fbl = mob->getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break;
case MSC_FRIENDSTATUSON: // friend status[num] on
case MSC_FRIENDSTATUSOFF: // friend status[num] off
- flag = ((fmd = mob->getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break;
+ flag = ((fbl = mob->getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL);
+ break;
case MSC_SLAVELT: // slave < num
flag = (mob->countslave(&md->bl) < c2 ); break;
case MSC_ATTACKPCGT: // attack pc > num
@@ -3564,7 +3571,7 @@ static int mobskill_use(struct mob_data *md, int64 tick, int event)
break;
FALLTHROUGH
case MST_FRIEND:
- bl = fbl?fbl:(fmd?&fmd->bl:&md->bl);
+ bl = (fbl != NULL) ? fbl : &md->bl;
break;
default:
bl = &md->bl;
@@ -3610,9 +3617,6 @@ static int mobskill_use(struct mob_data *md, int64 tick, int event)
if (fbl) {
bl = fbl;
break;
- } else if (fmd) {
- bl = &fmd->bl;
- break;
} // else fall through
FALLTHROUGH
default:
diff --git a/src/map/mob.h b/src/map/mob.h
index 577e4db91..6ad1ce705 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -573,7 +573,7 @@ struct mob_interface {
struct block_list* (*getfriendhprate) (struct mob_data *md, int min_rate, int max_rate);
struct block_list* (*getmasterhpltmaxrate) (struct mob_data *md, int rate);
int (*getfriendstatus_sub) (struct block_list *bl, va_list ap);
- struct mob_data* (*getfriendstatus) (struct mob_data *md, int cond1, int cond2);
+ struct block_list *(*getfriendstatus) (struct mob_data *md, int cond1, int cond2);
int (*skill_use) (struct mob_data *md, int64 tick, int event);
int (*skill_event) (struct mob_data *md, struct block_list *src, int64 tick, int flag);
int (*is_clone) (int class_);
diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc
index b8aa5ae61..3bd0b7fe6 100644
--- a/src/plugins/HPMHooking/HPMHooking.Defs.inc
+++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc
@@ -5452,8 +5452,8 @@ typedef struct block_list* (*HPMHOOK_pre_mob_getmasterhpltmaxrate) (struct mob_d
typedef struct block_list* (*HPMHOOK_post_mob_getmasterhpltmaxrate) (struct block_list* retVal___, struct mob_data *md, int rate);
typedef int (*HPMHOOK_pre_mob_getfriendstatus_sub) (struct block_list **bl, va_list ap);
typedef int (*HPMHOOK_post_mob_getfriendstatus_sub) (int retVal___, struct block_list *bl, va_list ap);
-typedef struct mob_data* (*HPMHOOK_pre_mob_getfriendstatus) (struct mob_data **md, int *cond1, int *cond2);
-typedef struct mob_data* (*HPMHOOK_post_mob_getfriendstatus) (struct mob_data* retVal___, struct mob_data *md, int cond1, int cond2);
+typedef struct block_list *(*HPMHOOK_pre_mob_getfriendstatus) (struct mob_data **md, int *cond1, int *cond2);
+typedef struct block_list *(*HPMHOOK_post_mob_getfriendstatus) (struct mob_data* retVal___, struct mob_data *md, int cond1, int cond2);
typedef int (*HPMHOOK_pre_mob_skill_use) (struct mob_data **md, int64 *tick, int *event);
typedef int (*HPMHOOK_post_mob_skill_use) (int retVal___, struct mob_data *md, int64 tick, int event);
typedef int (*HPMHOOK_pre_mob_skill_event) (struct mob_data **md, struct block_list **src, int64 *tick, int *flag);
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index 940f96ca2..57351b808 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -53703,11 +53703,11 @@ int HP_mob_getfriendstatus_sub(struct block_list *bl, va_list ap) {
}
return retVal___;
}
-struct mob_data* HP_mob_getfriendstatus(struct mob_data *md, int cond1, int cond2) {
+struct block_list *HP_mob_getfriendstatus(struct mob_data *md, int cond1, int cond2) {
int hIndex = 0;
- struct mob_data* retVal___ = NULL;
+ struct block_list *retVal___ = NULL;
if (HPMHooks.count.HP_mob_getfriendstatus_pre > 0) {
- struct mob_data* (*preHookFunc) (struct mob_data **md, int *cond1, int *cond2);
+ struct block_list *(*preHookFunc) (struct mob_data **md, int *cond1, int *cond2);
*HPMforce_return = false;
for (hIndex = 0; hIndex < HPMHooks.count.HP_mob_getfriendstatus_pre; hIndex++) {
preHookFunc = HPMHooks.list.HP_mob_getfriendstatus_pre[hIndex].func;
@@ -53722,7 +53722,7 @@ struct mob_data* HP_mob_getfriendstatus(struct mob_data *md, int cond1, int cond
retVal___ = HPMHooks.source.mob.getfriendstatus(md, cond1, cond2);
}
if (HPMHooks.count.HP_mob_getfriendstatus_post > 0) {
- struct mob_data* (*postHookFunc) (struct mob_data* retVal___, struct mob_data *md, int cond1, int cond2);
+ struct block_list *(*postHookFunc) (struct block_list *retVal___, struct mob_data *md, int cond1, int cond2);
for (hIndex = 0; hIndex < HPMHooks.count.HP_mob_getfriendstatus_post; hIndex++) {
postHookFunc = HPMHooks.list.HP_mob_getfriendstatus_post[hIndex].func;
retVal___ = postHookFunc(retVal___, md, cond1, cond2);