Support for Zombie Horde plugin NPCsSuggestion

I made the above changes (including changing the permissions to read only) and it didn't seem to work for me. When I made the changes, I shut down the server, updated the files, and then reloaded.

DeathNotes is reporting on the standard NPCs when I kill them, but not the ZombieHorde entities. Both get reported in WebRCON:

Cobra Kai Johnny[7971164] was killed by Flint Monkey[###############]
Sensei John Kreese[4172607] was killed by Flint Monkey[###############]
[Death Notes] Flint Monkey shot a Jazz Chicken using their M249 over a distance of 7.1 meters.
[Death Notes] Flint Monkey shot a Jazz Chicken using their M249 over a distance of 20.8 meters.
Sensei Chozen Toguchi[1635914] was killed by Flint Monkey[###############]
Captain Kangaroo[511433] was killed by Flint Monkey[###############]
Minnie Moo[3170824] was killed by Flint Monkey[###############]
Bessie[4083932] was killed by Flint Monkey[###############]
[Death Notes] Flint Monkey shot a Boar using their M249 over a distance of 9.2 meters.

I tried this fix and was _not_ able to get it working.... very interested in any config files that are able to make it work.

Merged post

Okay, I was finally able to get this working. Let's see if I can include steps to reproduce AND code snippets. I published my changes to github and also included a copy of my config file so you can check them out. 

First, @LizardMods is right and @k1lly0u's instructions work. I also made modifications to the data files based on @hc4stillo02's post above; not sure if they are needed or not.

  1. Modify DeathNotes.cs as follows:

    1a. Switch the order of these two statements as suggested so it checks type first:
    code

    Resulting code should look like:
                if (_combatEntityTypes.Contents != null)
                {
    
                    if (_combatEntityTypes.Contents.ContainsKey(entity.GetType().Name))
                        return _combatEntityTypes.Contents[entity.GetType().Name];
                                        
                    if (_combatEntityTypes.Contents.ContainsKey(entity.ShortPrefabName))
                        return _combatEntityTypes.Contents[entity.ShortPrefabName];
    
                }
    ​


    1b. Under internal enum CombatEntityType, you need to define ZombieNPC as a combat entity type. Here's my code:
            internal enum CombatEntityType
            {
                Helicopter = 0,
                Bradley = 1,
                Animal = 2,
                Murderer = 3,
                Scientist = 4,
                Scarecrow = 16,
                TunnelDweller = 17,
                UnderwaterDweller = 18,
                ZombieNPC = 19,
                Player = 5,
                Trap = 6,
                Turret = 7,
                Barricade = 8,
                ExternalWall = 9,
                HeatSource = 10,
                Fire = 11,
                Lock = 12,
                Sentry = 13,
                Other = 14,
                None = 15
            }​

    1c. Add a case to the GetEntityName function so it will display the zombies name. Here's what was suggested:


    You actually need to add 'CombatEntityType.ZombieNPC:' as follows:
                    case CombatEntityType.Player:
                        return StripRichText(entity.ToPlayer().displayName);
    
                    case CombatEntityType.Scientist:
                    case CombatEntityType.Murderer:
                    case CombatEntityType.Scarecrow:
                    case CombatEntityType.ZombieNPC:
                        var name = entity.ToPlayer()?.displayName;​

    That's it for DeathNotes.cs. Save that file.

  2.  In CombatEntityTypes.json (Folder path /oxide/data/DeathNotes/CombatEntityTypes.json), I also added "ZombieNPC" (same value of 19). I do not know how valuable it is to do this. I tested locking (as @hc4stillo02 suggests) and not locking the data files. There seems to be no impact either way.

    Anyway, here's the revised code:
    {
      "GunTrap": 6,
      "FlameTurret": 7,
      "AutoTurret": 7,
      "BaseHelicopter": 0,
      "BradleyAPC": 1,
      "BasePlayer": 5,
      "NPCMurderer": 3,
      "CodeLock": 12,
      "Scientist": 4,
      "ScientistNPC": 4,
      "HTNPlayer": 4,
      "NPCAutoTurret": 13,
      "FireBall": 11,
      "Scarecrow": 16,
      "ScientistNPCNew": 4,
      "zombieNPC": 18,
      "ZombieNPC": 19
    }​
    Note that I added ZombieNPC AND zombieNPC. Not sure if this matters as I don't reference zombieNPC anywhere else and the death messages work fine.
  3. In DeathNotes.json (Folder path /oxide/config/DeathNotes.json), I also added messages as follows:
      {
    	"KillerType": "Player",
    	"VictimType": "ZombieNPC",
    	"DamageType": "*",
    	"Messages": [
    	  "{killer} fought off and terminated {victim} using their {weapon}."
    	]
      },
      {
    	"KillerType": "ZombieNPC",
    	"VictimType": "Player",
    	"DamageType": "*",
    	"Messages": [
    	  "{killer} chased down {victim}, killed them with their {weapon}, and then ate their brains."
      ]
      },​

    Finally, I am getting a load error in RCON, but the plugin works as expected:

    Loaded plugin Death Notes v6.3.6 by LaserHydra
    [Death Notes] Could not load remote config 'CombatEntityTypes'. The plugin will be using the previously downloaded file.

Across the board support for other entity types would be huge... This manual implementation is pretty complex lol

wj3HSYaLDDX3DIC.png flintmonkey

I tried this fix and was _not_ able to get it working.... very interested in any config files that are able to make it work.

Merged post

Okay, I was finally able to get this working. Let's see if I can include steps to reproduce AND code snippets. I published my changes to github and also included a copy of my config file so you can check them out. 

First, @LizardMods is right and @k1lly0u's instructions work. I also made modifications to the data files based on @hc4stillo02's post above; not sure if they are needed or not.

  1. Modify DeathNotes.cs as follows:

    1a. Switch the order of these two statements as suggested so it checks type first:
    code

    Resulting code should look like:
                if (_combatEntityTypes.Contents != null)
                {
    
                    if (_combatEntityTypes.Contents.ContainsKey(entity.GetType().Name))
                        return _combatEntityTypes.Contents[entity.GetType().Name];
                                        
                    if (_combatEntityTypes.Contents.ContainsKey(entity.ShortPrefabName))
                        return _combatEntityTypes.Contents[entity.ShortPrefabName];
    
                }
    ​


    1b. Under internal enum CombatEntityType, you need to define ZombieNPC as a combat entity type. Here's my code:
            internal enum CombatEntityType
            {
                Helicopter = 0,
                Bradley = 1,
                Animal = 2,
                Murderer = 3,
                Scientist = 4,
                Scarecrow = 16,
                TunnelDweller = 17,
                UnderwaterDweller = 18,
                ZombieNPC = 19,
                Player = 5,
                Trap = 6,
                Turret = 7,
                Barricade = 8,
                ExternalWall = 9,
                HeatSource = 10,
                Fire = 11,
                Lock = 12,
                Sentry = 13,
                Other = 14,
                None = 15
            }​

    1c. Add a case to the GetEntityName function so it will display the zombies name. Here's what was suggested:


    You actually need to add 'CombatEntityType.ZombieNPC:' as follows:
                    case CombatEntityType.Player:
                        return StripRichText(entity.ToPlayer().displayName);
    
                    case CombatEntityType.Scientist:
                    case CombatEntityType.Murderer:
                    case CombatEntityType.Scarecrow:
                    case CombatEntityType.ZombieNPC:
                        var name = entity.ToPlayer()?.displayName;​

    That's it for DeathNotes.cs. Save that file.

  2.  In CombatEntityTypes.json (Folder path /oxide/data/DeathNotes/CombatEntityTypes.json), I also added "ZombieNPC" (same value of 19). I do not know how valuable it is to do this. I tested locking (as @hc4stillo02 suggests) and not locking the data files. There seems to be no impact either way.

    Anyway, here's the revised code:
    {
      "GunTrap": 6,
      "FlameTurret": 7,
      "AutoTurret": 7,
      "BaseHelicopter": 0,
      "BradleyAPC": 1,
      "BasePlayer": 5,
      "NPCMurderer": 3,
      "CodeLock": 12,
      "Scientist": 4,
      "ScientistNPC": 4,
      "HTNPlayer": 4,
      "NPCAutoTurret": 13,
      "FireBall": 11,
      "Scarecrow": 16,
      "ScientistNPCNew": 4,
      "zombieNPC": 18,
      "ZombieNPC": 19
    }​
    Note that I added ZombieNPC AND zombieNPC. Not sure if this matters as I don't reference zombieNPC anywhere else and the death messages work fine.
  3. In DeathNotes.json (Folder path /oxide/config/DeathNotes.json), I also added messages as follows:
      {
    	"KillerType": "Player",
    	"VictimType": "ZombieNPC",
    	"DamageType": "*",
    	"Messages": [
    	  "{killer} fought off and terminated {victim} using their {weapon}."
    	]
      },
      {
    	"KillerType": "ZombieNPC",
    	"VictimType": "Player",
    	"DamageType": "*",
    	"Messages": [
    	  "{killer} chased down {victim}, killed them with their {weapon}, and then ate their brains."
      ]
      },​

    Finally, I am getting a load error in RCON, but the plugin works as expected:

    Loaded plugin Death Notes v6.3.6 by LaserHydra
    [Death Notes] Could not load remote config 'CombatEntityTypes'. The plugin will be using the previously downloaded file.

pPPKTewfFwjAKT0.jpg hc4stillo02

This is long overdue but thanks to both of you I got it working. This was on the back burner of things for me to do.

for anyone who is wondering about the status of this thread, ZombieNPC has been added to the latest .cs file.

you might still need to make changes in the config and data file but it should work.

R0BKDRazGzzvByt.png LizardMods

This is long overdue but thanks to both of you I got it working. This was on the back burner of things for me to do.

for anyone who is wondering about the status of this thread, ZombieNPC has been added to the latest .cs file.

you might still need to make changes in the config and data file but it should work.

Glad you were able to get it working. I recently had to go through this _again_ and this time I did not add 'zombieNPC' this time around (only added 'ZombieNPC') and it worked correctly. 

Not sure if anything has changed, I couldnt get the data file changes to stick - would get overwritten everytime. Anyone still have this working?

flE0qYO76cA8nPj.jpg RickG

Not sure if anything has changed, I couldnt get the data file changes to stick - would get overwritten everytime. Anyone still have this working?

Make sure the plugin is unloaded before making any data file changes then save, then reload , if you make changes when plugin is running it wont save data changes and will revert back to original

nMyfFlEnglczTD3.jpg pookins

Make sure the plugin is unloaded before making any data file changes then save, then reload , if you make changes when plugin is running it wont save data changes and will revert back to original

This is how I do all my edits, thank you. 

Anyone still have this working?

euPbbPENkszK3OZ.png therustingdead

This is how I do all my edits, thank you. 

Anyone still have this working?

I still have it working.

QTO8uYaCzd2HGch.png flintmonkey

I still have it working.

same here

still working

it did throw an error

Failed to call hook 'OnFlameExplosion' on plugin 'DeathNotes v6.3.7' (NullReferenceException: Object reference not set to an instance of an object)
at Oxide.Plugins.DeathNotes.OnFlameExplosion (FlameExplosive explosive, BaseEntity baseEntity) [0x00000] in <696a19b6f891428488e298b432088916>:0

at Oxide.Plugins.DeathNotes.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x0023f] in <696a19b6f891428488e298b432088916>:0

at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <09575a60985045248bcb43b20faeeb99>:0

at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <bae5f1223fce49c493b01571c99dce02>:0

at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <bae5f1223fce49c493b01571c99dce02>:0
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

here in the null check fix. credit goes to Steenamaroo

private void OnFlameExplosion(FlameExplosive explosive, BaseEntity baseEntity)
{
    // add this
    if (baseEntity?.gameObject == null || explosive?.creatorEntity == null)
        return;
    //

    var flame = baseEntity.gameObject.AddComponent<Flame>();
    flame.Source = Flame.FlameSource.IncendiaryProjectile;
    flame.SourceEntity = explosive;
    flame.Initiator = explosive.creatorEntity;
}
puhEauZgsgkK163.png LizardMods

still working

it did throw an error

Failed to call hook 'OnFlameExplosion' on plugin 'DeathNotes v6.3.7' (NullReferenceException: Object reference not set to an instance of an object)
at Oxide.Plugins.DeathNotes.OnFlameExplosion (FlameExplosive explosive, BaseEntity baseEntity) [0x00000] in <696a19b6f891428488e298b432088916>:0

at Oxide.Plugins.DeathNotes.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x0023f] in <696a19b6f891428488e298b432088916>:0

at Oxide.Plugins.CSharpPlugin.InvokeMethod (Oxide.Core.Plugins.HookMethod method, System.Object[] args) [0x00079] in <09575a60985045248bcb43b20faeeb99>:0

at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x000d8] in <bae5f1223fce49c493b01571c99dce02>:0

at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00060] in <bae5f1223fce49c493b01571c99dce02>:0
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

here in the null check fix. credit goes to Steenamaroo

private void OnFlameExplosion(FlameExplosive explosive, BaseEntity baseEntity)
{
    // add this
    if (baseEntity?.gameObject == null || explosive?.creatorEntity == null)
        return;
    //

    var flame = baseEntity.gameObject.AddComponent<Flame>();
    flame.Source = Flame.FlameSource.IncendiaryProjectile;
    flame.SourceEntity = explosive;
    flame.Initiator = explosive.creatorEntity;
}

Just started to get this error since the wipe today,



Merged post

The null check fixed it

My combatentitytypes.json still overwrites itself everytime, but the plugin has been functioning perfectly regardless. I did follow all of the other steps.

{
  "GunTrap": 6,
  "FlameTurret": 7,
  "AutoTurret": 7,
  "BaseHelicopter": 0,
  "BradleyAPC": 1,
  "BasePlayer": 5,
  "NPCMurderer": 3,
  "CodeLock": 12,
  "Scientist": 4,
  "ScientistNPC": 4,
  "HTNPlayer": 4,
  "NPCAutoTurret": 13,
  "FireBall": 11,
  "Scarecrow": 16,
  "ScientistNPCNew": 4
}