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);
52 // when triggered, it is disabled/enabled for everyone
53 float trigger_music_SendEntity(entity to, float sf)
55 WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
59 WriteByte(MSG_ENTITY, sf);
62 WriteCoord(MSG_ENTITY, self.origin_x);
63 WriteCoord(MSG_ENTITY, self.origin_y);
64 WriteCoord(MSG_ENTITY, self.origin_z);
68 if(self.model != "null")
70 WriteShort(MSG_ENTITY, self.modelindex);
71 WriteCoord(MSG_ENTITY, self.mins_x);
72 WriteCoord(MSG_ENTITY, self.mins_y);
73 WriteCoord(MSG_ENTITY, self.mins_z);
74 WriteCoord(MSG_ENTITY, self.maxs_x);
75 WriteCoord(MSG_ENTITY, self.maxs_y);
76 WriteCoord(MSG_ENTITY, self.maxs_z);
80 WriteShort(MSG_ENTITY, 0);
81 WriteCoord(MSG_ENTITY, self.maxs_x);
82 WriteCoord(MSG_ENTITY, self.maxs_y);
83 WriteCoord(MSG_ENTITY, self.maxs_z);
85 WriteByte(MSG_ENTITY, self.volume * 255.0);
86 WriteByte(MSG_ENTITY, self.fade_time * 16.0);
87 WriteByte(MSG_ENTITY, self.fade_rate * 16.0);
88 WriteString(MSG_ENTITY, self.noise);
92 void trigger_music_reset()
94 self.cnt = !(self.spawnflags & 1);
95 self.SendFlags |= 0x80;
97 void trigger_music_use()
100 self.SendFlags |= 0x80;
102 void spawnfunc_trigger_music()
105 setmodel(self, self.model);
110 setorigin(self, self.origin + self.mins);
111 setsize(self, '0 0 0', self.maxs - self.mins);
113 trigger_music_reset();
115 self.use = trigger_music_use;
116 self.reset = trigger_music_reset;
118 Net_LinkEntity(self, FALSE, 0, trigger_music_SendEntity);