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

[Stock] Grenade Way


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarkGL
Senior Member
Join Date: Aug 2010
Location: Warsaw, Poland
Old 01-18-2012 , 07:14   [Stock] Grenade Way
Reply With Quote #1

Function show player how thrown grenade will go
PHP Code:
new laser;

public 
plugin_precache(){
        
laser   =       precache_model("sprites/laserbeam.spr")
}

stock showGrenadeWay id weapon ){
    new 
Float:fGrenadeGrav 1.0;

    switch( 
weapon) {
    case 
CSW_HEGRENADE:
        
fGrenadeGrav    =                 0.55;
    case 
CSW_FLASHBANG:
        
fGrenadeGrav    =                 0.5;
    case 
CSW_SMOKEGRENADE:
        
fGrenadeGrav    =                 0.5;
    }
    static 
pGrav;
    
    if( !
pGrav )    pGrav   =          get_cvar_pointer"sv_gravity" );
    
    new 
Float:fStartPos] , FloatfViewOfs] , FloatfVector] , FloatfVeloc ] , FloatfAngles ] , FloatfEndPos ] , FloatfTmpVector ] , pTr FloatfFraction FloatfNormal ] , iCollision FloatfVel;
    new 
Float:fGrav =                 get_pcvar_floatpGrav ) , pHit 0;

    const            
maxCollsion                =            30;
    const 
Float:    fConstAliveTime            =            2.0;
    const 
Float:    fConstLoops                =            20.0;
    new 
Float:        fAliveTime                =            0.0;
    new 
Float:        fStep                    =            fConstAliveTime fConstLoops;

    
pevid pev_origin fStartPos );
    
pevid pev_view_ofs fViewOfs );
    
pevid pev_velocity fVeloc );
    
pevid pev_v_angle fAngles );

    
xs_vec_addfStartPos fViewOfs fStartPos );

    if (
fAngles[0] < 0)
        
fAngles[0] = -10.0 fAngles[0] * ((90.0 10.0) / 90.0);
    else
        
fAngles[0] = -10.0 fAngles[0] * ((90.0 10.0) / 90.0);

    
fVel = (90.0 fAngles[0]) * 6.0;
    if (
fVel 750.0)
        
fVel 750.0;

    
pevid pev_v_angle fAngles );

    
angle_vectorfAngles ANGLEVECTOR_FORWARD fVector );

    
xs_vec_mul_scalarfVector 16.0 fTmpVector );

    
xs_vec_addfStartPos fTmpVector fStartPos );

    
xs_vec_mul_scalarfVector fVel fVector );

    
xs_vec_addfVector fVeloc fVector );


    for( ; 
fAliveTime fConstAliveTime fAliveTime += fStep ){

        
xs_vec_copyfStartPos fEndPos);
        
xs_vec_mul_scalarfVector fStep fTmpVector );
        
xs_vec_addfEndPos fTmpVector fEndPos );

        
pTr       =              create_tr2();

        
engfunc(EngFunc_TraceLinefStartPosfEndPosDONT_IGNORE_MONSTERSidpTr )
        
        if( 
fAliveTime == 0.0 ){
            
fStartPos ] += 10.0;
        }

        
get_tr2pTr TR_flFraction fFraction);

        
pHit    =                 get_tr2pTr TR_pHit );

        if( 
pHit != id && fFraction 1.0 ){
            
get_tr2pTr TR_vecEndPos fEndPos );
            
            
get_tr2pTr TR_vecPlaneNormal fNormal )
            
            if( 
fNormal ] > 0.9 && fVector ] <= 0.0 && fVector ] >= -fGrav 0.20 ){
                return ;
            }

            new 
FloatfScalar xs_vec_dotfVectorfNormal ) * 1.3;

            
fVector[0] = fVector[0] - fScalar fNormal[0];
            
fVector[1] = fVector[1] - fScalar fNormal[1];
            
fVector[2] = fVector[2] - fScalar fNormal[2];

            
iCollision++;

            if(  
iCollision maxCollsion )
            break;

            
fAliveTime              -=        fStep   *             ( 1.0 fFraction ) ;
        }
        
        new 
iR iG iB;

        switch( 
weapon ) {
        case 
CSW_HEGRENADE:{
                
iR 250;
                
iG 0;
                
iB 0;
            }
        case 
CSW_FLASHBANG:{
                
iR 0;
                
iG 0;
                
iB 250;
            }
        case 
CSW_SMOKEGRENADE:{
                
iR 0;
                
iG 250;
                
iB 0;
            }
        }
        
        
