Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit 6ce981a

Browse files
committed
nSkinz advancedfx-v0.1.19
- Fixes quick switch knife animation problems (#31).
1 parent 475f6a9 commit 6ce981a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/Hooks/Sequence.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,10 +563,18 @@ static auto do_sequence_remapping(sdk::C_BaseViewModel* entity, int nSequence) -
563563

564564
static std::map<void*,vmt_multi_hook *> C_BaseViewModel_SetSequence_hooks;
565565

566+
void * g_setsequence_called = nullptr;
567+
sdk::C_BaseViewModel* g_setsequence_This = nullptr;
568+
int g_setsequence_value = 0;
569+
566570
auto __fastcall hooks::C_BaseViewModel_SetSequence::hooked(sdk::C_BaseViewModel* This, void* Edx, int nSequence) -> void
567571
{
568572
auto &pHook = C_BaseViewModel_SetSequence_hooks[*(void**)This];
569-
pHook->get_original_function<void (__fastcall *)(sdk::C_BaseViewModel*, void*, int)>(219)(This, Edx, do_sequence_remapping(This, nSequence));
573+
g_setsequence_value = nSequence;
574+
g_setsequence_This = This;
575+
g_setsequence_called = pHook->get_original_function<void(__fastcall*)(sdk::C_BaseViewModel*, void*, int)>(219);
576+
int newSequence = do_sequence_remapping(This, nSequence);
577+
((void (__fastcall *)(sdk::C_BaseViewModel*, void*, int))g_setsequence_called)(This, Edx, newSequence);
570578
}
571579

572580
void hook_C_BaseViewModel_SetSequence(sdk::C_BaseViewModel* thisptr) {
@@ -588,9 +596,6 @@ int g_modelindex_value = 0;
588596

589597
auto __cdecl hooks::modelindex_proxy_fn(const sdk::CRecvProxyData* proxy_data_const, void* entity, void* output) -> void
590598
{
591-
// The problem is that model index is set before we know the weapon handle, so we cache it off and fix it up after weapon handle is set,
592-
// assuming that weapon handle changes when model index changes.
593-
594599
g_modelindex_called = true;
595600
g_modelindex_value = proxy_data_const->m_Value.m_Int;
596601
}
@@ -619,4 +624,10 @@ auto __cdecl hooks::weapon_proxy_fn(const sdk::CRecvProxyData* proxy_data_const,
619624
// Fake in model index call as good as we can (good enough I guess):
620625
g_modelindex_hook->get_original_function()(&data, view_model, &(view_model->GetModelIndex()));
621626
}
627+
628+
if (g_setsequence_called && g_setsequence_This == view_model) {
629+
int newSequence = do_sequence_remapping(view_model, g_setsequence_value);
630+
((void(__fastcall*)(sdk::C_BaseViewModel*, void*, int))g_setsequence_called)(g_setsequence_This, 0, newSequence);
631+
}
632+
g_setsequence_called = nullptr;
622633
}

src/gui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void draw_gui()
263263
ImGui::PopItemWidth();
264264
ImGui::Columns(1);
265265

266-
ImGui::Text("nSkinz by namazso (advancedfx-v0.1.18)");
266+
ImGui::Text("nSkinz by namazso (advancedfx-v0.1.19)");
267267

268268
ImGui::End();
269269
}

0 commit comments

Comments
 (0)