From f270d48e238e2895b2a85e1ec1b6ffb8a801684d Mon Sep 17 00:00:00 2001 From: ultramage Date: Mon, 6 Apr 2009 19:53:48 +0000 Subject: Modified the lazy mob AI code to fix some very annoying behavior (bugreport:2258) - mobs will no longer get scattered across the whole map as soon as the last player leaves - mobs will now random-walk indefinitely even if there are no players on the map (might have a performance impact) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13664 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/mob.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/map/mob.c b/src/map/mob.c index 634df71ab..e8f15b728 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1560,7 +1560,6 @@ static int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) static int mob_ai_sub_lazy(struct mob_data *md, va_list args) { unsigned int tick; - int mode; nullpo_retr(0, md); @@ -1605,35 +1604,21 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args) return 0; } - mode = status_get_mode(&md->bl); - if(DIFF_TICK(md->next_walktime,tick)<0 && - (mode&MD_CANMOVE) && unit_can_move(&md->bl) ){ - - if( map[md->bl.m].users>0 ){ - // Since PC is in the same map, somewhat better negligent processing is carried out. - - // It sometimes moves. - if(rand()%1000next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit_can_move(&md->bl) ) + { + if( map[md->bl.m].users > 0 ) + { + if( rand()%1000 < MOB_LAZYMOVEPERC(md) ) + mob_randomwalk(md, tick); + else + if( rand()%1000 < MOB_LAZYSKILLPERC ) //Chance to do a mob's idle skill. mobskill_use(md, tick, -1); - // MOB which is not not the summons MOB but BOSS, either sometimes reboils. - // People don't want this, it seems custom, noone can prove it.... -// else if( rand()%1000spawn && !md->spawn->x && !md->spawn->y) -// && !md->target_id && !(mode&MD_BOSS)) -// unit_warp(&md->bl,-1,-1,-1,0); - }else{ - // Since PC is not even in the same map, suitable processing is carried out even if it takes. - - // MOB which is not BOSS which is not Summons MOB, either -- a case -- sometimes -- leaping - if( rand()%1000spawn && !md->spawn->x && !md->spawn->y) - && !(mode&MD_BOSS)) - unit_warp(&md->bl,-1,-1,-1,0); } - - md->next_walktime = tick+rand()%10000+5000; + else + { + if( rand()%1000 < MOB_LAZYMOVEPERC(md) ) + mob_randomwalk(md, tick); + } } return 0; } -- cgit v1.2.3-70-g09d2