9 void TargetMusic_Advance()
11 // run AFTER all the thinks!
15 if(music_target && time < music_target.lifetime)
19 for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); ) if(e.noise)
22 if(getsoundtime(e, CHAN_VOICE) < 0)
30 e.state = bound(0, e.state + frametime / e.fade_time, 1);
38 e.state = bound(0, e.state - frametime / e.fade_rate, 1);
42 vol = e.state * e.volume * autocvar_bgmvolume;
46 sound(e, CHAN_VOICE, e.noise, vol, ATTN_NONE); // restart
48 sound(e, CHAN_VOICE, "", vol, ATTN_NONE);
52 music_trigger = world;
55 bgmtime = getsoundtime(best, CHAN_VOICE);
57 bgmtime = gettime(GETTIME_CDTRACK);
60 void Net_TargetMusic()
62 float vol, fai, fao, tim, id;
67 vol = ReadByte() / 255.0;
68 fai = ReadByte() / 16.0;
69 fao = ReadByte() / 16.0;
73 for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); )
81 e.enttype = ENT_CLIENT_TRIGGER_MUSIC;
88 e.noise = strzone(noi);
89 precache_sound(e.noise);
90 sound(e, CHAN_VOICE, e.noise, 0, ATTN_NONE);
91 if(getsoundtime(e, CHAN_VOICE) < 0)
93 print("Cannot initialize sound ", e.noise, "\n");
95 e.noise = string_null;
109 localcmd("cd stop\n"); // just in case
116 e.lifetime = time + tim;
121 void Ent_TriggerMusic_Think()
123 if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
125 music_trigger = self;
127 self.nextthink = time;
130 void Ent_TriggerMusic_Remove()
133 strunzone(self.noise);
134 self.noise = string_null;
137 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;
173 strunzone(self.noise);
174 self.noise = strzone(ReadString());
177 precache_sound(self.noise);
178 sound(self, CHAN_VOICE, self.noise, 0, ATTN_NONE);
179 if(getsoundtime(self, CHAN_VOICE) < 0)
181 print("Cannot initialize sound ", self.noise, "\n");
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;