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 * cvar("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 void Net_TargetMusic()
57 float vol, fai, fao, tim, id;
62 vol = ReadByte() / 255.0;
63 fai = ReadByte() / 16.0;
64 fao = ReadByte() / 16.0;
68 for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); )
76 e.enttype = ENT_CLIENT_TRIGGER_MUSIC;
83 e.noise = strzone(noi);
84 precache_sound(e.noise);
85 sound(e, CHAN_VOICE, e.noise, 0, ATTN_NONE);
86 if(getsoundtime(e, CHAN_VOICE) < 0)
88 print("Cannot initialize sound ", e.noise, "\n");
90 e.noise = string_null;
104 localcmd("cd stop\n"); // just in case
111 e.lifetime = time + tim;
116 void Ent_TriggerMusic_Think()
118 if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
120 music_trigger = self;
122 self.nextthink = time;
125 void Ent_TriggerMusic_Remove()
128 strunzone(self.noise);
129 self.noise = string_null;
132 void Ent_ReadTriggerMusic()
139 self.origin_x = ReadCoord();
140 self.origin_y = ReadCoord();
141 self.origin_z = ReadCoord();
145 self.modelindex = ReadShort();
148 self.mins_x = ReadCoord();
149 self.mins_y = ReadCoord();
150 self.mins_z = ReadCoord();
151 self.maxs_x = ReadCoord();
152 self.maxs_y = ReadCoord();
153 self.maxs_z = ReadCoord();
158 self.maxs_x = ReadCoord();
159 self.maxs_y = ReadCoord();
160 self.maxs_z = ReadCoord();
163 self.volume = ReadByte() / 255.0;
164 self.fade_time = ReadByte() / 16.0;
165 self.fade_rate = ReadByte() / 16.0;
168 strunzone(self.noise);
169 self.noise = strzone(ReadString());
172 precache_sound(self.noise);
173 sound(self, CHAN_VOICE, self.noise, 0, ATTN_NONE);
174 if(getsoundtime(self, CHAN_VOICE) < 0)
176 print("Cannot initialize sound ", self.noise, "\n");
177 strunzone(self.noise);
178 self.noise = string_null;
183 setorigin(self, self.origin);
184 setsize(self, self.mins, self.maxs);
186 self.think = Ent_TriggerMusic_Think;
187 self.nextthink = time;