Raised This Month: $51 Target: $400
 12% 

FM_Touch vs Ham_Touch vs register_touch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-10-2013 , 10:10   FM_Touch vs Ham_Touch vs register_touch
Reply With Quote #1

Which is the best variant to hook touch especially when the players have high speed (sat_user_maxspeed( , >500))

Last edited by didoWEE; 04-11-2013 at 09:06.
didoWEE is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-10-2013 , 11:27   Re: FM_Touch vs Ham_Touch
Reply With Quote #2

I've tested this before and found that FM_Touch was faster, and engine touch was faster then both of them.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-10-2013 , 11:33   Re: FM_Touch vs Ham_Touch
Reply With Quote #3

Ok, thanks. I'm waiting for more posts
I'll try with Engine
didoWEE is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 04-10-2013 , 16:07   Re: FM_Touch vs Ham_Touch
Reply With Quote #4

You should also note that Ham gives you the ability (requirement) to limit the Touch calls by classname directly in the forward registration. It really matters on what you want to use it for as each is better for something else. Though generally speaking, engine calls are the fastest.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 04-10-2013 at 16:10.
Backstabnoob is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-10-2013 , 16:45   Re: FM_Touch vs Ham_Touch
Reply With Quote #5

Yes, hook Ham_Touch is more efficient than FM_Touch, and by far, dunno what Hornet is talking about.
FM_Touch should NEVER be hooked IMO.

As said, you may prefer register_touch over Ham_Touch, depending on your needs (also supports custom class entities).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-11-2013 , 00:11   Re: FM_Touch vs Ham_Touch
Reply With Quote #6

player touch player
btw which is the first index - the touched or the the toucher

Last edited by didoWEE; 04-11-2013 at 00:11.
didoWEE is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-11-2013 , 01:12   Re: FM_Touch vs Ham_Touch
Reply With Quote #7

first index is toucheD, always.

But if you use register_think("player", "player", "some_function")

When a touched by b, b is also touched by a, so you gonna have function called twice for sure if you hook FM_Touch or pfn_touch
If you hook with register_think there are some checks made internally to plugin, i couln't say if it is to prevent that but it seems to be something like that, anyway that should be faster to log it from a plugin rather than decript code


About the order touched and toucher, this is how it works :

game engine (not the module) on every frame detects what touchs what, and when an entity is touched it calls pfnTouch function on game dll, which is represented in code whith function name DispatchTouch.

void DispatchTouch( edict_t *pentTouched, edict_t *pentOther )
Spoiler


So you can see that in DispatchTouch function, if some checks are passed, virtual function ->Touch is passed which results in function CBaseEntity::Touch


If you hook FM_Touch (fakemeta module) or pfn_touch (engine module) or custom forward with register_touch (engine), you are basically hooking when pfnTouch (DispatchTouch) is called by the game engine to the dll engine.
When you hook Ham_Touch (hamsandwich module), you are hooking pEntity->Touch( pOther ); where in your plugin pEntity gonna be the first argument and oPther gonna be the second.


So, do never hook FM_Touch or pfn_touch (or old one vexd_pfntouch which is the same and kept in amxx for compatibility), prefer register_touch or Ham_Touch depending on your needs.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-12-2013 at 00:42.
ConnorMcLeod is offline
didoWEE
Senior Member
Join Date: Oct 2012
Location: Bulgaria
Old 04-11-2013 , 09:10   Re: FM_Touch vs Ham_Touch vs register_touch
Reply With Quote #8

Thanks for this good answer
didoWEE is offline
Reply



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 12:00.


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