1 void() plat_center_touch;
2 void() plat_outside_touch;
3 void() plat_trigger_use;
7 float PLAT_LOW_TRIGGER = 1;
9 void() plat_spawn_inside_trigger =
12 local vector tmin, tmax;
15 trigger.touch = plat_center_touch;
16 trigger.movetype = MOVETYPE_NONE;
17 trigger.solid = SOLID_TRIGGER;
20 tmin = self.mins + '25 25 0';
21 tmax = self.maxs - '25 25 -8';
22 tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8);
23 if (self.spawnflags & PLAT_LOW_TRIGGER)
26 if (self.size_x <= 50)
28 tmin_x = (self.mins_x + self.maxs_x) / 2;
31 if (self.size_y <= 50)
33 tmin_y = (self.mins_y + self.maxs_y) / 2;
37 setsize (trigger, tmin, tmax);
42 sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
44 self.think = plat_go_down;
45 self.nextthink = self.ltime + 3;
48 void() plat_hit_bottom =
50 sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
56 sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
58 SUB_CalcMove (self.pos2, self.speed, plat_hit_bottom);
63 sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
65 SUB_CalcMove (self.pos1, self.speed, plat_hit_top);
68 void() plat_center_touch =
70 if (other.classname != "player")
73 if (other.health <= 0)
79 else if (self.state == 1)
80 self.nextthink = self.ltime + 1; // delay going down
83 void() plat_outside_touch =
85 if (other.classname != "player")
88 if (other.health <= 0)
96 void() plat_trigger_use =
99 return; // allready activated
108 else if (self.state == 3)
111 objerror ("plat_crush: bad self.state\n");
118 objerror ("plat_use: not in up state");
123 .string sound1, sound2;
132 if (self.sounds == 0)
135 if (self.sounds == 1)
137 precache_sound ("plats/plat1.wav");
138 precache_sound ("plats/plat2.wav");
139 self.noise = "plats/plat1.wav";
140 self.noise1 = "plats/plat2.wav";
143 if (self.sounds == 2)
145 precache_sound ("plats/medplat1.wav");
146 precache_sound ("plats/medplat2.wav");
147 self.noise = "plats/medplat1.wav";
148 self.noise1 = "plats/medplat2.wav";
153 precache_sound (self.sound1);
154 self.noise = self.sound1;
158 precache_sound (self.sound2);
159 self.noise1 = self.sound2;
162 self.mangle = self.angles;
163 self.angles = '0 0 0';
165 self.classname = "plat";
166 self.solid = SOLID_BSP;
167 self.movetype = MOVETYPE_PUSH;
168 setorigin (self, self.origin);
169 setmodel (self, self.model);
170 setsize (self, self.mins , self.maxs);
172 self.blocked = plat_crush;
175 self.pos1 = self.origin;
176 self.pos2 = self.origin;
177 self.pos2_z = self.origin_z - self.size_z + 8;
179 self.use = plat_trigger_use;
181 plat_spawn_inside_trigger (); // the "start moving" trigger
190 setorigin (self, self.pos2);
198 void() func_train_find;
200 void() train_blocked =
202 if (time < self.attack_finished)
204 self.attack_finished = time + 0.5;
208 if (self.think != func_train_find)
217 self.nextthink = self.ltime + self.wait;
218 sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
221 self.nextthink = self.ltime + 0.1;
223 self.think = train_next;
230 targ = find (world, targetname, self.target);
231 self.target = targ.target;
233 objerror ("train_next: no next target");
235 self.wait = targ.wait;
238 sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
239 SUB_CalcMove (targ.origin - self.mins, self.speed, train_wait);
242 void() func_train_find =
246 targ = find (world, targetname, self.target);
247 self.target = targ.target;
248 setorigin (self, targ.origin - self.mins);
249 if (!self.targetname)
250 { // not triggered, so start immediately
251 self.nextthink = self.ltime + 0.1;
252 self.think = train_next;
262 objerror ("func_train without a target");
264 if (self.sounds == 0)
266 self.noise = ("misc/null.wav");
267 precache_sound ("misc/null.wav");
268 self.noise1 = ("misc/null.wav");
269 precache_sound ("misc/null.wav");
272 if (self.sounds == 1)
274 self.noise = ("plats/train2.wav");
275 precache_sound ("plats/train2.wav");
276 self.noise1 = ("plats/train1.wav");
277 precache_sound ("plats/train1.wav");
280 self.solid = SOLID_BSP;
281 self.movetype = MOVETYPE_PUSH;
282 self.blocked = train_blocked;
283 self.use = train_use;
284 self.classname = "train";
286 setmodel (self, self.model);
287 setsize (self, self.mins , self.maxs);
288 setorigin (self, self.origin);
289 self.nextthink = self.ltime + 0.1;
290 self.think = func_train_find;
297 self.think = train_next;
298 self.nextthink = self.ltime + self.wait;
304 targ = find(world, targetname, self.target);
305 self.target = targ.target;
307 objerror("train_next: no next target");
308 self.wait = targ.wait;
312 SUB_CalcMove(targ.origin - self.mins, targ.speed, train_wait);
314 SUB_CalcMove(targ.origin - self.mins, self.speed, train_wait);
317 void() func_train_find =
320 targ = find(world, targetname, self.target);
321 self.target = targ.target;
322 setorigin(self, targ.origin - self.mins);
323 self.nextthink = self.ltime + 1;
324 self.think = train_next;
327 /*QUAKED func_train (0 .5 .8) ?
328 Ridable platform, targets path_corner path to follow.
329 speed : speed the train moves (can be overridden by each path_corner)
330 target : targetname of first path_corner (starts here)
335 objerror("func_train without a target");
339 self.solid = SOLID_BSP;
340 self.movetype = MOVETYPE_PUSH;
342 setmodel(self, self.model);
343 setsize(self, self.mins, self.maxs);
344 setorigin(self, self.origin);
346 // wait for targets to spawn
347 self.nextthink = self.ltime + 0.1;
348 self.think = func_train_find;
351 /*QUAKED func_rotating (0 .5 .8) ? - - X_AXIS Y_AXIS
352 Brush model that spins in place on one axis (default Z).
353 speed : speed to rotate (in degrees per second)
354 noise : path/name of looping .wav file to play.
356 void() func_rotating =
360 precache_sound(self.noise);
361 ambientsound(self.origin, self.noise, 1, ATTN_IDLE);
365 // FIXME: test if this turns the right way, then remove this comment (negate as needed)
366 if (self.spawnflags & 4) // X (untested)
367 self.avelocity = '0 0 1' * self.speed;
368 // FIXME: test if this turns the right way, then remove this comment (negate as needed)
369 else if (self.spawnflags & 8) // Y (untested)
370 self.avelocity = '1 0 0' * self.speed;
371 // FIXME: test if this turns the right way, then remove this comment (negate as needed)
373 self.avelocity = '0 1 0' * self.speed;
375 self.solid = SOLID_BSP;
376 self.movetype = MOVETYPE_PUSH;
378 setmodel(self, self.model);
379 setsize(self, self.mins, self.maxs);
380 setorigin(self, self.origin);
382 // wait for targets to spawn
383 self.nextthink = self.ltime + 999999999;
384 self.think = SUB_Null;
389 void() func_bobbing_controller_think =
392 self.nextthink = time + 0.1;
393 // calculate sinewave using makevectors
394 makevectors((time * self.owner.cnt + self.owner.phase) * '0 1 0');
395 v = self.owner.destvec + self.owner.movedir * v_forward_y;
396 // * 10 so it will arrive in 0.1 sec
397 self.owner.velocity = (v - self.owner.origin) * 10;
400 /*QUAKED func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS
401 Brush model that moves back and forth on one axis (default Z).
402 speed : how long one cycle takes in seconds (default 4)
403 height : how far the cycle moves (default 32)
404 phase : cycle timing adjustment (0-1 as a fraction of the cycle, default 0)
405 noise : path/name of looping .wav file to play.
407 void() func_bobbing =
409 local entity controller;
412 precache_sound(self.noise);
413 ambientsound(self.origin, self.noise, 1, ATTN_IDLE);
419 // center of bobbing motion
420 self.destvec = self.origin;
421 // time scale to get degrees
422 self.cnt = 360 / self.speed;
424 if (self.spawnflags & 1) // X
425 self.movedir = '1 0 0' * self.height;
426 else if (self.spawnflags & 2) // Y
427 self.movedir = '0 1 0' * self.height;
429 self.movedir = '0 0 1' * self.height;
431 self.solid = SOLID_BSP;
432 self.movetype = MOVETYPE_PUSH;
434 setmodel(self, self.model);
435 setsize(self, self.mins, self.maxs);
436 setorigin(self, self.origin);
438 // wait for targets to spawn
439 controller = spawn();
440 controller.classname = "func_bobbing_controller";
441 controller.owner = self;
442 controller.nextthink = time + 1;
443 controller.think = func_bobbing_controller_think;
444 self.nextthink = self.ltime + 999999999;
445 self.think = SUB_Null;