Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player TraceLine issue #7

Open
guljam opened this issue Feb 17, 2018 · 1 comment
Open

Player TraceLine issue #7

guljam opened this issue Feb 17, 2018 · 1 comment

Comments

@guljam
Copy link

guljam commented Feb 17, 2018

I am using the Player :: GetNearByLocation function to spawn Special infected better than Director.

The problem is the Player :: CanTraceToLocation function when trying to find a place that Survivor can not see.
This is theoretically no problem.

Returning Utils.AreVectorsEqual (m_trace.pos, finish) on some maps is problematic.

For example, in map c2m5_concert.
GetNearByLocation finds a position in the tilted audience chair Navmash and when CanTraceToLocation decides.
It returns a false value with an error of Z axis (difference of 0.00035 for example) with a very slight difference.
It is also the same when the player is placed in a tilted navmash.

The conclusion is that the player can see its position, but the CanTraceToLocation function returns false.
So I modified it to "Utils.CalculateDistance (arr [i], m_trace.pos) <15) return true".
And with a little tolerance, I solved this problem.

So VSLib :: Utils :: SpawnZombieNearPlayer has a problem. I used this at first. It did not work well.
TraceMask should use MASK_OPAQUE. (Reason: transparent white barbed wire for example c2m2_fairgrounds)
I do not know why it traces the 128-height of the Z-axis. The general eye level of special infected is about 60.

Below is the function I created. Trace values ​​are returned more naturally in real situations.


function VSLib::Player::CanTraceLocationAround (where, tolerance = 15, traceMask = MASK_OPAQUE)
{
if(!IsEntityValid()) return;
if(!IsAlive()) return;

local eyepos = GetEyePosition();
local eyeang = GetEyeAngles();

local whereL = where + eyeang.Left().Scale(15);
local whereR = where + eyeang.Left().Scale(-15);

local arr =[where, whereL, whereR];

for(local i = 0; i < 2; i++)
{
	local m_trace = { start = eyepos, end = arr[i], ignore = _ent, mask = traceMask };
	TraceLine(m_trace);

	if(Utils.CalculateDistance(arr[i], m_trace.pos) < tolerance)
	{
		return true;
	}
}

return false;

}

@neil-119
Copy link
Member

Create a pull request and we can merge your contribution in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants