summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-03 15:15:23 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-07-03 15:15:23 +0000
commitbff8a4273ec7cedd86b95055278be824ff566f98 (patch)
treeade51d50184bbcc361b3cc0ba4e86d0d398946e0 /src/map/script.c
parentf0b6539b1f935f0c05ed3d6543abb604659418d7 (diff)
downloadhercules-bff8a4273ec7cedd86b95055278be824ff566f98.tar.gz
hercules-bff8a4273ec7cedd86b95055278be824ff566f98.tar.bz2
hercules-bff8a4273ec7cedd86b95055278be824ff566f98.tar.xz
hercules-bff8a4273ec7cedd86b95055278be824ff566f98.zip
- Re-coded 'soundeffectall'; removed the third parameter ('coverage')
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10844 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c91
1 files changed, 46 insertions, 45 deletions
diff --git a/src/map/script.c b/src/map/script.c
index c3985a4a3..9e909cadb 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10845,73 +10845,74 @@ BUILDIN_FUNC(misceffect)
*------------------------------------------*/
BUILDIN_FUNC(soundeffect)
{
+ TBL_PC* sd = script_rid2sd(st);
+ const char* name = script_getstr(st,2);
+ int type = script_getnum(st,3);
- // Redundn
- TBL_PC *sd=script_rid2sd(st);
- const char *name;
- int type=0;
-
-
- name=script_getstr(st,2);
- type=script_getnum(st,3);
- if(sd){
+ if(sd)
+ {
if(!st->rid)
clif_soundeffect(sd,map_id2bl(st->oid),name,type);
- else{
+ else
clif_soundeffect(sd,&sd->bl,name,type);
- }
}
return 0;
}
int soundeffect_sub(struct block_list* bl,va_list ap)
{
- char *name;
- int type;
-
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
-
- name = va_arg(ap,char *);
- type = va_arg(ap,int);
+ char* name = va_arg(ap,char*);
+ int type = va_arg(ap,int);
clif_soundeffect((TBL_PC *)bl, bl, name, type);
return 0;
}
+/*==========================================
+ * Play a sound effect (.wav) on multiple clients
+ * soundeffectall "<filepath>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>};
+ *------------------------------------------*/
BUILDIN_FUNC(soundeffectall)
{
- // [Lance] - Improved.
- const char *name, *map = NULL;
- struct block_list *bl;
- int type, coverage, x0, y0, x1, y1;
+ struct block_list* bl;
+ const char* name;
+ int type;
- name=script_getstr(st,2);
- type=script_getnum(st,3);
- coverage=script_getnum(st,4);
+ bl = (st->rid) ? &(script_rid2sd(st)->bl) : map_id2bl(st->oid);
+ if (!bl)
+ return 0;
- if(!st->rid)
- bl = map_id2bl(st->oid);
+ name = script_getstr(st,2);
+ type = script_getnum(st,3);
+
+ //FIXME: enumerating map squares (map_foreach) is slower than enumerating the list of online players (map_foreachpc?)
+
+ if(!script_hasdata(st,4))
+ { // area around
+ clif_soundeffectall(bl, name, type, AREA);
+ }
else
- bl = &(script_rid2sd(st)->bl);
-
- if(bl){
- if(coverage < 23){
- clif_soundeffectall(bl,name,type,coverage);
- }else {
- if(script_hasdata(st,9)){
- map= script_getstr(st,5);
- x0 = script_getnum(st,6);
- y0 = script_getnum(st,7);
- x1 = script_getnum(st,8);
- y1 = script_getnum(st,9);
- map_foreachinarea(soundeffect_sub,map_mapname2mapid(map),x0,y0,x1,y1,BL_PC,name,type);
- } else {
- ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n");
- }
- }
+ if(!script_hasdata(st,5))
+ { // entire map
+ const char* map = script_getstr(st,4);
+ map_foreachinmap(soundeffect_sub, map_mapname2mapid(map), BL_PC, name, type);
+ }
+ else
+ if(script_hasdata(st,9))
+ { // specified part of map
+ const char* map = script_getstr(st,5);
+ int x0 = script_getnum(st,6);
+ int y0 = script_getnum(st,7);
+ int x1 = script_getnum(st,8);
+ int y1 = script_getnum(st,9);
+ map_foreachinarea(soundeffect_sub, map_mapname2mapid(map), x0, y0, x1, y1, BL_PC, name, type);
}
+ else
+ {
+ ShowError("buildin_soundeffectall: insufficient arguments for specific area broadcast.\n");
+ }
+
return 0;
}
/*==========================================