Raised This Month: $ Target: $400
 0% 

Grenade trajectory prediction


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
matsi
Thinkosaur
Join Date: Sep 2006
Old 03-15-2011 , 11:07   Grenade trajectory prediction
Reply With Quote #1

Is it possible to draw line ( for example ) where grenade will hit and possibly bounce off?
[img]http://img854.**************/img854/5683/nuketti.png[/img]

If possible... How ? o_O

Last edited by matsi; 03-15-2011 at 11:43.
matsi is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 03-15-2011 , 11:13   Re: Grenade throw prediction
Reply With Quote #2

check this thread: http://forums.alliedmods.net/showthread.php?t=119432
__________________
Impossible is Nothing
Sylwester is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 03-15-2011 , 11:46   Re: Grenade throw prediction
Reply With Quote #3

Quote:
Originally Posted by Sylwester View Post
Thanks for the link. Like 4JOKE said on post #11 i need to know trajectory before i throw the grenade.

I guess its too advanced for me like he also said.


e: I don't know if Immortal_BLG 's post #13 will help someone but i don't really get anything out of it.

Last edited by matsi; 03-15-2011 at 11:48.
matsi is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 03-31-2011 , 10:03   Re: Grenade trajectory prediction
Reply With Quote #4

bump
matsi is offline
Old 03-31-2011, 10:31
droper
This message has been deleted by droper.
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-31-2011 , 10:48   Re: Grenade trajectory prediction
Reply With Quote #5

TraceToss
lazarev is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 03-31-2011 , 11:14   Re: Grenade trajectory prediction
Reply With Quote #6

Quote:
Originally Posted by lazarev View Post
TraceToss
If i understood correctly TraceToss gets start & end origins and i need to know them before i throw the grenade.

matsi is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-31-2011 , 13:01   Re: Grenade trajectory prediction
Reply With Quote #7

Quote:
Originally Posted by matsi View Post
If i understood correctly TraceToss gets start & end origins and i need to know them before i throw the grenade.

http://www.gamedeception.net/threads...renade-Tracing
hope this helps.
lazarev is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 03-31-2011 , 13:16   Re: Grenade trajectory prediction
Reply With Quote #8

Quote:
Originally Posted by lazarev View Post
I hope it helps too. I will try to make something out of it.


Thank you very much.

edit: Anyone is welcome to 'convert' it ^^ I try to convert as much as i know how.

Last edited by matsi; 03-31-2011 at 13:25.
matsi is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 03-31-2011 , 15:27   Re: Grenade trajectory prediction
Reply With Quote #9

PHP Code:
/*    Copyright © 2011, Gabe Newell

    Grenade Tracing is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Grenade Tracing; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
    
    This plugin was made by request.
    Credits: Revolution. http://www.gamedeception.net/threads/12759-Grenade-Tracing
*/

#include < amxmodx >
#include < fakemeta >
#include < xs >

#define NUMBLOOPS 20.0
#define TIMEALIVE 2.0
#define OLDDAMPER 1.75
#define NEWDAMPER 0.75
#define SVGRAVITY 3.75
#define FLOORSTOP 0.20

new spr_beam;

public 
plugin_init( )
{
    
register_plugin"Grenade Tracing""0.0.2""Juice" );
    
register_concmd"trace_grenade""TraceGrenade" );
}

public 
plugin_precache()
{
    
spr_beam precache_model"sprites/laserbeam.spr" );
}

public 
TraceGrenadeid )
{
    
//new Float:dest[3];
    
new pmtrace 0;

    new 
Float:gravity get_cvar_float("sv_gravity") / SVGRAVITY;

    new 
Float:angThrow], Float:throwvector], Float:startpos], Float:endpos], Float:punchangle];
    new 
Float:origin], Float:view_ofs];
    new 
Float:pmEyePos], Float:pmVelocity];
    
    
pevidpev_velocitypmVelocity );
    
    
pevidpev_punchanglepunchangle );
    
