33#define DEBUG
44
55#define PLUGIN_AUTHOR " BattlefieldDuck"
6- #define PLUGIN_VERSION " 4.7 "
6+ #define PLUGIN_VERSION " 4.8 "
77
88#include <sourcemod>
99#include <sdkhooks>
@@ -41,6 +41,17 @@ static const int g_iPhysicsGunQuality = 1;
4141static const int g_iPhysicsGunLevel = 99 - 128 ; //Level displays as 99 but negative level ensures this is unique
4242static const int g_iPhysicsGunColor [4 ] = {0 , 191 , 255 , 255 };
4343
44+ enum PhysicsGunSequence
45+ {
46+ IDLE = 0 ,
47+ HOLD_IDLE ,
48+ DRAW ,
49+ HOLSTER ,
50+ FIRE ,
51+ ALTFIRE ,
52+ CHARGEUP
53+ }
54+
4455ConVar g_cvbCanGrabBuild ;
4556
4657int g_iModelIndex ;
@@ -49,6 +60,7 @@ int g_iPhysicsGunVM;
4960int g_iPhysicsGunWM ;
5061
5162bool g_bPhysGunMode [MAXPLAYERS + 1 ];
63+ bool g_bIN_ATTACK [MAXPLAYERS + 1 ];
5264bool g_bIN_ATTACK2 [MAXPLAYERS + 1 ];
5365
5466int g_iAimingEntityRef [MAXPLAYERS + 1 ]; //Aimming entity ref
@@ -67,6 +79,8 @@ float g_fCopyCD[MAXPLAYERS + 1];
6779
6880public void OnPluginStart ()
6981{
82+ CreateConVar (" sm_tf2sb_physgun_version" , PLUGIN_VERSION , " " , FCVAR_SPONLY | FCVAR_NOTIFY );
83+
7084 RegAdminCmd (" sm_physgun" , Command_EquipPhysicsGun , 0 , " Equip a Physics Gun" );
7185 RegAdminCmd (" sm_physicsgun" , Command_EquipPhysicsGun , 0 , " Equip a Physics Gun" );
7286
@@ -539,7 +553,7 @@ int Duplicator(int iEntity)
539553 return - 1 ;
540554}
541555
542- stock void ClientSettings (int client , int &buttons , int &impulse , float vel [3 ], float angles [3 ], int &weapon , int &subtype , int &cmdnum , int &tickcount , int &seed , int mouse [2 ])
556+ void ClientSettings (int client , int &buttons , int &impulse , float vel [3 ], float angles [3 ], int &weapon , int &subtype , int &cmdnum , int &tickcount , int &seed , int mouse [2 ])
543557{
544558 int iViewModel = GetEntPropEnt (client , Prop_Send , " m_hViewModel" );
545559 if (IsHoldingPhysicsGun (client ) && EntRefToEntIndex (g_iClientVMRef [client ]) == INVALID_ENT_REFERENCE )
@@ -549,13 +563,52 @@ stock void ClientSettings(int client, int &buttons, int &impulse, float vel[3],
549563
550564 //Create client physics gun viewmodel
551565 g_iClientVMRef [client ] = EntIndexToEntRef (CreateVM (client , g_iPhysicsGunVM ));
566+
567+ int iTFViewModel = EntRefToEntIndex (g_iClientVMRef [client ]);
568+ if (IsValidEntity (iTFViewModel ))
569+ {
570+ SetEntProp (iTFViewModel , Prop_Send , " m_nSequence" , view_as <PhysicsGunSequence >(DRAW ));
571+ SetEntPropFloat (iTFViewModel , Prop_Send , " m_flPlaybackRate" , 3.0 );
572+ }
552573 }
553574 //Remove client physics gun viewmodel
554575 else if (! IsHoldingPhysicsGun (client ) && EntRefToEntIndex (g_iClientVMRef [client ]) != INVALID_ENT_REFERENCE )
555576 {
556577 AcceptEntityInput (EntRefToEntIndex (g_iClientVMRef [client ]), " Kill" );
557578 }
558579
580+ if (IsHoldingPhysicsGun (client ))
581+ {
582+ int iTFViewModel = EntRefToEntIndex (g_iClientVMRef [client ]);
583+
584+ if (buttons & IN_ATTACK )
585+ {
586+ if (IsValidEntity (iTFViewModel ))
587+ {
588+ if (! g_bIN_ATTACK [client ])
589+ {
590+ g_bIN_ATTACK [client ] = true ;
591+
592+ SetEntProp (iTFViewModel , Prop_Send , " m_nSequence" , view_as <PhysicsGunSequence >(FIRE ));
593+ SetEntPropFloat (iTFViewModel , Prop_Send , " m_flPlaybackRate" , 1.5 );
594+ }
595+ }
596+ }
597+ else
598+ {
599+ if (IsValidEntity (iTFViewModel ))
600+ {
601+ if (g_bIN_ATTACK [client ])
602+ {
603+ SetEntProp (iTFViewModel , Prop_Send , " m_nSequence" , view_as <PhysicsGunSequence >(IDLE ));
604+ SetEntPropFloat (iTFViewModel , Prop_Send , " m_flPlaybackRate" , 0.0 );
605+ }
606+ }
607+
608+ g_bIN_ATTACK [client ] = false ;
609+ }
610+ }
611+
559612 if (IsHoldingPhysicsGun (client ) && buttons & IN_ATTACK )
560613 {
561614 if (buttons & IN_ATTACK )
@@ -564,12 +617,6 @@ stock void ClientSettings(int client, int &buttons, int &impulse, float vel[3],
564617 SDKHook (client , SDKHook_WeaponCanSwitchTo , BlockWeaponSwitch );
565618 SetEntProp (client , Prop_Send , " m_iHideHUD" , GetEntProp (client , Prop_Send , " m_iHideHUD" ) | HIDEHUD_WEAPONSELECTION );
566619
567- int iTFViewModel = EntRefToEntIndex (g_iClientVMRef [client ]);
568- if (IsValidEntity (iTFViewModel ) && GetEntProp (iTFViewModel , Prop_Send , " m_nSequence" ) != 1 )
569- {
570- SetEntProp (iTFViewModel , Prop_Send , " m_nSequence" , 1 );
571- }
572-
573620 //Fix client eyes angles
574621 if (buttons & IN_RELOAD || buttons & IN_ATTACK3 )
575622 {
@@ -580,14 +627,6 @@ stock void ClientSettings(int client, int &buttons, int &impulse, float vel[3],
580627 if (GetEntityFlags (client ) & FL_FROZEN ) SetEntityFlags (client , (GetEntityFlags (client ) & ~ FL_FROZEN ));
581628 }
582629 }
583- else
584- {
585- int iTFViewModel = EntRefToEntIndex (g_iClientVMRef [client ]);
586- if (IsValidEntity (iTFViewModel ) && GetEntProp (iTFViewModel , Prop_Send , " m_nSequence" ) != 0 )
587- {
588- SetEntProp (iTFViewModel , Prop_Send , " m_nSequence" , 0 );
589- }
590- }
591630 }
592631 else
593632 {
@@ -1032,10 +1071,10 @@ char[] GetEntityName(int entity)
10321071
10331072void AnglesNormalize (float vAngles [3 ])
10341073{
1035- while (vAngles [0 ] > 89.0 )vAngles [0 ] -= 360.0 ;
1036- while (vAngles [0 ] < - 89.0 )vAngles [0 ] += 360.0 ;
1037- while (vAngles [1 ] > 180.0 )vAngles [1 ] -= 360.0 ;
1038- while (vAngles [1 ] < - 180.0 )vAngles [1 ] += 360.0 ;
1039- while (vAngles [2 ] < - 0.0 )vAngles [2 ] += 360.0 ;
1040- while (vAngles [2 ] >= 360.0 )vAngles [2 ] -= 360.0 ;
1074+ while (vAngles [0 ] > 89.0 ) vAngles [0 ] -= 360.0 ;
1075+ while (vAngles [0 ] < - 89.0 ) vAngles [0 ] += 360.0 ;
1076+ while (vAngles [1 ] > 180.0 ) vAngles [1 ] -= 360.0 ;
1077+ while (vAngles [1 ] < - 180.0 ) vAngles [1 ] += 360.0 ;
1078+ while (vAngles [2 ] < - 0.0 ) vAngles [2 ] += 360.0 ;
1079+ while (vAngles [2 ] >= 360.0 ) vAngles [2 ] -= 360.0 ;
10411080}
0 commit comments