On_NPCHurt

Mar 1, 2015
On_NPCHurt
  • Method:
    On_NPCHurt

    Description:
    Runs when an NPC gets damage.

    Argument(s):
    HurtEvent he

    Examples:
    Python:

    Code (Python):

    def On_NPCHurt(self, HurtEvent):
         Server.Broadcast(HurtEvent.Victim.Name + " got hurt!")
     

    Javascript:
    Code (Javascript):

    function On_NPCHurt(HurtEvent) {
         Server.Broadcast(HurtEvent.Victim.Name + " got hurt!");
    }
     

    C#:
    Code (C#):
    public override void Initialize()
    {
         Hooks.OnNPCHurt += NPCHurt;
    }

    public override void DeInitialize()
    {
         Hooks.OnNPCHurt -= NPCHurt;
    }
    Code (C#):
    public void NPCHurt(HurtEvent he)
    {
         NPC animal = (NPC) he.Victim;

         string animalName = animal.Name;

         Server.GetServer().Broadcast(animalName + " got hurt!");
    }