AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hooking an event with orpheu (https://forums.alliedmods.net/showthread.php?t=143501)

bibu 11-20-2010 18:07

Hooking an event with orpheu
 
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?

Bugsy 11-20-2010 18:58

Re: Hooking an event with orpheu
 
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.

bibu 11-20-2010 19:14

Re: Hooking an event with orpheu
 
I heard it can hook it right before the bomb_explode() event from csx, that's why I was aking.

ConnorMcLeod 11-21-2010 04:12

Re: Hooking an event with orpheu
 
But why do you want to do exactly ?

bibu 11-21-2010 07:33

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

Arkshine 11-21-2010 09:31

Re: Hooking an event with orpheu
 
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"
        }
    ]
}


bibu 11-22-2010 16:44

Re: Hooking an event with orpheu
 
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.

Arkshine 11-22-2010 16:58

Re: Hooking an event with orpheu
 
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.

bibu 11-22-2010 17:13

Re: Hooking an event with orpheu
 
Quote:

Originally Posted by Arkshine (Post 1354716)
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 :wink:

Seta00 11-22-2010 18:39

Re: Hooking an event with orpheu
 
There's an (outdated) tutorial on the wiki: http://wiki.alliedmods.net/Signature..._of_a_Function


All times are GMT -4. The time now is 11:16.

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