diff --git a/src/map/clif.c b/src/map/clif.c index 34959a515d..d42ff2c88a 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18708,6 +18708,43 @@ void clif_parse_Oneclick_Itemidentify(int fd, struct map_session_data *sd) { #endif } +/// Starts navigation to the given target on client side +void clif_navigateTo(struct map_session_data *sd, const char* map, uint16 x, uint16 y, uint8 flag, bool hideWindow, uint16 mob_id ){ +#if PACKETVER >= 20111010 + int fd = sd->fd; + + WFIFOHEAD(fd,27); + WFIFOW(fd,0) = 0x08e2; + + // How detailed will our navigation be? + if( mob_id > 0 ){ + x = 0; + y = 0; + WFIFOB(fd,2) = 3; // monster with destination field + }else if( x > 0 && y > 0 ){ + WFIFOB(fd,2) = 0; // with coordinates + }else{ + x = 0; + y = 0; + WFIFOB(fd,2) = 1; // without coordinates(will fail if you are already on the map) + } + + // Which services can be used for transportation? + WFIFOB(fd,3) = flag; + // If this flag is set, the navigation window will not be opened up + WFIFOB(fd,4) = hideWindow; + // Target map + safestrncpy( (char*)WFIFOP(fd,5),map,MAP_NAME_LENGTH_EXT); + // Target x + WFIFOW(fd,21) = x; + // Target y + WFIFOW(fd,23) = y; + // Target monster ID + WFIFOW(fd,25) = mob_id; + WFIFOSET(fd,27); +#endif +} + /*========================================== * Main client packet processing function *------------------------------------------*/ diff --git a/src/map/clif.h b/src/map/clif.h index 5eeba3ff3f..a3aa6e897d 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -982,6 +982,7 @@ void clif_merge_item_open(struct map_session_data *sd); void clif_broadcast_obtain_special_item(const char *char_name, unsigned short nameid, unsigned short container, enum BROADCASTING_SPECIAL_ITEM_OBTAIN type, const char *srcname); void clif_dressing_room(struct map_session_data *sd, int flag); +void clif_navigateTo(struct map_session_data *sd, const char* map, uint16 x, uint16 y, uint8 flag, bool hideWindow, uint16 mob_id ); void clif_SelectCart(struct map_session_data *sd); #endif /* _CLIF_H_ */ diff --git a/src/map/script.c b/src/map/script.c index 005074f3d9..f1173c11b2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21047,6 +21047,40 @@ BUILDIN_FUNC(opendressroom) #endif } +/** + * navigateto(""{,,,,,,}); + */ +BUILDIN_FUNC(navigateto){ +#if PACKETVER >= 20111010 + TBL_PC* sd; + const char *map; + uint16 x = 0, y = 0, monster_id = 0; + uint8 flag = NAV_KAFRA_AND_PLANE; + bool hideWindow = true; + + map = script_getstr(st,2); + + if( script_hasdata(st,3) ) + x = script_getnum(st,3); + if( script_hasdata(st,4) ) + y = script_getnum(st,4); + if( script_hasdata(st,5) ) + flag = (uint8)script_getnum(st,5); + if( script_hasdata(st,6) ) + hideWindow = script_getnum(st,6) ? true : false; + if( script_hasdata(st,7) ) + monster_id = script_getnum(st,7); + + if (!script_charid2sd(8, sd)) + return SCRIPT_CMD_FAILURE; + + clif_navigateTo(sd,map,x,y,flag,hideWindow,monster_id); + + return SCRIPT_CMD_SUCCESS; +#else + return SCRIPT_CMD_FAILURE; +#endif +} #include "../custom/script.inc" @@ -21614,6 +21648,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(setquestinfo_req,"iii*"), BUILDIN_DEF(setquestinfo_job,"ii*"), BUILDIN_DEF(opendressroom,"i?"), + BUILDIN_DEF(navigateto,"s???????"), #include "../custom/script_def.inc" diff --git a/src/map/script.h b/src/map/script.h index d5d78b7035..7c24cb716e 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -623,6 +623,25 @@ enum unitdata_npctypes { UNPC_DMOTION, }; +enum navigation_service { + // 0 + NAV_NONE = 0, + // 1(actually 1-9) + NAV_AIRSHIP_ONLY = 1, + // 10 + NAV_SCROLL_ONLY = 10, + // 11(actually 11-99) + NAV_AIRSHIP_AND_SCROLL = NAV_AIRSHIP_ONLY + NAV_SCROLL_ONLY, + // 100 + NAV_KAFRA_ONLY = 100, + // 101(actually 101-109) + NAV_KAFRA_AND_PLANE = NAV_KAFRA_ONLY + NAV_AIRSHIP_ONLY, + // 110 + NAV_KAFRA_AND_SCROLL = NAV_KAFRA_ONLY + NAV_SCROLL_ONLY, + // 111(actually 111-255) + NAV_ALL = NAV_AIRSHIP_ONLY + NAV_SCROLL_ONLY + NAV_KAFRA_ONLY +}; + /** * used to generate quick script_array entries **/ diff --git a/src/map/script_constants.h b/src/map/script_constants.h index 74fb45114d..37f7d97c44 100644 --- a/src/map/script_constants.h +++ b/src/map/script_constants.h @@ -2995,6 +2995,15 @@ export_constant(UNPC_ADELAY); export_constant(UNPC_DMOTION); + export_constant(NAV_NONE); + export_constant(NAV_AIRSHIP_ONLY); + export_constant(NAV_SCROLL_ONLY); + export_constant(NAV_AIRSHIP_AND_SCROLL); + export_constant(NAV_KAFRA_ONLY); + export_constant(NAV_KAFRA_AND_PLANE); + export_constant(NAV_KAFRA_AND_SCROLL); + export_constant(NAV_ALL); + #undef export_constant #endif /* _SCRIPT_CONSTANTS_H_ */