-
Notifications
You must be signed in to change notification settings - Fork 21
/
zp_addon_presents.sp
719 lines (637 loc) · 31.1 KB
/
zp_addon_presents.sp
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
/**
* ============================================================================
*
* Zombie Plague
*
*
* Copyright (C) 2015-2023 qubka (Nikita Ushakov)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ============================================================================
**/
#include <sourcemod>
#include <sdktools>
#include <zombieplague>
#pragma newdecls required
#pragma semicolon 1
/**
* @brief Record plugin info.
**/
public Plugin myinfo =
{
name = "[ZP] Addon: Presents",
author = "qubka (Nikita Ushakov), Pelipoika",
description = "Spawns presents on the map that give some bonuses",
version = "2.0",
url = "https://forums.alliedmods.net/showthread.php?t=290657"
}
/**
* @section Types of drop.
**/
enum
{
SAFE,
EXPL,
HEAVY,
LIGHT,
PISTOL,
HPIST,
TOOLS,
HTOOL
};
/**
* @endsection
**/
// Timer index
Handle hPresentSpawn = null; ArrayList hPosition; bool bLoad; int gCaseCount;
// Type index
int gType;
// Sound index
int gSound;
// Cvars
ConVar hCvarPresentGlow;
ConVar hCvarPresentMax;
ConVar hCvarPresentHealth;
ConVar hCvarPresentDelay;
/**
* @brief Called when the plugin is fully initialized and all known external references are resolved.
* This is only called once in the lifetime of the plugin, and is paired with OnPluginEnd().
**/
public void OnPluginStart()
{
hCvarPresentGlow = CreateConVar("zp_presents_glow", "0", "Enable glow effect", 0, true, 0.0, true, 1.0);
hCvarPresentMax = CreateConVar("zp_presents_max", "6", "Maximum amount of presents on map", 0, true, 1.0);
hCvarPresentHealth = CreateConVar("zp_presents_health", "0", "Health of present. If disabled will be pickup on touch", 0, true, 0.0);
hCvarPresentDelay = CreateConVar("zp_presents_delay", "60.0", "Delay between presents spawn", 0, true, 0.0);
AutoExecConfig(true, "zp_addon_presents", "sourcemod/zombieplague");
}
/**
* @brief Called after a library is added that the current plugin references optionally.
* A library is either a plugin name or extension name, as exposed via its include file.
**/
public void OnLibraryAdded(const char[] sLibrary)
{
if (!strcmp(sLibrary, "zombieplague", false))
{
hPosition = new ArrayList(3);
LoadTranslations("presents.phrases");
HookEvent("round_prestart", RoundStateHook, EventHookMode_Pre);
HookEvent("round_end", RoundStateHook, EventHookMode_Pre);
if (ZP_IsMapLoaded())
{
ZP_OnEngineExecute();
}
}
}
/**
* @brief Called after a zombie core is loaded.
**/
public void ZP_OnEngineExecute()
{
gSound = ZP_GetSoundKeyID("present_sounds");
if (gSound == -1) SetFailState("[ZP] Custom sound key ID from name : \"present_sounds\" wasn't find");
gType = ZP_GetClassTypeID("human");
if (gType == -1) SetFailState("[ZP] Custom class type ID from name : \"human\" wasn't find");
}
/**
* @brief The map is loading.
**/
public void OnMapStart()
{
GameData hConfig = LoadGameConfigFile("plugin.presents");
if (!hConfig)
{
SetFailState("Failed to load presents gamedata.");
return;
}
Address TheNavAreas = hConfig.GetAddress("TheNavAreas");
if (TheNavAreas == Address_Null) SetFailState("Failed to get address: \"TheNavAreas\". Update address in \"plugin.presents\"");
int TheNavAreas_Count = view_as<int>(hConfig.GetAddress("TheNavAreas::Count"));
if (TheNavAreas_Count <= 0)
{
PrintToServer("[ZP] Addon: Presents = unloaded on the current map. Generate \"nav_mesh\" to make it work!");
bLoad = false;
delete hConfig;
return;
}
delete hConfig;
hPosition.Clear();
for (int i = 0; i < TheNavAreas_Count; ++i)
{
Address pNavArea = view_as<Address>(LoadFromAddress(TheNavAreas + view_as<Address>(i * 4), NumberType_Int32));
if (pNavArea != Address_Null)
{
static float nwCorner[3]; static float seCorner[3]; static float vCenter[3];
nwCorner[0] = view_as<float>(LoadFromAddress(pNavArea + view_as<Address>(4), NumberType_Int32));
nwCorner[1] = view_as<float>(LoadFromAddress(pNavArea + view_as<Address>(8), NumberType_Int32));
nwCorner[2] = view_as<float>(LoadFromAddress(pNavArea + view_as<Address>(12), NumberType_Int32));
seCorner[0] = view_as<float>(LoadFromAddress(pNavArea + view_as<Address>(16), NumberType_Int32));
seCorner[1] = view_as<float>(LoadFromAddress(pNavArea + view_as<Address>(20), NumberType_Int32));
seCorner[2] = view_as<float>(LoadFromAddress(pNavArea + view_as<Address>(24), NumberType_Int32));
if ((seCorner[0] - nwCorner[0]) <= 50.0 || (seCorner[1] - nwCorner[1]) <= 50.0)
{
continue;
}
AddVectors(nwCorner, seCorner, vCenter);
ScaleVector(vCenter, 0.5);
hPosition.PushArray(vCenter, sizeof(vCenter));
}
}
int iSize = hPosition.Length;
if (!iSize)
{
bLoad = false;
return;
}
bLoad = true;
PrecacheSound("survival/container_death_01.wav", true);
PrecacheSound("survival/container_death_02.wav", true);
PrecacheSound("survival/container_death_03.wav", true);
PrecacheSound("survival/container_damage_01.wav", true);
PrecacheSound("survival/container_damage_02.wav", true);
PrecacheSound("survival/container_damage_03.wav", true);
PrecacheSound("survival/container_damage_04.wav", true);
PrecacheSound("survival/container_damage_05.wav", true);
PrecacheModel("models/props_survival/cases/case_explosive.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib001.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib002.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib003.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib004.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib005.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib006.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib007.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib008.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib009.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib010.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib011.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib012.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib013.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib014.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib015.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib016.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib017.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib018.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib019.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib020.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib021.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib022.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib023.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib024.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib025.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib026.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib027.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib028.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib029.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib030.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib031.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib032.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib033.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib034.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib035.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib036.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib037.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib038.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib039.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib040.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib041.mdl", true);
PrecacheModel("models/props_survival/cases/case_heavy_weapon_gib042.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib001.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib002.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib003.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib004.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib005.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib006.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib007.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib008.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib009.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib010.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib011.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib012.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib013.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib014.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib015.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib016.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib017.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib018.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib019.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib020.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib021.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib022.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib023.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib024.mdl", true);
PrecacheModel("models/props_survival/cases/case_explosive_gib025.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib001.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib002.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib003.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib004.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib005.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib006.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib007.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib008.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib009.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib010.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib011.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib012.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib013.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib014.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib015.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib016.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib017.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib018.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib019.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib020.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib021.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib022.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib023.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib024.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_gib025.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib001.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib002.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib003.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib004.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib005.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib006.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib007.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib008.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib009.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib010.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib011.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib012.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib013.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib014.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib015.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib016.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib017.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib018.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib019.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib020.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib021.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib022.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib023.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib024.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib025.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib026.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib027.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib028.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib029.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib030.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib031.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib032.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib033.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib034.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib035.mdl", true);
PrecacheModel("models/props_survival/cases/case_tools_heavy_gib036.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib001.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib002.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib003.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib004.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib005.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib006.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib007.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib008.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib009.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib010.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib011.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib012.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib013.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib014.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib015.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib016.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib017.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib018.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib019.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib020.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib021.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib022.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib023.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib024.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib025.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib026.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib027.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib028.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib029.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib030.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib031.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib032.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib033.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib034.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib035.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_heavy_gib036.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib001.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib002.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib003.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib004.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib005.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib006.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib007.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib008.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib009.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib010.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib011.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib012.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib013.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib014.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib015.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib016.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib017.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib018.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib019.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib020.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib021.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib022.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib023.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib024.mdl", true);
PrecacheModel("models/props_survival/cases/case_pistol_gib025.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib001.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib002.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib003.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib004.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib005.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib006.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib007.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib008.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib009.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib010.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib011.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib012.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib013.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib014.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib015.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib016.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib017.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib018.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib019.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib020.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib021.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib022.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib023.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib024.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib025.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib026.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib027.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib028.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib029.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib030.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib031.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib032.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib033.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib034.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib035.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib036.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib037.mdl", true);
PrecacheModel("models/props_survival/cases/case_light_weapon_gib038.mdl", true);
}
/**
* @brief The map is ending.
**/
public void OnMapEnd()
{
hPresentSpawn = null; /// with flag TIMER_FLAG_NO_MAPCHANGE
}
/**
* @brief Called after a zombie round is started.
*
* @param mode The mode index.
**/
public void ZP_OnGameModeStart(int mode)
{
if (!bLoad)
{
return;
}
if (ZP_GetGameModeTypeHuman(mode) == gType)
{
delete hPresentSpawn;
hPresentSpawn = CreateTimer(hCvarPresentDelay.FloatValue, CaseSpawnHook, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
}
/**
* Event callback (round_prestart, round_end)
* @brief The round is starting/ending.
*
* @param gEventHook The event handle.
* @param gEventName The name of the event.
* @param dontBroadcast If true, event is broadcasted to all clients, false if not.
**/
public Action RoundStateHook(Event hEvent, char[] sName, bool dontBroadcast)
{
gCaseCount = 0;
delete hPresentSpawn;
return Plugin_Continue;
}
/**
* @brief Timer for spawing presents.
*
* @param hTimer The timer handle.
**/
public Action CaseSpawnHook(Handle hTimer)
{
int iAmount = hCvarPresentMax.IntValue - gCaseCount;
if (!iAmount)
{
return Plugin_Continue;
}
for (int i = 0; i < iAmount; i++)
{
static float vPosition[3];
if (!FindRandomPosition(vPosition))
{
iAmount++;
continue;
}
static char sModel[PLATFORM_LINE_LENGTH]; int iType = GetRandomInt(EXPL, HTOOL);
static int vColor[4];
switch (iType)
{
case EXPL :
{
strcopy(sModel, sizeof(sModel), "models/props_survival/cases/case_explosive.mdl");
vColor = {255, 127, 80, 255};
}
case HEAVY :
{
strcopy(sModel, sizeof(sModel), "models/props_survival/cases/case_heavy_weapon.mdl");
vColor = {220, 20, 60, 255};
}
case LIGHT :
{
strcopy(sModel, sizeof(sModel), "models/props_survival/cases/case_light_weapon.mdl");
vColor = {255, 0, 0, 255};
}
case PISTOL :
{
strcopy(sModel, sizeof(sModel), "models/props_survival/cases/case_pistol.mdl");
vColor = {240, 128, 128, 255};
}
case HPIST :
{
strcopy(sModel, sizeof(sModel), "models/props_survival/cases/case_pistol_heavy.mdl");
vColor = {219, 112, 147, 255};
}
case TOOLS :
{
strcopy(sModel, sizeof(sModel), "models/props_survival/cases/case_tools.mdl");
vColor = {0, 0, 205, 255};
}
case HTOOL :
{
strcopy(sModel, sizeof(sModel), "models/props_survival/cases/case_tools_heavy.mdl");
vColor = {95, 158, 160, 255};
}
}
int iHealth = hCvarPresentHealth.IntValue;
int iFlags = PHYS_FORCESERVERSIDE | PHYS_NOTAFFECTBYROTOR;
if (iHealth <= 0)
{
iFlags |= PHYS_MOTIONDISABLED;
}
int drop = UTIL_CreatePhysics("present", vPosition, NULL_VECTOR, sModel, iFlags);
if (drop != -1)
{
// TODO: Spawn using case type
///SetEntProp(drop, Prop_Data, "m_iHammerID", iType);
if (iHealth > 0)
{
SetEntProp(drop, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_WEAPON);
SetEntProp(drop, Prop_Data, "m_nSolidType", SOLID_VPHYSICS);
SetEntPropFloat(drop, Prop_Data, "m_flElasticity", 0.01);
SetEntProp(drop, Prop_Data, "m_takedamage", DAMAGE_YES);
SetEntProp(drop, Prop_Data, "m_iHealth", iHealth);
SetEntProp(drop, Prop_Data, "m_iMaxHealth", iHealth);
SDKHook(drop, SDKHook_OnTakeDamage, CaseDamageHook);
}
else
{
SetEntProp(drop, Prop_Data, "m_CollisionGroup", COLLISION_GROUP_PLAYER);
SetEntProp(drop, Prop_Data, "m_usSolidFlags", FSOLID_NOT_SOLID|FSOLID_TRIGGER); /// Make trigger
SetEntProp(drop, Prop_Data, "m_nSolidType", SOLID_VPHYSICS);
SetEntProp(drop, Prop_Data, "m_takedamage", DAMAGE_NO);
SDKHook(drop, SDKHook_Touch, CaseTouchHook);
}
if (hCvarPresentGlow.BoolValue)
{
int glow = UTIL_CreateGlowing("glow", vPosition, NULL_VECTOR, sModel, "ref", _, _, vColor);
if (glow != -1)
{
SetVariantString("!activator");
AcceptEntityInput(glow, "SetParent", drop, glow);
}
}
}
gCaseCount++;
}
int[] clients = new int[MaxClients]; int iTotal = 0;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientValid(i))
{
if (ZP_IsPlayerHuman(i))
{
SetGlobalTransTarget(i);
PrintHintText(i, "%t", "present arrived");
clients[iTotal++] = i;
}
}
}
if (iTotal)
{
EmitSound(clients, iTotal, SOUND_INFO_TIPS, SOUND_FROM_PLAYER, SNDCHAN_ITEM);
}
ZP_EmitSoundToAll(gSound, 1, SOUND_FROM_PLAYER, SNDCHAN_STATIC, true, false);
return Plugin_Continue;
}
/**
* @brief Case damage hook.
*
* @param entity The entity index.
* @param attacker The attacker index.
* @param inflictor The inflictor index.
* @param flDamage The damage amount.
* @param iBits The damage type.
**/
public Action CaseDamageHook(int entity, int &attacker, int &inflictor, float &flDamage, int &iBits)
{
int iHealth = GetEntProp(entity, Prop_Data, "m_iHealth") - RoundToNearest(flDamage); iHealth = (iHealth > 0) ? iHealth : 0;
if (!iHealth)
{
static float vPosition[3]; static float vAngle[3];
GetEntPropVector(entity, Prop_Data, "m_vecAbsOrigin", vPosition);
GetEntPropVector(entity, Prop_Data, "m_angAbsRotation", vAngle);
SpawnRandomWeapon(vPosition, vAngle, NULL_VECTOR, gType);
SDKUnhook(entity, SDKHook_OnTakeDamage, CaseDamageHook);
gCaseCount--;
}
return Plugin_Continue;
}
/**
* @brief Case touch hook.
*
* @param entity The entity index.
* @param target The target index.
**/
public Action CaseTouchHook(int entity, int target)
{
if (IsClientValid(target))
{
if (ZP_IsPlayerHuman(target))
{
static float vPosition[3]; static float vAngle[3];
GetEntPropVector(entity, Prop_Data, "m_vecAbsOrigin", vPosition);
GetEntPropVector(entity, Prop_Data, "m_angAbsRotation", vAngle);
SpawnRandomWeapon(vPosition, vAngle, NULL_VECTOR, gType);
AcceptEntityInput(entity, "Kill");
}
}
return Plugin_Continue;
}
/**
* @brief Called right before the entity transmitting to other entities.
*
* @param entity The entity index.
* @param client The client index.
**/
/*public Action CaseTransmitHook(int entity, int client)
{
if (ZP_IsPlayerZombie(client))
{
return Plugin_Handled;
}
return Plugin_Continue;
}*/
//**********************************************
//* Item (npc) stocks. *
//**********************************************
/**
* @brief Find the random position from the navigation mesh.
*
* @param vPosition (Optional) The position output.
* @return True on no colission, false otherwise.
**/
stock bool FindRandomPosition(float vPosition[3])
{
hPosition.GetArray(GetRandomInt(0, hPosition.Length - 1), vPosition, sizeof(vPosition));
static float vCenter[3]; vCenter = vPosition;
static const float vMins[3] = { -30.0, -30.0, 0.0 };
static const float vMaxs[3] = { 30.0, 30.0, 30.0 };
vCenter[2] += vMaxs[2] / 2.0; /// Move center of hull upward
TR_TraceHull(vCenter, vCenter, vMins, vMaxs, MASK_SOLID);
return !TR_DidHit();
}