Page 1 of 1

CollisionHook

Posted: Sun Oct 21, 2018 3:12 pm
by velocity
Is it possible that this can be ported over to SourcePython?

https://forums.alliedmods.net/showthread.php?t=197815

I'm not sure how to do it. Maybe it already is, but I don't see where.

EDIT:
The general idea is to make only some players collide with each other whereas others cannot collide these players but could, for example, collide with someone else. (Therefore changing the collision group will not cut it :( )

Re: CollisionHook

Posted: Wed Oct 24, 2018 9:26 am
by velocity
It has something to do with this identifier:
@_Z22PassServerEntityFilterPK13IHandleEntityS1_


Also, SDKHooks from SM have something called ShouldCollide, how do I use that in SourcePython, any thoughts?? Anything :P

Re: CollisionHook

Posted: Sat Nov 17, 2018 7:34 pm
by velocity
Would be great with some replies. Is it because nobody knows how to do it or no time to do it?

Re: CollisionHook

Posted: Sat Nov 17, 2018 7:39 pm
by Ayuto
Sorry, I totaly forgot about it. Here is the basic structure:

Syntax: Select all

import memory
from memory import Convention
from memory import DataType
from memory.hooks import PreHook
from entities.helpers import baseentity_from_pointer

server = memory.find_binary('server')

PassServerEntityFilter = server['_Z22PassServerEntityFilterPK13IHandleEntityS1_'].make_function(
Convention.CDECL,
[DataType.POINTER, DataType.POINTER],
DataType.BOOL
)

@PreHook(PassServerEntityFilter)
def _pre_pass_server_entity_filter(args):
p1 = baseentity_from_pointer(args[0])
p2 = baseentity_from_pointer(args[1])

# Do your code here

Re: CollisionHook

Posted: Sat Nov 17, 2018 9:02 pm
by velocity
Is that it? The source code for the collisionhook extension seems to do more: https://bitbucket.org/VoiDeD/collisionh ... ew-default
Or is it just this?

Re: CollisionHook

Posted: Sat Nov 17, 2018 9:05 pm
by Ayuto
It only shows how to setup the PassServerEntityFilter hook. Of course, there is more to do, but I haven't looked through the whole SM code. Just wanted to give you a hint/place to start.

Re: CollisionHook

Posted: Sat Nov 17, 2018 9:11 pm
by velocity
I appreciate that. I will try to see if I can make it work! Else I'll be back :)

Re: CollisionHook

Posted: Sat Nov 17, 2018 9:36 pm
by velocity
I put srv_check to False else it wouldn't work. I got a new error:

Syntax: Select all

PassServerEntityFilter = server['_Z22PassServerEntityFilterPK13IHandleEntityS1_'].make_function(



ValueError: Could not find symbol: _Z22PassServerEntityFilterPK13IHandleEntityS1_

Re: CollisionHook

Posted: Sat Nov 17, 2018 9:38 pm
by satoon101
If you are on Windows and/or the game is CS:GO, you will have to find the signature for _Z22PassServerEntityFilterPK13IHandleEntityS1_.

Re: CollisionHook

Posted: Sat Nov 17, 2018 9:41 pm
by velocity
I'm on Linux and in CS:GO. I copied the signatures from gamedata.txt from sourcemod. Isn't this the signature?

Code: Select all

/*
 * quack
*/

"Games"
{
   "#default"
   {
      "Signatures"
      {
         "PassServerEntityFilter"
         {
            "library"   "server"
            
            "windows"   "\x55\x8b\xec\x57\x8b\x7d\x0c\x85\xff\x75\x2a\xb0\x01\x5f\x5d\xc3\x56\x8b\x75"
            "linux"      "@_Z22PassServerEntityFilterPK13IHandleEntityS1_"
         }
      }
   }

Re: CollisionHook

Posted: Sun Nov 18, 2018 12:31 am
by L'In20Cible
velocity wrote:I'm on Linux and in CS:GO. I copied the signatures from gamedata.txt from sourcemod. Isn't this the signature?

Symbols are no longer public into the Linux binaries for CS:GO for quite some time now so you have to find a signature like you do on Windows.

Re: CollisionHook

Posted: Sun Nov 18, 2018 2:43 pm
by velocity
Alright I found the signature and got the function working.


Syntax: Select all

server = memory.find_binary('server', srv_check=False)

PassServerEntityFilter = server[b'\x55\xB8\x01\x00\x00\x00\x89\xE5\x83\xEC\x38\x89\x5D\xF4'].make_function(
Convention.CDECL,
[DataType.POINTER, DataType.POINTER],
DataType.BOOL
)


@PreHook(PassServerEntityFilter) # Edit it should be PreHook I messed around with them, It still doesn't work
def _pre_pass_server_entity_filter(args):
try:
p1 = index_from_pointer(args[0])
p2 = index_from_pointer(args[1])
except ValueError:
return

base_entity0 = BaseEntity(p1)
base_entity1 = BaseEntity(p2)

if not base_entity0.is_player() or not base_entity1.is_player():
return

return False



Players can now walk through each other, but it is not smooth - meaning that the player is twitching, slowing down. I'm unaware how to avoid this. I wonder if I could use ShouldCollide, but I'm not entirely sure what it does and how to use it. The main goal is to make certain entities collide, smoothly that is! :) Any ideas?

The CollisionHook extension has another cool thing:
PHP Code: forward Action:CH_ShouldCollide( ent1, ent2, &bool:result ); CH_ShouldCollide is called when vphysics is determining whether two vphysics objects (and their associated entities) should collide. Examples of these kinds of collisions include projectiles colliding with the world entity.

Re: CollisionHook

Posted: Sun Nov 18, 2018 3:11 pm
by Ayuto
Have you tried returning True instead of False?

Re: CollisionHook

Posted: Sun Nov 18, 2018 4:06 pm
by velocity
Yeah, returning True results in you just getting stuck

Edit:
Is it possible to hook this in SP?
CCOllisionEvent::ShouldCollide(IPhysicsObject*, IPhysicisObject*, void*, void*)

Edit #2
I got an answer from SourceMod forums how to avoid this "lag" problem, they use an extension called SendProxy, which allows you to modify collisiongroup in some smart way (source-code: https://github.com/SlidyBat/sendproxy ). This extension looks complicated, I'm not sure if this will be possible in SP :( Unless you guys can come up with a smart solution.

Re: CollisionHook

Posted: Mon Feb 21, 2022 3:58 pm
by Painkiller
Hi guys,
would this also work in HL2:DM ?
A CollisionHook so that the Combine Balls kill the bots again?

Unfortunately there is
https://forums.alliedmods.net/showthread.php?t=197815
no download available anymore.

Maybe someone could do it again.
I've been looking for something like this for a while.

Greetings Painkiller