Raised This Month: $ Target: $400
 0% 

Traceline with multiple hits


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elusive138
Senior Member
Join Date: Dec 2010
Old 01-25-2011 , 12:09   Traceline with multiple hits
Reply With Quote #1

I've been using Nomexous' Traceline tutorial and this line
Code:
new hit = get_tr2(trace, TR_pHit)
returns the player (or entity, etc) hit by the traceline. However, most guns (in CS) can shoot THROUGH entities, including hitting multiple targets. How would that work with the traceline? Is a seperate traceline generated for each target, or is there some other method for retrieving all players that can be hit?


Thanks
Elusive138 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-25-2011 , 13:09   Re: Traceline with multiple hits
Reply With Quote #2

In CS :

Each weapon has a penetration power. Value which represents how many penetration in something/one it can do. ( ie: ak47: 2, awp: 3, etc )
Each bullet has a penetration power. Value which represents the max thickness of something/one a bullet can penetrate.
Each bullet type has a penetration distance. Value which represents the max distance a bullet can penetrate a wall.
Each material has an absorptive capacity which alters the penetration power of a bullet.

When you fire a bullet, it throws a Traceline. If you hit something, it will loop again from the end position of the previous trace until the number of allowed penetration. Of course, it doesn't happen always because of some params like : you hit a shield , the bullet has travelled over the max distance, or the bullet has lost in penetration power.
__________________

Last edited by Arkshine; 01-25-2011 at 17:05.
Arkshine is offline
Elusive138
Senior Member
Join Date: Dec 2010
Old 01-25-2011 , 22:37   Re: Traceline with multiple hits
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
In CS :

Each weapon has a penetration power. Value which represents how many penetration in something/one it can do. ( ie: ak47: 2, awp: 3, etc )
Each bullet has a penetration power. Value which represents the max thickness of something/one a bullet can penetrate.
Each bullet type has a penetration distance. Value which represents the max distance a bullet can penetrate a wall.
Each material has an absorptive capacity which alters the penetration power of a bullet.

When you fire a bullet, it throws a Traceline. If you hit something, it will loop again from the end position of the previous trace until the number of allowed penetration. Of course, it doesn't happen always because of some params like : you hit a shield , the bullet has travelled over the max distance, or the bullet has lost in penetration power.
Ah, thanks. Is there any way/place I can get the penetration power?
Elusive138 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-26-2011 , 06:46   Re: Traceline with multiple hits
Reply With Quote #4

Yes, here
I've done a nice table for you.

Code:
BPP = Bullet Penetration Power
BPD = Bullet Penetration Distance
WP  = Weapon Penetration

                 ┌──────┬──────┬──────────────────────────────────────────────────────────────┐
                 │ BPP  │ BPD  │                              WP                              │
┌────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_9mm       │  21  │  800 │ 1 [weapon_elite, weapon_glock18, weapon_mp5navy, weapon_tmp] │
├────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_45acp     │  15  │  500 │ 1 [weapon_mac10, weapon_ump45, weapon_usp]                   │
├────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_50ae      │  30  │ 1000 │ 2 [weapon_deagle]                                            │
├────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_762nato   │  39  │ 5000 │ 3 [weapon_scout, weapon_g3sg1 ]                              │
│                │      │      │ 2 [weapon_ak47]                                              │
├────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_556nato   │  35  │ 4000 │ 2 [weapon_aug, weapon_sg550, weapon_galil, weapon_famas]     │
│                │      │      │ 2 [weapon_m249, weapon_m4a1, weapon_sg552]                   │
├────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_338magnum │  45  │ 8000 │ 3 [weapon_awp]                                               │
├────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_57mm      │  30  │ 2000 │ 1 [weapon_fiveseven, weapon_p90]                             │
├────────────────┼──────┼──────┼──────────────────────────────────────────────────────────────┤
│ ammo_357sig    │  25  │  800 │ 1 [weapon_p228]                                              │
└────────────────┴──────┴──────┴──────────────────────────────────────────────────────────────┘

