Hi everyone,
I am trying to create a backblast effect for rocket launchers. I'm having great difficulty getting the angles and calculations right. At this time, I'm just debug printing the values to the console to try to figure out how to do it. Basically what I want to do is get all players in a 90 degree cone behind the player who fires the rocket, and do some damage and effects based on distance. I'll post my code below, feel free to hack and redo anything to get it working. Any help is appreciated, this is driving me nuts. Thanks!
Code:
public DoBackblast(client)
{
new Float:senderOrigin[3];
GetClientEyePosition(client, senderOrigin);
new Float:targetOrigin[3];
new Float:distance;
new Float:dist;
new Float:vecPoints[3];
new Float:vecAngles[3];
new Float:senderAngles[3];
new String:name[32];
GetClientAbsAngles(client, senderAngles);
for(new target=0;target<= GetMaxEntities() ;target++)
{
if(!IsValidEntity(target))
{
continue;
}
if(GetEdictClassname(target, name, sizeof(name)))
{
if (StrContains(name,"player") > -1)
{
if (!IsFakeClient(target))
{
GetClientAbsOrigin(target, targetOrigin);
distance = GetVectorDistance(targetOrigin, senderOrigin);
dist = distance * 0.01905;
MakeVectorFromPoints(senderOrigin, targetOrigin, vecPoints);
GetVectorAngles(vecPoints, vecAngles);
new Float:diff = senderAngles[1] - vecAngles[1];
if (diff < -180)
{
diff = 360 + diff;
}
if (diff > 180)
{
diff = 360 - diff;
}
PrintToServer("[BACKBLAST] Player %N backblast found %N distance %f dist %f direction %f",client,target,distance,dist,diff);
if (diff >= 112.5 || diff < -112.5)
{
PrintToServer("[BACKBLAST] whoa this should be good");
}
}
}
}
}
}