diff options
author | shennetsind <ind@henn.et> | 2013-11-29 10:58:35 -0200 |
---|---|---|
committer | shennetsind <ind@henn.et> | 2013-11-29 10:58:35 -0200 |
commit | 098dbcf672e04657553b9f1629550e6bc8771af3 (patch) | |
tree | 6dfe6dd587591249faf9d278c1da8d3c71d30a66 /src/map/mob.c | |
parent | 61b02a2b161deb19be4de8e627ebe0f4ffd9a238 (diff) | |
download | hercules-098dbcf672e04657553b9f1629550e6bc8771af3.tar.gz hercules-098dbcf672e04657553b9f1629550e6bc8771af3.tar.bz2 hercules-098dbcf672e04657553b9f1629550e6bc8771af3.tar.xz hercules-098dbcf672e04657553b9f1629550e6bc8771af3.zip |
Minor improvement
pc_checkitem is now triggered by @reloaditemdb to ensure modified conditions are respected, also a performance boost that causes the itemlist/cartlist/storagelist/gstoragelist lookups to only be triggered on demand instead of on every teleport.
Closes #219
Fixed ancient monster ai bug that caused mobs to consider themselves elegible targets, which would waste status_check_skilluse and battle_check_target calls.
Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/mob.c')
-rw-r--r-- | src/map/mob.c | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 777518d87..02c263bd3 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1046,7 +1046,7 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) mode= va_arg(ap,int); //If can't seek yet, not an enemy, or you can't attack it, skip. - if ((*target) == bl || !status->check_skilluse(&md->bl, bl, 0, 0)) + if (md->bl.id == bl->id || (*target) == bl || !status->check_skilluse(&md->bl, bl, 0, 0)) return 0; if ((mode&MD_TARGETWEAK) && status->get_lv(bl) >= md->level-5) @@ -1055,39 +1055,38 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) if(battle->check_target(&md->bl,bl,BCT_ENEMY)<=0) return 0; - switch (bl->type) - { - case BL_PC: - if (((TBL_PC*)bl)->state.gangsterparadise && - !(status_get_mode(&md->bl)&MD_BOSS)) - return 0; //Gangster paradise protection. - default: - if (battle_config.hom_setting&0x4 && - (*target) && (*target)->type == BL_HOM && bl->type != BL_HOM) - return 0; //For some reason Homun targets are never overriden. + switch (bl->type) { + case BL_PC: + if (((TBL_PC*)bl)->state.gangsterparadise && + !(status_get_mode(&md->bl)&MD_BOSS)) + return 0; //Gangster paradise protection. + default: + if (battle_config.hom_setting&0x4 && + (*target) && (*target)->type == BL_HOM && bl->type != BL_HOM) + return 0; //For some reason Homun targets are never overriden. - dist = distance_bl(&md->bl, bl); - if( - ((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) && - battle->check_range(&md->bl,bl,md->db->range2) - ) { //Pick closest target? + dist = distance_bl(&md->bl, bl); + if( + ((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) && + battle->check_range(&md->bl,bl,md->db->range2) + ) { //Pick closest target? - if( map->list[bl->m].icewall_num && - !path->search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) { + if( map->list[bl->m].icewall_num && + !path->search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) { - if( !check_distance_bl(&md->bl, bl, status_get_range(&md->bl) ) ) - return 0; + if( !check_distance_bl(&md->bl, bl, status_get_range(&md->bl) ) ) + return 0; - } + } - (*target) = bl; - md->target_id=bl->id; - md->min_chase= dist + md->db->range3; - if(md->min_chase>MAX_MINCHASE) - md->min_chase=MAX_MINCHASE; - return 1; - } - break; + (*target) = bl; + md->target_id=bl->id; + md->min_chase= dist + md->db->range3; + if(md->min_chase>MAX_MINCHASE) + md->min_chase=MAX_MINCHASE; + return 1; + } + break; } return 0; } @@ -1104,7 +1103,7 @@ int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap) { target= va_arg(ap,struct block_list**); //If can't seek yet, not an enemy, or you can't attack it, skip. - if( *target == bl + if( md->bl.id == bl->id || *target == bl || battle->check_target(&md->bl,bl,BCT_ENEMY) <= 0 || !status->check_skilluse(&md->bl, bl, 0, 0) ) |