Fixed an issue where mobs instantly walked after being spotted (#7738)
* Fixed an issue where mobs instantly walked after being spotted MIN_RANDOMWALKTIME was initialized too early * This behavior is only applied on the monster script command
This commit is contained in:
parent
d3b99e6dc1
commit
b4b69a2cc1
@ -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) ||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user