forked from EmeraldTiger/Re-Mobilize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rotate.qc
1223 lines (1036 loc) · 29.6 KB
/
rotate.qc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Rotate QuickC program
By Jim Dose' 10/17/96
Copyright (c)1996 Hipnotic Interactive, Inc.
All rights reserved.
Distributed (unsupported) on 3.12.97
*/
float STATE_ACTIVE = 0;
float STATE_INACTIVE = 1;
float STATE_SPEEDINGUP = 2;
float STATE_SLOWINGDOWN = 3;
float STATE_CLOSED = 4;
float STATE_OPEN = 5;
float STATE_OPENING = 6;
float STATE_CLOSING = 7;
float STATE_WAIT = 0;
float STATE_MOVE = 1;
float STATE_STOP = 2;
float STATE_FIND = 3;
float STATE_NEXT = 4;
float OBJECT_ROTATE = 0;
float OBJECT_MOVEWALL = 1;
float OBJECT_SETORIGIN = 2;
// spawnflags for func_rotate_entity
float ROTATE_ENTITY_TOGGLE = 1;
float ROTATE_ENTITY_START_ON = 2;
// spawnflags for path_rotate
float PATH_ROTATE_ROTATION = 1;
float PATH_ROTATE_ANGLES = 2;
float PATH_ROTATE_STOP = 4;
float PATH_ROTATE_NO_ROTATE = 8;
float PATH_ROTATE_DAMAGE = 16;
float PATH_ROTATE_MOVETIME = 32;
float PATH_ROTATE_SET_DAMAGE = 64;
// spawnflags for func_rotate_door
float ROTATE_DOOR_STAYOPEN = 1;
.float rotate_type;
.vector neworigin;
.vector rotate;
.float endtime;
.float duration;
.vector finalangle;
.string path;
.string group;
.string event;
//=========================
//
// SUB_NormalizeAngles
//
//=========================
vector (vector ang) SUB_NormalizeAngles =
{
while( ang_x > 360 )
{
ang_x = ang_x - 360;
}
while( ang_x < 0 )
{
ang_x = ang_x + 360;
}
while( ang_y > 360 )
{
ang_y = ang_y - 360;
}
while( ang_y < 0 )
{
ang_y = ang_y + 360;
}
while( ang_z > 360 )
{
ang_z = ang_z - 360;
}
while( ang_z < 0 )
{
ang_z = ang_z + 360;
}
return ang;
};
/*QUAKED info_rotate (0 0.5 0) (-4 -4 -4) (4 4 4) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Used as the point of rotation for rotatable objects.
*/
void() info_rotate =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
// remove self after a little while, to make sure that entities that
// have targeted it have had a chance to spawn
self.nextthink = time + 2;
self.think = SUB_Remove;
};
void() RotateTargets =
{
local entity ent;
local vector vx;
local vector vy;
local vector vz;
local vector org;
makevectors (self.angles);
ent = find( world, targetname, self.target);
while( ent )
{
if ( ent.rotate_type == OBJECT_SETORIGIN )
{
org = ent.oldorigin;
vx = ( v_forward * org_x );
vy = ( v_right * org_y );
vy = vy * -1;
vz = ( v_up * org_z );
ent.neworigin = vx + vy + vz;
setorigin( ent, ent.neworigin + self.origin );
}
else if ( ent.rotate_type == OBJECT_ROTATE )
{
ent.angles = self.angles;
org = ent.oldorigin;
vx = ( v_forward * org_x );
vy = ( v_right * org_y );
vy = vy * -1;
vz = ( v_up * org_z );
ent.neworigin = vx + vy + vz;
setorigin( ent, ent.neworigin + self.origin );
}
else
{
org = ent.oldorigin;
vx = ( v_forward * org_x );
vy = ( v_right * org_y );
vy = vy * -1;
vz = ( v_up * org_z );
ent.neworigin = vx + vy + vz;
ent.neworigin = self.origin - self.oldorigin + (ent.neworigin - ent.oldorigin);
ent.velocity = (ent.neworigin-ent.origin)*25;
}
ent = find( ent, targetname, self.target);
}
};
void() RotateTargetsFinal =
{
local entity ent;
ent = find( world, targetname, self.target);
while( ent )
{
ent.velocity = '0 0 0';
if ( ent.rotate_type == OBJECT_ROTATE )
{
ent.angles = self.angles;
}
ent = find( ent, targetname, self.target);
}
SUB_UseTargets();
};
void() SetTargetOrigin =
{
local entity ent;
ent = find( world, targetname, self.target);
while( ent )
{
if ( ent.rotate_type == OBJECT_MOVEWALL )
{
setorigin( ent, self.origin - self.oldorigin +
(ent.neworigin - ent.oldorigin) );
}
else
{
setorigin( ent, ent.neworigin + self.origin );
}
ent = find( ent, targetname, self.target);
}
};
void() LinkRotateTargets =
{
local entity ent;
local vector tempvec;
self.oldorigin = self.origin;
ent = find( world, targetname, self.target);
while( ent )
{
if ( ent.classname == "rotate_object" )
{
ent.rotate_type = OBJECT_ROTATE;
ent.oldorigin = ent.origin - self.oldorigin;
ent.neworigin = ent.origin - self.oldorigin;
ent.owner = self;
}
else if ( ent.classname == "func_movewall" )
{
ent.rotate_type = OBJECT_MOVEWALL;
tempvec = ( ent.absmin + ent.absmax ) * 0.5;
ent.oldorigin = tempvec - self.oldorigin;
ent.neworigin = ent.oldorigin;
ent.owner = self;
}
else
{
ent.rotate_type = OBJECT_SETORIGIN;
ent.oldorigin = ent.origin - self.oldorigin;
ent.neworigin = ent.origin - self.oldorigin;
}
ent = find (ent, targetname, self.target);
}
};
void( entity ent, float amount ) hurt_setdamage =
{
ent.dmg = amount;
if ( !amount )
{
ent.solid = SOLID_NOT;
}
else
{
ent.solid = SOLID_TRIGGER;
}
ent.nextthink = -1;
};
void( float amount ) SetDamageOnTargets =
{
local entity ent;
ent = find( world, targetname, self.target);
while( ent )
{
if ( ent.classname == "trigger_hurt" )
{
hurt_setdamage( ent, amount );
}
else if ( ent.classname == "func_movewall" )
{
ent.dmg = amount;
}
ent = find( ent, targetname, self.target);
}
};
//************************************************
//
// Simple continual rotatation
//
//************************************************
void() rotate_entity_think =
{
local float t;
t = time - self.ltime;
self.ltime = time;
if ( self.state == STATE_SPEEDINGUP )
{
self.count = self.count + self.cnt * t;
if ( self.count > 1 )
{
self.count = 1;
}
// get rate of rotation
t = t * self.count;
}
else if ( self.state == STATE_SLOWINGDOWN )
{
self.count = self.count - self.cnt * t;
if ( self.count < 0 )
{
RotateTargetsFinal();
self.state = STATE_INACTIVE;
self.think = SUB_Null;
return;
}
// get rate of rotation
t = t * self.count;
}
self.angles = self.angles + ( self.rotate * t );
self.angles = SUB_NormalizeAngles( self.angles );
RotateTargets();
self.nextthink = time + 0.02;
};
void() rotate_entity_use =
{
// change to alternate textures
self.frame = 1 - self.frame;
if ( self.state == STATE_ACTIVE )
{
if ( self.spawnflags & ROTATE_ENTITY_TOGGLE )
{
if ( self.speed )
{
self.count = 1;
self.state = STATE_SLOWINGDOWN;
}
else
{
self.state = STATE_INACTIVE;
self.think = SUB_Null;
}
}
}
else if ( self.state == STATE_INACTIVE )
{
self.think = rotate_entity_think;
self.nextthink = time + 0.02;
self.ltime = time;
if ( self.speed )
{
self.count = 0;
self.state = STATE_SPEEDINGUP;
}
else
{
self.state = STATE_ACTIVE;
}
}
else if ( self.state == STATE_SPEEDINGUP )
{
if ( self.spawnflags & ROTATE_ENTITY_TOGGLE )
{
self.state = STATE_SLOWINGDOWN;
}
}
else
{
self.state = STATE_SPEEDINGUP;
}
};
void() rotate_entity_firstthink =
{
LinkRotateTargets();
if ( self.spawnflags & ROTATE_ENTITY_START_ON )
{
self.state = STATE_ACTIVE;
self.think = rotate_entity_think;
self.nextthink = time + 0.02;
self.ltime = time;
}
else
{
self.state = STATE_INACTIVE;
self.think = SUB_Null;
}
self.use = rotate_entity_use;
};
/*QUAKED func_rotate_entity (0 .5 .8) (-8 -8 -8) (8 8 8) TOGGLE START_ON X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Creates an entity that continually rotates. Can be toggled on and
off if targeted.
TOGGLE = allows the rotation to be toggled on/off
START_ON = wether the entity is spinning when spawned. If TOGGLE is 0, entity can be turned on, but not off.
If "deathtype" is set with a string, this is the message that will appear when a player is killed by the train.
"rotate" is the rate to rotate.
"target" is the center of rotation.
"speed" is how long the entity takes to go from standing still to full speed and vice-versa.
*/
void() func_rotate_entity =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
setmodel (self, self.model);
setsize( self, self.mins, self.maxs );
if ( self.speed != 0 )
{
self.cnt = 1 / self.speed;
}
self.think = rotate_entity_firstthink;
self.nextthink = time + 0.1;
self.ltime = time;
};
//************************************************
//
// Train with rotation functionality
//
//************************************************
/*QUAKED path_rotate (0.5 0.3 0) (-8 -8 -8) (8 8 8) ROTATION ANGLES STOP NO_ROTATE DAMAGE MOVETIME SET_DAMAGE
Path for rotate_train.
ROTATION tells train to rotate at rate specified by "rotate". Use '0 0 0' to stop rotation.
ANGLES tells train to rotate to the angles specified by "angles" while traveling to this path_rotate. Use values < 0 or > 360 to guarantee that it turns in a certain direction. Having this flag set automatically clears any rotation.
STOP tells the train to stop and wait to be retriggered.
NO_ROTATE tells the train to stop rotating when waiting to be triggered.
DAMAGE tells the train to cause damage based on "dmg".
MOVETIME tells the train to interpret "speed" as the length of time to take moving from one corner to another.
SET_DAMAGE tells the train to set all targets damage to "dmg"
"noise" contains the name of the sound to play when train stops.
"noise1" contains the name of the sound to play when train moves.
"event" is a target to trigger when train arrives at path_rotate.
*/
void() path_rotate =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
if ( self.noise != "" )
{
precache_sound( self.noise );
}
if ( self.noise1 != "" )
{
precache_sound( self.noise1 );
}
};
void() rotate_train;
void() rotate_train_next;
void() rotate_train_find;
void() rotate_train_think =
{
local float t;
local float timeelapsed;
t = time - self.ltime;
self.ltime = time;
if ( ( self.endtime ) && ( time >= self.endtime ) )
{
self.endtime = 0;
if ( self.state == STATE_MOVE )
{
setorigin(self, self.finaldest);
self.velocity = '0 0 0';
}
if (self.think1)
self.think1();
}
else
{
timeelapsed = (time - self.cnt) * self.duration;
if ( timeelapsed > 1 )
timeelapsed = 1;
setorigin( self, self.dest1 + ( self.dest2 * timeelapsed ) );
}
self.angles = self.angles + ( self.rotate * t );
self.angles = SUB_NormalizeAngles( self.angles );
RotateTargets();
self.nextthink = time + 0.02;
};
void() rotate_train_use =
{
if (self.think1 != rotate_train_find)
{
if ( self.velocity != '0 0 0' )
return; // already activated
if ( self.think1 )
{
self.think1();
}
}
};
void() rotate_train_wait =
{
self.state = STATE_WAIT;
if ( self.goalentity.noise != "" )
{
sound (self, CHAN_VOICE, self.goalentity.noise, 1, ATTN_NORM);
}
else
{
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}
if ( self.goalentity.spawnflags & PATH_ROTATE_ANGLES )
{
self.rotate = '0 0 0';
self.angles = self.finalangle;
}
if ( self.goalentity.spawnflags & PATH_ROTATE_NO_ROTATE )
{
self.rotate = '0 0 0';
}
self.endtime = self.ltime + self.goalentity.wait;
self.think1 = rotate_train_next;
};
void() rotate_train_stop =
{
self.state = STATE_STOP;
if ( self.goalentity.noise != "" )
{
sound (self, CHAN_VOICE, self.goalentity.noise, 1, ATTN_NORM);
}
else
{
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}
if ( self.goalentity.spawnflags & PATH_ROTATE_ANGLES )
{
self.rotate = '0 0 0';
self.angles = self.finalangle;
}
if ( self.goalentity.spawnflags & PATH_ROTATE_NO_ROTATE )
{
self.rotate = '0 0 0';
}
self.dmg = 0;
self.think1 = rotate_train_next;
};
void() rotate_train_next =
{
local entity targ;
local entity current;
local vector vdestdelta;
local float len, traveltime, div;
local string temp;
self.state = STATE_NEXT;
current = self.goalentity;
targ = find (world, targetname, self.path);
if ( targ.classname != "path_rotate" )
objerror( "Next target is not path_rotate" );
if ( self.goalentity.noise1 != "" )
{
self.noise1 = self.goalentity.noise1;
}
sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
self.goalentity = targ;
self.path = targ.target;
if (!self.path )
objerror ("rotate_train_next: no next target");
if ( targ.spawnflags & PATH_ROTATE_STOP )
{
self.think1 = rotate_train_stop;
}
else if (targ.wait)
{
self.think1 = rotate_train_wait;
}
else
{
self.think1 = rotate_train_next;
}
if ( current.event != "" )
{
// Trigger any events that should happen at the corner.
temp = self.target;
self.target = current.event;
self.message = current.message;
SUB_UseTargets();
self.target = temp;
self.message = string_null;
}
if ( current.spawnflags & PATH_ROTATE_ANGLES )
{
self.rotate = '0 0 0';
self.angles = self.finalangle;
}
if ( current.spawnflags & PATH_ROTATE_ROTATION )
{
self.rotate = current.rotate;
}
if ( current.spawnflags & PATH_ROTATE_DAMAGE )
{
self.dmg = current.dmg;
}
if ( current.spawnflags & PATH_ROTATE_SET_DAMAGE )
{
SetDamageOnTargets( current.dmg );
}
if ( current.speed == -1 )
{
// Warp to the next path_corner
setorigin( self, targ.origin );
self.endtime = self.ltime + 0.01;
SetTargetOrigin();
if ( targ.spawnflags & PATH_ROTATE_ANGLES )
{
self.angles = targ.angles;
}
self.duration = 1; // 1 / duration
self.cnt = time; // start time
self.dest2 = '0 0 0'; // delta
self.dest1 = self.origin; // original position
self.finaldest = self.origin;
}
else
{
self.state = STATE_MOVE;
self.finaldest = targ.origin;
if (self.finaldest == self.origin)
{
self.velocity = '0 0 0';
self.endtime = self.ltime + 0.1;
self.duration = 1; // 1 / duration
self.cnt = time; // start time
self.dest2 = '0 0 0'; // delta
self.dest1 = self.origin; // original position
self.finaldest = self.origin;
return;
}
// set destdelta to the vector needed to move
vdestdelta = self.finaldest - self.origin;
// calculate length of vector
len = vlen (vdestdelta);
if ( current.spawnflags & PATH_ROTATE_MOVETIME )
{
traveltime = current.speed;
}
else
{
// check if there's a speed change
if (current.speed>0)
self.speed = current.speed;
if (!self.speed)
objerror("No speed is defined!");
// divide by speed to get time to reach dest
traveltime = len / self.speed;
}
if (traveltime < 0.1)
{
self.velocity = '0 0 0';
self.endtime = self.ltime + 0.1;
if ( targ.spawnflags & PATH_ROTATE_ANGLES )
{
self.angles = targ.angles;
}
return;
}
// qcc won't take vec/float
div = 1 / traveltime;
if ( targ.spawnflags & PATH_ROTATE_ANGLES )
{
self.finalangle = SUB_NormalizeAngles( targ.angles );
self.rotate = ( targ.angles - self.angles ) * div;
}
// set endtime to trigger a think when dest is reached
self.endtime = self.ltime + traveltime;
// scale the destdelta vector by the time spent traveling to get velocity
self.velocity = vdestdelta * div;
self.duration = div; // 1 / duration
self.cnt = time; // start time
self.dest2 = vdestdelta; // delta
self.dest1 = self.origin; // original position
}
};
void() rotate_train_find =
{
local entity targ;
self.state = STATE_FIND;
LinkRotateTargets();
// the first target is the point of rotation.
// the second target is the path.
targ = find ( world, targetname, self.path);
if ( targ.classname != "path_rotate" )
objerror( "Next target is not path_rotate" );
// Save the current entity
self.goalentity = targ;
if ( targ.spawnflags & PATH_ROTATE_ANGLES )
{
self.angles = targ.angles;
self.finalangle = SUB_NormalizeAngles( targ.angles );
}
self.path = targ.target;
setorigin (self, targ.origin );
SetTargetOrigin();
RotateTargetsFinal();
self.think1 = rotate_train_next;
if (!self.targetname)
{
// not triggered, so start immediately
self.endtime = self.ltime + 0.1;
}
else
{
self.endtime = 0;
}
self.duration = 1; // 1 / duration
self.cnt = time; // start time
self.dest2 = '0 0 0'; // delta
self.dest1 = self.origin; // original position
};
/*QUAKED func_rotate_train (0 .5 .8) (-8 -8 -8) (8 8 8) X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
In path_rotate, set speed to be the new speed of the train after it reaches
the path change. If speed is -1, the train will warp directly to the next
path change after the specified wait time. If MOVETIME is set on the
path_rotate, the train to interprets "speed" as the length of time to
take moving from one corner to another.
"noise" contains the name of the sound to play when train stops.
"noise1" contains the name of the sound to play when train moves.
Both "noise" and "noise1" defaults depend upon "sounds" variable and
can be overridden by the "noise" and "noise1" variable in path_rotate.
Also in path_rotate, if STOP is set, the train will wait until it is
retriggered before moving on to the next goal.
Trains are moving platforms that players can ride.
"path" specifies the first path_rotate and is the starting position.
If the train is the target of a button or trigger, it will not begin moving until activated.
The func_rotate_train entity is the center of rotation of all objects targeted by it.
If "deathtype" is set with a string, this is the message that will appear when a player is killed by the train.
speed default 100
dmg default 0
sounds
1) ratchet metal
*/
void() rotate_train =
{
objerror ("rotate_train entities should be changed to rotate_object with\nfunc_rotate_train controllers\n");
};
void() func_rotate_train =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
if (!self.speed)
self.speed = 100;
if (!self.target)
objerror ("rotate_train without a target");
if ( !self.noise )
{
if (self.sounds == 0)
{
self.noise = ("misc/null.wav");
}
if (self.sounds == 1)
{
self.noise = ("plats/train2.wav");
}
}
if ( !self.noise1 )
{
if (self.sounds == 0)
{
self.noise1 = ("misc/null.wav");
}
if (self.sounds == 1)
{
self.noise1 = ("plats/train1.wav");
}
}
precache_sound( self.noise );
precache_sound( self.noise1 );
self.cnt = 1;
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_STEP;
self.use = rotate_train_use;
setmodel (self, self.model);
setsize (self, self.mins, self.maxs);
setorigin (self, self.origin);
// start trains on the second frame, to make sure their targets have had
// a chance to spawn
self.ltime = time;
self.nextthink = self.ltime + 0.1;
self.endtime = self.ltime + 0.1;
self.think = rotate_train_think;
self.think1 = rotate_train_find;
self.state = STATE_FIND;
self.duration = 1; // 1 / duration
self.cnt = 0.1; // start time
self.dest2 = '0 0 0'; // delta
self.dest1 = self.origin; // original position
self.flags = self.flags | FL_ONGROUND;
};
//************************************************
//
// Moving clip walls
//
//************************************************
void() rotate_door_reversedirection;
void() rotate_door_group_reversedirection;
void() movewall_touch =
{
if (time < self.owner.attack_finished)
return;
if ( self.dmg )
{
T_Damage (other, self, self.owner, self.dmg);
self.owner.attack_finished = time + 0.5;
}
else if ( self.owner.dmg )
{
T_Damage (other, self, self.owner, self.owner.dmg);
self.owner.attack_finished = time + 0.5;
}
};
void() movewall_blocked =
{
local entity temp;
if (time < self.owner.attack_finished)
return;
self.owner.attack_finished = time + 0.5;
if ( self.owner.classname == "func_rotate_door" )
{
temp = self;
self = self.owner;
rotate_door_group_reversedirection();
self = temp;
}
if ( self.dmg )
{
T_Damage (other, self, self.owner, self.dmg);
self.owner.attack_finished = time + 0.5;
}
else if ( self.owner.dmg )
{
T_Damage (other, self, self.owner, self.owner.dmg);
self.owner.attack_finished = time + 0.5;
}
};
void() movewall_think =
{
self.ltime = time;
self.nextthink = time + 0.02;
};
/*QUAKED func_movewall (0 .5 .8) ? VISIBLE TOUCH NONBLOCKING X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
Used to emulate collision on rotating objects.
VISIBLE causes brush to be displayed.
TOUCH specifies whether to cause damage when touched by player.
NONBLOCKING makes the brush non-solid. This is useless if VISIBLE is set.
"dmg" specifies the damage to cause when touched or blocked.
*/
void() func_movewall =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
self.angles = '0 0 0';
self.movetype = MOVETYPE_PUSH;
if ( self.spawnflags & MOVEWALL_NONBLOCKING )
{
self.solid = SOLID_NOT;
}
else
{
self.solid = SOLID_BSP;
self.blocked = movewall_blocked;
}
if ( self.spawnflags & MOVEWALL_TOUCH )
{
self.touch = movewall_touch;
}
setmodel (self,self.model);
if ( !( self.spawnflags & MOVEWALL_VISIBLE ) )
{
self.model = string_null;
}
self.think = movewall_think;
self.nextthink = time + 0.02;
self.ltime = time;
};
/*QUAKED rotate_object (0 .5 .8) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
This defines an object to be rotated. Used as the target of func_rotate_door.
*/
void() rotate_object =
{
if (SUB_Inhibit ()) // new spawnflags for all entities -- iw
return;
self.classname = "rotate_object";
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
setmodel (self,self.model);
setsize( self, self.mins, self.maxs );
self.think = SUB_Null;
};
//************************************************
//
// Rotating doors
//
//************************************************
void() rotate_door_think2 =
{
local float t;
t = time - self.ltime;
self.ltime = time;
// change to alternate textures
self.frame = 1 - self.frame;
self.angles = self.dest;
if ( self.state == STATE_OPENING )
{
self.state = STATE_OPEN;
}