Raised This Month: $ Target: $400
 0% 

Knife attack area


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 10-19-2013 , 13:09   Knife attack area
Reply With Quote #1

I'm trying to help Randomize here:
https://forums.alliedmods.net/showthread.php?t=226145

How do I properly determine that the person I am attacking with knife is within range/angles of getting damaged?

I'm trying to delay the knife attack by creating a new one, and since the player move in between I need to determine if the attack is a hit or a miss at the later point in time.

I've searched for patterns in angles, distances and viewcones and the outcome was nothing.
My next idea was to create a sphere in front of the attacker to search within, which would be fine I guess. But is it correct?

What I'm asking for is really how do the game engine determine if a knife attack is a hit or a miss?
__________________
Black Rose is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 10-19-2013 , 18:07   Re: Knife attack area
Reply With Quote #2

I don't know the exact answer, but maybe the following links can help you:

https://forums.alliedmods.net/showthread.php?p=825597
https://forums.alliedmods.net/showthread.php?t=212555
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 10-19-2013 , 20:31   Re: Knife attack area
Reply With Quote #3

Found this in the first link.
PHP Code:
    TraceResult tr

    
UTIL_MakeVectors (m_pPlayer->pev->v_angle); 
    
Vector vecSrc    m_pPlayer->GetGunPosition( ); //// not m_HackedGunPosition, origin + view_ofs 
    
Vector vecEnd    vecSrc gpGlobals->v_forward 32//// 32 for stabs, 48 for slashes; basically that constant is the distance of the trace 

    
UTIL_TraceLinevecSrcvecEnddont_ignore_monstersENTm_pPlayer->pev ), &tr ); 

    if ( 
tr.flFraction >= 1.0 
    { 
        
UTIL_TraceHullvecSrcvecEnddont_ignore_monstershead_hullENTm_pPlayer->pev ), &tr ); 
        if ( 
tr.flFraction 1.0 
        { 
            
// Calculate the point of intersection of the line (or hull) and the object we hit 
            // This is and approximation of the "best" intersection 
            
CBaseEntity *pHit CBaseEntity::Instancetr.pHit ); 
            if ( !
pHit || pHit->IsBSPModel() ) //// if we hit something which is not an entity (= we hit worldspawn ) the engine looks for the exact hit place 
                
FindHullIntersectionvecSrctrVEC_DUCK_HULL_MINVEC_DUCK_HULL_MAXm_pPlayer->edict() ); 
            
vecEnd tr.vecEndPos;    // This is the point on the actual surface (the hull could have hit space) 
        

    } 
I believe it is what I am searching for. Thank you very much.
__________________

Last edited by Black Rose; 10-19-2013 at 20:32.
Black Rose is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 10-19-2013 , 21:27   Re: Knife attack area
Reply With Quote #4

I'm glad that it helped you.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Upplands Väsby, Sweden
Old 10-20-2013 , 02:22   Re: Knife attack area
Reply With Quote #5

It sure did. Works flawlessly.

For anyone interested, here's the outcome:
https://forums.alliedmods.net/showth...28#post2051028
__________________
Black Rose is offline
Reply


Thread Tools
Display Modes

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 23:31.


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