Raised This Month: $ Target: $400
 0% 

Grenade trajectory


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4JOKE
Member
Join Date: Jan 2008
Old 02-21-2010 , 06:55   Grenade trajectory
Reply With Quote #1

It's possible to find out grenade trajectory?
I want make plugin, which will show color line from my position to wall where will grenade "fly" and where will grenade change direction from wall.

I think, it will need a lot of experience with physic computing (speed, angle of fall = angle of reflection).

I need it for training throwing grenades, so I can see how and where will grenade fall.

Does similar plugin exists? Because I have no experience with physic of throwen grenade ...

Thank you.
4JOKE is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-21-2010 , 07:21   Re: Grenade trajectory
Reply With Quote #2

It may help : http://forums.alliedmods.net/showpos...&postcount=138
__________________
Arkshine is offline
4JOKE
Member
Join Date: Jan 2008
Old 02-21-2010 , 13:06   Re: Grenade trajectory
Reply With Quote #3

Thank you! I found also some usefull example here: http://forums.alliedmods.net/showthr...Func_TraceToss

... but it's possible to get something as array of hitPoints? Because I want to make lines for all movement of grenade, until it will land on box or ground...
...this function will give me only trace to first hitPoint...
4JOKE is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 02-21-2010 , 20:05   Re: Grenade trajectory
Reply With Quote #4

You should call TraceToss after each touch of grenade with any entity.

That's because TraceToss works just with only the current trajectory.

If the grenade bounce with something, it's a new trajectory.
__________________

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
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-21-2010 , 20:24   Re: Grenade trajectory
Reply With Quote #5

Code:
#include < amxmodx > #include < fakemeta > new sv_gravity; public plugin_init( ) {     sv_gravity = get_cvar_pointer( "sv_gravity" ); } // ============= VERSION 1 ================= // Uses interval of time with cell arrays // ======================================= // ... // iEntity = entity to find trajectory // the time between each point found const Float:TIME_INTERVAL = 0.1; new Array:aOrigins = ArrayCreate( 3 ); new iTotalPoints; new Float:vStartOrigin[ 3 ]; pev( iEntity, pev_origin, vStartOrigin ); new Float:vStopOrigin[ 3 ]; engfunc( EngFunc_TraceToss, iEntity, iEntity, 0 ); get_tr2( 0, TR_vecEndPos, vStopOrigin ); new Float:vVelocity[ 3 ]; pev( iEntity, pev_velocity, vVelocity ); new Float:fGravity; pev( iEntity, pev_gravity, fGravity ); fGravity *= get_pcvar_float( sv_gravity ); new Float:fTotalTime = ( vVelocity[ 2 ] + floatsqroot( ( floatpower( vVelocity[ 2 ], 2.0 ) + ( 2.0 * fGravity * ( vStartOrigin[ 2 ] - vStopOrigin[ 2 ] ) ) ) ) ) / fGravity; new Float:fPercent; new Float:vCalcOrigin[ 3 ]; for( new Float:fTime = TIME_INTERVAL; fTime <= fTotalTime; fTime += TIME_INTERVAL ) {     fPercent = fTime / fTotalTime;         vCalcOrigin[ 0 ] = vStartOrigin[ 0 ] + ( fPercent * ( vStopOrigin[ 0 ] - vStartOrigin[ 0 ] ) );     vCalcOrigin[ 1 ] = vStartOrigin[ 1 ] + ( fPercent * ( vStopOrigin[ 1 ] - vStartOrigin[ 1 ] ) );     vCalcOrigin[ 2 ] = vStartOrigin[ 2 ] - ( floatpower( fTime, 2.0 ) * fGravity / 2.0 ) + ( fTime * vVelocity[ 2 ] );         ArrayPushArray( aOrigins, vCalcOrigin );     iTotalPoints++; } ArrayPushArray( aOrigins, vStopOrigin ); iTotalPoints++; // ============= VERSION 2 ================= // Uses maximum points and memory arrays // ======================================= // ... // iEntity = entity to find trajectory // the total amount of points to store const MAX_POINTS = 32; new Float:vOrigins[ MAX_POINTS + 1 ][ 3 ]; new Float:fTimes[ MAX_POINTS + 1 ]; new Float:vStartOrigin[ 3 ]; pev( iEntity, pev_origin, vStartOrigin ); new Float:vStopOrigin[ 3 ]; engfunc( EngFunc_TraceToss, iEntity, iEntity, 0 ); get_tr2( 0, TR_vecEndPos, vStopOrigin ); new Float:vVelocity[ 3 ]; pev( iEntity, pev_velocity, vVelocity ); new Float:fGravity; pev( iEntity, pev_gravity, fGravity ); fGravity *= get_pcvar_float( sv_gravity ); new Float:fTotalTime = ( vVelocity[ 2 ] + floatsqroot( ( floatpower( vVelocity[ 2 ], 2.0 ) + ( 2.0 * fGravity * ( vStartOrigin[ 2 ] - vStopOrigin[ 2 ] ) ) ) ) ) / fGravity; new Float:fPercent; new Float:fMaxPoints = float( MAX_POINTS ); new Float:fTime; new Float:vCalcOrigin[ 3 ]; for( new i; i <= MAX_POINTS; i++ ) {     fPercent = float( i ) / fMaxPoints;     fTime = fTotalTime * fPercent;         vOrigins[ i ][ 0 ] = vStartOrigin[ 0 ] + ( fPercent * ( vStopOrigin[ 0 ] - vStartOrigin[ 0 ] ) );     vOrigins[ i ][ 1 ] = vStartOrigin[ 1 ] + ( fPercent * ( vStopOrigin[ 1 ] - vStartOrigin[ 1 ] ) );     vOrigins[ i ][ 2 ] = vStartOrigin[ 2 ] - ( floatpower( fTime, 2.0 ) * fGravity / 2.0 ) + ( fTime * vVelocity[ 2 ] );     fTimes[ i ] = fTime; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 02-21-2010 , 20:37   Re: Grenade trajectory
Reply With Quote #6

