Cleaned up monster skill status checks (#7495)

Fixes 4 more warnings introduced in 1f4c068
This commit is contained in:
Lemongrass3110 2022-12-16 21:56:55 +01:00 committed by GitHub
parent ef602d98cb
commit 4d734abc53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3631,14 +3631,39 @@ struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int64 rate)
return NULL; return NULL;
} }
bool mob_getstatus_sub( struct mob_data& md, e_mob_skill_condition condition, sc_type type ){
bool found = false;
if( type == SC_NONE ){
for( int i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++ ){
if( md.sc.getSCE( i ) != nullptr ){
// Once an effect was found, break out. [Skotlex]
found = true;
break;
}
}
}else{
found = md.sc.getSCE( type ) != nullptr;
}
switch( condition ){
case MSC_MYSTATUSON:
case MSC_FRIENDSTATUSON:
return found;
case MSC_MYSTATUSOFF:
case MSC_FRIENDSTATUSOFF:
return !found;
default:
return false;
}
}
/*========================================== /*==========================================
* What a status state suits by nearby MOB is looked for. * What a status state suits by nearby MOB is looked for.
*------------------------------------------*/ *------------------------------------------*/
int mob_getfriendstatus_sub(struct block_list *bl,va_list ap) int mob_getfriendstatus_sub( struct block_list *bl, va_list ap ){
{ struct mob_data *md, *mmd;
int64 cond1,cond2;
struct mob_data **fr, *md, *mmd;
int flag=0;
nullpo_ret(bl); nullpo_ret(bl);
nullpo_ret(md=(struct mob_data *)bl); nullpo_ret(md=(struct mob_data *)bl);
@ -3649,19 +3674,14 @@ int mob_getfriendstatus_sub(struct block_list *bl,va_list ap)
if (battle_check_target(&mmd->bl,bl,BCT_ENEMY)>0) if (battle_check_target(&mmd->bl,bl,BCT_ENEMY)>0)
return 0; return 0;
cond1=va_arg(ap,int64);
cond2=va_arg(ap,int64); int64 cond1 = va_arg( ap, int64 );
fr=va_arg(ap,struct mob_data **); int64 cond2 = va_arg( ap, int64 );
if( cond2==-1 ){ struct mob_data** fr = va_arg( ap, struct mob_data** );
int j;
for(j=SC_COMMON_MIN;j<=SC_COMMON_MAX && !flag;j++){ if( mob_getstatus_sub( *md, static_cast<e_mob_skill_condition>( cond1 ), static_cast<sc_type>( cond2 ) ) ){
if ((flag=(md->sc.getSCE(j) != NULL))) //Once an effect was found, break out. [Skotlex] *fr = md;
break;
} }
}else
flag=( md->sc.getSCE(cond2) != NULL );
if( flag^( cond1==MSC_FRIENDSTATUSOFF ) )
(*fr)=md;
return 0; return 0;
} }
@ -3765,14 +3785,12 @@ int mobskill_use(struct mob_data *md, t_tick tick, int event, int64 damage)
case MSC_MYSTATUSOFF: // status[num] off case MSC_MYSTATUSOFF: // status[num] off
if( !md->sc.count ){ if( !md->sc.count ){
flag = 0; flag = 0;
} else if (ms[i]->cond2 == -1) { }else if( mob_getstatus_sub( *md, static_cast<e_mob_skill_condition>( ms[i]->cond1 ), static_cast<sc_type>( ms[i]->cond2 ) ) ){
for (j = SC_COMMON_MIN; j <= SC_COMMON_MAX; j++) flag = 1;
if ((flag = (md->sc.getSCE(j)!=NULL)) != 0)
break;
}else{ }else{
flag = (md->sc.getSCE(ms[i]->cond2)!=NULL); flag = 0;
} }
flag ^= (ms[i]->cond1 == MSC_MYSTATUSOFF); break; break;
case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp% case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp%
flag = ((fbl = mob_getfriendhprate(md, 0, ms[i]->cond2)) != NULL); break; flag = ((fbl = mob_getfriendhprate(md, 0, ms[i]->cond2)) != NULL); break;
case MSC_FRIENDHPINRATE : case MSC_FRIENDHPINRATE :