1. Code:
    object OnEntityAttacked(MonoBehaviour entity, HitInfo hitinfo)
    {
         if (hitinfo == null)
         {
             Print("No hit info at all");
             return null;
         }
         if (hitinfo.Initiator == null)
         {
             Print("Attacker is null");
             return null;
         }
         if (hitinfo.HitEntity == null)
         {
             Print("Defender is null");
             return null;
         }
    }
    
    hitinfo.HitEntity seems to always be null whenever a BasePlayer gets attacked. I've tried with a stone hatchet, and a thompson

    When a player gets hit, and starts bleeding, i get a buuuunch of calls on OnEntityAttacked, with the DEFENDER being null...


    Am i doing somethiong wrong....
    [DOUBLEPOST=1423527215][/DOUBLEPOST]Its very strange, that when a player is bleeding, cold, or going through radiation damage, HitEntity (the defender) is null.... So, what is being damaged.
     
  2. oops sorry nm
    [DOUBLEPOST=1423528309][/DOUBLEPOST]why do you use hintinfo.HitEntity ?
    and not entity ?
     
  3. "entity" isn't a property of the Assembly-CSharp/HitInfo class
     
  4. MonoBehaviour entity
     
  5. and how do i get the BasePlayer from that?
     
  6. trying it just like that, dunno if it will work , but normally it will:

    Code:
    object OnEntityAttacked(MonoBehaviour entity, HitInfo hitinfo)
    {
      var player = entity as BasePlayer;
      if(player == null)
      {
        return;
      }
      Puts(player.displayName);
    }
     
  7. Alrighty... wasnt sure if you could just cast it.
     
  8. Wulf

    Wulf Community Admin

    We've also added back OnPlayerAttack, if that's of any use to it.
     
  9. That did work Reneb. Thanks.

    Cool. Thanks Wulf