4 #include "../../../dpdefs/progsdefs.qh"
5 #include "../../../dpdefs/dpextensions.qh"
6 #include "../../constants.qh"
7 #include "../../../server/constants.qh"
8 #include "../../../server/defs.qh"
20 // when triggered, the music is overridden for activator until lifetime (or forever, if lifetime is 0)
21 // when targetname is not set, THIS ONE is default
22 void target_music_sendto(float to, float is)
24 WriteByte(to, SVC_TEMPENTITY);
25 WriteByte(to, TE_CSQC_TARGET_MUSIC);
26 WriteShort(to, num_for_edict(self));
27 WriteByte(to, self.volume * 255.0 * is);
28 WriteByte(to, self.fade_time * 16.0);
29 WriteByte(to, self.fade_rate * 16.0);
30 WriteByte(to, self.lifetime);
31 WriteString(to, self.noise);
33 void target_music_reset()
35 if(self.targetname == "")
36 target_music_sendto(MSG_ALL, 1);
38 void target_music_use()
42 if(IS_REAL_CLIENT(activator))
44 msg_entity = activator;
45 target_music_sendto(MSG_ONE, 1);
48 FOR_EACH_SPEC(head) if(head.enemy == activator) { msg_entity = head; target_music_sendto(MSG_ONE, 1); }
50 void spawnfunc_target_music()
52 self.use = target_music_use;
53 self.reset = target_music_reset;
56 if(self.targetname == "")
57 target_music_sendto(MSG_INIT, 1);
59 target_music_sendto(MSG_INIT, 0);
61 void TargetMusic_RestoreGame()
63 for(self = world; (self = find(self, classname, "target_music")); )
65 if(self.targetname == "")
66 target_music_sendto(MSG_INIT, 1);
68 target_music_sendto(MSG_INIT, 0);
78 // when triggered, it is disabled/enabled for everyone
79 float trigger_music_SendEntity(entity to, float sf)
81 WriteByte(MSG_ENTITY, ENT_CLIENT_TRIGGER_MUSIC);
85 WriteByte(MSG_ENTITY, sf);
88 WriteCoord(MSG_ENTITY, self.origin.x);
89 WriteCoord(MSG_ENTITY, self.origin.y);
90 WriteCoord(MSG_ENTITY, self.origin.z);
94 if(self.model != "null")
96 WriteShort(MSG_ENTITY, self.modelindex);
97 WriteCoord(MSG_ENTITY, self.mins.x);
98 WriteCoord(MSG_ENTITY, self.mins.y);
99 WriteCoord(MSG_ENTITY, self.mins.z);
100 WriteCoord(MSG_ENTITY, self.maxs.x);
101 WriteCoord(MSG_ENTITY, self.maxs.y);
102 WriteCoord(MSG_ENTITY, self.maxs.z);
106 WriteShort(MSG_ENTITY, 0);
107 WriteCoord(MSG_ENTITY, self.maxs.x);
108 WriteCoord(MSG_ENTITY, self.maxs.y);
109 WriteCoord(MSG_ENTITY, self.maxs.z);
111 WriteByte(MSG_ENTITY, self.volume * 255.0);
112 WriteByte(MSG_ENTITY, self.fade_time * 16.0);
113 WriteByte(MSG_ENTITY, self.fade_rate * 16.0);
114 WriteString(MSG_ENTITY, self.noise);
118 void trigger_music_reset()
120 self.cnt = !(self.spawnflags & 1);
121 self.SendFlags |= 0x80;
123 void trigger_music_use()
125 self.cnt = !self.cnt;
126 self.SendFlags |= 0x80;
128 void spawnfunc_trigger_music()
131 setmodel(self, self.model);
136 setorigin(self, self.origin + self.mins);
137 setsize(self, '0 0 0', self.maxs - self.mins);
139 trigger_music_reset();
141 self.use = trigger_music_use;
142 self.reset = trigger_music_reset;
144 Net_LinkEntity(self, false, 0, trigger_music_SendEntity);