Skip to content

OnNpcTarget

Usage

  • No return behavior

Example Autogenerated

csharp
private void OnNpcTarget(  )
{
    Puts( "OnNpcTarget works!" );
}
csharp
private void OnNpcTarget(  )
{
    Puts( "OnNpcTarget works!" );
}

Location

  • AIBrainSenses::GetNearest(System.Collections.Generic.List`1<BaseEntity> entities, float rangeFraction)
  • HumanNPC::GetBestTarget()
csharp
//---
	}
	float num = float.PositiveInfinity;
	BaseEntity result = null;
	foreach (BaseEntity current in entities)
	{
		if (!(current == null) && current.Health() > 0f && Interface.CallHook("OnNpcTarget", this.owner, current) == null)
		{
			float num2 = Vector3.Distance(current.transform.position, this.owner.transform.position);
			if (num2 <= rangeFraction * this.maxRange && num2 < num)
			{
				result = current;
//---
csharp
//---
{
	BaseEntity result = null;
	float num = -1f;
	foreach (BaseEntity current in this.Brain.Senses.Players)
	{
		if (!(current == null) && current.Health() > 0f && Interface.CallHook("OnNpcTarget", this, current) == null)
		{
			float value = Vector3.Distance(current.transform.position, base.transform.position);
			float num2 = 1f - Mathf.InverseLerp(1f, this.Brain.SenseRange, value);
			float value2 = Vector3.Dot((current.transform.position - base.eyes.position).normalized, base.eyes.BodyForward());
			num2 += Mathf.InverseLerp(this.Brain.VisionCone, 1f, value2) / 2f;
//---

Released under the MIT License.