OnNpcTarget not working for HumanNPCNewSolved

Using this:

object OnNpcTarget(BaseEntity npc, BaseEntity entity) { return true; }

junkpile scientists still attack. What am I missing?

Using the following plugin, which is the only plugin loaded, Junkpile scientists, OilRig scientists, and TunnelDwellers still KOS. Any suggestions?

namespace Oxide.Plugins
{
[Info("Test", "phudgee", "1.0")]
[Description("Scientists test")]
public class Test : RustPlugin
{
// OnNpcTarget

object OnNpcTarget(BaseNpc npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(BaseEntity npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(NPCPlayerApex npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(NPCPlayer npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(ScientistNPC npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(HumanNPC npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(HumanNPCNew npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(ScientistNPCNew npc, BaseEntity entity)
{
return true;
}

object OnNpcTarget(HTNPlayer npc, BaseEntity entity)
{
return true;
}

//OnNpcPlayerTarget

object OnNpcPlayerTarget(BaseNpc npc, BaseEntity entity)
{
return true;
}

object OnNpcPlayerTarget(BaseEntity npc, BaseEntity entity)
{
return true;
}

object OnNpcPlayerTarget(NPCPlayerApex npc, BaseEntity entity)
{
return true;
}

object OnNpcPlayerTarget(NPCPlayer npc, BaseEntity entity)
{
return true;
}

object OnNpcPlayerTarget(ScientistNPC npc, BaseEntity entity)
{
return true;
}

object OnNpcPlayerTarget(HumanNPC npc, BaseEntity entity)
{
return true;
}

object OnNpcPlayerTarget(HumanNPCNew npc, BaseEntity entity)
{
return true;
}

object OnNpcPlayerTarget(ScientistNPCNew npc, BaseEntity entity)
{
return true;
}
}
}​

I think it stop working when Facepunch changed the IA of the NPC ( tunnel dweller, underwater lab, blue scientist ).
The can attack of the HumanNPCNew does not have a hook yet.

// HumanNPCNew
public bool CanAttack(BaseEntity entity)
{
	return true;
}​

This should be it, and it is added for AIBrainSenses:

object OnNpcTarget(BaseEntity entity, BaseEntity entity)
{
    return true;
}​

Does not seem to work, and cannot find this reference with ilspy.
The hook in class AIBrainSenses is:

object OnNpcTarget(BaseEntity owner, BaseEntity entity)​
I have searched all references of OnNpcTarget and none are called when the NPCs are targetting
xIMZD2y4D11w1jj.jpg Lorenzo

Does not seem to work, and cannot find this reference with ilspy.
The hook in class AIBrainSenses is:

object OnNpcTarget(BaseEntity owner, BaseEntity entity)​
I have searched all references of OnNpcTarget and none are called when the NPCs are targetting
You are right, that would be the hook; missed the .owner part when checking it. I'll take another look.

Merged post

Pushed a hook that should address this. object OnNpcTarget(HumanNPCNew npc, BaseEntity entity)

Development builds(release/public branch of game only):

- https://ci.appveyor.com/api/projects/oxidemod/oxide-rust/artifacts/Oxide.Rust-develop.zip?pr=false&branch=develop

- https://ci.appveyor.com/api/projects/oxidemod/oxide-rust/artifacts/Oxide.Rust-linux-develop.zip?pr=false&branch=develop

Thank for the dev version. What i see now is that the Banditcamp guard, tunnel dwellers, underwater labs, call the
OnNpcTarget(HumanNPCNew, BaseEntity) hook

and Scientist  ( outpost, oilrig, excavator,  mil tunnel, cargoship) call the
OnNpcTarget(ScientistNPCNew, BaseEntity) hook.

At first, I thought it was not working because the NPC were still shooting at player even if the hook return true.
but looking at the code, i needed to return false, for player to be invisible to NPC.
after a few tests, seems to work well.

I may tweak the return handling to more closely match the other hooks yet.

Perfect! Thank you.

Locked automatically