Raised This Month: $63 Target: $400
 15% 

[tf2] hook when physics objects collide?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
foon
Junior Member
Join Date: Dec 2018
Old 10-18-2019 , 13:31   [tf2] hook when physics objects collide?
Reply With Quote #1

Im wondering if there is a way to test when a physics object (pipebomb, stickybomb, milk, jarate, etc [it does work with all flairs, but not gaspasser]) hits another?

I am spawning in a model and setting the solidtype to vphysics, It triggers with rockets fine, but no physics objects. I have tried all collision groups, but none work. Any ideas?

Code:
}
int entity = CreateEntityByName("prop_physics_override");
	if (IsValidEntity(entity))
	{
		SetEntityModel(entity, model);
		DispatchKeyValue(entity, "StartDisabled", "false");
		DispatchSpawn(entity);
		
		TeleportEntity(entity, origin, NULL_VECTOR, NULL_VECTOR);
		
		SetEntProp(entity, Prop_Send, "m_usSolidFlags", 12); // FSOLID_NOT_SOLID|FSOLID_TRIGGER
		SetEntProp(entity, Prop_Data, "m_nSolidType", 6); // SOLID_VPHYSICS
		SetEntProp(entity, Prop_Send, "m_CollisionGroup", 2); // COLLISION_GROUP_DEBRIS
		AcceptEntityInput(entity, "Enable");
		
		SDKHook(entity, SDKHook_StartTouch, Hook_OnTouch);
	}
}

public Action Hook_OnTouch(int call, int client)
{
	PrintToServer("touched");
}

Last edited by foon; 10-18-2019 at 15:19.
foon is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 10-18-2019 , 15:38   Re: [tf2] hook when physics objects collide?
Reply With Quote #2

Did you try SDKHook_ShouldCollide ?

Also, may be helpful for you:
https://forums.alliedmods.net/showthread.php?t=197815
__________________
Expert of CMD/VBS/VB6. Malware analyst.
[My plugins] [My tools] [GitHub]
Dragokas is offline
foon
Junior Member
Join Date: Dec 2018
Old 10-18-2019 , 16:09   Re: [tf2] hook when physics objects collide?
Reply With Quote #3

SDKHook_ShouldCollide seems to use the boundingbox instead of VPhysics, so if the model is concave or rotated, it wont work (unless I am doing something wrong here). I just tested CollisionHook after I made my first post, but it seems its not updated anymore and doesn't work.

Last edited by foon; 10-18-2019 at 16:40.
foon is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine
Old 10-19-2019 , 08:21   Re: [tf2] hook when physics objects collide?
Reply With Quote #4

And what about SDKHook_Touch instead StartTouch?

What "model" variable = ? Is it a model supporting physics at all?
Try prop_physics instead.
__________________
Expert of CMD/VBS/VB6. Malware analyst.
[My plugins] [My tools] [GitHub]

Last edited by Dragokas; 10-19-2019 at 08:27.
Dragokas is offline
foon
Junior Member
Join Date: Dec 2018
Old 10-19-2019 , 11:16   Re: [tf2] hook when physics objects collide?
Reply With Quote #5

I have tried SDKHook_Touch, yes. I got CollisionHook working, but it is exactly the same as using SDKHook in this case. The model is custom and it does support physics. I have also tried prop_physics (and override) but its the same.

If you want to check out the model, here it is: https://files.catbox.moe/rx61p6.zip

Here are some pics too.
https://i.imgur.com/BTzp6HW.png
https://i.imgur.com/jGTFIJt.png

And here is an example, if I shoot through the corners, it still registers as getting hit. Its like its using the bbox instead of vphysics.
https://i.imgur.com/9ZwbOIx.png

Last edited by foon; 10-20-2019 at 10:40.
foon is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Location: Methamphetamine
Old 10-20-2019 , 01:34   Re: [tf2] hook when physics objects collide?
Reply With Quote #6

You can try to use this

https://developer.valvesoftware.com/...lisionProperty
CCollisionProperty::SetSurroundingBoundsType( SurroundingBoundsType_t, Vector const*, Vector const*)

or this

https://developer.valvesoftware.com/wiki/Bounding_box
UTIL_SetSize() or CBaseEntity::SetSize()
__________________
Heart
BHaType is offline
Send a message via AIM to BHaType
foon
Junior Member
Join Date: Dec 2018
Old 10-20-2019 , 11:53   Re: [tf2] hook when physics objects collide?
Reply With Quote #7

I have gone through all the settings for m_nSurroundType, but its still exactly the same. It either triggers with the bbox/rbox/absbox, or it doesn't trigger at all. Is there maybe a way where I can parent a rocket to the sticky/pipe and still keep the physics of the sticky/pipe?

Last edited by foon; 10-20-2019 at 11:57.
foon is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 10-21-2019 , 11: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)

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:25.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode