3 float STATE_BOTTOM = 1;
11 void() plat_center_touch;
12 void() plat_outside_touch;
13 void() plat_trigger_use;
17 float PLAT_LOW_TRIGGER = 1;
19 void plat_spawn_inside_trigger()
22 local vector tmin, tmax;
25 trigger.touch = plat_center_touch;
26 trigger.movetype = MOVETYPE_NONE;
27 trigger.solid = SOLID_TRIGGER;
30 tmin = self.absmin + '25 25 0';
31 tmax = self.absmax - '25 25 -8';
32 tmin_z = tmax_z - (self.pos1_z - self.pos2_z + 8);
33 if (self.spawnflags & PLAT_LOW_TRIGGER)
36 if (self.size_x <= 50)
38 tmin_x = (self.mins_x + self.maxs_x) / 2;
41 if (self.size_y <= 50)
43 tmin_y = (self.mins_y + self.maxs_y) / 2;
47 setsize (trigger, tmin, tmax);
52 sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
54 self.think = plat_go_down;
55 self.nextthink = self.ltime + 3;
58 void plat_hit_bottom()
60 sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
66 sound (self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
68 SUB_CalcMove (self.pos2, self.speed, plat_hit_bottom);
73 sound (self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
75 SUB_CalcMove (self.pos1, self.speed, plat_hit_top);
78 void plat_center_touch()
80 if not(other.iscreature)
83 if (other.health <= 0)
89 else if (self.state == 1)
90 self.nextthink = self.ltime + 1; // delay going down
93 void plat_outside_touch()
95 if not(other.iscreature)
98 if (other.health <= 0)
106 void plat_trigger_use()
109 return; // allready activated
116 if((self.spawnflags & 4) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!!
117 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
119 if((self.dmg) && (other.takedamage != DAMAGE_NO)) { // Shall we bite?
120 Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
121 // Gib dead/dying stuff
122 if(other.deadflag != DEAD_NO)
123 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
128 else if (self.state == 3)
131 objerror ("plat_crush: bad self.state\n");
139 objerror ("plat_use: not in up state");
143 void plat_init_movedown()
145 setorigin (self, self.pos2);
149 .string sound1, sound2;
151 void spawnfunc_path_corner() { };
152 void spawnfunc_func_plat()
159 if (self.sounds == 0)
162 if(self.spawnflags & 4)
165 if(self.dmg && (!self.message))
166 self.message = "was squished";
167 if(self.dmg && (!self.message2))
168 self.message2 = "was squished by";
170 if (self.sounds == 1)
172 precache_sound ("plats/plat1.wav");
173 precache_sound ("plats/plat2.wav");
174 self.noise = "plats/plat1.wav";
175 self.noise1 = "plats/plat2.wav";
178 if (self.sounds == 2)
180 precache_sound ("plats/medplat1.wav");
181 precache_sound ("plats/medplat2.wav");
182 self.noise = "plats/medplat1.wav";
183 self.noise1 = "plats/medplat2.wav";
188 precache_sound (self.sound1);
189 self.noise = self.sound1;
193 precache_sound (self.sound2);
194 self.noise1 = self.sound2;
197 self.mangle = self.angles;
198 self.angles = '0 0 0';
200 self.classname = "plat";
201 InitMovingBrushTrigger();
202 self.effects |= EF_LOWPRECISION;
203 setsize (self, self.mins , self.maxs);
205 self.blocked = plat_crush;
210 self.pos1 = self.origin;
211 self.pos2 = self.origin;
212 self.pos2_z = self.origin_z - self.size_z + 8;
214 self.use = plat_trigger_use;
216 plat_spawn_inside_trigger (); // the "start moving" trigger
224 InitializeEntity(self, plat_init_movedown, INITPRIO_SETLOCATION);
231 self.think = train_next;
232 self.nextthink = self.ltime + self.wait;
238 targ = find(world, targetname, self.target);
239 self.target = targ.target;
241 objerror("train_next: no next target");
242 self.wait = targ.wait;
248 SUB_CalcMove(targ.origin - self.mins, targ.speed, train_next);
250 SUB_CalcMove(targ.origin - self.mins, self.speed, train_next);
255 SUB_CalcMove(targ.origin - self.mins, targ.speed, train_wait);
257 SUB_CalcMove(targ.origin - self.mins, self.speed, train_wait);
261 void func_train_find()
264 targ = find(world, targetname, self.target);
265 self.target = targ.target;
267 objerror("func_train_find: no next target");
268 setorigin(self, targ.origin - self.mins);
269 self.nextthink = self.ltime + 1;
270 self.think = train_next;
273 /*QUAKED spawnfunc_func_train (0 .5 .8) ?
274 Ridable platform, targets spawnfunc_path_corner path to follow.
275 speed : speed the train moves (can be overridden by each spawnfunc_path_corner)
276 target : targetname of first spawnfunc_path_corner (starts here)
278 void spawnfunc_func_train()
281 objerror("func_train without a target");
285 InitMovingBrushTrigger();
286 self.effects |= EF_LOWPRECISION;
288 // wait for targets to spawn
289 InitializeEntity(self, func_train_find, INITPRIO_SETLOCATION);
294 void rotating_blocked()
297 if(self.dmg && other.takedamage != DAMAGE_NO) {
298 if(self.dmgtime2 < time) {
299 Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
300 self.dmgtime2 = time + self.dmgtime;
303 // Gib dead/dying stuff
304 if(other.deadflag != DEAD_NO)
305 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
311 /*QUAKED spawnfunc_func_rotating (0 .5 .8) ? - - X_AXIS Y_AXIS
312 Brush model that spins in place on one axis (default Z).
313 speed : speed to rotate (in degrees per second)
314 noise : path/name of looping .wav file to play.
315 dmg : Do this mutch dmg every .dmgtime intervall when blocked
319 void spawnfunc_func_rotating()
323 precache_sound(self.noise);
324 ambientsound(self.origin, self.noise, VOL_BASE, ATTN_IDLE);
328 // FIXME: test if this turns the right way, then remove this comment (negate as needed)
329 if (self.spawnflags & 4) // X (untested)
330 self.avelocity = '0 0 1' * self.speed;
331 // FIXME: test if this turns the right way, then remove this comment (negate as needed)
332 else if (self.spawnflags & 8) // Y (untested)
333 self.avelocity = '1 0 0' * self.speed;
334 // FIXME: test if this turns the right way, then remove this comment (negate as needed)
336 self.avelocity = '0 1 0' * self.speed;
338 if(self.dmg & (!self.message))
339 self.message = " was squished";
340 if(self.dmg && (!self.message2))
341 self.message2 = "was squished by";
344 if(self.dmg && (!self.dmgtime))
347 self.dmgtime2 = time;
349 InitMovingBrushTrigger();
350 // no EF_LOWPRECISION here, as rounding angles is bad
352 self.blocked = rotating_blocked;
354 // wait for targets to spawn
355 self.nextthink = self.ltime + 999999999;
356 self.think = SUB_Null;
360 void func_bobbing_controller_think()
363 self.nextthink = time + 0.1;
364 // calculate sinewave using makevectors
365 makevectors((time * self.owner.cnt + self.owner.phase * 360) * '0 1 0');
366 v = self.owner.destvec + self.owner.movedir * v_forward_y;
367 // * 10 so it will arrive in 0.1 sec
368 self.owner.velocity = (v - self.owner.origin) * 10;
371 void bobbing_blocked()
373 // no need to duplicate code
377 /*QUAKED spawnfunc_func_bobbing (0 .5 .8) ? X_AXIS Y_AXIS
378 Brush model that moves back and forth on one axis (default Z).
379 speed : how long one cycle takes in seconds (default 4)
380 height : how far the cycle moves (default 32)
381 phase : cycle timing adjustment (0-1 as a fraction of the cycle, default 0)
382 noise : path/name of looping .wav file to play.
383 dmg : Do this mutch dmg every .dmgtime intervall when blocked
386 void spawnfunc_func_bobbing()
388 local entity controller;
391 precache_sound(self.noise);
392 ambientsound(self.origin, self.noise, VOL_BASE, ATTN_IDLE);
398 // center of bobbing motion
399 self.destvec = self.origin;
400 // time scale to get degrees
401 self.cnt = 360 / self.speed;
403 // damage when blocked
404 self.blocked = bobbing_blocked;
405 if(self.dmg & (!self.message))
406 self.message = " was squished";
407 if(self.dmg && (!self.message2))
408 self.message2 = "was squished by";
409 if(self.dmg && (!self.dmgtime))
411 self.dmgtime2 = time;
414 if (self.spawnflags & 1) // X
415 self.movedir = '1 0 0' * self.height;
416 else if (self.spawnflags & 2) // Y
417 self.movedir = '0 1 0' * self.height;
419 self.movedir = '0 0 1' * self.height;
421 InitMovingBrushTrigger();
423 // wait for targets to spawn
424 controller = spawn();
425 controller.classname = "func_bobbing_controller";
426 controller.owner = self;
427 controller.nextthink = time + 1;
428 controller.think = func_bobbing_controller_think;
429 self.nextthink = self.ltime + 999999999;
430 self.think = SUB_Null;
432 // Savage: Reduce bandwith, critical on e.g. nexdm02
433 self.effects |= EF_LOWPRECISION;
436 // button and multiple button
439 void() button_return;
443 self.state = STATE_TOP;
444 self.nextthink = self.ltime + self.wait;
445 self.think = button_return;
446 activator = self.enemy;
448 self.frame = 1; // use alternate textures
453 self.state = STATE_BOTTOM;
458 self.state = STATE_DOWN;
459 SUB_CalcMove (self.pos1, self.speed, button_done);
460 self.frame = 0; // use normal textures
462 self.takedamage = DAMAGE_YES; // can be shot again
466 void button_blocked()
468 // do nothing, just don't come all the way back out
474 self.health = self.max_health;
475 self.takedamage = DAMAGE_NO; // will be reset upon return
477 if (self.state == STATE_UP || self.state == STATE_TOP)
480 if (self.noise != "")
481 sound (self, CHAN_TRIGGER, self.noise, VOL_BASE, ATTN_NORM);
483 self.state = STATE_UP;
484 SUB_CalcMove (self.pos2, self.speed, button_wait);
490 // if (activator.classname != "player")
492 // dprint(activator.classname);
493 // dprint(" triggered a button\n");
495 self.enemy = activator;
501 // if (activator.classname != "player")
503 // dprint(activator.classname);
504 // dprint(" touched a button\n");
508 if not(other.iscreature)
510 if(other.velocity * self.movedir < 0)
514 self.enemy = other.owner;
518 void button_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
520 self.health = self.health - damage;
521 if (self.health <= 0)
523 // if (activator.classname != "player")
525 // dprint(activator.classname);
526 // dprint(" killed a button\n");
528 self.enemy = damage_attacker;
534 /*QUAKED spawnfunc_func_button (0 .5 .8) ?
535 When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again.
537 "angle" determines the opening direction
538 "target" all entities with a matching targetname will be used
539 "speed" override the default 40 speed
540 "wait" override the default 1 second wait (-1 = never return)
541 "lip" override the default 4 pixel lip remaining at end of move
542 "health" if set, the button must be killed instead of touched. If set to -1, the button will fire on ANY attack, even damageless ones like the MinstaGib laser
549 void spawnfunc_func_button()
553 InitMovingBrushTrigger();
554 self.effects |= EF_LOWPRECISION;
556 self.blocked = button_blocked;
557 self.use = button_use;
559 // if (self.health == 0) // all buttons are now shootable
563 self.max_health = self.health;
564 self.event_damage = button_damage;
565 self.takedamage = DAMAGE_YES;
568 self.touch = button_touch;
578 precache_sound(self.noise);
580 self.state = STATE_BOTTOM;
582 self.pos1 = self.origin;
583 self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
587 float DOOR_START_OPEN = 1;
588 float DOOR_DONT_LINK = 4;
589 float DOOR_TOGGLE = 32;
593 Doors are similar to buttons, but can spawn a fat trigger field around them
594 to open without a touch, and they link together to form simultanious
597 Door.owner is the master door. If there is only one door, it points to itself.
598 If multiple doors, all will point to a single one.
600 Door.enemy chains from the master door through all doors linked in the chain.
605 =============================================================================
609 =============================================================================
614 void() door_rotating_go_down;
615 void() door_rotating_go_up;
620 if((self.spawnflags & 8) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!!
621 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
624 if((self.dmg) && (other.takedamage == DAMAGE_YES)) // Shall we bite?
625 Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
627 //Dont chamge direction for dead or dying stuff
628 if(other.deadflag != DEAD_NO && (other.takedamage == DAMAGE_NO)) {
631 if (self.state == STATE_DOWN)
632 if (self.classname == "door")
637 door_rotating_go_up ();
640 if (self.classname == "door")
645 door_rotating_go_down ();
649 //gib dying stuff just to make sure
650 if((self.dmg) && (other.takedamage != DAMAGE_NO)) // Shall we bite?
651 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
655 //T_Damage (other, self, self, self.dmg, self.dmg, self.deathtype, DT_IMPACT, (self.absmin + self.absmax) * 0.5, '0 0 0', Obituary_Generic);
656 // if a door has a negative wait, it would never come back if blocked,
657 // so let it just squash the object to death real fast
658 /* if (self.wait >= 0)
660 if (self.state == STATE_DOWN)
671 if (self.noise1 != "")
672 sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
673 self.state = STATE_TOP;
674 if (self.spawnflags & DOOR_TOGGLE)
675 return; // don't come down automatically
676 if (self.classname == "door")
678 self.think = door_go_down;
681 self.think = door_rotating_go_down;
683 self.nextthink = self.ltime + self.wait;
686 void door_hit_bottom()
688 if (self.noise1 != "")
689 sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
690 self.state = STATE_BOTTOM;
695 if (self.noise2 != "")
696 sound (self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
699 self.takedamage = DAMAGE_YES;
700 self.health = self.max_health;
703 self.state = STATE_DOWN;
704 SUB_CalcMove (self.pos1, self.speed, door_hit_bottom);
709 if (self.state == STATE_UP)
710 return; // allready going up
712 if (self.state == STATE_TOP)
713 { // reset top wait time
714 self.nextthink = self.ltime + self.wait;
718 if (self.noise2 != "")
719 sound (self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
720 self.state = STATE_UP;
721 SUB_CalcMove (self.pos2, self.speed, door_hit_top);
724 oldmessage = self.message;
727 self.message = oldmessage;
732 =============================================================================
736 =============================================================================
744 if (self.owner != self)
745 objerror ("door_fire: self.owner != self");
749 if (self.spawnflags & DOOR_TOGGLE)
751 if (self.state == STATE_UP || self.state == STATE_TOP)
756 if (self.classname == "door")
762 door_rotating_go_down ();
765 } while ( (self != starte) && (self != world) );
771 // trigger all paired doors
775 if (self.classname == "door")
780 door_rotating_go_up ();
783 } while ( (self != starte) && (self != world) );
792 //dprint("door_use (model: ");dprint(self.model);dprint(")\n");
803 void door_trigger_touch()
805 if (other.health < 1)
806 if not(other.iscreature && other.deadflag == DEAD_NO)
809 if (time < self.attack_finished_single)
811 self.attack_finished_single = time + 1;
820 void door_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
823 self.health = self.health - damage;
824 if (self.health <= 0)
828 self.health = self.max_health;
829 self.takedamage = DAMAGE_NO; // wil be reset upon return
845 if(other.classname != "player")
847 if (self.owner.attack_finished_single > time)
850 self.owner.attack_finished_single = time + 2;
852 if (!(self.owner.dmg) && (self.owner.message != ""))
854 if (other.flags & FL_CLIENT)
855 centerprint (other, self.owner.message);
856 play2(other, "misc/talk.wav");
861 void door_rotating_blocked()
864 if((self.spawnflags & 8) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!!
865 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
868 if((self.dmg) && (other.takedamage == DAMAGE_YES)) // Shall we bite?
869 Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
871 //Dont chamge direction for dead or dying stuff
872 if(other.deadflag != DEAD_NO && (other.takedamage == DAMAGE_NO)) {
875 if (self.state == STATE_DOWN)
876 door_rotating_go_up ();
878 door_rotating_go_down ();
881 //gib dying stuff just to make sure
882 if((self.dmg) && (other.takedamage != DAMAGE_NO)) // Shall we bite?
883 Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
887 //T_Damage (other, self, self, self.dmg, self.dmg, self.deathtype, DT_IMPACT, (self.absmin + self.absmax) * 0.5, '0 0 0', Obituary_Generic);
888 // if a door has a negative wait, it would never come back if blocked,
889 // so let it just squash the object to death real fast
890 /* if (self.wait >= 0)
892 if (self.state == STATE_DOWN)
893 door_rotating_go_up ();
895 door_rotating_go_down ();
901 void door_rotating_hit_top()
903 if (self.noise1 != "")
904 sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
905 self.state = STATE_TOP;
906 if (self.spawnflags & DOOR_TOGGLE)
907 return; // don't come down automatically
908 self.think = door_rotating_go_down;
909 self.nextthink = self.ltime + self.wait;
912 void door_rotating_hit_bottom()
914 if (self.noise1 != "")
915 sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
916 self.state = STATE_BOTTOM;
919 void door_rotating_go_down()
921 if (self.noise2 != "")
922 sound (self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
925 self.takedamage = DAMAGE_YES;
926 self.health = self.max_health;
929 self.state = STATE_DOWN;
930 SUB_CalcAngleMove (self.pos1, self.speed, door_hit_bottom);
933 void door_rotating_go_up()
935 if (self.state == STATE_UP)
936 return; // already going up
938 if (self.state == STATE_TOP)
939 { // reset top wait time
940 self.nextthink = self.ltime + self.wait;
943 if (self.noise2 != "")
944 sound (self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
945 self.state = STATE_UP;
946 SUB_CalcAngleMove (self.pos2, self.speed, door_rotating_hit_top);
949 oldmessage = self.message;
952 self.message = oldmessage;
959 =============================================================================
963 =============================================================================
967 entity spawn_field(vector fmins, vector fmaxs)
969 local entity trigger;
973 trigger.classname = "doortriggerfield";
974 trigger.movetype = MOVETYPE_NONE;
975 trigger.solid = SOLID_TRIGGER;
976 trigger.owner = self;
977 trigger.touch = door_trigger_touch;
981 setsize (trigger, t1 - '60 60 8', t2 + '60 60 8');
986 float EntitiesTouching(entity e1, entity e2)
988 if (e1.absmin_x > e2.absmax_x)
990 if (e1.absmin_y > e2.absmax_y)
992 if (e1.absmin_z > e2.absmax_z)
994 if (e1.absmax_x < e2.absmin_x)
996 if (e1.absmax_y < e2.absmin_y)
998 if (e1.absmax_z < e2.absmin_z)
1013 local entity t, starte;
1014 local vector cmins, cmaxs;
1017 return; // already linked by another door
1018 if (self.spawnflags & 4)
1020 self.owner = self.enemy = self;
1028 self.trigger_field = spawn_field(self.absmin, self.absmax);
1030 return; // don't want to link this door
1033 cmins = self.absmin;
1034 cmaxs = self.absmax;
1041 self.owner = starte; // master door
1044 starte.health = self.health;
1046 starte.targetname = self.targetname;
1047 if (self.message != "")
1048 starte.message = self.message;
1050 t = find(t, classname, self.classname);
1053 self.enemy = starte; // make the chain a loop
1055 // shootable, or triggered doors just needed the owner/enemy links,
1056 // they don't spawn a field
1067 self.owner.trigger_field = spawn_field(cmins, cmaxs);
1072 if (EntitiesTouching(self,t))
1075 objerror ("cross connected doors");
1080 if (t.absmin_x < cmins_x)
1081 cmins_x = t.absmin_x;
1082 if (t.absmin_y < cmins_y)
1083 cmins_y = t.absmin_y;
1084 if (t.absmin_z < cmins_z)
1085 cmins_z = t.absmin_z;
1086 if (t.absmax_x > cmaxs_x)
1087 cmaxs_x = t.absmax_x;
1088 if (t.absmax_y > cmaxs_y)
1089 cmaxs_y = t.absmax_y;
1090 if (t.absmax_z > cmaxs_z)
1091 cmaxs_z = t.absmax_z;
1098 /*QUAKED spawnfunc_func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK x x TOGGLE
1099 if two doors touch, they are assumed to be connected and operate as a unit.
1101 TOGGLE causes the door to wait in both the start and end states for a trigger event.
1103 START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not useful for touch or takedamage doors).
1105 "message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
1106 "angle" determines the opening direction
1107 "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
1108 "health" if set, door must be shot open
1109 "speed" movement speed (100 default)
1110 "wait" wait before returning (3 default, -1 = never return)
1111 "lip" lip remaining at end of move (8 default)
1112 "dmg" damage to inflict when blocked (2 default)
1119 FIXME: only one sound set available at the time being
1123 void door_init_startopen()
1125 setorigin (self, self.pos2);
1126 self.pos2 = self.pos1;
1127 self.pos1 = self.origin;
1130 void spawnfunc_func_door()
1132 //if (!self.deathtype) // map makers can override this
1133 // self.deathtype = " got in the way";
1136 self.max_health = self.health;
1137 InitMovingBrushTrigger();
1138 self.effects |= EF_LOWPRECISION;
1139 self.classname = "door";
1141 self.blocked = door_blocked;
1142 self.use = door_use;
1144 if(self.spawnflags & 8)
1147 if(self.dmg && (!self.message))
1148 self.message = "was squished";
1149 if(self.dmg && (!self.message2))
1150 self.message2 = "was squished by";
1152 if (self.sounds > 0)
1154 precache_sound ("plats/medplat1.wav");
1155 precache_sound ("plats/medplat2.wav");
1156 self.noise2 = "plats/medplat1.wav";
1157 self.noise1 = "plats/medplat2.wav";
1167 self.pos1 = self.origin;
1168 self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
1170 // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
1171 // but spawn in the open position
1172 if (self.spawnflags & DOOR_START_OPEN)
1173 InitializeEntity(self, door_init_startopen, INITPRIO_SETLOCATION);
1175 self.state = STATE_BOTTOM;
1179 self.takedamage = DAMAGE_YES;
1180 self.event_damage = door_damage;
1186 self.touch = door_touch;
1188 // LinkDoors can't be done until all of the doors have been spawned, so
1189 // the sizes can be detected properly.
1190 InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
1193 /*QUAKED spawnfunc_func_door_rotating (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK x x TOGGLE X_AXIS Y_AXIS BIDIR
1194 if two doors touch, they are assumed to be connected and operate as a unit.
1196 TOGGLE causes the door to wait in both the start and end states for a trigger event.
1198 BIDIR makes the door work bidirectional, so that the opening direction is always away from the requestor.
1199 This feature is NOT YET IMPLEMENTED!
1201 START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
1203 "message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
1204 "angle" determines the destination angle for opening. negative values reverse the direction.
1205 "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
1206 "health" if set, door must be shot open
1207 "speed" movement speed (100 default)
1208 "wait" wait before returning (3 default, -1 = never return)
1209 "dmg" damage to inflict when blocked (2 default)
1216 FIXME: only one sound set available at the time being
1219 void door_rotating_init_startopen()
1221 self.angles = self.movedir;
1222 self.pos2 = '0 0 0';
1223 self.pos1 = self.movedir;
1227 void spawnfunc_func_door_rotating()
1230 //if (!self.deathtype) // map makers can override this
1231 // self.deathtype = " got in the way";
1233 // I abuse "movedir" for denoting the axis for now
1234 if (self.spawnflags & 64) // X (untested)
1235 self.movedir = '0 0 1';
1236 else if (self.spawnflags & 128) // Y (untested)
1237 self.movedir = '1 0 0';
1239 self.movedir = '0 1 0';
1241 if (self.angles_y==0) self.angles_y = 90;
1243 self.movedir = self.movedir * self.angles_y;
1244 self.angles = '0 0 0';
1246 self.max_health = self.health;
1247 InitMovingBrushTrigger();
1248 //self.effects |= EF_LOWPRECISION;
1249 self.classname = "door_rotating";
1251 self.blocked = door_blocked;
1252 self.use = door_use;
1254 if(self.spawnflags & 8)
1257 if(self.dmg && (!self.message))
1258 self.message = "was squished";
1259 if(self.dmg && (!self.message2))
1260 self.message2 = "was squished by";
1262 if (self.sounds > 0)
1264 precache_sound ("plats/medplat1.wav");
1265 precache_sound ("plats/medplat2.wav");
1266 self.noise2 = "plats/medplat1.wav";
1267 self.noise1 = "plats/medplat2.wav";
1275 self.pos1 = '0 0 0';
1276 self.pos2 = self.movedir;
1278 // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
1279 // but spawn in the open position
1280 if (self.spawnflags & DOOR_START_OPEN)
1281 InitializeEntity(self, door_rotating_init_startopen, INITPRIO_SETLOCATION);
1283 self.state = STATE_BOTTOM;
1287 self.takedamage = DAMAGE_YES;
1288 self.event_damage = door_damage;
1294 self.touch = door_touch;
1296 // LinkDoors can't be done until all of the doors have been spawned, so
1297 // the sizes can be detected properly.
1298 InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
1302 =============================================================================
1306 =============================================================================
1309 void() fd_secret_move1;
1310 void() fd_secret_move2;
1311 void() fd_secret_move3;
1312 void() fd_secret_move4;
1313 void() fd_secret_move5;
1314 void() fd_secret_move6;
1315 void() fd_secret_done;
1317 float SECRET_OPEN_ONCE = 1; // stays open
1318 float SECRET_1ST_LEFT = 2; // 1st move is left of arrow
1319 float SECRET_1ST_DOWN = 4; // 1st move is down from arrow
1320 float SECRET_NO_SHOOT = 8; // only opened by trigger
1321 float SECRET_YES_SHOOT = 16; // shootable even if targeted
1324 void fd_secret_use()
1327 string message_save;
1329 self.health = 10000;
1330 self.bot_attack = TRUE;
1332 // exit if still moving around...
1333 if (self.origin != self.oldorigin)
1336 message_save = self.message;
1337 self.message = ""; // no more message
1338 SUB_UseTargets(); // fire all targets / killtargets
1339 self.message = message_save;
1341 self.velocity = '0 0 0';
1343 // Make a sound, wait a little...
1345 if (self.noise1 != "")
1346 sound(self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
1347 self.nextthink = self.ltime + 0.1;
1349 temp = 1 - (self.spawnflags & SECRET_1ST_LEFT); // 1 or -1
1350 makevectors(self.mangle);
1354 if (self.spawnflags & SECRET_1ST_DOWN)
1355 self.t_width = fabs(v_up * self.size);
1357 self.t_width = fabs(v_right * self.size);
1361 self.t_length = fabs(v_forward * self.size);
1363 if (self.spawnflags & SECRET_1ST_DOWN)
1364 self.dest1 = self.origin - v_up * self.t_width;
1366 self.dest1 = self.origin + v_right * (self.t_width * temp);
1368 self.dest2 = self.dest1 + v_forward * self.t_length;
1369 SUB_CalcMove(self.dest1, self.speed, fd_secret_move1);
1370 if (self.noise2 != "")
1371 sound(self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
1374 // Wait after first movement...
1375 void fd_secret_move1()
1377 self.nextthink = self.ltime + 1.0;
1378 self.think = fd_secret_move2;
1379 if (self.noise3 != "")
1380 sound(self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NORM);
1383 // Start moving sideways w/sound...
1384 void fd_secret_move2()
1386 if (self.noise2 != "")
1387 sound(self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
1388 SUB_CalcMove(self.dest2, self.speed, fd_secret_move3);
1391 // Wait here until time to go back...
1392 void fd_secret_move3()
1394 if (self.noise3 != "")
1395 sound(self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NORM);
1396 if (!(self.spawnflags & SECRET_OPEN_ONCE))
1398 self.nextthink = self.ltime + self.wait;
1399 self.think = fd_secret_move4;
1404 void fd_secret_move4()
1406 if (self.noise2 != "")
1407 sound(self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
1408 SUB_CalcMove(self.dest1, self.speed, fd_secret_move5);
1412 void fd_secret_move5()
1414 self.nextthink = self.ltime + 1.0;
1415 self.think = fd_secret_move6;
1416 if (self.noise3 != "")
1417 sound(self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NORM);
1420 void fd_secret_move6()
1422 if (self.noise2 != "")
1423 sound(self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
1424 SUB_CalcMove(self.oldorigin, self.speed, fd_secret_done);
1427 void fd_secret_done()
1429 if (self.spawnflags&SECRET_YES_SHOOT)
1431 self.health = 10000;
1432 self.takedamage = DAMAGE_YES;
1433 //self.th_pain = fd_secret_use;
1435 if (self.noise3 != "")
1436 sound(self, CHAN_TRIGGER, self.noise3, VOL_BASE, ATTN_NORM);
1439 void secret_blocked()
1441 if (time < self.attack_finished_single)
1443 self.attack_finished_single = time + 0.5;
1444 //T_Damage (other, self, self, self.dmg, self.dmg, self.deathtype, DT_IMPACT, (self.absmin + self.absmax) * 0.5, '0 0 0', Obituary_Generic);
1456 if not(other.iscreature)
1458 if (self.attack_finished_single > time)
1461 self.attack_finished_single = time + 2;
1465 if (other.flags & FL_CLIENT)
1466 centerprint (other, self.message);
1467 play2(other, "misc/talk.wav");
1472 /*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
1473 Basic secret door. Slides back, then to the side. Angle determines direction.
1474 wait = # of seconds before coming back
1475 1st_left = 1st move is left of arrow
1476 1st_down = 1st move is down from arrow
1477 always_shoot = even if targeted, keep shootable
1478 t_width = override WIDTH to move back (or height if going down)
1479 t_length = override LENGTH to move sideways
1480 "dmg" damage to inflict when blocked (2 default)
1482 If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
1489 void spawnfunc_func_door_secret()
1491 /*if (!self.deathtype) // map makers can override this
1492 self.deathtype = " got in the way";*/
1498 self.mangle = self.angles;
1499 self.angles = '0 0 0';
1500 self.classname = "door";
1501 InitMovingBrushTrigger();
1502 self.effects |= EF_LOWPRECISION;
1504 self.touch = secret_touch;
1505 self.blocked = secret_blocked;
1507 self.use = fd_secret_use;
1512 self.spawnflags |= SECRET_YES_SHOOT;
1514 if(self.spawnflags&SECRET_YES_SHOOT)
1516 self.health = 10000;
1517 self.takedamage = DAMAGE_YES;
1518 self.event_damage = fd_secret_use;
1520 self.oldorigin = self.origin;
1522 self.wait = 5; // 5 seconds before closing