CollisionHook

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

CollisionHook

Postby velocity » Sun Oct 21, 2018 3:12 pm

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 :( )
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Wed Oct 24, 2018 9:26 am

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
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Sat Nov 17, 2018 7:34 pm

Would be great with some replies. Is it because nobody knows how to do it or no time to do it?
User avatar
Ayuto
Project Leader
Posts: 1911
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: CollisionHook

Postby Ayuto » Sat Nov 17, 2018 7:39 pm

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
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Sat Nov 17, 2018 9:02 pm

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?
User avatar
Ayuto
Project Leader
Posts: 1911
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: CollisionHook

Postby Ayuto » Sat Nov 17, 2018 9:05 pm

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.
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Sat Nov 17, 2018 9:11 pm

I appreciate that. I will try to see if I can make it work! Else I'll be back :)
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Sat Nov 17, 2018 9:36 pm

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_
User avatar
satoon101
Project Leader
Posts: 2582
Joined: Sat Jul 07, 2012 1:59 am

Re: CollisionHook

Postby satoon101 » Sat Nov 17, 2018 9:38 pm

If you are on Windows and/or the game is CS:GO, you will have to find the signature for _Z22PassServerEntityFilterPK13IHandleEntityS1_.
Image
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Sat Nov 17, 2018 9:41 pm

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_"
         }
      }
   }
User avatar
L'In20Cible
Project Leader
Posts: 1105
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: CollisionHook

Postby L'In20Cible » Sun Nov 18, 2018 12:31 am

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.
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Sun Nov 18, 2018 2:43 pm

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.
Last edited by velocity on Sun Nov 18, 2018 6:25 pm, edited 1 time in total.
User avatar
Ayuto
Project Leader
Posts: 1911
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: CollisionHook

Postby Ayuto » Sun Nov 18, 2018 3:11 pm

Have you tried returning True instead of False?
User avatar
velocity
Senior Member
Posts: 153
Joined: Sat May 10, 2014 6:17 pm

Re: CollisionHook

Postby velocity » Sun Nov 18, 2018 4:06 pm

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.

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 16 guests