12 // when triggered, the music is overridden for activator until lifetime (or forever, if lifetime is 0)
13 // when targetname is not set, THIS ONE is default
14 void target_music_sendto(float to, float is)
16 WriteByte(to, SVC_TEMPENTITY);
17 WriteByte(to, TE_CSQC_TARGET_MUSIC);
18 WriteShort(to, num_for_edict(self));
19 WriteByte(to, self.volume * 255.0 * is);
20 WriteByte(to, self.fade_time * 16.0);
21 WriteByte(to, self.fade_rate * 16.0);
22 WriteByte(to, self.lifetime);
23 WriteString(to, self.noise);
25 void target_music_reset()
27 if(self.targetname == "")
28 target_music_sendto(MSG_ALL, 1);
30 void target_music_use()
34 if(IS_REAL_CLIENT(activator))
36 msg_entity = activator;
37 target_music_sendto(MSG_ONE, 1);
40 FOR_EACH_SPEC(head) if(head.enemy == activator) { msg_entity = head; target_music_sendto(MSG_ONE, 1); }
42 void spawnfunc_target_music()
44 self.use = target_music_use;
45 self.reset = target_music_reset;
48 if(self.targetname == "")
49 target_music_sendto(MSG_INIT, 1);
51 target_music_sendto(MSG_INIT, 0);
53 void TargetMusic_RestoreGame()
55 for(self = world; (self = find(self, classname, "target_music")); )
57 if(self.targetname == "")
58 target_music_sendto(MSG_INIT, 1);
60 target_music_sendto(MSG_INIT, 0);
70 // when triggered, it is disabled/enabled for everyone
71 float trigger_music_SendEntity(entity to, int sf)
73 WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
77 WriteByte(MSG_ENTITY, sf);
80 WriteCoord(MSG_ENTITY, self.origin.x);
81 WriteCoord(MSG_ENTITY, self.origin.y);
82 WriteCoord(MSG_ENTITY, self.origin.z);
86 if(self.model != "null")
88 WriteShort(MSG_ENTITY, self.modelindex);
89 WriteCoord(MSG_ENTITY, self.mins.x);
90 WriteCoord(MSG_ENTITY, self.mins.y);
91 WriteCoord(MSG_ENTITY, self.mins.z);
92 WriteCoord(MSG_ENTITY, self.maxs.x);
93 WriteCoord(MSG_ENTITY, self.maxs.y);
94 WriteCoord(MSG_ENTITY, self.maxs.z);
98 WriteShort(MSG_ENTITY, 0);
99 WriteCoord(MSG_ENTITY, self.maxs.x);
100 WriteCoord(MSG_ENTITY, self.maxs.y);
101 WriteCoord(MSG_ENTITY, self.maxs.z);
103 WriteByte(MSG_ENTITY, self.volume * 255.0);
104 WriteByte(MSG_ENTITY, self.fade_time * 16.0);
105 WriteByte(MSG_ENTITY, self.fade_rate * 16.0);
106 WriteString(MSG_ENTITY, self.noise);
110 void trigger_music_reset()
112 self.cnt = !(self.spawnflags & 1);
113 self.SendFlags |= 0x80;
115 void trigger_music_use()
117 self.cnt = !self.cnt;
118 self.SendFlags |= 0x80;
120 void spawnfunc_trigger_music()
123 setmodel(self, self.model);
128 setorigin(self, self.origin + self.mins);
129 setsize(self, '0 0 0', self.maxs - self.mins);
131 trigger_music_reset();
133 self.use = trigger_music_use;
134 self.reset = trigger_music_reset;
136 Net_LinkEntity(self, false, 0, trigger_music_SendEntity);