]> icculus.org git repositories - divverent/nexuiz.git/blob - TeamNexuiz/game/gamec/tfdoors.c
now menu qc respects g_campaign_name
[divverent/nexuiz.git] / TeamNexuiz / game / gamec / tfdoors.c
1 // TF DOORS     \r
2 void() door_go_down;\r
3 void() door_go_up;\r
4 float() DoorShouldOpen;\r
5 \r
6 void() fd_secret_move1;\r
7 void() fd_secret_move2;\r
8 void() fd_secret_move3;\r
9 void() fd_secret_move4;\r
10 void() fd_secret_move5;\r
11 void() fd_secret_move6;\r
12 void() fd_secret_done;\r
13 \r
14 \r
15 float() DoorShouldOpen = \r
16 {\r
17         local entity ptr;\r
18         local float plyrcount;\r
19         local entity plyr1;\r
20         local entity plyr2;\r
21         if (coop != 2)\r
22         {\r
23                 return TF_FLARE_OFF;\r
24         }\r
25         plyrcount = TF_FLARE_LIT;\r
26         ptr = find(world, classname, "player");\r
27         while (ptr != world)\r
28         {\r
29                 if (!(ptr.tf_items & self.items) && ptr.playerclass != TF_FLARE_LIT && ptr.solid != TF_FLARE_LIT && ptr.model != string_null)\r
30                 {\r
31                         plyrcount = plyrcount + TF_FLARE_OFF;\r
32                         if (plyrcount == TF_FLARE_OFF)\r
33                         {\r
34                                 plyr1 = ptr;\r
35                         }\r
36                         else\r
37                         {\r
38                                 if (plyrcount == 2)\r
39                                 {\r
40                                         plyr2 = ptr;\r
41                                 }\r
42                         }\r
43                 }\r
44                 ptr = find(ptr, classname, "player");\r
45         }\r
46         if (plyrcount != TF_FLARE_LIT)\r
47         {\r
48                 if (plyrcount == TF_FLARE_OFF)\r
49                 {\r
50                         bprint(plyr1.netname);\r
51                         bprint(" needs");\r
52                 }\r
53                 else\r
54                 {\r
55                         if (plyrcount == 2)\r
56                         {\r
57                                 bprint(plyr1.netname);\r
58                                 bprint(" and ");\r
59                                 bprint(plyr2.netname);\r
60                                 bprint(" need");\r
61                         }\r
62                         else\r
63                         {\r
64                                 bprint("More players need");\r
65                         }\r
66                 }\r
67                 bprint(" to unlock the ");\r
68                 if (self.items & 131072)\r
69                 {\r
70                         bprint("silver");\r
71                 }\r
72                 else\r
73                 {\r
74                         bprint("gold");\r
75                 }\r
76                 bprint(" door\n");\r
77                 return TF_FLARE_LIT;\r
78         }\r
79         bprint("The ");\r
80         if (self.items & 131072)\r
81         {\r
82                 bprint("silver");\r
83         }\r
84         else\r
85         {\r
86                 bprint("gold");\r
87         }\r
88         bprint(" door has been unlocked\n");\r
89         return TF_FLARE_OFF;\r
90 };\r
91 \r
92 void() door_blocked = \r
93 {\r
94         T_Damage(other, self, self, self.dmg);\r
95         if (self.wait >= TF_FLARE_LIT)\r
96         {\r
97                 if (self.state == 3)\r
98                 {\r
99                         door_go_up();\r
100                 }\r
101                 else\r
102                 {\r
103                         door_go_down();\r
104                 }\r
105         }\r
106 };\r
107 \r
108 void() door_hit_top = \r
109 {\r
110         sound(self, 2, self.noise1, TF_FLARE_OFF, TF_FLARE_OFF);\r
111         self.state = TF_FLARE_LIT;\r
112         if (self.spawnflags & 32)\r
113         {\r
114                 return;\r
115         }\r
116         self.think = door_go_down;\r
117         self.nextthink = self.ltime + self.wait;\r
118 };\r
119 \r
120 void() door_hit_bottom = \r
121 {\r
122         self.goal_state = 2;\r
123         sound(self, 2, self.noise1, TF_FLARE_OFF, TF_FLARE_OFF);\r
124         self.state = TF_FLARE_OFF;\r
125 };\r
126 \r
127 void() door_go_down = \r
128 {\r
129         sound(self, 2, self.noise2, TF_FLARE_OFF, TF_FLARE_OFF);\r
130         if (self.max_health)\r
131         {\r
132                 self.takedamage = TF_FLARE_OFF;\r
133                 self.health = self.max_health;\r
134         }\r
135         self.state = 3;\r
136         SUB_CalcMove(self.pos1, self.speed, door_hit_bottom);\r
137 };\r
138 \r
139 void() door_go_up = \r
140 {\r
141         if (self.state == 2)\r
142         {\r
143                 return;\r
144         }\r
145         if (self.state == TF_FLARE_LIT)\r
146         {\r
147                 self.nextthink = self.ltime + self.wait;\r
148                 return;\r
149         }\r
150         sound(self, 2, self.noise2, TF_FLARE_OFF, TF_FLARE_OFF);\r
151         self.state = 2;\r
152         SUB_CalcMove(self.pos2, self.speed, door_hit_top);\r
153         SUB_UseTargets();\r
154 };\r
155 \r
156 void() door_fire = \r
157 {\r
158         local entity oself;\r
159         local entity starte;\r
160         if (self.owner != self)\r
161         {\r
162                 objerror("door_fire: self.owner != self");\r
163         }\r
164         if (self.items)\r
165         {\r
166                 sound(self, 2, self.noise4, TF_FLARE_OFF, TF_FLARE_OFF);\r
167         }\r
168         self.message = string_null;\r
169         oself = self;\r
170         if (self.spawnflags & 32)\r
171         {\r
172                 if (self.state == 2 || self.state == TF_FLARE_LIT)\r
173                 {\r
174                         starte = self;\r
175                         do\r
176                         {\r
177                                 door_go_down();\r
178                                 self = self.enemy;\r
179                         } while (self != starte && self != world);\r
180                         self = oself;\r
181                         return;\r
182                 }\r
183         }\r
184         starte = self;\r
185         do\r
186         {\r
187                 door_go_up();\r
188                 self = self.enemy;\r
189         } while (self != starte && self != world);\r
190         self = oself;\r
191 };\r
192 \r
193 void() door_use = \r
194 {\r
195         local entity oself;\r
196         self.message = "";\r
197         self.owner.message = "";\r
198         self.enemy.message = "";\r
199         oself = self;\r
200         self = self.owner;\r
201         door_fire();\r
202         self = oself;\r
203 };\r
204 \r
205 void() door_trigger_touch = \r
206 {\r
207         local entity te;\r
208         if (other.health <= TF_FLARE_LIT)\r
209         {\r
210                 return;\r
211         }\r
212         if (!Activated(self, other))\r
213         {\r
214                 if (self.else_goal != TF_FLARE_LIT)\r
215                 {\r
216                         te = Findgoal(self.else_goal);\r
217                         if (te)\r
218                         {\r
219                                 DoResults(te, other, self.goal_result & 2);\r
220                         }\r
221                 }\r
222                 return;\r
223         }\r
224         if (time < self.attack_finished)\r
225         {\r
226                 return;\r
227         }\r
228         self.attack_finished = time + TF_FLARE_OFF;\r
229         activator = other;\r
230         self = self.owner;\r
231         door_use();\r
232 };\r
233 \r
234 void() door_killed = \r
235 {\r
236         local entity oself;\r
237         oself = self;\r
238         self = self.owner;\r
239         self.health = self.max_health;\r
240         self.takedamage = TF_FLARE_LIT;\r
241         door_use();\r
242         self = oself;\r
243 };\r
244 \r
245 void() door_touch = \r
246 {\r
247         local entity te;\r
248         if (other.classname != "player")\r
249         {\r
250                 return;\r
251         }\r
252         if (self.owner.attack_finished > time)\r
253         {\r
254                 return;\r
255         }\r
256         if (!Activated(self, other))\r
257         {\r
258                 if (self.else_goal != TF_FLARE_LIT)\r
259                 {\r
260                         te = Findgoal(self.else_goal);\r
261                         if (te)\r
262                         {\r
263                                 DoResults(te, other, self.goal_result & 2);\r
264                         }\r
265                 }\r
266                 return;\r
267         }\r
268         self.owner.attack_finished = time + 2;\r
269         if (self.owner.message != "")\r
270         {\r
271                 CenterPrint(other, self.owner.message);\r
272                 sound(other, 2, "misc/talk.wav", TF_FLARE_OFF, TF_FLARE_OFF);\r
273         }\r
274         if (!(self.items))\r
275         {\r
276                 return;\r
277         }\r
278         if ((self.items & other.items) != self.items)\r
279         {\r
280                 if (self.owner.items == 131072)\r
281                 {\r
282                         if (world.worldtype == 2)\r
283                         {\r
284                                 CenterPrint(other, "You need the silver keycard");\r
285                                 sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
286                         }\r
287                         else\r
288                         {\r
289                                 if (world.worldtype == TF_FLARE_OFF)\r
290                                 {\r
291                                         CenterPrint(other, "You need the silver runekey");\r
292                                         sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
293                                 }\r
294                                 else\r
295                                 {\r
296                                         if (world.worldtype == TF_FLARE_LIT)\r
297                                         {\r
298                                                 CenterPrint(other, "You need the silver key");\r
299                                                 sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
300                                         }\r
301                                 }\r
302                         }\r
303                 }\r
304                 else\r
305                 {\r
306                         if (world.worldtype == 2)\r
307                         {\r
308                                 CenterPrint(other, "You need the gold keycard\n");\r
309                                 sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
310                         }\r
311                         else\r
312                         {\r
313                                 if (world.worldtype == TF_FLARE_OFF)\r
314                                 {\r
315                                         CenterPrint(other, "You need the gold runekey");\r
316                                         sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
317                                 }\r
318                                 else\r
319                                 {\r
320                                         if (world.worldtype == TF_FLARE_LIT)\r
321                                         {\r
322                                                 CenterPrint(other, "You need the gold key");\r
323                                                 sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
324                                         }\r
325                                 }\r
326                         }\r
327                 }\r
328                 return;\r
329         }\r
330         other.items = other.items - self.items;\r
331         other.tf_items = other.tf_items | self.items;\r
332         if (DoorShouldOpen())\r
333         {\r
334                 self.touch = SUB_Null;\r
335                 if (self.enemy)\r
336                 {\r
337                         self.enemy.touch = SUB_Null;\r
338                 }\r
339                 door_use();\r
340         }\r
341 };\r
342 \r
343 entity(vector fmins, vector fmaxs) spawn_field = \r
344 {\r
345         local entity trigger;\r
346         local vector t1;\r
347         local vector t2;\r
348         trigger = spawn();\r
349         trigger.movetype = TF_FLARE_LIT;\r
350         trigger.solid = TF_FLARE_OFF;\r
351         trigger.owner = self;\r
352         trigger.touch = door_trigger_touch;\r
353         trigger.team_no = self.team_no;\r
354         trigger.playerclass = self.playerclass;\r
355         trigger.items_allowed = self.items_allowed;\r
356         trigger.activate_goal_no = self.activate_goal_no;\r
357         trigger.inactivate_goal_no = self.inactivate_goal_no;\r
358         trigger.remove_goal_no = self.remove_goal_no;\r
359         trigger.restore_goal_no = self.restore_goal_no;\r
360         trigger.activate_group_no = self.activate_group_no;\r
361         trigger.inactivate_group_no = self.inactivate_group_no;\r
362         trigger.remove_group_no = self.remove_group_no;\r
363         trigger.restore_group_no = self.restore_group_no;\r
364         trigger.goal_activation = self.goal_activation;\r
365         trigger.goal_effects = self.goal_effects;\r
366         trigger.goal_result = self.goal_result;\r
367         trigger.goal_group = self.goal_group;\r
368         t1 = fmins;\r
369         t2 = fmaxs;\r
370         setsize(trigger, t1 - '60 60 8', t2 + '60 60 8');\r
371         return trigger;\r
372 };\r
373 \r
374 float(entity e1, entity e2) EntitiesTouching = \r
375 {\r
376         if (e1.mins_x > e2.maxs_x)\r
377         {\r
378                 return TF_FLARE_LIT;\r
379         }\r
380         if (e1.mins_y > e2.maxs_y)\r
381         {\r
382                 return TF_FLARE_LIT;\r
383         }\r
384         if (e1.mins_z > e2.maxs_z)\r
385         {\r
386                 return TF_FLARE_LIT;\r
387         }\r
388         if (e1.maxs_x < e2.mins_x)\r
389         {\r
390                 return TF_FLARE_LIT;\r
391         }\r
392         if (e1.maxs_y < e2.mins_y)\r
393         {\r
394                 return TF_FLARE_LIT;\r
395         }\r
396         if (e1.maxs_z < e2.mins_z)\r
397         {\r
398                 return TF_FLARE_LIT;\r
399         }\r
400         return TF_FLARE_OFF;\r
401 };\r
402 \r
403 void() LinkDoors = \r
404 {\r
405         local entity t;\r
406         local entity starte;\r
407         local vector cmins;\r
408         local vector cmaxs;\r
409         if (self.enemy)\r
410         {\r
411                 return;\r
412         }\r
413         if (self.spawnflags & 4)\r
414         {\r
415                 self.enemy = self;\r
416                 self.owner = self;\r
417                 return;\r
418         }\r
419         cmins = self.mins;\r
420         cmaxs = self.maxs;\r
421         starte = self;\r
422         t = self;\r
423         do\r
424         {\r
425                 self.owner = starte;\r
426                 if (self.health)\r
427                 {\r
428                         starte.health = self.health;\r
429                 }\r
430                 if (self.targetname)\r
431                 {\r
432                         starte.targetname = self.targetname;\r
433                 }\r
434                 if (self.message != "")\r
435                 {\r
436                         starte.message = self.message;\r
437                 }\r
438                 t = find(t, classname, self.classname);\r
439                 if (!t)\r
440                 {\r
441                         self.enemy = starte;\r
442                         self = self.owner;\r
443                         if (self.health)\r
444                         {\r
445                                 return;\r
446                         }\r
447                         if (self.targetname)\r
448                         {\r
449                                 return;\r
450                         }\r
451                         if (self.items)\r
452                         {\r
453                                 return;\r
454                         }\r
455                         self.owner.trigger_field = spawn_field(cmins, cmaxs);\r
456                         return;\r
457                 }\r
458                 if (EntitiesTouching(self, t))\r
459                 {\r
460                         if (t.enemy)\r
461                         {\r
462                                 objerror("cross connected doors");\r
463                         }\r
464                         self.enemy = t;\r
465                         self = t;\r
466                         if (t.mins_x < cmins_x)\r
467                         {\r
468                                 cmins_x = t.mins_x;\r
469                         }\r
470                         if (t.mins_y < cmins_y)\r
471                         {\r
472                                 cmins_y = t.mins_y;\r
473                         }\r
474                         if (t.mins_z < cmins_z)\r
475                         {\r
476                                 cmins_z = t.mins_z;\r
477                         }\r
478                         if (t.maxs_x > cmaxs_x)\r
479                         {\r
480                                 cmaxs_x = t.maxs_x;\r
481                         }\r
482                         if (t.maxs_y > cmaxs_y)\r
483                         {\r
484                                 cmaxs_y = t.maxs_y;\r
485                         }\r
486                         if (t.maxs_z > cmaxs_z)\r
487                         {\r
488                                 cmaxs_z = t.maxs_z;\r
489                         }\r
490                 }\r
491         } while (TF_FLARE_OFF);\r
492 };\r
493 \r
494 void() func_door = \r
495 {\r
496         //      Q3F/ETF Map Support\r
497         if (self.allowteams == "red")\r
498         {\r
499                 self.team_no = 2;\r
500         }\r
501         if (self.allowteams == "blue")\r
502         {\r
503                 self.team_no = 1;\r
504         }\r
505 \r
506         if(self.noise2) precache_sound (self.noise2);   //tz 05 11 10\r
507 \r
508         if (CheckExistence() == TF_FLARE_LIT)\r
509         {\r
510                 dremove(self);\r
511                 return;\r
512         }\r
513         if (world.worldtype == TF_FLARE_LIT)\r
514         {\r
515                 precache_sound("doors/medtry.wav");\r
516                 precache_sound("doors/meduse.wav");\r
517                 self.noise3 = "doors/medtry.wav";\r
518                 self.noise4 = "doors/meduse.wav";\r
519         }\r
520         else\r
521         {\r
522                 if (world.worldtype == TF_FLARE_OFF)\r
523                 {\r
524                         precache_sound("doors/runetry.wav");\r
525                         precache_sound("doors/runeuse.wav");\r
526                         self.noise3 = "doors/runetry.wav";\r
527                         self.noise4 = "doors/runeuse.wav";\r
528                 }\r
529                 else\r
530                 {\r
531                         if (world.worldtype == 2)\r
532                         {\r
533                                 precache_sound("doors/basetry.wav");\r
534                                 precache_sound("doors/baseuse.wav");\r
535                                 self.noise3 = "doors/basetry.wav";\r
536                                 self.noise4 = "doors/baseuse.wav";\r
537                         }\r
538                         else\r
539                         {\r
540                                 dprint("no worldtype set!\n");\r
541                         }\r
542                 }\r
543         }\r
544         if (self.sounds == TF_FLARE_LIT)\r
545         {\r
546                 precache_sound("misc/null.wav");\r
547                 precache_sound("misc/null.wav");\r
548                 self.noise1 = "misc/null.wav";\r
549                 if (!self.noise2)\r
550                         self.noise2 = "misc/null.wav";\r
551         }\r
552         if (self.sounds == TF_FLARE_OFF)\r
553         {\r
554                 precache_sound("doors/drclos4.wav");\r
555                 precache_sound("doors/doormv1.wav");\r
556                 self.noise1 = "doors/drclos4.wav";\r
557                 if (!self.noise2)\r
558                         self.noise2 = "doors/doormv1.wav";\r
559         }\r
560         if (self.sounds == 2)\r
561         {\r
562                 precache_sound("doors/hydro1.wav");\r
563                 precache_sound("doors/hydro2.wav");\r
564                 self.noise2 = "doors/hydro1.wav";\r
565                 self.noise1 = "doors/hydro2.wav";\r
566         }\r
567         if (self.sounds == 3)\r
568         {\r
569                 precache_sound("doors/stndr1.wav");\r
570                 precache_sound("doors/stndr2.wav");\r
571                 self.noise2 = "doors/stndr1.wav";\r
572                 self.noise1 = "doors/stndr2.wav";\r
573         }\r
574         if (self.sounds == 4)\r
575         {\r
576                 precache_sound("doors/ddoor1.wav");\r
577                 precache_sound("doors/ddoor2.wav");\r
578                 self.noise1 = "doors/ddoor2.wav";\r
579                 self.noise2 = "doors/ddoor1.wav";\r
580         }\r
581         if (self.armorclass == TF_FLARE_OFF)\r
582         {\r
583                 precache_sound("doors/creekdr1.wav");\r
584                 precache_sound("doors/creekdr2.wav");\r
585                 self.noise2 = "doors/creekdr1.wav";\r
586                 self.noise1 = "doors/creekdr2.wav";\r
587         }\r
588         if (self.armorclass == 2)\r
589         {\r
590                 precache_sound("doors/metaldr1.wav");\r
591                 precache_sound("doors/metaldr2.wav");\r
592                 self.noise2 = "doors/metaldr1.wav";\r
593                 self.noise1 = "doors/metaldr2.wav";\r
594         }\r
595         if (self.armorclass == 3)\r
596         {\r
597                 precache_sound("doors/electdr1.wav");\r
598                 precache_sound("doors/electdr2.wav");\r
599                 self.noise2 = "doors/electdr1.wav";\r
600                 self.noise1 = "doors/electdr2.wav";\r
601         }\r
602         if (self.armorclass == 4)\r
603         {\r
604                 precache_sound("doors/track_st.wav");\r
605                 precache_sound("doors/track_e.wav");\r
606                 self.noise2 = "doors/track_st.wav";\r
607                 self.noise1 = "doors/track_e.wav";\r
608         }\r
609         SetMovedir();\r
610         self.max_health = self.health;\r
611         self.solid = 4;\r
612         self.movetype = 7;\r
613         setorigin(self, self.origin);\r
614         setmodel(self, self.model);\r
615         self.classname = "door";\r
616         self.blocked = door_blocked;\r
617         self.use = door_use;\r
618         if (self.spawnflags & 16)\r
619         {\r
620                 self.items = 131072;\r
621         }\r
622         if (self.spawnflags & 8)\r
623         {\r
624                 self.items = 262144;\r
625         }\r
626         if (!(self.speed))\r
627         {\r
628                 self.speed = 100;\r
629         }\r
630         if (!(self.wait))\r
631         {\r
632                 self.wait = 3;\r
633         }\r
634         if (!(self.lip))\r
635         {\r
636                 self.lip = 8;\r
637         }\r
638         if (!(self.dmg))\r
639         {\r
640                 self.dmg = 2;\r
641         }\r
642         self.pos1 = self.origin;\r
643         self.pos2 = self.pos1 + self.movedir * (fabs(self.movedir * self.size) - self.lip);\r
644         if (self.spawnflags & TF_FLARE_OFF)\r
645         {\r
646                 setorigin(self, self.pos2);\r
647                 self.pos2 = self.pos1;\r
648                 self.pos1 = self.origin;\r
649         }\r
650         self.state = TF_FLARE_OFF;\r
651         if (self.health)\r
652         {\r
653                 self.takedamage = TF_FLARE_OFF;\r
654                 self.th_die = door_killed;\r
655         }\r
656         if (self.items)\r
657         {\r
658                 self.wait = -1;\r
659         }\r
660         self.touch = door_touch;\r
661         self.think = LinkDoors;\r
662         self.nextthink = self.ltime + 0.1;\r
663 };\r
664 \r
665 void() fd_secret_use = \r
666 {\r
667         local float temp;\r
668         self.health = 10000;\r
669         if (self.origin != self.oldorigin)\r
670         {\r
671                 return;\r
672         }\r
673         if (self.spawnflags & 32)\r
674         {\r
675                 return;\r
676         }\r
677         self.message = string_null;\r
678         SUB_UseTargets();\r
679         if (!(self.spawnflags & 8))\r
680         {\r
681                 self.th_pain = SUB_Null;\r
682                 self.takedamage = TF_FLARE_LIT;\r
683         }\r
684         self.velocity = '0 0 0';\r
685         sound(self, 2, self.noise1, TF_FLARE_OFF, TF_FLARE_OFF);\r
686         self.nextthink = self.ltime + 0.1;\r
687         temp = TF_FLARE_OFF - (self.spawnflags & 2);\r
688         makevectors(self.mangle);\r
689         if (!(self.t_width))\r
690         {\r
691                 if (self.spawnflags & 4)\r
692                 {\r
693                         self.t_width = fabs(v_up * self.size);\r
694                 }\r
695                 else\r
696                 {\r
697                         self.t_width = fabs(v_right * self.size);\r
698                 }\r
699         }\r
700         if (!(self.t_length))\r
701         {\r
702                 self.t_length = fabs(v_forward * self.size);\r
703         }\r
704         if (self.spawnflags & 4)\r
705         {\r
706                 self.dest1 = self.origin - v_up * self.t_width;\r
707         }\r
708         else\r
709         {\r
710                 self.dest1 = self.origin + v_right * (self.t_width * temp);\r
711         }\r
712         self.dest2 = self.dest1 + v_forward * self.t_length;\r
713         SUB_CalcMove(self.dest1, self.speed, fd_secret_move1);\r
714         sound(self, 2, self.noise2, TF_FLARE_OFF, TF_FLARE_OFF);\r
715 };\r
716 \r
717 void() fd_secret_move1 = \r
718 {\r
719         self.nextthink = self.ltime + TF_FLARE_OFF;\r
720         self.think = fd_secret_move2;\r
721         sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
722 };\r
723 \r
724 void() fd_secret_move2 = \r
725 {\r
726         sound(self, 2, self.noise2, TF_FLARE_OFF, TF_FLARE_OFF);\r
727         SUB_CalcMove(self.dest2, self.speed, fd_secret_move3);\r
728 };\r
729 \r
730 void() fd_secret_move3 = \r
731 {\r
732         sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
733         if (!(self.spawnflags & TF_FLARE_OFF))\r
734         {\r
735                 self.nextthink = self.ltime + self.wait;\r
736                 self.think = fd_secret_move4;\r
737         }\r
738 };\r
739 \r
740 void() fd_secret_move4 = \r
741 {\r
742         sound(self, 2, self.noise2, TF_FLARE_OFF, TF_FLARE_OFF);\r
743         SUB_CalcMove(self.dest1, self.speed, fd_secret_move5);\r
744 };\r
745 \r
746 void() fd_secret_move5 = \r
747 {\r
748         self.nextthink = self.ltime + TF_FLARE_OFF;\r
749         self.think = fd_secret_move6;\r
750         sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
751 };\r
752 \r
753 void() fd_secret_move6 = \r
754 {\r
755         sound(self, 2, self.noise2, TF_FLARE_OFF, TF_FLARE_OFF);\r
756         SUB_CalcMove(self.oldorigin, self.speed, fd_secret_done);\r
757 };\r
758 \r
759 void() fd_secret_done = \r
760 {\r
761         if (!(self.targetname) || (self.spawnflags & 16))\r
762         {\r
763                 self.health = 10000;\r
764                 self.takedamage = TF_FLARE_OFF;\r
765                 self.th_pain = fd_secret_use;\r
766                 self.th_die = fd_secret_use;\r
767         }\r
768         sound(self, 2, self.noise3, TF_FLARE_OFF, TF_FLARE_OFF);\r
769 };\r
770 \r
771 void() secret_blocked = \r
772 {\r
773         if (time < self.attack_finished)\r
774         {\r
775                 return;\r
776         }\r
777         self.attack_finished = time + 0.5;\r
778         T_Damage(other, self, self, self.dmg);\r
779 };\r
780 \r
781 void() secret_touch = \r
782 {\r
783         if (other.classname != "player")\r
784         {\r
785                 return;\r
786         }\r
787         if (self.attack_finished > time)\r
788         {\r
789                 return;\r
790         }\r
791         if (self.spawnflags & 32)\r
792         {\r
793                 return;\r
794         }\r
795         self.attack_finished = time + 2;\r
796         if (self.message)\r
797         {\r
798                 CenterPrint(other, self.message);\r
799                 sound(other, 4, "misc/talk.wav", TF_FLARE_OFF, TF_FLARE_OFF);\r
800         }\r
801 };\r
802 \r
803 void() func_door_secret = \r
804 {\r
805         if (CheckExistence() == TF_FLARE_LIT)\r
806         {\r
807                 dremove(self);\r
808                 return;\r
809         }\r
810         if (self.sounds == TF_FLARE_LIT)\r
811         {\r
812                 self.sounds = 3;\r
813         }\r
814         if (self.sounds == TF_FLARE_OFF)\r
815         {\r
816                 precache_sound("doors/latch2.wav");\r
817                 precache_sound("doors/winch2.wav");\r
818                 precache_sound("doors/drclos4.wav");\r
819                 self.noise1 = "doors/latch2.wav";\r
820                 self.noise2 = "doors/winch2.wav";\r
821                 self.noise3 = "doors/drclos4.wav";\r
822         }\r
823         if (self.sounds == 2)\r
824         {\r
825                 precache_sound("doors/airdoor1.wav");\r
826                 precache_sound("doors/airdoor2.wav");\r
827                 self.noise2 = "doors/airdoor1.wav";\r
828                 self.noise1 = "doors/airdoor2.wav";\r
829                 self.noise3 = "doors/airdoor2.wav";\r
830         }\r
831         if (self.sounds == 3)\r
832         {\r
833                 precache_sound("doors/basesec1.wav");\r
834                 precache_sound("doors/basesec2.wav");\r
835                 self.noise2 = "doors/basesec1.wav";\r
836                 self.noise1 = "doors/basesec2.wav";\r
837                 self.noise3 = "doors/basesec2.wav";\r
838         }\r
839         if (!(self.dmg))\r
840         {\r
841                 self.dmg = 2;\r
842         }\r
843         self.mangle = self.angles;\r
844         self.angles = '0 0 0';\r
845         self.solid = 4;\r
846         self.movetype = 7;\r
847         self.classname = "door";\r
848         setmodel(self, self.model);\r
849         setorigin(self, self.origin);\r
850         self.touch = secret_touch;\r
851         self.blocked = secret_blocked;\r
852         self.speed = 50;\r
853         self.use = fd_secret_use;\r
854         if (!(self.targetname) || (self.spawnflags & 16))\r
855         {\r
856                 self.health = 10000;\r
857                 self.takedamage = TF_FLARE_OFF;\r
858                 self.th_pain = fd_secret_use;\r
859         }\r
860         self.oldorigin = self.origin;\r
861         if (!(self.wait))\r
862         {\r
863                 self.wait = 5;\r
864         }\r
865 };\r