Scarecrow loot not changeable

Hello,

I have tried to get help from Discord, from plugin developers related to loot plugins on my server and I have had no help from anyone so I'm trying here. It seems like the Scarecrow is not sending data to the OnCorpsePopulate hook in order for AlphaLoot or any plugin for that matter, to modify the vanilla loot they have. Is anyone else seeing this and have a fix for it?

I tried to create a simple fix plugin and when they die, I get nothing, when I shoot Scientists I get data here in the puts statements.

private void OnCorpsePopulate(ScarecrowNPC player, NPCPlayerCorpse corpse)
        {
            Puts(player.ShortPrefabName + " " + player.PrefabName);
            Puts(corpse.ShortPrefabName + " " + corpse.PrefabName);
            if (corpse.PrefabName == "assets/prefabs/npc/murderer/murderer_corpse.prefab")
            {
                ItemContainer container = corpse.containers[0];
                for (int i = container.itemList.Count - 1; i >= 0; i--)
                {
                    Item item = container.itemList[i];
                    var shortname = item.info.shortname;
                    var category = item.info.category.ToString();
                    if (item.info.stackable > 1)
                    {
                        int itemMultiplier = 100;
                        item.amount *= itemMultiplier;
                    }
                }

            }
            return;

        }​

check

container.itemList.Count​

to see if there is any loot in there Puts(container.itemList.Count.ToString());

Yep, that doesn't work either, the hook is not called at all, someone finally gave me the heads up that it's not passing corpse but an string prefab...I tried this and it will not work as containers is null and crashing the hook. The containers below crashes the hook and gives errors on null. So I tried to cound the containers and it's null. It almost looks like I have to create the containers with this method?

 private NPCPlayerCorpse OnCorpsePopulate(BasePlayer entity, string prefab)
        {
            Puts(prefab);
            NPCPlayerCorpse npcPlayerCorpse = entity.DropCorpse(prefab) as NPCPlayerCorpse;
            Puts(entity.ShortPrefabName + " " + entity.PrefabName);
            Puts(npcPlayerCorpse.ShortPrefabName + " " + npcPlayerCorpse.PrefabName);
            npcPlayerCorpse.SetLootableIn(2f);
            npcPlayerCorpse.name = "scarecrow";
            //npcPlayerCorpse.containers            
            if (npcPlayerCorpse.PrefabName == "assets/prefabs/npc/murderer/murderer_corpse.prefab")
            {
                global::HumanNPC theNPC = GameManager.server.FindPrefab("assets/prefabs/npc/scarecrow/scarecrow.prefab").GetComponent<global::HumanNPC>();
                LootSpawnSlots = theNPC.LootSpawnSlots;
                Puts(LootSpawnSlots.Length.ToString());
                if (this.LootSpawnSlots != null && this.LootSpawnSlots.Length != 0)
                {
                    foreach (LootContainer.LootSpawnSlot lootSpawnSlot in this.LootSpawnSlots)
                    {
                        for (int index = 0; index < lootSpawnSlot.numberToSpawn; ++index)
                        {
                            if ((double)UnityEngine.Random.Range(0.0f, 1f) <= (double)lootSpawnSlot.probability)
                                lootSpawnSlot.definition.SpawnIntoContainer(npcPlayerCorpse.containers[0]);
                        }
                    }
                }

                

            }

            return npcPlayerCorpse;

        }​

take a look in npcraiders public override BaseCorpse CreateCorpse() see if that helps

idn if the hook changed but doc. shows it as

BaseCorpse OnCorpsePopulate(BasePlayer npcPlayer, BaseCorpse corpse)
{
    Puts("OnCorpsePopulate works!");
    return null;
}​


if so you could always

        private void OnEntitySpawned(BaseNetworkable entity)
        {
            if (entity.name.Contains("corpsnamehere"))
            {
                BaseCorpse corpse = entity as BaseCorpse;

            }
        }


here is what i am doing in npc hourses

        private void OnEntitySpawned(BaseNetworkable entity)
        {
            if (entity.name.Contains("horse.co"))
            {
                BaseCorpse corpse = entity as BaseCorpse;
                NextTick(() =>
                {
                    if (corpse != null)
                    {
                        foreach (var key in deathLocation.ToList())
                        {
                            if (Vector3.Distance(corpse.transform.position, key.Key) < 1.5f)
                            {
                                LootableCorpse component = corpse.GetComponent<LootableCorpse>();
                                if (component != null)
                                    foreach (ItemContainer containers in component.containers)
                                        ClearContainer(containers);
                                deathLocation.Remove(key.Key);
                                break;
                            }
                        }
                    }
                });
            }
        }