Thread: CG_Trace

Results 1 to 4 of 4
  1. #1
    shaunm2's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    4
    My Mood
    Amazed

    CG_Trace

    So i'm having a small problem with CG_Trace when i'm ingame it just aims through everything here is what i'm currently using:

    void (*CG_Trace)(cTrace_t *trace,vec3_t start,vec3_t mins,vec3_t maxs,vec3_t end,int skipNumber,int Mask) = (void(__cdecl *)(cTrace_t*, vec3_t,vec3_t,vec3_t,vec3_t,int, int))0x660980;

    which can be found here:
    Code:
    00460BE0   8B4424 20        MOV EAX,DWORD PTR SS:[ESP+20]
    00460BE4   8B4C24 1C        MOV ECX,DWORD PTR SS:[ESP+1C]
    00460BE8   8B5424 08        MOV EDX,DWORD PTR SS:[ESP+8]
    00460BEC   81EC 84000000    SUB ESP,84
    00460BF2   53               PUSH EBX
    00460BF3   8B9C24 94000000  MOV EBX,DWORD PTR SS:[ESP+94]
    00460BFA   55               PUSH EBP
    00460BFB   8BAC24 A0000000  MOV EBP,DWORD PTR SS:[ESP+A0]
    00460C02   56               PUSH ESI
    00460C03   8BB424 A0000000  MOV ESI,DWORD PTR SS:[ESP+A0]
    00460C0A   57               PUSH EDI
    00460C0B   8BBC24 98000000  MOV EDI,DWORD PTR SS:[ESP+98]
    00460C12   50               PUSH EAX
    00460C13   51               PUSH ECX
    00460C14   56               PUSH ESI
    00460C15   53               PUSH EBX
    00460C16   55               PUSH EBP
    00460C17   52               PUSH EDX
    00460C18   57               PUSH EDI
    00460C19   E8 62FD1F00      CALL BlackOps.00660980
    00460C1E   F3:0F104F 10     MOVSS XMM1,DWORD PTR DS:[EDI+10]
    00460C23   83C4 1C          ADD ESP,1C
    this is how i'm using it:

    Code:
    bool IsVisible( vec3_t vecpoint )
    {
    	cTrace_t trace;
    	
    	CG_Trace( &trace,refdef->vOrigin,vecpoint,cg->clientNum,0x803003);
    
    	return( trace.fraction == 1.0f );
    }
    and i think the trace struct that kingorgy posted is correct.

    would someone kindly try this function and see if they get the same results?

    many thanks.

    credits:cardoow,raiders,kingorgy.

  2. #2
    cardoow's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    215
    Reputation
    28
    Thanks
    766
    My Mood
    Amazed
    change your mask

  3. The Following User Says Thank You to cardoow For This Useful Post:

    shaunm2 (02-18-2011)

  4. #3
    shaunm2's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    7
    Reputation
    10
    Thanks
    4
    My Mood
    Amazed
    first off thanks for the reply and secondly ive found the correct mask for this trace func which seems to do the same thing aiming through walls and so on...

  5. #4
    King-Orgy's Avatar
    Join Date
    Dec 2010
    Gender
    female
    Posts
    119
    Reputation
    15
    Thanks
    628
    My Mood
    Angelic
    try
    Code:
    void (*CG_Trace)(Trace* Trace, vec3_t Start, vec3_t End, int skipNumber, int mask, int a6, int a7) = (void (__cdecl *)(Trace* , vec3_t , vec3_t , int , int , int , int ))0x004DA230;//done
    
    struct Trace
    {
    	vec3_t            HitPos;
    	int               UNKNOW1; 
    	float	          fraction;
    	float             ViewX;
    	float             ViewY;
            bool              Solid;
    	int               entityNum;
    	float             UNKNOW2;
    	char              z_crap2[32];
    	vec3_t            HitPos2;
    };
    Trace* CTrace;
    
    bool CMisc::isVisible ( vec3_t End )
    {
    	if( !CTrace ) 
    	{ 
    		CTrace = new Trace; ZeroMemory( CTrace, sizeof( Trace ) ); 
    	}
    	CG_Trace	( CTrace, Refdef->Viewport, End, 0, 0x803003, 0, 0 );
            
            return	CTrace->fraction == 1.0f;
    }

  6. The Following 2 Users Say Thank You to King-Orgy For This Useful Post:

    intervention61 (10-10-2011),shaunm2 (02-18-2011)