Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gStart, gEnd here are grenade trajectory points
- for (t = 0.0; t <= dtime; t += dt)
- {
- gEnd[0] = gStart[0] + GrenadeVelocity[0] * dt;
- gEnd[1] = gStart[1] + GrenadeVelocity[1] * dt;
- new Float:gForce = 0.4 * float(gravity.IntValue);
- new Float:NewVelocity = GrenadeVelocity[2] - gForce * dt;
- new Float:AvgVelocity = (GrenadeVelocity[2] + NewVelocity) / 2.0;
- gEnd[2] = gStart[2] + AvgVelocity * dt;
- GrenadeVelocity[2] = NewVelocity;
- new Float:mins[3] = {-2.0, -2.0, -2.0}, Float:maxs[3] = {2.0, 2.0, 2.0};
- new Handle:gRayTrace = TR_TraceHullEx(gStart, gEnd, mins, maxs, MASK_SHOT_HULL);
- if (TR_GetFraction(gRayTrace) != 1.0)
- {
- if (TR_GetEntityIndex(gRayTrace) == client && t == 0.0)
- {
- CloseHandle(gRayTrace);
- gStart = gEnd;
- continue;
- }
- TR_GetEndPosition(gEnd, gRayTrace);
- new Float:NVector[3];
- TR_GetPlaneNormal(gRayTrace, NVector);
- new Float:Impulse = 2.0 * GetVectorDotProduct(NVector, GrenadeVelocity);
- for (new i = 0; i < 3; i++)
- {
- GrenadeVelocity[i] -= Impulse * NVector[i];
- if (FloatAbs(GrenadeVelocity[i]) < 0.1)
- GrenadeVelocity[i] = 0.0;
- }
- new Float:SurfaceElasticity = GetEntPropFloat(TR_GetEntityIndex(gRayTrace), Prop_Send, "m_flElasticity");
- new Float:elasticity = 0.45 * SurfaceElasticity;
- ScaleVector(GrenadeVelocity, elasticity);
- new Float:ZVector[3] = { 0.0, 0.0, 1.0 };
- if(GetVectorDotProduct(NVector, ZVector) > 0.7) // old value from CS:Source
- {
- if (StrEqual(cWeapon, "weapon_incgrenade", false) || StrEqual(cWeapon, "weapon_molotov", false))
- dtime = 0.0;
- }
- }
- CloseHandle(gRayTrace);
- new Float:width = GetConVarFloat(sm_gtrajectory_size);
- TE_SetupBeamPoints(gStart, gEnd, _Laser, 0, 0, 0, trajectory_show_time, width, width, 0, 0.0, trailcolor, 0);
- TE_SendToAll(0.0);
- gStart = gEnd;
- }
Advertisement
Add Comment
Please, Sign In to add comment