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

Detecting when shield is hit (not just aiming at it)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Owyn
Veteran Member
Join Date: Nov 2007
Old 06-29-2009 , 14:50   Detecting when shield is hit (not just aiming at it)
Reply With Quote #1

i searched the forum and found only ways to detect when user is aiming at the shield but not hitting it with the bullet, i want to make an action only when shield is hit not when you just look at it, maybe someone found a way ?

i tried get_tr2( tr, TR_iHitgroup ) in TraceAttack pre and post but traceattack isn't even called for shield
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 06-29-2009 , 15:19   Re: Detecting when shield is hit
Reply With Quote #2

you could rebuild the traceline the engine sends and check yourself whether it hits the shield or not, use FM_EmitSound (bad method) or some better way which hopefully exists ^^
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-29-2009 , 15:20   Re: Detecting when shield is hit
Reply With Quote #3

IIRC the hitgroup of shield is 8.

EDIT:As i knew -> http://forums.alliedmods.net/showpos...57&postcount=5
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 06-29-2009 , 15:51   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #4

for 8th hitgroup TraceAttack isn't called and traceline hooks aiming not shooting (as far as i know)

SchlumPF*
i haven't done anything like that yet, could you help me little further?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-29-2009 , 17:09   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #5

You can simply modulate TraceLine to detect attack. Just hook CmdStart forward, check Buttons&IN_ATTACK then do a traceline ? There are some other ways too...
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 06-29-2009 , 17:22   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #6

,Owyn. yet, i wont give you the code but i will tell you how you can find out how to do what you want (learn-effect):
- download the hlsdk
- search in mp5.dll for the function which is called when the weapon is fired and find the function inside which checks for a hit
- the function is located in combat.cpp
- understand its code, try to rebuild it in pawn and add your shieldhit detection

if its really that hard for you (at least try it) i may help you as soon as i got more motivation + time ;D

@Alka
i guess you know my knife-distance plugin and how it detects the attack type (tracehandle value), should be possible here too also, there is already a tutorial of VEN about this (Owyn search for it in the code snippets section, might be helpful) which does not check pev_buttons or uses cmdstart in general ^^
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-29-2009 , 17:30   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #7

Yea, but my idea is a simple way (: i said
Quote:
Originally Posted by Alka
There are some other ways too...
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-01-2009 , 09:32   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #8

There isn't a clean way to do this since when you hit a shield a traceattack doesn't occur and the shield doesn't even exist as an entity. This is the best way I found:

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <xs>

#define PLUGIN    "New Plugin"
#define AUTHOR    "Unknown"
#define VERSION    "1.0"

const m_iClip 51
const m_iClip_linuxoffset 4

new Weapons[] = 
{
    
CSW_P228,
    
CSW_SCOUT,
    
CSW_XM1014,
    
CSW_C4,
    
CSW_MAC10,
    
CSW_AUG,
    
CSW_ELITE,
    
CSW_FIVESEVEN,
    
CSW_UMP45,
    
CSW_SG550,
    
CSW_GALI,
    
CSW_GALIL,
    
CSW_FAMAS,
    
CSW_USP,
    
CSW_GLOCK18,
    
CSW_AWP,
    
CSW_MP5NAVY,
    
CSW_M249,
    
CSW_M3,
    
CSW_M4A1,
    
CSW_TMP,
    
CSW_G3SG1,
    
CSW_DEAGLE,
    
CSW_SG552,
    
CSW_AK47,
    
CSW_KNIFE,
    
CSW_P90,
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new 
weaponName[24];
    for(new 
i=0;i<sizeof Weapons;i++)
    {
        
get_weaponname(Weapons[i],weaponName,charsmax(weaponName));
        
RegisterHam(Ham_Weapon_PrimaryAttack,weaponName,"attack")
    }
}

public 
attack(weaponID)
{
    if(
get_pdata_int(weaponID,m_iClip,m_iClip_linuxoffset))
    {
        static 
Float:start[3], Float:dest[3] , Float:viewOffset[3], Float:path[3]
        
        new 
id pev(weaponID,pev_owner)
        
        
pev(id,pev_origin,start);
        
pev(id,pev_view_ofs,viewOffset);
        
xs_vec_add(start,viewOffset,start);

        
pev(id,pev_v_angle,path);
        
engfunc(EngFunc_MakeVectors,path);
        
global_get(glb_v_forward,path);

        
xs_vec_mul_scalar(path,9999.0,dest);
        
xs_vec_add(start,dest,dest);
            
        
engfunc(EngFunc_TraceLine,start,dest,0,id,0);
        
        if(
get_tr2(0,TR_iHitgroup) == 8)
        {
            
client_print(0,print_chat,"Hit Shield")
        }
    }

You have to modify it to handle the knife attack right because, as it is, as long you are aiming at a shield (no matter how far from it) and you use the weapon primary attack, it reports a shield hit. (Or ask Schweinsteiger* to do it for you)
__________________

Last edited by joaquimandrade; 07-01-2009 at 16:50. Reason: weapon attack -> knife attack
joaquimandrade is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 07-01-2009 , 11:25   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #9

you get same result just checking pev button IN_ATTACK in traceline, atm i think hooking shield-hit sound with fakemeta is a nice way
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-01-2009 , 11:42   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #10

Quote:
Originally Posted by .Owyn. View Post
you get same result just checking pev button IN_ATTACK in traceline, atm i think hooking shield-hit sound with fakemeta is a nice way
You get the same results but is some hundred times more expensive.

And thinking again, no you don't. You can be pressing IN_ATTACK without attacking.
__________________
joaquimandrade 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 10:48.


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