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 if(!IS_REAL_CLIENT(activator))
33 msg_entity = activator;
34 target_music_sendto(MSG_ONE, 1);
36 FOR_EACH_SPEC(head) if(head.enemy == activator) { msg_entity = head; target_music_sendto(MSG_ONE, 1); }
38 void spawnfunc_target_music()
40 self.use = target_music_use;
41 self.reset = target_music_reset;
44 if(self.targetname == "")
45 target_music_sendto(MSG_INIT, 1);
47 target_music_sendto(MSG_INIT, 0);
49 void TargetMusic_RestoreGame()
51 for(self = world; (self = find(self, classname, "target_music")); )
53 if(self.targetname == "")
54 target_music_sendto(MSG_INIT, 1);
56 target_music_sendto(MSG_INIT, 0);
66 // when triggered, it is disabled/enabled for everyone
67 float trigger_music_SendEntity(entity to, float sf)
69 WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
73 WriteByte(MSG_ENTITY, sf);
76 WriteCoord(MSG_ENTITY, self.origin_x);
77 WriteCoord(MSG_ENTITY, self.origin_y);
78 WriteCoord(MSG_ENTITY, self.origin_z);
82 if(self.model != "null")
84 WriteShort(MSG_ENTITY, self.modelindex);
85 WriteCoord(MSG_ENTITY, self.mins_x);
86 WriteCoord(MSG_ENTITY, self.mins_y);
87 WriteCoord(MSG_ENTITY, self.mins_z);
88 WriteCoord(MSG_ENTITY, self.maxs_x);
89 WriteCoord(MSG_ENTITY, self.maxs_y);
90 WriteCoord(MSG_ENTITY, self.maxs_z);
94 WriteShort(MSG_ENTITY, 0);
95 WriteCoord(MSG_ENTITY, self.maxs_x);
96 WriteCoord(MSG_ENTITY, self.maxs_y);
97 WriteCoord(MSG_ENTITY, self.maxs_z);
99 WriteByte(MSG_ENTITY, self.volume * 255.0);
100 WriteByte(MSG_ENTITY, self.fade_time * 16.0);
101 WriteByte(MSG_ENTITY, self.fade_rate * 16.0);
102 WriteString(MSG_ENTITY, self.noise);
106 void trigger_music_reset()
108 self.cnt = !(self.spawnflags & 1);
109 self.SendFlags |= 0x80;
111 void trigger_music_use()
113 self.cnt = !self.cnt;
114 self.SendFlags |= 0x80;
116 void spawnfunc_trigger_music()
119 setmodel(self, self.model);
124 setorigin(self, self.origin + self.mins);
125 setsize(self, '0 0 0', self.maxs - self.mins);
127 trigger_music_reset();
129 self.use = trigger_music_use;
130 self.reset = trigger_music_reset;
132 Net_LinkEntity(self, FALSE, 0, trigger_music_SendEntity);