-
Notifications
You must be signed in to change notification settings - Fork 17
/
lights.qc
999 lines (909 loc) · 28.5 KB
/
lights.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
//
// ================================================================
//
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
// you know what's cool? arrays.
// 0 normal
string light0 = "m";
// 1 FLICKER (first variety)
string light1 = "mmnmmommommnonmmonqnmmo";
// 2 SLOW STRONG PULSE
string light2 = "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba";
// 3 CANDLE (first variety)
string light3 = "mmmmmaaaaammmmmaaaaaabcdefgabcdefg";
// 4 FAST STROBE
string light4 = "mamamamamama";
// 5 GENTLE PULSE 1
string light5 = "jklmnopqrstuvwxyzyxwvutsrqponmlkj";
// 6 FLICKER (second variety)
string light6 = "nmonqnmomnmomomno";
// 7 CANDLE (second variety)
string light7 = "mmmaaaabcdefgmmmmaaaammmaamm";
// 8 CANDLE (third variety)
string light8 = "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa";
// 9 SLOW STROBE (fourth variety)
string light9 = "aaaaaaaazzzzzzzz";
// 10 FLUORESCENT FLICKER
string light10 = "mmamammmmammamamaaamammma";
// 11 SLOW PULSE TO BLACK
string light11 = "abcdefghijklmnopqrrqponmlkjihgfedcba";
// styles 32-62 are assigned by the light program for switchable lights
string light_off = "a";
/*FGD
@baseclass base() color(255 255 80) size(-8 -8 -8, 8 8 8) = Light [
light(integer) : "Brightness" : 300
_color(string) : "Color" : "1 1 1"
wait(string) : "Fade distance multiplier" : "1"
mangle(string) : "Spotlight aim (yaw pitch roll, neg. pitch is down)"
angle(integer) : "Spotlight cone angle"
_softangle(integer) : "Spotlight inner cone angle"
_dirt(integer) : "Override dirt"
message(string) : "override the style string directly for the assigned style (clashes will overwrite each other)"
target(string) : "Entity to aim at"
delay(choices) : "Attenuation" =
[
0 : "Linear falloff (Default)"
1 : "Inverse distance falloff"
2 : "Inverse distance squared"
3 : "No falloff"
4 : "Local minlight"
5 : "Inverse distance squared B"
]
style(Choices) : "Appearance" : 0 =
[
0 : "Normal"
10: "Fluorescent flicker"
2 : "Slow, strong pulse"
11: "Slow pulse, black"
5 : "Gentle pulse, no black"
1 : "Flicker A"
6 : "Flicker B"
3 : "Candle A"
7 : "Candle B"
8 : "Candle C"
4 : "Fast strobe"
9 : "Slow strobe"
]
]
@baseclass base(Light, Targetname) = LightTriggerable [
spawnflags(flags) = [
1 : "Start off" : 0
]
]
@baseclass base() = Flame [
volume(string) : "Crackle Volume" : "1"
distance(choices) : "Crackle Range" : 0 =
[
0 : "Ambient"
1 : "Monster Idle"
2 : "Monster Bark"
3 : "Global (plz no)"
]
spawnflags(flags) = [
2 : "Silent" : 0
]
]
*/
//
// ================================================================
//
string( float st ) GetLightStyle =
{
if (st == 1) return light1;
if (st == 2) return light2;
if (st == 3) return light3;
if (st == 4) return light4;
if (st == 5) return light5;
if (st == 6) return light6;
if (st == 7) return light7;
if (st == 8) return light8;
if (st == 9) return light9;
if (st == 10) return light10;
if (st == 11) return light11;
/* if (st == 12) return light12;
if (st == 13) return light13;
if (st == 14) return light14;
if (st == 15) return light15;
if (st == 16) return light16;
if (st == 17) return light17;
if (st == 18) return light18;*/
if (icantsee)
return "z";
return light0;
}
void() InitLightStyles =
{
lightstyle(0, light0);
lightstyle(1, light1);
lightstyle(2, light2);
lightstyle(3, light3);
lightstyle(4, light4);
lightstyle(5, light5);
lightstyle(6, light6);
lightstyle(7, light7);
lightstyle(8, light8);
lightstyle(9, light9);
lightstyle(10, light10);
lightstyle(11, light11);
/* lightstyle(12, light12);
lightstyle(13, light13);
lightstyle(14, light14);
lightstyle(15, light15);
lightstyle(16, light16);
lightstyle(17, light17);
lightstyle(18, light18);*/
// 63 testing
//lightstyle(63, "a");
}
void() light_use =
{
//dprint("light_use\n");
if (self.spawnflags & START_OFF)
{
if (self.message != string_null)
lightstyle(self.style, self.message);
else
lightstyle(self.style, GetLightStyle(self.oldstyle));
self.spawnflags = self.spawnflags - START_OFF;
//dprint("turning light on\n");
}
else
{
lightstyle(self.style, light_off);
self.spawnflags = self.spawnflags | START_OFF;
//dprint("turning light off\n");
}
}
void(entity b, float opacity) bmodel_lightstyle =
{
if (sandyMadeThis) return;
if (!b.style && !b.switchshadstyle) return;
float a = zeroconvertdefault(b.alpha, 1);
float f;
// 'alpha' could be set by mapper or target_fade, 0 is invisible
// 1 blocks all light, 0 admits all
// 'opacity' is like positional alpha: is the bmodel visible or hidden? how far open is the door? etc
// 1 blocks all light, 0 admits all
// stash for future changes in alpha
if (opacity == 0) b.alpha2 = -1;
else b.alpha2 = opacity;
if (b.customflags & CFL_INVLIGHT)
opacity = 1 - opacity;
// 0 for either will override the other and admit light, so we multiply
// finally, invert so 0 (brightest) becomes a high value
f = 1 - opacity * a;
string l = light_str(f);
if (b.style)
lightstyle(b.style, l);
if (b.switchshadstyle)
lightstyle(b.switchshadstyle, l);
}
string(float f) light_str =
{
float bright = floor(f * 12 + 0.5);
if (bright <= 0 ) return "a";
if (bright >= 12) return "m";
if (bright == 1 ) return "b";
if (bright == 2 ) return "c";
if (bright == 3 ) return "d";
if (bright == 4 ) return "e";
if (bright == 5 ) return "f";
if (bright == 6 ) return "g";
if (bright == 7 ) return "h";
if (bright == 8 ) return "i";
if (bright == 9 ) return "j";
if (bright == 10) return "k";
if (bright == 11) return "l";
return "a";
}
// Lights with "count" will gradually change brightness each time they're triggered, reaching normal brightness or complete darkness after 'count' triggers.
void() light_inc_use =
{
if (self.spawnflags & START_OFF)
{
if (self.cnt == self.count) return;
self.cnt = self.cnt + 1;
}
else
{
if (self.cnt == 0) return;
self.cnt = self.cnt - 1;
}
lightstyle(self.style, light_str(self.cnt / self.count));
}
void() light_message =
{
if (self.message != string_null)
{
if (self.oldstyle > 11)
lightstyle(self.oldstyle, self.message);
else if (self.style > 11)
lightstyle(self.style, self.message);
else
dprint5("\bwarning:\b light at ", vtos(self.origin), " with message ", self.message, " but no style # set\n");
}
}
void() light_oldstyle =
{
if (self.style >= 32)
{
if (self.count > 0)
{
self.use = light_inc_use;
if (self.spawnflags & START_OFF)
{
lightstyle(self.style, light_off);
self.cnt = 0;
}
else
{
lightstyle(self.style, GetLightStyle(self.oldstyle));
self.cnt = self.count;
}
return;
}
self.use = light_use;
if (self.spawnflags & START_OFF)
lightstyle(self.style, light_off);
else
lightstyle(self.style, GetLightStyle(self.oldstyle));
}
}
/*QUAKED light (0 .75 0) (-8 -8 -8) (8 8 8) START_OFF
Non-displayed light. If targeted, it will toggle between on or off.
"start_off" starts off until triggered
Keys:
"light" sets brightness (default: 300)
"targetname" entity name
"mangle" spotlight direction - the first # is yaw, 0 to 360 around Z. second # is pitch, 90 up to -90 down.
"angle" spotlight cone size
"_softangle" spotlight inner cone size
"wait" scale the falloff distance. N>1 will shorten range, n<1 will extend it
"delay" attenuation formula
0 = Linear, original id (default)
1 = 1/x attenuation formula
2 = 1/(x^2) attenuation formula
3 = No attenuation (light stays same brightness at any distance)
"_color" "# # #" 0-255
"style"
0 = normal
1 = flicker: "mmnmmommommnonmmonqnmmo"
2 = slow strong pulse: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
3 = candle: "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"
4 = fast strobe: "mamamamamama"
5 = slow pulse, no black: "jklmnopqrstuvwxyzyxwvutsrqponmlkj"
6 = flicker: "nmonqnmomnmomomno"
7 = candle: "mmmaaaabcdefgmmmmaaaammmaamm"
8 = candle2: "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"
9 = slow strobe: "aaaaaaaazzzzzzzz"
10 = flourescent flicker: mmamammmmammamamaaamammma"
11 = slow pulse, fading to black: "abcdefghijklmnopqrrqponmlkjihgfedcba"
styles 32-62 are assigned by the light program for switchable lights
(default: 0)
"message" override the style string directly for the assigned style (clashes will overwrite each other)
*/
/*FGD
@PointClass base(LightTriggerable) = light : "Invisible light source" []
*/
void() light =
{
light_message();
if (self.targetname == string_null && !self.impulse)
{ // inert light
remove(self);
return;
}
light_oldstyle();
}
//============================================================================
/*QUAKED light_fluoro (1 1 0) (-8 -8 -8) (8 8 8) START_OFF
Non-displayed light. Makes steady fluorescent humming sound.
Flags:
"start_off" starts off until triggered
Keys:
"light" sets brightness (default: 300)
"targetname" entity name
"mangle" spotlight direction - the first # is yaw, 0 to 360 around Z. second # is pitch, 90 up to -90 down.
"angle" spotlight cone size
"_softangle" spotlight inner cone size
"wait" scale the falloff distance. N>1 will shorten range, n<1 will extend it
"delay" attenuation formula
0 = Linear, original id (default)
1 = 1/x attenuation formula
2 = 1/(x^2) attenuation formula
3 = No attenuation (light stays same brightness at any distance)
"_color" "# # #" 0-255
"style"
0 = normal
1 = flicker: "mmnmmommommnonmmonqnmmo"
2 = slow strong pulse: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
3 = candle: "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"
4 = fast strobe: "mamamamamama"
5 = slow pulse, no black: "jklmnopqrstuvwxyzyxwvutsrqponmlkj"
6 = flicker: "nmonqnmomnmomomno"
7 = candle: "mmmaaaabcdefgmmmmaaaammmaamm"
8 = candle2: "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"
9 = slow strobe: "aaaaaaaazzzzzzzz"
10 = flourescent flicker: mmamammmmammamamaaamammma"
11 = slow pulse, fading to black: "abcdefghijklmnopqrrqponmlkjihgfedcba"
styles 32-62 are assigned by the light program for switchable lights
(default: 0)
"message" override the style string directly for the assigned style (clashes will overwrite each other)
*/
/*FGD
@PointClass base(LightTriggerable) = light_fluoro : "Humming fluorescent light source" []
*/
void() light_fluoro =
{
if (self.style >= 32)
{
self.use = light_use;
if (self.spawnflags & START_OFF)
lightstyle(self.style, "a");
else
lightstyle(self.style, "m");
}
precache_sound ("ambience/fl_hum1.wav");
ambientsound (self.origin, "ambience/fl_hum1.wav", 0.5, ATTN_STATIC);
}
/*QUAKED light_fluorospark (1 1 0) (-8 -8 -8) (8 8 8)
Non-displayed light. Default style is 10. Makes sparking, broken fluorescent sound.
Keys:
"light" sets brightness (default: 300)
"mangle" spotlight direction - the first # is yaw, 0 to 360 around Z. second # is pitch, 90 up to -90 down.
"angle" spotlight cone size
"_softangle" spotlight inner cone size
"wait" scale the falloff distance. N>1 will shorten range, n<1 will extend it
"delay" attenuation formula
0 = Linear, original id (default)
1 = 1/x attenuation formula
2 = 1/(x^2) attenuation formula
3 = No attenuation (light stays same brightness at any distance)
"_color" "# # #" 0-255
"style"
0 = normal
1 = flicker: "mmnmmommommnonmmonqnmmo"
2 = slow strong pulse: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
3 = candle: "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"
4 = fast strobe: "mamamamamama"
5 = slow pulse, no black: "jklmnopqrstuvwxyzyxwvutsrqponmlkj"
6 = flicker: "nmonqnmomnmomomno"
7 = candle: "mmmaaaabcdefgmmmmaaaammmaamm"
8 = candle2: "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"
9 = slow strobe: "aaaaaaaazzzzzzzz"
10 = flourescent flicker: mmamammmmammamamaaamammma"
11 = slow pulse, fading to black: "abcdefghijklmnopqrrqponmlkjihgfedcba"
styles 32-62 are assigned by the light program for switchable lights
(default: 0)
"message" override the style string directly for the assigned style (clashes will overwrite each other)
*/
/*FGD
@PointClass base(Light) = light_fluorospark : "Sparking flickering light source" []
*/
void() light_fluorospark =
{
if (!self.style)
self.style = 10;
precache_sound ("ambience/buzz1.wav");
ambientsound (self.origin, "ambience/buzz1.wav", 0.5, ATTN_STATIC);
}
/*QUAKED light_globe (1 1 0) (-12 -12 -12) (12 12 12)
Sphere globe light. Can't be triggered.
Keys:
"light" sets brightness (default: 300)
"mangle" spotlight direction - the first # is yaw, 0 to 360 around Z. second # is pitch, 90 up to -90 down.
"angle" spotlight cone size
"_softangle" spotlight inner cone size
"wait" scale the falloff distance. N>1 will shorten range, n<1 will extend it
"delay" attenuation formula
0 = Linear, original id (default)
1 = 1/x attenuation formula
2 = 1/(x^2) attenuation formula
3 = No attenuation (light stays same brightness at any distance)
"_color" "# # #" 0-255
"style"
0 = normal
1 = flicker: "mmnmmommommnonmmonqnmmo"
2 = slow strong pulse: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
3 = candle: "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"
4 = fast strobe: "mamamamamama"
5 = slow pulse, no black: "jklmnopqrstuvwxyzyxwvutsrqponmlkj"
6 = flicker: "nmonqnmomnmomomno"
7 = candle: "mmmaaaabcdefgmmmmaaaammmaamm"
8 = candle2: "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"
9 = slow strobe: "aaaaaaaazzzzzzzz"
10 = flourescent flicker: mmamammmmammamamaaamammma"
11 = slow pulse, fading to black: "abcdefghijklmnopqrrqponmlkjihgfedcba"
styles 32-62 are assigned by the light program for switchable lights
(default: 0)
"message" override the style string directly for the assigned style (clashes will overwrite each other)
*/
/*FGD
@PointClass base(Light) size(24 24 24) = light_globe : "Globe light" []
*/
void() light_globe =
{
precache_model ("progs/s_light.spr");
setmodel (self, "progs/s_light.spr");
makestatic (self);
}
void() FireAmbient =
{
if (self.spawnflags & 2) return; // silent spawnflag
precache_sound ("ambience/fire1.wav");
// attenuate fast
ambientsound (self.origin, "ambience/fire1.wav", 0.5, ATTN_STATIC);
}
/*QUAKED light_torch_small_walltorch (1 1 0) (-4 -4 -12) (4 4 20)
Short wall torch. Makes crackly torch sound.
Flags:
"silent" no ambient noise
Keys:
"light" sets brightness (default: 300)
"mangle" spotlight direction - the first # is yaw, 0 to 360 around Z. second # is pitch, 90 up to -90 down.
"angle" spotlight cone size
"_softangle" spotlight inner cone size
"wait" scale the falloff distance. N>1 will shorten range, n<1 will extend it
"delay" attenuation formula
0 = Linear, original id (default)
1 = 1/x attenuation formula
2 = 1/(x^2) attenuation formula
3 = No attenuation (light stays same brightness at any distance)
"_color" "# # #" 0-255
"style"
0 = normal
1 = flicker: "mmnmmommommnonmmonqnmmo"
2 = slow strong pulse: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
3 = candle: "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"
4 = fast strobe: "mamamamamama"
5 = slow pulse, no black: "jklmnopqrstuvwxyzyxwvutsrqponmlkj"
6 = flicker: "nmonqnmomnmomomno"
7 = candle: "mmmaaaabcdefgmmmmaaaammmaamm"
8 = candle2: "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"
9 = slow strobe: "aaaaaaaazzzzzzzz"
10 = flourescent flicker: mmamammmmammamamaaamammma"
11 = slow pulse, fading to black: "abcdefghijklmnopqrrqponmlkjihgfedcba"
styles 32-62 are assigned by the light program for switchable lights
(default: 0)
"message" override the style string directly for the assigned style (clashes will overwrite each other)
"distance" sound attenuation range (integer) - defaults to 0, which is the same as other ambient sounds.
1 = 'idle' - monster idle sound range
2 = 'normal' - monster bark sound range
3 = 'none' - loops everywhere forever (don't use this)
"volume" loudness (0-1), distinct from distance
*/
/*FGD
@PointClass base(Light, Flame) size(-4 -4 -12, 4 4 20) model({ "path": ":progs/flame.mdl" }) =
light_torch_small_walltorch : "Small walltorch" []
*/
void() light_torch_small_walltorch =
{
precache_model ("progs/flame.mdl");
setmodel (self, "progs/flame.mdl");
FireAmbient ();
makestatic (self);
}
/*QUAKED light_flame_large_yellow (1 1 0) (-8 -8 -12) (8 8 20)
Large yellow flame ball. Makes crackly torch sound.
Flags:
"silent" no ambient noise
Keys:
"light" sets brightness (default: 300)
"mangle" spotlight direction - the first # is yaw, 0 to 360 around Z. second # is pitch, 90 up to -90 down.
"angle" spotlight cone size
"_softangle" spotlight inner cone size
"wait" scale the falloff distance. N>1 will shorten range, n<1 will extend it
"delay" attenuation formula
0 = Linear, original id (default)
1 = 1/x attenuation formula
2 = 1/(x^2) attenuation formula
3 = No attenuation (light stays same brightness at any distance)
"_color" "# # #" 0-255
"style"
0 = normal
1 = flicker: "mmnmmommommnonmmonqnmmo"
2 = slow strong pulse: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
3 = candle: "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"
4 = fast strobe: "mamamamamama"
5 = slow pulse, no black: "jklmnopqrstuvwxyzyxwvutsrqponmlkj"
6 = flicker: "nmonqnmomnmomomno"
7 = candle: "mmmaaaabcdefgmmmmaaaammmaamm"
8 = candle2: "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"
9 = slow strobe: "aaaaaaaazzzzzzzz"
10 = flourescent flicker: mmamammmmammamamaaamammma"
11 = slow pulse, fading to black: "abcdefghijklmnopqrrqponmlkjihgfedcba"
styles 32-62 are assigned by the light program for switchable lights
(default: 0)
"message" override the style string directly for the assigned style (clashes will overwrite each other)
"distance" sound attenuation range (integer) - defaults to 0, which is the same as other ambient sounds.
1 = 'idle' - monster idle sound range
2 = 'normal' - monster bark sound range
3 = 'none' - loops everywhere forever (don't use this)
"volume" loudness (0-1), distinct from distance
*/
/*FGD
@PointClass base(Light, Flame) size(-8 -8 -12, 8 8 20) model({ "path": ":progs/flame2.mdl" }) =
light_flame_large_yellow : "Large yellow flame" []
*/
void() light_flame_large_yellow =
{
precache_model ("progs/flame2.mdl");
setmodel (self, "progs/flame2.mdl");
self.frame = 1;
FireAmbient ();
makestatic (self);
}
/*QUAKED light_flame_small_yellow (1 1 0) (-4 -4 -12) (4 4 20)
Small yellow flame ball. Makes crackly torch sound.
Flags:
"silent" no ambient noise
Keys:
"light" sets brightness (default: 300)
"mangle" spotlight direction - the first # is yaw, 0 to 360 around Z. second # is pitch, 90 up to -90 down.
"angle" spotlight cone size
"_softangle" spotlight inner cone size
"wait" scale the falloff distance. N>1 will shorten range, n<1 will extend it
"delay" attenuation formula
0 = Linear, original id (default)
1 = 1/x attenuation formula
2 = 1/(x^2) attenuation formula
3 = No attenuation (light stays same brightness at any distance)
"_color" "# # #" 0-255
"style"
0 = normal
1 = flicker: "mmnmmommommnonmmonqnmmo"
2 = slow strong pulse: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
3 = candle: "mmmmmaaaaammmmmaaaaaabcdefgabcdefg"
4 = fast strobe: "mamamamamama"
5 = slow pulse, no black: "jklmnopqrstuvwxyzyxwvutsrqponmlkj"
6 = flicker: "nmonqnmomnmomomno"
7 = candle: "mmmaaaabcdefgmmmmaaaammmaamm"
8 = candle2: "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa"
9 = slow strobe: "aaaaaaaazzzzzzzz"
10 = flourescent flicker: mmamammmmammamamaaamammma"
11 = slow pulse, fading to black: "abcdefghijklmnopqrrqponmlkjihgfedcba"
styles 32-62 are assigned by the light program for switchable lights
(default: 0)
"message" override the style string directly for the assigned style (clashes will overwrite each other)
"distance" sound attenuation range (integer) - defaults to 0, which is the same as other ambient sounds.
1 = 'idle' - monster idle sound range
2 = 'normal' - monster bark sound range
3 = 'none' - loops everywhere forever (don't use this)
"volume" loudness (0-1), distinct from distance
*/
/*FGD
@PointClass base(Light, Flame) size(-4 -4 -12, 4 4 20) model({ "path": ":progs/flame2.mdl" }) =
light_flame_small_yellow : "Small yellow flame" []
*/
void() light_flame_small_yellow =
{
precache_model ("progs/flame2.mdl");
setmodel (self, "progs/flame2.mdl");
FireAmbient ();
makestatic (self);
}
/*QUAKED light_flame_small_white (1 1 0) (-4 -4 -12) (4 4 20)
Same as light_flame_small_yellow. Use that one.
*/
/*FGD
@PointClass base(Light, Flame) size(-4 -4 -12, 4 4 20) model({ "path": ":progs/flame2.mdl" }) =
light_flame_small_white : "Small white flame (same as light_flame_small_yellow)" []
*/
void() light_flame_small_white =
{
light_flame_small_yellow();
}
// ================================================================
void() light_candle_group_off =
{
entity c;
c = self;
do {
c.frame = not(c.frame, 1);
c = c.buddy;
} while (c != self && c != world);
}
void() light_candle_group_on =
{
entity c;
c = self;
do {
c.frame |= 1;
c = c.buddy;
} while (c != self && c != world);
}
void() light_candle_use =
{
light_use();
if (self.spawnflags & START_OFF)
light_candle_group_off();
else
light_candle_group_on();
}
// cache all candles with the same targetname as a linked list, with the first
// one as master, so they can all be turned on and off in one target activation
// without searching the whole map each time
void() light_candle_group =
{
if (self.buddy)
return;
entity c, clast;
string oh = self.targetname;
clast = c = self;
do {
c = find(c, targetname, oh);
if (c.classname == "light_candle")
{
clast.buddy = c;
c.targetname = string_null;
c.nextthink = 0;
clast = c;
}
} while (c != world);
self.targetname = oh;
self.use = light_candle_use;
}
/*QUAKED light_candle (1 1 0) (-4 -4 0) (4 4 16) START_OFF
Candle. If triggered to turn on and off, all candles with a matching targetname will ignite or go out as well.
Keys:
"width" - choose width 1-3, default (0) is random
"height" - choose height 1-3, default (0) is random
"angle" - choose orientation, blank is random yaw
See 'light' keyvalues/spawnflags for more.
*/
/*FGD
@PointClass base(LightTriggerable) size(-4 -4 0, 4 4 16) model({ "path": ":progs/candle2.mdl" }) =
light_candle : "Animated candle. Trigger to turn on or off.
If triggered to turn on and off, all candles with a matching targetname will ignite or go out as well.
Choose size with 'width' and 'height' (leave either at 0 for random selection)."
[
width(choices) : "Width" : 0 =
[
0: "Random"
1: "Narrow"
2: "Medium"
3: "Thick"
]
height(choices) : "Height" : 0 =
[
0: "Random"
1: "Short"
2: "Medium"
3: "Tall"
]
]
*/
void() light_candle =
{
if (!self.width)
//self.width = 1 + floor(random()*2.99);
self.width = 1 + floor(fabs((self.origin_x % 5) + (self.origin_y % 13) - self.origin_z) % 3);
if (!self.height)
//self.height = 1 + floor(random()*2.99);
self.height = 1 + floor(fabs((self.origin_x % 11) + (self.origin_y % 7) - self.origin_z) % 3);
if (self.angles == VEC_ORIGIN)
self.angles_y = floor(fabs((self.origin_x % 17) + (self.origin_y % 23) - self.origin_z) % 10) * 36;
if (self.height == 1)
self.model = "progs/candle1.mdl";
else if (self.height == 2)
self.model = "progs/candle2.mdl";
else if (self.height == 3)
self.model = "progs/candle3.mdl";
precache_model2(self.model);
setmodel(self,self.model);
if (self.width == 1)
self.frame = 4;
else if (self.width == 2)
self.frame = 0;
else if (self.width == 3)
self.frame = 2;
if (!(self.spawnflags & START_OFF))
self.frame += 1;
light_message();
if (self.targetname == string_null && self.style < 32)
{
makestatic(self);
return;
}
light_oldstyle();
self.think = light_candle_group;
self.nextthink = time + 0.1;
}
// ================================================================
string() target_lightstyle_next =
{
entity tls;
if (self.owner) tls = self.owner;
else tls = self;
if (tls.state == 0)
{
if (tls.noise == string_null)
tls.state = 0;
else
tls.state += 1;
return tls.message;
}
else if (tls.state == 1)
{
if (tls.noise1 == string_null)
tls.state = 0;
else
tls.state += 1;
return tls.noise;
}
else if (tls.state == 2)
{
if (tls.noise2 == string_null)
tls.state = 0;
else
tls.state += 1;
return tls.noise1;
}
else if (tls.state == 3)
{
if (tls.noise3 == string_null)
tls.state = 0;
else
tls.state += 1;
return tls.noise2;
}
else if (tls.state == 4)
{
if (tls.noise4 == string_null)
tls.state = 0;
else
tls.state += 1;
return tls.noise3;
}
else if (tls.state == 5)
{
tls.state = 0;
return tls.noise4;
}
return tls.message;
}
void(entity l, string st) lightstyle_switch =
{
if (l.style)
lightstyle(l.style, st);
if (l.switchshadstyle)
lightstyle(l.switchshadstyle, st);
}
void() target_lightstyle_go =
{
float st;
string newstyle = target_lightstyle_next();
if (self.style)
{
st = zeroconvert(self.style);
lightstyle(st, newstyle);
return;
}
entity l;
if (self.target != string_null)
{
l = world;
while (l.style == 0 && l.switchshadstyle == 0)
{
l = find(l, targetname, self.target);
if (l == world)
{
dprint3("target_lightstyle couldn't find target ", self.target, "\n");
break;
}
}
}
if (l) lightstyle_switch(l, newstyle);
if (self.target2 != string_null)
{
l = world;
while (l.style == 0 && l.switchshadstyle == 0)
{
l = find(l, targetname, self.target2);
if (l == world)
{
dprint3("target_lightstyle couldn't find target2 ", self.target, "\n");
break;
}
}
}
if (l) lightstyle_switch(l, newstyle);
if (self.target3 != string_null)
{
l = world;
while (l.style == 0 && l.switchshadstyle == 0)
{
l = find(l, targetname, self.target3);
if (l == world)
{
dprint3("target_lightstyle couldn't find target3 ", self.target, "\n");
break;
}
}
}
if (l) lightstyle_switch(l, newstyle);
if (self.target4 != string_null)
{
l = world;
while (l.style == 0 && l.switchshadstyle == 0)
{
l = find(l, targetname, self.target4);
if (l == world)
{
dprint3("target_lightstyle couldn't find target4 ", self.target, "\n");
break;
}
}
}
if (l) lightstyle_switch(l, newstyle);
}
void() target_lightstyle_use =
{
entity tls;
if (self.delay)
{
tls = spawn();
tls.think = target_lightstyle_go;
tls.nextthink = time + self.delay;
SUB_CopyTargets(tls);
tls.style = self.style;
tls.owner = self;
}
else
{
target_lightstyle_go();
}
playercount_convert(count);
if (self.count > 0)
{
self.count -= 1;
if (self.count == 0)
remove(self);
}
}
/*QUAKED target_lightstyle (.5 .8 .5) (-8 -8 -8) (8 8 8) START_ON
This entity changes a global lightstyle when triggered. Set "style" to the lightstyle you want to override, and set "message" to the brightness pattern you want to set it to. If style is not set, and this entity targets any triggerable lights, it sets the brightness pattern of those lights when triggered instead. Note that targeting anything at a light makes it a triggerable light with its own style automatically.
Setting style to -1 will override lightstyle 0, which is all static lights in the entire level.
"targetname" if unspecified, will auto-fire itself once at map start
"count" limit number of uses, 0 = infinite
"delay" pause between trigger and activation
"noise/noise1-4" cycle to additional brightness patterns on subsequent activations
START_ON: fire itself once when the map starts regardless of targetname
*/
/*FGD
@PointClass base(Appearflags, Targetname) color(128 210 128) = target_lightstyle :
"Target : Lightstyle
Changes a global lightstyle when triggered. Will auto-fire at spawn if it has no targetname.
Cycles through 'message' and then all the 'noise' keys if triggered repeatedly."
[
message(string) : "Brightness pattern"
noise(string) : "Brightness pattern (2nd)"
noise1(string) : "Brightness pattern (3rd)"
noise2(string) : "Brightness pattern (4th)"
noise3(string) : "Brightness pattern (5th)"
noise4(string) : "Brightness pattern (6th)"
style(integer) : "Lightstyle to change (0-63)" : 0
count(integer) : "Limit uses" : 0
delay(string) : "Delay before activation" : "0"
target(target_destination) : "Target: acts on all with matching targetname"
target2(target_destination) : "Target 2: acts on all with matching targetname"
target3(target_destination) : "Target 3: acts on all with matching targetname"
target4(target_destination) : "Target 4: acts on all with matching targetname"
spawnflags(flags) = [
1 : "Go at map start" : 0
]
]
*/
void() target_lightstyle =
{
if (!SUB_ShouldSpawn())
return;
if (self.message == string_null)
self.message = "azam"; // suitably garish accidental default
self.use = target_lightstyle_use;
if (self.spawnflags & 1 || self.targetname == string_null)
{
self.think = target_lightstyle_go;
self.nextthink = time + 0.1;
}
}