From 2de9fa2b9bcc944a5671a1965813a56b1e1dfd5c Mon Sep 17 00:00:00 2001 From: skotlex Date: Sat, 8 Apr 2006 17:56:31 +0000 Subject: - Fixed @movenpc - Cleaned up and improved the lootsearch routine to pick nearest item. - Added INVISIBLE_CLASS to the list of classes supported by npc_get_viewdata - Fixed trying to set the view_data for npcs who are located on a map, but have no visual data. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5959 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/atcommand.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 089c88c3c..b7d172f35 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6999,7 +6999,7 @@ int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* command, const char* message) { - int x = 0, y = 0; + int x = 0, y = 0, m; struct npc_data *nd = 0; nullpo_retr(-1, sd); @@ -7020,9 +7020,15 @@ atcommand_npcmove(const int fd, struct map_session_data* sd, if ((nd = npc_name2id(atcmd_player_name)) == NULL) return -1; + if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) + return -1; //Not on a map. + npc_enable(atcmd_player_name, 0); - nd->bl.x = x; - nd->bl.y = y; + if (x < 0) x = 0; + else if (x >= map[m].xs) x = map[m].xs-1; + if (y < 0) y = 0; + else if (y >= map[m].ys) y = map[m].ys-1; + map_moveblock(&nd->bl, x, y, gettick()); npc_enable(atcmd_player_name, 1); return 0; -- cgit v1.2.3-70-g09d2