pevidpev_v_angleangThrow );
    
    
pevid ,pev_originorigin );
    
pevidpev_view_ofsview_ofs );
    
    
xs_vec_addangThrowpunchangleangThrow );
    
xs_vec_addoriginview_ofspmEyePos );

    if (
angThrow[0] < 0)
        
angThrow[0] = -10 angThrow[0] * ((90 10) / 90.0);
    else
        
angThrow[0] = -10 angThrow[0] * ((90 10) / 90.0);

    new 
Float:flVel = (90 angThrow[0]) * 6;
    if (
flVel 500)
        
flVel 500.0;
        
    
angle_vectorangThrowANGLEVECTOR_FORWARDthrowvector );

    
startpos[0] = pmEyePos[0] + throwvector[0] * 16;
    
startpos[1] = pmEyePos[1] + throwvector[1] * 16;
    
startpos[2] = pmEyePos[2] + throwvector[2] * 16;

    
throwvector[0] = throwvector[0] * flVel pmVelocity[0];
    
throwvector[1] = throwvector[1] * flVel pmVelocity[1];
    
throwvector[2] = throwvector[2] * flVel pmVelocity[2];

    new 
collisions 0;
    new 
Float:timelive;
    new 
Float:step = (TIMEALIVE NUMBLOOPS);
    
    new 
ent;
    new 
Float:plane_normal[3];
    new 
Float:fraction;
    
    for ( 
timelive 0.0timelive TIMEALIVEtimelive += step )
    {
        
endpos[0] = startpos[0] + throwvector[0] * step;
        
endpos[1] = startpos[1] + throwvector[1] * step;
        
endpos[2] = startpos[2] + throwvector[2] * step//move
        
        
engfuncEngFunc_TraceLinestartposendposDONT_IGNORE_MONSTERS0pmtrace );
        
ent get_tr2pmtraceTR_pHit )

        
get_tr2pmtraceTR_vecPlaneNormalplane_normal );
        
get_tr2pmtraceTR_flFractionfraction );
        
        if( 
ent != id && fraction 1.0 )
        {
            
endpos[0] = startpos[0] + throwvector[0] * fraction step;
            
endpos[1] = startpos[1] + throwvector[1] * fraction step;
            
endpos[2] = startpos[2] + throwvector[2] * fraction step;
            
/*
            if ( plane_normal[2] > 0.9 && throwvector[2] <= 0 && throwvector[2] >= -gravity*FLOORSTOP )
            {
                dest[0] = endpos[0];
                dest[1] = endpos[1];
                dest[2] = endpos[2];
            }
            */
            
message_beginMSG_ONE_UNRELIABLESVC_TEMPENTITY_id );
            
write_byteTE_SPARKS );
            
engfuncEngFunc_WriteCoordendpos[0] );
            
engfuncEngFunc_WriteCoordendpos[1] );
            
engfuncEngFunc_WriteCoordendpos[2] );
            
message_end();
            
            new 
Float:proj xs_vec_dotthrowvectorplane_normal ); 
            
            
throwvector[0] = (throwvector[0]*OLDDAMPER proj*2*plane_normal[0]) * NEWDAMPER//reflection off the wall
            
throwvector[1] = (throwvector[1]*OLDDAMPER proj*2*plane_normal[1]) * NEWDAMPER;
            
throwvector[2] = (throwvector[2]*OLDDAMPER proj*2*plane_normal[2]) * NEWDAMPER

            
collisions++;
            if (
collisions 30) break;

            
timelive -= (step * (fraction));
        }
        
        
BeamPointsidstartposendpos );
        
        
startpos[0] = endpos[0];
        
startpos[1] = endpos[1];
        
startpos[2] = endpos[2];

        
throwvector[2] -= gravity fraction step//gravity
    
}

    
//dest[0] = startpos[0];
    //dest[1] = startpos[1];
    //dest[2] = startpos[2];
    
    
return PLUGIN_HANDLED;
}

