Official site anti-cheat Ultra Core Protector

Home Download F.A.Q. Addons Monitor Forum Support Advertise English version site UCP Anti-Cheat    Russian version site UCP Anti-Cheat
Ultra Core Protector - is the client-server anti-cheat freeware, for server protection from unscrupulous players.

Abilities Supported games  
Half-Life
Condition Zero
Counter-Strike 1.6
Day of Defeat
Adrenaline Gamer
Team Fortress Classic
Counter-Strike Source
MU Online
Ragnarok Online
Half-Life 2 Deathmatch
Adrenaline Gamer 2
Team Fortress 2
Multiple grenade paths + pFade effect (for grenade pred)

So ive always wanted my grenade prediction to show multiple nades i threw + a nice fade effect.

it fades the last few lines with a speed relative to the initial path length so the lines are visible for the same amount of time regardles of their length.

it reduces the alpha by an amout relative to the path length and if the alpha goes to zero it erases the line from the deque.

if a grenadepath is empty, it removes it from the main deque. a pretty simple concept that results in a very smooth fade effect.

all the paths themselves are stored in a deque(youll have to have an already working grenade pred) with the throwtime added so none of them get drawn multiple times.

use this struct:
struct GrenadePath
{
GrenadePath( const std::deque>& path, const float& flThrowTime, const float& flDuration, const float& flFadeSpeed )
{
this->path = path;
this->flThrowTime = flThrowTime;
this->flDuartion = flDuration;
this->flFadeSpeed = flFadeSpeed;
this->iInitialPathSize = path.size();
this->bThrown = true;
this->step = 0;
}
void Fade()
{
step += g_pGlobalVarsBase->frametime;
if ( step <= flDuartion ) return; for ( int i = path.size() - 1; i >= 0; i-- )
{
auto it = path.begin() + i;

if ( !it->second )
{
path.erase( it );
continue;
}

it->second -= ( iInitialPathSize * flFadeSpeed / 255 ) / ( i + 6 );
if ( it->second < 0 ) it->second = 0.f;
}
}
std::deque> path;
float flThrowTime;
float flDuartion;
float flFadeSpeed;
size_t iInitialPathSize;
bool bThrown;
float step;
};

setting up your paths is pretty simple as long as you already have grenade prediction.
wherever you would add points to your path in a deque do this instead:

std::deque> path;

//calc your points bla bla bla...

//add them like this: where vecSrc is a point of your path.
path.push_back( std::pair( vecSrc, 255.f ) );

//then add them to the main deque that contains all Grenade paths.
deques.push_back( GrenadePath( path, pWeapon->GetThrowTime(), duration, speed ) );
//the values i used were: duration = 6.f, speed = 100.f
//duration determines the time the line wil stay until it starts fading and speed the fade speed.

/*deques is just this:*/ std::deque deques; //put into a header file.

to draw your paths use this:

void CGrenadePred::Paint()
{
float throwtime = 0;
for ( int i = deques.size() - 1; i >= 0; i-- )
{
auto dq = deques.begin() + i;

auto currdeque = dq->path;

if ( !Shoulddraw( *dq, throwtime ) )
{
deques.erase( dq );
continue;
}

throwtime = dq->flThrowTime;

Vector prev = currdeque.at( 0 ).first;
Vector res1, res2;
for ( auto it = currdeque.begin(), end = currdeque.end(); it != end; it++ )
{
if ( D::WorldToScreen( prev, res1 ) && D::WorldToScreen( it->first, res2 ) ) //draws the lines between your points
D::DrawLine( res1.x, res1.y, res2.x, res2.y, Color( 255, 255, 255, it->second ) );
prev = it->first;
}

if ( D::WorldToScreen( prev, res2 ) ) //draws the cube at the end of the line
D::DrawRect( res2.x - 4, res2.y - 4, 8, 8, Color( 255, 105, 180, ( currdeque.end() - 1 )->second ) );

if ( dq->bThrown )
dq->Fade();

if ( !currdeque.size() )
deques.erase( dq );
}
}

Shoulddraw looks like this:

bool CGrenadePred::Shoulddraw( GrenadePath& gp, float prevthrowtime )
{
for ( auto it = gp.path.begin(), end = gp.path.end(); it != end; ++it )
{
if ( gp.flThrowTime && g_pGlobalVarsBase->curtime + duration > gp.flThrowTime && gp.flThrowTime != prevthrowtime )
return true;

if ( gp.bThrown )
{
gp.bThrown = false;
return true;
}
}

return false;
}

i hope that from now on your guyses grenade prediction will start looking more nicely

hope i could help you out and save you some time if you were looking for making something like this on your own.


 



Home | Download | F.A.Q. | Addons | Forum | Banners | Sitemap | Directory | Support
Copyright © 2008-2015 UCP. All rights reserved. Privacy Policy. Siter.