瀏覽代碼

Implemented serverside navigation system start

This feature was hidden in the client since 2011 and just came to our attention recently.
Lemongrass3110 9 年之前
父節點
當前提交
4f13007fec
共有 5 個文件被更改,包括 101 次插入0 次删除
  1. 37 0
      src/map/clif.c
  2. 1 0
      src/map/clif.h
  3. 35 0
      src/map/script.c
  4. 19 0
      src/map/script.h
  5. 9 0
      src/map/script_constants.h

+ 37 - 0
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
  *------------------------------------------*/

+ 1 - 0
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_ */

+ 35 - 0
src/map/script.c

@@ -21047,6 +21047,40 @@ BUILDIN_FUNC(opendressroom)
 #endif
 }
 
+/**
+ * navigateto("<map>"{,<x>,<y>,<flag>,<hide_window>,<monster_id>,<char_id>});
+ */
+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"
 

+ 19 - 0
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
  **/

+ 9 - 0
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_ */