XBoom31 / ApocalyseCheatsSC

42 stars 31 forks source link

Not an issue but some helperino | knife animations fix #28

Closed eeioruewo0iruwe closed 7 years ago

eeioruewo0iruwe commented 7 years ago

Proxies.h

pragma once

include "Skins1.h"

include "Entities.h"

include "Interfaces.h"

include "ClientRecvProps.h"

// Store the original proxy functions. RecvVarProxyFn fnSequenceProxyFn = NULL;

// Function to fix sequences for certain models. void SetViewModelSequence(const CRecvProxyData pDataConst, void pStruct, void pOut) { // Make the incoming data editable. CRecvProxyData pData = const_cast<CRecvProxyData*>(pDataConst);

// Confirm that we are replacing our view model and not someone elses.
CBaseViewModel* pViewModel = (CBaseViewModel*)pStruct;

if (pViewModel) {
    IClientEntity* pOwner = Interfaces::EntList->GetClientEntityFromHandle(HANDLE(pViewModel->GetOwner()));

    // Compare the owner entity of this view model to the local player entity.
    if (pOwner && pOwner->GetIndex() == Interfaces::Engine->GetLocalPlayer()) {
        // Get the filename of the current view model.
        void* pModel = Interfaces::ModelInfo->GetModel(pViewModel->GetModelIndex());
        const char* szModel = Interfaces::ModelInfo->GetModelName(pModel);

        // Store the current sequence.
        int m_nSequence = pData->m_Value.m_Int;

        if (!strcmp(szModel, "models/weapons/v_knife_butterfly.mdl")) {
            // Fix animations for the Butterfly Knife.
            switch (m_nSequence) {
            case SEQUENCE_DEFAULT_DRAW:
                m_nSequence = RandomInt(SEQUENCE_BUTTERFLY_DRAW, SEQUENCE_BUTTERFLY_DRAW2); break;
            case SEQUENCE_DEFAULT_LOOKAT01:
                m_nSequence = RandomInt(SEQUENCE_BUTTERFLY_LOOKAT01, SEQUENCE_BUTTERFLY_LOOKAT03); break;
            default:
                m_nSequence++;
            }
        }
        else if (!strcmp(szModel, "models/weapons/v_knife_falchion_advanced.mdl")) {
            // Fix animations for the Falchion Knife.
            switch (m_nSequence) {
            case SEQUENCE_DEFAULT_IDLE2:
                m_nSequence = SEQUENCE_FALCHION_IDLE1; break;
            case SEQUENCE_DEFAULT_HEAVY_MISS1:
                m_nSequence = RandomInt(SEQUENCE_FALCHION_HEAVY_MISS1, SEQUENCE_FALCHION_HEAVY_MISS1_NOFLIP); break;
            case SEQUENCE_DEFAULT_LOOKAT01:
                m_nSequence = RandomInt(SEQUENCE_FALCHION_LOOKAT01, SEQUENCE_FALCHION_LOOKAT02); break;
            case SEQUENCE_DEFAULT_DRAW:
            case SEQUENCE_DEFAULT_IDLE1:
                break;
            default:
                m_nSequence--;
            }
        }
        else if (!strcmp(szModel, "models/weapons/v_knife_push.mdl")) {
            // Fix animations for the Shadow Daggers.
            switch (m_nSequence) {
            case SEQUENCE_DEFAULT_IDLE2:
                m_nSequence = SEQUENCE_DAGGERS_IDLE1; break;
            case SEQUENCE_DEFAULT_LIGHT_MISS1:
            case SEQUENCE_DEFAULT_LIGHT_MISS2:
                m_nSequence = RandomInt(SEQUENCE_DAGGERS_LIGHT_MISS1, SEQUENCE_DAGGERS_LIGHT_MISS5); break;
            case SEQUENCE_DEFAULT_HEAVY_MISS1:
                m_nSequence = RandomInt(SEQUENCE_DAGGERS_HEAVY_MISS2, SEQUENCE_DAGGERS_HEAVY_MISS1); break;
            case SEQUENCE_DEFAULT_HEAVY_HIT1:
            case SEQUENCE_DEFAULT_HEAVY_BACKSTAB:
            case SEQUENCE_DEFAULT_LOOKAT01:
                m_nSequence += 3; break;
            case SEQUENCE_DEFAULT_DRAW:
            case SEQUENCE_DEFAULT_IDLE1:
                break;
            default:
                m_nSequence += 2;
            }
        }
        else if (!strcmp(szModel, "models/weapons/v_knife_survival_bowie.mdl")) {
            // Fix animations for the Bowie Knife.
            switch (m_nSequence) {
            case SEQUENCE_DEFAULT_DRAW:
            case SEQUENCE_DEFAULT_IDLE1:
                break;
            case SEQUENCE_DEFAULT_IDLE2:
                m_nSequence = SEQUENCE_BOWIE_IDLE1; break;
            default:
                m_nSequence--;
            }
        }

        // Set the fixed sequence.
        pData->m_Value.m_Int = m_nSequence;
    }
}

