This repository has been archived by the owner on Dec 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
3013 lines (2697 loc) · 135 KB
/
main.cpp
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
#include <windows.h>
#include <stdio.h>
#define EXT_IUTIL
#define EXT_IPLAYER
#define EXT_IOBJECT
#define EXT_IHALOENGINE
#define EXT_ITIMER
#define EXT_HKTIMER
#define EXT_ICOMMAND
#define EXT_ICINIFILE
#define _INC_TIME
#pragma comment(lib, "../Add-on API/Add-on API.lib")
#include "../Add-on API/Add-on API.h"
addon_info EXTPluginInfo = { L"Infection GameType Add-on", L"2.0.0.0",
L"RadWolfie & Wizard",
L"It provide ability simulate a zombie gametype with almost any proper gametype.",
L"Infection Gametype",
L"gametype",
NULL,
NULL,
NULL,
NULL };
//#define offsetof(s,m) (size_t)&reinterpret_cast<const volatile char&>((((s *)0)->m))
IUtil* pIUtil = 0;
IPlayer* pIPlayer = 0;
IObject* pIObject = 0;
IHaloEngine* pIHaloEngine = 0;
ITimer* pITimer = 0;
ICommand* pICommand = 0;
ICIniFile* pICIniFile = 0;
UINT EAOHashID = 0;
#pragma region //Wizard's Code
#include <string>
#include <vector>
#include <math.h> //Dumb Microsoft for leaving out round in many versions...
#include <time.h> //Is needed for srand function.
double roundC(double num) {
return (num > 0.0) ? floor(num + 0.5) : ceil(num - 0.5);
}
#define randomRange(min, max) (min + (rand() % (int)(max - min + 1)))
//#define randomRange(min, max) (int( rand() / (RAND_MAX+1)) * (max-min+1) + min) //BAD
// Global Variable
//std::wstring default_script_prefix = L"";
e_color_team_index human_team = COLOR_TEAM_RED; // 0 is red, 1 is blue
UINT max_zombie_count = 1; // this caps what the zombie count would be w/ ratio (nil is disable)
UINT time_invis = 1; // In seconds, how long the zombie/human should be invis when they crouch.
int zombie_count = 1; // if value is less than 1 is it used as a percentage, more than or equal to one is absolute count
e_color_team_index zombie_team = COLOR_TEAM_BLUE; // 0 is red, 1 is blue
e_color_team_index join_team = zombie_team; // the team that people will join if a game is currently running
float flashlight_speed = 2.2f; //I wouldn't suggest increasing this, unless you want people to lag.
// Alpha Zombie Variables
int alphazombie_frag_count = 0; // number of frag nades they spawn with
int alphazombie_plasma_count = 0; // number of plasma nades they spawn with
int alphazombie_clip_count = 0; // number of shots in clip (loaded ammo)
int alphazombie_ammo_count = 0; // backpack ammo they get (unloaded ammo)
float alphazombie_battery_count = 0.0f; // stored as a percent (0 to 1, do NOT go over or under)
// Zombie Variables
int zombie_ammo_count = 0; // backpack ammo zombies once there are not only alpha zombies (unloaded ammo)
int zombie_clip_count = 0; // number of shots in clip for zombies once there are not only alpha zombies (loaded ammo)
float zombie_battery_count = 0; // stored as a percent (0 to 1, do NOT go over or under)
int zombie_frag_count = 0; // number of frag nades they spawn with
int zombie_plasma_count = 0; // number of plasma nades they spawn with
int zombie_spawn_time = 0; // spawn time for zombies in seconds. Leave "default" for default spawn time of gametype
float zombie_speed = 1.5f; // zombie speed
e_color_index zombie_color = COLOR_TAN;
// Zombie weapons
// Note: If you decide the player holds a flag or a ball, make sure the secondary, tertiary, and quarternary fields are "".
// DO NOT make zombies hold multiple weapons if you want them to hold an oddball or a flag. If you do it will not work right, and it's entirely your fault.
const char* zombie_weapon[4] = {
"weapons\\shotgun\\shotgun", // Primary weapon for zombies.
"", // Secondary weapon for zombies.
"", // Tertiary weapon for zombies.
""}; // Quarternary weapon for zombies.
s_ident zweapon[4] = { 0 };
// Human weapons
const char* human_weapon[4] = {
"", // Primary weapon for humans.
"", // Secondary weapon for humans.
"", // Tertiary weapon for humans.
""}; // Quarternary weapon for humans.
s_ident hweapon[4] = { 0 };
// Human Variables
float human_dmgmodifier = 1.0f; // damage modifier for humans.
float human_speed = 1.0f; // speed when not infected
int human_spawn_time = 2; // spawn time for humans in seconds. Leave "default" for default spawn time of gametype
e_color_index human_color = COLOR_RED;
// Last Man Variables
float lastman_dmgmodifier = 1.35f; // damage modifier for the last man
int lastman_invistime = 20; // in seconds
int lastman_invulnerable = 10; // time (in seconds) the last man is invulnerable for: replace with nil to disable
float lastman_speed = 1.50f; // last man speed
// Booleans
bool humans_allowed_in_vehis = false; // if this is set to false { humans cannot enter vehicles
bool zombies_allowed_in_vehis = false; // if this is set to false { zombies cannot enter vehicles.
bool humans_invisible_on_crouch = false; // if this is set to true { humans will become invisible when they crouch.
bool zombies_invisible_on_crouch = true; // if this is set to true { zombies will be invisible when they crouch.
bool infect_on_fall = true; // if this is set to true { people who die from fall damage will become zombies.
bool infect_on_guardians = false; // if this is set to true { people who get killed by the guardians will become zombies.
bool infect_on_suicide = true; // if this is set to true { people who kill themselves will become a zombie.
bool infect_on_betrayal = false; // if this is set to true { people who betray their teammates will become a zombie.
bool last_human_next_zombie = true; // if this value is true the last man standing becomes the next zombie, if not it's random
bool use_old_kill_messages = true; // Set this if you like the OLD zombie infection messages with the 059 zombies.
// Additional variables.
bool team_play = false;
bool starting_equipment_is_generic;
UINT gametype = -1;
static const wchar_t teamRedStr[] = L"rt";
static const wchar_t teamBlueStr[] = L"bt";
UINT infected[16] = { 0 };
bool usedFlashlight[16] = { 0 };
UINT zombie_kills[16] = { 0 };
// Custom messages
ICIniFile* customMsg;
static const wchar_t customMsgStr[] = L"message.ini";
static const wchar_t str1_0[] = L"1.0";
static const wchar_t str1_1[] = L"1.1";
static const wchar_t str1_2[] = L"1.2";
static const wchar_t str1_3[] = L"1.3";
static const wchar_t str1_4[] = L"1.4";
static const wchar_t str1_5[] = L"1.5";
static const wchar_t str1_6[] = L"1.6";
static const wchar_t str1_7[] = L"1.7";
static const wchar_t str1_8[] = L"1.8";
static const wchar_t str1_9[] = L"1.9";
static const wchar_t str1_10[] = L"1.10";
static const wchar_t str1_11[] = L"1.11";
static const wchar_t str1_12[] = L"1.12";
static const wchar_t str1_13[] = L"1.13";
static const wchar_t str1_14[] = L"1.14";
static const wchar_t str2_0[] = L"2.0";
static const wchar_t str2_1[] = L"2.1";
static const wchar_t str2_2[] = L"2.2";
static const wchar_t str2_3[] = L"2.3";
static const wchar_t str2_4[] = L"2.4";
static const wchar_t str2_5[] = L"2.5";
static const wchar_t str2_6[] = L"2.6";
static const wchar_t str2_7[] = L"2.7";
static const wchar_t str2_8[] = L"2.8";
static const wchar_t str2_9[] = L"2.9";
static const wchar_t str2_10[] = L"2.10";
static const wchar_t str2_11[] = L"2.11";
static const wchar_t str2_12[] = L"2.12";
static const wchar_t str2_13[] = L"2.13";
static const wchar_t str3_0[] = L"3.0";
static const wchar_t str3_1[] = L"3.1";
static const wchar_t str3_2[] = L"3.2";
static const wchar_t str3_3[] = L"3.3";
static const wchar_t str3_4[] = L"3.4";
static const wchar_t str3_5[] = L"3.5";
static const wchar_t str3_6[] = L"3.6";
static const wchar_t str3_7[] = L"3.7";
static const wchar_t str3_8[] = L"3.8";
static const wchar_t str3_9[] = L"3.9";
static const wchar_t str4_0[] = L"4.0";
static const wchar_t str4_1[] = L"4.1";
static const wchar_t str4_2[] = L"4.2";
static const wchar_t str4_3[] = L"4.3";
static const wchar_t str4_4[] = L"4.4";
static const wchar_t str4_5[] = L"4.5";
static const wchar_t str4_6[] = L"4.6";
static const wchar_t str4_7[] = L"4.7";
static const wchar_t str4_8[] = L"4.8";
static const wchar_t str4_9[] = L"4.9";
static const wchar_t str5_0[] = L"5.0";
static const wchar_t str5_1[] = L"5.1";
static const wchar_t str5_2[] = L"5.2";
static const wchar_t str5_3[] = L"5.3";
static const wchar_t str5_4[] = L"5.4";
static const wchar_t str5_5[] = L"5.5";
static const wchar_t str5_6[] = L"5.6";
static const wchar_t str5_7[] = L"5.7";
static const wchar_t str5_8[] = L"5.8";
static const wchar_t str5_9[] = L"5.9";
static const wchar_t str6_0[] = L"6.0";
static const wchar_t str6_1[] = L"6.1";
static const wchar_t str6_2[] = L"6.2";
static const wchar_t str6_3[] = L"6.3";
static const wchar_t str6_4[] = L"6.4";
static const wchar_t str6_5[] = L"6.5";
static const wchar_t str6_6[] = L"6.6";
static const wchar_t str6_7[] = L"6.7";
static const wchar_t str6_8[] = L"6.8";
static const wchar_t str6_9[] = L"6.9";
static const wchar_t section_str_hint[] = L"hint";
static const wchar_t section_str_death[] = L"death";
static const wchar_t section_str_complement[] = L"complement";
static const wchar_t section_str_new_team[] = L"new team";
static const wchar_t section_str_misc[] = L"misc";
static const wchar_t section_str_gametype[] = L"gametype";
static const wchar_t section_str_command[] = L"command";
static const wchar_t section_str_general[] = L"general";
// Hint Messages
wchar_t blockteamchange_message[INIFILEVALUEMAX] = L"Autobalance: You're not allowed to change team.",
teamkill_message[INIFILEVALUEMAX] = L"Don't team kill...",
nozombiesleftmessage[INIFILEVALUEMAX] = L"There are no zombies left. Someone needs to change team or someone will be forced to.",
lastman_message[INIFILEVALUEMAX] = L"{0:s} is the last human alive and is invisible for {1:2d} seconds!",
rejoin_message[INIFILEVALUEMAX] = L"Please don't leave and rejoin. You've been put back onto your last team.",
zombieinvis_message[INIFILEVALUEMAX] = L"The zombies are invisible for 20 seconds!",
speedburst_begin_message[INIFILEVALUEMAX] = L"**FLASHLIGHT SPEEDBURST USED**",
speedburst_end_message[INIFILEVALUEMAX] = L"**FLASHLIGHT SPEED USED. REGAIN IT ON NEXT SPAWN**",
block_tree_message[INIFILEVALUEMAX] = L"This tree is blocked.",
block_spot_message[INIFILEVALUEMAX] = L"Sorry, this spot has been blocked...",
block_glitch_message[INIFILEVALUEMAX] = L"Glitching is not allowed!",
nozombiesleft_counter_message[INIFILEVALUEMAX] = L"In {0:2d} seconds a player will be forced to become a zombie.",
// Death/Infection Messages
falling_infected_message[INIFILEVALUEMAX] = L"{0:s} has been infected by falling",
guardian_infected_message[INIFILEVALUEMAX] = L"{0:s} was infected by the guardians",
kill_infected_message[INIFILEVALUEMAX] = L"{0:s} has infected {1:s}",
teammate_infected_message[INIFILEVALUEMAX] = L"{0:s} was infected for betraying {1:s}",
suicide_infected_message[INIFILEVALUEMAX] = L"{0:s} lost the will to live",
human_kill_message[INIFILEVALUEMAX] = L"{0:s} has killed {1:s}",
falling_death_message[INIFILEVALUEMAX] = L"{0:s} slipped and fell",
guardian_death_message[INIFILEVALUEMAX] = L"",
teammate_death_message[INIFILEVALUEMAX] = L"{0:s} betrayed {1:s}",
suicide_death_message[INIFILEVALUEMAX] = L"{0:s} has killed themself",
infected_message[INIFILEVALUEMAX] = L"{0:s} has been infected!",
// Complement Messages
timer_team_change_msg[INIFILEVALUEMAX] = L"Thank you. The game will now continue",
zombie_backtap_message[INIFILEVALUEMAX] = L"Nice backtap!",
// New Team Messages
human_message[INIFILEVALUEMAX] = L"YOU'RE A HUMAN. Survive!",
zombie_message[INIFILEVALUEMAX] = L"YOU'RE A ZOMBIE. FEED ON HUMANS!",
// Additional Messages
welcome_message[INIFILEVALUEMAX] = L"Welcome to Zombies",
koth_additional_welcome_msg[INIFILEVALUEMAX] = L"The hill is a safezone! Use it for quick getaways!",
slayer_additional_welcome1_msg[INIFILEVALUEMAX] = L"The nav points are not just for decoration!",
slayer_additional_welcome2_msg[INIFILEVALUEMAX] = L"They will point to the last human surviving!",
cure_zombie_kill_message[INIFILEVALUEMAX] = L"{0:s} is now a human because they infected 5 times!",
game_start_message[INIFILEVALUEMAX] = L"The game has started",
zombie_infect_human_message[INIFILEVALUEMAX] = L"You have transmitted the zombie virus to {0:s}",
human_infect_begin_message[INIFILEVALUEMAX] = L"YOU ARE INFECTED! Find a healthpack in 45 seconds to survive!",
human_infect_counter_message[INIFILEVALUEMAX] = L"YOU ARE INFECTED! Find a healthpack in {0:2d} seconds to survive!",
human_infect_end_message[INIFILEVALUEMAX] = L"{0:s} could not find a cure in time!",
cure_human_message[INIFILEVALUEMAX] = L"YOU HAVE BEEN CURED!",
// Gametype Messages
koth_infect_begin_message[INIFILEVALUEMAX] = L"{0:s} must leave the hill in 10 seconds or they will be infected!",
koth_infect_end_message[INIFILEVALUEMAX] = L"{0:s} was infected because they were in the hill too long!",
koth_kill_begin_message[INIFILEVALUEMAX] = L"{0:s} must leave the hill in 10 seconds or they will be killed!",
koth_kill_end_message[INIFILEVALUEMAX] = L"{0:s} has been killed because they were in the hill too long!",
koth_kill_counter_message[INIFILEVALUEMAX] = L"You have {0:2d} seconds to leave the hill!";
// Don't modify below variables unless you know what you're doing
int cur_zombie_count = 0;
int cur_human_count = 0;
UINT alpha_zombie_count = 0;
//int human_time = {};
//int cur_players = 0; //Don't use this, intead use pIHaloEngine->serverHeader->totalPlayers
PlayerInfo cur_last_human;
//int last_man_name = 0;
//BYTE game_init = 0;
//bool game_enable = 0;
bool allow_change = false;
bool map_reset_boolean = false;
bool dontModifyDmg = false;
//Modified to improve the Infection gametype flow.
struct dataTable {
std::string hash;
int human_time;
int zombie_kills;
char isZombie;
int inhill_time;
DWORD activateFlashlight;
DWORD uniqueID;
dataTable() {
human_time = 0;
zombie_kills = 0;
isZombie = 0;
inhill_time = -1;
activateFlashlight = 0;
uniqueID=-1;
}
};
std::vector<dataTable> cacheTable;
bool game_started;
UINT human_time[16];
UINT last_hill_time[16];
wchar_t last_human_name[12] = { 0 };
wchar_t name_table[16][12];
UINT inhill_time[16];
UINT gametype_indicator;
int playerChangeCounter=0;
PlayerInfo pl_null;
s_ident oddball_flag_obj[16];
real_vector3d location;
real_vector3d velocity_reset;
PlayerInfo plI_ctf;
s_weapon* oddball_flag_relocate=NULL;
//Missing values
int resptime = 0;
hTagHeader *falling_tag_id,
*distance_tag_id,
*camouflage_tag_id,
*healthpack_tag_id,
*overshield_tag_id,
*fragnade_tag_id,
*plasmanade_tag_id,
// fragnade_tag_id, //Found duplicated
// plasmanade_tag_id, //Found duplicated
*oddball_tag_id,
*flag_tag_id,
*rifle_id,
*needler_id,
*pistol_id,
*rocket_id,
*shotgun_id,
*sniper_id,
*flame_id,
*rifle_ammo_id,
*needler_ammo_id,
*pistol_ammo_id,
*rocket_ammo_id,
*shotgun_ammo_id,
*sniper_ammo_id,
*flame_ammo_id,
*fuel_dmg1_id,
*fuel_dmg2_id,
*fuel_dmg3_id,
*fuel_dmg4_id;
#pragma endregion
#pragma region //RadWolfie's code port to H-Ext plugin.
#pragma region Timers section
typedef enum eTimer {
eNONE = -1,
eAssignLeftOverZombieWeapon = 0,
eAssignLeftOverHumanWeapon,
eAssignZombieWeapon,
eAssignHumanWeapon,
eHaveSpeedTimer,
eBumpTimer,
eBumpInfection,
eCheckGameState,
eHumanTimer,
eInvisCrouch,
eMsgTimer,
eNewGameTimer,
ePlayerChangeTimer,
eRemoveLastManProtection
} eTimer;
typedef struct dTimer {
UINT TimerID;
eTimer eFunc;
int machine_index; //(optional field)
} dTimer;
std::vector<dTimer> vTimer(0x40);
//Additional field checker
bool hasPlayerChangeTimer = false;
s_ident lastman_object;
#pragma endregion
#pragma region Functions section
//RadWolfie - Approved
int getalphacount() {
// recalculate how many "alpha" zombies there are
//int alpha_zombie_count;
if (zombie_count < 1)
alpha_zombie_count = (int)roundC((pIHaloEngine->serverHeader->totalPlayers * zombie_count) + 0.5);
else
alpha_zombie_count = zombie_count;
if (alpha_zombie_count > max_zombie_count)
alpha_zombie_count = max_zombie_count;
return alpha_zombie_count;
}
//RadWolfie - Approved | except patch is excluded and does not work with multiple halo builds due to different code.
void InitializeGame() {
//RadWolfie - This is just in case someone might initialize this while not hosting the map.
if (pIHaloEngine->mapCurrent->type == 1) {
cur_zombie_count = 0;
cur_human_count = 0;
alpha_zombie_count = 0;
for (std::vector<dTimer>::iterator iTimer = vTimer.begin(); iTimer != vTimer.end(); iTimer++) {
pITimer->m_delete(EAOHashID, iTimer->TimerID);
}
vTimer.clear();
hasPlayerChangeTimer = false;
UINT i;
for (i = 0; i < 16; i++) {
human_time[i] = 0;
}
cur_last_human = PlayerInfo();
//last_human_name[0] = 0;
game_started = false;
allow_change = false;
for (i = 0; i < 16; i++) {
last_hill_time[i] = -1;
}
for (i = 0; i < 16; i++) {
name_table[i][0] = 0;
}
for (i = 0; i < 16; i++) {
inhill_time[i] = -1;
}
for (i = 0; i < 16; i++) {
zombie_kills[i] = 0;
}
// write patches
/* This is lua's code.
// Not require - H-Ext already provided patch for CTF's repeated message glitch.
writebyte(addresses.ctf_msgs_patch, 0xEB)
// Not require - See EXTOnPlayerSpawnColor hook event for this process
writebyte(addresses.color_patch, 0xEB)
// Cannot patch due to variety halo builds are different.
writebyte(addresses.slayer_score_patch, 0xEB)
writebyte(addresses.nonslayer_score_patch, 0xEB)
*/
// set color values - See EXTOnPlayerSpawnColor hook event for this process
// recalculate team counters
cur_human_count = pIPlayer->m_get_str_to_player_list(human_team == COLOR_TEAM_BLUE ? teamBlueStr : teamRedStr, nullptr, nullptr);
cur_zombie_count = pIPlayer->m_get_str_to_player_list(zombie_team == COLOR_TEAM_BLUE ? teamBlueStr : teamRedStr, nullptr, nullptr);
// recalculate how many "alpha" zombies there are
alpha_zombie_count = getalphacount();
team_play = pIHaloEngine->gameTypeLive->isTeamPlay;
lastman_object = -1;
// set gametype specific variables
gametype = pIHaloEngine->gameTypeLive->game_stage;
gametype_indicator = pIHaloEngine->gameTypeLive->objective_indicator;
switch (gametype) {
case GAMETYPE_CTF: { // CTF
//writedword(addresses.flag_respawn_addr, 0xFFFFFFFF)
//TODO: DelayWriteCoords timer is not needed.
//UINT id = pITimer->m_add(EAOHashID, nullptr, 0); //0 second
//join_team = zombie_team;
}
case GAMETYPE_SLAYER: { // Slayer
//zombie_team = COLOR_BLUE;
//human_team = COLOR_RED;
}
case GAMETYPE_ODDBALL: // Oddball
//TODO: Added by RadWolfie - Support oddball anyway.
case GAMETYPE_KOTH: { // KOTH
//join_team = zombie_team;
break;
}
default: { // Incompatible gametype
VARIANT argList[1];
VARIANTwstr(&argList[0], pIHaloEngine->gameTypeLive->name);
pIPlayer->m_send_custom_message_broadcast(MF_ERROR, L"Incompatible gametype: ", 1, argList);
return;
}
}
starting_equipment_is_generic = !pIHaloEngine->gameTypeLive->isCustomEquipment;
UINT id = pITimer->m_add(EAOHashID, nullptr, 30); //1 second
if (id)
vTimer.push_back({ id, eHumanTimer, -1 });
id = pITimer->m_add(EAOHashID, nullptr, 6); //200 miliseconds
if (id)
vTimer.push_back({ id, eInvisCrouch, -1 });
id = pITimer->m_add(EAOHashID, nullptr, 27); //900 miliseconds
if (id)
vTimer.push_back({ id, eBumpTimer, -1 });
id = pITimer->m_add(EAOHashID, nullptr, 27); //200 milliseconds
if (id)
vTimer.push_back({ id, eCheckGameState, -1 });
}
}
//RadWolfie - Not required.
//UINT getteamsize(e_color_team_index team) {};
// RadWolfie - Approved
// Gets the ammo mapId of the weapon, or nil if there's no ammo for the weapon.
// Accepts the weapon's mapId as an argument.
// Created by Wizard
s_ident getAmmoTagId(hTagHeader* mapId) {
s_ident ammoTagId = -1;
if (mapId == rifle_id) {
ammoTagId = rifle_ammo_id->ident;
} else if (mapId == needler_id) {
ammoTagId = needler_ammo_id->ident;
} else if (mapId == pistol_id) {
ammoTagId = pistol_ammo_id->ident;
} else if (mapId == rocket_id) {
ammoTagId = rocket_ammo_id->ident;
} else if (mapId == shotgun_id) {
ammoTagId = shotgun_ammo_id->ident;
} else if (mapId == sniper_id) {
ammoTagId = sniper_ammo_id->ident;
} else if (mapId == flame_id) {
ammoTagId = flame_ammo_id->ident;
}
return ammoTagId;
}
//RadWolfie - Approved
void spawnAmmoForKiller(PlayerInfo killer, PlayerInfo victim) {
s_biped* m_biped = (s_biped*)pIObject->m_get_address(victim.plS->CurrentBiped);
if (m_biped) {
// Don't drop ammo for last killer
if (!cur_last_human.mS) {
// Get coordinates to drop the ammo at.
real_vector3d coord = m_biped->sObject.World;
coord.z += 1;
// Get the weapon of the killer so we can check its ammo type.
s_weapon* m_weapon = (s_weapon*)pIObject->m_get_address(m_biped->sObject.Weapon);
if (m_weapon) {
hTagHeader* weapHeader = pIObject->m_lookup_tag(m_biped->sObject.Weapon);
// Get weapon ammo's mapId of the killer's weapon
s_ident tagId = m_weapon->sObject.ModelTag;
s_ident ammoTagId = getAmmoTagId(weapHeader);
if (ammoTagId.Tag != -1) {
pIObject->m_create(ammoTagId, s_ident(-1), 60, nullptr, &coord);
}
}
}
}
}
//RadWolfie - Not required.
//void all_players_zombies(PlayerInfo plI) {};
//RadWolfie - Approved
PlayerInfo ChooseRandomPlayer(e_color_team_index excludeTeam) {
UINT randNumber;
UINT count;
PlayerInfoList plList;
// loop through all 16 possible spots and add to table
count = pIPlayer->m_get_str_to_player_list(excludeTeam == COLOR_TEAM_BLUE ? teamRedStr : teamBlueStr, &plList, nullptr);
if (count == 0)
return PlayerInfo();
count--;
randNumber = randomRange(0, count);
return plList.plList[randNumber];
}
//RadWolfie - Approved
void destroyweapons(PlayerInfo plI) {
s_biped* pl_biped = (s_biped*)pIObject->m_get_address(plI.plS->CurrentBiped);
if (pl_biped) {
for (UINT i = 0; i < 4; i++) {
if (pl_biped->Weapons[i].Tag!=-1)
pIObject->m_destroy(pl_biped->Weapons[i]);
}
}
}
//RadWolfie - Approved
void AddScore(PlayerInfo plI, UINT amount) {
//if (!plI.mS)
//error
human_time[plI.plR->MachineIndex] += amount;
}
//RadWolfie - Approved
void LoadTags() {
falling_tag_id = pIObject->m_lookup_tag_type_name(TAG_JPT_, "globals\\falling");
distance_tag_id = pIObject->m_lookup_tag_type_name(TAG_JPT_, "globals\\distance");
camouflage_tag_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\active camouflage");
healthpack_tag_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\health pack");
overshield_tag_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\over shield");
fragnade_tag_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "weapons\\frag grenade\\frag grenade");
plasmanade_tag_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "weapons\\plasma grenade\\plasma grenade");
fragnade_tag_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "weapons\\frag grenade\\frag grenade");
plasmanade_tag_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "weapons\\plasma grenade\\plasma grenade");
oddball_tag_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\ball\\ball");
flag_tag_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\flag\\flag");
rifle_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\assault rifle\\assault rifle");
needler_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\needler\\mp_needler");
pistol_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\pistol\\pistol");
rocket_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\rocket launcher\\rocket launcher");
shotgun_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\shotgun\\shotgun");
sniper_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\sniper rifle\\sniper rifle");
flame_id = pIObject->m_lookup_tag_type_name(TAG_WEAP, "weapons\\flamethrower\\flamethrower");
rifle_ammo_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\assault rifle ammo\\assault rifle ammo");
needler_ammo_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\needler ammo\\needler ammo");
pistol_ammo_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\pistol ammo\\pistol ammo");
rocket_ammo_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\rocket launcher ammo\\rocket launcher ammo");
shotgun_ammo_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\shotgun ammo\\shotgun ammo");
sniper_ammo_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\sniper rifle ammo\\sniper rifle ammo");
flame_ammo_id = pIObject->m_lookup_tag_type_name(TAG_EQIP, "powerups\\flamethrower ammo\\flamethrower ammo");
fuel_dmg1_id = pIObject->m_lookup_tag_type_name(TAG_JPT_, "weapons\\plasma_cannon\\effects\\plasma_cannon_explosion");
fuel_dmg2_id = pIObject->m_lookup_tag_type_name(TAG_JPT_, "weapons\\plasma_cannon\\effects\\plasma_cannon_misfire");
fuel_dmg3_id = pIObject->m_lookup_tag_type_name(TAG_JPT_, "weapons\\plasma_cannon\\effects\\plasma_cannon_trigger");
fuel_dmg4_id = pIObject->m_lookup_tag_type_name(TAG_JPT_, "weapons\\plasma_cannon\\impact damage");
}
//RadWolfie - Extended
bool must_be_readied[4];
bool must_be_picked_up[4];
float melee_dmg_force[4];
float melee_response_force[4];
struct s_meta_weapon {
BYTE unknown1[0x308]; //0x000
bool bitfield0 : 1; //0x308
bool bitfield1 : 1;
bool bitfield2 : 1;
bool must_be_readied : 1;
bool bitfield4 : 1;
bool bitfield5 : 1;
bool bitfield6 : 1;
bool must_be_picked_up : 1;
BYTE unknown2[0x8B]; //0x309
};
struct s_meta_melee {
BYTE unknown1[0x1F4]; //0x000
float force; //0x1F4
};
//RadWolfie - Approved | except not sure about bitfield offset is correct. (It also edited the tagset too. So, once unload it remain as effect until map change.)
// This function will set the zombie weapon attributes
// It will loop through all the zombie weapons
// and give a 10x force to the zombie weapon's melee
void setZombieWeaponAttributes() {
for (int i = 0; i < 4; i++) {
if (zombie_weapon[i] != nullptr && zombie_weapon[i][0] != 0) {
hTagHeader* weapon_tag = pIObject->m_lookup_tag_type_name(TAG_WEAP, zombie_weapon[i]);
if (weapon_tag) {
zweapon[i] = weapon_tag->ident;
if (weapon_tag->ident.Tag >= 0xE0000000 && weapon_tag->ident.Tag <= 0xF0000000) {
s_meta_weapon* weapon_meta = (s_meta_weapon*)weapon_tag->group_meta_tag;
must_be_readied[i] = weapon_meta->must_be_readied;
weapon_meta->must_be_readied = 0;
must_be_picked_up[i] = weapon_meta->must_be_picked_up;
weapon_meta->must_be_picked_up = 1;
DWORD melee_dmg_mapId = *(DWORD*)(weapon_meta + 0x394 + 0xC);
if (melee_dmg_mapId && melee_dmg_mapId >= 0xD0000000 && melee_dmg_mapId <= 0xF0000000) {
hTagHeader* melee_dmg_tag = pIObject->m_lookup_tag(melee_dmg_mapId);
s_meta_melee* melee_dmg_meta = (s_meta_melee*)melee_dmg_tag->group_meta_tag;
melee_dmg_force[i] = melee_dmg_meta->force;
melee_dmg_meta->force = 10.0f;
}
DWORD melee_response_mapId = *(DWORD*)(weapon_meta + 0x3A4 + 0xC);
if (melee_response_mapId && melee_response_mapId >= 0xD0000000 && melee_response_mapId <= 0xF0000000) {
hTagHeader* melee_response_tag = pIObject->m_lookup_tag(melee_response_mapId);
s_meta_melee* melee_response_meta = (s_meta_melee*)melee_response_tag->group_meta_tag;
melee_response_force[i] = melee_response_meta->force;
melee_response_meta->force = 10.0f;
}
}
} else zweapon[i] = -1;
} else zweapon[i] = 0;
}
}
void unsetZombieWeaponAttributes() {
for (int i = 0; i < 4; i++) {
if (zombie_weapon[i] != nullptr && zombie_weapon[i][0] != 0) {
hTagHeader* weapon_tag = pIObject->m_lookup_tag_type_name(TAG_WEAP, zombie_weapon[i]);
if (weapon_tag) {
zweapon[i] = weapon_tag->ident;
if (weapon_tag->ident.Tag >= 0xE0000000 && weapon_tag->ident.Tag <= 0xF0000000) {
s_meta_weapon* weapon_meta = (s_meta_weapon*)weapon_tag->group_meta_tag;
weapon_meta->must_be_readied = must_be_readied[i];
weapon_meta->must_be_picked_up = must_be_picked_up[i];
DWORD melee_dmg_mapId = *(DWORD*)(weapon_meta + 0x394 + 0xC);
if (melee_dmg_mapId && melee_dmg_mapId >= 0xD0000000 && melee_dmg_mapId <= 0xF0000000) {
hTagHeader* melee_dmg_tag = pIObject->m_lookup_tag(melee_dmg_mapId);
s_meta_melee* melee_dmg_meta = (s_meta_melee*)melee_dmg_tag->group_meta_tag;
melee_dmg_meta->force = melee_dmg_force[i];
}
DWORD melee_response_mapId = *(DWORD*)(weapon_meta + 0x3A4 + 0xC);
if (melee_response_mapId && melee_response_mapId >= 0xD0000000 && melee_response_mapId <= 0xF0000000) {
hTagHeader* melee_response_tag = pIObject->m_lookup_tag(melee_response_mapId);
s_meta_melee* melee_response_meta = (s_meta_melee*)melee_response_tag->group_meta_tag;
melee_response_meta->force = melee_response_force[i];
}
}
} else zweapon[i] = -1;
} else zweapon[i] = 0;
}
}
//RadWolfie - Approved
// This function basically 'sets' a human's traits.
// It CAN convert a zombie to a human, or simply set the traits of a human.
void makehuman(PlayerInfo plI, bool forcekill) {
// change the player's speed to human speed.
// Should not be in the if statement because if statement is ONLY for changing teams IF they are a zombie.
plI.plS->VelocityMultiplier = human_speed;
// Check if we need to change their team.
if (plI.plR->Team == zombie_team) {
// Change their team.
pIPlayer->m_change_team(&plI, human_team, forcekill);
// Player is already a human, let's assign their color and possibly kill them... slowly...
} else {
if (forcekill)
pIObject->m_kill(plI.plS->CurrentBiped);
}
}
//RadWolfie - Approved
// This function basically 'sets' a zombie's traits.
// It CAN convert a human to a zombie, or simply set the traits of a zombie.
void makezombie(PlayerInfo plI, bool forcekill) {
// change the player's speed to zombie speed.
// Should not be in the if statement because if statement is ONLY for changing teams IF they are a zombie.
plI.plS->VelocityMultiplier = zombie_speed;
// Make sure the player is a human before we make them zombie.
if (plI.plR->Team == human_team) {
// Change their team.
pIPlayer->m_change_team(&plI, zombie_team, forcekill);
// Player is already a zombie, let's assign their color and possibly kill them.
} else {
if (forcekill)
pIObject->m_kill(plI.plS->CurrentBiped);
}
}
//RadWolfie - Approved
void noZombiesLeft() {
if (team_play) {
if (!hasPlayerChangeTimer) {
allow_change = true;
pIPlayer->m_send_custom_message_broadcast(MF_BLANK, nozombiesleftmessage, 0, nullptr);
UINT id = pITimer->m_add(EAOHashID, nullptr, 30); //1 seconds
if (id) {
vTimer.push_back({ id, ePlayerChangeTimer, -1 });
hasPlayerChangeTimer = true;
}
}
} else {
// pick a human and make them zombie.
PlayerInfo newZomb = ChooseRandomPlayer(zombie_team);
if (newZomb.plS) {
makezombie(newZomb, true);
pIPlayer->m_send_custom_message(MF_BLANK, MP_RCON, &newZomb, zombie_message, 0, nullptr);
}
}
}
//RadWolfie - Approved
bool check_in_sphere(real_vector3d objectLoc, real_vector3d loc, float R) {
bool Pass = false;
if (pow(loc.x - objectLoc.x, 2) + pow(loc.y - objectLoc.y, 2) + pow(loc.z - objectLoc.z, 2) <= R) {
Pass = true;
}
return Pass;
}
//RadWolfie - Approved
void WriteNavsToZombies(PlayerInfo plI) {
PlayerInfoList plList;
UINT count = pIPlayer->m_get_str_to_player_list(zombie_team == COLOR_TEAM_BLUE ? teamBlueStr : teamRedStr, &plList, nullptr);
for (UINT i = 0; i < count; i++) {
plList.plList[i].plS->killInOrderObjective.index = plI.plR->PlayerIndex;
plList.plList[i].plS->killInOrderObjective.salt = plI.plS->PlayerID;
}
}
//RadWolfie - Approved | except unsure about invulnerable bit offset.
void onlastman() {
// lookup the last man
PlayerInfo lastManCheck;
PlayerInfoList plList;
s_biped* m_biped;
s_weapon* m_weapon;
UINT i = pIPlayer->m_get_str_to_player_list(human_team==COLOR_TEAM_BLUE ? teamBlueStr : teamRedStr, &plList, nullptr);
if (i == 0)
return;
i--;
//for is not required since m_get_str_to_player_list can get team list. Plus it only need to get one human, so "for" isn't even needed.
//for (UINT i=0; i < count; i++) {
// set the last human global variable
cur_last_human = plList.plList[i];
// Write the navs of zombies to the last man.
if (gametype == GAMETYPE_SLAYER) { // Slayer
WriteNavsToZombies(cur_last_human);
}
// give the last human speed and extra ammo
cur_last_human.plS->VelocityMultiplier = lastman_speed;
// find the last human's weapons
m_biped = (s_biped*)pIObject->m_get_address(cur_last_human.plS->CurrentBiped);
if (m_biped) {
if (lastman_invulnerable) {
// setup the invulnerable timer
m_biped->sObject.noCollision = 1;
lastman_object = cur_last_human.plS->CurrentBiped;
UINT id = pITimer->m_add(EAOHashID, &cur_last_human, lastman_invulnerable * 33);
if (id)
vTimer.push_back({ id, eRemoveLastManProtection, -1 });
}
// Give all weapons infinite ammo
for (UINT w = 0; w < 4; w++) {
m_weapon = (s_weapon*)pIObject->m_get_address(m_biped->Weapons[w]);
if (m_weapon) {
// set the ammo
m_weapon->BulletCountInRemainingClips = 0x7FFF;
m_weapon->BulletCountInCurrentClip = 0x7FFF;
pIObject->m_update(m_biped->Weapons[w]);
}
}
}
//}
if (cur_last_human.mS) {
VARIANT argList[2];
VARIANTwstr(&argList[0], cur_last_human.plS->Name);
VARIANTint(&argList[1], lastman_invistime);
pIPlayer->m_send_custom_message_broadcast(MF_BLANK, lastman_message, 2, argList);
pIPlayer->m_apply_camo(&cur_last_human, lastman_invistime);
}
}
//RadWolfie - Approved
bool PlayerInHill(PlayerInfo plI) {
if (plI.plS->CurrentBiped.Tag != -1 && pIHaloEngine->gameTypeGlobals->kothGlobal.isInHill[plI.plR->PlayerIndex]) {
return true;
}
return false;
}
//RadWolfie - Approved
void takenavsaway() {
PlayerInfoList plList;
UINT count = pIPlayer->m_get_str_to_player_list(L"*", &plList, nullptr);
for (UINT i = 0; i < count; i++) {
//TODO: killInOrderObjective set to -1 method does not show it is working for both PC & CE...Wizard said it is working in PC.
//plList.plList[i].plS->killInOrderObjective.Tag = -1;
plList.plList[i].plS->killInOrderObjective.salt = plList.plList[i].plS->PlayerID; //Alternate workaround for now.
plList.plList[i].plS->killInOrderObjective.index = plList.plList[i].plR->PlayerIndex; //Alternate workaround for now.
}
}
//RadWolfie - Not required.
//PlayerInfoList getplayertable(excludeTeam) {};
//RadWolfie - Not required.
//bool getteamplay() {};
//RadWolfie - Not required.
//UINT, UINT getteamsizes() {};
//RadWolfie - Not required.
//UINT getcolorval(color) {};
//RadWolfie - Not required.
//UINT getPreferredColor(playerId) {};
//RadWolfie - Not required, it is done internally.
//changeteam(playerId, forcekill) {};
//RadWolfie - Not required.
//getRandomColorTeam(cur_color) {};
//RadWolfie - Not required. These are just extras...
//objectidtoplayer(objectId) {};
//getplayerobject(playerId) {};
//getplayervehicleid(playerId) {};
//getplayervehicle(playerId) {};
//getplayerweaponid(playerId, slot) {};
//getplayerweapon(playerId, slot) {};
#pragma endregion
#pragma region Timers section
typedef struct assignData {
int clipcount;
int ammocount;
float batterycount;
} assignData;
assignData AssignLeftoverZombieWeaponsData[16] = { 0 };
//RadWolfie - Approved | This is not needed, use hook func "EXTOnWeaponAssignmentDefault" and "EXTOnWeaponAssignmentCustom" instead.
// basically this timer assigns the tertiary and quarternary weapons to zombies if specified at the top
// this is needed since onweaponassignment isn't called for tertiary and quartenary weapons
void AssignLeftoverZombieWeapons(int index) {
s_ident weaponId;
PlayerInfo plI;
if (!(index >= 0 && index <= 15))
return;
assignData* data = AssignLeftoverZombieWeaponsData + index;
if (!pIPlayer->m_get_m_index(index, &plI, 1))
return;
s_biped* m_biped = (s_biped*)pIObject->m_get_address(plI.plS->CurrentBiped);
if (m_biped) {
if (zweapon[2].Tag) {
if (pIObject->m_create(zweapon[2], s_ident(-1), 60, &weaponId, &real_vector3d(5, 2, 2))) {
s_weapon* m_weapon = (s_weapon*)pIObject->m_get_address(weaponId);
if (m_weapon) {
// set the ammo
m_weapon->BulletCountInRemainingClips = data->ammocount;
m_weapon->BulletCountInCurrentClip = data->clipcount;
m_weapon->ammoBattery = abs(data->batterycount - 1);
// force it to sync
pIObject->m_update(weaponId);
}
}
}
// make sure the script user isn't retarded so we don't get errors
if (zweapon[2].Tag) {
// create the quarternary weapon
if (pIObject->m_create(zweapon[3], s_ident(-1), 60, &weaponId, &real_vector3d(1, 1, 1))) {
s_weapon* m_weapon = (s_weapon*)pIObject->m_get_address(weaponId);
// make sure createobject didn't screw up
if (m_weapon) {
// assign the weapon to the player
pIObject->m_equipment_assign(plI.plS->CurrentBiped, weaponId);
// set the ammo
m_weapon->BulletCountInRemainingClips = data->ammocount;
m_weapon->BulletCountInCurrentClip = data->clipcount;
m_weapon->ammoBattery = abs(data->batterycount - 1);
// force it to sync
pIObject->m_update(weaponId);
}
}
}
}
}
assignData AssignLeftoverHumanWeaponsData[16] = { 0 };
//RadWolfie - Approved | This is not needed, use hook func "EXTOnWeaponAssignmentDefault" and "EXTOnWeaponAssignmentCustom" instead.
// basically this timer assigns the tertiary and quarternary weapons to zombies if specified at the top
// this is needed since onweaponassignment isn't called for tertiary and quartenary weapons
void AssignLeftoverHumanWeapons(int index) {
s_ident weaponId;
PlayerInfo plI;
if (!(index >= 0 && index <= 15))
return;
assignData* data = AssignLeftoverHumanWeaponsData + index;
if (!pIPlayer->m_get_m_index(index, &plI, 1))
return;
s_biped* m_biped = (s_biped*)pIObject->m_get_address(plI.plS->CurrentBiped);
if (m_biped) {
if (hweapon[2].Tag) {
if (pIObject->m_create(hweapon[2], s_ident(-1), 60, &weaponId, &real_vector3d(5, 2, 2))) {
s_weapon* m_weapon = (s_weapon*)pIObject->m_get_address(weaponId);