Raised This Month: $ Target: $400
 0% 

Hooking an event with orpheu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 11-20-2010 , 18:07   Hooking an event with orpheu
Reply With Quote #1

I am hooking bomb (c4) explosion with the one from the csx module. I want to hook it by using orpheu and hooking CGrenade::Explode2() which is the best way I heard. Is someone willing to help me with that?
bibu is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-20-2010 , 18:58   Re: Hooking an event with orpheu
Reply With Quote #2

It doesn't matter which module is used to do a particular task as long as there is no major difference in amount of code and/or efficiency. Why do you prefer orpheu? Nothing against the module or anything but you should seek a solution to the problem/question itself without requesting it be with only a single method/format unless there's a valid reason.
__________________
Bugsy is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-20-2010 , 19:14   Re: Hooking an event with orpheu
Reply With Quote #3

I heard it can hook it right before the bomb_explode() event from csx, that's why I was aking.
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-21-2010 , 04:12   Re: Hooking an event with orpheu
Reply With Quote #4

But why do you want to do exactly ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-21-2010 , 07:33   Re: Hooking an event with orpheu
Reply With Quote #5

This sometime works and sometimes not, that's why I thought it would work perfectly by hooking it with orpheu.

Last edited by bibu; 11-21-2010 at 16:26.
bibu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-21-2010 , 09:31   Re: Hooking an event with orpheu
Reply With Quote #6

bomb_explode() is sent when #Target_Bomb message is detected.
When the bomb timer is finished, CGrenade::Detonate2() (called from CGrenade::C4Think()) calls CGrenade::Explode2(). Inside, it calls CBaseMonster::RadiusDamage().
#Target_Bomb is fired in CHalflifeMultiplay::CheckWinConditions().

So, basically : Timer ends -> Explosion -> Radius damage -> Scoring -> End message.

bomb_explode() is called after the damage done, so it can't work using this forward.

Without using Orpheu, it could be possible to hook svc_tempentity or ScreenShake but for the most reliable way would be to hook CGrenade::Detonate2() or CGrenade::Explode2().
Using Orpheu, I would use CGrenade::Detonate2(), because this function is exported by default thus giving a symbol name which is more reliable than making a signatures of bytes.

So :

Code:
#include <amxmodx> #include <orpheu> public plugin_init() {     OrpheuRegisterHook( OrpheuGetFunction( "Detonate2", "CGrenade" ), "CGrenade_Detonate2" ); } public CGrenade_Detonate2() {     log_amx( "CGrenade::Detonate2() called." ); }

and the signature, you need to create a file named "Detonate2" in "orpheu/functions/CGrenade" with this content :

Code:
{
    "name"        : "Detonate2",
    "class"       : "CGrenade",
    "library"     : "mod",
    "identifiers" :
    [
        {
            "os"    : "windows",
            "mod"   : "cstrike",
            "value" : "?Detonate2@CGrenade@@QAEXXZ"
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : "Detonate2__8CGrenade"
        }
    ]
}
__________________
Arkshine is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-22-2010 , 16:44   Re: Hooking an event with orpheu
Reply With Quote #7

Works perfectly on linux / windows. I really wonder how you found those things with the values for win and linux
and thinking about why there isn't any topic in the tutorials section with a list of made signatures and functions available for orpheu.
bibu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-22-2010 , 16:58   Re: Hooking an event with orpheu
Reply With Quote #8

Simply by disassembling the mod binary. For sure, it would be nice to have all the signatures, well, orpheu is still new and coders are not used yet of such module, so it's fine to ask here for the moment. I have to make a tuto how to make a signature, but I'm not motivated right now.
__________________
Arkshine is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 11-22-2010 , 17:13   Re: Hooking an event with orpheu
Reply With Quote #9

Quote:
Originally Posted by Arkshine View Post
I have to make a tuto how to make a signature, but I'm not motivated right now.
That would be really awesome, so that means, stop being lazy... nono I will just wait and read it if you are going to do it sometime. Thanks again
bibu is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 11-22-2010 , 18:39   Re: Hooking an event with orpheu
Reply With Quote #10

There's an (outdated) tutorial on the wiki: http://wiki.alliedmods.net/Signature..._of_a_Function
Seta00 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 11:16.


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