⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.cpp

📁 我对他如何控制准星、显示敌友很好奇
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		return; 
	}

	if( !cvar.ftime ) { cvar.ftime = 0.1f; }
	if( cvar.burstflags&BurstInfo::BURSTFLAG_GROUND )
	{
		if(!(me.pmFlags&FL_ONGROUND)) // in mid air?
		{
			bAttacking = false;
			nFireSequence = FIRESEQ_INACTIVE; // delay shooting until landed
		}
	}

	if (gAimbot.target!=-1)
	{
		switch (nFireSequence)
		{
		case FIRESEQ_INACTIVE: 
			if( cvar.sdelay )
			{ 
				nFireSequence =  FIRESEQ_STARTDELAY; 
				timer = ClientTime::current; 
				gStopMovement();
				
			} else { 
				nFireSequence =  FIRESEQ_ACTIVE;     
				timer = ClientTime::current;
				bFireCycle  = true;
				bAttacking = true;
			}
			break;
		case FIRESEQ_STARTDELAY:
			if( ClientTime::current >= (timer+cvar.sdelay) )  
			{
				// start delay time's up, start firing
				nFireSequence =  FIRESEQ_ACTIVE;     
				timer = ClientTime::current;
				bFireCycle  = true;
				bAttacking = true;

			}
			break;
		case FIRESEQ_ACTIVE:  
			if( bFireCycle ) 
			{
				if( (ClientTime::current >= (timer+cvar.ftime)) && (cvar.dtime!=0)) 
				{
					bAttacking = false;
					timer = ClientTime::current;
					bFireCycle = false;
				}
				
			} else {    
				if( ClientTime::current >= (timer+cvar.dtime) )
				{
					bAttacking = true;
					timer = ClientTime::current;
					bFireCycle = true;
				}
			}
			break;
		case FIRESEQ_RELEASEDELAY:
			nFireSequence =  FIRESEQ_ACTIVE;     
			timer = ClientTime::current;
			bFireCycle  = true;
			bAttacking = true;
			break;
		}
		
	} else { 
		switch (nFireSequence)
		{
		case FIRESEQ_INACTIVE: 
			break;
		case FIRESEQ_STARTDELAY: 
			nFireSequence =  FIRESEQ_INACTIVE;     
			gFreeMovement();
			break;
		case FIRESEQ_ACTIVE:  
			gFreeMovement();
			if( !bFireCycle || (cvar.rdelay==0) )
			{                   
				bAttacking = false;
				nFireSequence =  FIRESEQ_INACTIVE;     
				
			} else {        
				timer = ClientTime::current;
				nFireSequence = FIRESEQ_RELEASEDELAY;
			}
			break;
		case FIRESEQ_RELEASEDELAY: 
			gFreeMovement();
			if( ClientTime::current >= (timer+cvar.rdelay) ) 
			{
				bAttacking = false;
				nFireSequence =  FIRESEQ_INACTIVE;     
			}
			break;
		}
	}
}

//========================================================================================
void UpdateScreenInfo(void)
{
	screeninfo.iSize=sizeof(SCREENINFO);
	gEngfuncs.pfnGetScreenInfo(&screeninfo);
	displayCenterX = screeninfo.iWidth/2;
	displayCenterY = screeninfo.iHeight/2;
}

void security_hook();void security_unhook();
//========================================================================================
void dynamic_hook()
{
	if(bDontAutoHook) return;

	bIsHooked = true;
	
	if(hw_client_dllfuncs)   { memcpy(hw_client_dllfuncs,&gHookedClientExports,sizeof(gHookedClientExports)); }
	if(client_enginefuncs)   { memcpy(client_enginefuncs,&gHookedEngfuncs     ,sizeof(gHookedEngfuncs)); }
	if(hw_client_studio_ptr) { hw_client_studio_ptr->StudioDrawPlayer = NewStudioDrawPlayer; }
		if(commandPatch.patchloc){ commandPatch.apply(); }	if(soundPatch.patchloc)  { soundPatch.apply();   }	//if(loaderPatch.patchloc) { loaderPatch.apply();  }
	if(chasePatch.patchloc)  { chasePatch.apply(); }
	//client_enginefuncs->pEfxAPI->R_BloodSprite = R_BloodSpriteHook;
	//R_BloodSprite_Org = gHookEnginefuncs.pEfxAPI->R_BloodSprite;
	if(hProcess)FlushInstructionCache(hProcess,0,0);

}

//========================================================================================
void dynamic_unhook()
{
	if(bDontAutoHook) return;

	bIsHooked = false;

	if(hw_client_dllfuncs)   { memcpy(hw_client_dllfuncs,&gClientExports,sizeof(gClientExports)); }
	if(client_enginefuncs)   { memcpy(client_enginefuncs,&gEngfuncs,sizeof(gEngfuncs)); }
	if(hw_client_studio_ptr) { hw_client_studio_ptr->StudioDrawPlayer = OrigStudioDrawPlayer; }
	if(commandPatch.patchloc){ commandPatch.restore(); }	if(soundPatch.patchloc)  { soundPatch  .restore(); }	//if(loaderPatch.patchloc) { loaderPatch .restore(); }
	if(chasePatch.patchloc)  { chasePatch.restore(); }
	
	//client_enginefuncs->pEfxAPI->R_BloodSprite = gEngfuncs.pEfxAPI->R_BloodSprite;
	if(hProcess)FlushInstructionCache(hProcess,0,0);
}

