]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/plat.qc
Shoot rockets through doors
[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
16                 WriteByte(MSG_ENTITY, self.platmovetype_start);
17                 WriteByte(MSG_ENTITY, self.platmovetype_turn);
18                 WriteByte(MSG_ENTITY, self.platmovetype_end);
19
20                 WriteString(MSG_ENTITY, self.model);
21
22                 trigger_common_write(true);
23
24                 WriteCoord(MSG_ENTITY, self.pos1_x);
25                 WriteCoord(MSG_ENTITY, self.pos1_y);
26                 WriteCoord(MSG_ENTITY, self.pos1_z);
27                 WriteCoord(MSG_ENTITY, self.pos2_x);
28                 WriteCoord(MSG_ENTITY, self.pos2_y);
29                 WriteCoord(MSG_ENTITY, self.pos2_z);
30
31                 WriteCoord(MSG_ENTITY, self.size_x);
32                 WriteCoord(MSG_ENTITY, self.size_y);
33                 WriteCoord(MSG_ENTITY, self.size_z);
34
35                 WriteAngle(MSG_ENTITY, self.mangle_x);
36                 WriteAngle(MSG_ENTITY, self.mangle_y);
37                 WriteAngle(MSG_ENTITY, self.mangle_z);
38
39                 WriteShort(MSG_ENTITY, self.speed);
40                 WriteShort(MSG_ENTITY, self.height);
41                 WriteByte(MSG_ENTITY, self.lip);
42                 WriteByte(MSG_ENTITY, self.state);
43
44                 WriteShort(MSG_ENTITY, self.dmg);
45         }
46
47         if(sf & SF_TRIGGER_RESET)
48         {
49                 // used on client
50         }
51
52         return true;
53 }
54
55 void plat_link()
56 {
57         Net_LinkEntity(self, 0, false, plat_send);
58 }
59
60 void spawnfunc_func_plat()
61 {
62         if (self.sounds == 0)
63                 self.sounds = 2;
64
65     if(self.spawnflags & 4)
66         self.dmg = 10000;
67
68     if(self.dmg && (self.message == ""))
69                 self.message = "was squished";
70     if(self.dmg && (self.message2 == ""))
71                 self.message2 = "was squished by";
72
73         if (self.sounds == 1)
74         {
75                 precache_sound ("plats/plat1.wav");
76                 precache_sound ("plats/plat2.wav");
77                 self.noise = "plats/plat1.wav";
78                 self.noise1 = "plats/plat2.wav";
79         }
80
81         if (self.sounds == 2)
82         {
83                 precache_sound ("plats/medplat1.wav");
84                 precache_sound ("plats/medplat2.wav");
85                 self.noise = "plats/medplat1.wav";
86                 self.noise1 = "plats/medplat2.wav";
87         }
88
89         if (self.sound1)
90         {
91                 precache_sound (self.sound1);
92                 self.noise = self.sound1;
93         }
94         if (self.sound2)
95         {
96                 precache_sound (self.sound2);
97                 self.noise1 = self.sound2;
98         }
99
100         self.mangle = self.angles;
101         self.angles = '0 0 0';
102
103         self.classname = "plat";
104         if (!InitMovingBrushTrigger())
105                 return;
106         self.effects |= EF_LOWPRECISION;
107         setsize (self, self.mins , self.maxs);
108
109         self.blocked = plat_crush;
110
111         if (!self.speed)
112                 self.speed = 150;
113         if (!self.lip)
114                 self.lip = 16;
115         if (!self.height)
116                 self.height = self.size_z - self.lip;
117
118         self.pos1 = self.origin;
119         self.pos2 = self.origin;
120         self.pos2_z = self.origin_z - self.height;
121
122         self.reset = plat_reset;
123         plat_reset();
124
125         plat_link();
126
127         InitializeEntity(self, plat_delayedinit, INITPRIO_FINDTARGET);
128 }
129 #elif defined(CSQC)
130 void plat_draw()
131 {
132         Movetype_Physics_NoMatchServer();
133 }
134
135 void ent_plat()
136 {
137         float sf = ReadByte();
138
139         if(sf & SF_TRIGGER_INIT)
140         {
141                 self.sv_entnum = ReadShort();
142
143                 self.platmovetype_start = ReadByte();
144                 self.platmovetype_turn = ReadByte();
145                 self.platmovetype_end = 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.solid = SOLID_BSP;
175                 self.movetype = MOVETYPE_PUSH;
176                 self.drawmask = MASK_NORMAL;
177                 self.draw = plat_draw;
178                 self.use = plat_use;
179                 self.entremove = trigger_remove_generic;
180
181                 plat_reset(); // also called here
182
183                 self.move_origin = self.origin;
184                 self.move_angles = self.angles;
185                 self.move_time = time;
186         }
187
188         if(sf & SF_TRIGGER_RESET)
189         {
190                 plat_reset();
191
192                 self.move_origin = self.origin;
193                 self.move_angles = self.angles;
194                 self.move_time = time;
195         }
196 }
197 #endif