[EDIT] Others datas considering the material type, which will reduce the bullet penetration power and the damage.

Code:
PM = Penatration Modifier
DM = Damage Modifier

                    ┌──────┬──────┐
                    │ PM   │ DM   │                     
┌───────────────────┼──────┼──────┤
│ CHAR_TEX_METAL    │ 0.15 │ 0.2  │
├───────────────────┼──────┼──────┤
│ CHAR_TEX_CONCRETE │ 0.25 │ 0.25 │
├───────────────────┼──────┼──────┤
│ CHAR_TEX_GRATE    │ 0.5  │ 0.4  │ 
├───────────────────┼──────┼──────┤
│ CHAR_TEX_VENT     │ 0.5  │ 0.45 │              
├───────────────────┼──────┼──────┤
│ CHAR_TEX_TILE     │ 0.65 │ 0.3  │
├───────────────────┼──────┼──────┤
│ CHAR_TEX_COMPUTER │ 0.4  │ 0.45 │ 
├───────────────────┼──────┼──────┤
│ CHAR_TEX_WOOD     │ 1.0  │ 0.6  │
└───────────────────┴──────┴──────┘
__________________

Last edited by Arkshine; 01-26-2011 at 10:18.
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 01-26-2011 , 10:34   Re: Traceline with multiple hits
Reply With Quote #5

Hope this works.

This will trace lines thought entities, but it stops when it hits a wall.

