Raised This Month: $32 Target: $400
 8% 

Solved Ham_TraceAttack for Grenades?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WAR3DM
Senior Member
Join Date: Mar 2016
Old 03-08-2018 , 15:20   Ham_TraceAttack for Grenades?
Reply With Quote #1

Hello

Is it possible to trace grenade attacks on a brush entity? Ham_TraceAttack seems to only work for bullets.

Code:
/**
     * Description:     Usually called whenever an entity gets attacked by a hitscan (such as a gun) weapon.
     *                  Use the get/set tr2 natives in fakemeta to handle the traceresult data.
     *                  Do not use a handle of 0 as a traceresult in execution, use create_tr2() from Fakemeta
     *                  to pass a custom handle instead.  (Don't forget to free the handle when you're done.)
     * Forward params:  function(this, idattacker, Float:damage, Float:direction[3], traceresult, damagebits)
     * Return type:     None.
     * Execute params:  ExecuteHam(Ham_TraceAttack, this, idattacker, Float:damage, Float:direction[3], tracehandle, damagebits);
     */
    Ham_TraceAttack
I tried Ham_TakeDamage but that doesn't seem to work on brush entities.

Perhaps there's a way to detect grenade blasts within a radius around the brush entity?

Any help is greatly appreciated!

Last edited by WAR3DM; 03-10-2018 at 21:38.
WAR3DM is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 03-08-2018 , 17:19   Re: Ham_TraceAttack for Grenades?
Reply With Quote #2

Quote:
Perhaps there's a way to detect grenade blasts within a radius around the brush entity?
1. Hook takedamage on func_breakable?
2. On explode search ent in radius?
__________________
My English is A0
E1_531G is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 03-09-2018 , 15:09   Re: Ham_TraceAttack for Grenades?
Reply With Quote #3

Hook grenade think then get dmgtime, when 1.0s before explode, do check brush entity

PHP Code:
RegisterHam(Ham_Think"grenade""fw_ThinkGrenade")

...

public 
fw_ThinkGrenade(Ent)
{
    if(!
pev_valid(Ent)) return HAM_IGNORED

    
static Float:dmgtime
    pev
(Entpev_dmgtimedmgtime)
    
    if(
dmgtime 1.0 <= get_gametime())
    {
        
//Check here
    
}

__________________
My plugin:
Celena Luna is offline
WAR3DM
Senior Member
Join Date: Mar 2016
Old 03-09-2018 , 23:26   Re: Ham_TraceAttack for Grenades?
Reply With Quote #4

Thanks, that works perfect!

Any idea how to keep it from triggering multiple times for each grenade?

Last edited by WAR3DM; 03-09-2018 at 23:26.
WAR3DM is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 03-10-2018 , 07:00   Re: Ham_TraceAttack for Grenades?
Reply With Quote #5

Quote:
Originally Posted by WAR3DM View Post
Thanks, that works perfect!

Any idea how to keep it from triggering multiple times for each grenade?
What do you mean?
__________________
My plugin:
Celena Luna is offline
WAR3DM
Senior Member
Join Date: Mar 2016
Old 03-10-2018 , 14:13   Re: Ham_TraceAttack for Grenades?
Reply With Quote #6

Quote:
Originally Posted by Celena Luna View Post
What do you mean?
fw_ThinkGrenade triggers multiple times for every grenade, I only need it to trigger once.
WAR3DM is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 03-10-2018 , 14:42   Re: Ham_TraceAttack for Grenades?
Reply With Quote #7

https://www.amxmodx.org/api/hamsandw...ableHamForward
__________________
My English is A0
E1_531G is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-10-2018 , 16:25   Re: Ham_TraceAttack for Grenades?
Reply With Quote #8

Quote:
Originally Posted by WAR3DM View Post
fw_ThinkGrenade triggers multiple times for every grenade, I only need it to trigger once.
It's a think event, it's going to be called again and again and again until this entity is removed. You can disable the forward or use some boolean to decide when you want to execute the code.
__________________
HamletEagle is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 03-10-2018 , 17:25   Re: Ham_TraceAttack for Grenades?
Reply With Quote #9

Quote:
Originally Posted by WAR3DM View Post
fw_ThinkGrenade triggers multiple times for every grenade, I only need it to trigger once.
Like Hamlet said, you can disable forward but I suggest you not doing it if you don't know what are you doing.

Other way is the give a boolean but you need to make the g_Checked back to false somewhere to make the grenade check brush entity again

PHP Code:
new bool:g_Checked 

RegisterHam
(Ham_Think"grenade""fw_ThinkGrenade")

...

public 
fw_ThinkGrenade(Ent)
{
    if(!
pev_valid(Ent)) return HAM_IGNORED

    
static Float:dmgtime
    pev
(Entpev_dmgtimedmgtime)
    
    if(
dmgtime 1.0 <= get_gametime())
    {
        if(!
g_Checked)
        {
                
//Check here
                
g_Checked true
        
}
    }

__________________
My plugin:

Last edited by Celena Luna; 03-10-2018 at 17:26.
Celena Luna is offline
WAR3DM
Senior Member
Join Date: Mar 2016
Old 03-10-2018 , 21:38   Re: Ham_TraceAttack for Grenades?
Reply With Quote #10

Thanks guys, the bool global works perfectly. I set it back to false with a set_task.
WAR3DM 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 22:53.


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