PHP Code
Code:
#include "stdafx.h"
#include "NoShake.h"
dice::network::StreamManagerMoveClient_VTable* g_pNewMoveManager = NULL;
typedef dice::network::TransmitResult ( __fastcall* transmitPacket_t )( dice::network::StreamManagerMoveClient*, void*, dice::IBitStreamWrite*, dice::network::ITransmissionRecord **, unsigned int *);
transmitPacket_t ptransmitPacket = NULL;
dice::network::TransmitResult __fastcall new_transmitPacket( dice::network::StreamManagerMoveClient* pthis, void* _EDX, dice::IBitStreamWrite *stream, dice::network::ITransmissionRecord **tr, unsigned int *voiceDataSize )
{
dice::HaloAimer* halo = util::haloAimer();
if( halo && pthis->m_moves.empty() == false )
{
DequeIterator< dice::network::IMoveObject*, 64 > b;
pthis->m_moves.begin( &b );
for( size_t m = 0; m < pthis->m_moves.size(); m++ )
{
dice::network::IMoveObject** i = b.mpCurrent;
if( i == NULL )
continue;
if( ( *i ) == NULL )
continue;
dice::EntryInputStateNetworkMove* entryMove = ( dice::EntryInputStateNetworkMove* )( *i );
// Is it possible to update spread and recoil here, then nullify it after?
// This might allow us to calculate spread and recoil accurately without it ever effecting visibility
dice::Vec3 correctionAngle( halo->m_yaw, halo->m_pitch, 0.0f );
if( entryMove->getLevel( dice::EiaFire ) != 0.0f || weapon::isWeaponFiring() )
{
if( gVarManager.removal_spread.m_value == 1.0f )
{
weapon::correctSpread( &correctionAngle );
}
if( gVarManager.removal_recoil.m_value == 1.0f )
{
weapon::correctRecoil( &correctionAngle );
}
}
if( gVarManager.removal_snipersway.m_value == 1.0f )
{
weapon::correctBreathing();
}
entryMove->m_authorativeAimingPitch = correctionAngle.y;
entryMove->m_authorativeAimingYaw = correctionAngle.x;
++b;
}
}
dice::network::TransmitResult trr = ptransmitPacket( pthis, _EDX, stream, tr, voiceDataSize );
// Zero out all spread/recoil/etc here on the client so it can look pretty
weapon::destroyVisualPeturb();
return trr;
}
DWORD WINAPI lpHookMove( LPVOID lpParam )
{
while( true )
{
dice::GameContext* gameContext = NULL;
while( gameContext == NULL )
{
gameContext = dice::GameContext::Singleton();
Sleep( 100 );
}
dice::online::ClientConnection* clientConnection = NULL;
while( clientConnection == NULL )
{
if( util::IsOriginVersion() )
{
dice::ClientGameContext_EADM* clientGameContext = ( dice::ClientGameContext_EADM* ) gameContext;
clientConnection = clientGameContext->m_clientConnection;
}
else
{
dice::ClientGameContext* clientGameContext = ( dice::ClientGameContext* ) gameContext;
clientConnection = clientGameContext->m_clientConnection;
}
Sleep( 100 );
}
dice::network::StreamManagerMoveClient* moveClient = NULL;
while( moveClient == NULL )
{
moveClient = clientConnection->MoveClient();
Sleep( 100 );
}
PDWORD* pdwMoveClient = ( PDWORD* ) moveClient;
while( *pdwMoveClient == NULL )
{
Sleep( 100 );
}
if( g_pNewMoveManager == NULL )
{
g_pNewMoveManager = ( dice::network::StreamManagerMoveClient_VTable* ) malloc( 1024 );
memcpy( g_pNewMoveManager, ( void* ) *pdwMoveClient, 1024 );
}
if( ptransmitPacket == NULL )
{
ptransmitPacket = ( transmitPacket_t ) g_pNewMoveManager->transmitPacket;
}
if( ( ( transmitPacket_t ) g_pNewMoveManager->transmitPacket ) != new_transmitPacket )
{
g_pNewMoveManager->transmitPacket = new_transmitPacket;
}
*pdwMoveClient = ( PDWORD ) g_pNewMoveManager;
Sleep( 100 );
}
return 0;
}
void InitializeShakeHooks()
{
//gApp.AddToLogFileA( "hook.log", "InitializeShakeHooks" );
CreateThread( 0, 0, lpHookMove, 0, 0, 0 );
}
PHP Code
Code:
#include "stdafx.h"
#include "WeaponMod.h"
namespace weapon
{
dice::GunSway::Deviation FireSpread;
dice::GunSway::Deviation FireRecoil;
void correctSpread( dice::Vec3* data )
{
dice::ClientSoldierWeapon* wep = util::localWeapon();
if( wep == NULL )
return;
dice::SoldierWeaponData* wepdata = wep->m_data;
if( wepdata == NULL )
return;
if( wepdata->m_weaponClass == dice::wcTracerDart ||
wepdata->m_weaponClass == dice::wcMortarStrike ||
wepdata->m_weaponClass == dice::wcPowerTool ||
wepdata->m_weaponClass == dice::wcATMine ||
wepdata->m_weaponClass == dice::wcAmmoBox ||
wepdata->m_weaponClass == dice::wcMedKit ||
strstr( wepdata->m_name.c_str(), XStr( /*M136*/ 0x01, 0x04, 0xA6, 0xEB969B9F ).c() ) )
return;
data->x += FireSpread.m_yaw;
data->y += FireSpread.m_pitch;
}
void correctRecoil( dice::Vec3* data )
{
dice::ClientSoldierWeapon* wep = util::localWeapon();
if( wep == NULL )
return;
dice::SoldierWeaponData* wepdata = wep->m_data;
if( wepdata == NULL )
return;
if( wepdata->m_weaponClass == dice::wcTracerDart ||
wepdata->m_weaponClass == dice::wcMortarStrike ||
wepdata->m_weaponClass == dice::wcPowerTool ||
wepdata->m_weaponClass == dice::wcATMine ||
wepdata->m_weaponClass == dice::wcAmmoBox ||
wepdata->m_weaponClass == dice::wcMedKit ||
strstr( wepdata->m_name.c_str(), XStr( /*M136*/ 0x01, 0x04, 0xD8, 0x95E8E9ED ).c() ) )
return;
data->x += FireRecoil.m_yaw;
data->y += FireRecoil.m_pitch;
}
void correctBreathing()
{
dice::ClientSoldierWeapon* wep = util::localWeapon();
if( wep == NULL ) return;
if( wep->m_data->m_weaponClass != dice::wcSniper ) return;
dice::ClientSoldierAimingSimulation* simulation = wep->m_authorativeAiming;
if( simulation == NULL ) return;
dice::SoldierAimingSimulationData* aimingSimulationData = simulation->m_data;
if( aimingSimulationData == NULL ) return;
dice::ZoomLevelData* zoomData = aimingSimulationData->m_zoomLevels.m_dataBlock[ simulation->m_zoomLevel ];
if( zoomData == NULL ) return;
zoomData->m_swayPitchMultiplier = 0.0f;
zoomData->m_swayYawMultiplier = 0.0f;
zoomData->m_recoilMultiplier = 0.0f;
}
void correctLag()
{
/*
dice::ClientSoldierWeapon* wep = util::localWeapon();
if( wep == NULL ) return;
if( wep->m_data->m_weaponClass == dice::wcTracerDart ||
wep->m_data->m_weaponClass == dice::wcMortarStrike ||
wep->m_data->m_weaponClass == dice::wcPowerTool ||
wep->m_data->m_weaponClass == dice::wcATMine ||
wep->m_data->m_weaponClass == dice::wcAmmoBox ||
wep->m_data->m_weaponClass == dice::wcMedKit ||
strstr( wep->m_data->m_name.c_str(), "M136" ) ) return;
dice::WeaponLagEffect* lagEffect = wep->m_cameraLagEffect;
if( lagEffect == NULL ) return;
dice::FirstPersonCameraData* fpsCameraData = lagEffect->m_data;
if( fpsCameraData == NULL ) return;
fpsCameraData->m_releaseModifierYaw = 0.0f;
fpsCameraData->m_releaseModifierRoll = 0.0f;
fpsCameraData->m_releaseModifierPitch = 0.0f;
fpsCameraData->m_releaseModifier = 0.0f;
*/
}
void destroyVisualPeturb()
{
dice::ClientSoldierWeapon* wep = util::localWeapon();
if( wep == NULL )
return;
dice::SoldierWeaponData* wepdata = wep->m_data;
if( wepdata == NULL )
return;
if( wepdata->m_weaponClass == dice::wcTracerDart ||
wepdata->m_weaponClass == dice::wcMortarStrike ||
wepdata->m_weaponClass == dice::wcPowerTool ||
wepdata->m_weaponClass == dice::wcATMine ||
wepdata->m_weaponClass == dice::wcAmmoBox ||
wepdata->m_weaponClass == dice::wcMedKit ||
strstr( wepdata->m_name.c_str(), XStr( /*M136*/ 0x01, 0x04, 0x65, 0x2857545E ).c() ) )
return;
dice::WeaponFiring* predictedFiring = wep->m_predictedFiring;
if( predictedFiring == NULL ) return;
dice::WeaponSway* weaponSway = predictedFiring->m_weaponSway;
if( weaponSway == NULL ) return;
if( gVarManager.removal_recoil.m_value == 1.0f )
{
if( weaponSway->m_cameraRecoilDeviation )
{
if( weaponSway->m_cameraRecoilDeviation->m_cameraRecoilData )
{
weaponSway->m_cameraRecoilDeviation->m_cameraRecoilData->m_springConstant = 0.0f;
weaponSway->m_cameraRecoilDeviation->m_cameraRecoilData->m_springDamping = 0.0f;
weaponSway->m_cameraRecoilDeviation->m_cameraRecoilData->m_springMinThresholdAngle = 0.0f;
}
weaponSway->m_cameraRecoilDeviation->m_pitchSpring.m_pos = 0.0f;
weaponSway->m_cameraRecoilDeviation->m_pitchSpring.m_restPos = 0.0f;
weaponSway->m_cameraRecoilDeviation->m_pitchSpring.m_velocity = 0.0f;
weaponSway->m_cameraRecoilDeviation->m_yawSpring.m_pos = 0.0f;
weaponSway->m_cameraRecoilDeviation->m_yawSpring.m_restPos = 0.0f;
weaponSway->m_cameraRecoilDeviation->m_yawSpring.m_velocity = 0.0f;
}
}
}
bool isWeaponFiring()
{
dice::ClientSoldierWeapon* wep = util::localWeapon();
if( wep == NULL ) return false;
dice::WeaponFiring* wepfire = wep->m_predictedFiring;
if( wepfire == NULL ) return false;
bool bResult = false;
switch( wepfire->m_weaponState )
{
case dice::WeaponFiring::PreFireDelay:
case dice::WeaponFiring::PreFireZoomDelay:
case dice::WeaponFiring::PrimarySingleDelay:
case dice::WeaponFiring::PrimarySingle:
case dice::WeaponFiring::PrimaryAutomaticFire:
case dice::WeaponFiring::PrimaryHoldAndRelease_Hold:
case dice::WeaponFiring::PrimaryHoldAndRelease_ReleaseDelay:
case dice::WeaponFiring::PrimaryHoldAndRelease_Release:
{
bResult = true;
break;
}
default:
{
bResult = false;
break;
}
}
return bResult;
}
};
If you've ever hacked a game from the source engine, transmitPacket works a little like CreateMove when correcting spread/recoil.
This will correct for recoil and spread prior to it being sent to the server, so all you have left to do is destroy the *visual* effects.
PHP Code
Code:
#include "stdafx.h"
#include "WeaponCallback.h"
class EA_WeaponFiringCallback : public dice::WeaponFiringCallbacks
{
public:
void primaryStartedFiringCallback()
{
weapon::destroyVisualPeturb();
}
void primaryFireCallback()
{
weapon::destroyVisualPeturb();
}
void primaryFireReleaseCallback()
{
}
void primaryFireShotSpawnedCallback( float powerModifier, bool trace, dice::WeaponFiringUpdateContext *context )
{
dice::ClientGameContext* gameContext = dice::ClientGameContext::Singleton();
if( gameContext == NULL )
return;
dice::GameTime* gameTime = gameContext->m_gameTime;
if( gameTime == NULL )
return;
dice::ClientSoldierWeapon* wep = util::localWeapon();
if( wep == NULL ) return;
if( wep->m_data == NULL ) return;
if( wep->m_data->m_weaponClass == dice::wcTracerDart ||
wep->m_data->m_weaponClass == dice::wcMortarStrike ||
wep->m_data->m_weaponClass == dice::wcPowerTool ||
wep->m_data->m_weaponClass == dice::wcATMine ||
wep->m_data->m_weaponClass == dice::wcAmmoBox ||
wep->m_data->m_weaponClass == dice::wcMedKit ||
strstr( wep->m_data->m_name.c_str(), XStr( /*M136*/ 0x01, 0x04, 0xF8, 0xB5C8C9CD ).c() ) ) return;
dice::WeaponFiring* predictedFiring = wep->m_predictedFiring;
if( predictedFiring == NULL ) return;
dice::WeaponSway* weaponSway = predictedFiring->m_weaponSway;
if( weaponSway == NULL ) return;
dice::WeaponFiringUpdateContext C;
// Maybe +1 maybe not, was not +1 before.
C.ticks = gameTime->m_ticks;
weaponSway->primaryFireShotSpawnedCallback( 1.0f, false, &C );
weapon::FireSpread.m_yaw = weaponSway->m_currentDispersionDeviation.m_yaw;
weapon::FireSpread.m_pitch = weaponSway->m_currentDispersionDeviation.m_pitch;
// We need to update the recoil as well, or else there's really no point.
weapon::FireRecoil.m_yaw = weaponSway->m_currentRecoilDeviation.m_yaw;
weapon::FireRecoil.m_pitch = weaponSway->m_currentRecoilDeviation.m_pitch;
weapon::destroyVisualPeturb();
}
void primaryFireAutomaticBeginCallback()
{
weapon::destroyVisualPeturb();
}
void primaryFireAutomaticEndCallback()
{
}
void primaryFireTriggeredReloadCallback()
{
}
void primaryFireTriggeredOutOfAmmoCallback()
{
}
void primaryStoppedFiringCallback()
{
}
void primaryOutOfAmmoCallback()
{
}
void orderCallback()
{
}
void meleeCallback( bool isFatal )
{
}
void boltActionCallback()
{
}
void boltActionEndCallback()
{
}
void reloadPrimaryCallback()
{
}
void reloadPrimaryEndCallback()
{
}
void detonationSwitchCallback( bool detonatorActive )
{
}
void detonatorTriggered( bool detonationDeployed )
{
}
void activate()
{
}
void deactivate()
{
}
void switchedTo()
{
}
void holdAndReleaseReleaseCallback()
{
}
void updateRequired( bool needed )
{
}
};
EA_WeaponFiringCallback *EACallback = new EA_WeaponFiringCallback;
void addWeaponCallback( void )
{
dice::ClientSoldierWeapon* localWeapon = util::localWeapon();
if( localWeapon == NULL )
return;
dice::WeaponFiring* firing = localWeapon->m_predictedFiring;
if( firing == NULL )
return;
for( size_t i = 0; i < firing->m_callbackHandlers.size(); i++ )
{
dice::WeaponFiringCallbacks* cb = firing->m_callbackHandlers.at( i );
if( cb == EACallback )
{
return;
}
}
firing->m_callbackHandlers.push_back( EACallback );
}
dice::GunSway_VTable *gOriginalSwayTable = NULL;
dice::GunSway_VTable *gNewSwayTable = NULL;
void __fastcall new_getDispersion( dice::GunSway* pthis, void* _EDX, dice::LinearTransform* dispersionTransform, bool scaleTransform )
{
float originalYaw = pthis->m_currentRecoilDeviation.m_yaw;
float originalPitch = pthis->m_currentRecoilDeviation.m_pitch;
if( gVarManager.removal_spread.m_value == 1.0f )
{
pthis->m_currentDispersionDeviation.m_yaw = 0.0f;
pthis->m_currentDispersionDeviation.m_pitch = 0.0f;
}
gOriginalSwayTable->getDispersion( pthis, _EDX, dispersionTransform, scaleTransform );
pthis->m_currentDispersionDeviation.m_yaw = originalYaw;
pthis->m_currentDispersionDeviation.m_pitch = originalPitch;
}
void __fastcall new_getRecoil( dice::GunSway* pthis, void* _EDX, dice::LinearTransform *recoilTransform, bool scaleTransform )
{
float originalYaw = pthis->m_currentRecoilDeviation.m_yaw;
float originalPitch = pthis->m_currentRecoilDeviation.m_pitch;
if( gVarManager.removal_recoil.m_value == 1.0f )
{
pthis->m_currentRecoilDeviation.m_yaw = 0.0f;
pthis->m_currentRecoilDeviation.m_pitch = 0.0f;
}
gOriginalSwayTable->getRecoil( pthis, _EDX, recoilTransform, scaleTransform );
pthis->m_currentRecoilDeviation.m_yaw = originalYaw;
pthis->m_currentRecoilDeviation.m_pitch = originalPitch;
}
void MaintainGunswayHook( void )
{
dice::ClientSoldierWeapon* soldierWeapon = util::localWeapon();
if( soldierWeapon == NULL )
return;
dice::WeaponFiring* predictedFiring = soldierWeapon->m_predictedFiring;
if( predictedFiring == NULL )
return;
dice::WeaponSway* weaponSway = predictedFiring->m_weaponSway;
if( weaponSway == NULL )
return;
PDWORD* pdwSwayTable = ( PDWORD* ) weaponSway;
if( *pdwSwayTable == NULL )
return;
dice::GunSway_VTable* currentSwayTable = ( dice::GunSway_VTable* ) *pdwSwayTable;
if( currentSwayTable->getRecoil != new_getRecoil )
{
if( gOriginalSwayTable )
{
free( gOriginalSwayTable );
}
if( gNewSwayTable )
{
free( gNewSwayTable );
}
gOriginalSwayTable = ( dice::GunSway_VTable* ) malloc( 1024 );
gNewSwayTable = ( dice::GunSway_VTable* ) malloc( 1024 );
memcpy( gOriginalSwayTable, currentSwayTable, 1024 );
memcpy( gNewSwayTable, currentSwayTable, 1024 );
gNewSwayTable->getRecoil = new_getRecoil;
gNewSwayTable->getDispersion = new_getDispersion;
*pdwSwayTable = ( PDWORD ) gNewSwayTable;
}
}
Credits:
s0beit (obviously, ******)
zoomgod
Sparten
Tom M
raiders