View Single Post
Author Message
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 08-06-2013 , 21:24   [SNIPPET] Wicked Nades
Reply With Quote #1

Give nades random direction depending on players movement speed

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <smlib>

public OnEntityCreated(entity, const String:classname[])
{
if (
StrEqual(classname"hegrenade_projectile"))
{
CreateTimer(0.0Timer_RandomentityTIMER_FLAG_NO_MAPCHANGE);
}

if (
StrEqual(classname"flashbang_projectile"))
{
CreateTimer(0.0Timer_RandomentityTIMER_FLAG_NO_MAPCHANGE);
}

if (
StrEqual(classname"smokegrenade_projectile"))
{
CreateTimer(0.0Timer_RandomentityTIMER_FLAG_NO_MAPCHANGE);
}
}

public 
Action:Timer_Random(Handle:Timerany:entity)
{
if(
IsValidEntity(entity))
{
new 
client GetEntPropEnt(entityProp_Send"m_hOwnerEntity");

decl Float:fVelp[3];
new 
Float:currentspeed;

new 
Float:RandomMult;

if(
Client_IsValid(clienttrue))
{
Entity_GetAbsVelocity(clientfVelp);
currentspeed SquareRoot(Pow(fVelp[0],2.0)+Pow(fVelp[1],2.0));

RandomMult currentspeed+1.0 2.0;
}

decl Float:fVeln[3];
Entity_GetAbsVelocity(entityfVeln);

fVeln[1] += GetRandomFloat(RandomMult*(-1.0), RandomMult);
fVeln[0] += GetRandomFloat(RandomMult*(-1.0), RandomMult);

TeleportEntity(entityNULL_VECTORNULL_VECTORfVeln);
}
return 
Plugin_Handled;

__________________

Last edited by asherkin; 01-14-2015 at 20:03.
zipcore is offline