forked from ShakaUVM/CustomTF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGRUNTY.QC
2962 lines (2532 loc) · 85 KB
/
GRUNTY.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
/* ------------------------------------------------------------------------------------
** ------------------------------------GRUNTY(tm)--------------------------------------
** -- Your artificially intelligent mercenary from beyond the Void --
** -- Use with caution -
** -- Do not expose to excessive amounts of radiation -
** -- Share and Enjoy! --
** --- Copyright(c)2000 By Dwarven Star Interactive Industrial Industry Enterprises ---
** ----------------------------------------------------------------------------------*/
/* ALREADY DEFINED IN ARMY.QC
#define WAYPOINT_TYPE_PRIMARY 0
#define WAYPOINT_TYPE_SECONDARY 1
#define WAYPOINT_TYPE_ENEMYLASTSEEN 2
*/
#define GRUNTY_PAINTIME 2
// Function Prototypes
// Whenever a function is added within the grunty, add it up here
void(entity wyp, entity soldier) RemoveWaypoint;
void () GruntyThink;
void () GRun;
void () GruntyScanTargets;
void () GruntyCheckFire;
void (entity targ) GetRank;
void () Grunty_Check_Frags;
float (float angle, float dist) botmovedist;
float () ReturnWeaponVelocity;
void () GruntyPayThink;
void () GruntyDrawPay;
// External Functions
// List all external functions used here
float () isMelee;
//entity (entity scanner) LookAround;
float(entity thing) IsOwnedMonster;
//=- OfN -=//
void(entity sld, entity player, string msg, float priority) PrintFromSoldier;
string(entity sld) GetOwnerMessage;
string(entity sld) GetFriendlyMessage;
entity (entity sold, entity viewpoint) ReturnEasyWaypoint;
string(entity thething) GetEnemyName;
void () CheckWaterJump;
// The Frames of Grunty
$cd /raid/quake/id1/models/player_4
$origin 0 -6 24
$base base
$skin skin0
$skin skin1
$skin skin2
$skin skin3
// Frames, from player.qc
//
// running
//
$frame axrun1 axrun2 axrun3 axrun4 axrun5 axrun6
$frame rockrun1 rockrun2 rockrun3 rockrun4 rockrun5 rockrun6
//
// standing
//
$frame stand1 stand2 stand3 stand4 stand5
$frame axstnd1 axstnd2 axstnd3 axstnd4 axstnd5 axstnd6
$frame axstnd7 axstnd8 axstnd9 axstnd10 axstnd11 axstnd12
//
// pain
//
$frame axpain1 axpain2 axpain3 axpain4 axpain5 axpain6
$frame pain1 pain2 pain3 pain4 pain5 pain6
//
// death
//
$frame axdeth1 axdeth2 axdeth3 axdeth4 axdeth5 axdeth6
$frame axdeth7 axdeth8 axdeth9
$frame deatha1 deatha2 deatha3 deatha4 deatha5 deatha6 deatha7 deatha8
$frame deatha9 deatha10 deatha11
$frame deathb1 deathb2 deathb3 deathb4 deathb5 deathb6 deathb7 deathb8
$frame deathb9
$frame deathc1 deathc2 deathc3 deathc4 deathc5 deathc6 deathc7 deathc8
$frame deathc9 deathc10 deathc11 deathc12 deathc13 deathc14 deathc15
$frame deathd1 deathd2 deathd3 deathd4 deathd5 deathd6 deathd7
$frame deathd8 deathd9
$frame deathe1 deathe2 deathe3 deathe4 deathe5 deathe6 deathe7
$frame deathe8 deathe9
//
// attacks
//
$frame nailatt1 nailatt2
$frame light1 light2
$frame rockatt1 rockatt2 rockatt3 rockatt4 rockatt5 rockatt6
$frame shotatt1 shotatt2 shotatt3 shotatt4 shotatt5 shotatt6
$frame axatt1 axatt2 axatt3 axatt4 axatt5 axatt6
$frame axattb1 axattb2 axattb3 axattb4 axattb5 axattb6
$frame axattc1 axattc2 axattc3 axattc4 axattc5 axattc6
$frame axattd1 axattd2 axattd3 axattd4 axattd5 axattd6
void(entity grunty) grunty_setstartframe =
{
grunty.frame = $stand1;
};
/* ---------------------------------------------------------------------------------- */
// The Fun Bit
/* ---------------------------------------------------------------------------------- */
// GRUNTY - PART ONE
// Standing Around
//
// Grunty is standing around having a good time
/* ---------------------------------------------------------------------------------- */
// Grunty is standing with his axe or other melee weapon
// Note that he must do a GruntyThink each frame
// (each frame is 0.05 seconds)
// However, he may only animate every 0.1 seconds, hence the flooring and odd incrementing
// of his frame variable. (0.05 animation is very smooth and twice as fast as normal)
void() grunty_run;
void() grunty_stand = // We need two stand sections for axe and weapon
{
//self.nextthink = time + 0.05; //needed?? nope
if (self.health > 0) self.think = grunty_stand;
self.weaponframe = 0;
if (isMelee())
{
if (self.walkframe >= 12)
self.walkframe = 0;
self.frame = $axstnd1 + floor(self.walkframe);
}
else
{
if (self.walkframe >= 5)
self.walkframe = 0;
self.frame = $stand1 + floor(self.walkframe);
}
self.walkframe = self.walkframe + 0.5;
//self.walkframe = self.walkframe + 0.5;
// allow grunty pick up ammo when standing
//touchworld();
#ifdef VERBOSE_GRUNTY
if (self.super_time <= time)
{
sprint(self.real_owner, #PRINT_HIGH, "Soldier in position and awaiting target.\n");
self.super_time = time + 5;
}
#endif
Grunty_Check_Frags();
if (self.goalentity != world)
{
self.walkframe = 0;
self.think = grunty_run;
//return;
}
GruntyThink();
//sprint(self.real_owner, #PRINT_HIGH, "Done gruntythink in stand().\n");
};
/* ---------------------------------------------------------------------------------- */
// GRUNTY - PART TWO
// Running Around
//
// Grunty is charging about the place
/* ---------------------------------------------------------------------------------- */
// Again we have a choice of which animation to use
void() grunty_run =
{
// local string st;
if (self.health > 0) self.think = grunty_run;
self.weaponframe = 0; //needed?
if (isMelee())
{
if (self.walkframe >= 6)
self.walkframe = 0;
self.frame = $axrun1 + floor(self.walkframe);
}
else
{
if (self.walkframe >= 6)
self.walkframe = 0;
self.frame = $rockrun1 + floor(self.walkframe);
}
self.walkframe = self.walkframe + 0.5;
#ifdef VERBOSE_GRUNTY
if (self.super_time <= time)
{
sprint(self.real_owner, #PRINT_HIGH, "Hello, commander! I am currently running at speed ");
st = ftos(self.custom_speed);
sprint(self.real_owner, #PRINT_HIGH, st);
sprint(self.real_owner, #PRINT_HIGH, " towards ");
sprint(self.real_owner, #PRINT_HIGH, self.goalentity.netname);
sprint(self.real_owner, #PRINT_HIGH, "\n");
self.super_time = time + 5;
}
#endif
if (self.goalentity == world)
{
self.walkframe = 0;
self.think = grunty_stand;
//return;
}
GruntyThink();
#ifdef VERBOSE_GRUNTY
sprint(self.real_owner, #PRINT_HIGH, "I have just finished GruntyThink (self.enemy = ");
sprint(self.real_owner, #PRINT_HIGH, self.enemy);
sprint(self.real_owner, #PRINT_HIGH, ")\n");
#endif
GRun();
#ifdef VERBOSE_GRUNTY
sprint(self.real_owner, #PRINT_HIGH, "I have just finished GRun (self.enemy = ");
sprint(self.real_owner, #PRINT_HIGH, self.enemy);
sprint(self.real_owner, #PRINT_HIGH, ")\n");
#endif
Grunty_Check_Frags();
};
void() stand_frames = //- ofn - used when soldier is following us, and when hes stuck and set to not jump
{
self.weaponframe=0;
if (isMelee())
{
if (self.walkframe >= 12)
self.walkframe = 0;
self.frame = $axstnd1 + floor(self.walkframe);
}
else
{
if (self.walkframe >= 5)
self.walkframe = 0;
self.frame = $stand1 + floor(self.walkframe);
}
self.walkframe = self.walkframe + 0.1;
};
/* ---------------------------------------------------------------------------------- */
// GRUNTY - PART THREE
// Axing People
//
// Grunty goes psycho
/* ---------------------------------------------------------------------------------- */
// Grunty's first axe attack
void() grunty_axeatta =
{
self.frame = $axatt1 + floor(self.weaponframe);
if (self.weaponframe == 1)
if (self.current_weapon == #WEAP_AXE)
W_FireAxe();
else
W_FireSpanner();
self.weaponframe = self.weaponframe + 0.5;
GruntyThink();
GRun();
///self.nextthink = time + 0.05;
if (self.weaponframe > 3)
if (self.health > 0) self.think = grunty_run;
};
// Grunty's second axe attack
void() grunty_axeattb =
{
self.frame = $axattb1 + floor(self.weaponframe);
if (self.weaponframe == 2)
if (self.current_weapon == #WEAP_AXE)
W_FireAxe();
else
W_FireSpanner();
self.weaponframe = self.weaponframe + 0.5;
GruntyThink();
GRun();
///self.nextthink = time + 0.05;
if (self.weaponframe > 3)
if (self.health > 0) self.think = grunty_run;
};
// Grunty's third axe attack
void() grunty_axeattc =
{
self.frame = $axattc1 + floor(self.weaponframe);
if (self.weaponframe == 2)
if (self.current_weapon == #WEAP_AXE)
W_FireAxe();
else
W_FireSpanner();
self.weaponframe = self.weaponframe + 0.5;
GruntyThink();
GRun();
///self.nextthink = time + 0.05;
if (self.weaponframe > 3)
if (self.health > 0) self.think = grunty_run;
};
// Grunty's fourth axe attack
void() grunty_axeattd =
{
self.frame = $axattd1 + floor(self.weaponframe);
if (self.weaponframe == 2)
if (self.current_weapon == #WEAP_AXE)
W_FireAxe();
else
W_FireSpanner();
self.weaponframe = self.weaponframe + 0.5;
GruntyThink();
GRun();
///self.nextthink = time + 0.05;
if (self.weaponframe > 3)
if (self.health > 0) self.think = grunty_run;
};
// Axe attack chooser
void() grunty_axeatt =
{
MonsterAuraPower();
local float r;
self.walkframe = 0; // Reset walkframe to avoid freaky animations?
r = random();
if (r < 0.25)
grunty_axeatta();
else if (r < 0.5)
grunty_axeattb();
else if (r < 0.75)
grunty_axeattc();
else
grunty_axeattd();
};
/* ---------------------------------------------------------------------------------- */
// GRUNTY - PART FOUR
// Shooting Time
//
// Grunty goes postal
/* ---------------------------------------------------------------------------------- */
// Grunty uses the shotgun
// The firing is done after he chooses the attack
void() grunty_shotgun =
{
MonsterAuraPower();
self.frame = $shotatt1 + floor(self.weaponframe);
if (self.weaponframe == 0)
self.effects = self.effects | #EF_DIMLIGHT;
else if (self.weaponframe == 0.5)
self.effects = self.effects - (self.effects & #EF_DIMLIGHT);
self.weaponframe = self.weaponframe + 0.5;
GruntyThink();
GRun();
///self.nextthink = time + 0.05;
if (self.weaponframe > 5)
{
self.walkframe = 0;
if (self.ammo_shells < 1)
PrintFromSoldier(self,self.real_owner,"i've run out of shells!\n",#PRINT_LOW);
if (self.health > 0) self.think = grunty_run;
}
};
// Grunty fires his rocket launcher! muahahahahaha
// The firing is done after he chooses the attack
void() grunty_rocket =
{
MonsterAuraPower();
self.frame = $rockatt1 + floor(self.weaponframe);
if (self.weaponframe == 0)
self.effects = self.effects | #EF_DIMLIGHT;
else if (self.weaponframe == 0.5)
self.effects = self.effects - (self.effects & #EF_DIMLIGHT);
self.weaponframe = self.weaponframe + 0.5;
GruntyThink();
GRun();
///self.nextthink = time + 0.05;
if (self.weaponframe > 5)
{
self.walkframe = 0;
if (self.ammo_rockets < 1)
PrintFromSoldier(self,self.real_owner,"i've run out of rockets!\n",#PRINT_LOW);
if (self.health > 0) self.think = grunty_run;
}
};
//- ofn - this to compensate no prediction
//- GRUNTY'S NAILS GO FASTER AS HIS RANK IS INCREASED (upto 2200)-//
void(vector org, vector dir) grunty_spike =
{
newmis = spawn ();
newmis.owner = self;
newmis.movetype = #MOVETYPE_FLYMISSILE;
newmis.solid = #SOLID_BBOX;
newmis.angles = vectoangles(dir);
newmis.touch = spike_touch;
newmis.weapon = #DMSG_NAILGUN;
newmis.classname = "spike";
newmis.think = SUB_Remove;
newmis.nextthink = time + 6;
setmodel (newmis, "progs/spike.mdl");
setsize (newmis, #VEC_ORIGIN, #VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir*(1100+1100*(self.has_sensor/17));
};
// Grunty uses the nailgun
void() grunty_nail1 = [$nailatt1, grunty_nail2]
{
MonsterAuraPower();
GruntyThink(); GRun(); self.effects = self.effects | #EF_DIMLIGHT;
if (self.ammo_nails > 0)
{
W_FireSpikes(4);
if (self.ammo_nails < 1) PrintFromSoldier(self,self.real_owner,"i've run out of nails!\n",#PRINT_LOW);
}
};
void() grunty_nail2 = [$nailatt1, grunty_nail3]
{
GruntyThink(); GRun(); self.effects = self.effects | #EF_DIMLIGHT;
};
void() grunty_nail3 = [$nailatt2, grunty_nail4]
{
GruntyThink(); GRun(); self.effects = self.effects - (self.effects & #EF_DIMLIGHT);
if (self.ammo_nails > 0)
{
W_FireSpikes(-4);
if (self.ammo_nails < 1) PrintFromSoldier(self,self.real_owner,"i've run out of nails!\n",#PRINT_LOW);
}
};
float( entity bot, float allowedweaps, float dist ) GruntyPickBestWeapon;
void() grunty_nail4 = [$nailatt2, grunty_nail1]
{
GruntyThink(); GRun(); self.effects = self.effects - (self.effects & #EF_DIMLIGHT);
local float vis, dist;
vis = visible(self.enemy);
dist = vlen(self.origin - self.enemy.origin);
// Gizmo - removed "dist < 200" from this, and added GruntyPickBestWeapon() check
// Gizmo - grunty can be limited on his weapon's use (defaults to all weapons allowed)
if (!vis || self.ammo_nails < 1 || self.enemy.health <= 0 || random() < 0.025
|| GruntyPickBestWeapon( self, self.#allowed_weapons, dist ) != #WEAP_NAILGUN )
{
self.walkframe = 0;
grunty_run();
return;
}
};
vector () Grunty_LeadShot =
{
local vector pvel, dir, loc;//, lead;
local vector src, targ;
src = self.origin + '0 0 16';
targ = self.enemy.origin;
pvel = '0 0 0'; // ofn - no prediction
/*if (self.enemy.classname == "player")
pvel='0 0 0';//pvel = self.enemy.velocity;
else if (self.enemy.classname == "monster_army")
{
makevectors(self.enemy.angles);
pvel = self.enemy.velocity + v_forward * self.enemy.custom_speed * 20;// * 10; //- ? was 20
}
else
pvel = '0 0 0';*/
//if (!self.enemy.flags & #FL_ONGROUND)
// pvel_z = pvel_z / 20;
//lead = pvel * (vlen(src - targ) / ReturnWeaponVelocity());
loc = targ;// + lead;
// do the following do anything?-----//
//lead = pvel * (vlen(src - loc) / ReturnWeaponVelocity());
//lead_x = lead_x + (10 - random() * 20);
//lead_y = lead_y + (10 - random() * 20);
//------------------------------------// self.view_ofs
traceline(src, targ, #TL_BSP_ONLY, self);
if (trace_fraction != 1.0)
{
loc_z = loc_z + self.enemy.maxs_z; // already commented
//if (self.current_weapon == #WEAP_ROCKET_LAUNCHER)
// loc_z = loc_z + self.enemy.mins_z * -1;
}
else
{
//- OFN - makes grunty aim to the ground with RL sometimes, so evil! ^_^
if (self.current_weapon == #WEAP_ROCKET_LAUNCHER && random() > 0.3) {
// Gizmo - made a lot of changes to make him aim at feet better
if ( self.enemy.flags & #FL_ONGROUND ) {
loc_z = self.enemy.absmin_z;
// Gizmo - make sure their feet are actually visible
traceline( src, loc, #TL_ANY_SOLID, self );
// if feet aren't visible, aim back up
if ( trace_fraction != 1 )
if ( trace_ent != self.enemy )
loc_z = self.enemy.origin_z;
}
}
}
dir = normalize (loc - src);
return dir;
};
/* ---------------------------------------------------------------------------------- */
// GRUNTY - PART FIVE
// Thinking Skills
//
// Grunty reflects on what he has done
/* ---------------------------------------------------------------------------------- */
void() GruntyThink =
{
AI_Check_Contents(self);
if (self.health <= 0) return;
self.nextthink = time + 0.05; //was 0.05
// check for Follow Me Grunty's owner death
if (self.goalentity == self.real_owner)
if (self.goalentity.health <= 0)
self.goalentity = world;
// Check to buy
if (self.suicide_time <= time)
GruntyPayThink();
// scan for targets
GruntyScanTargets();
};
/*
==============
IsValidGruntyTarget
Gizmo - Made a function from the code in LookAroundGrunty(),
and fixed up some pointless code that wasn't very efficient.
==============
*/
float( entity gtarget, entity grunty ) IsValidGruntyTarget = {
#ifdef MAD_MONSTERS
if ( gtarget.classname == "player" && IsSummon( grunty ) )
return #TRUE;
#else
if ( gtarget.classname == "player" && !Teammate( gtarget, grunty.real_owner ) ) {
if ( gtarget.is_undercover ) {
if ( gtarget.cutf_items & #CUTF_JAMMER || !( grunty.tf_items & #NIT_SCANNER ) )
return #FALSE;
}
if ( gtarget.modelindex == modelindex_null ) {
if ( gtarget.cutf_items & #CUTF_JAMMER || !( grunty.tf_items & #NIT_SCANNER ) )
return #FALSE;
}
if ( gtarget.modelindex == modelindex_eyes ) {
if ( gtarget.cutf_items & #CUTF_JAMMER || !( grunty.tf_items & #NIT_SCANNER ) ) {
if ( random() < 2 - grunty.has_tesla * random() )
return #FALSE;
}
}
// Gizmo - used to be ( gtarget, grunty, 1, 0, 0, 0 ), but we already check visible before calling this
return Pharse_Client( gtarget, grunty, 0, 0, 0, 0 );
}
#endif
// Gizmo - allow non demons and non army soldiers to be affected (coop monsters)
else if ( IsMonster( gtarget ) && gtarget.health > 0 ) {
if ( !Teammate( gtarget.real_owner, grunty.real_owner ) )
return #TRUE;
} else if ( gtarget.classname == "grenade" && gtarget.netname == "land_mine" ) {
if ( !Teammate( gtarget.owner, grunty.real_owner ) )
return #TRUE;
} else if ( !Teammate( gtarget, grunty.real_owner ) ) { // && gtarget.classname != "building_sentrygun_base"
if ( IsOffenseBuilding( gtarget ) ) // for teslas isoffensiveb only returns true if not cloaked
return #TRUE;
}
return #FALSE;
};
// LookAround for grunty
entity( entity scanner ) LookAroundGrunty = {
local entity client;
// local entity list_client;
// local entity list;
//if (infokey(world,"ceasefire")=="on") //OfN
if (ceasefire)
return scanner;
client = findradius(scanner.origin, 2500);
while (client)
{
// Gizmo - added a traceline so he doesn't shoot through teammates
traceline( scanner.origin + '0 0 16', client.origin, #TL_ANY_SOLID, scanner );
if ( trace_ent == client )
if (client != scanner && visible2(client, scanner))
{
// Gizmo - use this function instead of the code commented out below
if ( IsValidGruntyTarget( client, scanner ) )
return client;
}
client = client.chain;
}
return scanner;
};
entity () GruntyPharse =
{
local float r;
r = random();
#ifdef MAD_GRUNTY
if (r < 0.30 && (visible(self.real_owner)) && self.real_owner.health > 0)
return self.real_owner;
#else
//- ofn - lot of shit changed in lookaround to make them target well
if (r < 0.30)
return LookAroundGrunty(self);
#endif
return world;
};
void() GruntyScanTargets =
{
local entity targ; // our hapless foe
local string st;
if (self.enemy != world)
if (self.enemy.health <= 0 || !self.enemy.is_connected)
{
self.enemy = world;
self.goalentity = ReturnEasyWaypoint(self,self);
//// self.enemy = world;
//// self.goalentity = world;
if (self.demon_one != world)
{
RemoveWaypoint(self.demon_one,self);
self.demon_one = world;
}
self.has_teleporter = 0;
self.effects = self.effects - (self.effects & #EF_DIMLIGHT);
return;
}
// If we have a target already
if (self.enemy != world)
{
local float vis;
vis = visible(self.enemy);
// Gizmo - added a traceline so he doesn't shoot through teammates
traceline( self.origin + '0 0 16', self.enemy.origin, #TL_ANY_SOLID, self );
if ( vis && trace_ent == self.enemy )
{
if (self.demon_one != world)
{
RemoveWaypoint(self.demon_one, self);
self.demon_one = world;
} //often =world
self.search_time = time + 3;
if (self.attack_finished <= time)
GruntyCheckFire();
}
else
{
if (self.is_malfunctioning==0 || self.is_malfunctioning==2)
{
self.enemy = world;
self.goalentity = ReturnEasyWaypoint(self,self);
self.has_teleporter = 0;
self.effects = self.effects - (self.effects & #EF_DIMLIGHT);
return;
}
// tactic
// Gizmo - if we're seeking out an enemy, check if another one is visible so we don't get lamed
targ=GruntyPharse();
if ( targ != self )
if ( targ != world )
self.search_time = 0; // Gizmo - hack to reuse the code below
if (self.demon_one == world) // if we don't have a enemy last seen marker
{
self.demon_one = CreateWaypoint(self.enemy.origin - self.enemy.velocity * 0.05, #WAYPOINT_AI_LIFE, #WAYPOINT_TYPE_ENEMYLASTSEEN, self);
self.demon_one.goalentity = ReturnEasyWaypoint(self,self.demon_one);
self.goalentity = self.demon_one;
self.search_time = time + #GRUNTY_SEEKTIME; // was 8
//- OfN -
self.has_teleporter = 0;
}
else if (self.search_time <= time) // we seeked enemy for GRUNTY_SEEKTIME already so...
{
self.enemy = world;
self.goalentity = world;
if (self.demon_one != world) // d1 remove contingency check
{
RemoveWaypoint(self.demon_one,self);
self.demon_one = world;
self.goalentity = ReturnEasyWaypoint(self,self);
}
}
}
}
else // otherwise look for a target
{
targ=GruntyPharse();
if (targ == self)
return;
if (targ == world)
return;
if (!self.is_detpacking || ceasefire)//infokey(world,"ceasefire")=="on")
{
if (!IsBuilding(targ) && self.super_time < time && targ.netname != "land_mine")
{
st = strcat("i can see ",targ.netname);
st = strcat(st," around there...\n");
PrintFromSoldier(self,self.real_owner,st,#PRINT_HIGH);
//sprint(self.real_owner, #PRINT_HIGH, targ.netname);
//sprint(self.real_owner, #PRINT_HIGH, " around there...\n");
self.super_time = time + 4;
}
return;
}
if (self.super_time < time)
{
//local string targetstr;
//targetstr=GetEnemyName(targ);//targ.netname;
st = strcat("Target ",targ.netname);
st = strcat(st, " spotted!\n Engaging target...\n");
PrintFromSoldier(self,self.real_owner,st,#PRINT_HIGH);
//sprint(self.real_owner, #PRINT_HIGH, targ.netname);
//sprint(self.real_owner, #PRINT_HIGH, " spotted!\n Engaging target...\n");
self.super_time = time + 2.5;
}
self.enemy = targ;
// Gizmo - check for static mode
if ( self.is_malfunctioning != 2 )
self.goalentity = self.enemy;
self.search_time = time + 3;
}
};
// Gizmo
float( entity bot, float allowedweaps, float dist ) GruntyPickBestWeapon = {
local float enemySpeed;
// used for deciding which weapon to use
if ( bot.enemy.flags & #FL_ONGROUND && IsMonster( bot.enemy ) )
enemySpeed = 0;
else {
// Gizmo - this works, but I want the bot to ignore forward and backward enemy movement because only enemies strafing around the grunt matter
//enemySpeed = vlen( bot.enemy.velocity );
// Gizmo - NOTE: I don't think the previous v_* vectors need to be restored upon return
makevectors( bot.angles );
enemySpeed = bot.enemy.velocity * ( v_right + v_up );
enemySpeed = fabs( enemySpeed );
}
if ( dist < 64 ) {
// use the knife and super shotgun first
if ( bot.weapons_carried & #WEAP_AXE && allowedweaps & #WEAP_AXE && bot.cutf_items & #CUTF_KNIFE )
return #WEAP_AXE;
if ( bot.weapons_carried & #WEAP_SUPER_SHOTGUN && allowedweaps & #WEAP_SUPER_SHOTGUN
&& bot.ammo_shells > 1 )
return #WEAP_SUPER_SHOTGUN;
// opportunistic weapon usage
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 150 )
return #WEAP_NAILGUN;
// standard weapon priority
if ( bot.weapons_carried & #WEAP_AXE && allowedweaps & #WEAP_AXE )
return #WEAP_AXE;
if ( bot.weapons_carried & #WEAP_SHOTGUN && allowedweaps & #WEAP_SHOTGUN
&& bot.ammo_shells > 0 )
return #WEAP_SHOTGUN;
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 )
return #WEAP_NAILGUN;
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 )
return #WEAP_ROCKET_LAUNCHER;
// at this range we try them all
return 0;
} else if ( dist < 200 ) {
// use the super shotgun first
if ( bot.weapons_carried & #WEAP_SUPER_SHOTGUN && allowedweaps & #WEAP_SUPER_SHOTGUN
&& bot.ammo_shells > 1 )
return #WEAP_SUPER_SHOTGUN;
// opportunistic weapon usage
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 100 )
return #WEAP_NAILGUN;
// standard weapon priority
if ( bot.weapons_carried & #WEAP_SHOTGUN && allowedweaps & #WEAP_SHOTGUN
&& bot.ammo_shells > 0 )
return #WEAP_SHOTGUN;
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 )
return #WEAP_ROCKET_LAUNCHER;
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 )
return #WEAP_NAILGUN;
} else if ( dist < 400 ) {
// use the rocket launcher first
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 )
return #WEAP_ROCKET_LAUNCHER;
// opportunistic weapon usage
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 50 && enemySpeed < 100 )
return #WEAP_NAILGUN;
// standard weapon priority
if ( bot.weapons_carried & #WEAP_SHOTGUN && allowedweaps & #WEAP_SHOTGUN
&& bot.ammo_shells > 0 )
return #WEAP_SHOTGUN;
if ( bot.weapons_carried & #WEAP_SUPER_SHOTGUN && allowedweaps & #WEAP_SUPER_SHOTGUN
&& bot.ammo_shells > 1 )
return #WEAP_SUPER_SHOTGUN;
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 )
return #WEAP_NAILGUN;
} else if ( dist < 1100 ) {
// use the rocket launcher first
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 )
return #WEAP_ROCKET_LAUNCHER;
// opportunistic weapon usage
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 && enemySpeed < 100 )
return #WEAP_NAILGUN;
// standard weapon priority
if ( bot.weapons_carried & #WEAP_SHOTGUN && allowedweaps & #WEAP_SHOTGUN
&& bot.ammo_shells > 0 )
return #WEAP_SHOTGUN;
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 )
return #WEAP_NAILGUN;
if ( bot.weapons_carried & #WEAP_SUPER_SHOTGUN && allowedweaps & #WEAP_SUPER_SHOTGUN
&& bot.ammo_shells > 1 )
return #WEAP_SUPER_SHOTGUN;
} else if ( dist < 1400 ) {
// try the rocket launcher first
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 && random() > 0.75 )
return #WEAP_ROCKET_LAUNCHER;
// opportunistic weapon usage
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 && enemySpeed < 75 )
return #WEAP_NAILGUN;
// standard weapon priority
if ( bot.weapons_carried & #WEAP_SHOTGUN && allowedweaps & #WEAP_SHOTGUN
&& bot.ammo_shells > 0 )
return #WEAP_SHOTGUN;
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 )
return #WEAP_NAILGUN;
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 )
return #WEAP_ROCKET_LAUNCHER;
// this is probably out of the super shotgun range
if ( bot.weapons_carried & #WEAP_SUPER_SHOTGUN && allowedweaps & #WEAP_SUPER_SHOTGUN
&& bot.ammo_shells > 1 )
return #WEAP_SUPER_SHOTGUN;
} else if ( dist < 2000 ) {
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 && random() > 0.98 )
return #WEAP_ROCKET_LAUNCHER;
// standard weapon priority
if ( bot.weapons_carried & #WEAP_NAILGUN && allowedweaps & #WEAP_NAILGUN
&& bot.ammo_nails > 0 )
return #WEAP_NAILGUN;
if ( bot.weapons_carried & #WEAP_ROCKET_LAUNCHER && allowedweaps & #WEAP_ROCKET_LAUNCHER
&& bot.ammo_rockets > 0 )
return #WEAP_ROCKET_LAUNCHER;
// these weapons won't do much if anything at this range
if ( bot.weapons_carried & #WEAP_SHOTGUN && allowedweaps & #WEAP_SHOTGUN
&& bot.ammo_shells > 0 )
return #WEAP_SHOTGUN;