Raised This Month: $ Target: $400
 0% 

[Help] Shield touch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 01-26-2015 , 15:23   [Help] Shield touch
Reply With Quote #1

I searched around but couldn't find a way to *easily* detect shield's touch (NOT shield pickup)

I want to hook touch between X entity and shielded user, and find out if that entity hit the player or the shield ._.

This is the code I'm currently testing (inside engine touch)

PHP Code:
if(cs_get_user_shield(ent)) //shielded player?
{
    new 
Float:ent_orig[3//hitted player origin
    
new Float:bullet_orig[3//hitter entity origin
    
pev(entpev_originent_orig)
    
pev(bulletpev_originbullet_orig)

    
//I found this code (just slightly modified) but doesn't seem to work for me >.<
    
new trace 0
    engfunc
(EngFunc_TraceLinebullet_origent_origDONT_IGNORE_MONSTERS0trace)
    new 
hitgroup get_tr2(traceTR_iHitgroup)

    
client_print(ownerprint_chat"Bullet orig %.2f %.2f %.2f"bullet_orig[0], bullet_orig[1], bullet_orig[2])
    
client_print(ownerprint_chat"Player orig %.2f %.2f %.2f"ent_orig[0], ent_orig[1], ent_orig[2])
    
client_print(entprint_chat"Bullet orig %.2f %.2f %.2f"bullet_orig[0], bullet_orig[1], bullet_orig[2])
    
client_print(entprint_chat"Player orig %.2f %.2f %.2f"ent_orig[0], ent_orig[1], ent_orig[2])

    if(
hitgroup == 8)//HIT_SHIELD)
    
{
        
client_print(ownerprint_chat"Shield hit")
        
client_print(entprint_chat"Shield hit")
    }

I'm not sure if I need to use TR_pHit, since the touch is registered only between entity and player.
These are some hits I got

Code:
Bullet orig -458.64 817.47 32.23
Player orig -443.50 834.50 36.03

Bullet orig 682.42 -191.39 140.70
Player orig 699.45 -189.44 132.03

Bullet orig 682.42 -178.76 135.52
Player orig 699.45 -189.44 114.03

Bullet orig 682.42 -173.55 126.96
Player orig 699.45 -189.44 114.03

Bullet orig 1435.05 630.16 214.56
Player orig 1452.08 632.21 196.03

Bullet orig 2352.99 625.98 190.38
Player orig 2362.70 643.02 196.03
I couldn't get any hit on the shield >.<
Any help?
__________________
Hey ^_^
NikKOo31 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-26-2015 , 16:24   Re: [Help] Shield touch
Reply With Quote #2

Ignore ent param should be probably "ent" instead of "0".
__________________
Arkshine is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 01-26-2015 , 17:08   Re: [Help] Shield touch
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
Ignore ent param should be probably "ent" instead of "0".
I just tested a few times with different values

PHP Code:
if(cs_get_user_shield(ent))
{
    new 
Float:ent_orig[3]
    new 
Float:bullet_orig[3]
    
pev(entpev_originent_orig)
    
pev(bulletpev_originbullet_orig)

    new 
hitgrouptrace 0
    engfunc
(EngFunc_TraceLinebullet_origent_origDONT_IGNORE_MONSTERS0trace)
    
hitgroup get_tr2(traceTR_iHitgroup)
    
client_print(entprint_chat"Hitgroup (0): %d"hitgroup)

    
trace 0
    engfunc
(EngFunc_TraceLinebullet_origent_origDONT_IGNORE_MONSTERSenttrace)
    
hitgroup get_tr2(traceTR_iHitgroup)
    
client_print(entprint_chat"Hitgroup (ent): %d"hitgroup)

    
trace 0
    engfunc
(EngFunc_TraceLinebullet_origent_origDONT_IGNORE_MONSTERSbullettrace)
    
hitgroup get_tr2(traceTR_iHitgroup)
    
client_print(entprint_chat"Hitgroup (bullet): %d"hitgroup)

    if(
hitgroup == 8)//HIT_SHIELD)
    
{
        
client_print(ownerprint_chat"Shield hit")
        
client_print(entprint_chat"Shield hit")
    }

If I ignore ent (player) I got no hits
This time I got 1 hit in the shield (I was covered all the time but only 1 hit was detected in the shield)

Code:
Hitgroup (0): 3
Hitgroup (ent): 0
Hitgroup (bullet): 3

Hitgroup (0): 5
Hitgroup (ent): 0
Hitgroup (bullet): 5

Hitgroup (0): 8
Hitgroup (ent): 0
Hitgroup (bullet): 8
Shield hit

Hitgroup (0): 0
Hitgroup (ent): 0
Hitgroup (bullet): 4

Hitgroup (0): 5
Hitgroup (ent): 0
Hitgroup (bullet): 5

Hitgroup (0): 4
Hitgroup (ent): 0
Hitgroup (bullet): 4
I can't figure out how to detect the shield *accurately* >.<
__________________
Hey ^_^

Last edited by NikKOo31; 01-26-2015 at 17:39.
NikKOo31 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-26-2015 , 18:50   Re: [Help] Shield touch
Reply With Quote #4

Are you sure you test properly? Meaning shield is well drawn when you do traceline?
Ignorent should be "ent", because trace line starts from player (inside), and you probably don't want to hit inside.
__________________
Arkshine is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 01-26-2015 , 20:32   Re: [Help] Shield touch
Reply With Quote #5

I covered with shield and run directly to bots ._. it was well drawn

Isn't this trace from bullet to player?
PHP Code:
engfunc(EngFunc_TraceLinebullet_origent_origDONT_IGNORE_MONSTERS0trace
From 2nd param, to 3rd param

I think the problem is that engine touch is too late to make a traceline, the entity goes through the shield too fast, that's why I'm not detecting it
__________________
Hey ^_^
NikKOo31 is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 01-26-2015 , 21:26   Re: [Help] Shield touch
Reply With Quote #6

Quote:
I think the problem is that engine touch is too late to make a traceline, the entity goes through the shield too fast, that's why I'm not detecting it
If your bullet ent is moving too fast then yes, the ent can past through certain part of player before touch is call, especially if ent's solid is SOLID_TRIGGER(sometimes it can past through completely without touch called with this solid type).

Last edited by RateX; 01-26-2015 at 21:26.
RateX is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 01-26-2015 , 23:59   Re: [Help] Shield touch
Reply With Quote #7

Quote:
Originally Posted by RateX View Post
If your bullet ent is moving too fast then yes, the ent can past through certain part of player before touch is call, especially if ent's solid is SOLID_TRIGGER(sometimes it can past through completely without touch called with this solid type).
Well, actually is SOLID_BBOX, but yes, it's shot @2k (vel_by_aim)

The only thing that comes to my mind is using traceline in entity think, but will be a pain in the as$ D:
Any other suggestion?
__________________
Hey ^_^
NikKOo31 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 04:53.


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