Index: src/map/script.c
===================================================================
--- src/map/script.c (revision 17307)
+++ src/map/script.c (working copy)
@@ -15359,7 +15359,6 @@
}
// <--- [zBuffer] List of player cont commands
// [zBuffer] List of mob control commands --->
-//## TODO always return if the request/whatever was successfull [FlavioJS]
/// Makes the unit walk to target position or map
/// Returns if it was successfull
@@ -15372,17 +15371,16 @@
bl = map_id2bl(script_getnum(st,2));
if( bl == NULL )
- {
script_pushint(st, 0);
- }
- else if( script_hasdata(st,4) )
- {
+
+ if( script_hasdata(st,4) ) {
int x = script_getnum(st,3);
int y = script_getnum(st,4);
- script_pushint(st, unit_walktoxy(bl,x,y,0));// We'll use harder calculations.
- }
- else
- {
+ if( unit_can_reach_pos(bl,x,y,0) ) {
+ add_timer(gettick()+50, unit_delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF)); // Need timer to avoid mismatches
+ return 1;
+ }
+ } else {
int map_id = script_getnum(st,3);
script_pushint(st, unit_walktobl(bl,map_id2bl(map_id),65025,1));
}
Index: src/map/unit.c
===================================================================
--- src/map/unit.c (revision 17307)
+++ src/map/unit.c (working copy)
@@ -298,7 +298,7 @@
return 0;
}
-static int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
+int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct block_list *bl = map_id2bl(id);
Index: src/map/unit.h
===================================================================
--- src/map/unit.h (revision 17307)
+++ src/map/unit.h (working copy)
@@ -68,61 +68,56 @@
unsigned dead_sit : 2;
};
-// PC, MOB, PET ɀʷéðPÂÉÜÆßévæ
+// PC, MOB, PET
-// àsJn
-// ßèlÍA0 ( ¬÷ ), 1 ( žs )
+// Does walk action for unit
int unit_walktoxy( struct block_list *bl, short x, short y, int easy);
int unit_walktobl( struct block_list *bl, struct block_list *target, int range, int easy);
int unit_run(struct block_list *bl);
int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir);
-// àsâ~
-// typeÍȺÌgÝí¹ :
-// 1: ÊuîñÌM( ±ÌÖÌãÉÊuîñðM·éêÍsv )
-// 2: _[WfBCLè
-// 4: sŸ(MOBÌÝH)
+// Causes the target object to stop moving.
int unit_stop_walking(struct block_list *bl,int type);
int unit_can_move(struct block_list *bl);
int unit_is_walking(struct block_list *bl);
int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type);
+int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data);
int unit_escape(struct block_list *bl, struct block_list *target, short dist);
-// Êu̧ڮ(«òεÈÇ)
+
+// Instant unit changes
int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath);
int unit_warp(struct block_list *bl, short map, short x, short y, clr_type type);
int unit_setdir(struct block_list *bl,unsigned char dir);
uint8 unit_getdir(struct block_list *bl);
int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag);
-// »±ÜÅàsÅœÇè
¯é©Ì»è
+// Can-reach checks
bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy);
bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y);
-// UÖA
+// Unit attack functions
int unit_stop_attack(struct block_list *bl);
int unit_attack(struct block_list *src,int target_id,int continuous);
int unit_cancel_combo(struct block_list *bl);
-// XLgp
+// Cast on a unit
int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv);
int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv);
-
-// XLgp( â³ÏÝLXgÔALZsÂÝèt« )
int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
-// r¥LZ
+// Cancel unit cast
int unit_skillcastcancel(struct block_list *bl,int type);
int unit_counttargeted(struct block_list *bl);
int unit_set_target(struct unit_data* ud, int target_id);
-// unit_data Ìú»
+// unit_data
void unit_dataset(struct block_list *bl);
int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int damage,int div,int type,int damage2);
-// »ÌŒ
+// Remove unit
struct unit_data* unit_bl2ud(struct block_list *bl);
void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype);
void unit_free_pc(struct map_session_data *sd);
@@ -131,12 +126,10 @@
int unit_free(struct block_list *bl, clr_type clrtype);
int unit_changeviewsize(struct block_list *bl,short size);
-// ú»[`
int do_init_unit(void);
int do_final_unit(void);
-/**
- * Ranger
- **/
+
+// Ranger
int unit_wugdash(struct block_list *bl, struct map_session_data *sd);
extern const short dirx[8];