Exolent, I guess your code makes and array with MAX_POINTS of the parabola.

He wants every hitpoint (of multiples parabolas), not the parabola.
__________________

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
4JOKE
Member
Join Date: Jan 2008
Old 02-22-2010 , 07:06   Re: Grenade trajectory
Reply With Quote #7

joropito, you are right. I tryed Exolent's code and it realy does one parabola. Anyway thank you Exolent.

I just still need make multiple parabolas... but how to detect new traces after grenade hit something ?!
4JOKE is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 02-22-2010 , 07:22   Re: Grenade trajectory
Reply With Quote #8

Use the code with TraceToss at each touch (register as post). Check if it works.

Like this

PHP Code:
public plugin_init()
{
    
register_forward(FM_Touchfw_touch1)
}

public 
fw_touch(touchertouched)
{
    static class[
32]
    
entity_get_string(toucherEV_SZ_classname, class, sizeof(class))
    if(!
equal(class, "grenade")) return FMRES_IGNORED

    
// Put your TraceToss code here


    
return FMRES_IGNORED

__________________

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
4JOKE
Member
Join Date: Jan 2008
Old 02-22-2010 , 11:26   Re: Grenade trajectory
Reply With Quote #9

I tryed. I really can get trace everytime when grenade touch something. So I can see when it touch something, where grenade will land or hit something again...

I am sorry, your code is right, but it's not exactly what I want. I want if I use command ie. "grenade", it will show me all parabolas(depending on where I am aiming), where grenade will hit something and where will it land. It's possible do it without throwing grenade? Somthing like parabolas, where my grenade "could" fly and hit something and where it "could" land if I throw it...
4JOKE is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 02-22-2010 , 15:33   Re: Grenade trajectory
Reply With Quote #10

Throw a fake grenade (invisible, no sound, no effect, no damage)
__________________

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
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 14:36.


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