// Call original function with the modified data.
fnSequenceProxyFn(pData, pStruct, pOut);

}

eeioruewo0iruwe commented 7 years ago

Skins1.h

pragma once

include "ClientRecvProps.h"

extern RecvVarProxyFn fnSequenceProxyFn;

define SEQUENCE_DEFAULT_DRAW 0

define SEQUENCE_DEFAULT_IDLE1 1

define SEQUENCE_DEFAULT_IDLE2 2

define SEQUENCE_DEFAULT_LIGHT_MISS1 3

define SEQUENCE_DEFAULT_LIGHT_MISS2 4

define SEQUENCE_DEFAULT_HEAVY_MISS1 9

define SEQUENCE_DEFAULT_HEAVY_HIT1 10

define SEQUENCE_DEFAULT_HEAVY_BACKSTAB 11

define SEQUENCE_DEFAULT_LOOKAT01 12

define SEQUENCE_BUTTERFLY_DRAW 0

define SEQUENCE_BUTTERFLY_DRAW2 1

define SEQUENCE_BUTTERFLY_LOOKAT01 13

define SEQUENCE_BUTTERFLY_LOOKAT03 15

define SEQUENCE_FALCHION_IDLE1 1

define SEQUENCE_FALCHION_HEAVY_MISS1 8

define SEQUENCE_FALCHION_HEAVY_MISS1_NOFLIP 9

define SEQUENCE_FALCHION_LOOKAT01 12

define SEQUENCE_FALCHION_LOOKAT02 13

define SEQUENCE_DAGGERS_IDLE1 1

define SEQUENCE_DAGGERS_LIGHT_MISS1 2

define SEQUENCE_DAGGERS_LIGHT_MISS5 6

define SEQUENCE_DAGGERS_HEAVY_MISS2 11

define SEQUENCE_DAGGERS_HEAVY_MISS1 12

define SEQUENCE_BOWIE_IDLE1 1

define LIFE_ALIVE 0

define RandomInt(nMin, nMax) (rand() % (nMax - nMin + 1) + nMin);

extern void SetViewModelSequence(const CRecvProxyData pDataConst, void pStruct, void *pOut);

eeioruewo0iruwe commented 7 years ago

AntiAntiAim.cpp

include "Proxies.h"

