1. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    Would it be possible to get a hook for NPCPlayer targeting?
    I'm not sure - would that be GetWantsToAttack() ?

    Right now I'm using OnTick() to poll NPCPlayers' AttackTarget and setting null if it's an animal.
    Far from ideal.

    Apologies if there's a better way I don't know.
     
    redBDGR likes this.
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    What's wrong with CanNpcAttack?
     
  3. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    They aren't calling it. Maybe I'm missing a step?
     
  4. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    How are you using it exactly?
     
  5. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    I just put in

    void CanNpcAttack(BaseNpc npc, BaseEntity target)
    {
    Puts("CanNpcAttack works!");
    }

    and let them fire at me with no result.

    Edit : I put in Puts($"{npc.name}"); - all returns are animals.
     
  6. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Ahh, because they use a base of BaseNpc whereas this would be based on BasePlayer.
     
    Fujikura likes this.
  7. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    That means my question is valid?
     
  8. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Yeah, hooks would have to be added for them.
     
  9. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    Cool, thank you Wulf.
    I'm still pretty green here. Trying not to ask stupid questions. ;)

    Not sure about using the OnTick() solution in the mean time.
    I mean, it works but I'm concerned it would have a big performance hit on busy servers.
    Can you advise?
     
  10. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    It's not ideal, but there aren't any other hooks you could use that I am aware of.
     
  11. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    That's great. Thank for your help.
     
  12. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    Looking at it, CanNpcAttack doesn't seem to handle targeting anyway - Just damage.
    Could/should the same hook be added in GetWantsToAttack() for BaseNpc, to prevent animal AI targeting whomever?
     
  13. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Where are you seeing GetWantsToAttack with NPCPlayer?
     
  14. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

    I don't have a reference to hand but I believe it's under NPCPlayerApex.
     
  15. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Yup, that was it.
     
  16. =BBUK= Steenamaroo

    =BBUK= Steenamaroo Plugin Developer

  17. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Implemented.
     
    =BBUK= Steenamaroo likes this.