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

grenade miss check


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-02-2023 , 04:49   grenade miss check
Reply With Quote #1

hi, is there a 'if check' to check if a grenade is missed? thanks

im just trying to play a sound when its missed but i cant figure it out

PHP Code:
if (something here?)
        {
            
ArrayGetString(grenade_miss_playerrandom_num(0ArraySize(grenade_miss_player) - 1), soundcharsmax(sound))
            
emit_sound(victimCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
            continue;
        } 

Last edited by HowToRuski; 04-02-2023 at 04:56.
HowToRuski is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-02-2023 , 05:20   Re: grenade miss check
Reply With Quote #2

How do you define a miss? For example, if we are talking about he grenade, is it a miss if the grenade does not damage anyone or is it a miss if the grenade does not directly hit (touch) a player?
__________________

Last edited by HamletEagle; 04-02-2023 at 05:20.
HamletEagle is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 04-02-2023 , 05:23   Re: grenade miss check
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
How do you define a miss? For example, if we are talking about he grenade, is it a miss if the grenade does not damage anyone or is it a miss if the grenade does not directly hit (touch) a player?
probably not damage anyone

i've got something like this, but it doesnt seem to work....
PHP Code:
// Missed grenade
        
if (victim == -1)
        {
            
ArrayGetString(grenade_miss_playerrandom_num(0ArraySize(grenade_miss_player) - 1), soundcharsmax(sound))
            
emit_sound(victimCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
            continue;
        } 

Last edited by HowToRuski; 04-02-2023 at 05:38.
HowToRuski is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-02-2023 , 17:50   Re: grenade miss check
Reply With Quote #4

Not ideal but it works without using Orpheu
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const Version[] = "0.1";

new const 
GrenadeExplodedSounds[][] =
{
    
"weapons/debris1.wav",
    
"weapons/debris2.wav",
    
"weapons/debris3.wav"
};

public 
plugin_init() 
{
    
register_plugin"Detect Grenade Damage" Version "bugsy" );
    
    
RegisterHamHam_TakeDamage "player" "PlayerTakeDamage" );
    
register_forwardFM_EmitSound "EmitSound" );
}

public 
PlayerTakeDamageiVictim iInflictor iAttacker Float:fDamage damageBits )
{
    if ( 
iInflictor != iAttacker )
    {
        
set_peviInflictor pev_iuser4 );
        
client_printprint_chat "Player id [%d] took damage by grenade entity [%d]" iVictim iInflictor );
    }
}

public 
grenade_throwid gid wid )
{
    if ( 
wid == CSW_HEGRENADE )
    {
        
client_printprint_chat "Grenade entity [%d] thrown" gid );
        
set_pevgid pev_iuser4 );
    }
}

public 
EmitSoundiEntity iChannel , const szSound[] )
{
    if ( 
pev_validiEntity ) )
    {        
        for( new 
sizeofGrenadeExplodedSounds ) ; i++ )
        {
            if ( 
equalGrenadeExplodedSounds], szSound ) )
            {
                
client_printprint_chat "Grenade entity [%d] exploded" iEntity );
                
set_task0.2 "CheckForDamage" iEntity );
                break;
            }
        }
    }
    
    return 
FMRES_IGNORED;
}

public 
CheckForDamageiEntity )
{    
    if ( 
peviEntity pev_iuser4 ) )
        
client_printprint_chat "Player(s) were damaged by grenade entity [%d]" iEntity );
    else
        
client_printprint_chat "No player(s) were damaged by grenade entity [%d]" iEntity );

__________________

Last edited by Bugsy; 04-08-2023 at 23:56.
Bugsy is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 04-03-2023 , 08:18   Re: grenade miss check
Reply With Quote #5

Depends, if you want it the easy way purpose damage detector you'd hook ham takedamage and check damagebits type DMG_GRENADE. Simple.

You could also hook when the grenade explodes, and use find_ent_in_sphere or whatever the function was called, creating a sphere of dimensions - DMG_GRENADE radius const value, but this way its worse because if you have a plugin modifying it's range then it won't detect it.

Also please check if the damage inflicted was less than 1, so you don't accidentally register 0.5 dmg (which causes players to emit hurt sounds but they stay undamaged)
__________________

Last edited by deprale; 04-03-2023 at 08:19.
deprale is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-03-2023 , 08:22   Re: grenade miss check
Reply With Quote #6

This wasn't meant to be the end all be all, it worked in a few quick tests I did. It may need some TLC to get perfect. Feel free if you have the time.
__________________
Bugsy is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 04-03-2023 , 08:26   Re: grenade miss check
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
This wasn't meant to be the end all be all, it worked in a few quick tests I did. It may need some TLC to get perfect. Feel free if you have the time.
Oh it wasn't a critique to your reply Bugsy, I was throwing suggestions at the OP, he doesn't look clueless so I didn't bother writing any code.
__________________
deprale 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 14:40.


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