Sfoglia il codice sorgente

* Added support for packet 0x7fe which changes the bgm temporarily for a single player.
* Added 2 script commands, playBGM and playBGMall, documented use in doc/script_commands.txt

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14335 54d463be-8e91-2dee-dedb-b68131a5f0ec

Yommy 15 anni fa
parent
commit
fccc67c6be
5 ha cambiato i file con 111 aggiunte e 1 eliminazioni
  1. 3 0
      Changelog-Trunk.txt
  2. 19 0
      doc/script_commands.txt
  3. 21 1
      src/map/clif.c
  4. 1 0
      src/map/clif.h
  5. 67 0
      src/map/script.c

+ 3 - 0
Changelog-Trunk.txt

@@ -3,6 +3,9 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2010/06/09
+	* Added support for packet 0x7fe which changes the bgm temporarily for a single player [Rikter/Yommy]
+	* Added 2 script commands, playBGM and playBGMall, documented use in doc/script_commands.txt [Rikter/Yommy]
 2010/06/01
 	* Rev. 14329 Corrected warnings (and errors on some compilers) from r14327. [L0ne_W0lf]
 	* Rev. 14327 Implemented the Manuk and Splendide item status effects, thanks to Epoque. [L0ne_W0lf]

+ 19 - 0
doc/script_commands.txt

@@ -6035,6 +6035,25 @@ You can add your own effects this way, naturally.
 
 ---------------------------------------
 
+*playBGM "<BGM filename>"
+*playBGMall "<BGM filename>",{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>}
+
+These two commands will play a Background Music to either the invoking character 
+only ('playBGM') or multiple characters ('playBGMall'). If the running 
+code does not have an object ID (a 'floating' npc) or is not running from an NPC 
+object at all (an item script) the sound will be centered on the character who's 
+RID got attached to the script, if any. If it does, it will be centered on that 
+object. (an NPC sprite)
+
+BGM filename is the filename in /BGM/ folder. It has to be in .mp3 extension.
+
+It's not required to specify the extension inside the script.
+If coordinates are omitted, BGM will be broadcasted on the entire map.
+
+You can add your own BGMs this way, naturally.
+
+---------------------------------------
+
 *pvpon "<map name>";
 *pvpoff "<map name>";
 

+ 21 - 1
src/map/clif.c

@@ -7350,6 +7350,26 @@ int clif_wisall(struct map_session_data *sd,int type,int flag)
 
 	return 0;
 }
+
+/*==========================================
+ * Play a BGM! [Rikter/Yommy]
+ *------------------------------------------*/
+void clif_playBGM(struct map_session_data* sd, struct block_list* bl, const char* name)
+{
+	int fd;
+
+	nullpo_retv(sd);
+	nullpo_retv(bl);
+
+	fd = sd->fd;
+	WFIFOHEAD(fd,packet_len(0x7fe));
+	WFIFOW(fd,0) = 0x7fe;
+	safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH);
+	WFIFOSET(fd,packet_len(0x7fe));
+
+	return;
+}
+
 /*==========================================
  * ƒTƒEƒ“ƒhƒGƒtƒFƒNƒg
  *------------------------------------------*/
@@ -13946,7 +13966,7 @@ static int packetdb_readdb(void)
 	    6,  2, -1,  4,  4,  4,  4,  8,  8,268,  6,  8,  6, 54, 30, 54,
 #endif
 	    0,  0,  0,  0,  0,  8,  8, 32, -1,  5,  0,  0,  0,  0,  0,  0,
-	    0,  0,  0,  0,  0,  0, 14, 93, 86, 87,  0,  0,  0,  0,  0,  0,
+	    0,  0,  0,  0,  0,  0, 14, 93, 86, 87,  0,  0,  0,  0, 26,  0,
 	//#0x0800
 	   -1, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 20,
 	    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,

+ 1 - 0
src/map/clif.h

@@ -156,6 +156,7 @@ void clif_talkiebox(struct block_list* bl, const char* talkie);
 void clif_wedding_effect(struct block_list *bl);
 void clif_divorced(struct map_session_data* sd, const char* name);
 //void clif_callpartner(struct map_session_data *sd);
+void clif_playBGM(struct map_session_data* sd, struct block_list* bl, const char* name);
 void clif_soundeffect(struct map_session_data* sd, struct block_list* bl, const char* name, int type);
 int clif_soundeffectall(struct block_list* bl, const char *name, int type, enum send_target coverage);
 void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, int target_id, unsigned int tick);

+ 67 - 0
src/map/script.c

@@ -10635,6 +10635,71 @@ BUILDIN_FUNC(misceffect)
 	}
 	return 0;
 }
+/*==========================================
+ * Play a BGM on a single client [Rikter/Yommy]
+ *------------------------------------------*/
+BUILDIN_FUNC(playBGM)
+{
+	TBL_PC* sd = script_rid2sd(st);
+	const char* name = script_getstr(st,2);
+
+	if(sd)
+	{
+		if(!st->rid)
+			clif_playBGM(sd,map_id2bl(st->oid),name);
+		else
+			clif_playBGM(sd,&sd->bl,name);
+	}
+
+	return 0;
+}
+
+int playBGM_sub(struct block_list* bl,va_list ap)
+{
+	char* name = va_arg(ap,char*);
+
+	clif_playBGM((TBL_PC *)bl, bl, name);
+
+    return 0;
+}
+
+/*==========================================
+ * Play a BGM on multiple client [Rikter/Yommy]
+ *------------------------------------------*/
+BUILDIN_FUNC(playBGMall)
+{
+	struct block_list* bl;
+	const char* name;
+
+	bl = (st->rid) ? &(script_rid2sd(st)->bl) : map_id2bl(st->oid);
+	if (!bl)
+		return 0;
+
+	name = script_getstr(st,2);
+
+	if(script_hasdata(st,7))
+	{	// specified part of map
+		const char* map = script_getstr(st,3);
+		int x0 = script_getnum(st,4);
+		int y0 = script_getnum(st,5);
+		int x1 = script_getnum(st,6);
+		int y1 = script_getnum(st,7);
+		map_foreachinarea(playBGM_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name);
+	}
+	else
+	if(!script_hasdata(st,7))
+	{	// entire map
+		const char* map = script_getstr(st,3);
+		map_foreachinmap(playBGM_sub, map_mapname2mapid(map), BL_PC, name);
+	}
+	else
+	{
+		ShowError("buildin_playBGMall: insufficient arguments for specific area broadcast.\n");
+	}
+
+	return 0;
+}
+
 /*==========================================
  * ƒTƒEƒ“ƒhƒGƒtƒFƒNƒg
  *------------------------------------------*/
@@ -14504,6 +14569,8 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(clearitem,""),
 	BUILDIN_DEF(classchange,"ii"),
 	BUILDIN_DEF(misceffect,"i"),
+	BUILDIN_DEF(playBGM,"s"),
+	BUILDIN_DEF(playBGMall,"s*"),
 	BUILDIN_DEF(soundeffect,"si"),
 	BUILDIN_DEF(soundeffectall,"si*"),	// SoundEffectAll [Codemaster]
 	BUILDIN_DEF(strmobinfo,"ii"),	// display mob data [Valaris]