jpw1991 / chebs-necromancy

Cheb's Necromancy adds Necromancy to Valheim via craftable wands and structures. Minions will follow you, guard your base, and perform menial tasks.
The Unlicense
10 stars 4 forks source link

DropOnDeath=Everything may not properly consider quantity #225

Closed jpw1991 closed 11 months ago

jpw1991 commented 1 year ago

Configuring a DropOnDeath value of Everything will correctly return all ingredients used to create a skeleton, but does not seem to correctly return the quantities. For example: Creating a fire archer consumes 6 bones and 10 fire arrows, but on death, it is only dropping 1 bone and 1 fire arrow.

This bug discovered while debugging issue #224


To reproduce:

jpw1991 commented 11 months ago

Further testing indicates it only happens if crates are not being used too.

jpw1991 commented 11 months ago

Huh. So the plot thickens:

[Info   :ChebsNecromancy.Patches.CharacterDrop_Patches] Drops zdo = BoneFragments:6,ArrowFire:10,BlackMetal:1
[Info   :ChebsNecromancy.Patches.CharacterDrop_Patches+<>c] Drop BoneFragments min=6 max=6 chance=1
[Info   :ChebsNecromancy.Patches.CharacterDrop_Patches+<>c] Drop ArrowFire min=10 max=10 chance=1
[Info   :ChebsNecromancy.Patches.CharacterDrop_Patches+<>c] Drop BlackMetal min=1 max=1 chance=1
namespace ChebsNecromancy.Patches
{
    [HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
    class CharacterDrop_Patches
    {
        [HarmonyPrefix]
        static void AddBonesToDropList(ref List<CharacterDrop.Drop> ___m_drops, CharacterDrop __instance)
        {
            ...

            /// dumb testy
            var undeadm = __instance.GetComponent<UndeadMinion>();
            if (undeadm != null)
            {
                var drops = undeadm.GetComponent<ZNetView>()?.GetZDO().GetString(ChebGonazMinion.MinionDropsZdoKey, "");
                Jotunn.Logger.LogInfo($"Drops zdo = {drops}");

                var characterDrop = __instance.GetComponent<CharacterDrop>();
                characterDrop.m_drops.ForEach(d => Jotunn.Logger.LogInfo($"Drop {d.m_prefab.name} min={d.m_amountMin} max={d.m_amountMax} chance={d.m_chance}"));
            }
            /// dumb testy
        }
    }
}