void ApplyAAAHooks() { ClientClass pClass = Interfaces::Client->GetAllClasses(); while (pClass) { const char pszName = pClass->m_pRecvTable->m_pNetTableName; if (!strcmp(pszName, "DT_CSPlayer")) { for (int i = 0; i < pClass->m_pRecvTable->m_nProps; i++) { RecvProp pProp = &(pClass->m_pRecvTable->m_pProps[i]); const char name = pProp->m_pVarName;

            // Pitch Fix
            if (!strcmp(name, "m_angEyeAngles[0]"))
            {
                pProp->m_ProxyFn = FixX;
            }

            // Yaw Fix
            if (!strcmp(name, "m_angEyeAngles[1]"))
            {
                Utilities::Log("Yaw Fix Applied");
                pProp->m_ProxyFn = FixY;
            }
        }
    }
    else if (!strcmp(pszName, "DT_BaseViewModel"))
    {
        for (int i = 0; i < pClass->m_pRecvTable->m_nProps; i++)
        {
            RecvProp *pProp = &(pClass->m_pRecvTable->m_pProps[i]);
            const char *name = pProp->m_pVarName;

            // Knives
            if (!strcmp(name, "m_nModelIndex"))
            {
                oRecvnModelIndex = (RecvVarProxyFn)pProp->m_ProxyFn;
                pProp->m_ProxyFn = Hooked_RecvProxy_Viewmodel;
            }
        }
        for (ClientClass* pClass = Interfaces::Client->GetAllClasses(); pClass; pClass = pClass->m_pNext) {
            if (!strcmp(pClass->m_pNetworkName, "CBaseViewModel")) {
                // Search for the 'm_nModelIndex' property.
                RecvTable* pClassTable = pClass->m_pRecvTable;

                for (int nIndex = 0; nIndex < pClassTable->m_nProps; nIndex++) {
                    RecvProp* pProp = &pClassTable->m_pProps[nIndex];

                    if (!pProp || strcmp(pProp->m_pVarName, "m_nSequence"))
                        continue;

                    // Store the original proxy function.
                    fnSequenceProxyFn = (RecvVarProxyFn)pProp->m_ProxyFn;

                    // Replace the proxy function with our sequence changer.
                    pProp->m_ProxyFn = SetViewModelSequence;

                    break;
                }

                break;
            }
        }
    }
    pClass = pClass->m_pNext;
}

}w

eeioruewo0iruwe commented 7 years ago

Add at the end of Entities.h

