well im working on a shotgun plugin for dod.. its basically working great, but im having a few issues that my small brain cant figure out...
basically with the firing of the pellets, im doing tracelines for each one to check for hits and for the most part this works great. Except.. The higher or lower the player aims, the less 'spread' there is left and right (when looking straight down from high up (or looking straight up) there is basically no spread from left to right so they end up hitting in a straight line up and down)
its probably just the math or something, im not really sure.. This function isnt originally my code so im not exactly sure on whats totally going on at all points during this function.. i have a feeling it might be related to the global_get( glb_v_forward, fwd ) native, but ive messed around with all sorts of stuff and cant seem to figure it out
so here's the function:
Code:
#define WPN_PELLETS 16
#define WPN_RANGE 2000.0
#define WPN_SPREAD 5.0
#define WPN_COF 2.0
#define WPN_COFMOVING 3.0
#define WPN_COFCROUCH 1.5
//called with this:
// Get COF Offset
new Float:offset[3];
pev( id, pev_v_angle, offset );
// set default cof and get speed
new Float:velocity[3], Float:cof = WPN_COF;
pev( id, pev_velocity, velocity );
// check conditions
if( button & IN_DUCK || dod_get_pronestate(id) ) //If crouched or prone..
cof = WPN_COFCROUCH;
else if( velocity[0] || velocity[1] || velocity[2] ) //else if standing and moving...
cof = WPN_COFMOVING;
offset[0] += random_float( cof, (cof * -1.0) );
offset[1] += random_float( cof, (cof * -1.0) );
new Float:start[3], Float:view_ofs[3];
pev( id, pev_origin, start );
pev( id, pev_view_ofs, view_ofs );
xs_vec_add( start, view_ofs, start );
for( new i; i < WPN_PELLETS; i++ )
{
shoot_pellet( id, offset, start );
}
///////////////////////////////////////////////////////
shoot_pellet( id, Float:offset[3], Float:start[3] )
{
new Float:dest[3];
xs_vec_copy( offset, dest );
dest[0] += random_float( WPN_SPREAD, (WPN_SPREAD* -1.0) );
dest[1] += random_float( WPN_SPREAD, (WPN_SPREAD* -1.0) );
engfunc( EngFunc_MakeVectors, dest );
new Float:fwd[3];
global_get( glb_v_forward, fwd );
xs_vec_mul_scalar( fwd, WPN_RANGE, dest );
xs_vec_add( start, dest, dest );
new Float:end[3]; //,player;
traceline( start, dest, id, end );
//traceline is another function that calls the EngFunc_TraceLine and handles giving out damage and such... all of which works fine
}
any ideas how to make it so the spread stays somewhat constant no matter what the pitch angle is? (so its the same when looking straight down as it is when looking straight ahead... and everywhere in between)
__________________