PHP Code:
new Float:vecStart[3// This should be the original start position
new Float:vecEnd[3// And this should be the end position

new iTraceHit // hitted entity
new iEntToIgnore MyFirstEntityToIgnore // this would change at every trace
new iTraceHandle create_tr2()// trace handle

while(engfunc(EngFunc_TraceLinevecStartvecEndDONT_IGNORE_MONSTERSiEntToIgnoreiTraceHandle)) // will always return 1, see engfunc.cpp
{
    
iTraceHit get_tr2(iTraceHandleTR_pHit// getting hitted entity
    
    
if(get_global_float(GL_trace_fraction) >= 1.0// the traceline finished at the original end position, so we will stop here
        
break;
    
    if(!
is_user_alive(iTraceHit)) // if you want to stop the traceline when it hits a wall, use this
        
break;
        
    
// your functions here
    
    // the next traceline will start at the end of the last one
    
iEntToIgnore iTraceHit
    get_tr2
(iTraceHandleTR_vecEndPosvecStart)
}

get_tr2(iTraceHandleTR_vecEndPosvecEnd// out of the loop, this will get the last position of the last traceline. you can use a beam effect or something if you want

free_tr2(iTraceHandle// freeing the tracehandle 
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross

Last edited by meTaLiCroSS; 01-26-2011 at 12:42.
meTaLiCroSS is offline
Elusive138
Senior Member
Join Date: Dec 2010
Old 01-26-2011 , 10:40   Re: Traceline with multiple hits
Reply With Quote #6

Thank you both so much for this info!
Elusive138 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-26-2011 , 14:52   Re: Traceline with multiple hits
Reply With Quote #7

If interested, here how works CS when you shot a bullet.

PHP Code:
Vector CBaseEntity::FireBullets3Vector vecSrcVector vecDirShootingVector vecSpread,
                                  
float flDistanceint iPenetrationint iBulletTypeint iDamagefloat flRangeModifier,
                                  
entvars_t *pevAttacker_int shared_rand )
{
    
int iCurrentDamage iDamage;

    
Vector vecRight gpGlobals->v_right;
    
Vector vecUp    gpGlobals->v_up;

    
TraceResult tr;
    
int iPenetrationPower;
    
float flPenetrationDistance;
    
float flCurrentDistance;
    
float xyz;

    switch( 
iBulletType )
    {
        case 
BULLET_PLAYER_9MM :
        {
            
iPenetrationPower     21;
            
flPenetrationDistance 800.0;
            break;
        }
        case 
BULLET_PLAYER_45ACP :
        {
            
iPenetrationPower     15;
            
flPenetrationDistance 500.0;
            break;
        }
        case 
BULLET_PLAYER_50AE :
        {
            
iPenetrationPower     30;
            
flPenetrationDistance 1000.0;
            break;
        }
        case 
BULLET_PLAYER_762MM :
        {
            
iPenetrationPower     39;
            
flPenetrationDistance 5000.0;
            break;
        }
        case 
BULLET_PLAYER_556MM :
        {
            
iPenetrationPower     35;
            
flPenetrationDistance 4000.0;
            break;
        }
        case 
BULLET_PLAYER_338MAG :
        {
            
iPenetrationPower     45;
            
flPenetrationDistance 8000.0;
            break;
        }
        case 
BULLET_PLAYER_57MM :
        {
            
iPenetrationPower     30;
            
flPenetrationDistance 2000.0;
            break;
        }
        case 
BULLET_PLAYER_357SIG :
        {
            
iPenetrationPower     25;
            
flPenetrationDistance 800.0;
            break;
        }
        default :
        {
            
iPenetrationPower     0;
            
flPenetrationDistance 0.0;
            break;
        }
    }

    if( 
pevAttacker == NULL )
        
pevAttacker pev;

    
gMultiDamage.type = ( DMG_BULLET DMG_NEVERGIB );

    if( 
IsPlayer() )
    {
        
UTIL_SharedRandomFloatshared_rand    , -0.50.5 ) + UTIL_SharedRandomFloatshared_rand 1, -0.50.5 );
        
UTIL_SharedRandomFloatshared_rand 2, -0.50.5 ) + UTIL_SharedRandomFloatshared_rand 3, -0.50.5 );
    }
    else
    {
        do
        {
            
RANDOM_FLOAT( -0.50.5 ) + RANDOM_FLOAT( -0.50.5 );
            
RANDOM_FLOAT( -0.50.5 ) + RANDOM_FLOAT( -0.50.5 );
        }
        while( 
);
    }

    [...]
    
    
Vector vecDir vecDirShooting vecSpread.vecRight vecSpread.vecUp;
    
Vector vecEnd vecSrc vecDir flDistance;

    while( 
iPenetration )
    {
        
ClearMultiDamage();
        
UTIL_TraceLinevecSrcvecEnddont_ignore_monstersENTpev ), &tr );

        if( 
tr.fraction != 1.0 )
        {
            
TheBots->OnEventEVENT_PLAYER_SHOOTpevtr.vecEndPos );
        }

        
BOOL bSparks;
        
BOOL bHitMetal;

        switch( 
UTIL_TextureHittrvecSrcvecEnd ) )
        {
            case 
CHAR_TEX_METAL :
            {
                
bSparks bHitMetal TRUE;

                
iPenetrationPower = (int)( iPenetrationPower 0.15 );
                
flDamageModifier  0.2;
                break;
            }
            case 
CHAR_TEX_CONCRETE :
            {
                
iPenetrationPower = (int)( iPenetrationPower 0.25 );
                
flDamageModifier  0.25;
                break;
            }
            case 
CHAR_TEX_GRATE :
            {
                
bSparks bHitMetal TRUE;

                
iPenetrationPower = (int)( iPenetrationPower 0.5 );
                
flDamageModifier  0.4;
                break;
            }
            case 
CHAR_TEX_VENT :
            {
                
bSparks bHitMetal TRUE;

                
iPenetrationPower = (int)( iPenetrationPower 0.5 );
                
flDamageModifier  0.45;
                break;
            }
            case 
CHAR_TEX_TILE :
            {
                
iPenetrationPower = (int)( iPenetrationPower 0.65 );
                
flDamageModifier  0.3;
                break;
            }
            case 
CHAR_TEX_COMPUTER :
            {
                
bSparks bHitMetal TRUE;;

                
iPenetrationPower = (int)( iPenetrationPower 0.4 );
                
flDamageModifier  0.45;
                break;
            }
            case 
CHAR_TEX_WOOD :
            {
                
iPenetrationPower = (int)( iPenetrationPower 1.0 );
                
flDamageModifier  0.6;
                break;
            }
        }

        if( 
tr.fraction != 1.0 )
        {
            --
iPenetration;

            
flCurrentDistance tr.fraction flDistance;
            
iCurrentDamage *= powflCurrentDistance 0.002flRangeModifier );

            if( 
flCurrentDistance flPenetrationDistance )
                