message_beginMSG_ONE_UNRELIABLE SVC_TEMPENTITY , { } , id )
        
write_byte(0)                     // TE_BEAMPOINTS
        
engfuncEngFunc_WriteCoord fStartPos ] )
        
engfuncEngFunc_WriteCoord fStartPos ] )
        
engfuncEngFunc_WriteCoord fStartPos ] )
        
engfuncEngFunc_WriteCoord fEndPos ] )
        
engfuncEngFunc_WriteCoord fEndPos ] )
        
engfuncEngFunc_WriteCoord fEndPos ] )
        
write_short(laser)
        
write_byte(1)
        
write_byte(1)
        
write_byte(1)
        
write_byte(15)
        
write_byte(0)
                
write_byteiR )
                
write_byteiG )
                
write_byteiB )
        
write_byte(210)
        
write_byte(0)
        
message_end()

        
xs_vec_copyfEndPos fStartPos );
        
        
fVector]    -=              floatmulfloatmulfGrenadeGrav fGrav ) , floatmulfFraction fStep ) );

        
free_tr2pTr );
    }

Result:
Click image for larger version

Name:	post-6262-0-80371700-1326807336.jpg
Views:	463
Size:	91.5 KB
ID:	98323
Click image for larger version

Name:	post-6262-0-39358000-1326807901.jpg
Views:	457
Size:	89.7 KB
ID:	98324
http://www.youtube.com/watch?v=RzXca9lTRBA

Library
PHP Code:
#include <xs>
#include <fakemeta> 
  • First parametr is player id
  • Second is weapon CSW_HEGRENADE , CSW_FLASHBANG or CSW_SMOKEGRENADE

Example:
Showing way when player have grenade in hands
PHP Code:
public client_PreThinkid ){
        if( 
is_user_aliveid ) ){
                new 
iWeapon     =       get_user_weaponid );
                
                if( 
iWeapon == CSW_HEGRENADE || iWeapon == CSW_SMOKEGRENADE || iWeapon == CSW_FLASHBANG ){
                        
showGrenadeWayid iWeapon );
                }
        }

__________________

Last edited by DarkGL; 01-18-2012 at 08:03.
DarkGL is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 01-18-2012 , 17:13   Re: [Stock] Grenade Way
Reply With Quote #2

Great.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-19-2012 , 03:10   Re: [Stock] Grenade Way
Reply With Quote #3

This is so awesome.
__________________
hleV is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 01-19-2012 , 11:09   Re: [Stock] Grenade Way
Reply With Quote #4

Why not using TE_BEAMFOLLOW after grenade spawn and avoid to hook client_PreThink?
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
DarkGL
Senior Member
Join Date: Aug 2010
Location: Warsaw, Poland
Old 01-19-2012 , 11:31   Re: [Stock] Grenade Way
Reply With Quote #5

joropito it show grenade way before you throw him
your method would show way after throw and only traveled path
__________________

Last edited by DarkGL; 01-19-2012 at 11:32.
DarkGL is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 01-19-2012 , 12:31   Re: [Stock] Grenade Way
Reply With Quote #6

This is fantastic!
Lolz0r is offline
kiki33hun
Veteran Member
Join Date: Jul 2011
Location: Magyarország
Old 01-30-2012 , 10:34   Re: [Stock] Grenade Way
Reply With Quote #7

Nice, thanx
__________________
kiki33hun is offline
liinuus
Senior Member
Join Date: Apr 2010
Old 01-30-2012 , 11:25   Re: [Stock] Grenade Way
Reply With Quote #8

awesome
liinuus is offline
FR0NTLINE
AlliedModders Donor
Join Date: Apr 2006
Location: Riverside Cali
Old 01-30-2012 , 13:02   Re: [Stock] Grenade Way
Reply With Quote #9

Awesome way to show team flashers whats up! Good fuckin job
__________________
FR0NTLINE is offline
Send a message via AIM to FR0NTLINE Send a message via MSN to FR0NTLINE Send a message via Yahoo to FR0NTLINE
Immortal_BLG
Member
Join Date: Feb 2010
Location: RUSSIA
Old 01-30-2012 , 21:15   Re: [Stock] Grenade Way
Reply With Quote #10

Another method how find grenade explosion origin, even if the grenade is on conveyor, etc: http://forums.bots-united.com/showthread.php?t=7641

Last edited by Immortal_BLG; 01-30-2012 at 21:30.
Immortal_BLG 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 04:15.


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