9 // when triggered, the music is overridden for activator until lifetime (or forever, if lifetime is 0)
10 // when targetname is not set, THIS ONE is default
11 void target_music_sendto(float to, float is)
13 WriteByte(to, SVC_TEMPENTITY);
14 WriteByte(to, TE_CSQC_TARGET_MUSIC);
15 WriteShort(to, num_for_edict(self));
16 WriteByte(to, self.volume * 255.0 * is);
17 WriteByte(to, self.fade_time * 16.0);
18 WriteByte(to, self.fade_rate * 16.0);
19 WriteByte(to, self.lifetime);
20 WriteString(to, self.noise);
22 void target_music_reset()
24 if(self.targetname == "")
25 target_music_sendto(MSG_ALL, 1);
27 void target_music_use()
31 msg_entity = activator;
32 target_music_sendto(MSG_ONE, 1);
34 void spawnfunc_target_music()
36 self.use = target_music_use;
37 self.reset = target_music_reset;
40 if(self.targetname == "")
41 target_music_sendto(MSG_INIT, 1);
43 target_music_sendto(MSG_INIT, 0);
45 void TargetMusic_RestoreGame()
47 for(self = world; (self = find(self, classname, "target_music")); )
49 if(self.targetname == "")
50 target_music_sendto(MSG_INIT, 1);
52 target_music_sendto(MSG_INIT, 0);
62 // when triggered, it is disabled/enabled for everyone
63 float trigger_music_SendEntity(entity to, float sf)
65 WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
69 WriteByte(MSG_ENTITY, sf);
72 WriteCoord(MSG_ENTITY, self.origin_x);
73 WriteCoord(MSG_ENTITY, self.origin_y);
74 WriteCoord(MSG_ENTITY, self.origin_z);
78 if(self.model != "null")
80 WriteShort(MSG_ENTITY, self.modelindex);
81 WriteCoord(MSG_ENTITY, self.mins_x);
82 WriteCoord(MSG_ENTITY, self.mins_y);
83 WriteCoord(MSG_ENTITY, self.mins_z);
84 WriteCoord(MSG_ENTITY, self.maxs_x);
85 WriteCoord(MSG_ENTITY, self.maxs_y);
86 WriteCoord(MSG_ENTITY, self.maxs_z);
90 WriteShort(MSG_ENTITY, 0);
91 WriteCoord(MSG_ENTITY, self.maxs_x);
92 WriteCoord(MSG_ENTITY, self.maxs_y);
93 WriteCoord(MSG_ENTITY, self.maxs_z);
95 WriteByte(MSG_ENTITY, self.volume * 255.0);
96 WriteByte(MSG_ENTITY, self.fade_time * 16.0);
97 WriteByte(MSG_ENTITY, self.fade_rate * 16.0);
98 WriteString(MSG_ENTITY, self.noise);
102 void trigger_music_reset()
104 self.cnt = !(self.spawnflags & 1);
105 self.SendFlags |= 0x80;
107 void trigger_music_use()
109 self.cnt = !self.cnt;
110 self.SendFlags |= 0x80;
112 void spawnfunc_trigger_music()
115 setmodel(self, self.model);
120 setorigin(self, self.origin + self.mins);
121 setsize(self, '0 0 0', self.maxs - self.mins);
123 trigger_music_reset();
125 self.use = trigger_music_use;
126 self.reset = trigger_music_reset;
128 Net_LinkEntity(self, FALSE, 0, trigger_music_SendEntity);