Raised This Month: $51 Target: $400
 12% 

TraceRay to ground in the end of a slope


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 03-09-2022 , 09:33   TraceRay to ground in the end of a slope
Reply With Quote #1

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;
}
Attached Files
File Type: zip Video.zip (13.34 MB, 41 views)
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 03-09-2022 at 10:16.
eyal282 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode