8 void TargetMusic_Advance()
10 // run AFTER all the thinks!
14 if(music_target && time < music_target.lifetime)
18 for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); ) if(e.noise)
21 if(getsoundtime(e, CHAN_VOICE) < 0)
29 e.state = bound(0, e.state + frametime / e.fade_time, 1);
37 e.state = bound(0, e.state - frametime / e.fade_rate, 1);
44 sound(e, CHAN_VOICE, e.noise, e.volume * e.state * cvar("bgmvolume"), ATTN_NONE); // restart
46 sound(e, CHAN_VOICE, "", e.volume * e.state * cvar("bgmvolume"), ATTN_NONE);
49 music_trigger = world;
52 void Net_TargetMusic()
54 float vol, fai, fao, tim, id;
59 vol = ReadByte() / 255.0;
60 fai = ReadByte() / 16.0;
61 fao = ReadByte() / 16.0;
65 for(e = world; (e = findfloat(e, enttype, ENT_CLIENT_TRIGGER_MUSIC)); )
73 e.enttype = ENT_CLIENT_TRIGGER_MUSIC;
78 e.noise = strzone(noi);
81 precache_sound(e.noise);
82 sound(e, CHAN_VOICE, e.noise, 0, ATTN_NONE);
83 if(getsoundtime(e, CHAN_VOICE) < 0)
85 print("Cannot initialize sound ", e.noise, "\n");
87 e.noise = string_null;
101 localcmd("cd stop\n"); // just in case
108 e.lifetime = time + tim;
113 void Ent_TriggerMusic_Think()
115 if(WarpZoneLib_BoxTouchesBrush(view_origin, view_origin, self, world))
117 music_trigger = self;
119 self.nextthink = time;
122 void Ent_TriggerMusic_Remove()
125 strunzone(self.noise);
126 self.noise = string_null;
129 void Ent_ReadTriggerMusic()
136 self.origin_x = ReadCoord();
137 self.origin_y = ReadCoord();
138 self.origin_z = ReadCoord();
142 self.modelindex = ReadShort();
145 self.mins_x = ReadCoord();
146 self.mins_y = ReadCoord();
147 self.mins_z = ReadCoord();
148 self.maxs_x = ReadCoord();
149 self.maxs_y = ReadCoord();
150 self.maxs_z = ReadCoord();
155 self.maxs_x = ReadCoord();
156 self.maxs_y = ReadCoord();
157 self.maxs_z = ReadCoord();
160 self.volume = ReadByte() / 255.0;
161 self.fade_time = ReadByte() / 16.0;
162 self.fade_rate = ReadByte() / 16.0;
165 strunzone(self.noise);
166 self.noise = strzone(ReadString());
169 precache_sound(self.noise);
170 sound(self, CHAN_VOICE, self.noise, 0, ATTN_NONE);
171 if(getsoundtime(self, CHAN_VOICE) < 0)
173 print("Cannot initialize sound ", self.noise, "\n");
174 strunzone(self.noise);
175 self.noise = string_null;
180 setorigin(self, self.origin);
181 setsize(self, self.mins, self.maxs);
183 self.think = Ent_TriggerMusic_Think;
184 self.nextthink = time;