Will this work?

Posts 1–2 of 2 · Page 1 of 1
Will this work?
This is the source code for auto wall on cod 4.
Code:
Code:
/************************************************************************/
/*                                                                      */
/************************************************************************/

#ifndef _C_AUTOWALL_H_
#define _C_AUTOWALL_H_

class CAutoWall
{
private:

	void	DisableBulletImpacts( );
	void	DisableBulletTrails( );

	void	EnableBulletImpacts( );
	void	EnableBulletTrails( );

	void	SetupBulletTrace( bulletTrace_t* btr, vec3_t start, vec3_t end, int skipNum );


public:
 
	CAutoWall( );
	~CAutoWall( );

	bool	GetRemainingPower( vec3_t vieworg, centity_t* cent, vec3_t origin, float* remainingPower  );
};

extern CAutoWall AutoWall;

#endif




code:
CAutoWall::CAutoWall( )
{

}

// ----------------------------------------------------------------------

CAutoWall::~CAutoWall( )
{

}

void CAutoWall::SetupBulletTrace( bulletTrace_t* btr, vec3_t start, vec3_t end, int skipNum )
{
	btr->worldEntNum = 1022;
	btr->skipNum = skipNum;
	btr->power = 1.0f;
	btr->bulletType = 1;
	VectorCopy( cg->refdef.Vieworg, btr->vieworg );
	VectorCopy( start, btr->start );
	VectorCopy( end, btr->end );

	vec3_t delta;
	VectorSubtract( end, start, delta );

	vec3_t angles;
	Math.vectoangles( delta, angles );
	Math.AngleVectors( angles, btr->viewDirection, NULL, NULL );
}

void DrawBulletTrajectory( centity_t* cent, int a2, bulletTrace_t* bulletTrace, weapon_t* weapon, vec3_t vieworg, int serverTimeDelta )
{
	DWORD dwCallAddr = 0x00455A80;
	__asm
	{
		push	[ serverTimeDelta ];
		push	[ vieworg ];
		push	[ weapon ];
		push	[ bulletTrace ];
		push	[ a2 ];
		mov		edi, [ cent ];
		call	[ dwCallAddr ];
		add		esp, 0x14;
	}
}

void PatchBytes( void * lpAddress, const char * szBytes, int nLen )
{
	// Needed by VirtualProtect.
	DWORD dwBack = 0;
	VirtualProtect( lpAddress, nLen, PAGE_READWRITE, &dwBack );

	// Write Byte-After-Byte.
	for( int i = 0; i < nLen; i++ )
		*( BYTE * )( ( DWORD )lpAddress + i ) = szBytes[ i ];

	// Restore old protection.
	VirtualProtect( lpAddress, nLen, dwBack, &dwBack );
}


void CAutoWall::DisableBulletImpacts( )
{
	PatchBytes( ( void* )0x00455A20, "\xC3", 1 );
}

// ----------------------------------------------------------------------

void CAutoWall::DisableBulletTrails( )
{
	PatchBytes( ( void* )0x00458110, "\xC3", 1 );
}

// ----------------------------------------------------------------------

void CAutoWall::EnableBulletImpacts( )
{
	PatchBytes( ( void* )0x00455A20, "\x8B", 1 );
}

// ----------------------------------------------------------------------

void CAutoWall::EnableBulletTrails( )
{
	PatchBytes( ( void* )0x00458110, "\x83", 1 );
}

// ----------------------------------------------------------------------

weapon_t**		cg_weapons2			= ( weapon_t** )0x00736DB8;

bool CAutoWall::GetRemainingPower( vec3_t vieworg, centity_t* cent, vec3_t origin, float* remainingPower )
{
	bulletTrace_t bulletTrace;
	SetupBulletTrace( &bulletTrace, vieworg, origin, 0 );

	int serverTimeDelta = cg->nextSnap->serverTime - cg->snap->serverTime;

	if ( serverTimeDelta < 0 )
		serverTimeDelta = 0;

	DisableBulletImpacts( );
	DisableBulletTrails( );

	DrawBulletTrajectory( &cg->predictedPlayerEntity, 0, &bulletTrace, cg_weapons2[ cg->predictedPlayerState.weapon ], vieworg, serverTimeDelta );

	EnableBulletImpacts( );
	EnableBulletTrails( );
	if ( bulletTrace.skipNum == cent->clientNum )
	{
		*remainingPower = bulletTrace.power;

		return true;
	}
	else
	{
		*remainingPower = 0.0f;

		return false;
	}
}
Of course it won't work, COD4 and MW3 are different and those addresses are wrong... Also, next time, use a proper code box...

/closed
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us