Support for new Rust NPC typesSuggestion

I realized that the plugin hasn't been updated in a long time so I took it upon myself to make some changes, like restoring messages for when NPCs kill each other or die by other means that the plugin ignores. 
How would I go about adding tunnel dwellers, underwater dwellers, sharks and mostly anything the plugin doesn't account for?

I'd be glad to share my modified versions (with and without NPC vs NPC) once I get this sorted out 

Since today's server update underwaterdweller and tunneldweller are no longer being announced.

Can say the same happened after wipe on our server.

cant get it to work on mine either

Can say the same happened after wipe on our server. 

        private void OnEntityDeath(BaseCombatEntity victimEntity, HitInfo hitInfo)
        {
			
            // Ignore - there is no victim for some reason
            if (victimEntity == null)
                return;
			
			
			
            // Try to avoid error when entity was destroyed
            if (victimEntity.gameObject == null)
                return;

            var data = new DeathData
            {
                VictimEntity = victimEntity,
                KillerEntity = victimEntity.lastAttacker ?? hitInfo?.Initiator,
                VictimEntityType = GetCombatEntityType(victimEntity),
                KillerEntityType = GetCombatEntityType(victimEntity.lastAttacker),
                DamageType = victimEntity.lastDamage,
                HitInfo = hitInfo
            };

            // Handle inconsistencies/exceptions
            HandleInconsistencies(ref data);

#if DEBUG
            LogDebug("[DEATHNOTES DEBUG]");
            LogDebug($"VictimEntity: {data.VictimEntity?.GetType().Name ?? "NULL"} / {data.VictimEntity?.ShortPrefabName ?? "NULL"} / {data.VictimEntity?.PrefabName ?? "NULL"}");
            LogDebug($"KillerEntity: {data.KillerEntity?.GetType().Name ?? "NULL"} / {data.KillerEntity?.ShortPrefabName ?? "NULL"} / {data.KillerEntity?.PrefabName ?? "NULL"}");
            LogDebug($"VictimEntityType: {data.VictimEntityType}");
            LogDebug($"KillerEntityType: {data.KillerEntityType}");
            LogDebug($"DamageType: {data.DamageType}");
            LogDebug($"Bodypart: {GetCustomizedBodypartName(data.HitInfo)}");
            LogDebug($"Weapon: {hitInfo?.WeaponPrefab?.ShortPrefabName ?? "NULL"}");
#endif

            // Ignore deaths of other entities
            if (data.KillerEntityType == CombatEntityType.Other || data.VictimEntityType == CombatEntityType.Other)
				return;​

Becase data.VictimEntityType = CombatEntityType.Other = Other when Player is TunnelDweller or UnderwaterDweller
The script not  go on exec

Any chance of gettting this updated/patched ? Anyone have a workaround?

Just replace in

private void OnEntityDeath​
cRUTcEGEaEMef25.JPG rustybeachcomber

Any chance of gettting this updated/patched ? Anyone have a workaround?

if (data.KillerEntityType == CombatEntityType.Other)
{
	return;
}
			
if (data.VictimEntityType == CombatEntityType.Other && !data.VictimEntity.ShortPrefabName.ToLower().Contains("dweller"))
{
	return;
}

if (data.VictimEntity.ShortPrefabName.ToLower().Contains("underwaterdweller"))
{
	data.VictimEntityType = CombatEntityType.UnderwaterDweller;
}

if (data.VictimEntity.ShortPrefabName.ToLower().Contains("tunneldweller"))
{
	data.VictimEntityType = CombatEntityType.TunnelDweller;
}
mk9EWFJBNUlhDhz.png bigmak
if (data.KillerEntityType == CombatEntityType.Other)
{
	return;
}
			
if (data.VictimEntityType == CombatEntityType.Other && !data.VictimEntity.ShortPrefabName.ToLower().Contains("dweller"))
{
	return;
}

if (data.VictimEntity.ShortPrefabName.ToLower().Contains("underwaterdweller"))
{
	data.VictimEntityType = CombatEntityType.UnderwaterDweller;
}

if (data.VictimEntity.ShortPrefabName.ToLower().Contains("tunneldweller"))
{
	data.VictimEntityType = CombatEntityType.TunnelDweller;
}

Hi bigmak, appreciate you taking the time to find a fix. Are you just adding this code below the "Ignore deaths of other entities comment", or is anything being replaced? It shows now if I kill TunnelDwellers but not if I die to them. :(

GetCombatEntityType

if(entity.GetType().Name.ToString().ToLower() == "tunneldweller")
				return CombatEntityType.TunnelDweller;
			
			if(entity.GetType().Name.ToString().ToLower() == "underwaterdweller")
				return CombatEntityType.UnderwaterDweller;
			
			if(entity.GetType().Name.ToString().ToLower() == "zombienpc")
				return CombatEntityType.ZombieNPC;​

GetEntityName

				case CombatEntityType.ZombieNPC:
					return "ZombieNPC";

CombatEntityType

ZombieNPC = 19,

config\DeathNotes/json

{
        "KillerType": "ZombieNPC",
        "VictimType": "Player",
        "DamageType": "*",
        "Messages": [
          "{victim} 被 {killer} 挠死"
        ]
      },
      {
        "KillerType": "Player",
        "VictimType": "ZombieNPC",
        "DamageType": "*",
        "Messages": [
          "{killer} 用 {weapon} 干掉了 {victim}({distance})"
        ]
},

support : ZombieHorde,UnderwaterDweller and TunnelDweller

Hello, this code changing entity type of victim and killer from "other" to *dweller, replace "OnEntityDeath" and add  method "RepairEntityTypes":

private void OnEntityDeath(BaseCombatEntity victimEntity, HitInfo hitInfo)
{
	if (victimEntity == null)
		return;

	if (victimEntity.gameObject == null)
		return;
		

	var data = new DeathData
	{
		VictimEntity = victimEntity,
		KillerEntity = victimEntity.lastAttacker ?? hitInfo?.Initiator,
		VictimEntityType = GetCombatEntityType(victimEntity),
		KillerEntityType = GetCombatEntityType(victimEntity.lastAttacker),
		DamageType = victimEntity.lastDamage,
		HitInfo = hitInfo
	};
	
	// Change entity type for dwellers
	RepairEntityTypes(data);

	HandleInconsistencies(ref data);

	if (data.KillerEntityType == CombatEntityType.Other || data.VictimEntityType == CombatEntityType.Other)
		return;

	if (data.VictimEntityType != CombatEntityType.Player && data.KillerEntityType != CombatEntityType.Player && data.VictimEntityType != CombatEntityType.Helicopter)
		return;

	string message = PopulateMessageVariables(
		// Find the best matching death message for this death
		GetDeathMessage(data),
		data
	);

	if (message == null)
		return;

	object hookResult = Interface.Call("OnDeathNotice", data.ToDictionary(), message);

	if (hookResult?.Equals(false) ?? false)
		return;

	if (_configuration.ShowInChat)
	{
		foreach (var player in BasePlayer.activePlayerList)
		{
			if (_configuration.RequirePermission && !permission.UserHasPermission(player.UserIDString, CanSeePermission))
				continue;

			if (_configuration.MessageRadius != -1 && player.Distance(data.VictimEntity) > _configuration.MessageRadius)
				continue;

			Player.Reply(
				player,
				_configuration.ChatFormat.Replace("{message}", message),
				ulong.Parse(_configuration.ChatIcon)
			);
		}
	}

	if (_configuration.ShowInConsole)
		Puts(StripRichText(message));
}

private void RepairEntityTypes(DeathData data)
{
	string victimPrefabName = data.VictimEntity.ShortPrefabName.ToLower();
	string killerPrefabName = data.KillerEntity.ShortPrefabName.ToLower();

	if (victimPrefabName.Contains("underwaterdweller"))
	{
		data.VictimEntityType = CombatEntityType.UnderwaterDweller;
	}

	if (victimPrefabName.Contains("tunneldweller"))
	{
		data.VictimEntityType = CombatEntityType.TunnelDweller;
	}
	
	if (killerPrefabName.Contains("underwaterdweller"))
	{
		data.KillerEntityType = CombatEntityType.UnderwaterDweller;
	}

	if (killerPrefabName.Contains("tunneldweller"))
	{
		data.KillerEntityType = CombatEntityType.TunnelDweller;
	}
}

 

Craftbot

Hi bigmak, appreciate you taking the time to find a fix. Are you just adding this code below the "Ignore deaths of other entities comment", or is anything being replaced? It shows now if I kill TunnelDwellers but not if I die to them. :(

Added null reference checking and reference type of argument, works for me

private void OnEntityDeath(BaseCombatEntity victimEntity, HitInfo hitInfo)
{
	if (victimEntity == null)
		return;

	if (victimEntity.gameObject == null)
		return;
		

	var data = new DeathData
	{
		VictimEntity = victimEntity,
		KillerEntity = victimEntity.lastAttacker ?? hitInfo?.Initiator,
		VictimEntityType = GetCombatEntityType(victimEntity),
		KillerEntityType = GetCombatEntityType(victimEntity.lastAttacker),
		DamageType = victimEntity.lastDamage,
		HitInfo = hitInfo
	};
	

	HandleInconsistencies(ref data);
	
	
	// Change entity type for dwellers
	RepairEntityTypes(ref data);

	if (data.KillerEntityType == CombatEntityType.Other || data.VictimEntityType == CombatEntityType.Other)
		return;

	if (data.VictimEntityType != CombatEntityType.Player && data.KillerEntityType != CombatEntityType.Player && data.VictimEntityType != CombatEntityType.Helicopter)
		return;

	string message = PopulateMessageVariables(GetDeathMessage(data), data);

	if (message == null)
		return;

	object hookResult = Interface.Call("OnDeathNotice", data.ToDictionary(), message);

	if (hookResult?.Equals(false) ?? false)
		return;

	if (_configuration.ShowInChat)
	{
		foreach (var player in BasePlayer.activePlayerList)
		{
			if (_configuration.RequirePermission && !permission.UserHasPermission(player.UserIDString, CanSeePermission))
				continue;

			if (_configuration.MessageRadius != -1 && player.Distance(data.VictimEntity) > _configuration.MessageRadius)
				continue;

			Player.Reply(
				player,
				_configuration.ChatFormat.Replace("{message}", message),
				ulong.Parse(_configuration.ChatIcon)
			);
		}
	}

	if (_configuration.ShowInConsole)
		Puts(StripRichText(message));
}

private void RepairEntityTypes(ref DeathData data)
{
	if (data.VictimEntity != null)
	{
		string victimPrefabName = data.VictimEntity.ShortPrefabName.ToLower();
		if (victimPrefabName.Contains("underwaterdweller"))
		{
			data.VictimEntityType = CombatEntityType.UnderwaterDweller;
		}

		if (victimPrefabName.Contains("tunneldweller"))
		{
			data.VictimEntityType = CombatEntityType.TunnelDweller;
		}
	}
	
	if (data.KillerEntity != null)
	{			
		string killerPrefabName = data.KillerEntity.ShortPrefabName.ToLower();				
		
		if (killerPrefabName.Contains("underwaterdweller"))
		{
			data.KillerEntityType = CombatEntityType.UnderwaterDweller;
		}

		if (killerPrefabName.Contains("tunneldweller"))
		{
			data.KillerEntityType = CombatEntityType.TunnelDweller;
		}
	}
}



Craftbot

Hi bigmak, appreciate you taking the time to find a fix. Are you just adding this code below the "Ignore deaths of other entities comment", or is anything being replaced? It shows now if I kill TunnelDwellers but not if I die to them. :(

Share the entire code, please? That way I could copy/paste without worry. 

9OndLfJhgRnTBoK.png bigmak

Added null reference checking and reference type of argument, works for me

private void OnEntityDeath(BaseCombatEntity victimEntity, HitInfo hitInfo)
{
	if (victimEntity == null)
		return;

	if (victimEntity.gameObject == null)
		return;
		

	var data = new DeathData
	{
		VictimEntity = victimEntity,
		KillerEntity = victimEntity.lastAttacker ?? hitInfo?.Initiator,
		VictimEntityType = GetCombatEntityType(victimEntity),
		KillerEntityType = GetCombatEntityType(victimEntity.lastAttacker),
		DamageType = victimEntity.lastDamage,
		HitInfo = hitInfo
	};
	

	HandleInconsistencies(ref data);
	
	
	// Change entity type for dwellers
	RepairEntityTypes(ref data);

	if (data.KillerEntityType == CombatEntityType.Other || data.VictimEntityType == CombatEntityType.Other)
		return;

	if (data.VictimEntityType != CombatEntityType.Player && data.KillerEntityType != CombatEntityType.Player && data.VictimEntityType != CombatEntityType.Helicopter)
		return;

	string message = PopulateMessageVariables(GetDeathMessage(data), data);

	if (message == null)
		return;

	object hookResult = Interface.Call("OnDeathNotice", data.ToDictionary(), message);

	if (hookResult?.Equals(false) ?? false)
		return;

	if (_configuration.ShowInChat)
	{
		foreach (var player in BasePlayer.activePlayerList)
		{
			if (_configuration.RequirePermission && !permission.UserHasPermission(player.UserIDString, CanSeePermission))
				continue;

			if (_configuration.MessageRadius != -1 && player.Distance(data.VictimEntity) > _configuration.MessageRadius)
				continue;

			Player.Reply(
				player,
				_configuration.ChatFormat.Replace("{message}", message),
				ulong.Parse(_configuration.ChatIcon)
			);
		}
	}

	if (_configuration.ShowInConsole)
		Puts(StripRichText(message));
}

private void RepairEntityTypes(ref DeathData data)
{
	if (data.VictimEntity != null)
	{
		string victimPrefabName = data.VictimEntity.ShortPrefabName.ToLower();
		if (victimPrefabName.Contains("underwaterdweller"))
		{
			data.VictimEntityType = CombatEntityType.UnderwaterDweller;
		}

		if (victimPrefabName.Contains("tunneldweller"))
		{
			data.VictimEntityType = CombatEntityType.TunnelDweller;
		}
	}
	
	if (data.KillerEntity != null)
	{			
		string killerPrefabName = data.KillerEntity.ShortPrefabName.ToLower();				
		
		if (killerPrefabName.Contains("underwaterdweller"))
		{
			data.KillerEntityType = CombatEntityType.UnderwaterDweller;
		}

		if (killerPrefabName.Contains("tunneldweller"))
		{
			data.KillerEntityType = CombatEntityType.TunnelDweller;
		}
	}
}


Where exactly do we need to put this? Sorry I'm a noob, I don't know where to add this or replace in the .cs file to get it to work properly. Thank you

Hi, can anyone please share the modified whole config that works? (ZombieHorde, UnderwaterDweller and TunnelDweller). Thank you