]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/plat.qc
Merge branch 'TimePath/experiments/csqc_prediction' into Mario/qc_physics
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / plat.qc
1 #ifdef SVQC
2 void plat_delayedinit()
3 {
4         plat_spawn_inside_trigger ();   // the "start moving" trigger
5 }
6
7 float plat_send(entity to, float sf)
8 {
9         WriteByte(MSG_ENTITY, ENT_CLIENT_PLAT);
10         WriteByte(MSG_ENTITY, sf);
11
12         if(sf & SF_TRIGGER_INIT)
13         {
14                 WriteShort(MSG_ENTITY, num_for_edict(self));
15                 WriteString(MSG_ENTITY, self.target);
16                 WriteString(MSG_ENTITY, self.target2);
17                 WriteString(MSG_ENTITY, self.target3);
18                 WriteString(MSG_ENTITY, self.target4);
19                 WriteString(MSG_ENTITY, self.targetname);
20
21                 WriteByte(MSG_ENTITY, self.platmovetype_start);
22                 WriteByte(MSG_ENTITY, self.platmovetype_turn);
23                 WriteByte(MSG_ENTITY, self.platmovetype_end);
24
25                 WriteCoord(MSG_ENTITY, self.origin_x);
26                 WriteCoord(MSG_ENTITY, self.origin_y);
27                 WriteCoord(MSG_ENTITY, self.origin_z);
28
29                 WriteString(MSG_ENTITY, self.model);
30
31                 WriteCoord(MSG_ENTITY, self.mins_x);
32                 WriteCoord(MSG_ENTITY, self.mins_y);
33                 WriteCoord(MSG_ENTITY, self.mins_z);
34                 WriteCoord(MSG_ENTITY, self.maxs_x);
35                 WriteCoord(MSG_ENTITY, self.maxs_y);
36                 WriteCoord(MSG_ENTITY, self.maxs_z);
37
38                 WriteCoord(MSG_ENTITY, self.pos1_x);
39                 WriteCoord(MSG_ENTITY, self.pos1_y);
40                 WriteCoord(MSG_ENTITY, self.pos1_z);
41                 WriteCoord(MSG_ENTITY, self.pos2_x);
42                 WriteCoord(MSG_ENTITY, self.pos2_y);
43                 WriteCoord(MSG_ENTITY, self.pos2_z);
44
45                 WriteCoord(MSG_ENTITY, self.size_x);
46                 WriteCoord(MSG_ENTITY, self.size_y);
47                 WriteCoord(MSG_ENTITY, self.size_z);
48
49                 WriteAngle(MSG_ENTITY, self.angles_x);
50                 WriteAngle(MSG_ENTITY, self.angles_y);
51                 WriteAngle(MSG_ENTITY, self.angles_z);
52
53                 WriteAngle(MSG_ENTITY, self.mangle_x);
54                 WriteAngle(MSG_ENTITY, self.mangle_y);
55                 WriteAngle(MSG_ENTITY, self.mangle_z);
56
57                 WriteShort(MSG_ENTITY, self.speed);
58                 WriteShort(MSG_ENTITY, self.height);
59                 WriteByte(MSG_ENTITY, self.lip);
60                 WriteByte(MSG_ENTITY, self.state);
61
62                 WriteShort(MSG_ENTITY, self.dmg);
63         }
64
65         if(sf & SF_TRIGGER_RESET)
66         {
67                 // used on client
68         }
69
70         return true;
71 }
72
73 void plat_link()
74 {
75         Net_LinkEntity(self, 0, false, plat_send);
76 }
77
78 void spawnfunc_func_plat()
79 {
80         if (self.sounds == 0)
81                 self.sounds = 2;
82
83     if(self.spawnflags & 4)
84         self.dmg = 10000;
85
86     if(self.dmg && (self.message == ""))
87                 self.message = "was squished";
88     if(self.dmg && (self.message2 == ""))
89                 self.message2 = "was squished by";
90
91         if (self.sounds == 1)
92         {
93                 precache_sound ("plats/plat1.wav");
94                 precache_sound ("plats/plat2.wav");
95                 self.noise = "plats/plat1.wav";
96                 self.noise1 = "plats/plat2.wav";
97         }
98
99         if (self.sounds == 2)
100         {
101                 precache_sound ("plats/medplat1.wav");
102                 precache_sound ("plats/medplat2.wav");
103                 self.noise = "plats/medplat1.wav";
104                 self.noise1 = "plats/medplat2.wav";
105         }
106
107         if (self.sound1)
108         {
109                 precache_sound (self.sound1);
110                 self.noise = self.sound1;
111         }
112         if (self.sound2)
113         {
114                 precache_sound (self.sound2);
115                 self.noise1 = self.sound2;
116         }
117
118         self.mangle = self.angles;
119         self.angles = '0 0 0';
120
121         self.classname = "plat";
122         if (!InitMovingBrushTrigger())
123                 return;
124         self.effects |= EF_LOWPRECISION;
125         setsize (self, self.mins , self.maxs);
126
127         self.blocked = plat_crush;
128
129         if (!self.speed)
130                 self.speed = 150;
131         if (!self.lip)
132                 self.lip = 16;
133         if (!self.height)
134                 self.height = self.size_z - self.lip;
135
136         self.pos1 = self.origin;
137         self.pos2 = self.origin;
138         self.pos2_z = self.origin_z - self.height;
139
140         self.reset = plat_reset;
141         plat_reset();
142
143         plat_link();
144
145         InitializeEntity(self, plat_delayedinit, INITPRIO_FINDTARGET);
146 }
147 #elif defined(CSQC)
148 void plat_draw()
149 {
150
151 }
152
153 void ent_plat()
154 {
155         float sf = ReadByte();
156
157         if(sf & SF_TRIGGER_INIT)
158         {
159                 self.sv_entnum = ReadShort();
160                 self.target = strzone(ReadString());
161                 self.target2 = strzone(ReadString());
162                 self.target3 = strzone(ReadString());
163                 self.target4 = strzone(ReadString());
164                 self.targetname = strzone(ReadString());
165
166                 self.platmovetype_start = ReadByte();
167                 self.platmovetype_turn = ReadByte();
168                 self.platmovetype_end = ReadByte();
169
170                 self.origin_x = ReadCoord();
171                 self.origin_y = ReadCoord();
172                 self.origin_z = ReadCoord();
173                 setorigin(self, self.origin);
174
175                 self.model = strzone(ReadString());
176                 setmodel(self, self.model);
177
178                 self.mins_x = ReadCoord();
179                 self.mins_y = ReadCoord();
180                 self.mins_z = ReadCoord();
181                 self.maxs_x = ReadCoord();
182                 self.maxs_y = ReadCoord();
183                 self.maxs_z = ReadCoord();
184                 setsize(self, self.mins, self.maxs);
185
186                 self.pos1_x = ReadCoord();
187                 self.pos1_y = ReadCoord();
188                 self.pos1_z = ReadCoord();
189                 self.pos2_x = ReadCoord();
190                 self.pos2_y = ReadCoord();
191                 self.pos2_z = ReadCoord();
192
193                 self.size_x = ReadCoord();
194                 self.size_y = ReadCoord();
195                 self.size_z = ReadCoord();
196
197                 self.angles_x = ReadAngle();
198                 self.angles_y = ReadAngle();
199                 self.angles_z = ReadAngle();
200
201                 self.mangle_x = ReadAngle();
202                 self.mangle_y = ReadAngle();
203                 self.mangle_z = ReadAngle();
204
205                 self.speed = ReadShort();
206                 self.height = ReadShort();
207                 self.lip = ReadByte();
208                 self.state = ReadByte();
209
210                 self.dmg = ReadShort();
211
212                 self.solid = SOLID_BSP;
213                 self.movetype = MOVETYPE_PUSH;
214                 self.drawmask = MASK_NORMAL;
215                 self.draw = plat_draw;
216                 self.use = plat_use;
217
218                 plat_reset(); // also called here
219         }
220
221         if(sf & SF_TRIGGER_RESET)
222         {
223                 plat_reset();
224         }
225 }
226 #endif