diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/clif.c | 42 | ||||
-rw-r--r-- | src/map/clif.h | 1 | ||||
-rw-r--r-- | src/map/script.c | 55 | ||||
-rw-r--r-- | src/map/script.h | 11 |
4 files changed, 109 insertions, 0 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 7e4f6b825..749b3d068 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -18861,6 +18861,47 @@ void clif_selectcart(struct map_session_data *sd) #endif } +/// Starts navigation to the given target on client side +void clif_navigate_to(struct map_session_data *sd, const char* mapname, uint16 x, uint16 y, uint8 flag, bool hideWindow, uint16 mob_id) +{ +#if PACKETVER >= 20111010 + int fd; + + nullpo_retv(sd); + nullpo_retv(mapname); + fd = sd->fd; + WFIFOHEAD(fd, 27); + WFIFOW(fd, 0) = 0x8e2; + + // 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), mapname, 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 +} + /** * Returns the name of the given bl, in a client-friendly format. * @@ -19704,6 +19745,7 @@ void clif_defaults(void) { clif->selectcart = clif_selectcart; /* */ clif->isdisguised = clif_isdisguised; + clif->navigate_to = clif_navigate_to; clif->bl_type = clif_bl_type; /*------------------------ diff --git a/src/map/clif.h b/src/map/clif.h index 8f6950666..3203a3e66 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1111,6 +1111,7 @@ struct clif_interface { void (*ackmergeitems) (int fd, struct map_session_data *sd); /* */ bool (*isdisguised) (struct block_list* bl); + void (*navigate_to) (struct map_session_data *sd, const char* mapname, uint16 x, uint16 y, uint8 flag, bool hideWindow, uint16 mob_id); unsigned char (*bl_type) (struct block_list *bl); /*------------------------ *- Parse Incoming Packet diff --git a/src/map/script.c b/src/map/script.c index 2633c1e5f..f8754660c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -20507,6 +20507,48 @@ BUILDIN(pcre_match) } /** + * navigateto("<map>"{,<x>,<y>,<flag>,<hide_window>,<monster_id>,<char_id>}); + */ +BUILDIN(navigateto) +{ +#if PACKETVER >= 20111010 + struct map_session_data* sd; + const char *mapname; + uint16 x = 0; + uint16 y = 0; + uint16 monster_id = 0; + uint8 flag = NAV_KAFRA_AND_AIRSHIP; + bool hideWindow = true; + + mapname = 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_hasdata(st, 8)) { + sd = map->charid2sd(script_getnum(st, 8)); + } else { + sd = script->rid2sd(st); + } + + clif->navigate_to(sd, mapname, x, y, flag, hideWindow, monster_id); + + return true; +#else + ShowError("Navigation system works only with packet version >= 20111010"); + return false; +#endif +} + +/** * Adds a built-in script function. * * @param buildin Script function data @@ -21175,6 +21217,9 @@ void script_parse_builtin(void) { BUILDIN_DEF(purchaseok,""), BUILDIN_DEF(shopcount, "i"), + /* Navigation */ + BUILDIN_DEF(navigateto, "s??????"), + BUILDIN_DEF(channelmes, "ss"), BUILDIN_DEF(showscript, "s?"), BUILDIN_DEF(mergeitem,""), @@ -21329,6 +21374,16 @@ void script_hardcoded_constants(void) script->set_constant("EQP_SHADOW_ACC_R", EQP_SHADOW_ACC_R, false, false); script->set_constant("EQP_SHADOW_ACC_L", EQP_SHADOW_ACC_L, false, false); + script->constdb_comment("Navigation constants, use with *navigateto*"); + script->set_constant("NAV_NONE", NAV_NONE, false, false); + script->set_constant("NAV_AIRSHIP_ONLY", NAV_AIRSHIP_ONLY, false, false); + script->set_constant("NAV_SCROLL_ONLY", NAV_SCROLL_ONLY, false, false); + script->set_constant("NAV_AIRSHIP_AND_SCROLL", NAV_AIRSHIP_AND_SCROLL, false, false); + script->set_constant("NAV_KAFRA_ONLY", NAV_KAFRA_ONLY, false, false); + script->set_constant("NAV_KAFRA_AND_AIRSHIP", NAV_KAFRA_AND_AIRSHIP, false, false); + script->set_constant("NAV_KAFRA_AND_SCROLL", NAV_KAFRA_AND_SCROLL, false, false); + script->set_constant("NAV_ALL", NAV_ALL, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); diff --git a/src/map/script.h b/src/map/script.h index c4c082263..a69000991 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -338,6 +338,17 @@ enum { MF_NOVIEWID }; +enum navigation_service { + NAV_NONE = 0, + NAV_AIRSHIP_ONLY = 1, + NAV_SCROLL_ONLY = 10, + NAV_AIRSHIP_AND_SCROLL = NAV_AIRSHIP_ONLY + NAV_SCROLL_ONLY, //11 + NAV_KAFRA_ONLY = 100, + NAV_KAFRA_AND_AIRSHIP = NAV_KAFRA_ONLY + NAV_AIRSHIP_ONLY, // 101 + NAV_KAFRA_AND_SCROLL = NAV_KAFRA_ONLY + NAV_SCROLL_ONLY, // 110 + NAV_ALL = NAV_AIRSHIP_ONLY + NAV_SCROLL_ONLY + NAV_KAFRA_ONLY // 111-255 +}; + /** * Structures **/ |