BeamPointsidFloat:startpos[3], Float:endpos[3] )
{
    
message_beginMSG_ONE_UNRELIABLESVC_TEMPENTITY_id );
    
write_byteTE_BEAMPOINTS )            // type
    
engfuncEngFunc_WriteCoordstartpos[0] );    // origin[1]
    
engfuncEngFunc_WriteCoordstartpos[1] );    // origin[2]
    
engfuncEngFunc_WriteCoordstartpos[2] );    // origin[3]
    
engfuncEngFunc_WriteCoordendpos[0] );    // origin2[1]
    
engfuncEngFunc_WriteCoordendpos[1] );    // origin2[2]
    
engfuncEngFunc_WriteCoordendpos[2] );    // origin2[3]
    
write_shortspr_beam );            // sprite index
    
write_byte);                // start frame
    
write_byte);                // framerate
    
write_byte30 );                // life in 0.1 sec
    
write_byte20 );                // width
    
write_byte);                // noise
    
write_byte);                // red
    
write_byte255 );                // green
    
write_byte);                // blue
    
write_byte255 );                // brightness
    
write_byte);                // speed
    
message_end()


Last edited by lazarev; 04-01-2011 at 10:49.
lazarev is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 03-31-2011 , 17:20   Re: Grenade trajectory prediction
Reply With Quote #10

Quote:
Originally Posted by lazarev View Post
PHP Code:
/*    Copyright © 2011, Juice

    Grenade Tracing is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Grenade Tracing; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
    
    This plugin was made by request.
    Credits: Revolution. http://www.gamedeception.net/threads/12759-Grenade-Tracing
*/

#include < amxmodx >
#include < fakemeta >
#include < xs >

#define NUMBLOOPS 20.0
#define TIMEALIVE 2.0
#define OLDDAMPER 1.75
#define NEWDAMPER 0.75
#define SVGRAVITY 3.75
#define FLOORSTOP 0.20

new spr_beam;

public 
plugin_init( )
{
    
register_plugin"Grenade Tracing""0.0.1""Juice" );
    
register_concmd"trace_grenade""TraceGrenade" );
}

public 
plugin_precache()
{
    
spr_beam precache_model"sprites/laserbeam.spr" );
}

public 
TraceGrenadeid )
{
    new 
Float:dest[3];
    new 
pmtrace 0;

    new 
Float:gravity get_cvar_float("sv_gravity") / SVGRAVITY;

    new 
Float:throwangles], Float:throwvector], Float:startpos], Float:endpos];
    new 
Float:origin], Float:view_ofs];
    new 
Float:pmEyePos], Float:pmVelocity];
    
    
pevidpev_v_anglethrowangles );
    
pevidpev_velocitypmVelocity );
    
    
pevid ,pev_originorigin );
    
pevidpev_view_ofsview_ofs );
    
xs_vec_addoriginview_ofspmEyePos );

    if (
throwangles[0] < 0)
        
throwangles[0] = -10 throwangles[0] * ((90 10) / 90.0);
    else
        
throwangles[0] = -10 throwangles[0] * ((90 10) / 90.0);

    new 
Float:flVel = (90 throwangles[0]) * 4;
    if (
flVel 500)
        
flVel 500.0;
    
    
angle_vectorthrowanglesANGLEVECTOR_FORWARDthrowvector );

    
startpos[0] = pmEyePos[0] + throwvector[0] * 16;
    
startpos[1] = pmEyePos[1] + throwvector[1] * 16;
    
startpos[2] = pmEyePos[2] + throwvector[2] * 16;

    
throwvector[0] = (throwvector[0] * flVel) + pmVelocity[0];
    
throwvector[1] = (throwvector[1] * flVel) + pmVelocity[1];
    
throwvector[2] = (throwvector[2] * flVel) + pmVelocity[2];

    new 
collisions 0;
    new 
Float:timelive;
    new 
Float:step = (TIMEALIVE NUMBLOOPS);
    
    new 
ent;
    new 