iPenetration 0;

            
CBaseEntity *pEntity CBaseEntity::Instancetr.pHit );

            if( 
tr.iHitgroup == HITGROUP_SHIELD )
            {
                if( 
RANDOM_LONG0) )
                    
EMIT_SOUNDENTpEntity->pev ), CHAN_VOICE"weapons/ric_metal-1.wav"1ATTN_NORM );
                else
                    
EMIT_SOUNDENTpEntity->pev ), CHAN_VOICE"weapons/ric_metal-2.wav"1ATTN_NORM );

                
UTIL_Sparkstr.vecEndPos );

                 
pEntity->pev->punchangle.iCurrentDamage RANDOM_FLOAT ( -0.150.15 );
                 
pEntity->pev->punchangle.iCurrentDamage RANDOM_FLOAT ( -0.150.15 );

                if( 
pEntity->pev->punchangle.)
                    
pEntity->pev->punchangle.= -4;

                if( 
pEntity->pev->punchangle.< -)
                    
pEntity->pev->punchangle.= -5;
                else if( 
pEntity->pev->punchangle.)
                    
pEntity->pev->punchangle.5;
                
                break;
            }

            
/* if( unknownParam || RANDOM_NUM( 0, 3 ) )
            {
                bSomeVar = TRUE;
            } */

            
int iDamageType DMG_BULLET DMG_NEVERGIB;
            
// DecalGunshot( &tr, iBulletType, bSomeVar?, pev, bSparks? );
            
            
if( pEntity->pev->solid == SOLID_BSP && iPenetration  )
            {
                
vecSrc tr.vecEndpos + ( vecDir iPenetrationPower );
                
flDistance = ( flDistance flCurrentDistance ) * 0.5;
                
vecEnd = ( vecDir flDistance ) + vecSrc;

                
pEntity->TraceAttackpevAttackeriCurrentDamagevecDir, &triDamageType );

                
iCurrentDamage *= flDamageModifier;
            }
            else
            {
                
vecSrc tr.vecEndpos + ( vecDir 42.0 );
                
flDistance = ( flDistance flCurrentDistance ) * 0.75;
                
vecEnd = ( vecDir flDistance ) + vecSrc;
                    
                
pEntity->TraceAttackpevAttackeriCurrentDamagevecDir, &triDamageType );

                
iCurrentDamage *= 0.75;
            }
        }
        else
        {
            
iPenetration 0;
        }

        
ApplyMultiDamage();
    }

    return 
VectorvecSpreadvecSpread);

__________________

Last edited by Arkshine; 01-26-2011 at 17:43.
Arkshine is offline
darktemplar
Member
Join Date: Sep 2009
Old 02-15-2013 , 02:38   Re: Traceline with multiple hits
Reply With Quote #8

My question is : Can we change the penetration power ?
darktemplar is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-15-2013 , 03:01   Re: Traceline with multiple hits
Reply With Quote #9

You can with some memory patching.
__________________
Arkshine is offline
darktemplar
Member
Join Date: Sep 2009
Old 02-15-2013 , 03:07   Re: Traceline with multiple hits
Reply With Quote #10

Can you help me ? . I'm using rage. I know how to hook FireBullets3 , but if I hook it , I can only change the base damage and range modifier , not Penetration
darktemplar 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:18.


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