33#define DEBUG
44
55#define PLUGIN_AUTHOR " BattlefieldDuck"
6- #define PLUGIN_VERSION " 1.6 "
6+ #define PLUGIN_VERSION " 1.7 "
77
88#include <sourcemod>
99#include <sdkhooks>
@@ -114,7 +114,7 @@ public void OnClientPutInServer(int client)
114114 SDKHook (client , SDKHook_WeaponSwitchPost , WeaponSwitchHookPost );
115115
116116 g_iClientVMRef [client ] = INVALID_ENT_REFERENCE ;
117- g_iAimPointRef [client ] = EntIndexToEntRef ( CreateAimPoint ()) ;
117+ g_iAimPointRef [client ] = INVALID_ENT_REFERENCE ;
118118 g_iCopyEntityRef [client ] = INVALID_ENT_REFERENCE ;
119119}
120120
@@ -220,6 +220,7 @@ public Action WeaponSwitchHookPost(int client, int entity)
220220 return Plugin_Continue ;
221221}
222222
223+ #define MAX_TOOLS 10
223224public Action OnPlayerRunCmd (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 ])
224225{
225226 int iViewModel = GetEntPropEnt (client , Prop_Send , " m_hViewModel" );
@@ -536,6 +537,52 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
536537 }
537538 }
538539 }
540+ //Set Sequences
541+ case (9 ):
542+ {
543+ if (IsValidEntity (entity ))
544+ {
545+ if ((buttons & IN_ATTACK ) || (buttons & IN_ATTACK2 ))
546+ {
547+ int iSequence = GetEntProp (entity , Prop_Send , " m_nSequence" );
548+ if (buttons & IN_ATTACK )
549+ {
550+ iSequence += 1 ;
551+ }
552+ else if (buttons & IN_ATTACK2 && iSequence > 0 )
553+ {
554+ iSequence -= 1 ;
555+ }
556+
557+ SetEntProp (entity , Prop_Send , " m_nSequence" , iSequence );
558+
559+ PrintCenterText (client , " Sequence: %i " , iSequence );
560+ }
561+ }
562+ }
563+ //Set Animation
564+ case (10 ):
565+ {
566+ if (IsValidEntity (entity ))
567+ {
568+ if (buttons & IN_ATTACK )
569+ {
570+ if (SetAnimation (entity ))
571+ {
572+ PrintCenterText (client , " Set Animation successfully" );
573+ }
574+ else
575+ {
576+ PrintCenterText (client , " No Animation found!" );
577+ }
578+ }
579+ else if (buttons & IN_ATTACK2 )
580+ {
581+ SetVariantString (" 0.0" );
582+ AcceptEntityInput (entity , " SetPlaybackRate" );
583+ }
584+ }
585+ }
539586 }
540587 }
541588 else if (g_fToolsCD [client ] > 0.0 )
@@ -552,7 +599,14 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
552599
553600 EmitSoundToClient (client , SONND_TOOLGUN_SELECT , client , SNDCHAN_AUTO , SNDLEVEL_NORMAL , SND_NOFLAGS , 1.0 , 100 );
554601
555- (g_iTools [client ] < 8 )? (g_iTools [client ]++ ) : (g_iTools [client ] = 0 );
602+ if (buttons & IN_DUCK )
603+ {
604+ (g_iTools [client ] > 0 )? (g_iTools [client ]-- ) : (g_iTools [client ] = MAX_TOOLS );
605+ }
606+ else
607+ {
608+ (g_iTools [client ] < MAX_TOOLS )? (g_iTools [client ]++ ) : (g_iTools [client ] = 0 );
609+ }
556610
557611 //Reset value
558612 if (g_iTools [client ] == 3 )
@@ -578,7 +632,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
578632 }
579633
580634 char display [170 ];
581- Format (display , sizeof (display ), " ------------------------\n %s \n ------------------------\n [MOUSE1] %s \n [MOUSE2] %s \n [RELOAD] Switch Tools (%i )"
635+ Format (display , sizeof (display ), " ------------------------\n %s \n ------------------------\n [MOUSE1] %s \n [MOUSE2] %s \n [RELOAD] Next Tool (%i )"
582636 , GetToolDisplay (g_iTools [client ], client ), GetToolMouse1 (g_iTools [client ]), GetToolMouse2 (g_iTools [client ]), g_iTools [client ]);
583637
584638 if (g_iTools [client ] == 8 )
@@ -629,8 +683,14 @@ void TE_SendLaser(int client)
629683
630684 int clientvm = EntRefToEntIndex (g_iClientVMRef [client ]);
631685 int iAimPoint = EntRefToEntIndex (g_iAimPointRef [client ]);
632- if (clientvm != INVALID_ENT_REFERENCE && iAimPoint != INVALID_ENT_REFERENCE )
686+ if (clientvm != INVALID_ENT_REFERENCE )
633687 {
688+ if (iAimPoint == INVALID_ENT_REFERENCE )
689+ {
690+ iAimPoint = CreateAimPoint ();
691+ g_iAimPointRef [client ] = EntIndexToEntRef (iAimPoint );
692+ }
693+
634694 TeleportEntity (iAimPoint , GetClientAimPosition (client ), NULL_VECTOR , NULL_VECTOR );
635695
636696 TE_SetupBeamEnts (iAimPoint , EntRefToEntIndex (g_iClientVMRef [client ]), g_iModelIndex , g_iHaloIndex , 0 , 15 , 0.1 , 1.0 , 1.0 , 1 , 0.0 , {255 , 255 , 255 , 255 }, 10 , 20 );
@@ -694,38 +754,17 @@ int TF2_EquipWearable(int client, int entity)
694754
695755int CreateAimPoint ()
696756{
697- int iAimPoint = CreateEntityByName (" prop_dynamic_override" );
698- DispatchKeyValue (iAimPoint , " model" , MODEL_TOOLGUNWM );
757+ int iAimPoint = CreateEntityByName (" prop_dynamic_override" );
758+
759+ SetEntityModel (iAimPoint , MODEL_TOOLGUNWM );
699760
700761 SetEntPropFloat (iAimPoint , Prop_Send , " m_flModelScale" , 0.0 );
701762
702763 DispatchSpawn (iAimPoint );
764+
703765 return iAimPoint ;
704766}
705767
706- //Normally 2 is okay but 4 is more secure
707- #define FRAME_DELAY 5
708-
709- //Credits: Pelipoika
710- public void KillAimPointPost (int entity )
711- {
712- static int iFrame = 0 ;
713-
714- if (++ iFrame < FRAME_DELAY )
715- {
716- RequestFrame (KillAimPointPost , entity );
717- return ;
718- }
719-
720- int iAimPoint = EntRefToEntIndex (entity );
721- if (iAimPoint != INVALID_ENT_REFERENCE )
722- {
723- AcceptEntityInput (iAimPoint , " Kill" );
724- }
725-
726- iFrame = 0 ;
727- }
728-
729768//Credits: Alienmario
730769void TE_SetupBeamEnts (int ent1 , int ent2 , int ModelIndex , int HaloIndex , int StartFrame , int FrameRate , float Life , float Width , float EndWidth , int FadeLength , float Amplitude , const int Color [4 ], int Speed , int flags )
731770{
@@ -753,13 +792,15 @@ float[] GetClientEyePositionEx(int client)
753792{
754793 float pos [3 ];
755794 GetClientEyePosition (client , pos );
795+
756796 return pos ;
757797}
758798
759799float [] GetClientEyeAnglesEx (int client )
760800{
761801 float angles [3 ];
762802 GetClientEyeAngles (client , angles );
803+
763804 return angles ;
764805}
765806
@@ -774,6 +815,7 @@ float[] GetClientAimPosition(int client)
774815 }
775816
776817 CloseHandle (trace );
818+
777819 return endpos ;
778820}
779821
@@ -825,22 +867,27 @@ public bool TraceEntityFilter(int entity, int mask, int client)
825867int Duplicator (int iEntity )
826868{
827869 //Get Value
828- float fOrigin [3 ], fAngles [3 ], fSize ;
870+ float fOrigin [3 ], fAngles [3 ];
829871 char szModel [64 ], szName [128 ], szClass [32 ];
830- int iCollision , iRed , iGreen , iBlue , iAlpha , iSkin ;
831- RenderFx EntityRenderFx ;
832-
872+ int iRed , iGreen , iBlue , iAlpha ;
873+
833874 GetEntityClassname (iEntity , szClass , sizeof (szClass ));
875+
876+ if (StrEqual (szClass , " prop_dynamic" ))
877+ {
878+ szClass = " prop_dynamic_override" ;
879+ }
880+ else if (StrEqual (szClass , " prop_physics" ))
881+ {
882+ szClass = " prop_physics_override" ;
883+ }
884+
834885 GetEntPropString (iEntity , Prop_Data , " m_ModelName" , szModel , sizeof (szModel ));
835886 GetEntPropVector (iEntity , Prop_Send , " m_vecOrigin" , fOrigin );
836887 GetEntPropVector (iEntity , Prop_Data , " m_angRotation" , fAngles );
837- iCollision = GetEntProp (iEntity , Prop_Data , " m_CollisionGroup" , 4 );
838- fSize = GetEntPropFloat (iEntity , Prop_Send , " m_flModelScale" );
839888 GetEntityRenderColor (iEntity , iRed , iGreen , iBlue , iAlpha );
840- EntityRenderFx = GetEntityRenderFx (iEntity );
841- iSkin = GetEntProp (iEntity , Prop_Send , " m_nSkin" );
842889 GetEntPropString (iEntity , Prop_Data , " m_iName" , szName , sizeof (szName ));
843-
890+
844891 int iNewEntity = CreateEntityByName (szClass );
845892 if (iNewEntity > MaxClients && IsValidEntity (iNewEntity ))
846893 {
@@ -852,24 +899,83 @@ int Duplicator(int iEntity)
852899 PrecacheModel (szModel );
853900 }
854901
855- DispatchKeyValue (iNewEntity , " model " , szModel );
902+ SetEntityModel (iNewEntity , szModel );
856903 TeleportEntity (iNewEntity , fOrigin , fAngles , NULL_VECTOR );
857904 DispatchSpawn (iNewEntity );
858- SetEntData (iNewEntity , FindSendPropInfo (" CBaseEntity" , " m_CollisionGroup" ), iCollision , 4 , true );
859- SetEntPropFloat (iNewEntity , Prop_Send , " m_flModelScale" , fSize );
860- if (iAlpha < 255 ) SetEntityRenderMode (iNewEntity , RENDER_TRANSCOLOR );
861- else SetEntityRenderMode (iNewEntity , RENDER_NORMAL );
905+ SetEntData (iNewEntity , FindSendPropInfo (" CBaseEntity" , " m_CollisionGroup" ), GetEntProp (iEntity , Prop_Data , " m_CollisionGroup" , 4 ), 4 , true );
906+ SetEntPropFloat (iNewEntity , Prop_Send , " m_flModelScale" , GetEntPropFloat (iEntity , Prop_Send , " m_flModelScale" ));
907+ (iAlpha < 255 ) ? SetEntityRenderMode (iNewEntity , RENDER_TRANSCOLOR ) : SetEntityRenderMode (iNewEntity , RENDER_NORMAL );
862908 SetEntityRenderColor (iNewEntity , iRed , iGreen , iBlue , iAlpha );
863- SetEntityRenderFx (iNewEntity , EntityRenderFx );
864- SetEntProp (iNewEntity , Prop_Send , " m_nSkin" , iSkin );
909+ SetEntityRenderFx (iNewEntity , GetEntityRenderFx ( iEntity ) );
910+ SetEntProp (iNewEntity , Prop_Send , " m_nSkin" , GetEntProp ( iEntity , Prop_Send , " m_nSkin " ) );
865911 SetEntPropString (iNewEntity , Prop_Data , " m_iName" , szName );
866-
912+
867913 return iNewEntity ;
868914 }
869915
870916 return - 1 ;
871917}
872918
919+ bool SetAnimation (int entity )
920+ {
921+ char szModel [64 ];
922+ GetEntPropString (entity , Prop_Data , " m_ModelName" , szModel , sizeof (szModel ));
923+
924+ if (StrContains (szModel , " pickup_powerup_" ) != - 1
925+ || StrEqual (szModel , " models/items/tf_gift.mdl" )
926+ || StrEqual (szModel , " models/props_halloween/halloween_gift.mdl" )
927+ || StrEqual (szModel , " models/flag/briefcase.mdl" )
928+ || StrEqual (szModel , " models/flag/ticket_case.mdl" )
929+ || StrEqual (szModel , " models/props_doomsday/australium_container.mdl" )
930+ || StrEqual (szModel , " models/buggy.mdl" ))
931+ {
932+ SetEntProp (entity , Prop_Send , " m_nSequence" , 0 );
933+
934+ SetVariantString (" spin" );
935+ AcceptEntityInput (entity , " SetAnimation" );
936+ AcceptEntityInput (entity , " Enable" );
937+
938+ return true ;
939+ }
940+ else if (StrContains (szModel , " ammopack_" ) != - 1
941+ || StrContains (szModel , " medkit_" ) != - 1
942+ || StrContains (szModel , " currencypack_" ) != - 1
943+ || StrEqual (szModel , " models/items/plate_robo_sandwich.mdl" )
944+ || StrEqual (szModel , " models/items/plate_sandwich_xmas.mdl" )
945+ || StrEqual (szModel , " models/items/plate.mdl" ))
946+ {
947+ SetEntProp (entity , Prop_Send , " m_nSequence" , 0 );
948+
949+ SetVariantString (" idle" );
950+ AcceptEntityInput (entity , " SetAnimation" );
951+ AcceptEntityInput (entity , " Enable" );
952+
953+ return true ;
954+ }
955+ else if (StrContains (szModel , " models/bots/boss_bot/tank_track" ) != - 1 )
956+ {
957+ SetEntProp (entity , Prop_Send , " m_nSequence" , 0 );
958+
959+ SetVariantString (" forward" );
960+ AcceptEntityInput (entity , " SetAnimation" );
961+ AcceptEntityInput (entity , " Enable" );
962+
963+ return true ;
964+ }
965+ else if (StrEqual (szModel , " models/bots/boss_bot/boss_tank.mdl" ))
966+ {
967+ SetEntProp (entity , Prop_Send , " m_nSequence" , 0 );
968+
969+ SetVariantString (" movement" );
970+ AcceptEntityInput (entity , " SetAnimation" );
971+ AcceptEntityInput (entity , " Enable" );
972+
973+ return true ;
974+ }
975+
976+ return false ;
977+ }
978+
873979#define SPACE " "
874980char [] GetToolDisplay (int tool , int client )
875981{
@@ -885,6 +991,8 @@ char[] GetToolDisplay(int tool, int client)
885991 case (6 ): toolname = " Set Skin " ;
886992 case (7 ): toolname = " Set Render Fx " ;
887993 case (8 ): toolname = " Set Effect " ;
994+ case (9 ): toolname = " Set Sequence " ;
995+ case (10 ): toolname = " Set Animation " ;
888996 }
889997
890998 Format (toolname , sizeof (toolname ), " %s%s%s " , SPACE , toolname , SPACE );
@@ -913,15 +1021,17 @@ char[] GetToolMouse1(int tool)
9131021 char mouse1 [30 ];
9141022 switch (tool )
9151023 {
916- case (0 ): mouse1 = " Remove" ;
917- case (1 ): mouse1 = " Larger" ;
918- case (2 ): mouse1 = " Collide" ;
919- case (3 ): mouse1 = " Copy" ;
920- case (4 ): mouse1 = " More Transparent" ;
921- case (5 ): mouse1 = " Next Color" ;
922- case (6 ): mouse1 = " Next Skin" ;
923- case (7 ): mouse1 = " Next Render Fx" ;
924- case (8 ): mouse1 = " Apply Effect" ;
1024+ case (0 ): mouse1 = " Remove" ;
1025+ case (1 ): mouse1 = " Larger" ;
1026+ case (2 ): mouse1 = " Collide" ;
1027+ case (3 ): mouse1 = " Copy" ;
1028+ case (4 ): mouse1 = " More Transparent" ;
1029+ case (5 ): mouse1 = " Next Color" ;
1030+ case (6 ): mouse1 = " Next Skin" ;
1031+ case (7 ): mouse1 = " Next Render Fx" ;
1032+ case (8 ): mouse1 = " Apply Effect" ;
1033+ case (9 ): mouse1 = " Next Sequence" ;
1034+ case (10 ): mouse1 = " Enable Animation" ;
9251035 }
9261036
9271037 return mouse1 ;
@@ -932,15 +1042,17 @@ char[] GetToolMouse2(int tool)
9321042 char mouse2 [60 ];
9331043 switch (tool )
9341044 {
935- case (0 ): mouse2 = " Remove" ;
936- case (1 ): mouse2 = " Smaller" ;
937- case (2 ): mouse2 = " No Collide" ;
938- case (3 ): mouse2 = " Paste" ;
939- case (4 ): mouse2 = " More Visible" ;
940- case (5 ): mouse2 = " Restore" ;
941- case (6 ): mouse2 = " Previous Skin" ;
942- case (7 ): mouse2 = " Previous Render Fx" ;
943- case (8 ): mouse2 = " Remove Effect\n [MOUSE3] Change Effect" ;
1045+ case (0 ): mouse2 = " Remove" ;
1046+ case (1 ): mouse2 = " Smaller" ;
1047+ case (2 ): mouse2 = " No Collide" ;
1048+ case (3 ): mouse2 = " Paste" ;
1049+ case (4 ): mouse2 = " More Visible" ;
1050+ case (5 ): mouse2 = " Restore" ;
1051+ case (6 ): mouse2 = " Previous Skin" ;
1052+ case (7 ): mouse2 = " Previous Render Fx" ;
1053+ case (8 ): mouse2 = " Remove Effect\n [MOUSE3] Change Effect" ;
1054+ case (9 ): mouse2 = " Previous Sequence" ;
1055+ case (10 ): mouse2 = " Disable Animation" ;
9441056 }
9451057
9461058 return mouse2 ;
@@ -971,7 +1083,7 @@ void TE_ParticleToAll(char[] Name, float origin[3] = NULL_VECTOR, float start[3]
9711083 }
9721084 }
9731085
974- if (stridx == INVALID_STRING_INDEX )
1086+ if (stridx == INVALID_STRING_INDEX )
9751087 {
9761088 LogError (" Could not find particle: %s " , Name );
9771089 return ;
0 commit comments