View Single Post
cigzag
AlliedModders Donor
Join Date: Nov 2014
Location: NZ
Old 08-17-2017 , 02:10   Re: [TF2] Yet Another Dodgeball Plugin v1.3.2 (7/21/2017)
Reply With Quote #51

Quote:
Originally Posted by Honey Senpai View Post
You can
Find this part of code in the tools part in the tf2_dodgeball.sp file in scripts

Code:
stock int SelectTarget(int iTeam, int iRocket = -1)
{
	int iTarget			 = -1;
	float fTargetWeight = 0.0;
	float fRocketPosition[3];
	float fRocketDirection[3];
	float fWeight;
	bool bUseRocket;

	if (iRocket != -1)
	{
		int iClass = g_iRocketClass[iRocket];
		int iEntity = EntRefToEntIndex(g_iRocketEntity[iRocket]);

		GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fRocketPosition);
		CopyVectors(g_fRocketDirection[iRocket], fRocketDirection);
		fWeight = g_fRocketClassTargetWeight[iClass];

		bUseRocket = true;
	}

	for (int iClient = 1; iClient <= MaxClients; iClient++)
	{
		// If the client isn't connected, skip.
		if (!IsValidClient(iClient, true)) continue;
		if (iTeam && GetClientTeam(iClient) != iTeam) continue;

		// Determine if this client should be the target.
		float fNewWeight = GetURandomFloatRange(0.0, 100.0);

		if (bUseRocket == true)
		{
			float fClientPosition[3]; GetClientEyePosition(iClient, fClientPosition);
			float fDirectionToClient[3]; MakeVectorFromPoints(fRocketPosition, fClientPosition, fDirectionToClient);
			fNewWeight += GetVectorDotProduct(fRocketDirection, fDirectionToClient) * fWeight;
		}

		if ((iTarget == -1) || fNewWeight >= fTargetWeight)
		{
			iTarget = iClient;
			fTargetWeight = fNewWeight;
		}
	}

	return iTarget;
}
and replace it with this

Code:
stock int SelectTarget(int iTeam, int iRocket = -1)
{
	int iTarget = -1;
	float fRocketPosition[3];
	float fRocketDirection[3];
	bool bUseRocket;
	float flBestLength = 99999.9;
	
	if (iRocket != -1)
	{
		int iEntity = EntRefToEntIndex(g_iRocketEntity[iRocket]);
		GetEntPropVector(iEntity, Prop_Send, "m_vecOrigin", fRocketPosition);
		
	}
	
	for (int i = 1; i <= MaxClients; i++)
	{
		// If the client isn't connected, skip.
		if (!IsValidClient(i, true))continue;
		if (iTeam && GetClientTeam(i) != iTeam)continue;
		float flPos2[3];
		GetClientEyePosition(i, flPos2);
		
		float flDistance = GetVectorDistance(fRocketPosition, flPos2);
		
		//if(flDistance < 70.0) continue;
		
		if (flDistance < flBestLength)
		{
			iTarget = i;
			flBestLength = flDistance;
		}
		
	}
	return iTarget;
}
then save it as something different like tf2_dodgeball2.sp
compile it.
move original to disabled or delete which ever.
put the smx file you got from compiling it into the plugin folder.
then boom targets the closest.

NOTE: spawn rockets will target the closest as well.

Its what I use on my version of the original plugin. I ripped it from the rtd effect homing rockets and mashed it in there. It should work cause it seem that the tools part was the only thing you didn't touch much.
Oh and by the way I love that some one actually made the plugin better and more easily available.
here is my version if you want to take a gander it uses the original plugin though. it replaces the rocket with flares. the reason is that rockets have a lot of particles that will hurt people who have low frame rates (most of my friends). so i chose to replace the entity with a flare because it has much less particles compared to rockets though I had to add a light entity to it to let people see it.
so let me know if it works for you.

EDIT: I just adjusted it to work for the plugin and all ready did the changes in the sp file so you just have to use the bottom one.
Interesting, will have to have to take a look.
cigzag is offline