I don't want to spam tracerays within the slope, just something accurate enough to find a trigger hurt not even in the ground itself, but still inside that slope. My non-working code, firing every 0.1 seconds:
This is to find the trigger_hurt of the slopes in c12m4_barn
I am okay with sacrificing a bit of accuracy for performance, because of the frequency the function calls. This will be used to trigger kills by removal of a player from the map ( karma ) with smoker, charger, jockey, boomer ( bitch slap plugin ) and tank. I am unaware if a map exists that allows a smoker to do it.
Code:
public Action Timer_CheckCharge(Handle timer, any client)
{
if (!client || !IsClientInGame(client) || !IsPlayerAlive(client))
{
chargerTimer[client] = INVALID_HANDLE;
return Plugin_Stop;
}
int victim = GetCarryVictim(client);
if (victim == -1)
return Plugin_Continue;
else if (IsDoubleCharged(victim))
return Plugin_Continue;
else if (GetEntityFlags(client) & FL_ONGROUND) return Plugin_Continue;
float fOrigin[3], fEndOrigin[3], fMins[3], fMaxs[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", fOrigin);
ArrayList aEntities = new ArrayList(1);
GetClientMins(client, fMins);
GetClientMaxs(client, fMaxs);
TR_TraceRayFilter(fOrigin, ANGLE_STRAIGHT_DOWN, MASK_PLAYERSOLID, RayType_Infinite, TraceFilter_DontHitPlayers);
TR_GetEndPosition(fEndOrigin);
// Now try again with hull to avoid funny stuff.
TR_TraceHullFilter(fOrigin, fEndOrigin, fMins, fMaxs, MASK_PLAYERSOLID, TraceFilter_DontHitPlayers);
TR_GetEndPosition(fEndOrigin);
float fPlaneNormal[3];
TR_GetPlaneNormal(INVALID_HANDLE, fPlaneNormal);
float fPlaneRotated[3];
Math_RotateVector(fPlaneNormal, { 0.0, 0.0, -120.0 }, fPlaneRotated);
fPlaneRotated[0] *= GetVectorLength(fEndOrigin);
fPlaneRotated[1] *= GetVectorLength(fEndOrigin);
fPlaneRotated[2] *= GetVectorLength(fEndOrigin);
float fSlopedOrigin[3];
// Account for slopes when finding a trigger_hurt. Why must Blood Harvest exist?
TR_TraceRayFilter(fEndOrigin, fPlaneRotated, MASK_PLAYERSOLID, RayType_Infinite, TraceFilter_DontHitPlayers);
TR_GetEndPosition(fSlopedOrigin);
TE_SetupBeamPoints(fOrigin, fPlaneRotated, PrecacheModel("materials/vgui/white_additive.vmt"), 0, 0, 0, 10.0, 10.0, 10.0, 0, 10.0, { 255, 0, 0, 255 }, 50);
TE_SendToAllInRange(fOrigin, RangeType_Audibility);
TR_EnumerateEntities(fOrigin, fSlopedOrigin, PARTITION_SOLID_EDICTS | PARTITION_TRIGGER_EDICTS | PARTITION_STATIC_PROPS, RayType_EndPoint, TraceEnum_TriggerHurt, aEntities);
int iSize = GetArraySize(aEntities);
delete aEntities;
if (iSize > 0)
{
AnnounceKarma(client, victim, "Charge");
chargerTimer[client] = INVALID_HANDLE;
return Plugin_Stop;
}
else if (GetConVarBool(karmaBirdCharge))
{
DebugPrintToAll("%.2f", fPlaneNormal[2]);
if (!CanClientSurviveFall(victim, apexHeight[client] - fEndOrigin[2]) && fPlaneNormal[2] >= 0.98)
{
AnnounceKarma(client, victim, "Charge", true);
chargerTimer[client] = INVALID_HANDLE;
return Plugin_Stop;
}
}
return Plugin_Continue;
}
I am available to make plugins for pay.
Discord: Eyal282#1334