Skip to content

Commit

Permalink
Fix quirky viewmodels from red team
Browse files Browse the repository at this point in the history
  • Loading branch information
FortyTwoFortyTwo committed Aug 15, 2023
1 parent 4ee5af6 commit 281ae0b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
5 changes: 1 addition & 4 deletions addons/sourcemod/scripting/superzombiefortress.sp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "include/superzombiefortress.inc"

#define PLUGIN_VERSION "4.6.0"
#define PLUGIN_VERSION "4.6.1"
#define PLUGIN_VERSION_REVISION "manual"

#define MAX_CONTROL_POINTS 8
Expand Down Expand Up @@ -2520,9 +2520,6 @@ public Action OnPlayerRunCmd(int iClient, int &iButtons, int &iImpulse, float fV

Action OnGiveNamedItem(int iClient, const char[] sClassname, int iIndex)
{
// Reset arms so generated weapons don't get the wrong viewmodel
ViewModel_ResetArms(iClient);

if (g_bGiveNamedItemSkip || TF2_IsPlayerInCondition(iClient, TFCond_Disguised))
return Plugin_Continue;

Expand Down
11 changes: 11 additions & 0 deletions addons/sourcemod/scripting/szf/sdkhook.sp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void SDKHook_OnEntityCreated(int iEntity, const char[] sClassname)

void SDKHook_HookClient(int iClient)
{
SDKHook(iClient, SDKHook_Spawn, Client_Spawn);
SDKHook(iClient, SDKHook_PreThink, Client_PreThink);
SDKHook(iClient, SDKHook_PreThinkPost, Client_PreThinkPost);
SDKHook(iClient, SDKHook_Touch, Client_Touch);
Expand All @@ -37,6 +38,7 @@ void SDKHook_HookClient(int iClient)

void SDKHook_UnhookClient(int iClient)
{
SDKUnhook(iClient, SDKHook_Spawn, Client_Spawn);
SDKUnhook(iClient, SDKHook_PreThink, Client_PreThink);
SDKUnhook(iClient, SDKHook_PreThinkPost, Client_PreThinkPost);
SDKUnhook(iClient, SDKHook_Touch, Client_Touch);
Expand All @@ -45,6 +47,15 @@ void SDKHook_UnhookClient(int iClient)
SDKUnhook(iClient, SDKHook_WeaponSwitchPost, Client_WeaponSwitchPost);
}

public Action Client_Spawn(int iClient)
{
Classes_SetClient(iClient);

// Reset arms so generated weapons don't get the wrong viewmodel
ViewModel_ResetArms(iClient);
return Plugin_Continue;
}

public Action Client_PreThink(int iClient)
{
if (!g_iOffsetDisguiseCompleteTime)
Expand Down
16 changes: 2 additions & 14 deletions addons/sourcemod/scripting/szf/viewmodel.sp
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,9 @@ void ViewModel_ResetArms(int iClient)
return;

int iViewModel = GetEntPropEnt(iClient, Prop_Send, "m_hViewModel");
int iModelIndex = GetModelIndex(g_sViewModelsArms[nClass]);
if (iViewModel != INVALID_ENT_REFERENCE)
SetEntityModel(iViewModel, g_sViewModelsArms[nClass]);

SetEntityModel(iViewModel, g_sViewModelsArms[nClass]);
SetEntProp(iViewModel, Prop_Send, "m_nModelIndex", iModelIndex);

for (int iSlot = WeaponSlot_Primary; iSlot <= WeaponSlot_BuilderEngie; iSlot++)
{
int iWeapon = GetPlayerWeaponSlot(iClient, iSlot);
if (iWeapon == INVALID_ENT_REFERENCE)
continue;

SetEntityModel(iWeapon, g_sViewModelsArms[nClass]);
SetEntProp(iWeapon, Prop_Send, "m_iViewModelIndex", iModelIndex);
SetEntProp(iWeapon, Prop_Send, "m_nCustomViewmodelModelIndex", iModelIndex);
}
}

void ViewModel_SetAnimation(int iClient, const char[] sActivity)
Expand Down

0 comments on commit 281ae0b

Please sign in to comment.