Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool IsShotCritical ( C_BaseCombatWeapon* pBaseWeapon )
- {
- if (!pBaseWeapon)
- return false;
- DWORD result = false;
- DWORD FuncOffset = 0x568;
- DWORD weaponOffset = 0x1700;
- DWORD weaponSeed = 0;
- __asm
- {
- pushad;
- mov ecx, pBaseWeapon;
- mov eax, [ecx+0x1700];
- push eax;
- mov eax, [ecx];
- mov eax, [eax+0x568];
- call eax;
- mov result, eax;
- pop eax;
- mov ecx, pBaseWeapon;
- mov [ecx+0x1700], eax;
- popad;
- }
- return (bool)(result&1);
- }
- //=========== Copyright © 1990-2010, HL-SDK, All rights reserved. ===========//
- //
- // Purpose: Additional information can be found in header file.
- //
- //===========================================================================//
- #include "Critbot.h"
- #include <in_buttons.h>
- #include <Release/Memory.h>
- #include <Release/Entity.h>
- #include <Release/Weapon.h>
- #include <Release/Interfaces.h>
- #include <Release/TF2.h>
- #include <Release/SigManager.h>
- enum { CRIT_NONE, CRIT_ALL, CRIT_MELEE, CRIT_SPECIALIZED };
- CCritbot::CCritbot()
- {
- m_pGlobalSeed = (int*)g_pSigManager->Find("pGlobalSeed");
- m_iFramesWaited = 0;
- m_iCritMult = 0;
- }
- CCritbot::~CCritbot()
- {
- }
- void ms_crits_enable_callback( IConVar *var, const char *pOldValue, float flOldValue );
- static ConVar ms_crits_enable( "ms_crits_enable", "0", FCVAR_NONE, "Crithack enabled? 0 = no, 1 = all weapons, 2 = melee only", ms_crits_enable_callback );
- void ms_crits_enable_callback( IConVar *var, const char *pOldValue, float flOldValue )
- {
- switch (ms_crits_enable.GetInt())
- {
- case CRIT_NONE:
- Msg("[MS] Crits turned OFF\n");
- break;
- case CRIT_ALL:
- Msg("[MS] Crits turned ON for ALL WEAPONS\n");
- break;
- case CRIT_MELEE:
- Msg("[MS] Crits turned ON for MELEE WEAPONS\n");
- break;
- case CRIT_SPECIALIZED:
- Msg("[MS] Crits turned ON in SPECIALIZED FRAME WAITING MODE\n");
- break;
- }
- }
- bool CCritbot::Run(CUserCmd* pCmd)
- {
- C_BaseCombatWeapon* pWeapon = Zeus::Weapons::GetFromPlayer((C_BasePlayer*)Zeus::Entity::Me());
- if (!pWeapon)
- return false;
- m_iCritMult = *reinterpret_cast<GenDT_TFPlayer*>(Zeus::Entity::Me())->Shared()->iCritMult();
- //if (!(pCmd->buttons & IN_ATTACK)) //We're not attempting to fire
- //{
- // m_iFramesWaited = 0; //Reset frame counter
- // return false; //Nothing to do.
- //}
- int GlobalSeed_backup = *m_pGlobalSeed;
- *m_pGlobalSeed = pCmd->random_seed;
- bool bCrit = Zeus::Weapons::IsShotCritical(pWeapon);
- *m_pGlobalSeed = GlobalSeed_backup;
- switch (ms_crits_enable.GetInt())
- {
- case CRIT_NONE: //no crits
- break;
- case CRIT_ALL:
- if (!bCrit)
- pCmd->buttons &= ~0x00000001;
- break;
- case CRIT_MELEE: //melee only
- if (Zeus::Weapons::IsMelee(Zeus::Weapons::GetID(pWeapon)))
- {
- if (!bCrit)
- pCmd->buttons &= ~0x00000001;
- }
- break;
- case CRIT_SPECIALIZED: //Special frame-waiting method
- {
- if (!bCrit)
- {
- m_iFramesWaited++;
- if (m_iCritMult < 40)
- {
- if (m_iFramesWaited < 5) //If our critmult is low and we haven't waited 10 frames yet, hold back
- pCmd->buttons &= ~IN_ATTACK;
- }
- else
- {
- if (m_iFramesWaited < 30) //Critmult is pretty high, we can wait longer
- pCmd->buttons &= ~IN_ATTACK;
- }
- }
- else
- {
- m_iFramesWaited = 0; //We are critting, reset counter.
- }
- }
- break;
- default:
- break;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment