Seems like i can't get this to work. Since almost everyone out there probably has that one working, does someone see what could possibly be wrong in here?
I'm using engine.dll and EngineTraceClient0 to obtain the pointer to IEngineTrace, that should be fine. (ptr is not null)
Thanks in advance.
I'm using engine.dll and EngineTraceClient0 to obtain the pointer to IEngineTrace, that should be fine. (ptr is not null)
Code:
struct cplane_t
{
Vector normal;
float dist;
BYTE type;
BYTE signbits;
BYTE pad[2];
};
class CBaseTrace
{
public:
Vector startpos;
Vector endpos;
cplane_t plane;
float fraction;
int contents;
unsigned short dispFlags;
bool allsolid;
bool startsolid;
};
struct csurface_t
{
const char* name;
short surfaceProps;
unsigned short flags;
};
class CGameTrace : public CBaseTrace
{
public:
bool DidHitWorld() const;
bool DidHitNonWorldEntity() const;
int GetEntityIndex() const;
bool DidHit() const;
public:
float fractionleftsolid;
csurface_t surface;
int hitgroup;
short physicsbone;
unsigned short worldSurfaceIndex;
CBaseEntity* m_pEnt;
int hitbox;
};
inline bool CGameTrace::DidHit() const
{
return fraction < 1.0f || allsolid || startsolid;
}
typedef CGameTrace trace_t;
enum TraceType_t
{
TRACE_EVERYTHING = 0,
TRACE_WORLD_ONLY,
TRACE_ENTITIES_ONLY,
TRACE_EVERYTHING_FILTER_PROPS,
};
class ITraceFilter
{
public:
virtual bool ShouldHitEntity(PVOID pEntity, int contentsMask) = 0;
virtual TraceType_t GetTraceType() const = 0;
};
Code:
void TraceRay(const Ray_t &ray, unsigned int fMask, ITraceFilter* pTraceFilter, trace_t* pTrace)
{
typedef void(__thiscall* fnTraceRay)(void*, const Ray_t&, unsigned int, ITraceFilter*, trace_t*);
ToVirtual<fnTraceRay>(this, 5)(this, ray, fMask, pTraceFilter, pTrace);
}
Code:
source_engine::Ray_t ray;
source_engine::trace_t trace;
ray.Init(pLocalPlayer->GetEyePos(), pBasePlayer->GetEyePos());
pEngineTrace->TraceRay(ray, 0x4600400B, NULL, &trace); //crashs here
Aucun commentaire:
Enregistrer un commentaire