5 // FIXME also control bgmvolume here, to not require a target_music for the default track.
10 void TargetMusic_Advance()
12 // run AFTER all the thinks!
16 if(music_target && time < music_target.lifetime)
20 for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); ) if(e.noise)
23 if(getsoundtime(e, CH_BGM_SINGLE) < 0)
31 e.state = bound(0, e.state + frametime / e.fade_time, 1);
39 e.state = bound(0, e.state - frametime / e.fade_rate, 1);
43 vol = e.state * e.volume * autocvar_bgmvolume;
47 sound(e, CH_BGM_SINGLE, e.noise, vol, ATTEN_NONE); // restart
49 sound(e, CH_BGM_SINGLE, "", vol, ATTEN_NONE);
53 music_trigger = world;
56 bgmtime = getsoundtime(best, CH_BGM_SINGLE);
58 bgmtime = gettime(GETTIME_CDTRACK);
61 void Net_TargetMusic()
63 float vol, fai, fao, tim, id;
68 vol = ReadByte() / 255.0;
69 fai = ReadByte() / 16.0;
70 fao = ReadByte() / 16.0;
74 for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); )
82 e.enttype = ENT_CLIENT_TRIGGER_MUSIC;
89 e.noise = strzone(noi);
90 precache_sound(e.noise);
91 sound(e, CH_BGM_SINGLE, e.noise, 0, ATTEN_NONE);
92 if(getsoundtime(e, CH_BGM_SINGLE) < 0)
94 dprintf("Cannot initialize sound %s\n", e.noise);
96 e.noise = string_null;
110 cvar_settemp("music_playlist_index", "-1"); // don't use playlists
111 localcmd("cd stop\n"); // just in case
118 e.lifetime = time + tim;
123 void Ent_TriggerMusic_Think()
125 if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
127 music_trigger = self;
129 self.nextthink = time;
132 void Ent_TriggerMusic_Remove()
135 strunzone(self.noise);
136 self.noise = string_null;
139 void Ent_ReadTriggerMusic()
144 self.origin_x = ReadCoord();
145 self.origin_y = ReadCoord();
146 self.origin_z = ReadCoord();
150 self.modelindex = ReadShort();
153 self.mins_x = ReadCoord();
154 self.mins_y = ReadCoord();
155 self.mins_z = ReadCoord();
156 self.maxs_x = ReadCoord();
157 self.maxs_y = ReadCoord();
158 self.maxs_z = ReadCoord();
163 self.maxs_x = ReadCoord();
164 self.maxs_y = ReadCoord();
165 self.maxs_z = ReadCoord();
168 self.volume = ReadByte() / 255.0;
169 self.fade_time = ReadByte() / 16.0;
170 self.fade_rate = ReadByte() / 16.0;
171 string s = self.noise;
173 strunzone(self.noise);
174 self.noise = strzone(ReadString());
177 precache_sound(self.noise);
178 sound(self, CH_BGM_SINGLE, self.noise, 0, ATTEN_NONE);
179 if(getsoundtime(self, CH_BGM_SINGLE) < 0)
181 dprintf("Cannot initialize sound %s\n", self.noise);
182 strunzone(self.noise);
183 self.noise = string_null;
188 setorigin(self, self.origin);
189 setsize(self, self.mins, self.maxs);
191 self.think = Ent_TriggerMusic_Think;
192 self.nextthink = time;