Float:plane_normal[3];
    new 
Float:fraction;
    
    for ( 
timelive 0.0timelive TIMEALIVEtimelive += step )
    {
        
endpos[0] = startpos[0] + throwvector[0] * step;
        
endpos[1] = startpos[1] + throwvector[1] * step;
        
endpos[2] = startpos[2] + throwvector[2] * step//move
        
        
engfuncEngFunc_TraceLinestartposendposDONT_IGNORE_MONSTERS0pmtrace );
        
ent get_tr2pmtraceTR_pHit )

        
get_tr2pmtraceTR_vecPlaneNormalplane_normal );
        
get_tr2pmtraceTR_flFractionfraction );
        
        if( 
ent != id && fraction 1.0 //hits a wall
        
{
            
//hitpoint
            
endpos[0] = startpos[0] + throwvector[0] * fraction step;
            
endpos[1] = startpos[1] + throwvector[1] * fraction step;
            
endpos[2] = startpos[2] + throwvector[2] * fraction step;

            if ( 
plane_normal[2] > 0.9 && throwvector[2] <= && throwvector[2] >= -gravity*FLOORSTOP )
            {
                
dest[0] = endpos[0];
                
dest[1] = endpos[1];
                
dest[2] = endpos[2];
            }
            
            
message_beginMSG_ONE_UNRELIABLESVC_TEMPENTITY_id );
            
write_byteTE_SPARKS );
            
engfuncEngFunc_WriteCoordendpos[0] );
            
engfuncEngFunc_WriteCoordendpos[1] );
            
engfuncEngFunc_WriteCoordendpos[2] );
            
message_end();
            
            new 
Float:proj xs_vec_dotthrowvectorplane_normal ); 
            
            
throwvector[0] = (throwvector[0]*OLDDAMPER proj*2*plane_normal[0]) * NEWDAMPER//reflection off the wall
            
throwvector[1] = (throwvector[1]*OLDDAMPER proj*2*plane_normal[1]) * NEWDAMPER;
            
throwvector[2] = (throwvector[2]*OLDDAMPER proj*2*plane_normal[2]) * NEWDAMPER

            
collisions++;
            if (
collisions 30) return PLUGIN_HANDLED;

            
timelive -= (step * (fraction));
        }
        
        
BeamPointsidstartposendpos );
        
        
startpos[0] = endpos[0];
        
startpos[1] = endpos[1];
        
startpos[2] = endpos[2];

        
throwvector[2] -= gravity fraction step//gravity
    
}

    
dest[0] = startpos[0];
    
dest[1] = startpos[1];
    
dest[2] = startpos[2];
    
    return 
PLUGIN_HANDLED;
}

BeamPointsidFloat:startpos[3], Float:endpos[3] )
{
    
message_beginMSG_ONE_UNRELIABLESVC_TEMPENTITY_id );
    
write_byteTE_BEAMPOINTS )            // type
    
engfuncEngFunc_WriteCoordstartpos[0] );    // origin[1]
    
engfuncEngFunc_WriteCoordstartpos[1] );    // origin[2]
    
engfuncEngFunc_WriteCoordstartpos[2] );    // origin[3]
    
engfuncEngFunc_WriteCoordendpos[0] );    // origin2[1]
    
engfuncEngFunc_WriteCoordendpos[1] );    // origin2[2]
    
engfuncEngFunc_WriteCoordendpos[2] );    // origin2[3]
    
write_shortspr_beam );            // sprite index
    
write_byte);                // start frame
    
write_byte);                // framerate
    
write_byte30 );                // life in 0.1 sec
    
write_byte20 );                // width
    
write_byte);                // noise
    
write_byte);                // red
    
write_byte255 );                // green
    
write_byte);                // blue
    
write_byte255 );                // brightness
    
write_byte);                // speed
    
message_end()

Nice, thanks.

Its not 100% accurate but it will have to do.

+ It says "overflow on player x" on console if two people try it same time(?)
matsi 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 23:25.


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