View Single Post
nosoop
Veteran Member
Join Date: Aug 2014
Old 10-21-2019 , 10:03   Re: [tf2] hook when physics objects collide?
Reply With Quote #8

For collisions between physics objects (including world), you may want to hook CBaseEntity::VPhysicsCollision(int index, gamevcollisionevent_t* event) with DHooks.

The first argument determines which array index represents its own values in the collision event argument (0 or 1).

Here's some information about the offsets within the gamevcollisionevent_t struct for TF2, should you need it:

Code:
// vphysics_interface.h
abstract_class IPhysicsCollisionData {
public:
	virtual void GetSurfaceNormal( Vector &out ) = 0;
	virtual void GetContactPoint( Vector &out ) = 0;
	virtual void GetContactSpeed( Vector &out ) = 0;
}

// public/vphysics_interfaceV30.h
struct vcollisionevent_t {
	IPhysicsObject*			pObjects[2]; // 0x00, 0x04
	int						surfaceProps[2]; // 0x08, 0x0C
	bool					isCollision; // 0x10
	bool					isShadowCollision; // 0x11 ??
	float					deltaCollisionTime; 0x14
	
	float					collisionSpeed; // 0x18
	IPhysicsCollisionData*	pInternalData; // 0x1C
}

// game/server/physics.h
struct gamevcollisionevent_t : vcollisionevent_t {
	Vector					preVelocity[2]; // 0x20, 0x2C
	Vector					postVelocity[2]; // 0x38, 0x44
	AngularImpulse			preAngularVelocity[2]; // 0x50, 0x5C
	CBaseEntity*			pEntities[2]; // 0x68, 0x6C
}
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 10-21-2019 at 10:05.
nosoop is offline