diff --git a/src/map/mob.cpp b/src/map/mob.cpp index c007d96379..bde792c746 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -1571,6 +1571,12 @@ int mob_randomwalk(struct mob_data *md,t_tick tick) nullpo_ret(md); + // Initialize next_walktime + if (md->next_walktime == INVALID_TIMER) { + md->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME; + return 1; + } + if(DIFF_TICK(md->next_walktime,tick)>0 || status_has_mode(&md->status,MD_NORANDOMWALK) || !unit_can_move(&md->bl) || diff --git a/src/map/script.cpp b/src/map/script.cpp index e6114ac9a7..ef0cb6b0ba 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -11157,11 +11157,18 @@ BUILDIN_FUNC(monster) else m = map_mapname2mapid(mapn); + TBL_MOB* md; + for(i = 0; i < amount; i++) { //not optimised int mobid = mob_once_spawn(sd, m, x, y, str, class_, 1, event, size, ai); - if (mobid) + if (mobid > 0) { + md = map_id2md(mobid); + if (md) + md->next_walktime = INVALID_TIMER; + mapreg_setreg(reference_uid(add_str("$@mobid"), i), mobid); + } } return SCRIPT_CMD_SUCCESS; @@ -11274,11 +11281,18 @@ BUILDIN_FUNC(areamonster) else m = map_mapname2mapid(mapn); + TBL_MOB* md; + for(i = 0; i < amount; i++) { //not optimised int mobid = mob_once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, 1, event, size, ai); - if (mobid) + if (mobid > 0) { + md = map_id2md(mobid); + if (md) + md->next_walktime = INVALID_TIMER; + mapreg_setreg(reference_uid(add_str("$@mobid"), i), mobid); + } } return SCRIPT_CMD_SUCCESS;