forked from itslunaranyo/copper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
item_weap_ammo.qc
595 lines (521 loc) · 13.6 KB
/
item_weap_ammo.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
/*
===============================================================================
WEAPONS
===============================================================================
*/
float ITEM_AMMO_BIG = 1;
void(entity e) bound_ammo =
{
e.ammo_shells = min(e.ammo_shells, MAX_AMMO_SHELLS);
e.ammo_nails = min(e.ammo_nails, MAX_AMMO_NAILS);
e.ammo_rockets = min(e.ammo_rockets, MAX_AMMO_ROCKETS);
e.ammo_cells = min(e.ammo_cells, MAX_AMMO_CELLS);
}
/*
=============
weapon_touch_coop
=============
*/
void() weapon_touch_coop =
{
if (!coop) return;
activator = other;
SUB_UseTargets();
self.killtarget = string_null;
self.target = string_null;
self.target2 = string_null;
self.target3 = string_null;
self.target4 = string_null;
}
void(entity to) weapon_give =
{
to.items |= self.items;
to.ammo_shells += self.ammo_shells;
to.ammo_nails += self.ammo_nails;
to.ammo_rockets += self.ammo_rockets;
to.ammo_cells += self.ammo_cells;
bound_ammo(to);
sprint (to, "You got the ");
sprint (to, self.netname);
sprint (to, "\n");
sound (to, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
stuffcmd (to, "bf\n");
}
/*
=============
weapon_touch
=============
*/
void() weapon_touch =
{
float leave, nsw;
if (!CheckValidTouch()) return;
if (deathmatch == 2 || deathmatch == 3 || coop > 1)
leave = 1;
else
leave = 0;
if (leave)
{
if (other.items & self.items == self.items) // already have it
{
weapon_touch_coop();
return;
}
}
if (self.items & other.items) nsw = TRUE;
weapon_give(other);
// change to the weapon
if (nsw)
SUB_CallAsSelf(W_ResetWeaponState, other);
else
W_BetterWeapon(other, self.items);
if (coop == 1)
{
entity pl = get_next_client(other);
while (pl != other)
{
weapon_give(pl);
pl = get_next_client(pl);
}
}
if (leave)
{
weapon_touch_coop();
return;
}
ItemTouched();
}
/*
============
StartWeapon
============
*/
void() StartWeapon =
{
self.type = "weapon";
self.touch = weapon_touch;
setsize (self, '-16 -16 0', '16 16 56');
if (deathmatch == 1)
self.wait = 30;
StartItem ();
}
// ===============================================================================
/*FGD
@baseclass size(-16 -16 0, 16 16 56) color(0 0 200) base(Item) = Weapon []
*/
/*QUAKED weapon_shotgun (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
Shotgun.
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_shotgn.mdl" }) = weapon_shotgun : "Shotgun.
5 Shells." []
*/
void() weapon_shotgun =
{
if (!SUB_ShouldSpawn()) return;
precache_model3 ("progs/g_shotgn.mdl");
setmodel (self, "progs/g_shotgn.mdl");
self.items = IT_SHOTGUN;
self.ammo_shells = 5;
self.netname = "Shotgun";
StartWeapon();
}
/*QUAKED weapon_supershotgun (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
Double-barreled shotgun.
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_shot.mdl" }) = weapon_supershotgun : "Double-barreled shotgun.
10 shells." []
*/
void() weapon_supershotgun =
{
if (!SUB_ShouldSpawn()) return;
precache_model_safe ("progs/g_shot.mdl");
setmodel (self, "progs/g_shot.mdl");
self.items = IT_SUPER_SHOTGUN;
self.ammo_shells = 10;
self.netname = "Double-barreled Shotgun";
StartWeapon();
}
/*QUAKED weapon_nailgun (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
Nailgun.
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_nail.mdl" }) = weapon_nailgun : "Nailgun.
30 nails." []
*/
void() weapon_nailgun =
{
if (!SUB_ShouldSpawn()) return;
precache_model_safe ("progs/g_nail.mdl");
setmodel (self, "progs/g_nail.mdl");
self.items = IT_NAILGUN;
self.ammo_nails = 30;
self.netname = "Nailgun";
StartWeapon();
}
/*QUAKED weapon_supernailgun (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
Perforator (Super Nailgun).
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_nail2.mdl" }) = weapon_supernailgun : "Perforator (Super Nailgun).
30 nails." []
*/
void() weapon_supernailgun =
{
if (!SUB_ShouldSpawn()) return;
precache_model_safe ("progs/g_nail2.mdl");
setmodel (self, "progs/g_nail2.mdl");
self.items = IT_SUPER_NAILGUN;
self.ammo_nails = 30;
self.netname = "Perforator";
StartWeapon();
}
/*QUAKED weapon_grenadelauncher (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
Grenade Launcher.
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_rock.mdl" }) = weapon_grenadelauncher : "Grenade launcher.
5 rockets." []
*/
void() weapon_grenadelauncher =
{
if (!SUB_ShouldSpawn()) return;
precache_model_safe ("progs/g_rock.mdl");
setmodel (self, "progs/g_rock.mdl");
self.items = IT_GRENADE_LAUNCHER;
self.ammo_rockets = 5;
self.netname = "Grenade Launcher";
StartWeapon();
}
/*QUAKED weapon_rocketlauncher (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
Rocket Launcher.
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_rock2.mdl" }) = weapon_rocketlauncher : "Rocket launcher.
5 rockets." []
*/
void() weapon_rocketlauncher =
{
if (!SUB_ShouldSpawn()) return;
precache_model_safe ("progs/g_rock2.mdl");
setmodel (self, "progs/g_rock2.mdl");
self.items = IT_ROCKET_LAUNCHER;
self.ammo_rockets = 5;
self.netname = "Rocket Launcher";
StartWeapon();
}
/*QUAKED weapon_lightning (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
Thunderbolt Cannon.
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_light.mdl" }) = weapon_lightning : "Thunderbolt.
12 cells." []
*/
void() weapon_lightning =
{
if (!SUB_ShouldSpawn()) return;
precache_model_safe ("progs/g_light.mdl");
setmodel (self, "progs/g_light.mdl");
self.items = IT_LIGHTNING;
self.ammo_cells = 12;
self.netname = "Thunderbolt";
StartWeapon();
}
/*QUAKED weapon_axe (0 0 1) (-16 -16 0) (16 16 56) ? ? SUSPENDED
The axe, should you happen to make the player start without one.
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Weapon) model({ "path": ":progs/g_axe.mdl" }) = weapon_axe : "Axe." []
*/
void() weapon_axe =
{
if (!SUB_ShouldSpawn()) return;
precache_model_safe ("progs/g_axe.mdl");
setmodel (self, "progs/g_axe.mdl");
self.items = IT_AXE;
self.netname = "Axe. Find some wood!";
StartWeapon();
}
// ===============================================================================
/*
============
ammo_touch
============
*/
void() ammo_touch =
{
if (!CheckValidTouch()) return;
// structured in dual if's instead of using && to preserve ammo_touch maphacks
if (self.ammo_shells)
{
if (other.ammo_shells < MAX_AMMO_SHELLS)
other.ammo_shells += self.ammo_shells;
else return;
}
else if (self.ammo_nails)
{
if (other.ammo_nails < MAX_AMMO_NAILS)
other.ammo_nails += self.ammo_nails;
else return;
}
else if (self.ammo_rockets)
{
if (other.ammo_rockets < MAX_AMMO_ROCKETS)
other.ammo_rockets += self.ammo_rockets;
else return;
}
else if (self.ammo_cells)
{
if (other.ammo_cells < MAX_AMMO_CELLS)
other.ammo_cells += self.ammo_cells;
else return;
}
//else return;
bound_ammo(other);
sprint (other, "You got the ");
sprint (other, self.netname);
sprint (other, "\n");
sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
stuffcmd (other, "bf\n");
if (!self.weapon)
SUB_CallAsSelf(W_SelectBestWeapon, other);
else
// if changed current ammo, update it
SUB_CallAsSelf(W_SetCurrentAmmo, other);
ItemTouched();
}
/*
============
StartAmmo
============
*/
void() StartAmmo =
{
self.type = "ammo";
setsize (self, '0 0 0', '32 32 56');
self.touch = ammo_touch;
if (deathmatch == 1)
self.wait = 30;
if (deathmatch == 3)
self.wait = 15;
StartItem ();
//ItemRotateAndSize('32 32 56');
}
/*FGD
@baseclass size(0 0 0, 32 32 32) color(0 160 160) base(Item) = Ammo [ spawnflags(flags) = [ 1 : "Large box (2x)" : 0 ] ]
*/
/*QUAKED item_shells (0 .5 .5) (0 0 0) (32 32 32) BIG ? SUSPENDED
20 shells for both Shotgun and SuperShotgun.
Flags:
"big" gives 40 instead of 20
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Ammo)
model(
{{
spawnflags & 1 -> ":maps/b_shell1.bsp",
":maps/b_shell0.bsp"
}}
) = item_shells : "Shells, 20/40" []
*/
void() item_shells =
{
if (!SUB_ShouldSpawn()) return;
if (self.spawnflags & ITEM_AMMO_BIG)
{
self.ammo_shells = 40;
precache_model_safe ("progs/m_shell2.mdl");
setmodel (self, "progs/m_shell2.mdl");
}
else
{
self.ammo_shells = 20;
precache_model_safe ("progs/m_shell1.mdl");
setmodel (self, "progs/m_shell1.mdl");
}
self.weapon = 1;
self.netname = "shells";
StartAmmo();
}
/*QUAKED item_spikes (0 .5 .5) (0 0 0) (32 32 32) BIG ? SUSPENDED
25 ammo points (spikes) for Perforator and Super Perforator.
Flags:
"big" gives 50 instead of 25
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Ammo)
model(
{{
spawnflags & 1 -> ":maps/b_nail1.bsp",
":maps/b_nail0.bsp"
}}
) = item_spikes : "Nailgun/Perforator ammo, 25/50" []
*/
void() item_spikes =
{
if (!SUB_ShouldSpawn()) return;
if (self.spawnflags & ITEM_AMMO_BIG)
{
self.ammo_nails = 50;
precache_model_safe ("progs/m_nails2.mdl");
setmodel (self, "progs/m_nails2.mdl");
}
else
{
self.ammo_nails = 25;
precache_model_safe ("progs/m_nails1.mdl");
setmodel (self, "progs/m_nails1.mdl");
}
self.weapon = 2;
self.netname = "nails";
StartAmmo();
}
/*QUAKED item_rockets (0 .5 .5) (0 0 0) (32 32 32) BIG ? SUSPENDED
3 ammo points (rockets) for the Rocket/Grenade Launcher.
Flags:
"big" gives 6 instead of 3
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Ammo)
model(
{{
spawnflags & 1 -> ":maps/b_rock1.bsp",
":maps/b_rock0.bsp"
}}
) =
item_rockets : "Rockets, 4/8" []
*/
void() item_rockets =
{
if (!SUB_ShouldSpawn()) return;
if (self.spawnflags & ITEM_AMMO_BIG)
{
self.ammo_rockets = 8;
precache_model_safe ("progs/m_rock2.mdl");
setmodel (self, "progs/m_rock2.mdl");
}
else
{
self.ammo_rockets = 4;
precache_model_safe ("progs/m_rock1.mdl");
setmodel (self, "progs/m_rock1.mdl");
}
self.weapon = 3;
self.netname = "rockets";
StartAmmo();
}
/*QUAKED item_cells (0 .5 .5) (0 0 0) (32 32 32) BIG ? SUSPENDED
6 ammo points (cells) for the Thunderbolt (Lightning).
Flags:
"big" gives 12 instead of 6
Keys:
"target/2/3/4/k" - entity to trigger when picked up
"targetname" - will not spawn until triggered
"wait" - will respawn after 'wait' seconds. fires targets every time.
"count" - limit number of times to respawn
*/
/*FGD
@PointClass base(Ammo)
model(
{{
spawnflags & 1 -> ":maps/b_batt1.bsp",
":maps/b_batt0.bsp"
}}
) =
item_cells : "Thunderbolt Ammo, 6/12 cells" []
*/
void() item_cells =
{
if (!SUB_ShouldSpawn()) return;
if (self.spawnflags & ITEM_AMMO_BIG)
{
self.ammo_cells = 12;
precache_model_safe ("progs/m_cells2.mdl");
setmodel (self, "progs/m_cells2.mdl");
}
else
{
self.ammo_cells = 6;
precache_model_safe ("progs/m_cells1.mdl");
setmodel (self, "progs/m_cells1.mdl");
}
self.weapon = 4;
self.netname = "cells";
StartAmmo();
}
// ================================
// still used in a few id maps, bleh
void() item_weapon =
{
float WEAPON_SHOTGUN = 1;
float WEAPON_ROCKET = 2;
float WEAPON_SPIKES = 4;
float WEAPON_BIG = 8;
float oldflags;
oldflags = self.spawnflags & 15;
self.spawnflags = not(self.spawnflags, 15);
if (oldflags & WEAPON_BIG)
self.spawnflags = self.spawnflags | ITEM_AMMO_BIG;
if (oldflags & WEAPON_SHOTGUN)
item_shells();
else if (oldflags & WEAPON_SPIKES)
item_spikes();
else if (oldflags & WEAPON_ROCKET)
item_rockets();
};