Skip to content

OnNpcTarget

Usage

  • Return a non-null value to override default behavior

Example Autogenerated

csharp
private object OnNpcTarget( BaseNpc npc, BaseEntity target )
{
    Puts( "OnNpcTarget works!" );
    return null;
}

Location

  • RustCore::IOnNpcTarget(BaseNpc npc, BaseEntity target)
csharp
private object IOnNpcTarget(BaseNpc npc, BaseEntity target)
{
	if (Interface.CallHook("OnNpcTarget", npc, target) != null)
	{
		npc.SetFact(BaseNpc.Facts.HasEnemy, 0);
		npc.SetFact(BaseNpc.Facts.EnemyRange, 3);
		npc.SetFact(BaseNpc.Facts.AfraidRange, 1);

		//TODO: Find replacements of those:
		// npc.AiContext.EnemyPlayer = null;
		// npc.AiContext.LastEnemyPlayerScore = 0f;

		npc.playerTargetDecisionStartTime = 0f;
		return 0f;
	}

	return null;
}

Released under the MIT License.