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

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


Post New Thread Reply   
 
Thread Tools Display Modes
Owyn
Veteran Member
Join Date: Nov 2007
Old 07-01-2009 , 13:31   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #11

indeed here we check attack first then do traceline, there the reversed way, but it is still not a good way to count hits
__________________
☜ 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 , 13:52   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #12

Why?

(And it's not the reverse. In that one it is being checked every traceline where the IN_ATTACK is pressed. In the one i've posted a traceline is made when an attack occurs)
__________________
joaquimandrade is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 07-01-2009 , 14:13   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #13

gonna try something later i guess to support knives and guns
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-01-2009 , 14:39   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #14

@joaquimandrade: What I don't understand is why in TraceAttack() there is a check to see if it's hitting the shield and when you shot on it TraceAttack is not called at all. Oo
__________________
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-01-2009 , 15:34   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #15

Quote:
Originally Posted by arkshine View Post
@joaquimandrade: What I don't understand is why in TraceAttack() there is a check to see if it's hitting the shield and when you shot on it TraceAttack is not called at all. Oo
Where?
__________________
joaquimandrade is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 07-01-2009 , 15:43   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #16

probably in your super shield plugin, but there i think cuz shield is not worn
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
stupok
Veteran Member
Join Date: Feb 2006
Old 07-01-2009 , 15:49   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #17

@joaquimandrade:

arkshine is pointing out an oddity in the code you posted in this thread.

I'll try to explain...

You're hooking TraceAttack, so it should be called when a player attacks with a weapon that makes tracelines. However, you said this:

Quote:
when you hit a shield a traceattack doesn't occur and the shield doesn't even exist as an entity
I think arkshine did not notice that you're creating an additional traceline, so he was confused, thinking that the function would never be called.

For me, two things are very odd:

1. Why does your additional traceline detect the shield?
2. Why isn't a traceattack triggered when the client shoots a shield?

It's just strange o_O
__________________
stupok is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-01-2009 , 16:12   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #18

Stupok, I was talking in the CS code, by disassembling, IsHittingShield() is called from TraceAttack() at the top of function.

CBasePlayer::IsHittingShield(Vector const &,TraceResult *)

It's possible that this function return false by default et thus not used here.
__________________
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 07-01-2009 , 16:40   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #19

Stupok, i'm not hooking traceAttack i'm hooking Weapon_PrimaryAttack.

About arkshine question, i don't know. I guess that when "IsHittingShield" returns true the TraceAttack is blocked and thus not forwarded but i really don't know.

(And as a note, in Super Shield plugin is different because the shields that it handle are real entities so it is more easy than this)
__________________

Last edited by joaquimandrade; 07-01-2009 at 16:49.
joaquimandrade is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-01-2009 , 17:03   Re: Detecting when shield is hit (not just aiming at it)
Reply With Quote #20

Actually IsHittingShield() would looks like like in css ( code not from me, somewhere on internet ) :

Code:
  bool CCSPlayer::IsHittingShield( const Vector &vecDirection, trace_t *ptr ) {     /*     if ( HasShield() == false )         return false;     if ( ptr->hitgroup == HITGROUP_SHIELD )         return true;           if ( m_bShieldDrawn == false )         return false;     Vector2D    vec2LOS;     float       flDot;     Vector vForward;     AngleVectors( GetAbsAngles(), &vForward );     vec2LOS = vecDirection.Make2D();     vec2LOS = vec2LOS.Normalize();     flDot = DotProduct ( vec2LOS , vForward.Make2D() );         if ( flDot < -0.87f )         return true;     */         return false; }

Code:
void CCSPlayer::TraceAttack( const CTakeDamageInfo &info, const Vector &vecDir, trace_t *ptr ) {         bool bShouldBleed = true;         bool bShouldSpark = false;         bool bHitShield = IsHittingShield( vecDir, ptr );         CBasePlayer *pAttacker = (CBasePlayer*)ToBasePlayer( info.GetAttacker() );         if ( ( GetTeamNumber() == pAttacker->GetTeamNumber() ) )                 bShouldBleed = false;                 if ( m_takedamage != DAMAGE_YES )                 return;         m_LastHitGroup = ptr->hitgroup;         float flDamage = info.GetDamage();         if ( bHitShield )         {             /*             flDamage = 0;             bShouldBleed = false;             if ( RANDOM_LONG( 0, 1 ) )                 EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-1.wav", 1, ATTN_NORM );             else                 EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/ric_metal-2.wav", 1, ATTN_NORM );                             UTIL_Sparks( ptr->vecEndPos );             pev->punchangle.x = flDamage * RANDOM_FLOAT ( -0.15, 0.15 );             pev->punchangle.z = flDamage * RANDOM_FLOAT ( -0.15, 0.15 );             if (pev->punchangle.x < 4)                 pev->punchangle.x = -4;               if (pev->punchangle.z < -5)                 pev->punchangle.z = -5;             else if (pev->punchangle.z > 5)                 pev->punchangle.z = 5;             */         }         else         {             switch ( ptr->hitgroup )             {                         }         }                     [...]    }

When you see in the CS disassembled the code seems to be the same. That's why I don't understand why TraceAttack is not called.
__________________
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 05:51.


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