I can’t do a null check for HitInfo.Weapon.

When a stone is thrown, the following code becomes true.

info.Weapon == null

I understand that this means that info.Weapon is null.
However, info.Weapon.skinID works normally in this state.
Why doesn’t a NullReferenceException occur?

void OnPlayerAttack(BasePlayer attacker, HitInfo info)
  Message(attacker,(info.Weapon == null).ToString()); // stone is thrown --> true
  var skin = info.Weapon.skinID;

make sure info is not null also

if (info == null || info.Weapon == null)
{
     Message(attacker,("info or Weapon is null");
     return;
}​

Thank you for your reply.

I am using Hitinfo’s Weapon.skinID in the OnPlayerAttack event to get the skin ID of the thrown stone.

And at the beginning of OnPlayerAttack, I want to do a null check on Hitinfo.Weapon.
But if I do that, I can’t get the skin ID of the thrown stone.

This is because the following code when throwing a stone is true.

Hitinfo.Weapon == null // true

If I don’t do this check, Weapon.skinID will return the skin ID of the thrown stone correctly.