forked from SimsOCallaghan/ArcaneDimensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
items.qc
4364 lines (3944 loc) · 160 KB
/
items.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
//======================================================================
// ITEM FUNCTIONS
//======================================================================
/* Moved to defscustom.qc
float ITEM_RESPAWN = 16; // Item will respawn
float ITEM_FLOATING = 32; // Spawn floating
float ITEM_NOEFFECTS = 128; // Disable particles and effects
float H_ROTTEN = 1; // Rotten
float H_MEGA = 2; // Mega Health
float A_LARGE = 1; // Used by ammo boxes
float A_LID = 2; // Display Lid
float BACKPACK_SHELLS = 1;
float BACKPACK_NAILS = 2;
float BACKPACK_ROCKETS = 4;
float BACKPACK_CELLS = 8;
float BACKPACK_GRNTYPE = 1;
float BACKPACK_YELTYPE = 2;
float BACKPACK_REDTYPE = 4;*/
float AIRTANK_SILENT = 8; // No sound with airtank
float SKIN_BASE = 0; // Green ammo boxes and square health packs
float SKIN_MEDIEVAL = 1; // Wood ammo boxes and red health flasks
float ITEM_CKEY1 = 1; // Arcane Key 1
float ITEM_CKEY2 = 2; // Arcane Key 2
float ITEM_CKEY3 = 4; // Arcane Key 3
float ITEM_CKEY4 = 8; // Arcane Key 4
// Used for weapons only
string WEAPON_PICKUP = "weapons/pkup.wav";
// Used for ammo, custom items and backpacks
string AMMO_PICKUP = "weapons/lock4.wav";
// Various bounding boxes for items
// vector VEC_ORID_MIN = '0 0 0';
// vector VEC_ORID_MAX = '32 32 56';
vector VEC_HEAL_MIN = '0 0 0';
vector VEC_HEAL_MAX = '32 32 56';
vector VEC_WPNS_MIN = '-16 -16 0';
vector VEC_WPNS_MAX = '16 16 56';
vector VEC_AMMO_MIN = '0 0 0';
vector VEC_AMMO_MAX = '32 32 56';
vector VEC_KEYS_MIN = '-16 -16 -24';
vector VEC_KEYS_MAX = '16 16 32';
vector VEC_POWR_MIN = '-16 -16 -24';
vector VEC_POWR_MAX = '16 16 32';
// Default respawn timers for items
float RESPAWN_HEALTH = 20; // 15,25,100+
float RESPAWN_ARMOR = 20; // Green, Yellow, Red
float RESPAWN_WEAPON = 30; // SG -> LG
float RESPAWN_AMMO = 30; // Shells,Nails,Rockets,Cells
float RESPAWN_KEY = 60; // Gold,Silver,Custom
float RESPAWN_RUNE = 60; // Sigil/runes
float RESPAWN_ARTIFACT1 = 60; // Quad + Suit
float RESPAWN_ARTIFACT2 = 300; // Pent + Invisibilty
float RESPAWN_BACKPACK = 30; // Random Ammo Drop
float RESPAWN_COOP = 5; // Default timer for coop
float RESPAWN_PARTICLES = 32; // Particle burst for ring/center
float RESPAWN_EXPTIME = 1; // Particles burst lifetime
float RESPAWN_EXPRADIUS = 12; // Particle ring radius
float MODEL_ANIM_SPEED = 3;
float MODEL_ANIM_RANGE = 3;
//----------------------------------------------------------------------
// Some items have pickup conditions which prevent targets
// from firing when coop mode is active, show console warning
//----------------------------------------------------------------------
void() item_coopcheck =
{
// coop active?
if (coop <= 0) return;
// Coop checks for prog list done elsewhere
if (self.progspawnlist) return;
// Check for any target(s) on coop sensitive items?
if (self.target != "" || self.target2 != "") {
dprint("\b[Coop]\b (");
dprint(self.classname);
dprint(") unreliable target(s) in coop!\n");
}
};
//----------------------------------------------------------------------
// Setup skin parameter for ammo and health items
//----------------------------------------------------------------------
// world.worldtype Model style Skin
// 0 = default (Medieval) wood / flasks 1
// 1 = runic / metal wood / flasks 1
// 2 = base green / square packs 0
//
// skin_override Model style Skin
// 0 = default - -
// 1 = base green / square packs 0
// 2 = Medieval wood / flasks 1
//----------------------------------------------------------------------
float(entity targ) item_skintype =
{
// Go through medieval exceptions based on table above
if (world.worldtype == 0 && !targ.skin_override) return SKIN_MEDIEVAL;
else if (world.worldtype == 1 && !targ.skin_override) return SKIN_MEDIEVAL;
else if (targ.skin_override == 2) return SKIN_MEDIEVAL;
else return SKIN_BASE;
};
//----------------------------------------------------------------------
// Check floor under item and animated skin for new BASE health boxes
//----------------------------------------------------------------------
void() item_thinkloop =
{
// Check for entity states
if (self.estate & ESTATE_BLOCK) return;
// Has the item been turned off?
if (self.attack_finished > time) return;
// Has the item removal timer been reached?
if (self.item_expired > 0 && self.item_expired < time) remove(self);
if (self.item_skinanim > 0) {
self.item_skincycle = self.item_skincycle + 1;
if (self.item_skincycle > MODEL_ANIM_SPEED) {
self.item_skincycle = 0;
self.item_skinanim_no = self.item_skinanim_no + 1;
if (self.item_skinanim_no > MODEL_ANIM_RANGE) {
self.item_skinanim_no = 0;
}
}
// Update skin
self.skin = self.item_skinanim_no;
}
// Check floor below item (global function)
if (self.item_flrcheck > 0) {
ent_floorcheck(self, self.item_flrcheck);
// Record any movement for respawn function
self.oldorigin = self.origin;
}
// Keep checking
self.think = item_thinkloop;
self.nextthink = time + 0.1;
};
void() item_estate_setup;
//----------------------------------------------------------------------
void() item_reset =
{
// Reset trigger_once conditions
self.attack_finished = 0;
if (!self.estate_on) item_estate_setup();
self.estate_on();
};
//----------------------------------------------------------------------
void() item_debugcustomdl =
{
if (self.mdl != "") {
dprint("\b[ITEMS]\b "); dprint(self.classname);
dprint(" with Custom mdl ("); dprint(self.mdl);
dprint(")\n");
spawn_marker(self.origin+'0 0 32', SPNMARK_GREEN);
}
};
//----------------------------------------------------------------------
void() item_finished =
{
// Check for coop respawn options
// This system can easily be abused by switching coop on/off
// But its better the respawns are added, rather than not
if (coop > 0) {
if (self.classgroup == CG_WEAPON) {
// This is just crazy back to front logic!
// The id default is respawning weapons for coop
// Which means coop_weapons is FALSE when TRUE!!!
if (coop_weapons == FALSE && self.respawn_time > 0) {
// make sure weapon respawn timer is lower for coop
if (self.respawn_time > RESPAWN_COOP) self.respawn_time = RESPAWN_COOP;
self.spawnflags = self.spawnflags | ITEM_RESPAWN;
}
}
else if (self.classgroup == CG_HEALTH) {
if (coop_health == TRUE && self.respawn_time > 0)
self.spawnflags = self.spawnflags | ITEM_RESPAWN;
}
else if (self.classgroup == CG_AMMOITEM) {
if (coop_ammoboxes == TRUE && self.respawn_time > 0)
self.spawnflags = self.spawnflags | ITEM_RESPAWN;
}
else if (self.classgroup == CG_ARTIFACT) {
if (coop_powerups == TRUE && self.respawn_time > 0)
self.spawnflags = self.spawnflags | ITEM_RESPAWN;
}
}
self.attack_finished = LARGE_TIMER;
if (!self.estate_off) item_estate_setup();
self.estate_off();
};
//----------------------------------------------------------------------
void() item_respawn =
{
// Classic quake re-spawn sound
sound (self, CHAN_VOICE, SOUND_RESPAWN, 1, ATTN_NORM);
// Are particles enabled?
if (query_configflag(SVR_PARTICLES)) {
// Switch off any respawn emitter
if (self.respawn_part.classtype == CT_PARTICLEEMIT)
misc_particle_off(self.respawn_part);
if (self.respawn_style & PARTICLE_BURST_RING)
particle_ring(self.origin + self.respawn_ofs, '0 0 4', '4 4 16', RESPAWN_EXPRADIUS, RESPAWN_PARTICLES, RESPAWN_EXPTIME, self.respawn_style );
else if (self.respawn_style & PARTICLE_BURST_CENTER)
particle_explode(self.origin + self.respawn_ofs, RESPAWN_PARTICLES*2, RESPAWN_EXPTIME, self.respawn_style, self.respawn_style);
}
self.alpha = 1;
self.estate_reset();
};
//----------------------------------------------------------------------
// Re-direction for map hacks (not used normally)
//----------------------------------------------------------------------
void() SUB_regen = {
// self.model = self.mdl;
// self.solid = SOLID_TRIGGER;
sound (self, CHAN_VOICE, SOUND_RESPAWN, 1, ATTN_NORM);
// setorigin (self, self.origin);
item_reset();
};
//----------------------------------------------------------------------
void() alphafade_item_respawn =
{
if (self.waitmin > time) {
self.speed = 1 - ((self.waitmin - time) / self.respawn_time);
self.alpha = 0.1 + ((self.speed*0.4)*random());
// If respawn effect active, modify total particles
if (self.respawn_part.part_style == PARTICLE_STYLE_RESPAWN) {
self.respawn_part.part_limit = rint(RESPAWN_PARTICLES * self.speed);
}
self.think = alphafade_item_respawn;
self.nextthink = time + 0.1;
}
else item_respawn();
};
//----------------------------------------------------------------------
void() start_item_respawn =
{
// Is the item being respawned at the moment?
if (self.waitmin > time) return;
// Is the item setup to instantly respawn?
if (self.respawn_trig == TRUE && self.spawnflags & ITEM_RESPAWN) {
// Check for any respawn quantity counts
if (self.respawn_count > 0) {
self.respawn_count = self.respawn_count - 1;
if (self.respawn_count == 0)
self.spawnflags = self.spawnflags - (self.spawnflags & ITEM_RESPAWN);
}
// Instantly spawn item
item_respawn();
}
else {
// deathmatch 2 is the silly old rules
if (deathmatch == 1 || self.spawnflags & ITEM_RESPAWN) {
setmodel(self,self.mdl);
setsize (self, self.bbmins, self.bbmaxs);
self.waitmin = time + self.respawn_time;
self.alpha = 0.1;
// Check for any respawn quantity counts
if (self.respawn_count > 0) {
self.respawn_count = self.respawn_count - 1;
if (self.respawn_count == 0)
self.spawnflags = self.spawnflags - (self.spawnflags & ITEM_RESPAWN);
}
// Are particles enabled?
if (query_configflag(SVR_PARTICLES)) {
// Switch off any particle emitters
if (self.part_emitter) misc_particle_off(self.part_emitter);
// Is there any need for respawn effect?
if (self.respawn_effect) {
// If emitter does not exist? create one, else switch on
if (self.respawn_part.classtype == CT_PARTICLEEMIT)
misc_particle_on(self.respawn_part);
else self.respawn_part = spawn_pemitter(self, self, PARTICLE_STYLE_RESPAWN, PARTICLE_START_ON);
}
}
// Switch on gradual alpha fade
alphafade_item_respawn();
}
}
};
//----------------------------------------------------------------------
void() check_item_respawn =
{
// Respawn feature is waiting for trigger
if (!self.respawn_trig) start_item_respawn();
};
//----------------------------------------------------------------------
void() item_use =
{
// Check for any trigger respawn conditions first
// Respawn spawnflag, trigger condition and not trigger once
if (self.spawnflags & ITEM_RESPAWN && self.respawn_trig &&
self.estate == ESTATE_OFF) start_item_respawn();
else {
// usual trigger blocks, OFF, DISABLE and trigger_ONCE
if (self.estate & ESTATE_BLOCK) return;
if (self.attack_finished > time) return;
// Was item setup to be floating?
if(self.spawnflags & ITEM_FLOATING){
// Removed checkbottom check, it often fails and leaves
// items floating in midair when they should fall
// if (!checkbottom(self)) - left for comment only
// A quick toss of the item
self.movetype = MOVETYPE_TOSS;
self.origin_z = self.origin_z + 4;
self.flags = self.flags - (self.flags & FL_ONGROUND);
}
}
};
//----------------------------------------------------------------------
void() item_touch =
{
if (self.touchedvoid) {entity_hide(self); return;}
if (self.estate & ESTATE_BLOCK) return;
if ( !(other.flags & FL_CLIENT) ) return;
if ( other.health < 1 ) return;
if ( other.flags & FL_NOTARGET && map_notargetblock == 0) return;
if (self.attack_finished > time) return;
self.touch2(); // defined by item function
};
//----------------------------------------------------------------------
void() item_restore =
{
// Ammo boxes can have special animation frames or lids!
if (self.classgroup == CG_AMMOITEM) {
// Any LID (shells/spikes) defined?
if (self.spawnflags & A_LID && self.attachment) {
// Setup LID attachment entity (match angles/origin)
self.attachment.solid = SOLID_NOT;
self.attachment.movetype = self.movetype;
setmodel(self.attachment, self.headmdl);
// Give the lid the same bbox setup so it can move
setsize (self.attachment, self.mins, self.maxs);
// Start lid off the ground and remove ground flag
// This will let the lid naturally settle on the surface
setorigin(self.attachment, self.origin + '0 0 1');
self.attachment.flags = self.attachment.flags - (self.attachment.flags & FL_ONGROUND);
// Match angle and stored frame setup from ammo box
self.attachment.angles = self.angles;
// lid frame options -1/0=random, 1-7=exact
// Always generate a new lid position for respawning items
if (self.frame_box <= 0) self.attachment.frame = rint(1 + random()*6);
else if (self.frame_box > 7) self.frame_box = 1;
if (self.frame_box > 0) self.attachment.frame = self.frame_box;
// LID has different skins for shells and spikes
if (self.classtype == CT_AMMOSHELLS) self.attachment.skin = self.skin;
else self.attachment.skin = 2 + self.skin;
}
// Any special frames (rockets/plasma) defined?
else if (self.frame_override) {
// frame options -1=random 0=nothing, 1-7=exact
// Always generate a new frame number for respawning items
if (self.frame_box == -1) self.frame = rint(1 + random()*6);
else if (self.frame_box > 7) self.frame_box = 1;
if (self.frame_box > 0) self.frame = self.frame_box;
}
}
// Setup animated textures for old style ID health boxes
// Check floor under item for any changes
if (self.item_flrcheck > 0 || self.item_skinanim > 0) {
self.nextthink = time + random()*0.5;
self.think = item_thinkloop;
}
};
//----------------------------------------------------------------------
void() item_delay =
{
if (self.touchedvoid) {entity_hide(self); return;}
if (self.estate == ESTATE_DISABLE) return;
// Reset use function and any touch/skin triggers
self.estate_use = item_use;
self.touch = item_touch;
self.attack_finished = 0;
self.estate = ESTATE_ON;
// Setup enough parameters to test drop to floor
self.movetype = MOVETYPE_NONE;
self.solid = SOLID_TRIGGER;
setmodel(self,self.mdl);
setsize (self, self.bbmins, self.bbmaxs);
setorigin(self, self.oldorigin);
self.velocity = '0 0 0';
// Check if item is floating? = does not interact with world
if(self.spawnflags & ITEM_FLOATING) {
// Cannot check the floor of an item if its floating!?!
if (self.item_flrcheck > 0) self.item_flrcheck = 0;
}
else {
// Finalize item location (check drop to floor)
// Need this movetype for items to move with bmodels
self.movetype = MOVETYPE_TOSS;
self.velocity = '0 0 0';
self.origin_z = self.origin_z + 6;
// ID originally used a droptofloor test for space check
// Tried a pointcontents check but it can allows things
// to fall through the floor and just keep going
//if (pointcontents(self.origin) == CONTENT_SOLID) {
if (!droptofloor()) {
dprint ("\n\b[Item]\b "); dprint (self.classname);
dprint (" stuck at ("); dprint (vtos(self.origin)); dprint (")\n");
spawn_marker(self.origin, SPNMARK_YELLOW);
// The item is stuck, might still be useful to the player
// Originally the item was removed which is not super useful
// The mapper should see the console warning and yellow marker
// Changed to check for origin in solid instead
if (pointcontents(self.origin) == CONTENT_SOLID) {
remove(self); return;
}
}
}
// Toss velocity is designed for breakable objects to spawn items
// Will add forward/up velocity to an item so it does not get stuck
// Has to happen after the droptofloor otherwise position is wrong
if (self.item_tossvel > 0) {
// Make sure item can fly/move
self.movetype = MOVETYPE_TOSS;
self.velocity = '0 0 0';
// Must remove onground flag otherwise velocity does nothing
self.flags = self.flags - (self.flags & FL_ONGROUND);
// Push the item in the angle direction
makevectors(self.angles);
self.velocity = v_forward * self.item_tossvel;
// Push the item upward to make it travel
self.velocity_z = self.velocity_z + self.item_tossvel;
}
// If check floor under item enabled, workout distance check
// The bottom of the bounding box + 16 for large step
if (self.item_flrcheck > 0) {
self.item_flrcheck = fabs(self.mins_z) + 16;
}
// Spawn particle emitter if particles active and not blocked
if (query_configflag(SVR_PARTICLES) == SVR_PARTICLES) {
if (!(self.spawnflags & ITEM_NOEFFECTS) && self.part_active > 0) {
self.part_emitter = spawn_pemitter(self, self, self.part_active, PARTICLE_START_ON);
}
}
// Finally setup entity ready for use
self.oldorigin = self.origin;
// Remove the START OFF functionality
if (self.spawnflags & ENT_STARTOFF) {
self.spawnflags = self.spawnflags - ENT_STARTOFF;
// Check for respawn effect?
if (self.spawnflags & ITEM_RESPAWN) start_item_respawn();
else item_restore();
}
else item_restore();
};
//----------------------------------------------------------------------
void() item_on =
{
self.estate = ESTATE_ON;
self.movetype = MOVETYPE_NONE;
// Restore any effect flags settings (various dlight glows)
if (self.savedeffects > 0) self.effects = self.savedeffects;
// Check for delayed/trigger_once functionality?
if (self.spawnflags & ENT_STARTOFF || self.attack_finished > time)
self.solid = SOLID_NOT;
else {
// Restore movement, solid and model parameters
if(self.spawnflags & ITEM_FLOATING) self.movetype = MOVETYPE_NONE;
else self.movetype = MOVETYPE_TOSS;
self.solid = SOLID_TRIGGER;
setmodel(self,self.mdl);
setsize (self, self.bbmins, self.bbmaxs);
self.velocity = '0 0 0';
// Restore particle emitter
if (self.part_emitter) misc_particle_on(self.part_emitter);
// Setup touch/damage/bounding box functionality
self.think = SUB_Null;
item_restore();
}
};
//----------------------------------------------------------------------
void() item_off =
{
self.estate = ESTATE_OFF;
self.movetype = MOVETYPE_NONE;
self.solid = SOLID_NOT;
setmodel(self,"");
self.effects = 0;
setsize(self, VEC_ORIGIN, VEC_ORIGIN);
// If item was setup to float then it will be trigger item
// Don't reset origin as it might have fallen somewhere better
if( !(self.spawnflags & ITEM_FLOATING) ) setorigin(self, self.oldorigin);
if (self.attachment) {
setmodel(self.attachment,"");
setsize(self.attachment, VEC_ORIGIN, VEC_ORIGIN);
}
};
//----------------------------------------------------------------------
void() item_estate_setup =
{
// check for map hacks (redirects to item_delay)
if (self.use == SUB_regen) self.use = SUB_regen;
// Setup Entity State functionality
else if (self.targetname != "") self.use = entity_state_use;
self.estate_on = item_on;
self.estate_off = item_off;
self.estate_use = item_delay;
self.estate_reset = item_reset;
};
//----------------------------------------------------------------------
void() item_start =
{
self.oldorigin = self.origin; // Save origin
self.movetype = MOVETYPE_NONE; // Static item, no movement
self.flags = self.flags | FL_ITEM;
// Warning if effects flag is active before spawning
if (self.effects) {
dprint("\b[ITEM]\b Effects flag active\n");
self.savedeffects = self.effects;
}
// Reset effects flag because some engines will show effects
// This is especially obvious for delay spawned items
self.effects = 0;
// If respawn timer negative then wait for a trigger
if (self.respawn_time < 0) self.respawn_trig = TRUE;
// Respawn times < 1 break sound and particle spawners
if (self.respawn_time > 0 && self.respawn_time < 1) self.respawn_time = 1;
// Cannot start with a negative number for counting down
if (self.respawn_count < 0) self.respawn_count = 1;
// Override default item pickup sound with silence?
// It would have been good to offer the other sounds (1-6)
// on all items, but there is a good chance that a mapper
// has left a rogue sounds key on some item somewhere!
if (self.sounds == 4) self.noise = SOUND_EMPTY;
// Check if item is part of a progression spawner list
// Hide all progression items, only required for caching
if (self.progspawnlist) item_proglist_setup(self);
else {
// Check for spawning conditions (nightmare, coop)
if (check_nightmare() == TRUE) return;
if (check_coop() == TRUE) return;
// Setup Entity State functionality
item_estate_setup();
if (self.spawnflags & ENT_STARTOFF) self.estate_off();
else {
// delay drop to floor to make sure all doors have been spawned
// spread think times so they don't all happen at same time
self.nextthink = time + 0.1 + random()*0.5;
self.think = self.estate_use;
}
}
};
//======================================================================
// HEALTH FLASK/BOX
//======================================================================
float(entity hpplayer, entity hpitem) health_pickupcondition =
{
// Simple test first, player dead?
if (hpplayer.health <= 0) return TRUE;
// Mega Health pickups are awkward because the player can keep
// picking them up, unless they are at max HP already!
if (hpitem.classtype == CT_HEALMEGA) {
if (hpplayer.health >= hpplayer.mega_health) return TRUE;
}
// Regular Health pack can be wasteful with amount
else if (hpplayer.health >= hpplayer.max_health) return TRUE;
// Health Pack good to use!
return FALSE;
};
//----------------------------------------------------------------------
// targ - entity to receive healing
// t_healamount - the quanity to heal entity with
// ignore - whether to ignore max health amount
// returns FALSE if cannot heal entity by healamount
// returns TRUE if healamount applied
//
float (entity targ, float t_healamount, float ignore) T_Heal =
{
if (targ.health <= 0) return FALSE;
if ((!ignore) && (targ.health >= other.max_health)) return FALSE;
t_healamount = ceil(t_healamount);
targ.health = targ.health + t_healamount;
if ((!ignore) && (targ.health >= other.max_health))
targ.health = other.max_health;
if (targ.health > targ.mega_health) targ.health = targ.mega_health;
return TRUE;
};
//----------------------------------------------------------------------
void() health_touch =
{
local string s;
// Megahealth? Ignore max_health...
if (self.classtype == CT_HEALMEGA) {
if (other.health >= other.mega_health) return;
if (!T_Heal(other, self.healamount, 1)) return;
}
else {
if (!T_Heal(other, self.healamount, 0)) return;
}
// Check for randomizer megahealth
health_touchrandomizer();
// Healing the player negates some debuffs
ResetDebuffBurning(other);
ResetDebuffPoisoned(other);
sprint(other, "You receive ");
s = ftos(self.healamount);
sprint(other, s);
sprint(other, " health\n");
if (self.noise != SOUND_EMPTY)
sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
stuffcmd (other, "bf\n");
activator = other;
SUB_UseTargets();
// Megahealth = rot down the player's super health
// Moved functionality to debuff (rotting) system
// Rotting_Qty is set to zero (default) on item spawn
if (self.classtype == CT_HEALMEGA) RotDeBuff(other, self.rotting_qty);
// Quick exit, no need for following stuff
if (self.progspawnlist) return;
item_finished();
check_item_respawn();
};
//----------------------------------------------------------------------
/*QUAKED item_health (0.3 0.3 1) (-16 -16 0) (16 16 32) ROTTEN MEGA x x RESPAWN FLOAT STARTOFF NOEFFECTS NOT_EASY NOT_NORMAL NOT_HARD NOT_DM
{ model(":progs/health_25.mdl"); }
15, 25 or 100 Health
-------- KEYS --------
targetname : toggle state (use trigger ent for exact state)
angle : = -1 Random rotation everytime spawned (default)
skin_override : Override world type 1=Base Green, 2=Medieval Wood
healamount : Override heal quantity for pickup (def=15/25/100)
message : centerprint message when item is picked up
respawn_time : time to wait before respawning (1-x seconds, default varies)
respawn_count : Total amount of times to respawn (counts down to zero)
respawn_trig : = 1 Wait for trigger before respawning
-------- SPAWNFLAGS --------
ROTTEN : 15 health
MEGA : MegaHealth +100 health, rot down to 100
RESPAWN : Can respawn after being picked up
FLOAT : No drop to floor test
STARTOFF : Starts off and waits for trigger
NOEFFECTS : No particle or effects active
-------- NOTES --------
Health box gives 15, 25 or 100 points depending on spawnflags.
*/
//----------------------------------------------------------------------
void() item_health =
{
// Check for any random monster setups
if (health_checkrandomizer() == TRUE) return;
if (self.spawnflags & H_ROTTEN) {
// worldtype 0 = medieval, 1 = metal, 2 = base
if (item_skintype(self) == SKIN_MEDIEVAL) {
// New Medieval style red flask
self.mdl = "maps/b_bh10.bsp";
self.respawn_style = PARTICLE_BURST_RED + PARTICLE_BURST_RING;
}
else {
// Original ID pickup model
self.mdl = "maps/b_bh10.bsp";
self.respawn_style = PARTICLE_BURST_WHITE + PARTICLE_BURST_RING;
}
self.noise = SOUND_HEAL15;
if (self.healamount < 1) self.healamount = HEAL_ROT;
self.classtype = CT_HEALROT;
self.respawn_effect = TRUE;
self.respawn_ofs = '0 0 16';
}
else if (self.spawnflags & H_MEGA) {
if (item_skintype(self) == SKIN_MEDIEVAL) {
// New Medieval style red flask
self.mdl = "maps/b_bh100.bsp";
self.respawn_style = PARTICLE_BURST_RED + PARTICLE_BURST_RING;
}
else {
// Original ID pickup model
self.mdl = "maps/b_bh100.bsp";
self.respawn_style = PARTICLE_BURST_WHITE + PARTICLE_BURST_RING;
self.item_skinanim = TRUE;
}
self.noise = SOUND_HEAL100;
if (self.healamount < 1) self.healamount = HEAL_MEGA;
self.classtype = CT_HEALMEGA;
self.part_active = PARTICLE_STYLE_MEGAH;
self.respawn_effect = TRUE;
self.respawn_ofs = '0 0 28';
// Use default rotting value
self.rotting_qty = 0;
}
else {
if (item_skintype(self) == SKIN_MEDIEVAL) {
// New Medieval style red flask
self.mdl = "maps/b_bh25.bsp";
self.respawn_style = PARTICLE_BURST_RED + PARTICLE_BURST_RING;
self.respawn_ofs = '0 0 24';
}
else {
// Original ID pickup model
self.mdl = "maps/b_bh25.bsp";
self.respawn_style = PARTICLE_BURST_WHITE + PARTICLE_BURST_RING;
self.respawn_ofs = '0 0 16';
self.item_skinanim = TRUE;
}
self.noise = SOUND_HEAL25;
if (self.healamount < 1) self.healamount = HEAL_NORM;
self.classtype = CT_HEALNORM;
self.respawn_effect = TRUE;
}
precache_model(self.mdl);
precache_sound(self.noise);
// Query console variable 'temp1' for model upgrade option.
// Cannot use global vars because they don't exist at this point
// Move the new centered ammo models to match old ammo origin
// The default is to move all ammo items to suit original id maps
//if (query_configflag(SVR_ITEMOFFSET) == FALSE) {
// self.oldorigin = self.origin + '16 16 0';
// setorigin(self, self.oldorigin);
//}
// An old worldspawn key (not used anymore)
// This is backward compatibility with this key
// Will force all items to have an angle
if (world.no_item_rotate && self.angles_y == 0) self.angles_y = 360;
// Setting the angle key in the editor to UP/DOWN/0 = random rotation
if (self.angles_y <= 0) self.angles_y = rint(random()*359);
self.touch2 = health_touch;
self.classgroup = CG_HEALTH;
self.bbmins = VEC_HEAL_MIN;
self.bbmaxs = VEC_HEAL_MAX;
if (self.respawn_time == 0) self.respawn_time = RESPAWN_HEALTH;
// Check for coop errors
item_coopcheck();
item_start ();
};
//----------------------------------------------------------------------
/*QUAKED item_healthvial (0.3 0.3 1) (-8 -8 0) (8 8 32) x x x x RESPAWN FLOAT STARTOFF NOEFFECTS NOT_EASY NOT_NORMAL NOT_HARD NOT_DM
{ model(":progs/health_5.mdl"); }
Health item giving 2-5 points
-------- KEYS --------
targetname : toggle state (use trigger ent for exact state)
angle : = -1 Random rotation everytime spawned (default)
healamount : Override heal quantity for pickup (def=2+random*3)
message : centerprint message when item is picked up
respawn_time : time to wait before respawning (1-x seconds, default varies)
respawn_count : Total amount of times to respawn (counts down to zero)
respawn_trig : = 1 Wait for trigger before respawning
-------- SPAWNFLAGS --------
RESPAWN : Can respawn after being picked up
FLOAT : No drop to floor test
STARTOFF : Starts off and waits for trigger
NOEFFECTS : No particle or effects active
-------- NOTES --------
Health item giving 5 points
*/
//----------------------------------------------------------------------
void() item_healthvial =
{
self.classtype = CT_HEALVIAL;
self.respawn_effect = TRUE;
self.respawn_ofs = '0 0 20';
self.mdl = MODEL_HEAL5;
//if (self.healamount < 1) self.healamount = HEAL_GEM;
if (self.healamount < 1) self.healamount = rint(2 + (random() * 3));
self.noise = SOUND_HEAL05;
precache_model(self.mdl);
precache_sound(self.noise);
self.respawn_style = PARTICLE_BURST_RED + PARTICLE_BURST_CENTER;
self.touch2 = health_touch;
self.classgroup = CG_HEALTH;
self.bbmins = '-8 -8 0';
self.bbmaxs = '8 8 32';
if (self.respawn_time == 0) self.respawn_time = RESPAWN_HEALTH;
// Check for coop errors
item_coopcheck();
item_start ();
};
// Used to be called a gem, renamed to vial
void() item_healthgem = { item_healthvial(); }
//======================================================================
// armor_touch
//======================================================================
float(entity armplayer, entity armitem) armor_pickupcondition =
{
local float arm1, arm2;
arm1 = armplayer.armortype * armplayer.armorvalue;
arm2 = armitem.armortype * armitem.armorvalue;
if (arm1 >= arm2) return TRUE;
else return FALSE;
};
//----------------------------------------------------------------------
void() armor_touch =
{
// Cannot pickup armour if wearing something better!
if (armor_pickupcondition(other, self)) return;
// Check for randomizer pickup conditions
armour_touchrandomizer();
other.armortype = self.armortype;
other.armorvalue = self.armorvalue;
other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + self.items;
sprint (other, "You got the ");
sprint (other, self.netname);
sprint (other, "\n");
if (self.noise != SOUND_EMPTY)
sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
stuffcmd (other, "bf\n");
activator = other;
SUB_UseTargets();
// Quick exit, no need for following stuff
if (self.progspawnlist) return;
item_finished();
check_item_respawn();
};
//----------------------------------------------------------------------
void() item_armor_setup =
{
self.classgroup = CG_ARMOR;
self.part_active = PARTICLE_STYLE_ARMOR;
self.touch2 = armor_touch;
self.bbmins = '-16 -16 0';
self.bbmaxs = '16 16 56';
if (self.respawn_time == 0) self.respawn_time = RESPAWN_ARMOR;
self.noise = "items/armor1.wav";
// Check for coop errors
item_coopcheck();
item_start ();
};
//======================================================================
/*QUAKED item_armor1 (0 0.5 0.8) (-16 -16 0) (16 16 56) x x x x RESPAWN FLOAT STARTOFF NOEFFECTS NOT_EASY NOT_NORMAL NOT_HARD NOT_DM
{ model(":progs/armour.mdl"); }
Green Armour with 100 points of protection
-------- KEYS --------
targetname : toggle state (use trigger ent for exact state)
message : centerprint message when item is picked up
armortype : Override Percentage armor reduction (GRN=0.3,YEL=0.6,RED=0.8)
armorvalue : Override Quantity armor to pickup (GRN=100,YEL=150,RED=200)
respawn_time : time to wait before respawning (1-x seconds, default varies)
respawn_count : Total amount of times to respawn (counts down to zero)
respawn_trig : = 1 Wait for trigger before respawning
-------- SPAWNFLAGS --------
RESPAWN : Can respawn after being picked up
FLOAT : No drop to floor test
STARTOFF : Starts off and waits for trigger
NOEFFECTS : No particle or effects active
-------- NOTES --------
Green Armour with 100 points of protection
======================================================================*/
void() item_armor1 =
{
// Check for any random setups
if (armour_checkrandomizer() == TRUE) return;
// Check for custom model setup?
item_debugcustomdl();
// Setup default model
if (self.mdl == "") { self.mdl = "progs/armor.mdl"; self.skin = 0; }
precache_model (self.mdl);
self.classtype = CT_ARMOR1;
self.items = IT_ARMOR1;
if (self.netname == "") self.netname = "Green Armour";
if (self.armortype <= 0) self.armortype = ARMOR_GRN_TYPE;
if (self.armorvalue <= 0) self.armorvalue = ARMOR_GRN_VALUE;
self.respawn_effect = TRUE;
self.respawn_style = PARTICLE_BURST_GREEN + PARTICLE_BURST_RING;
self.respawn_ofs = '0 0 24';
item_armor_setup();
};
//======================================================================
/*QUAKED item_armor2 (0 0.5 0.8) (-16 -16 0) (16 16 56) x BLUESKIN x x RESPAWN FLOAT STARTOFF NOEFFECTS NOT_EASY NOT_NORMAL NOT_HARD NOT_DM
{ model(":progs/armour.mdl"); }
Yellow Armour with 150 points of protection
-------- KEYS --------
targetname : toggle state (use trigger ent for exact state)
message : centerprint message when item is picked up
armortype : Override Percentage armor reduction (GRN=0.3,YEL=0.6,RED=0.8)
armorvalue : Override Quantity armor to pickup (GRN=100,YEL=150,RED=200)
respawn_time : time to wait before respawning (1-x seconds, default varies)
respawn_count : Total amount of times to respawn (counts down to zero)
respawn_trig : = 1 Wait for trigger before respawning
-------- SPAWNFLAGS --------
BLUESKIN : Display a blue skin instead
RESPAWN : Can respawn after being picked up
FLOAT : No drop to floor test
STARTOFF : Starts off and waits for trigger
NOEFFECTS : No particle or effects active
-------- NOTES --------
Yellow Armour with 150 points of protection
======================================================================*/
void() item_armor2 =
{
// Check for any random setups
if (armour_checkrandomizer() == TRUE) return;
// Check for custom model setup?
item_debugcustomdl();
// Setup default model
if (self.mdl == "") self.mdl = "progs/armor.mdl";
precache_model (self.mdl);
self.classtype = CT_ARMOR2;
self.items = IT_ARMOR2;
if (self.armortype <= 0) self.armortype = ARMOR_YEL_TYPE;
if (self.armorvalue <= 0) self.armorvalue = ARMOR_YEL_VALUE;
self.respawn_effect = TRUE;
self.respawn_ofs = '0 0 24';
// Setup alternative colour
if (self.spawnflags & ARMOR_BLUE) {
if (self.netname == "") self.netname = "Blue Armour";
self.respawn_style = PARTICLE_BURST_BLUE + PARTICLE_BURST_RING;
self.skin = 3;
}
else {
if (self.netname == "") self.netname = "Yellow Armour";