Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions scripting/randomizer/sdkhook.sp
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,6 @@ public Action Client_WeaponEquip(int iClient, int iWeapon)
{
SetEntPropEnt(iWeapon, Prop_Send, "m_hOwnerEntity", iClient); //So client's class can be attempted first for TF2_GetDefaultClassFromItem

ViewModels_UpdateArms(iClient, iWeapon); // Set arms for the weapon were about to equip

//Change class before equipping the weapon, otherwise anims and reload times are odd
SetClientClass(iClient, TF2_GetDefaultClassFromItem(iWeapon));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix was added before the whole viewmodel update. While most anims and reload times does seems to have fixed itself from the update, It's however still needed for the first draw animation (along with ViewModels_UpdateArms in this hook). Comment could've been updated to reflect this current situation, or whenever if there is another solution to fix this without needing a class change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any changes after removing it. Any weapons in particular that get affected by it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any weapons, only happens when switching to it for the first time.

2023-03-05.18-51-57.mp4


// Don't allow robotarm model screw up anims
if (TF2Attrib_HookValueFloat(0.0, "wrench_builds_minisentry", iClient) == 1.0)
TF2Attrib_SetByName(iClient, "mod wrench builds minisentry", -1.0); // 1.0 + -1.0 = 0.0
Expand All @@ -268,8 +263,6 @@ public void Client_WeaponEquipPost(int iClient, int iWeapon)
{
TF2Attrib_RemoveByName(iClient, "mod wrench builds minisentry");

RevertClientClass(iClient);

ViewModels_UpdateArms(iClient);

//Refresh controls and huds
Expand All @@ -279,8 +272,6 @@ public void Client_WeaponEquipPost(int iClient, int iWeapon)

public Action Client_WeaponSwitch(int iClient, int iWeapon)
{
ViewModels_UpdateArms(iClient); // Incase if weapons were to be not properly set up yet for draw animation

//Save current active weapon properties before potentally switched out
Properties_SaveActiveWeaponAmmo(iClient);

Expand Down
21 changes: 10 additions & 11 deletions scripting/randomizer/viewmodels.sp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,16 @@ void ViewModels_UpdateArms(int iClient, int iForceWeapon = INVALID_ENT_REFERENCE
else
sModel = g_sViewModelsArms[nClass];

int iModelIndex = GetModelIndex(sModel);
if (GetEntProp(iViewModel, Prop_Send, "m_nModelIndex") != iModelIndex)
SetEntProp(iViewModel, Prop_Send, "m_nModelIndex", iModelIndex);
if(iActiveWeapon != INVALID_ENT_REFERENCE)
{
SetEntityModel(iActiveWeapon, sModel);
SetEntProp(iActiveWeapon, Prop_Send, "m_nCustomViewmodelModelIndex", GetEntProp(iActiveWeapon, Prop_Send, "m_nModelIndex"));
SetEntProp(iActiveWeapon, Prop_Send, "m_iViewModelIndex", GetEntProp(iActiveWeapon, Prop_Send, "m_nModelIndex"));
}

//int iModelIndex = GetModelIndex(sModel);
//if (GetEntProp(iViewModel, Prop_Send, "m_nModelIndex") != iModelIndex)
// SetEntProp(iViewModel, Prop_Send, "m_nModelIndex", iModelIndex);
}

int iArmsModelIndex = GetModelIndex(g_sViewModelsArms[TF2_GetPlayerClass(iClient)]);
Expand All @@ -101,14 +108,6 @@ void ViewModels_UpdateArms(int iClient, int iForceWeapon = INVALID_ENT_REFERENCE
SetEntPropEnt(iArms, Prop_Send, "m_hWeaponAssociatedWith", iActiveWeapon);
SetEntPropEnt(iWearable, Prop_Send, "m_hWeaponAssociatedWith", iActiveWeapon);
}

int iMaxWeapons = GetMaxWeapons();
for (int i = 0; i < iMaxWeapons; i++)
{
int iWeapon = GetEntPropEnt(iClient, Prop_Send, "m_hMyWeapons", i);
if (iWeapon != INVALID_ENT_REFERENCE)
SetEntProp(iWeapon, Prop_Send, "m_nCustomViewmodelModelIndex", GetEntProp(iWeapon, Prop_Send, "m_nModelIndex"));
}
}

int ViewModels_CreateWearable(int iClient, int iModelIndex, int iWeapon = INVALID_ENT_REFERENCE)
Expand Down