class CBaseViewModel : public IClientUnknown, public IClientRenderable, public IClientNetworkable { public: inline int GetModelIndex() { // DT_BaseViewModel -> m_nModelIndex return (int)((DWORD)this + 0x254); } inline DWORD GetOwner() { // DT_BaseViewModel -> m_hOwner return (PDWORD)((DWORD)this + 0x29BC); } inline DWORD GetWeapon() { // DT_BaseViewModel -> m_hWeapon return (PDWORD)((DWORD)this + 0x29B8); } inline void SetWeaponModel(const char Filename, IClientUnknown Weapon) { return call_vfunc<void(__thiscall)(void, const char, IClientUnknown)>(this, 242)(this, Filename, Weapon); } };

eeioruewo0iruwe commented 7 years ago

Replace CModelInfo in Materials.h with this:

template __forceinline Fn GetVirtualFunction(void pClassBase, int nFunctionIndex) { return (Fn)((PDWORD)(PDWORD*)pClassBase)[nFunctionIndex]; }

class CModelInfo { public: inline void GetModel(int Index) { return GetVirtualFunction<void(__thiscall )(void, int)>(this, 1)(this, Index); }

int GetModelIndex(const char *name)
{
    typedef int(__thiscall* oGetModelName)(PVOID, const char *);
    return call_vfunc< oGetModelName >(this, 2)(this, name);
}
inline const char* GetModelName(const void* Model) {
    return GetVirtualFunction<const char*(__thiscall *)(void*, const void*)>(this, 3)(this, Model);
}

studiohdr_t *GetStudiomodel(const model_t *mod)
{
    typedef studiohdr_t *(__stdcall* oGetStudiomodel)(const model_t*);
    return call_vfunc< oGetStudiomodel >(this, Offsets::VMT::ModelInfo_GetStudiomodel)(mod);
}
void GetModelMaterials(const model_t *model, int count, IMaterial** ppMaterial)
{
    typedef studiohdr_t* (*oGetModelMaterials)(void*, const model_t*, int, IMaterial**);
    call_vfunc<oGetModelMaterials>(this, 18)(this, model, count, ppMaterial);
}

};

eeioruewo0iruwe commented 7 years ago

have any errors?

just comment back on this. I'll be checking on this frequently. so expect a response 5-30 min after ur comment.

minhao-retard commented 7 years ago

http://prntscr.com/fnxot7 http://prntscr.com/fnxowe http://prntscr.com/fnxp06 http://prntscr.com/fnxp2o http://prntscr.com/fnxp5p http://prntscr.com/fnxp84 Yeah these are my errors. My Base is MotionSense

eeioruewo0iruwe commented 7 years ago

Mind showing full code? ie: where the errors are in the code

edit:: I'm going to try to paste the anim fix, if im successful ill link you or whatever

forgot to add this lol:

template __forceinline Fn GetVirtualFunction(void pClassBase, int nFunctionIndex) { return (Fn)((PDWORD)(PDWORD*)pClassBase)[nFunctionIndex]; }

put that above the GetModel shit

also here is proof

https://gyazo.com/ea0432e01a0c328b5a9ef81e36ee06a9

if you need further help, just let me know and ill upload fixed source :P

XBoom31 commented 7 years ago

like this? https://gyazo.com/64ec982f15aacd10f9ff8f8e73bfcc91

eeioruewo0iruwe commented 7 years ago

no, above, idk if i wasn't specific enough... sorry if I wasn't

https://gyazo.com/5a016bc126b2e418d3422acfae8c8042

XBoom31 commented 7 years ago

when i paste this template __forceinline Fn GetVirtualFunction(void* pClassBase, int nFunctionIndex) { return (Fn)((PDWORD)(PDWORD)pClassBase)[nFunctionIndex]; } where you said, i got this identifier Fn is undefinited

eeioruewo0iruwe commented 7 years ago

template __forceinline Fn GetVirtualFunction(void pClassBase, int nFunctionIndex) { return (Fn)((PDWORD)(PDWORD*)pClassBase)[nFunctionIndex]; }

? shouldnt have to be defined/autodefined. mind sharing a gyazo?

eeioruewo0iruwe commented 7 years ago

nvm github is the one being stupid

github is changing the code and i didn't realize :( sorry about that...

eeioruewo0iruwe commented 7 years ago

https://pastebin.com/SvAxUYUQ

XBoom31 commented 7 years ago

https://gyazo.com/36b336c231a205ba91fe1dfbcc4b374f

eeioruewo0iruwe commented 7 years ago

Im just gunna upload the source... i dont even know where to start on fixing that sorry :\

https://www.mediafire.com/?0gt88e6idply4u9

eeioruewo0iruwe commented 7 years ago

tbh i feel like git kinda messed up some of the code i posted above so I'm just gunna leave you with the source... HOPEFULLY that will clear some things up.

otvv commented 7 years ago

A pull request would be more easier than uploading the entire source code. But thanks anyways!

XBoom31 commented 7 years ago

yeah, iFloody is right

eeioruewo0iruwe commented 7 years ago

wouldn't let me do a pull request https://gyazo.com/7d17dc8f4cdc59da803e4b004a63ad53

XBoom31 commented 7 years ago

i'll let you pull a request wtf?

eeioruewo0iruwe commented 7 years ago

well i made it harder than it had to be so I apologize...

so here is a kitten playing with a feather toy: https://media.giphy.com/media/RQgzLsPYlzrBC/giphy.gif

minhao-retard commented 7 years ago

Still not getting it to work. Cannot convert PDWord to DWORD

XBoom31 commented 7 years ago

same

XBoom31 commented 7 years ago

just pull a request and ill accept it

otvv commented 7 years ago

I pasted all the shit from the source-code that @eeioruewo0iruwe provided and it's working fine here. I think that I can do a pull request if you want.

XBoom31 commented 7 years ago

yeah, would be nice, i have some probs with it, lemme update it then pull the request okay?

otvv commented 7 years ago

K.

Lemme just do some testings and I'll make the request.

XBoom31 commented 7 years ago

ok, pull that request now

eeioruewo0iruwe commented 7 years ago

ill be here if anyone needs me...

otvv commented 7 years ago

@XBoom31 Wait a sec, I need to fork your repo.

XBoom31 commented 7 years ago

the community needed you for that, and will need you for future updates if you want

eeioruewo0iruwe commented 7 years ago

:D yes

otvv commented 7 years ago

Done, pull request created.

XBoom31 commented 7 years ago

done, thanks @eeioruewo0iruwe and @iFloody

eeioruewo0iruwe commented 7 years ago

credit??

eeioruewo0iruwe commented 7 years ago

:P

XBoom31 commented 7 years ago

yeah, you have credits