Underwaterdweller and tunneldweller broken?

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.