//========================================================================================
void func_hook()
{
	sndPlaySound(getOgcDirFile("activated.wav").c_str(),SND_ASYNC);
	Con_Echo("&bHOOKED");

	bDontAutoHook = false;
	dynamic_hook();
	//bDontAutoHook = true;
}

//========================================================================================
void func_unhook()
{
	sndPlaySound(getOgcDirFile("deactivated.wav").c_str(),SND_ASYNC);
	Con_Echo("&bUNHOOKED");
	
	bDontAutoHook = false;
	dynamic_unhook();
	bDontAutoHook = true;
}

//========================================================================================
int pHUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
	assert(gClientExports.HUD_GetStudioModelInterface);
	int nResult = gClientExports.HUD_GetStudioModelInterface(version,ppinterface,pstudio);

	memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
	pIEngineStudio = &IEngineStudio;
	
	if(ppinterface && *ppinterface)
	{
		hw_client_studio_ptr = (*ppinterface);
		OrigStudioDrawPlayer = (*ppinterface)->StudioDrawPlayer;
	}
	
	// dynamic_unhook();

	return nResult;
}


//========================================================================================
extern hookinfo HUD_Redraw_Info;
int pHUD_Redraw (float x, int y)
{
	LOG(hudredraw_start)
	int nResult=0;
	//nResult = HUD_Redraw_Info.call_org(&y);
	nResult = gClientExports.HUD_Redraw(x,y);

	me.ent = gEngfuncs.GetLocalPlayer();
	if (cvar.cross)       { drawCrosshair       (); }
	if (cvar.czoom)	      { handleContinuousZoom(); }
	hudDrawInfoTexts();
	if (cvar.radar)	      { drawRadarFrame      (); }
	if (menu_active)      { drawMenu            (); }
	if (cvar.soundfilter) { drawSound           (); }
	

	// === check for scheduled commands:
	for( ScheduleList::iterator pos = scheduleList.begin();
		 pos != scheduleList.end();
		 ++pos)
	{
		if( (*pos).timer.expired() )
		{
			cmd.exec( const_cast<char*>((*pos).cmd.c_str()) );
			scheduleList.erase(pos);
			break;
		}	
	}

	// get screen info
	static bool done=false;
	if(!done)
	{ 
		UpdateScreenInfo(); 
		done=true; 
	}

	// === dead/alive signals
	static bool previous_alive_state=false;
	if     (  previous_alive_state && !me.alive )  { sendScriptSignal("dead" );  }
	else if( !previous_alive_state &&  me.alive )  { sendScriptSignal("alive" ); }
	previous_alive_state = me.alive;

	// === blink 
	if(blinkTimer.expired())
	{
		blinkPhase = !blinkPhase;
		if(blinkPhase){ blinkTimer.countdown(0.2); }
		else          { blinkTimer.countdown(0.1); }
	}

	// === flash removal
	if (cvar.flash)
	{
		static screenfade_t sf = { 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0 }; 
		gEngfuncs.pfnSetScreenFade( &sf ); 
	}

	// item esp + reset
	if(cvar.esp||cvar.radar) for (int ab=0;ab<vEntity.size();ab++) drawEsp(ab);
	vEntity.clear();

	// player esp
	for (int ax=0;ax<vPlayers.size();ax++) if (vPlayers[ax].getPVS() ) drawPlayerEsp(ax);
	if(cvar.avdraw) gAimbot.draw();

	// snake game
	snake.frame();
	if(cvar.wa_active) winamp.frame();

	// console
	gConsole.draw(cvar.con_x,cvar.con_y,cvar.con_w,cvar.con_h);

	// == handle autoshoot
	gAttackHandling();

	LOG(hudredraw_end)
	return nResult;
} 

//========================================================================================
void ActivatePlayer(struct cl_entity_s *ent)
{
	int px = ent->index;

	if(cvar.alive_method==1)
	{
		if(ent->curstate.solid) { vPlayers[px].setAlive(); }
		
		if(ent==me.ent) { me.alive = vPlayers[px].getAlive(); }
	}
	else if(cvar.alive_method==2)
	{
		if(ent->curstate.solid) { vPlayers[px].setAlive(); }
		else                    { vPlayers[px].setAlive(false);}
		
		if(ent==me.ent) { me.alive = vPlayers[px].getAlive(); }
	}


	vPlayers[px].setPVS();
	gEngfuncs.pfnGetPlayerInfo(ent->index, &vPlayers[px].entinfo);

	if(ent == me.ent) 
	{ 
		vPlayers[px].distance = 100000.0;
		vPlayers[px].visible  = false;
		vPlayers[px].fovangle = 360;
		vPlayers[px].points   = -999999;
		vPlayers[px].clearPVS(); 
		return;
	}
	
	// filter trash entities, calc distance/visibility, points ...
	playerCalcExtraData(px,ent);
}

