Checking if entity is certain type on death?Solved
void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            if (entity == null | info == null)
                return;
            if (entity.PrefabName == "assets/prefabs/npc/scientist/scientist.prefab")
                Puts("Scientist killed");
        }
This doesn't work and i don't know why, its supposed to put that message in console when a scientist is killed. Im not sure if I just got the prefab name wrong, but i tried killing scientists on oil rig and it didn't work. How do I fix it?
5ee8d1e1c84dc.png Kingfoo55
This doesn't work and i don't know why, its supposed to put that message in console when a scientist is killed. Im not sure if I just got the prefab name wrong, but i tried killing scientists on oil rig and it didn't work. How do I fix it?

You could do this instead of checking the PrefabName:

        void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
        {
            if (entity == null)
                return;

            if (entity is ScientistNPC)
            {
                Puts("scientist was killed");
            }
        }
Thanks, this worked.

How would i do this for heavyscientists, scarecrows, murderers?
5ee8d1e1c84dc.png Kingfoo55
Thanks, this worked.

How would i do this for heavyscientists, scarecrows, murderers?

Most of them have same class. Check by shortname

E: What orange said.
what do you mean by check by shortname?

Merged post

if (entity.ShortPrefabName == "murderer.prefab")​
would this work?
so it would be like this
if (entity.ShortPrefabName == "heavyscientist")​

It works, thanks for the help guys.
Locked automatically