-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathasw_marine.cpp
More file actions
6105 lines (5248 loc) · 192 KB
/
asw_marine.cpp
File metadata and controls
6105 lines (5248 loc) · 192 KB
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
//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============
//
// Purpose:
//
//=============================================================================
#include "cbase.h"
#include "ai_default.h"
#include "ai_task.h"
#include "ai_schedule.h"
#include "ai_node.h"
#include "ai_hull.h"
#include "ai_hint.h"
#include "ai_squad.h"
#include "ai_senses.h"
#include "ai_navigator.h"
#include "ai_motor.h"
#include "ai_behavior.h"
#include "ai_baseactor.h"
#include "ai_behavior_lead.h"
#include "ai_behavior_follow.h"
#include "ai_behavior_standoff.h"
#include "ai_behavior_assault.h"
#include "soundent.h"
#include "game.h"
#include "npcevent.h"
#include "entitylist.h"
#include "activitylist.h"
#include "vstdlib/random.h"
#include "engine/IEngineSound.h"
#include "sceneentity.h"
#include "asw_marine.h"
#include "asw_player.h"
#include "asw_marine_resource.h"
#include "asw_marine_profile.h"
#include "asw_weapon.h"
#include "asw_marine_speech.h"
//#include "asw_drone.h"
#include "asw_pickup.h"
#include "asw_pickup_weapon.h"
#include "asw_gamerules.h"
#include "asw_gamestats.h"
#include "asw_mission_manager.h"
#include "asw_fail_advice.h"
#include "ammodef.h"
#include "asw_shareddefs.h"
#include "asw_sentry_base.h"
#include "asw_sentry_top.h"
#include "asw_button_area.h"
#include "asw_equipment_list.h"
#include "asw_weapon_parse.h"
#include "asw_fx_shared.h"
#include "asw_parasite.h"
#include "shareddefs.h"
#include "iasw_vehicle.h"
#include "obstacle_pushaway.h"
#include "asw_computer_area.h"
#include "asw_remote_turret_shared.h"
#include "asw_util_shared.h"
#include "EntityFlame.h"
#include "physics_prop_ragdoll.h"
#include "asw_weapon_flashlight_shared.h"
#include "beam_shared.h"
#include "iasw_server_usable_entity.h"
#include "asw_weapon_ammo_bag_shared.h"
#include "datacache/imdlcache.h"
#include "asw_weapon_autogun_shared.h"
#include "asw_burning.h"
#include "asw_door.h"
#include "asw_hack.h"
#include "te_effect_dispatch.h"
#include "asw_trace_filter_melee.h"
#include "ai_moveprobe.h"
#include "asw_ai_senses.h"
#include "particle_parse.h"
#include "asw_director.h"
#include "asw_melee_system.h"
#include "ai_network.h"
#include "asw_weapon_normal_armor.h"
#include "asw_fire.h"
#include "asw_achievements.h"
#include "asw_objective_escape.h"
#include "sendprop_priorities.h"
#include "asw_marine_gamemovement.h"
#include "asw_deathmatch_mode.h"
#include "IEffects.h"
#include "asw_triggers.h"
#include "triggers.h"
#include "EnvLaser.h"
#include "iservervehicle.h"
#include "rd_cause_of_death.h"
#include "npc_zombine.h"
#include "asw_weapon_revive_tool_shared.h"
#include "asw_tech_marine_req.h"
#include "func_asw_fade.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#define ASW_DEFAULT_MARINE_MODEL "models/swarm/marine/marine.mdl"
extern ConVar asw_stats_verbose;
extern ConVar asw_stun_grenade_time;
ConVar rd_frags_limit( "rd_frags_limit", "20", FCVAR_REPLICATED, "Number of frags a player must reach to win the round");
ConVar rd_chatter_about_ff( "rd_chatter_about_ff", "1", FCVAR_REPLICATED, "If 1 marines will shout about friendly fire done to them");
ConVar rd_chatter_about_marine_death( "rd_chatter_about_marine_death", "1", FCVAR_REPLICATED, "If 1 marines will shout Marine Down if marine dies");
ConVar rd_marine_ignite_immediately( "rd_marine_ignite_immediately", "0", FCVAR_CHEAT | FCVAR_REPLICATED, "If 1 marines will will be ignited by flamer from single puff (see also the asw_marine_time_until_ignite convars)" );
ConVar rd_pvp_marine_take_damage_from_bots("rd_pvp_marine_take_damage_from_bots", "1", FCVAR_CHEAT, "If 0 players will not take damage from bots in PvP");
ConVar rd_bot_strong( "rd_bot_strong", "1", FCVAR_CHEAT, "If 1, bots take only 25% of damage in a co-op game" );
ConVar rd_medgun_medkit_refill_amount( "rd_medgun_medkit_refill_amount", "0", FCVAR_CHEAT, "Amount of ammo given to refill a healgun from a medkit" );
ConVar rd_marine_take_damage_from_ai_grenade( "rd_marine_take_damage_from_ai_grenade", "1", FCVAR_CHEAT, "Players take damage from bots' grenade launchers" );
ConVar rd_stuck_teleport_distance( "rd_stuck_teleport_distance", "256", FCVAR_CHEAT, "Maximum distance to teleport a stuck marine to a node" );
static ConVar rd_notify_about_out_of_ammo( "rd_notify_about_out_of_ammo", "1", FCVAR_CHEAT, "Chatter and print a yellow message when marine is out of ammo" );
static ConVar rd_gas_grenade_ff_dmg( "rd_gas_grenade_ff_dmg", "10", FCVAR_CHEAT, "Fixed friendly fire damage of gas grenade, marine to marine, done in asw_gas_grenade_damage_interval. " );
extern ConVar rd_marine_ff_fist;
extern ConVar rd_burning_interval;
extern ConVar rd_burning_marine_damage;
ConVar rd_marine_ff_fist_scale( "rd_marine_ff_fist_scale", "1", FCVAR_CHEAT, "Scale CLUB type damage done to marines (requires rd_ff_marine_fist)" );
ConVar rd_server_marine_backpacks("rd_server_marine_backpacks", "0", FCVAR_REPLICATED | FCVAR_CHEAT, "Attach unactive weapon model to marine's back");
ConVar rda_marine_strafe_allow_air("rda_marine_strafe_allow_air", "0", FCVAR_CHEAT, "If set to 1 marine able to strafe jump once in the air");
ConVar rda_marine_strafe_push_hor_velocity("rda_marine_strafe_push_hor_velocity", "520", FCVAR_CHEAT, "Horizontal velocity for strafe push");
ConVar rda_marine_strafe_push_vert_velocity("rda_marine_strafe_push_vert_velocity", "260", FCVAR_CHEAT, "Vertical velocity for strafe push");
#define ADD_STAT( field, amount ) \
if ( CASW_Marine_Resource *pMR = GetMarineResource() ) \
{ \
if ( asw_stats_verbose.GetBool() ) \
{ \
DevMsg( "marine %d (%s %d+%d)\n", ASWGameResource()->GetMarineResourceIndex( pMR ), #field, pMR->field, amount ); \
} \
pMR->field += amount; \
}
//=========================================================
// Marine activities
//=========================================================
LINK_ENTITY_TO_CLASS( asw_marine, CASW_Marine );
//---------------------------------------------------------
//
//---------------------------------------------------------
void SendProxy_CropMarineFlagsToPlayerFlagBitsLength( const SendProp *pProp, const void *pStruct, const void *pVarData, DVariant *pOut, int iElement, int objectID)
{
int mask = (1<<PLAYER_FLAG_BITS) - 1;
int data = *(int *)pVarData;
pOut->m_Int = ( data & mask );
//CBaseEntity *pEntity = (CBaseEntity *)pProp;
//if (pEntity)
//{
//if (( data & mask ) & FL_ONGROUND)
//{
//Msg(" [S] Transmitting FL_ONGROUND (flags=%d)\n", pEntity->GetFlags());
//}
//else
//{
//Msg(" [S] Not Transmitting FL_ONGROUND (flags=%d)\n", pEntity->GetFlags());
//}
//}
//else
//{
//Msg(" WARNING updated flags without an ent\n");
//}
}
IMPLEMENT_SERVERCLASS_ST(CASW_Marine, DT_ASW_Marine)
SendPropExclude( "DT_BaseEntity", "m_angRotation" ),
SendPropExclude( "DT_BaseAnimating", "m_flPoseParameter" ),
SendPropExclude( "DT_BaseAnimating", "m_flPlaybackRate" ),
SendPropExclude( "DT_BaseAnimating", "m_nSequence" ),
SendPropExclude( "DT_BaseAnimatingOverlay", "overlay_vars" ),
SendPropExclude( "DT_BaseAnimating", "m_nNewSequenceParity" ),
SendPropExclude( "DT_BaseAnimating", "m_nResetEventsParity" ),
SendPropExclude( "DT_BaseCombatCharacter", "bcc_localdata" ),
// asw_playeranimstate and clientside animation takes care of these on the client
SendPropExclude( "DT_ServerAnimationData" , "m_flCycle" ),
SendPropExclude( "DT_AnimTimeMustBeFirst" , "m_flAnimTime" ),
// We need to send a hi-res origin to avoid prediction errors sliding along walls
SendPropExclude( "DT_BaseEntity", "m_vecOrigin" ),
// send a hi-res origin to the local player for use in prediction
//SendPropVector (SENDINFO(m_vecOrigin), -1, SPROP_NOSCALE|SPROP_CHANGES_OFTEN, 0.0f, HIGH_DEFAULT, SendProxy_Origin ),
SendPropVectorXY(SENDINFO(m_vecOrigin), -1, SPROP_NOSCALE | SPROP_CHANGES_OFTEN, 0.0f, HIGH_DEFAULT, SendProxy_OriginXY ),
SendPropFloat (SENDINFO_VECTORELEM(m_vecOrigin, 2), -1, SPROP_NOSCALE | SPROP_CHANGES_OFTEN, 0.0f, HIGH_DEFAULT, SendProxy_OriginZ ), // , SENDPROP_LOCALPLAYER_ORIGINZ_PRIORITY
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 0), 32, SPROP_NOSCALE|SPROP_CHANGES_OFTEN ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 1), 32, SPROP_NOSCALE|SPROP_CHANGES_OFTEN ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecVelocity, 2), 32, SPROP_NOSCALE|SPROP_CHANGES_OFTEN ),
#if PREDICTION_ERROR_CHECK_LEVEL > 1
SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 0), 13, SPROP_NOSCALE|SPROP_CHANGES_OFTEN, CBaseEntity::SendProxy_AnglesX ),
SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 1), 13, SPROP_NOSCALE|SPROP_CHANGES_OFTEN, CBaseEntity::SendProxy_AnglesY ),
SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 2), 13, SPROP_NOSCALE|SPROP_CHANGES_OFTEN, CBaseEntity::SendProxy_AnglesZ ),
#else
SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 0), 13, SPROP_CHANGES_OFTEN, CBaseEntity::SendProxy_AnglesX ),
SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 1), 13, SPROP_CHANGES_OFTEN, CBaseEntity::SendProxy_AnglesY ),
SendPropAngle( SENDINFO_VECTORELEM(m_angRotation, 2), 13, SPROP_CHANGES_OFTEN, CBaseEntity::SendProxy_AnglesZ ),
#endif
SendPropFloat ( SENDINFO(m_fAIPitch), 0, SPROP_NOSCALE),
SendPropInt (SENDINFO(m_fFlags), PLAYER_FLAG_BITS, SPROP_UNSIGNED|SPROP_CHANGES_OFTEN, SendProxy_CropMarineFlagsToPlayerFlagBitsLength ),
SendPropFloat (SENDINFO(m_fInfestedTime), 6, SPROP_UNSIGNED, 0.0f, 64.0f ),
SendPropFloat (SENDINFO(m_fInfestedStartTime), 0, SPROP_NOSCALE ),
SendPropInt (SENDINFO(m_ASWOrders), 4),
SendPropArray3 ( SENDINFO_ARRAY3(m_iAmmo), SendPropInt( SENDINFO_ARRAY(m_iAmmo), 10, SPROP_UNSIGNED ) ),
SendPropBool (SENDINFO(m_bSlowHeal)),
SendPropInt (SENDINFO(m_iSlowHealAmount), 10 ),
SendPropBool (SENDINFO(m_bPreventMovement)),
SendPropFloat (SENDINFO(m_fFFGuardTime), 0, SPROP_NOSCALE ),
SendPropEHandle( SENDINFO ( m_hCurrentHack ) ),
SendPropEHandle ( SENDINFO( m_hGroundEntity ), SPROP_CHANGES_OFTEN ),
SendPropEHandle( SENDINFO ( m_hMarineFollowTarget ) ),
SendPropTime( SENDINFO(m_fStopMarineTime) ),
SendPropTime( SENDINFO(m_fNextMeleeTime) ),
SendPropTime( SENDINFO( m_flNextAttack ) ),
SendPropInt ( SENDINFO( m_iMeleeAttackID ), 7, SPROP_UNSIGNED ),
SendPropBool (SENDINFO(m_bOnFire)),
// emotes
SendPropInt ( SENDINFO( m_iEmote ), 8, SPROP_UNSIGNED ),
SendPropFloat ( SENDINFO( m_flLastMedicCall ) ),
SendPropFloat ( SENDINFO( m_flLastAmmoCall ) ),
// driving
SendPropEHandle( SENDINFO ( m_hASWVehicle ) ),
SendPropInt (SENDINFO(m_iVehicleSeat)),
SendPropBool (SENDINFO(m_bIsInVehicle)),
// knocked out
SendPropBool (SENDINFO(m_bKnockedOut)),
// turret
SendPropEHandle( SENDINFO ( m_hRemoteTurret ) ),
// We want to send all the marine's weapons to all the other marines
SendPropArray3( SENDINFO_ARRAY3(m_hMyWeapons), SendPropEHandle( SENDINFO_ARRAY(m_hMyWeapons) ) ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 0), 0, SPROP_NOSCALE ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 1), 0, SPROP_NOSCALE ),
SendPropFloat ( SENDINFO_VECTORELEM(m_vecViewOffset, 2), 0, SPROP_NOSCALE ),
#ifdef MELEE_CHARGE_ATTACKS
SendPropFloat ( SENDINFO(m_flMeleeHeavyKeyHoldStart), 0, SPROP_NOSCALE ),
#endif
SendPropInt ( SENDINFO( m_iForcedActionRequest ) ),
SendPropBool ( SENDINFO( m_bReflectingProjectiles ) ),
SendPropTime ( SENDINFO( m_flDamageBuffEndTime ) ),
SendPropTime ( SENDINFO( m_flElectrifiedArmorEndTime ) ),
SendPropDataTable( SENDINFO_DT( m_ElectrifiedArmorProjectileData ), &REFERENCE_SEND_TABLE( DT_RD_ProjectileData ) ),
SendPropInt ( SENDINFO( m_iPowerupType ) ),
SendPropTime ( SENDINFO( m_flPowerupExpireTime ) ),
SendPropBool ( SENDINFO( m_bPowerupExpires ) ),
SendPropFloat ( SENDINFO(m_flKnockdownYaw) ),
SendPropFloat ( SENDINFO( m_flMeleeYaw ) ),
SendPropBool ( SENDINFO( m_bFaceMeleeYaw ) ),
SendPropFloat ( SENDINFO( m_flPreventLaserSightTime ) ),
SendPropBool ( SENDINFO( m_bAICrouch ) ),
SendPropInt ( SENDINFO( m_iJumpJetting )),
SendPropVector ( SENDINFO( m_vecJumpJetEnd)),
SendPropFloat ( SENDINFO( m_fJumpJetDurationOverride ) ),
SendPropFloat ( SENDINFO( m_fJumpJetAnimationDurationOverride ) ),
SendPropBool ( SENDINFO( m_bForceWalking ) ),
SendPropBool ( SENDINFO( m_bRolls ) ),
SendPropInt ( SENDINFO( m_nMarineProfile ) ),
SendPropBool ( SENDINFO( m_bNightVision ) ),
SendPropInt ( SENDINFO( m_SpecialAbility ), NumBitsForCount( NUM_SPECIAL_ABILITIES ), SPROP_UNSIGNED ),
END_SEND_TABLE()
//---------------------------------------------------------
// Save/Restore
//---------------------------------------------------------
BEGIN_DATADESC( CASW_Marine )
DEFINE_FIELD( m_bSlowHeal, FIELD_BOOLEAN ),
DEFINE_FIELD( m_iSlowHealAmount, FIELD_INTEGER ),
DEFINE_FIELD( m_hRemoteTurret, FIELD_EHANDLE ),
DEFINE_FIELD( m_hASWVehicle, FIELD_EHANDLE ),
DEFINE_FIELD( m_iVehicleSeat, FIELD_INTEGER ),
DEFINE_FIELD( m_bIsInVehicle, FIELD_BOOLEAN ),
DEFINE_FIELD( m_iEmote, FIELD_INTEGER ),
DEFINE_FIELD( m_flLastMedicCall, FIELD_TIME ),
DEFINE_FIELD( m_flLastAmmoCall, FIELD_TIME ),
DEFINE_FIELD( m_Commander, FIELD_EHANDLE),
DEFINE_FIELD( m_hRemoteTurret, FIELD_EHANDLE ),
DEFINE_FIELD( m_fHoldingYaw, FIELD_FLOAT ),
DEFINE_FIELD( m_flFirstBurnTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flLastBurnTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flLastBurnSoundTime, FIELD_TIME ),
DEFINE_FIELD( m_fNextPainSoundTime, FIELD_TIME ),
DEFINE_FIELD( m_fStartedFiringTime, FIELD_TIME ),
DEFINE_FIELD( m_fNextSlowHealTick, FIELD_FLOAT ),
DEFINE_FIELD( m_fInfestedTime, FIELD_TIME ),
DEFINE_FIELD( m_fInfestedStartTime, FIELD_TIME ),
DEFINE_FIELD( m_fStopFacingPointTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fLastASWThink, FIELD_TIME ),
DEFINE_FIELD( m_iSlowHealAmount, FIELD_INTEGER ),
DEFINE_FIELD( m_iInfestCycle, FIELD_INTEGER ),
DEFINE_FIELD( m_fLastASWThink, FIELD_INTEGER ),
DEFINE_FIELD( m_Commander, FIELD_EHANDLE),
DEFINE_FIELD( m_bHacking, FIELD_BOOLEAN ),
DEFINE_FIELD( m_hCurrentHack, FIELD_EHANDLE),
DEFINE_FIELD( m_bKnockedOut, FIELD_BOOLEAN),
DEFINE_FIELD( m_fKickTime, FIELD_TIME ),
DEFINE_FIELD( m_fNextMeleeTime, FIELD_TIME ),
DEFINE_FIELD( m_fStopMarineTime, FIELD_TIME ),
DEFINE_FIELD( m_hLastWeaponSwitchedTo, FIELD_EHANDLE ),
// m_PlayerAnimState - recreated
// m_MarineSpeech - recreated
DEFINE_FIELD( m_MarineResource, FIELD_EHANDLE ),
DEFINE_FIELD( m_bWantsToFire, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bWantsToFire2, FIELD_BOOLEAN ),
DEFINE_FIELD( m_fMarineAimError, FIELD_FLOAT ),
DEFINE_FIELD( m_ASWOrders, FIELD_INTEGER ),
DEFINE_FIELD( m_fOverkillShootTime, FIELD_TIME ),
DEFINE_FIELD( m_vecOverkillPos, FIELD_VECTOR ),
DEFINE_FIELD( m_fUnfreezeTime, FIELD_TIME ),
DEFINE_FIELD( m_fFFGuardTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fLastStillTime, FIELD_TIME ),
DEFINE_FIELD( m_bDoneWoundedRebuke, FIELD_BOOLEAN ),
DEFINE_FIELD( m_vecMoveToOrderPos, FIELD_VECTOR ),
DEFINE_FIELD( m_fFriendlyFireDamage, FIELD_FLOAT ),
DEFINE_ARRAY( m_pRecentAttackers, FIELD_INTEGER, ASW_MOB_VICTIM_SIZE ),
DEFINE_FIELD( m_fLastMobDamageTime, FIELD_TIME ),
DEFINE_FIELD( m_bHasBeenMobAttacked, FIELD_BOOLEAN ),
DEFINE_FIELD( m_hInfestationCurer, FIELD_EHANDLE ),
DEFINE_FIELD( m_hInfestationCureWeapon, FIELD_EHANDLE ),
DEFINE_FIELD( m_bOnFire, FIELD_BOOLEAN ),
DEFINE_FIELD( m_fLastShotAlienTime, FIELD_TIME ),
DEFINE_FIELD( m_fLastShotJunkTime, FIELD_TIME ),
DEFINE_FIELD( m_fUsingEngineeringAura, FIELD_TIME ),
DEFINE_FIELD( m_fCachedIdealSpeed, FIELD_FLOAT ),
DEFINE_FIELD( m_fNextAlienWalkDamage, FIELD_FLOAT ),
DEFINE_FIELD( m_iLightLevel, FIELD_INTEGER ),
DEFINE_FIELD( m_fLastFriendlyFireTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fPrevFriendlyFireTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fLastAmmoCheckTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fFriendlyFireAbsorptionTime, FIELD_FLOAT ),
DEFINE_FIELD( m_vecMeleeStartPos, FIELD_VECTOR ),
DEFINE_FIELD( m_bFaceMeleeYaw, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flMeleeStartTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flMeleeLastCycle, FIELD_FLOAT ),
DEFINE_FIELD( m_flMeleeYaw, FIELD_FLOAT ),
DEFINE_FIELD( m_bMeleeCollisionDamage, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bMeleeComboKeypressAllowed, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bMeleeComboKeyPressed, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bMeleeComboTransitionAllowed, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bMeleeMadeContact, FIELD_BOOLEAN ),
DEFINE_FIELD( m_iUsableItemsOnMeleePress, FIELD_INTEGER ),
DEFINE_FIELD( m_iMeleeAllowMovement, FIELD_INTEGER ),
DEFINE_FIELD( m_bMeleeKeyReleased, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bPlayedMeleeHitSound, FIELD_BOOLEAN ),
#ifdef MELEE_CHARGE_ATTACKS
DEFINE_FIELD( m_flMeleeHeavyKeyHoldStart, FIELD_FLOAT ),
DEFINE_FIELD( m_bMeleeHeavyKeyHeld, FIELD_BOOLEAN ),
#endif
DEFINE_FIELD( m_bMeleeChargeActivate, FIELD_BOOLEAN ),
DEFINE_AUTO_ARRAY( m_iPredictedEvent, FIELD_INTEGER ),
DEFINE_AUTO_ARRAY( m_flPredictedEventTime, FIELD_FLOAT ),
DEFINE_FIELD( m_iNumPredictedEvents, FIELD_INTEGER ),
DEFINE_FIELD( m_iOnLandMeleeAttackID, FIELD_INTEGER ),
DEFINE_FIELD( m_flNextStumbleTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flDamageBuffEndTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flElectrifiedArmorEndTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flLastSquadEnemyTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flLastSquadShotAlienTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flLastHurtAlienTime, FIELD_FLOAT ),
DEFINE_FIELD( m_flLastAttributeExplosionSound, FIELD_TIME ),
DEFINE_FIELD( m_iPowerupType, FIELD_INTEGER ),
DEFINE_FIELD( m_flPowerupExpireTime, FIELD_FLOAT ),
DEFINE_FIELD( m_bPowerupExpires, FIELD_BOOLEAN ),
DEFINE_KEYFIELD( m_nMarineProfile, FIELD_INTEGER, "MarineProfile" ),
DEFINE_KEYFIELD( m_SpecialAbility, FIELD_INTEGER, "SpecialAbility" ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "AddPoints", InputAddPoints ),
DEFINE_OUTPUT( m_TotalPoints, "TotalPoints" ),
END_DATADESC()
BEGIN_ENT_SCRIPTDESC( CASW_Marine, CASW_Inhabitable_NPC, "Marine" )
DEFINE_SCRIPTFUNC( IsInhabited, "true if the marine is a player, false if the marine is a bot" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetCommander, "GetCommander", "get the player that owns the marine" )
DEFINE_SCRIPTFUNC_NAMED( ScriptExtinguish, "Extinguish", "Extinguish a burning marine.")
DEFINE_SCRIPTFUNC_NAMED( ScriptIgnite, "Ignite", "Ignites the marine into flames." )
DEFINE_SCRIPTFUNC_NAMED( ScriptBecomeInfested, "BecomeInfested", "Infests the marine." )
DEFINE_SCRIPTFUNC_NAMED( ScriptCureInfestation, "CureInfestation", "Cures an infestation." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGiveAmmo, "GiveAmmo", "Gives the marine ammo for the specified ammo index." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGiveWeapon, "GiveWeapon", "Gives the marine a weapon." )
DEFINE_SCRIPTFUNC_NAMED( ScriptDropWeapon, "DropWeapon", "Makes the marine drop a weapon." )
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveWeapon, "RemoveWeapon", "Removes a weapon from the marine." )
DEFINE_SCRIPTFUNC_NAMED( ScriptSwitchWeapon, "SwitchWeapon", "Make the marine switch to a weapon" )
DEFINE_SCRIPTFUNC_NAMED( Script_GetInvTable, "GetInvTable", "Returns a table of the marine's inventory data." )
DEFINE_SCRIPTFUNC_NAMED( Script_GetInventoryTable, "GetInventoryTable", "Fills the passed table with the marine's inventory." )
DEFINE_SCRIPTFUNC_NAMED( Script_GetMarineName, "GetMarineName", "Returns the marine's name, translated to the host's language." )
DEFINE_SCRIPTFUNC_NAMED( Script_GetMarineProfile, "GetMarineProfile", "Returns the marine's profile index (ASW_MARINE_PROFILE_SARGE, etc.)" )
DEFINE_SCRIPTFUNC_NAMED( Script_Speak, "Speak", "Makes the marine speak a response rules concept." )
DEFINE_SCRIPTFUNC( IsInfested, "Returns true if the marine is infested." )
DEFINE_SCRIPTFUNC( IsElectrifiedArmorActive, "Returns true if the marine currently has electrified armor (the effect, not the item)." )
DEFINE_SCRIPTFUNC( SetMarineRolls, "Send true to make marine roll, send false to make marine jump" )
DEFINE_SCRIPTFUNC( SetKnockedOut, "Used to knock out and incapacitate a marine, or revive them." )
DEFINE_SCRIPTFUNC( SetSpawnZombineOnDeath, "Used to spawn a zombine in the place of a marine after death." )
DEFINE_SCRIPTFUNC( SetNightVision, "Activate night vision on a marine without needing the equipment." )
DEFINE_SCRIPTFUNC_NAMED( ScriptKnockdown, "Knockdown", "Knocks down the marine with desired velocity." )
DEFINE_SCRIPTFUNC_NAMED( ScriptOrderHackArea,"OrderHackArea", "Order the marine to hack a computer or button area." )
DEFINE_SCRIPTFUNC_NAMED( OrderUseOffhandItem, "OrderUseItem", "Order the marine to use an item (welder, ammo satchel, etc)")
DEFINE_SCRIPTFUNC_NAMED( ScriptOrderFollowSquadLeader, "OrderFollowSquadLeader", "Order the marine to follow the squad leader" )
DEFINE_SCRIPTFUNC_NAMED( ScriptOrderHoldPosition, "OrderHoldPosition", "Order the marine to stop moving" )
DEFINE_SCRIPTFUNC_NAMED( ScriptOrderMoveTo, "OrderMoveTo", "Order the marine to move to a specified position" )
DEFINE_SCRIPTFUNC_NAMED( ScriptAddSlowHeal, "AddSlowHeal", "Heal a marine over time." )
DEFINE_SCRIPTFUNC( SetHealRateScale, "Set heal rate scale; you should do this in the marine_healed game event. Default heal rate scale is 2 for guns and 1 for other healing items." )
END_SCRIPTDESC()
extern ConVar weapon_showproficiency;
extern ConVar asw_leadership_radius;
extern ConVar asw_buzzer_poison_duration;
extern ConVar asw_debug_marine_chatter;
extern ConVar asw_debug_medals;
extern ConVar ai_show_hull_attacks;
extern ConVar asw_medal_melee_hits;
extern int AE_MARINE_KICK;
extern int AE_MARINE_UNFREEZE;
ConVar asw_marine_stumble_on_damage( "asw_marine_stumble_on_damage", "1", FCVAR_CHEAT, "Marine stumbles when he takes damage" );
ConVar asw_stumble_interval( "asw_stumble_interval", "2.0", FCVAR_CHEAT, "Min time between stumbles" );
ConVar asw_knockdown_interval( "asw_knockdown_interval", "3.0", FCVAR_CHEAT, "Min time between knockdowns" );
extern ConVar asw_marine_fall_damage;
extern ConVar asw_marine_fatal_fall_speed;
extern ConVar asw_marine_max_safe_fall_speed;
extern ConVar asw_marine_land_on_floating_object;
extern ConVar asw_marine_min_bounce_speed;
extern ConVar asw_marine_fall_punch_threshold;
ConVar asw_screenflash("asw_screenflash", "0", FCVAR_CHEAT, "Alpha of damage screen flash");
ConVar asw_damage_indicator( "asw_damage_indicator", "1", FCVAR_CHEAT, "If set, directional damage indicator is shown" );
ConVar asw_marine_server_ragdoll("asw_marine_server_ragdoll", "0", FCVAR_CHEAT, "If set, marines will have server ragdolls instead of clientside ones.");
ConVar asw_marine_death_protection( "asw_marine_death_protection", "1", FCVAR_CHEAT, "Prevents marines from dying in one hit, unless on 1 health" );
ConVar asw_marine_melee_distance("asw_marine_melee_distance", "50", FCVAR_CHEAT, "How far the marine can kick");
ConVar asw_marine_melee_damage("asw_marine_melee_damage", "20", FCVAR_CHEAT, "How much damage the marine's kick does");
ConVar asw_marine_melee_force("asw_marine_melee_force", "200000", FCVAR_CHEAT, "Marine kick force = this / dist");
ConVar asw_marine_melee_max_force("asw_marine_melee_max_force", "10000", FCVAR_CHEAT, "Maximum force allowed");
ConVar asw_marine_melee_kick_lift("asw_marine_melee_kick_lift", "0.2", FCVAR_CHEAT, "Upwards Z-Force given to kicked objects");
ConVar asw_marine_ai_acceleration("asw_marine_ai_acceleration", "4.0f", FCVAR_CHEAT, "Acceleration boost for marine AI");
ConVar asw_marine_scan_beams( "asw_marine_scan_beams", "0", FCVAR_CHEAT, "Draw scan beams for marines holding position" );
ConVar asw_debug_marine_damage( "asw_debug_marine_damage", "0", FCVAR_CHEAT, "Show damage marines are taking" );
ConVar asw_marine_ff( "asw_marine_ff", "1", FCVAR_CHEAT, "Marine friendly fire setting (0 = FFGuard, 1 = Normal (based on mission difficulty), 2 = Always max)", true, 0, true, 2 );
ConVar asw_marine_ff_guard_time( "asw_marine_ff_guard_time", "5.0", FCVAR_CHEAT, "Amount of time firing is disabled for when activating friendly fire guard" );
ConVar asw_marine_ff_dmg_base( "asw_marine_ff_dmg_base", "1.0", FCVAR_CHEAT, "Amount of friendly fire damage on mission difficulty 5" );
ConVar asw_marine_ff_dmg_step("asw_marine_ff_dmg_step", "0.2", FCVAR_CHEAT, "Amount friendly fire damage is modified per mission difficuly level away from 5");
ConVar asw_marine_ff_absorption_decay_rate("asw_marine_ff_absorption_decay_rate", "0.33f", FCVAR_CHEAT, "Rate of FF absorption decay");
ConVar asw_marine_ff_absorption_build_rate("asw_marine_ff_absorption_build_rate", "0.25f", FCVAR_CHEAT, "Rate of FF absorption decay build up when being shot by friendlies");
ConVar asw_marine_burn_time_easy( "asw_marine_burn_time_easy", "6", FCVAR_CHEAT, "Amount of time marine burns for when ignited on easy difficulty" );
ConVar asw_marine_burn_time_normal( "asw_marine_burn_time_normal", "8", FCVAR_CHEAT, "Amount of time marine burns for when ignited on normal difficulty" );
ConVar asw_marine_burn_time_hard( "asw_marine_burn_time_hard", "12", FCVAR_CHEAT, "Amount of time marine burns for when ignited on hard difficulty" );
ConVar asw_marine_burn_time_insane( "asw_marine_burn_time_insane", "15", FCVAR_CHEAT, "Amount of time marine burns for when ignited on insane difficulty" );
ConVar asw_marine_burn_time_min_fraction( "asw_marine_burn_time_min_fraction", "0.1875", FCVAR_CHEAT, "Minimum fraction of the burn time a marine can be ignited for due to friendly fire protection" );
ConVar asw_marine_burn_time_since_last_ff_scale( "asw_marine_burn_time_since_last_ff_scale", "1.0", FCVAR_CHEAT, "Number of seconds taken off of the burn time for each second since the last friendly fire incident" );
ConVar asw_marine_time_until_ignite_expire( "asw_marine_time_until_ignite_expire", "2.0", FCVAR_CHEAT, "Amount of time until repeated burn damage counter expires" );
ConVar asw_marine_time_until_ignite( "asw_marine_time_until_ignite", "0.7", FCVAR_CHEAT, "Amount of time before a marine ignites from taking repeated burn damage" );
ConVar asw_marine_time_until_ignite_hcff( "asw_marine_time_until_ignite_hcff", "0.2", FCVAR_CHEAT, "Amount of time before a marine ignites from taking repeated burn damage (hardcore ff)" );
ConVar asw_marine_time_until_ignite_flamer( "asw_marine_time_until_ignite_flamer", "0.0", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite for the M868 Flamer Unit" );
ConVar asw_marine_time_until_ignite_hcff_flamer( "asw_marine_time_until_ignite_hcff_flamer", "0.0", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite_hcff for the M868 Flamer Unit" );
ConVar asw_marine_time_until_ignite_grenade( "asw_marine_time_until_ignite_grenade", "-1", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite for M42 Vindicator grenades and NA-23 Incendiary Grenades" );
ConVar asw_marine_time_until_ignite_hcff_grenade( "asw_marine_time_until_ignite_hcff_grenade", "-1", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite_hcff for M42 Vindicator grenades and NA-23 Incendiary Grenades" );
ConVar asw_marine_time_until_ignite_mines( "asw_marine_time_until_ignite_mines", "-1", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite for M478 Proximity Incendiary Mines" );
ConVar asw_marine_time_until_ignite_hcff_mines( "asw_marine_time_until_ignite_hcff_mines", "-1", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite_hcff for M478 Proximity Incendiary Mines" );
ConVar asw_marine_time_until_ignite_plasma( "asw_marine_time_until_ignite_plasma", "-1", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite for the G521 Plasma Thrower" );
ConVar asw_marine_time_until_ignite_hcff_plasma( "asw_marine_time_until_ignite_hcff_plasma", "-1", FCVAR_CHEAT, "If non-negative, overrides asw_marine_time_until_ignite_hcff for the G521 Plasma Thrower" );
ConVar asw_marine_roll_through_firewall( "asw_marine_roll_through_firewall", "1", FCVAR_CHEAT, "If set, marines cannot be ignited by M478 Proximity Incendiary Mines while rolling" );
ConVar asw_mad_firing_break( "asw_mad_firing_break", "4", FCVAR_CHEAT, "Point at which the mad firing counter triggers the mad firing speech" );
ConVar asw_mad_firing_decay( "asw_mad_firing_decay", "0.15", FCVAR_CHEAT, "Tick down rate of the mad firing counter" );
ConVar asw_marine_special_idle_chatter_chance( "asw_marine_special_idle_chatter_chance", "0.25", FCVAR_CHEAT, "Chance of marine doing a special idle chatter" );
ConVar asw_force_ai_fire("asw_force_ai_fire", "0", FCVAR_CHEAT, "Forces all AI marines to fire constantly");
ConVar asw_realistic_death_chatter( "asw_realistic_death_chatter", "0", FCVAR_CHEAT, "If true, only 1 nearby marine will shout about marine deaths" );
ConVar asw_god( "asw_god", "0", FCVAR_CHEAT, "Set to 1 to make marines invulnerable" );
ConVar asw_god_effects( "asw_god_effects", "0", FCVAR_CHEAT, "If 1, marine health will not be affected by damage, but they will still take other effects" );
ConVar asw_marine_damage_force_scale( "asw_marine_damage_force_scale", "0", FCVAR_CHEAT, "Damage force in marine damage is applied as a velocity impulse scaled by this factor" );
ConVar rd_infinite_ammo( "rd_infinite_ammo", "0", FCVAR_CHEAT, "Marine's active weapon will never run out of ammo" );
extern ConVar asw_sentry_friendly_fire_scale;
extern ConVar asw_marine_ff_absorption;
ConVar asw_movement_direction_tolerance( "asw_movement_direction_tolerance", "30.0", FCVAR_CHEAT );
ConVar asw_movement_direction_interval( "asw_movement_direction_interval", "0.5", FCVAR_CHEAT );
extern ConVar rd_allow_revive;
extern ConVar rd_revive_health;
ConVar rd_marine_poison_recover_delay( "rd_marine_poison_recover_delay", "2", FCVAR_CHEAT, "time after being poisoned before suit antitoxin begins to act" );
ConVar rd_marine_poison_recover_tick( "rd_marine_poison_recover_tick", "0.5", FCVAR_CHEAT, "time between hitpoints restored by antitoxin" );
ConVar asw_leadership_resist_scale( "asw_leadership_resist_scale", "0.5", FCVAR_CHEAT, "Incoming damage scale for leadership bonus." );
ConVar rd_marine_spawn_zombine_on_death_chance( "rd_marine_spawn_zombine_on_death_chance", "0.0", FCVAR_CHEAT, "Chance to spawn a zombine when a marine dies from an alien" );
extern ConVar asw_marine_gun_offset_z;
float CASW_Marine::s_fNextMadFiringChatter = 0;
float CASW_Marine::s_fNextIdleChatterTime = 0;
enum eRip_Type
{
RIP_PARASITE = 0,
RIP_EXPLOSION
};
void CASW_Marine::DoAnimationEvent( PlayerAnimEvent_t event )
{
if (gpGlobals->maxClients > 1 &&
(event == PLAYERANIMEVENT_RELOAD || event == PLAYERANIMEVENT_JUMP || event == PLAYERANIMEVENT_WEAPON_SWITCH
|| event == PLAYERANIMEVENT_HEAL || event == PLAYERANIMEVENT_KICK || event == PLAYERANIMEVENT_THROW_GRENADE
|| event == PLAYERANIMEVENT_BAYONET || event == PLAYERANIMEVENT_PICKUP
|| ( event >= PLAYERANIMEVENT_MELEE && event <= PLAYERANIMEVENT_MELEE_LAST )
|| event == PLAYERANIMEVENT_DROP_MAGAZINE_GIB ) )
{
TE_MarineAnimEventExceptCommander( this, event ); // Send to any clients other than my commander who can see this guy.
}
else
{
TE_MarineAnimEvent( this, event ); // Send to all clients who can see this guy.
}
MDLCACHE_CRITICAL_SECTION();
m_PlayerAnimState->DoAnimationEvent(event);
}
void CASW_Marine::DoAnimationEventToAll( PlayerAnimEvent_t event )
{
TE_MarineAnimEvent( this, event ); // Send to all clients who can see this guy.
MDLCACHE_CRITICAL_SECTION();
m_PlayerAnimState->DoAnimationEvent( event );
}
void CASW_Marine::HandleAnimEvent( animevent_t *pEvent )
{
int nEvent = pEvent->Event();
if( !IsInhabited() && nEvent == AE_MELEE_DAMAGE )
{
float flYawStart, flYawEnd;
flYawStart = flYawEnd = 0.0f;
const char* options = pEvent->options;
const char *p = options;
char token[256];
if ( options[0] )
{
// Read in yaw start
p = nexttoken( token, p, ' ', sizeof(token) );
if( token[0] )
{
flYawStart = atof( token );
}
// Read in yaw end
p = nexttoken( token, p, ' ', sizeof(token) );
if( token[0] )
{
flYawEnd = atof( token );
}
}
DoMeleeDamageTrace( flYawStart, flYawEnd );
return;
}
if ( GetCurrentMeleeAttack() )
{
if ( !GetCurrentMeleeAttack()->AllowNormalAnimEvent( this, nEvent ) )
return;
}
if ( nEvent == AE_MARINE_UNFREEZE )
{
Msg("AE_MARINE_UNFREEZE\n");
RemoveFlag(FL_FROZEN);
return;
}
else if ( nEvent == AE_ASW_FOOTSTEP || nEvent == AE_MARINE_FOOTSTEP )
{
// footsteps are played clientside
return;
}
BaseClass::HandleAnimEvent( pEvent );
}
CASW_Marine::CASW_Marine() : m_RecentMeleeHits( 16, 16 )
{
m_flLastEnemyYaw = 0;
m_flLastEnemyYawTime = 0;;
m_flAIYawOffset = 0;
m_flNextYawOffsetTime = 0;
m_bAICrouch = false;
m_MarineResource = NULL;
m_fUnfreezeTime = 0;
m_PlayerAnimState = CreatePlayerAnimState(this, this, LEGANIM_9WAY, false);
UseClientSideAnimation();
m_HackedGunPos = Vector( 0, 0, asw_marine_gun_offset_z.GetFloat() );
m_MarineSpeech = new CASW_MarineSpeech(this);
m_flHealRateScale = 1.0f;
m_fNextSlowHealTick = 0;
m_fLastASWThink = gpGlobals->curtime;
m_fInfestedTime = 0;
m_fInfestedStartTime = 0;
m_iInfestCycle = 0;
m_flFirstBurnTime = 0;
m_flLastBurnTime = 0;
m_flLastBurnSoundTime = 0;
m_fNextPainSoundTime = 0;
m_fStopFacingPointTime = 0;
m_fHoldingYaw = 0;
m_hKnockedOutRagdoll = NULL;
m_fKickTime = 0;
m_fNextMeleeTime = 0;
#ifdef MELEE_CHARGE_ATTACKS
m_flMeleeHeavyKeyHoldStart = 0;
#endif
m_fMadFiringCounter = 0;
m_fUsingEngineeringAura = 0;
m_bDoneOrderChatter = false;
m_szInitialCommanderNetworkID[0] = '\0';
m_bWaitingForWeld = false;
m_flBeginWeldTime = 0.0f;
m_Commander = NULL;
// ai control of firing
m_bWantsToFire = false;
m_bWantsToFire2 = false;
m_fMarineAimError = 0;
m_fStopMarineTime = 0;
m_flTimeNextScanPing = 0;
m_flPreventLaserSightTime = 0;
m_fLastStuckTime = 0;
m_flFirstStuckTime = 0;
m_fIdleChatterDelay = random->RandomInt(20, 30);
m_fRandomFacing = 0;
m_fNewRandomFacingTime = 0;
m_fCachedIdealSpeed = 300.0f;
m_flNextBreadcrumbTime = 0;
m_flNextAmmoScanTime = 0;
m_flResetAmmoIgnoreListTime = 0;
m_iPowerupType = -1;
m_flPowerupExpireTime = -1;
m_bPowerupExpires = false;
m_flLastSquadEnemyTime = 0.0f;
m_flLastSquadShotAlienTime = 0.0f;
m_flLastHurtAlienTime = 0.0f;
m_flLastGooScanTime = 0.0f;
m_fLastAmmoCheckTime = 0.0f;
m_nFastReloadsInARow = 0;
for ( int i = 0; i < ASW_MARINE_HISTORY_POSITIONS; i++ )
{
m_PositionHistory[ i ].vecPosition = vec3_origin;
m_PositionHistory[ i ].flTime = 0.0f;
}
m_nPositionHistoryTail = -1;
// rappel
m_hLine = NULL;
m_bWaitingToRappel = false;
m_bOnGround = true;
m_vecRopeAnchor = vec3_origin;
for ( int i = 0; i < NELEMS( m_flFailedPathingTime ); i++ )
{
m_flFailedPathingTime[i] = FLT_MIN;
}
m_bAirStrafeUsed = false;
m_nIndexActWeapBeforeTempPickup = 0;
m_iPoisonHeal = 0;
m_flNextPoisonHeal = -1;
extern ConVar asw_marine_rolls;
m_bRolls = asw_marine_rolls.GetBool();
m_nMarineProfile = -1;
m_SpecialAbility = SPECIAL_ABILITY_FAST_RELOAD;
m_bSpawnZombineOnDeath = false;
m_bNightVision = false;
}
CASW_Marine::~CASW_Marine()
{
if ( m_MarineResource )
GetMarineResource()->SetMarineEntity(NULL);
m_PlayerAnimState->Release();
delete m_MarineSpeech;
}
// riflemod: methods used for reviving
void CASW_Marine::ActivateUseIcon( CASW_Inhabitable_NPC *pNPC, int nHoldType )
{
CASW_Marine *pMarine = AsMarine( pNPC );
if ( !pMarine )
return;
if ( nHoldType == ASW_USE_HOLD_START )
{
if ( !pMarine->m_hUsingEntity )
{
pMarine->GetMarineSpeech()->Chatter( CHATTER_USE );
}
pMarine->StartUsing( this );
}
else if ( nHoldType == ASW_USE_HOLD_RELEASE_FULL )
{
if ( m_bKnockedOut )
{
CASW_Marine_Resource *pMR = GetMarineResource();
CASW_Marine_Resource *pMROther = pMarine ? pMarine->GetMarineResource() : NULL;
if ( pMR && pMROther )
{
char szName[ 256 ];
pMR->GetDisplayName( szName, sizeof( szName ) );
char szNameOther[ 256 ];
pMROther->GetDisplayName( szNameOther, sizeof( szNameOther ) );
UTIL_ClientPrintAll( ASW_HUD_PRINTTALKANDCONSOLE, "#rd_revived_marine", szNameOther, szName );
}
pMarine->StopUsing();
SetHealth( rd_revive_health.GetInt() );
SetKnockedOut( false );
GetMarineSpeech()->Chatter( CHATTER_THANKS );
CASW_Player *pPlayer = pMarine->GetCommander();
if ( pPlayer && pMarine->IsInhabited() )
{
pPlayer->m_hUseKeyDownEnt = NULL;
pPlayer->m_flUseKeyDownTime = 0.0f;
}
IGameEvent * event = gameeventmanager->CreateEvent( "marine_revived" );
if ( event )
{
event->SetInt( "entindex", entindex() );
event->SetInt( "reviver", pMarine->entindex() );
gameeventmanager->FireEvent( event );
}
}
}
else if ( nHoldType == ASW_USE_RELEASE_QUICK )
{
pMarine->StopUsing();
}
}
void CASW_Marine::NPCUsing( CASW_Inhabitable_NPC *pNPC, float deltatime )
{
}
void CASW_Marine::NPCStartedUsing( CASW_Inhabitable_NPC *pNPC )
{
}
void CASW_Marine::NPCStoppedUsing( CASW_Inhabitable_NPC *pNPC )
{
}
// create our custom senses class
CAI_Senses *CASW_Marine::CreateSenses()
{
CAI_Senses *pSenses = new CASW_Marine_AI_Senses;
pSenses->SetOuter( this );
return pSenses;
}
void CASW_Marine::SetHeightLook( float flHeightLook )
{
CAI_Senses *pSenses = GetSenses();
Assert(pSenses);
if ( pSenses )
{
CASW_Marine_AI_Senses *pMarineSenses = dynamic_cast<CASW_Marine_AI_Senses*>( pSenses );
if ( pMarineSenses )
pMarineSenses->SetHeightLook( flHeightLook );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CASW_Marine::SelectModel()
{
Assert( !ASWGameRules() || ASWGameRules()->GetGameState() == ASW_GS_NONE || ( m_MarineResource == NULL ) != ( m_nMarineProfile == -1 ) );
if ( m_MarineResource == NULL && m_nMarineProfile == -1 )
{
// use sarge so we don't crash if ent_create spawns a marine
m_nMarineProfile = 0;
}
SelectModelFromProfile();
}
void CASW_Marine::UpdateOnRemove( void )
{
BaseClass::UpdateOnRemove();
StopUsing();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CASW_Marine::Spawn( void )
{
Precache();
BaseClass::Spawn();
SelectModel();
SetModel( STRING( GetModelName() ) );
SetHullType(HULL_HUMAN);
SetHullSizeNormal();
SetBodygroup( 1, m_nSkin );
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_NOT_STANDABLE );
SetBloodColor( BLOOD_COLOR_RED );
m_flFieldOfView = 0.02;
m_NPCState = NPC_STATE_NONE;
CapabilitiesClear();
CapabilitiesAdd( bits_CAP_MOVE_GROUND );
SetMoveType( MOVETYPE_STEP );
m_HackedGunPos = Vector( 0, 0, asw_marine_gun_offset_z.GetFloat() );
// Marines collide/moveprobe as players.
m_nAITraceMask = MASK_PLAYERSOLID;
CapabilitiesRemove( bits_CAP_FRIENDLY_DMG_IMMUNE | bits_CAP_NO_HIT_PLAYER );
// // riflemod: changed COLLISION_GROUP_PLAYER to ASW_COLLISION_GROUP_GRUBS, ASW_COLLISION_GROUP_GRUBS is used by bots. Setting it here also, because otherwise bots get COLLISION_GROUP_PLAYER
// SetCollisionGroup( ASW_COLLISION_GROUP_GRUBS );
AddEFlags( EFL_NO_DISSOLVE | EFL_NO_MEGAPHYSCANNON_RAGDOLL | EFL_NO_PHYSCANNON_INTERACTION );
// join the marines team
ChangeFaction( FACTION_MARINES );
SetHealth( 100 );
NPCInit();
// BenLubar(deathmatch-improvements): in deathmatch mode, the marine
// resource stays inhabited or uninhabited during respawns.
if ( !ASWDeathmatchMode() )
{
SetInhabited( false );
}
m_bWasFollowing = m_nMarineProfile == -1;
m_ASWOrders = m_bWasFollowing ? ASW_ORDER_FOLLOW : ASW_ORDER_HOLD_POSITION;
m_flFieldOfView = ASW_HOLD_POSITION_FOV_DOT;
SetDistLook( ASW_HOLD_POSITION_SIGHT_RANGE );
m_flDistTooFar = 1024.0f;
SetAIWalkable(false);
// bias the box south a bit - this feels better for FF collisions with the tilted cam
Vector vecSurroundingMins( -16, -18, 0 );
Vector vecSurroundingMaxs( 16, 14, 70 );
CollisionProp()->SetSurroundingBoundsType( USE_SPECIFIED_BOUNDS, &vecSurroundingMins, &vecSurroundingMaxs );
// make sure his move_x/y pose parameters are at full moving forwards, so the AI follow movement will detect some sequence motion when calculating goal speed
SetPoseParameter( "move_x", 1.0f );
SetPoseParameter( "move_y", 0.0f );
IGameEvent * event = gameeventmanager->CreateEvent( "marine_spawn" );
if ( event )
{
CASW_Player *pPlayer = GetCommander();
event->SetInt( "userid", ( pPlayer ? pPlayer->GetUserID() : 0 ) );
event->SetInt( "entindex", entindex() );
gameeventmanager->FireEvent( event );
}
UTIL_SetSize( this, GetHullMins(), GetHullMaxs() );
CFunc_ASW_Fade::DisableCollisionsWithMarine( this );
}
unsigned int CASW_Marine::PhysicsSolidMaskForEntity( void ) const
{
return MASK_PLAYERSOLID;
}
void CASW_Marine::Precache()
{
SelectModel();
BaseClass::Precache();
PrecacheSpeech();
PrecacheModel("models/swarm/shouldercone/shouldercone.mdl");
PrecacheModel("models/swarm/shouldercone/lasersight.mdl");
PrecacheModel("models/swarm/marine/gibs/marine_gib_chest.mdl");
PrecacheModel("models/swarm/marine/gibs/marine_gib_head.mdl");
PrecacheModel("models/swarm/marine/gibs/femalemarine_gib_head.mdl");
PrecacheModel("models/swarm/marine/gibs/marine_gib_leftarm.mdl");
PrecacheModel("models/swarm/marine/gibs/marine_gib_rightarm.mdl");
PrecacheModel("models/swarm/marine/gibs/marine_gib_leftleg.mdl");
PrecacheModel("models/swarm/marine/gibs/marine_gib_rightleg.mdl");
PrecacheModel("models/swarm/marine/gibs/marine_gib_pelvis.mdl");
PrecacheModel( "models/zombie/fallen_marine.mdl" );
UTIL_PrecacheOther( "npc_zombine" );
PrecacheModel( "cable/cable.vmt" );
PrecacheScriptSound( "ASW.MarineMeleeAttack" );
PrecacheScriptSound( "ASW.MarineMeleeAttackFP" );
PrecacheScriptSound( "ASW.MarinePowerFistAttack" );
PrecacheScriptSound( "ASW.MarinePowerFistAttackFP" );
PrecacheScriptSound( "ASW.MarinePowerFistHitWorld" );
PrecacheScriptSound( "ASW_Weapon_Flamer.FlameLoop" );
PrecacheScriptSound( "ASW_Weapon_Flamer.FlameStop" );
PrecacheScriptSound( "ASW_Weapon_Minigun.MinigunLoop" );
PrecacheScriptSound( "ASWFlashlight.FlashlightToggle" );
PrecacheScriptSound( "ASW_Flare.IgniteFlare" );
PrecacheScriptSound( "ASWScanner.Idle1" );
PrecacheScriptSound( "ASWScanner.Idle2" );
PrecacheScriptSound( "ASWScanner.Idle3" );
PrecacheScriptSound( "ASWScanner.Idle4" );
PrecacheScriptSound( "ASWScanner.Idle5" );
PrecacheScriptSound( "ASWScanner.Idle6" );
PrecacheScriptSound( "ASWScanner.Idle7" );
PrecacheScriptSound( "ASWScanner.Idle8" );
PrecacheScriptSound( "ASWScanner.Idle9" );
PrecacheScriptSound( "ASWScanner.Idle10" );
PrecacheScriptSound( "ASWScanner.Idle11" );
PrecacheScriptSound( "ASWScanner.Idle12" );
PrecacheScriptSound( "ASWScanner.Idle13" );
PrecacheScriptSound( "ASWScanner.Warning1" );
PrecacheScriptSound( "ASWScanner.Warning2" );
PrecacheScriptSound( "ASWScanner.Warning3" );
PrecacheScriptSound( "ASWScanner.Warning4" );
PrecacheScriptSound( "ASWScanner.Warning5" );
PrecacheScriptSound( "ASWScanner.Warning6" );
PrecacheScriptSound( "ASWScanner.Warning7" );
PrecacheScriptSound( "ASWScanner.Warning8" );
PrecacheScriptSound( "ASWScanner.Warning9" );
PrecacheScriptSound( "ASWScanner.Drawing" );
PrecacheScriptSound( "ASW_Weapon.Reload3" );
PrecacheScriptSound( "ASWInterface.Button3" );
PrecacheScriptSound( "Marine.DeathBeep" );
PrecacheScriptSound( "ASW.MarineImpactFP" );
PrecacheScriptSound( "ASW.MarineImpact" );
PrecacheScriptSound( "ASW.MarineImpactHeavyFP" );
PrecacheScriptSound( "ASW.MarineImpactHeavy" );
PrecacheScriptSound( "ASW.MarineMeleeAttack" );
PrecacheScriptSound( "ASW_Weapon.LowAmmoClick" );
PrecacheScriptSound( "ASW_ElectrifiedSuit.TurnOn" );
PrecacheScriptSound( "ASW_ElectrifiedSuit.Loop" );
PrecacheScriptSound( "ASW_ElectrifiedSuit.LoopFP" );
PrecacheScriptSound( "ASW_ElectrifiedSuit.OffFP" );
PrecacheScriptSound( "ASW.MarineBurnPain_NoIgnite" );
PrecacheScriptSound( "ASW_Extinguisher.OnLoop" );
PrecacheScriptSound( "ASW_Extinguisher.Stop" );
PrecacheScriptSound( "ASW_JumpJet.Activate" );
PrecacheScriptSound( "ASW_JumpJet.Loop" );
PrecacheScriptSound( "ASW_JumpJet.Impact" );
PrecacheScriptSound( "ASW_Blink.Blink" );
PrecacheScriptSound( "ASW_Blink.Teleport" );
PrecacheScriptSound( "ASW_XP.LevelUp" );
PrecacheScriptSound( "ASW_Leadership.Accuracy" );
PrecacheScriptSound( "ASW_Leadership.Resist" );
PrecacheScriptSound( "ASW_Weapon.InvalidDestination" );
PrecacheParticleSystem( "smallsplat" ); // shot
PrecacheParticleSystem( "marine_bloodsplat_light" ); // small shot
PrecacheParticleSystem( "marine_bloodsplat_heavy" ); // heavy shot
PrecacheParticleSystem( "marine_hit_blood_ff" );
PrecacheParticleSystem( "marine_hit_blood" );
PrecacheParticleSystem( "thorns_marine_buff" );
PrecacheParticleSystem( "marine_gib" );
PrecacheParticleSystem( "marine_death_ragdoll" );
PrecacheParticleSystem( "piercing_spark" );
PrecacheParticleSystem( "jj_trail_small" );
PrecacheParticleSystem( "jj_ground_pound" );
PrecacheParticleSystem( "invalid_destination" );
PrecacheParticleSystem( "Blink" );
PrecacheParticleSystem( "leadership_proc_accuracy" );
PrecacheParticleSystem( "leadership_proc_resist" );
}
void CASW_Marine::PrecacheSpeech()