//========================================================================================
void AddEntity(struct cl_entity_s *ent)
{
	hostage_info dummy;
	dummy.ent = ent;
	if(vEntity.size()<64) vEntity.push_back(dummy);
}


//========================================================================================
inline void drawLine(float*from, float*to, ColorEntry*color)
{
	gEngfuncs.pEfxAPI->R_BeamPoints(from,to,beamindex,0.001f,0.9f,0.5,32,2,0,10,color->fr,color->fg,color->fb);
}

//========================================================================================
extern hookinfo HUD_TempEntUpdate_Info;
void pHUD_TempEntUpdate (
		double frametime,   			// Simulation time
		double client_time, 			// Absolute time on client
		double cl_gravity,  			// True gravity on client
		TEMPENTITY **ppTempEntFree,   	// List of freed temporary ents
		TEMPENTITY **ppTempEntActive, 	// List 
		int		( *Callback_AddVisibleEntity )( cl_entity_t *pEntity ),
		void	( *Callback_TempEntPlaySound )( TEMPENTITY *pTemp, float damp ) )
{
LOG(Tempent_start)
	
	//HUD_TempEntUpdate_Info.call_org(&Callback_TempEntPlaySound);

	typedef void (*HUD_TempEntUpdateFunc)(double,double,double,TEMPENTITY**,TEMPENTITY**, int(*)(cl_entity_t*),void(*)(TEMPENTITY*,float));	

	(*(HUD_TempEntUpdateFunc)(gClientExports.HUD_TempEntUpdate))(
		frametime,
		client_time,
		cl_gravity,
		ppTempEntFree,
		ppTempEntActive,
		Callback_AddVisibleEntity,
		Callback_TempEntPlaySound 
		);
		

	me.ent = gEngfuncs.GetLocalPlayer();
	if(cvar.light)
	{
		dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight (0);
		VectorCopy (me.pmEyePos, dl->origin);
		dl->radius = cvar.light;
		dl->color.r = 255;
		dl->color.g = 255;
		dl->color.b = 255;
		dl->die = client_time + 0.01;
	}

	if(cvar.tlight && gAimbot.target!=-1 )
	{
		ColorEntry* color = colorList.get(29);
		dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight (0);
		VectorCopy ( vPlayers[gAimbot.target].getEnt()->origin, dl->origin );
		dl->radius = cvar.tlight;
		dl->color.r = color->r;
		dl->color.g = color->g;
		dl->color.b = color->b;
		dl->die = client_time + 0.01;
	}

	// == provide time handler with timing info
	ClientTime::reportMapTime( client_time );

	// find beamindex if needed 
	if(!beamindex) { beamindex = gEngfuncs.pEventAPI->EV_FindModelIndex("sprites/laserbeam.spr"); }
    		
	if( cvar.death && deathInfos.active )
	{
		ColorEntry* color = colorList.get(16);
		gEngfuncs.pEfxAPI->R_BeamPoints(deathInfos.from,deathInfos.to,beamindex,0.001f,0.9f,0,32,2,0,0,color->fr,color->fg,color->fb);
	}
LOG(Tempent_end)
}

//========================================================================================
void PreV_CalcRefdef (struct ref_params_s *pparams)
{
	// recoil
	VectorCopy(pparams->punchangle,me.punchangle);
	if (cvar.recoil) for (int i=0; i<3; i++) pparams->punchangle[i] = 0; 	

	if( pparams->nextView == 0 )
	{
		//if(!me.alive)
		//{
		//	// avoid problems with free chase cam view
		//	// where me.pmOrigin is the viewed player
		//	VectorCopy(pparams->vieworg,me.pmEyePos);
		//}

		// find a target
		gAimbot.findTarget();
		if( gAimbot.target != -1 && cvar.autoburst && mod==MOD_CSTRIKE)
		{
			// == update burst settings
			int dist = vPlayers[gAimbot.target].distance/22;
			BurstInfo::RangeInfo* range = burstInfo.get(currentWeaponID,dist );

			// update burst variables
			cvar.ftime  = range->ftime;
			cvar.dtime  = range->dtime;
			cvar.sdelay = range->sdelay;
			cvar.burstflags = range->flags;
		} 


		if ( cvar.aim ) 
		if ( (me.iClip && me.pmMoveType!=5) || !me.alive ) // out of ammo / on ladder / dead
		if ( gAimbot.target!=-1 )
		if (! (cvar.burstflags&BurstInfo::BURSTFLAG_NOAIM) )
		if ( pparams->nextView == 0 )
		{
			Aimbot_active = true;
			gAimbot.CalcViewAngles();
			VectorCopy(gAimbot.aim_viewangles, pparams->cl_viewangles);
			VectorCopy(gAimbot.aim_viewangles, pparams->viewangles);
		} 

		// decrement PVS+reset
		for (int ax=0;ax<vPlayers.size();ax++) 
		{
			vPlayers[ax].decrPVS();
			vPlayers[ax].numTargetSpots = 0; // gets filled again in gAimbot 
		}

	}

	//// viewport switching
	//if (!cvar.mirror)
	//{
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -