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