Raised This Month: $ Target: $400
 0% 

Hooking an event with orpheu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
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 #1

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
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