-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathtf_player.cpp
More file actions
23149 lines (19924 loc) · 707 KB
/
tf_player.cpp
File metadata and controls
23149 lines (19924 loc) · 707 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 Valve Corporation, All rights reserved. ============//
//
// Purpose: Player for HL1.
//
// $NoKeywords: $
//=============================================================================
#include "cbase.h"
#include "tf_player.h"
#include "tf_gamerules.h"
#include "tf_gamestats.h"
#include "KeyValues.h"
#include "viewport_panel_names.h"
#include "client.h"
#include "team.h"
#include "tf_weaponbase.h"
#include "tf_client.h"
#include "tf_team.h"
#include "tf_viewmodel.h"
#include "tf_item.h"
#include "in_buttons.h"
#include "entity_capture_flag.h"
#include "effect_dispatch_data.h"
#include "te_effect_dispatch.h"
#include "game.h"
#include "tf_weapon_builder.h"
#include "tf_obj.h"
#include "tf_ammo_pack.h"
#include "datacache/imdlcache.h"
#include "particle_parse.h"
#include "props_shared.h"
#include "filesystem.h"
#include "toolframework_server.h"
#include "IEffects.h"
#include "func_respawnroom.h"
#include "networkstringtable_gamedll.h"
#include "team_control_point_master.h"
#include "tf_weapon_pda.h"
#include "sceneentity.h"
#include "fmtstr.h"
#include "tf_weapon_sniperrifle.h"
#include "tf_weapon_minigun.h"
#include "tf_weapon_fists.h"
#include "tf_weapon_shotgun.h"
#include "tf_weapon_lunchbox.h"
#include "tf_weapon_knife.h"
#include "tf_weapon_bottle.h"
#include "tf_weapon_sword.h"
#include "tf_weapon_grenade_pipebomb.h"
#include "tf_weapon_buff_item.h"
#include "tf_weapon_flamethrower.h"
#include "tf_weapon_laser_pointer.h"
#include "tf_projectile_flare.h"
#include "trigger_area_capture.h"
#include "triggers.h"
#include "tf_weapon_medigun.h"
#include "tf_weapon_invis.h"
#include "hl2orange.spa.h"
#include "te_tfblood.h"
#include "activitylist.h"
#include "cdll_int.h"
#include "econ_entity_creation.h"
#include "tf_weaponbase_gun.h"
#include "team_train_watcher.h"
#include "vgui/ILocalize.h"
#include "tier3/tier3.h"
#include "serverbenchmark_base.h"
#include "trains.h"
#include "tf_fx.h"
#include "recipientfilter.h"
#include "ilagcompensationmanager.h"
#include "dt_utlvector_send.h"
#include "tf_item_wearable.h"
#include "tf_item_powerup_bottle.h"
#include "nav_mesh/tf_nav_mesh.h"
#include "tier0/vprof.h"
#include "econ_gcmessages.h"
#include "tf_gcmessages.h"
#include "tf_obj_sentrygun.h"
#include "tf_weapon_shovel.h"
#include "bot/tf_bot.h"
#include "bot/tf_bot_manager.h"
#include "NextBotUtil.h"
#include "tf_wearable_weapons.h"
#include "tier0/icommandline.h"
#include "entity_healthkit.h"
#include "choreoevent.h"
#include "minigames/tf_duel.h"
#include "tf_bot_temp.h"
#include "tf_objective_resource.h"
#include "tf_weapon_pipebomblauncher.h"
#include "func_achievement.h"
#include "halloween/merasmus/merasmus.h"
#include "inetchannel.h"
#include "tf_wearable_levelable_item.h"
#include "tf_weapon_jar.h"
#include "halloween/tf_weapon_spellbook.h"
#include "soundenvelope.h"
#include "tf_triggers.h"
#include "collisionutils.h"
#include "tf_taunt_prop.h"
#include "eventlist.h"
#include "entity_rune.h"
#include "entity_halloween_pickup.h"
#include "tf_gc_server.h"
#include "tf_logic_halloween_2014.h"
#include "tf_weapon_knife.h"
#include "tf_weapon_grapplinghook.h"
#include "tf_dropped_weapon.h"
#include "tf_passtime_logic.h"
#include "tf_weapon_passtime_gun.h"
#include "player_resource.h"
#include "tf_player_resource.h"
#include "gcsdk/gcclient_sharedobjectcache.h"
#include "tf_party.h"
#ifdef TF_RAID_MODE
#include "bot_npc/bot_npc_decoy.h"
#include "raid/tf_raid_logic.h"
#endif
#include "entity_currencypack.h"
#include "tf_mann_vs_machine_stats.h"
#include "player_vs_environment/tf_upgrades.h"
#include "player_vs_environment/tf_population_manager.h"
#include "tf_revive.h"
#include "tf_logic_halloween_2014.h"
#include "tf_logic_player_destruction.h"
#include "tf_weapon_slap.h"
#include "func_croc.h"
#include "tf_weapon_bonesaw.h"
#include "pointhurt.h"
#include "info_camera_link.h"
// NVNT haptic utils
#include "haptics/haptic_utils.h"
#include "gc_clientsystem.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#pragma warning( disable: 4355 ) // disables ' 'this' : used in base member initializer list'
ConVar sv_motd_unload_on_dismissal( "sv_motd_unload_on_dismissal", "0", 0, "If enabled, the MOTD contents will be unloaded when the player closes the MOTD." );
#define DAMAGE_FORCE_SCALE_SELF 9
#define SCOUT_ADD_BIRD_ON_GIB_CHANCE 5
#define MEDIC_RELEASE_DOVE_COUNT 10
#define JUMP_MIN_SPEED 268.3281572999747f
extern bool IsInCommentaryMode( void );
extern void SpawnClientsideFlyingBird( Vector &vecSpawn );
extern ConVar sk_player_head;
extern ConVar sk_player_chest;
extern ConVar sk_player_stomach;
extern ConVar sk_player_arm;
extern ConVar sk_player_leg;
extern ConVar tf_spy_invis_time;
extern ConVar tf_spy_invis_unstealth_time;
extern ConVar tf_stalematechangeclasstime;
extern ConVar tf_gravetalk;
extern ConVar tf_bot_quota_mode;
extern ConVar tf_bot_quota;
extern ConVar halloween_starting_souls;
extern ConVar tf_powerup_mode_killcount_timer_length;
float GetCurrentGravity( void );
float m_flNextReflectZap = 0.f;
static CTFPlayer *gs_pRecursivePlayerCheck = NULL;
bool CTFPlayer::m_bTFPlayerNeedsPrecache = true;
static const char g_pszIdleKickString[] = "#TF_Idle_kicked";
EHANDLE g_pLastSpawnPoints[TF_TEAM_COUNT];
EHANDLE g_hTestSub;
ConVar tf_playerstatetransitions( "tf_playerstatetransitions", "-2", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "tf_playerstatetransitions <ent index or -1 for all>. Show player state transitions." );
ConVar tf_playergib( "tf_playergib", "1", FCVAR_NOTIFY, "Allow player gibbing. 0: never, 1: normal, 2: always", true, 0, true, 2 );
ConVar tf_damageforcescale_other( "tf_damageforcescale_other", "6.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
ConVar tf_damageforcescale_self_soldier_rj( "tf_damageforcescale_self_soldier_rj", "10.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
ConVar tf_damageforcescale_self_soldier_badrj( "tf_damageforcescale_self_soldier_badrj", "5.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
ConVar tf_damageforcescale_pyro_jump( "tf_damageforcescale_pyro_jump", "8.5", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
ConVar tf_damagescale_self_soldier( "tf_damagescale_self_soldier", "0.60", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
ConVar tf_damage_range( "tf_damage_range", "0.5", FCVAR_DEVELOPMENTONLY );
ConVar tf_damage_multiplier_blue( "tf_damage_multiplier_blue", "1.0", FCVAR_CHEAT, "All incoming damage to a blue player is multiplied by this value" );
ConVar tf_damage_multiplier_red( "tf_damage_multiplier_red", "1.0", FCVAR_CHEAT, "All incoming damage to a red player is multiplied by this value" );
ConVar tf_max_voice_speak_delay( "tf_max_voice_speak_delay", "1.5", FCVAR_DEVELOPMENTONLY, "Max time after a voice command until player can do another one", true, 0.1f, false, 0.f );
ConVar tf_allow_player_use( "tf_allow_player_use", "0", FCVAR_NOTIFY, "Allow players to execute +use while playing." );
ConVar tf_deploying_bomb_time( "tf_deploying_bomb_time", "1.90", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "Time to deploy bomb before the point of no return." );
ConVar tf_deploying_bomb_delay_time( "tf_deploying_bomb_delay_time", "0.0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "Time to delay before deploying bomb." );
#ifdef TF_RAID_MODE
ConVar tf_raid_team_size( "tf_raid_team_size", "5", FCVAR_NOTIFY, "Max number of Raiders" );
ConVar tf_raid_respawn_safety_time( "tf_raid_respawn_safety_time", "1.5", FCVAR_NOTIFY, "Number of seconds of invulnerability after respawning" );
ConVar tf_raid_allow_class_change( "tf_raid_allow_class_change", "1", FCVAR_NOTIFY, "If nonzero, allow invaders to change their class after leaving the safe room" );
ConVar tf_raid_use_rescue_closets( "tf_raid_use_rescue_closets", "1", FCVAR_NOTIFY );
ConVar tf_raid_drop_healthkit_chance( "tf_raid_drop_healthkit_chance", "50" ); // , FCVAR_CHEAT );
ConVar tf_boss_battle_team_size( "tf_boss_battle_team_size", "5", FCVAR_NOTIFY, "Max number of players in Boss Battle mode" );
ConVar tf_boss_battle_respawn_safety_time( "tf_boss_battle_respawn_safety_time", "3", FCVAR_NOTIFY, "Number of seconds of invulnerability after respawning" );
ConVar tf_boss_battle_respawn_on_friends( "tf_boss_battle_respawn_on_friends", "1", FCVAR_NOTIFY );
#endif
ConVar tf_mvm_death_penalty( "tf_mvm_death_penalty", "0", FCVAR_NOTIFY | FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "How much currency players lose when dying" );
extern ConVar tf_populator_damage_multiplier;
extern ConVar tf_mvm_skill;
ConVar tf_highfive_separation_forward( "tf_highfive_separation_forward", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "Forward distance between high five partners" );
ConVar tf_highfive_separation_right( "tf_highfive_separation_right", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "Right distance between high five partners" );
ConVar tf_highfive_max_range( "tf_highfive_max_range", "150", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "The farthest away a high five partner can be" );
ConVar tf_highfive_height_tolerance( "tf_highfive_height_tolerance", "12", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, "The maximum height difference allowed for two high-fivers." );
ConVar tf_highfive_debug( "tf_highfive_debug", "0", FCVAR_NONE, "Turns on some console spew for debugging high five issues." );
ConVar tf_test_teleport_home_fx( "tf_test_teleport_home_fx", "0", FCVAR_CHEAT );
ConVar tf_halloween_giant_health_scale( "tf_halloween_giant_health_scale", "10", FCVAR_CHEAT );
ConVar tf_grapplinghook_los_force_detach_time( "tf_grapplinghook_los_force_detach_time", "1", FCVAR_CHEAT );
ConVar tf_powerup_max_charge_time( "tf_powerup_max_charge_time", "30", FCVAR_CHEAT );
extern ConVar tf_powerup_mode;
extern ConVar tf_mvm_buybacks_method;
extern ConVar tf_mvm_buybacks_per_wave;
#define TF_CANNONBALL_FORCE_SCALE 80.f
#define TF_CANNONBALL_FORCE_UPWARD 300.f
ConVar tf_halloween_unlimited_spells( "tf_halloween_unlimited_spells", "0", FCVAR_CHEAT );
extern ConVar tf_halloween_kart_boost_recharge;
extern ConVar tf_halloween_kart_boost_duration;
ConVar tf_halloween_kart_impact_force( "tf_halloween_kart_impact_force", "0.75f", FCVAR_CHEAT, "Impact force scaler" );
ConVar tf_halloween_kart_impact_damage( "tf_halloween_kart_impact_damage", "1.0f", FCVAR_CHEAT, "Impact damage scaler" );
ConVar tf_halloween_kart_impact_rate( "tf_halloween_kart_impact_rate", "0.5f", FCVAR_CHEAT, "rate of allowing impact damage" );
ConVar tf_halloween_kart_boost_impact_force( "tf_halloween_kart_boost_impact_force", "0.75f", FCVAR_CHEAT, "Impact force scaler on boosts" );
ConVar tf_halloween_kart_impact_bounds_scale( "tf_halloween_kart_impact_bounds_scale", "1.0f", FCVAR_CHEAT );
ConVar tf_halloween_kart_impact_feedback( "tf_halloween_kart_impact_feedback", "0.25f", FCVAR_CHEAT );
ConVar tf_halloween_kart_impact_lookahead( "tf_halloween_kart_impact_lookahead", "12.0f", FCVAR_CHEAT );
ConVar tf_halloween_kart_bomb_head_damage_scale( "tf_halloween_kart_bomb_head_damage_scale", "2", FCVAR_CHEAT );
ConVar tf_halloween_kart_bomb_head_impulse_scale( "tf_halloween_kart_bomb_head_impulse_scale", "2", FCVAR_CHEAT );
ConVar tf_halloween_kart_impact_air_scale( "tf_halloween_kart_impact_air_scale", "0.75f", FCVAR_CHEAT );
ConVar tf_halloween_kart_damage_to_force( "tf_halloween_kart_damage_to_force", "300.0f", FCVAR_CHEAT );
ConVar tf_halloween_kart_stun_duration_scale( "tf_halloween_kart_stun_duration_scale", "0.70f", FCVAR_CHEAT );
ConVar tf_halloween_kart_stun_amount( "tf_halloween_kart_stun_amount", "1.0f", FCVAR_CHEAT );
ConVar tf_halloween_kart_stun_enabled( "tf_halloween_kart_stun_enabled", "1", FCVAR_CHEAT );
ConVar tf_tauntcam_fov_override( "tf_tauntcam_fov_override", "0", FCVAR_CHEAT );
ConVar tf_nav_in_combat_range( "tf_nav_in_combat_range", "1000", FCVAR_CHEAT );
ConVar tf_halloween_kart_punting_ghost_force_scale( "tf_halloween_kart_punting_ghost_force_scale", "4", FCVAR_CHEAT );
ConVar tf_halloween_allow_ghost_hit_by_kart_delay( "tf_halloween_allow_ghost_hit_by_kart_delay", "0.5", FCVAR_CHEAT );
ConVar tf_maxhealth_drain_hp_min( "tf_maxhealth_drain_hp_min", "100", FCVAR_DEVELOPMENTONLY );
ConVar tf_maxhealth_drain_deploy_cost( "tf_maxhealth_drain_deploy_cost", "20", FCVAR_DEVELOPMENTONLY );
extern ConVar sv_vote_allow_spectators;
ConVar sv_vote_late_join_time( "sv_vote_late_join_time", "90", FCVAR_NONE, "Grace period after the match starts before players who join the match receive a vote-creation cooldown" );
ConVar sv_vote_late_join_cooldown( "sv_vote_late_join_cooldown", "300", FCVAR_NONE, "Length of the vote-creation cooldown when joining the server after the grace period has expired" );
extern ConVar tf_voice_command_suspension_mode;
extern ConVar tf_feign_death_duration;
extern ConVar spec_freeze_time;
extern ConVar spec_freeze_traveltime;
extern ConVar sv_maxunlag;
extern ConVar tf_allow_taunt_switch;
extern ConVar weapon_medigun_chargerelease_rate;
extern ConVar tf_scout_energydrink_consume_rate;
extern ConVar tf_mm_trusted;
extern ConVar mp_spectators_restricted;
extern ConVar mp_teams_unbalance_limit;
extern ConVar tf_tournament_classchange_allowed;
extern ConVar tf_tournament_classchange_ready_allowed;
extern ConVar tf_rocketpack_impact_push_min;
extern ConVar tf_rocketpack_impact_push_max;
#if defined( _DEBUG ) || defined( STAGING_ONLY )
extern ConVar mp_developer;
extern ConVar bot_mimic;
#endif // _DEBUG || STAGING_ONLY
extern CBaseEntity *FindPickerEntity( CBasePlayer *pPlayer );
extern bool CanScatterGunKnockBack( CTFWeaponBase *pWeapon, float flDamage, float flDistanceSq );
extern bool IsCustomGameMode();
static const char *s_pszTauntRPSParticleNames[] =
{
"rps_rock_red",
"rps_paper_red",
"rps_scissors_red",
"rps_rock_red_win",
"rps_paper_red_win",
"rps_scissors_red_win",
"rps_rock_blue",
"rps_paper_blue",
"rps_scissors_blue",
"rps_rock_blue_win",
"rps_paper_blue_win",
"rps_scissors_blue_win"
};
// -------------------------------------------------------------------------------- //
// Player animation event. Sent to the client when a player fires, jumps, reloads, etc..
// -------------------------------------------------------------------------------- //
class CTEPlayerAnimEvent : public CBaseTempEntity
{
public:
DECLARE_CLASS( CTEPlayerAnimEvent, CBaseTempEntity );
DECLARE_SERVERCLASS();
CTEPlayerAnimEvent( const char *name )
: CBaseTempEntity( name )
{
}
CNetworkHandle( CBasePlayer, m_hPlayer );
CNetworkVar( int, m_iEvent );
CNetworkVar( int, m_nData );
};
IMPLEMENT_SERVERCLASS_ST_NOBASE( CTEPlayerAnimEvent, DT_TEPlayerAnimEvent )
SendPropEHandle( SENDINFO( m_hPlayer ) ),
SendPropInt( SENDINFO( m_iEvent ), Q_log2( PLAYERANIMEVENT_COUNT ) + 1, SPROP_UNSIGNED ),
// BUGBUG: ywb we assume this is either 0 or an animation sequence #, but it could also be an activity, which should fit within this limit, but we're not guaranteed.
SendPropInt( SENDINFO( m_nData ), ANIMATION_SEQUENCE_BITS ),
END_SEND_TABLE()
static CTEPlayerAnimEvent g_TEPlayerAnimEvent( "PlayerAnimEvent" );
void TE_PlayerAnimEvent( CBasePlayer *pPlayer, PlayerAnimEvent_t event, int nData )
{
Vector vecEyePos = pPlayer->EyePosition();
CPVSFilter filter( vecEyePos );
if ( !IsCustomPlayerAnimEvent( event ) && ( event != PLAYERANIMEVENT_SNAP_YAW ) && ( event != PLAYERANIMEVENT_VOICE_COMMAND_GESTURE ) )
{
// if prediction is off, alway send jump
if ( !( ( event == PLAYERANIMEVENT_JUMP ) && ( FStrEq(engine->GetClientConVarValue( pPlayer->entindex(), "cl_predict" ), "0" ) ) ) )
{
filter.RemoveRecipient( pPlayer );
}
}
Assert( pPlayer->entindex() >= 1 && pPlayer->entindex() <= MAX_PLAYERS );
g_TEPlayerAnimEvent.m_hPlayer = pPlayer;
g_TEPlayerAnimEvent.m_iEvent = event;
Assert( nData < (1<<ANIMATION_SEQUENCE_BITS) );
Assert( (1<<ANIMATION_SEQUENCE_BITS) >= ActivityList_HighestIndex() );
g_TEPlayerAnimEvent.m_nData = nData;
g_TEPlayerAnimEvent.Create( filter, 0 );
}
//=================================================================================
//
// Ragdoll Entity
//
class CTFRagdoll : public CBaseAnimatingOverlay
{
public:
DECLARE_CLASS( CTFRagdoll, CBaseAnimatingOverlay );
DECLARE_SERVERCLASS();
CTFRagdoll()
{
m_bGib = false;
m_bBurning = false;
m_bElectrocuted = false;
m_bFeignDeath = false;
m_bWasDisguised = false;
m_bBecomeAsh = false;
m_bOnGround = false;
m_bCloaked = false;
m_iDamageCustom = 0;
m_bCritOnHardHit = false;
m_vecRagdollOrigin.Init();
m_vecRagdollVelocity.Init();
}
~CTFRagdoll()
{
// Destroy all of our attached wearables.
for ( int i=0; i<m_hRagWearables.Count(); ++i )
{
if ( m_hRagWearables[i] )
{
m_hRagWearables[i]->Remove();
}
}
m_hRagWearables.Purge();
}
// Transmit ragdolls to everyone.
virtual int UpdateTransmitState()
{
UseClientSideAnimation();
return SetTransmitState( FL_EDICT_ALWAYS );
}
CNetworkHandle( CBasePlayer, m_hPlayer );
CNetworkVector( m_vecRagdollVelocity );
CNetworkVector( m_vecRagdollOrigin );
CNetworkVar( bool, m_bGib );
CNetworkVar( bool, m_bBurning );
CNetworkVar( bool, m_bElectrocuted );
CNetworkVar( bool, m_bFeignDeath );
CNetworkVar( bool, m_bWasDisguised );
CNetworkVar( bool, m_bBecomeAsh );
CNetworkVar( bool, m_bOnGround );
CNetworkVar( bool, m_bCloaked );
CNetworkVar( int, m_iDamageCustom );
CNetworkVar( int, m_iTeam );
CNetworkVar( int, m_iClass );
CNetworkVar( bool, m_bGoldRagdoll );
CNetworkVar( bool, m_bIceRagdoll );
CNetworkVar( bool, m_bCritOnHardHit );
CNetworkVar( float, m_flHeadScale );
CNetworkVar( float, m_flTorsoScale );
CNetworkVar( float, m_flHandScale );
CUtlVector<CHandle<CEconWearable > > m_hRagWearables;
};
LINK_ENTITY_TO_CLASS( tf_ragdoll, CTFRagdoll );
IMPLEMENT_SERVERCLASS_ST_NOBASE( CTFRagdoll, DT_TFRagdoll )
SendPropVector( SENDINFO( m_vecRagdollOrigin ), -1, SPROP_COORD ),
SendPropEHandle( SENDINFO ( m_hPlayer) ),
SendPropVector ( SENDINFO(m_vecForce), -1, SPROP_NOSCALE ),
SendPropVector( SENDINFO( m_vecRagdollVelocity ), 13, SPROP_ROUNDDOWN, -2048.0f, 2048.0f ),
SendPropInt( SENDINFO( m_nForceBone ) ),
SendPropBool( SENDINFO( m_bGib ) ),
SendPropBool( SENDINFO( m_bBurning ) ),
SendPropBool( SENDINFO( m_bElectrocuted ) ),
SendPropBool( SENDINFO( m_bFeignDeath ) ),
SendPropBool( SENDINFO( m_bWasDisguised ) ),
SendPropBool( SENDINFO( m_bBecomeAsh ) ),
SendPropBool( SENDINFO( m_bOnGround ) ),
SendPropBool( SENDINFO( m_bCloaked ) ),
SendPropInt( SENDINFO( m_iDamageCustom ) ),
SendPropInt( SENDINFO( m_iTeam ), 3, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_iClass ), 4, SPROP_UNSIGNED ),
SendPropUtlVector( SENDINFO_UTLVECTOR( m_hRagWearables ), 8, SendPropEHandle( NULL, 0 ) ),
SendPropBool( SENDINFO( m_bGoldRagdoll ) ),
SendPropBool( SENDINFO( m_bIceRagdoll ) ),
SendPropBool( SENDINFO( m_bCritOnHardHit ) ),
SendPropFloat( SENDINFO( m_flHeadScale ) ),
SendPropFloat( SENDINFO( m_flTorsoScale ) ),
SendPropFloat( SENDINFO( m_flHandScale ) ),
END_SEND_TABLE()
// -------------------------------------------------------------------------------- //
// Tables.
// -------------------------------------------------------------------------------- //
//-----------------------------------------------------------------------------
// Purpose: SendProxy that converts the UtlVector list of objects to entindexes, where it's reassembled on the client
//-----------------------------------------------------------------------------
void SendProxy_PlayerObjectList( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID )
{
CTFPlayer *pPlayer = (CTFPlayer*)pStruct;
// If this fails, then SendProxyArrayLength_PlayerObjects didn't work.
Assert( iElement < pPlayer->GetObjectCount() );
CBaseObject *pObject = pPlayer->GetObject(iElement);
EHANDLE hObject;
hObject = pObject;
SendProxy_EHandleToInt( pProp, pStruct, &hObject, pOut, iElement, objectID );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int SendProxyArrayLength_PlayerObjects( const void *pStruct, int objectID )
{
CTFPlayer *pPlayer = (CTFPlayer*)pStruct;
int iObjects = pPlayer->GetObjectCount();
Assert( iObjects <= MAX_OBJECTS_PER_PLAYER );
return iObjects;
}
//-----------------------------------------------------------------------------
// Purpose: Send to attached medics
//-----------------------------------------------------------------------------
void* SendProxy_SendHealersDataTable( const SendProp *pProp, const void *pStruct, const void *pVarData, CSendProxyRecipients *pRecipients, int objectID )
{
CTFPlayer *pPlayer = (CTFPlayer*)pStruct;
if ( pPlayer )
{
// Add attached medics
for ( int i = 0; i < pPlayer->m_Shared.GetNumHealers(); i++ )
{
CTFPlayer *pMedic = ToTFPlayer( pPlayer->m_Shared.GetHealerByIndex( i ) );
if ( !pMedic )
continue;
pRecipients->SetRecipient( pMedic->GetClientIndex() );
return (void*)pVarData;
}
}
return NULL;
}
REGISTER_SEND_PROXY_NON_MODIFIED_POINTER( SendProxy_SendHealersDataTable );
BEGIN_DATADESC( CTFPlayer )
DEFINE_INPUTFUNC( FIELD_VOID, "IgnitePlayer", InputIgnitePlayer ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetCustomModel", InputSetCustomModel ),
DEFINE_INPUTFUNC( FIELD_STRING, "SetCustomModelWithClassAnimations", InputSetCustomModelWithClassAnimations ),
DEFINE_INPUTFUNC( FIELD_VECTOR, "SetCustomModelOffset", InputSetCustomModelOffset ),
DEFINE_INPUTFUNC( FIELD_VECTOR, "SetCustomModelRotation", InputSetCustomModelRotation ),
DEFINE_INPUTFUNC( FIELD_VOID, "ClearCustomModelRotation", InputClearCustomModelRotation ),
DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetCustomModelRotates", InputSetCustomModelRotates ),
DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetCustomModelVisibleToSelf", InputSetCustomModelVisibleToSelf ),
DEFINE_INPUTFUNC( FIELD_INTEGER, "SetForcedTauntCam", InputSetForcedTauntCam ),
DEFINE_INPUTFUNC( FIELD_VOID, "ExtinguishPlayer", InputExtinguishPlayer ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "BleedPlayer", InputBleedPlayer ),
DEFINE_INPUTFUNC( FIELD_VOID, "TriggerLootIslandAchievement", InputTriggerLootIslandAchievement ),
DEFINE_INPUTFUNC( FIELD_VOID, "TriggerLootIslandAchievement2", InputTriggerLootIslandAchievement2 ),
DEFINE_INPUTFUNC( FIELD_STRING, "SpeakResponseConcept", InputSpeakResponseConcept ),
DEFINE_INPUTFUNC( FIELD_VOID, "RollRareSpell", InputRollRareSpell ),
DEFINE_INPUTFUNC( FIELD_VOID, "RoundSpawn", InputRoundSpawn ),
END_DATADESC()
BEGIN_ENT_SCRIPTDESC( CTFPlayer, CBaseMultiplayerPlayer , "Team Fortress 2 Player" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetActiveWeapon, "GetActiveWeapon", "Get the player's current weapon" )
DEFINE_SCRIPTFUNC( ForceRespawn, "Force respawns the player" )
DEFINE_SCRIPTFUNC( ForceRegenerateAndRespawn, "Force regenerates and respawns the player" )
DEFINE_SCRIPTFUNC( Regenerate, "Resupplies a player. If regen health/ammo is set, clears negative conds, gives back player health/ammo" )
DEFINE_SCRIPTFUNC( HasItem, "Currently holding an item? Eg. capture flag" )
DEFINE_SCRIPTFUNC( GetNextRegenTime, "Get next health regen time." )
DEFINE_SCRIPTFUNC( SetNextRegenTime, "Set next health regen time." )
DEFINE_SCRIPTFUNC( GetNextChangeClassTime, "Get next change class time." )
DEFINE_SCRIPTFUNC( SetNextChangeClassTime, "Set next change class time." )
DEFINE_SCRIPTFUNC( GetNextChangeTeamTime, "Get next change team time." )
DEFINE_SCRIPTFUNC( SetNextChangeTeamTime, "Set next change team time." )
DEFINE_SCRIPTFUNC( DropFlag, "Force player to drop the flag." )
DEFINE_SCRIPTFUNC( DropRune, "Force player to drop the rune." )
DEFINE_SCRIPTFUNC( ForceChangeTeam, "Force player to change their team." )
DEFINE_SCRIPTFUNC( IsMiniBoss, "Is this player an MvM mini-boss?" )
DEFINE_SCRIPTFUNC( SetIsMiniBoss, "Make this player an MvM mini-boss." )
DEFINE_SCRIPTFUNC( CanJump, "Can the player jump?" )
DEFINE_SCRIPTFUNC( CanDuck, "Can the player duck?" )
DEFINE_SCRIPTFUNC( CanPlayerMove, "Can the player move?" )
DEFINE_SCRIPTFUNC( RemoveAllObjects, "Remove all player objects. Eg. dispensers/sentries." )
DEFINE_SCRIPTFUNC( IsPlacingSapper, "Returns true if we placed a sapper in the last few moments" )
DEFINE_SCRIPTFUNC( IsSapping, "Returns true if we are currently sapping" )
DEFINE_SCRIPTFUNC( RemoveInvisibility, "Un-invisible a spy." )
DEFINE_SCRIPTFUNC( RemoveDisguise, "Undisguise a spy." )
DEFINE_SCRIPTFUNC( TryToPickupBuilding, "Make the player attempt to pick up a building in front of them" )
DEFINE_SCRIPTFUNC( IsCallingForMedic, "Is this player calling for medic?" )
DEFINE_SCRIPTFUNC( GetTimeSinceCalledForMedic, "When did the player last call medic" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetHealTarget, "GetHealTarget", "Who is the medic healing?" )
DEFINE_SCRIPTFUNC( GetClassEyeHeight, "Gets the eye height of the player" )
DEFINE_SCRIPTFUNC( FiringTalk, "Makes eg. a heavy go AAAAAAAAAAaAaa like they are firing their minigun." )
DEFINE_SCRIPTFUNC( CanAirDash, "" )
DEFINE_SCRIPTFUNC( CanBreatheUnderwater, "" )
DEFINE_SCRIPTFUNC( CanGetWet, "" )
DEFINE_SCRIPTFUNC( InAirDueToExplosion, "" )
DEFINE_SCRIPTFUNC( InAirDueToKnockback, "" )
DEFINE_SCRIPTFUNC( ApplyAbsVelocityImpulse, "" )
DEFINE_SCRIPTFUNC( ApplyPunchImpulseX, "" )
DEFINE_SCRIPTFUNC( SetUseBossHealthBar, "" )
DEFINE_SCRIPTFUNC( IsFireproof, "" )
DEFINE_SCRIPTFUNC( IsAllowedToTaunt, "" )
DEFINE_SCRIPTFUNC( IsViewingCYOAPDA, "" )
DEFINE_SCRIPTFUNC( IsRegenerating, "" )
DEFINE_SCRIPTFUNC( GetCurrentTauntMoveSpeed, "" )
DEFINE_SCRIPTFUNC( SetCurrentTauntMoveSpeed, "" )
DEFINE_SCRIPTFUNC( IsUsingActionSlot, "" )
DEFINE_SCRIPTFUNC( IsInspecting, "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetGrapplingHookTarget, "GetGrapplingHookTarget", "What entity is the player grappling?" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetGrapplingHookTarget, "SetGrapplingHookTarget", "Set the player's target grapple entity" )
DEFINE_SCRIPTFUNC( AddCustomAttribute, "Add a custom attribute to the player" )
DEFINE_SCRIPTFUNC( RemoveCustomAttribute, "Remove a custom attribute to the player" )
DEFINE_SCRIPTFUNC_NAMED( ScriptAddCond, "AddCond", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptAddCondEx, "AddCondEx", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveCond, "RemoveCond", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveCondEx, "RemoveCondEx", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptInCond, "InCond", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptWasInCond, "WasInCond", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveAllCond,"RemoveAllCond", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetCondDuration, "GetCondDuration", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetCondDuration, "SetCondDuration", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDisguiseTarget, "GetDisguiseTarget", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsCarryingRune, "IsCarryingRune", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsCritBoosted, "IsCritBoosted", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsInvulnerable, "IsInvulnerable", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsStealthed, "IsStealthed", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptCanBeDebuffed, "CanBeDebuffed", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsImmuneToPushback, "IsImmuneToPushback", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDisguiseAmmoCount, "GetDisguiseAmmoCount", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetDisguiseAmmoCount, "SetDisguiseAmmoCount", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDisguiseTeam, "GetDisguiseTeam", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsFullyInvisible, "IsFullyInvisible", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSpyCloakMeter, "GetSpyCloakMeter", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetSpyCloakMeter, "SetSpyCloakMeter", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsRageDraining, "IsRageDraining", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRageMeter, "GetRageMeter", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetRageMeter, "SetRageMeter", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetScoutHypeMeter, "GetScoutHypeMeter", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetScoutHypeMeter, "SetScoutHypeMeter", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsHypeBuffed, "IsHypeBuffed", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsJumping, "IsJumping", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsAirDashing, "IsAirDashing", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsControlStunned, "IsControlStunned", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsSnared, "IsSnared", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetCaptures, "GetCaptures", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDefenses, "GetDefenses", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDominations, "GetDominations", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRevenge, "GetRevenge", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetBuildingsDestroyed, "GetBuildingsDestroyed", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetHeadshots, "GetHeadshots", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetBackstabs, "GetBackstabs", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetHealPoints, "GetHealPoints", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetInvulns, "GetInvulns", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetTeleports, "GetTeleports", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetResupplyPoints, "GetResupplyPoints", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetKillAssists, "GetKillAssists", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetBonusPoints, "GetBonusPoints", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptResetScores, "ResetScores", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptIsParachuteEquipped, "IsParachuteEquipped", "" )
DEFINE_SCRIPTFUNC( GetCurrency, "Get player's cash for game modes with upgrades, ie. MvM" )
DEFINE_SCRIPTFUNC( SetCurrency, "Set player's cash for game modes with upgrades, ie. MvM" )
DEFINE_SCRIPTFUNC( AddCurrency, "Kaching! Give the player some cash for game modes with upgrades, ie. MvM" )
DEFINE_SCRIPTFUNC( RemoveCurrency, "Take away money from a player for reasons such as ie. spending." )
DEFINE_SCRIPTFUNC( IgnitePlayer, "" )
DEFINE_SCRIPTFUNC( SetCustomModel, "" )
DEFINE_SCRIPTFUNC( SetCustomModelWithClassAnimations, "" )
DEFINE_SCRIPTFUNC( SetCustomModelOffset, "" )
DEFINE_SCRIPTFUNC( SetCustomModelRotation, "" )
DEFINE_SCRIPTFUNC( ClearCustomModelRotation, "" )
DEFINE_SCRIPTFUNC( SetCustomModelRotates, "" )
DEFINE_SCRIPTFUNC( SetCustomModelVisibleToSelf, "" )
DEFINE_SCRIPTFUNC( SetForcedTauntCam, "" )
DEFINE_SCRIPTFUNC( ExtinguishPlayerBurning, "" )
DEFINE_SCRIPTFUNC( BleedPlayer, "" )
DEFINE_SCRIPTFUNC( BleedPlayerEx, "" )
DEFINE_SCRIPTFUNC( RollRareSpell, "" )
DEFINE_SCRIPTFUNC( ClearSpells, "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPlayerClass, "GetPlayerClass", "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptSetPlayerClass, "SetPlayerClass", "" )
DEFINE_SCRIPTFUNC( RemoveTeleportEffect, "" )
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveAllItems, "RemoveAllItems", "" )
DEFINE_SCRIPTFUNC( UpdateSkin, "" )
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_ShootPosition, "" ) // Needs this slim wrapper or the world falls apart on MSVC.
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_CanUse, "" )
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Equip, "" )
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Drop, "" )
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_DropEx, "" )
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Switch, "" )
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_SetLast, "" )
DEFINE_SCRIPTFUNC_WRAPPED( GetLastWeapon, "" )
DEFINE_SCRIPTFUNC_WRAPPED( EquipWearableViewModel, "" )
DEFINE_SCRIPTFUNC_WRAPPED( IsFakeClient, "" )
DEFINE_SCRIPTFUNC_WRAPPED( GetBotType, "" )
DEFINE_SCRIPTFUNC_WRAPPED( IsBotOfType, "" )
DEFINE_SCRIPTFUNC( AddHudHideFlags, "Hides a hud element based on Constants.FHideHUD." )
DEFINE_SCRIPTFUNC( RemoveHudHideFlags, "Unhides a hud element based on Constants.FHideHUD." )
DEFINE_SCRIPTFUNC( SetHudHideFlags, "Force hud hide flags to a value" )
DEFINE_SCRIPTFUNC( GetHudHideFlags, "Gets current hidden hud elements" )
DEFINE_SCRIPTFUNC( IsTaunting, "" )
DEFINE_SCRIPTFUNC( DoTauntAttack, "" )
DEFINE_SCRIPTFUNC( CancelTaunt, "" )
DEFINE_SCRIPTFUNC( StopTaunt, "" )
DEFINE_SCRIPTFUNC( EndLongTaunt, "" )
DEFINE_SCRIPTFUNC( GetTauntRemoveTime, "" )
DEFINE_SCRIPTFUNC( IsAllowedToRemoveTaunt, "" )
DEFINE_SCRIPTFUNC( HandleTauntCommand, "" )
DEFINE_SCRIPTFUNC( ClearTauntAttack, "" )
DEFINE_SCRIPTFUNC( GetTauntAttackTime, "" )
DEFINE_SCRIPTFUNC( SetRPSResult, "" )
DEFINE_SCRIPTFUNC( GetVehicleReverseTime, "" )
DEFINE_SCRIPTFUNC( SetVehicleReverseTime, "" )
DEFINE_SCRIPTFUNC_WRAPPED( Taunt, "" )
DEFINE_SCRIPTFUNC( GrantOrRemoveAllUpgrades, "Grants or removes all upgrades the player has purchased." )
DEFINE_SCRIPTFUNC_NAMED( ScriptGetCustomAttribute, "GetCustomAttribute", "Get a custom attribute float from the player" )
DEFINE_SCRIPTFUNC_WRAPPED( StunPlayer, "" )
END_SCRIPTDESC();
EXTERN_SEND_TABLE( DT_ScriptCreatedItem );
// specific to the local player
BEGIN_SEND_TABLE_NOBASE( CTFPlayer, DT_TFLocalPlayerExclusive )
// send a hi-res origin to the local player for use in prediction
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 ),
SendPropArray2(
SendProxyArrayLength_PlayerObjects,
SendPropInt("player_object_array_element", 0, SIZEOF_IGNORE, NUM_NETWORKED_EHANDLE_BITS, SPROP_UNSIGNED, SendProxy_PlayerObjectList),
MAX_OBJECTS_PER_PLAYER,
0,
"player_object_array"
),
SendPropFloat( SENDINFO_VECTORELEM(m_angEyeAngles, 0), 8, SPROP_CHANGES_OFTEN, -90.0f, 90.0f ),
SendPropAngle( SENDINFO_VECTORELEM(m_angEyeAngles, 1), 10, SPROP_CHANGES_OFTEN ),
SendPropBool( SENDINFO( m_bIsCoaching ) ),
SendPropEHandle( SENDINFO( m_hCoach ) ),
SendPropEHandle( SENDINFO( m_hStudent ) ),
SendPropInt( SENDINFO( m_nCurrency ), -1, SPROP_VARINT ),
SendPropInt( SENDINFO( m_nExperienceLevel ), 7, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_nExperienceLevelProgress ), 7, SPROP_UNSIGNED ),
SendPropBool( SENDINFO( m_bMatchSafeToLeave ) ),
END_SEND_TABLE()
// all players except the local player
BEGIN_SEND_TABLE_NOBASE( CTFPlayer, DT_TFNonLocalPlayerExclusive )
// send a lo-res origin to other players
SendPropVectorXY(SENDINFO(m_vecOrigin), -1, SPROP_COORD_MP_LOWPRECISION|SPROP_CHANGES_OFTEN, 0.0f, HIGH_DEFAULT, SendProxy_OriginXY ),
SendPropFloat (SENDINFO_VECTORELEM(m_vecOrigin, 2), -1, SPROP_COORD_MP_LOWPRECISION|SPROP_CHANGES_OFTEN, 0.0f, HIGH_DEFAULT, SendProxy_OriginZ ),
SendPropFloat( SENDINFO_VECTORELEM(m_angEyeAngles, 0), 8, SPROP_CHANGES_OFTEN, -90.0f, 90.0f ),
SendPropAngle( SENDINFO_VECTORELEM(m_angEyeAngles, 1), 10, SPROP_CHANGES_OFTEN ),
END_SEND_TABLE()
//-----------------------------------------------------------------------------
// Purpose: Sent to attached medics
//-----------------------------------------------------------------------------
BEGIN_SEND_TABLE_NOBASE( CTFPlayer, DT_TFSendHealersDataTable )
SendPropInt( SENDINFO( m_nActiveWpnClip ), -1, SPROP_VARINT | SPROP_UNSIGNED ),
END_SEND_TABLE()
//============
LINK_ENTITY_TO_CLASS( player, CTFPlayer );
PRECACHE_REGISTER(player);
IMPLEMENT_SERVERCLASS_ST( CTFPlayer, DT_TFPlayer )
SendPropExclude( "DT_BaseAnimating", "m_flPoseParameter" ),
SendPropExclude( "DT_BaseAnimating", "m_flPlaybackRate" ),
SendPropExclude( "DT_BaseAnimating", "m_nSequence" ),
SendPropExclude( "DT_BaseAnimating", "m_nBody" ),
SendPropExclude( "DT_BaseEntity", "m_angRotation" ),
SendPropExclude( "DT_BaseAnimatingOverlay", "overlay_vars" ),
SendPropExclude( "DT_BaseEntity", "m_nModelIndex" ),
SendPropExclude( "DT_BaseEntity", "m_vecOrigin" ),
// cs_playeranimstate and clientside animation takes care of these on the client
SendPropExclude( "DT_ServerAnimationData" , "m_flCycle" ),
SendPropExclude( "DT_AnimTimeMustBeFirst" , "m_flAnimTime" ),
SendPropExclude( "DT_BaseFlex", "m_flexWeight" ),
SendPropExclude( "DT_BaseFlex", "m_blinktoggle" ),
SendPropExclude( "DT_BaseFlex", "m_viewtarget" ),
SendPropBool(SENDINFO(m_bSaveMeParity)),
SendPropBool(SENDINFO(m_bIsMiniBoss)),
SendPropBool(SENDINFO(m_bIsABot)),
SendPropInt( SENDINFO(m_nBotSkill), 3, SPROP_UNSIGNED ),
// This will create a race condition will the local player, but the data will be the same so.....
SendPropInt( SENDINFO( m_nWaterLevel ), 2, SPROP_UNSIGNED ),
// Ragdoll.
SendPropEHandle( SENDINFO( m_hRagdoll ) ),
SendPropDataTable( SENDINFO_DT( m_PlayerClass ), &REFERENCE_SEND_TABLE( DT_TFPlayerClassShared ) ),
SendPropDataTable( SENDINFO_DT( m_Shared ), &REFERENCE_SEND_TABLE( DT_TFPlayerShared ) ),
SendPropEHandle(SENDINFO(m_hItem)),
// Data that only gets sent to the local player
SendPropDataTable( "tflocaldata", 0, &REFERENCE_SEND_TABLE(DT_TFLocalPlayerExclusive), SendProxy_SendLocalDataTable ),
// Data that gets sent to all other players
SendPropDataTable( "tfnonlocaldata", 0, &REFERENCE_SEND_TABLE(DT_TFNonLocalPlayerExclusive), SendProxy_SendNonLocalDataTable ),
SendPropBool( SENDINFO( m_bAllowMoveDuringTaunt ) ),
SendPropBool( SENDINFO( m_bIsReadyToHighFive ) ),
SendPropEHandle( SENDINFO( m_hHighFivePartner ) ),
SendPropInt( SENDINFO( m_nForceTauntCam ), 2, SPROP_UNSIGNED ),
SendPropFloat( SENDINFO( m_flTauntYaw ), 0, SPROP_NOSCALE ),
SendPropInt( SENDINFO( m_nActiveTauntSlot ) ),
SendPropInt( SENDINFO( m_iTauntItemDefIndex ) ),
SendPropFloat( SENDINFO( m_flCurrentTauntMoveSpeed ) ),
SendPropFloat( SENDINFO( m_flVehicleReverseTime ) ),
SendPropFloat( SENDINFO( m_flMvMLastDamageTime ), 16, SPROP_ROUNDUP ),
SendPropInt( SENDINFO( m_iSpawnCounter ) ),
SendPropBool( SENDINFO( m_bFlipViewModels ) ),
SendPropBool( SENDINFO( m_bArenaSpectator ) ),
SendPropFloat( SENDINFO( m_flHeadScale ) ),
SendPropFloat( SENDINFO( m_flTorsoScale ) ),
SendPropFloat( SENDINFO( m_flHandScale ) ),
SendPropBool( SENDINFO( m_bUseBossHealthBar ) ),
SendPropBool( SENDINFO( m_bUsingVRHeadset ) ),
SendPropBool( SENDINFO( m_bForcedSkin ) ),
SendPropInt( SENDINFO( m_nForcedSkin ), ANIMATION_SKIN_BITS ),
SendPropDataTable( SENDINFO_DT( m_AttributeManager ), &REFERENCE_SEND_TABLE(DT_AttributeManager) ),
SendPropDataTable( "TFSendHealersDataTable", 0, &REFERENCE_SEND_TABLE( DT_TFSendHealersDataTable ), SendProxy_SendHealersDataTable ),
SendPropFloat( SENDINFO( m_flKartNextAvailableBoost ) ),
SendPropInt( SENDINFO( m_iKartHealth ) ),
SendPropInt( SENDINFO( m_iKartState ) ),
SendPropEHandle( SENDINFO( m_hGrapplingHookTarget ) ),
SendPropEHandle( SENDINFO( m_hSecondaryLastWeapon ) ),
SendPropBool( SENDINFO( m_bUsingActionSlot ) ),
SendPropFloat( SENDINFO( m_flInspectTime ) ),
SendPropFloat( SENDINFO( m_flHelpmeButtonPressTime ) ),
SendPropInt( SENDINFO( m_iCampaignMedals ) ),
SendPropInt( SENDINFO( m_iPlayerSkinOverride ) ),
SendPropBool( SENDINFO( m_bViewingCYOAPDA ) ),
SendPropBool( SENDINFO( m_bRegenerating ) ),
SendPropEHandle( SENDINFO( m_hOffHandWeapon ) ),
END_SEND_TABLE()
// -------------------------------------------------------------------------------- //
void cc_CreatePredictionError_f()
{
CBaseEntity *pEnt = CBaseEntity::Instance( 1 );
pEnt->SetAbsOrigin( pEnt->GetAbsOrigin() + Vector( 63, 0, 0 ) );
}
ConCommand cc_CreatePredictionError( "CreatePredictionError", cc_CreatePredictionError_f, "Create a prediction error", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
// -------------------------------------------------------------------------------- //
enum eCoachCommand
{
kCoachCommand_Look = 1, // slot1
kCoachCommand_Go, // slot2
kCoachCommand_Attack,
kCoachCommand_Defend,
kNumCoachCommands,
};
/**
* Handles a command from the coach
*/
static void HandleCoachCommand( CTFPlayer *pPlayer, eCoachCommand command )
{
if ( pPlayer && pPlayer->IsCoaching() && pPlayer->GetStudent() && command < kNumCoachCommands )
{
const float kMaxRateCoachCommands = 1.0f;
float flLastCoachCommandDelta = gpGlobals->curtime - pPlayer->m_flLastCoachCommand;
if ( flLastCoachCommandDelta < kMaxRateCoachCommands && flLastCoachCommandDelta > 0.0f )
{
return;
}
pPlayer->m_flLastCoachCommand = gpGlobals->curtime;
IGameEvent *pEvent = gameeventmanager->CreateEvent( "show_annotation" );
if ( pEvent )
{
Vector vForward;
AngleVectors( pPlayer->EyeAngles(), &vForward );
trace_t trace;
CTraceFilterSimple filter( pPlayer->GetStudent(), COLLISION_GROUP_NONE );
UTIL_TraceLine( pPlayer->EyePosition(), pPlayer->EyePosition() + vForward * MAX_TRACE_LENGTH, MASK_SOLID, &filter, &trace );
CBaseEntity *pHitEntity = trace.m_pEnt && trace.m_pEnt->IsWorld() == false && trace.m_pEnt != pPlayer->GetStudent() ? trace.m_pEnt : NULL;
pEvent->SetInt( "id", pPlayer->entindex() );
pEvent->SetFloat( "worldPosX", trace.endpos.x );
pEvent->SetFloat( "worldPosY", trace.endpos.y );
pEvent->SetFloat( "worldPosZ", trace.endpos.z );
pEvent->SetFloat( "worldNormalX", trace.plane.normal.x );
pEvent->SetFloat( "worldNormalY", trace.plane.normal.y );
pEvent->SetFloat( "worldNormalZ", trace.plane.normal.z );
pEvent->SetFloat( "lifetime", 10.0f );
if ( pHitEntity )
{
pEvent->SetInt( "follow_entindex", pHitEntity->entindex() );
}
pEvent->SetInt( "visibilityBitfield", ( 1 << pPlayer->entindex() | 1 << pPlayer->GetStudent()->entindex() ) );
pEvent->SetBool( "show_distance", true );
pEvent->SetBool( "show_effect", true );
switch ( command )
{
case kCoachCommand_Attack:
pEvent->SetString( "text", pHitEntity ? "#TF_Coach_AttackThis" : "#TF_Coach_AttackHere" );
pEvent->SetString( "play_sound", "coach/coach_attack_here.wav" );
break;
case kCoachCommand_Defend:
pEvent->SetString( "text", pHitEntity ? "#TF_Coach_DefendThis" : "#TF_Coach_DefendHere" );
pEvent->SetString( "play_sound", "coach/coach_defend_here.wav" );
break;
case kCoachCommand_Look:
pEvent->SetString( "text", pHitEntity ? "#TF_Coach_LookAt" : "#TF_Coach_LookHere" );
pEvent->SetString( "play_sound", "coach/coach_look_here.wav" );
break;
case kCoachCommand_Go:
pEvent->SetString( "text", pHitEntity ? "#TF_Coach_GoToThis" : "#TF_Coach_GoHere" );
pEvent->SetString( "play_sound", "coach/coach_go_here.wav" );
break;
}
gameeventmanager->FireEvent( pEvent );
}
}
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFPlayer::CTFPlayer()
{
m_pAttributes = this;
m_PlayerAnimState = CreateTFPlayerAnimState( this );
SetArmorValue( 10 );
m_hItem = NULL;
m_hTauntScene = NULL;
m_hTauntProp = NULL;
m_flTauntNextStartTime = -1.f;
UseClientSideAnimation();
m_angEyeAngles.Init();
m_pStateInfo = NULL;
m_lifeState = LIFE_DEAD; // Start "dead".
m_iMaxSentryKills = 0;
m_flLastCoachCommand = 0;
m_flNextTimeCheck = gpGlobals->curtime;
m_flSpawnTime = 0;
m_flWaterExitTime = 0;
SetViewOffset( TF_PLAYER_VIEW_OFFSET );
m_Shared.Init( this );
m_iLastSkin = -1;
m_bHudClassAutoKill = false;
m_bMedigunAutoHeal = false;
m_vecLastDeathPosition = Vector( FLT_MAX, FLT_MAX, FLT_MAX );
SetDesiredPlayerClassIndex( TF_CLASS_UNDEFINED );
SetContextThink( &CTFPlayer::TFPlayerThink, gpGlobals->curtime, "TFPlayerThink" );
m_flLastAction = gpGlobals->curtime;
m_flTimeInSpawn = 0;
m_bInitTaunt = false;
m_bSpeakingConceptAsDisguisedSpy = false;
m_nMannpowerKills = 0;
m_nMannpowerDeaths = 0;
m_bMannpowerHereForFullInterval = false;
m_iPreviousteam = TEAM_UNASSIGNED;
m_bArenaSpectator = false;
m_bArenaIsAFK = false;
m_bIsAFK = false;
m_nDeployingBombState = TF_BOMB_DEPLOYING_NONE;
m_flNextChangeClassTime = 0.0f;
m_flNextChangeTeamTime = 0.0f;