-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrubicon2.qc
1137 lines (905 loc) · 29.5 KB
/
rubicon2.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
/*==============================================================================
Rubicon 2 code by john fitzgibbons
Files created for rubicon 2:
- rubicon2.qc * func_breakable object that can be destroyed by shooting
* func_explobox same as misc_explobox but it's a brush entity
* func_laser togglable laser, can be solid or pass through
* item_circuitboard collectible circuit board thing
* light_fixture1 light fixture model
* light_beacon red flashing beacon
* misc_flag animated hanging banner
* misc_sparks spark emitter
* misc_smoke smoke/steam emitter
* misc_splash waterfall splash effect
* trigger_ladder invisible ladder volume
- dread.qc * monster_dreadnaught soldier with flame thrower
- floyd.qc * monster_floyd automaton enemy
- centurion.qc * monster_centurion air centurion
- turret.qc * func_turret defense turret
Files modified for rubicon 2 (search for "johnfitz" to find each modified bit):
- ai.qc * modified pain_forward() so floyd animations look better
* added new sight sounds: floyd, dread
* fixed monsters attacking intermission camera
- buttons.qc * added "movedir" key -- use it to set a button's move vector directly
- client.qc * added new obituaries
* removed axe and shotgun from default items in SetNewParms() but only on certain maps
* added code for impulse 666 (resurrection cheat)
* fixed armor absorbs drowning damage
* added ladder movement code
* added burning player code
- combat.qc * modified T_Damage() so that armour won't protect you from drowning damage
- defs.qc * added new fields and constants
* changed IT_EXTRA_WEAPON to IT_NO_WEAPON
- doors.qc * fixed unlock sound not being played on keyed doors
* added "movedir" key -- use it to set a door's move vector directly
- items.qc * weapon_axe
* weapon_shotgun
- fish.qc * fixed fish staying solid too long after death
- misc.qc * fixed ambient sounds consume edicts
* ambient_general
- monsters.qc * fixed fish count twice towards total_monsters
- plats.qc * added "retrigger" flag to func_train -- train will wait to be retriggered at each path_corner
* more func_train sound options
- player.qc * added player hurt sounds: steam(smoke), flame
- progs.src * added lines to compile the new .qc files
- triggers.qc * trigger_setskill is now targetable
- weapons.qc * added code for having no weapons (IT_NO_WEAPON)
* added code to make a clanking sound when hitting damagable brushmodels with axe
* fixed impulsecommands() called even though impulse = 0
* added new cheats (impulse 252, 253, 254 = ring, biosuit, pent)
- world.qc * fixed sounds for cheats not being precached
* added lightstyles 12 through 15
Files added for rubicon2:
- hiprot.qc * info_rotate
* func_movewall
* func_rotate_door
* func_rotate_entity
* func_rotate_train
* path_rotate
* rotate_object
* added sounds 4 = screechy metal for func_rotate_door
==============================================================================*/
//function to help monsters not shoot each other
float (entity targ) clean_shot =
{
local vector spot1, spot2;
spot1 = self.origin + self.view_ofs;
spot2 = targ.origin + targ.view_ofs;
traceline (spot1, spot2, FALSE, self); // try not to shoot through other monsters
if (trace_ent != targ)
return FALSE;
return TRUE;
};
/*
===============================================================================
func_breakable
===============================================================================
*/
float BREAKABLE_GREENMETAL = 0;
float BREAKABLE_REDMETAL = 1;
float BREAKABLE_CONCRETE = 2;
float BREAKABLE_GLASS = 3;
float BREAKABLE_WOOD = 5;
float BREAKABLE_ALWAYS_SHOOTABLE = 2;
float BREAKABLE_ONLY_EXPLOSION = 4;
void() make_breakable_debris = {
local float i;
i = 0;
while (i < self.cnt)
{
local entity new;
new = spawn();
new.origin_x = (self.maxs_x - self.mins_x)*random() + self.mins_x;
new.origin_y = (self.maxs_y - self.mins_y)*random() + self.mins_y;
new.origin_z = (self.maxs_z - self.mins_z)*random() + self.mins_z;
setmodel(new, self.mdl);
setsize(new, '0 0 0', '0 0 0');
new.velocity = VelocityForDamage (self.health*2);
new.movetype = MOVETYPE_BOUNCE;
new.solid = SOLID_NOT;
new.avelocity_x = random()*600;
new.avelocity_y = random()*600;
new.avelocity_z = random()*600;
new.think = GibThink;
new.ltime = time;
new.nextthink = time + 10 + random()*10;
//new.nextthink = time + 3;
new.flags = 0;
if(self.style == BREAKABLE_REDMETAL) {
new.skin = 1;
if (random() > 0.333)
new.frame = 1; //larger
else
new.frame = 2; //smaller
}
else if(self.style == BREAKABLE_CONCRETE) {
new.skin = 2;
if (random() > 0.333)
new.frame = 1; //larger
else
new.frame = 2; //smaller
}
else if(self.style == BREAKABLE_GLASS) {
new.alpha = 0.6;
new.frame = 1;
}
else if (self.style == BREAKABLE_GREENMETAL) {
new.skin = 0;
if (random() > 0.333)
new.frame = 1; //larger
else
new.frame = 2; //smaller
}
if (self.alpha2) new.alpha = self.alpha2;
i = i + 1;
}
};
void() func_breakable_break = {
sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
self.origin = (self.absmin + self.absmax) * 0.5;
setorigin(self, self.origin);
make_breakable_debris();
if (self.switchshadstyle) lightstyle(self.switchshadstyle, "m");
// broke by attacker
if (self.health <= 0) activator = damage_attacker;
SUB_UseTargets();
remove(self);
};
float(entity inflictor, entity attacker, float damage, float orig_damage, float dmgtype) func_breakable_damage = {
float ret;
ret = damage;
if (self.spawnflags & BREAKABLE_NO_MONSTERS && attacker.flags & FL_MONSTER)
ret = 0;
if (self.spawnflags & BREAKABLE_ONLY_EXPLOSION && !(dmgtype & DMGTYPE_EXPLOSION))
ret = 0;
return ret;
}
/*QUAKED func_breakable (0 .5 .8) ? NO_MONSTERS
A visible object that can be destroyed by shooting it. If it has a targetname, it will not be directly damageable.
NO_MONSTERS: object ignores damage from monsters
"health" Default 20
"cnt" number of pieces of debris to spawn. default 6.
"style" The style of the debris:
0 = green metal (default)
1 = red metal
2 = concrete
3 = glass
*/
void() func_breakable =
{
if (!SUB_InitEntity()) return;
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
setmodel (self, self.model);
if (self.style == BREAKABLE_REDMETAL) {
if (!self.noise1) self.noise1 = "misc/metal_impact.wav";
if (!self.mdl) self.mdl = "progs/debris.mdl";
self.cnt = zeroconvertdefault(self.cnt,6);
if (!self.bloodtype) self.bloodtype = SPAWN_DIRT;
}
else if (self.style == BREAKABLE_CONCRETE) {
if (!self.noise1) self.noise1 = "misc/conc_impact.wav";
if (!self.mdl) self.mdl = "progs/debris.mdl";
self.cnt = zeroconvertdefault(self.cnt,6);
if (!self.bloodtype) self.bloodtype = SPAWN_DIRT;
}
else if(self.style == BREAKABLE_GLASS) {
if (!self.mdl) self.mdl = "maps/glass01.bsp";
if (!self.noise1) self.noise1 = "misc/glass_impact.wav";
self.cnt = zeroconvertdefault(self.cnt,15);
if (!self.bloodtype) self.bloodtype = SPAWN_WHITESPARK;
}
else if (self.style == BREAKABLE_GREENMETAL) {
if (!self.noise1) self.noise1 = "misc/metal_impact.wav";
if (!self.mdl) self.mdl = "progs/debris.mdl";
self.cnt = zeroconvertdefault(self.cnt,6);
if (!self.bloodtype) self.bloodtype = SPAWN_DIRT;
}
else if (self.style == BREAKABLE_WOOD) {
if (!self.noise1) self.noise1 = "misc/wood_impact.wav";
if (!self.mdl) self.mdl = "maps/wood07.bsp";
self.cnt = zeroconvertdefault(self.cnt,6);
if (!self.bloodtype) self.bloodtype = SPAWN_DIRT;
}
else {
if (!self.noise1) self.noise1 = "misc/null.wav";
if (!self.mdl) self.mdl = "progs/misc_empty.mdl";
self.cnt = zeroconvertdefault(self.cnt,6);
if (!self.bloodtype) self.bloodtype = SPAWN_DIRT;
}
precache_sound (self.noise1);
precache_model (self.mdl);
if (self.health <= 0)
self.health = 20;
self.use = func_breakable_break;
self.th_damage = func_breakable_damage;
if (self.targetname == "" || (self.targetname != "" && (self.spawnflags & BREAKABLE_ALWAYS_SHOOTABLE))) {
self.takedamage = DAMAGE_YES;
self.th_die = func_breakable_break;
}
if (self.switchshadstyle) lightstyle(self.switchshadstyle, "a");
};
/*
===============================================================================
func_explobox
===============================================================================
*/
void () func_explobox_explode =
{
self.takedamage = DAMAGE_NO;
self.origin = ((self.absmin + self.absmax) * 0.5);
self.classname = "explo_box";
sound (self, CHAN_VOICE, "weapons/r_exp3.wav", 1, ATTN_NORM);
T_RadiusDamage(self, self, self.dmg, 1, world, DMGTYPE_EXPLOSION);
activator = self.enemy;
SUB_UseTargets();
BecomeExplosion ();
};
void () func_explobox_die =
{
// already fired, so disable all subsequent triggers
self.th_die = SUB_Null;
self.use = SUB_Null;
if (self.health <= 0) self.enemy = damage_attacker;
else self.enemy = activator;
self.enemy = damage_attacker;
self.nextthink = self.ltime + 0.05 + random()*0.05;
self.think = func_explobox_explode;
};
/*QUAKED func_explobox (0 .5 .8) ? START_OFF
An exploding brush entity. Works just like misc_explobox.
Keys:
"health" Default 20
"dmg" default 100
*/
void () func_explobox =
{
if (!SUB_InitEntity()) return;
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
setmodel (self, self.model);
precache_sound ("weapons/r_exp3.wav");
if (!self.health)
self.health = 20;
if (!self.dmg)
self.dmg = 100;
self.bloodtype = zeroconvertdefault(self.bloodtype, SPAWN_YELLOWSPARK);
self.use = func_explobox_die;
self.th_die = func_explobox_die;
if (!self.obituary) self.obituary = "blew up";
if(!(self.spawnflags & 1)) self.takedamage = DAMAGE_AIM;
};
/*
===============================================================================
func_laser
===============================================================================
*/
float LASER_SOLID = 2;
float LASER_SILENT = 4;
float LASER_DONTHURTMONSTERS = 8;
void() laser_helper_think =
{
if (!self.owner || self.owner.classname != "func_laser") {
remove(self);
return;
}
if (self.owner.state)
self.owner.alpha = self.alpha * 0.8 + self.alpha * random() * 0.4;
self.nextthink = time + 0.05;
};
void() func_laser_touch = {
if (!self.state)
return;
if (!self.dmg)
return;
if (other.flags & FL_MONSTER && self.spawnflags & LASER_DONTHURTMONSTERS)
return;
if (other.takedamage && self.attack_finished < time) {
T_Damage(other, self, self, self.dmg, DMGTYPE_ENERGY);
self.attack_finished = time + 0.1;
}
};
void () func_laser_use = {
if (!self.state) {
if (self.spawnflags & LASER_SOLID) {
self.solid = SOLID_BSP;
self.movetype = MOVETYPE_PUSH;
}
setmodel (self, self.origmodel);
if (!(self.spawnflags & LASER_SILENT))
sound (activator, CHAN_VOICE, "misc/laser_on.wav", 1, ATTN_NORM);
if (activator.classname == "player" && self.message != "")
centerprint (activator, self.message);
self.state = 1;
}
else {
if (self.spawnflags & LASER_SOLID) {
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
}
setmodel (self, "");
if (!(self.spawnflags & LASER_SILENT))
sound (activator, CHAN_VOICE, "misc/laseroff.wav", 1, ATTN_NORM);
if (activator.classname == "player" && self.message2 != "")
centerprint (activator, self.message2);
self.state = 0;
}
};
/*QUAKED func_laser (0 .5 .8) ? START_OFF LASER_SOLID
A togglable laser, hurts to touch, can be used to block players
START_OFF: Laser starts off.
LASER_SOLID: Laser blocks movement while turned on.
Keys:
"dmg" damage to do on touch. default 1
"alpha" approximate alpha you want the laser drawn at. default 0.5. alpha will vary by 20% of this value.
"message" message to display when activated
"message2" message to display when deactivated
*/
void () func_laser =
{
if (!SUB_InitEntity()) return;
local entity helper;
self.origmodel = self.model;
if (self.spawnflags & LASER_SOLID) {
if (self.spawnflags & START_OFF) {
self.solid = SOLID_NOT;
self.movetype = MOVETYPE_NONE;
}
else {
self.solid = SOLID_BSP; //so you can shoot between lasers in a single bmodel
self.movetype = MOVETYPE_PUSH;
}
}
else {
self.solid = SOLID_TRIGGER;
self.movetype = MOVETYPE_NONE;
}
if (self.spawnflags & START_OFF) {
self.state = 0;
setmodel(self, "");
}
else {
self.state = 1;
setmodel (self, self.model);
}
precache_sound ("misc/laser_on.wav");
precache_sound ("misc/laseroff.wav");
if (!self.alpha)
self.alpha = 0.5;
self.flags |= FL_IGNOREDATTACK; // monsters won't try to get mad at the laser
self.dmg = zeroconvertdefault(self.dmg, 1);
self.use = func_laser_use;
self.touch = func_laser_touch;
if (!self.obituary) self.obituary = "looked into laser with remaining eye";
// lasers shouldn't get bulletholes
self.nobullets = zeroconvertdefault(self.nobullets, 1);
//spawn a second entity to handle alpha changes, since MOVETYPE_PUSH doesn't support think functions
helper = spawn();
helper.alpha = self.alpha;
helper.owner = self;
helper.nextthink = 0.05;
helper.think = laser_helper_think;
};
/*
===============================================================================
item_circuitboard
===============================================================================
*/
void () circuitboard_touch =
{
if (other.classname != "player")
{
return;
}
if (other.health <= 0)
{
return;
}
stuffcmd (other, "bf\n");
if(!(self.spawnflags & 1)) {
sprint(other, "You got ");
sprint(other, self.netname);
sprint(other, "\n");
}
sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
activator = other;
SUB_UseTargets ();
remove (self);
};
/*QUAKED item_circuitboard (0 .5 .8) (-16 -16 -24) (16 16 32)
collectible circuit board thing
*/
void () item_circuitboard =
{
if (!SUB_InitEntity()) return;
if(!self.mdl) self.mdl = "progs/fromitz.mdl";
precache_model (self.mdl);
setmodel (self, self.mdl);
if(!self.netname) self.netname = "the 17-centimeter Fromitz board!";
if(!self.noise) self.noise = "misc/basekey.wav";//"items/protect.wav";
precache_sound (self.noise);
self.touch = circuitboard_touch;
setsize (self, '-16 -16 -24', '16 16 32');
StartItem ();
};
/*
===============================================================================
light_fixture1
===============================================================================
*/
/*QUAKED light_fixture1 (0 1 0) (-8 -8 -8) (8 8 24)
wall-mounted light fixture.
Default light value is 300
Default style is 0
Keys:
"angle2" is the angle the model should be facing; set it to face away from the wall
*/
void() light_fixture1 =
{
if (!SUB_InitEntity()) return;
precache_model ("progs/fixture1.mdl");
setmodel (self, "progs/fixture1.mdl");
self.angles_y = self.angle2;
makestatic (self);
};
/*
===============================================================================
light_beacon
===============================================================================
*/
/*QUAKED light_beacon (0 1 0) (-8 -8 -36) (8 8 8) BLINKING
floor-mounted flashing red beacon
Default light value is 300
Default style is 0
Flags:
"Blinking" if you want the beacon to blink (Set style to "16" to match the skin animation.)
Keys:
"angle2" can be used to rotate the model
*/
void() light_beacon =
{
if (!SUB_InitEntity()) return;
precache_model ("progs/beacon.mdl");
setmodel (self, "progs/beacon.mdl");
if (self.spawnflags & 1)
self.skin = 1;
self.angles_y = self.angle2;
makestatic (self);
};
/*
===============================================================================
misc_flag
===============================================================================
*/
/*QUAKED misc_flag (1 0 0) (-8 -8 -8) (8 8 8) NOT_ANIMATED BIG
A hanging banner, gently waving in the wind. Normal dimensions: 64 wide by 144 long.
Flags:
"Not Animated" Banner is not animated.
"Big" Banner is twice as big: 128 wide by 288 long.
*/
void () misc_flag =
{
if (!SUB_InitEntity()) return;
precache_model ("progs/flag.mdl");
setmodel (self, "progs/flag.mdl");
self.frame = (self.spawnflags & 3);
makestatic (self);
};
/*
===============================================================================
misc_sparks
===============================================================================
*/
float SPARKS_BLUE = 2;
float SPARKS_PALE = 4;
void() sparks_fade1 = [0, sparks_fade2] {self.alpha = 0.8; self.nextthink = time + 0.05;};
void() sparks_fade2 = [0, sparks_fade3] {self.alpha = 0.6; self.nextthink = time + 0.05;};
void() sparks_fade3 = [0, sparks_fade4] {self.alpha = 0.4; self.nextthink = time + 0.05;};
void() sparks_fade4 = [0, SUB_Remove] {self.alpha = 0.2; self.nextthink = time + 0.05;};
void() sparks_use =
{
if (self.spawnflags & START_OFF)
self.spawnflags = self.spawnflags - START_OFF;
else
self.spawnflags = self.spawnflags + START_OFF;
};
void() misc_sparks_think;
void() spark_turnofflight =
{
SUB_UseTargets();
self.think = misc_sparks_think;
self.nextthink = time + (random() + 0.5)*self.wait - 0.15;
}
void(vector org, float qt, float color, vector vel) spawnsparks = {
local float i;
i = -0.25*qt + random()*0.5*qt;
while (i < qt)
{
local entity spark;
spark = spawn();
spark.owner = self;
setmodel (spark, "progs/spark.mdl");
setorigin (spark, org);
spark.movetype = MOVETYPE_BOUNCE;
spark.solid = SOLID_TRIGGER;
spark.gravity = 0.3;
spark.velocity_x = vel_x -40 + random() * 80;
spark.velocity_y = vel_y -40 + random() * 80;
spark.velocity_z = vel_z -40 + random() * 80;
spark.avelocity = '3000 3000 3000';
spark.nextthink = time + 0.5 + 1.5*random();
spark.think = sparks_fade1;
spark.classname = "spark";
if (random() < 0.33)
spark.skin = 0;
else if (random() < 0.5)
spark.skin = 1;
else
spark.skin = 2;
if (color == SPARKS_PALE)
spark.skin = spark.skin + 6;
else if (color == SPARKS_BLUE)
spark.skin = spark.skin + 3;
setsize (spark, '0 0 0', '0 0 0');
i = i + 1;
}
}
void() misc_sparks_think =
{
if (self.spawnflags & START_OFF)
{
self.nextthink = time + 0.1;
self.think = misc_sparks_think;
}
else
{
float color;
if (self.spawnflags & SPARKS_PALE)
color = SPARKS_PALE;
else if (self.spawnflags & SPARKS_BLUE)
color = SPARKS_BLUE;
//spawnsparks(self.origin, self.cnt, color, '0 0 0');
spawnsparks(self.origin, self.cnt, color, self.movedir);
if (self.sounds == 1)
sound (self, CHAN_AUTO, "misc/spark.wav", 1, ATTN_STATIC);
SUB_UseTargets();
self.nextthink = time + 0.1 + random() * 0.1;
self.think = spark_turnofflight;
}
};
/*QUAKED misc_sparks (0 .5 .8) (-8 -8 -8) (8 8 8) START_OFF SPARKS_BLUE SPARKS_PALE
Produces a burst of yellow sparks at random intervals. If targeted, it will toggle between on or off. If it targets a light, that light will flash allong with each burst of sparks. Note: targeted lights should be set to START_OFF.
SPARKS_BLUE: sparks are blue in color
SPARKS_PALE: sparks are pale yellow in color
Keys:
"wait" is the average delay between bursts (variance is 1/2 wait). Default is 2.
"cnt" is the average number of sparks in a burst (variance is 1/4 cnt). Default is 15.
"sounds"
0) no sound
1) sparks
*/
void() misc_sparks =
{
if (!SUB_InitEntity()) return;
precache_model ("progs/spark.mdl");
precache_sound ("misc/spark.wav");
if (!self.movedir)
self.movedir = '0 0 -30';
if (!self.wait)
self.wait = 2;
if (!self.cnt)
self.cnt = 15;
self.use = sparks_use;
self.nextthink = time + random()*0.1;
self.think = misc_sparks_think;
};
/*
===============================================================================
misc_smoke
===============================================================================
*/
void() smoke_touch =
{
if (other == self.owner)
return;
if (other.solid == SOLID_TRIGGER)
return; // trigger field, do nothing
if (self.dmg > 0 && other.health)
{
T_Damage(other, self, self, self.dmg, DMGTYPE_BURN);
self.dmg = 0;
}
self.velocity = '0 0 0'; //FIXME: can't set velocity in a touch function
self.movedir = '0 0 0';
self.movedir2 = '0 0 15';
};
void() smoke_rise =
{
self.cnt = self.cnt + 1;
if (self.cnt > 6)
{
remove(self);
return;
}
self.frame = self.cnt;
self.velocity = self.velocity + self.movedir2 - (self.movedir * 0.12);
self.nextthink = time + 0.1 + random() * 0.05;
self.think = smoke_rise;
};
void() smoke_think =
{
if (self.spawnflags & START_OFF)
{
self.think = smoke_think;
self.nextthink = time + 0.1;
}
else
{
local entity smoke;
smoke = spawn();
smoke.owner = self;
setmodel (smoke, "progs/s_smoke.spr");
setorigin (smoke, self.origin);
smoke.movetype = MOVETYPE_FLY; //MOVETYPE_NOCLIP or MOVETYPE_FLY ?
smoke.solid = SOLID_BBOX; //was SOLID_TRIGGER or SOLID_BBOX?
smoke.velocity_x = self.movedir_x - 10 + random() * 20;
smoke.velocity_y = self.movedir_y - 10 + random() * 20;
smoke.velocity_z = self.movedir_z - 10 + random() * 20;
smoke.angles_z = random() * 360;
smoke.nextthink = time + 0.1 + random() * 0.05;
smoke.think = smoke_rise;
smoke.touch = smoke_touch;
smoke.classname = "smoke";
smoke.dmg = self.dmg;
smoke.movedir2 = self.movedir2;
smoke.frame = 0;
smoke.cnt = 0;
smoke.alpha = self.alpha;
setsize (smoke, '0 0 0', '0 0 0');
self.think = smoke_think;
self.nextthink = time + self.wait;
if (self.sounds)
{
local entity e;
local float dist;
//loop through players and see if any are at the outer audible range for this emitter
//if yes, restart the loop sound in case they were too far away when it started playing
//if a second player is well inside the radius, they will hear somewhat degraded sound
//but it can't be helped
e = find(world, classname, "player");
while(e)
{
dist = vlen(self.origin - e.origin);
if (300 < dist && dist < 350)
{
sound (self, CHAN_VOICE, "misc/airhiss.wav", 1, ATTN_STATIC);
return;
}
e = find(e, classname, "player");
}
}
}
};
void() smoke_use =
{
if (self.spawnflags & START_OFF)
{
self.spawnflags = self.spawnflags - START_OFF;
if (self.sounds)
sound (self, CHAN_VOICE, "misc/airhiss.wav", 1, ATTN_STATIC);
}
else
{
self.spawnflags = self.spawnflags + START_OFF;
if (self.sounds)
sound (self, CHAN_VOICE, "misc/airhiss2.wav", 1, ATTN_STATIC);
}
};
void() smoke_firstthink =
{
if (self.sounds)
if (!(self.spawnflags & START_OFF))
sound (self, CHAN_VOICE, "misc/airhiss.wav", 1, ATTN_STATIC);
smoke_think();
};
/*QUAKED misc_smoke (0 .5 .8) (-8 -8 -8) (8 8 8) START_OFF
Produces a jet of smoke/steam. If targeted, it will toggle between on or off.
Keys:
"wait" is the delay between puffs. Default is 0.1
"movedir" is a vector representing the initial velocity in X Y Z values. Default is "0 0 250" (up)
"movedir2" is a vector representing the wind in X Y Z values. Default is "0 0 0"
"dmg" is the amount of damage each puff gives on contact. Default is 0
"sounds"
0) no sound
1) steam hiss
*/
void() misc_smoke =
{
if (!SUB_InitEntity()) return;
precache_model ("progs/s_smoke.spr");
precache_sound ("misc/airhiss.wav");
precache_sound ("misc/airhiss2.wav");
if (!self.dmg)
self.dmg = 0;
if (!self.movedir)
self.movedir = '0 0 250';
if (!self.movedir2)
self.movedir2 = '0 0 0';
if (!self.wait)
self.wait = 0.1;
self.use = smoke_use;
self.nextthink = time + 0.5;
self.think = smoke_firstthink;
self.obituary = "was steamed alive";
};
/*
===============================================================================
misc_flame
===============================================================================
*/
float FLAME_DONTBURN = 2;
float FLAME_NOSOUND = 4;
float FLAME_SIMPLELIGHT = 8;
float FLAME_ST_OFF = 0;
float FLAME_ST_STOPPING = 1;
float FLAME_ST_ON = 2;
float FLAME_ST_STARTING = 3;
string FLAME_LIGHT_PATTERN = "klolmolmomlnonkmonqnlmo";
void() misc_flame_think =
{
if (self.state < FLAME_ST_ON) {
self.nextthink = time + 0.1;
if (self.state == FLAME_ST_STOPPING) {
if (!(self.spawnflags & FLAME_NOSOUND)) sound(self, CHAN_VOICE, "misc/burning2.wav", 1, ATTN_IDLE);
if (self.style) lightstyle(self.style, "a");
}
self.state = FLAME_ST_OFF;
return;
}
make_flame(self.origin, self.movedir);
if (!(self.spawnflags & FLAME_SIMPLELIGHT))
newmis.effects = 0;
newmis.velocity *= self.speed;
if (self.spawnflags & FLAME_DONTBURN)
newmis.style = 1;
newmis.dmg = self.dmg;
self.nextthink = time + self.wait;
if (self.state == FLAME_ST_ON && !(self.spawnflags & FLAME_NOSOUND)) {
entity e = find(world, classname, "player");
float dist;
while (e)
{
dist = vlen(self.origin - e.origin);
if (dist < 600 && dist > 500) {
self.burning_finished = 0;
__break;
}
e = find(e, classname, "player");
}
if (time > self.burning_finished) sound(self, CHAN_VOICE, "misc/burning.wav", 1, ATTN_IDLE);
self.burning_finished = time + 2.1;
}
if (self.state == FLAME_ST_STARTING) {
self.state = FLAME_ST_ON;
if (self.style) lightstyle(self.style, FLAME_LIGHT_PATTERN);
if (!(self.spawnflags & FLAME_NOSOUND))
sound(self, CHAN_VOICE, "dread/flameon.wav", 1, ATTN_IDLE);
self.burning_finished = time + 0.5;
}
};
void() misc_flame_use = {
if (self.state >= FLAME_ST_ON)
self.state = FLAME_ST_STOPPING;
else
self.state = FLAME_ST_STARTING;
};
void() misc_flame_startup = {
if (self.target != "") {
entity e = find(world, targetname, self.target);
if (e.classname == "light")
self.style = e.style;