Beispiel #1
0
        private static void _Hook_SmithingCraft(CPURegisters ctx)
        {
            var temperForm = MemoryObject.FromAddress <BGSConstructibleObject>(ctx.SI);

            if (temperForm == null)
            {
                return;
            }

            float        amount = 0.0f;
            TESContainer req    = temperForm.Requirements;
            int          max    = req.ContainerEntriesCount;

            for (int i = 0; i < max; i++)
            {
                var entry = req.GetContainerEntry(i);
                if (entry == null)
                {
                    break;
                }

                int gold = entry.Item.GoldValue;
                if (gold <= 0)
                {
                    continue;
                }

                amount += gold * entry.Count;
            }

            var   plr   = PlayerCharacter.Instance;
            float skill = 5.0f;

            if (plr != null)
            {
                skill = plr.GetActorValue(ActorValueIndices.Smithing);
            }

            float value = 0.0f;
            var   item  = temperForm.CreatedItem;

            if (item != null)
            {
                value = item.GoldValue * temperForm.CreatedCount;
            }

            if (value < 0.0f)
            {
                value = 0.0f;
            }

            float xp = Formula_Smithing(value, amount, skill);

            if (xp < 0.0f)
            {
                xp = 0.0f;
            }

            if (Settings.DebugMode > 0)
            {
                WriteToDebugFile("Smithing: original XP was " + ctx.XMM2f.ToString(System.Globalization.CultureInfo.InvariantCulture) + " and we replaced it with " + xp.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }

            ctx.XMM2f = xp;
        }
Beispiel #2
0
        private static void _Hook_SmithingTemper(CPURegisters ctx)
        {
            TESForm item = null;
            {
                var ptr = Memory.ReadPointer(ctx.BX);
                if (ptr != IntPtr.Zero)
                {
                    ptr  = Memory.ReadPointer(ptr);
                    item = MemoryObject.FromAddress <TESForm>(ptr);
                }
            }

            double value = 0.0;

            if (item != null)
            {
                value = item.GoldValue;
            }

            if (value < 1.0)
            {
                value = 1.0;
            }

            float oldQuality = Memory.ReadFloat(ctx.BX + 0x18);
            float newQuality = Memory.ReadFloat(ctx.BX + 0x1C);

            var temperForm = MemoryObject.FromAddress <BGSConstructibleObject>(Memory.ReadPointer(ctx.BX + 0x10));

            if (temperForm == null)
            {
                return;
            }

            float        amount = 0.0f;
            TESContainer req    = temperForm.Requirements;
            int          max    = req.ContainerEntriesCount;

            for (int i = 0; i < max; i++)
            {
                var entry = req.GetContainerEntry(i);
                if (entry == null)
                {
                    break;
                }

                int gold = entry.Item.GoldValue;
                if (gold <= 0)
                {
                    continue;
                }

                amount += gold * entry.Count;
            }

            var   plr   = PlayerCharacter.Instance;
            float skill = 5.0f;

            if (plr != null)
            {
                skill = plr.GetActorValue(ActorValueIndices.Smithing);
            }

            float xp = Formula_Tempering((newQuality - oldQuality) * (float)value, amount, skill);

            if (xp < 0.0f)
            {
                xp = 0.0f;
            }

            if (Settings.DebugMode > 0)
            {
                WriteToDebugFile("Tempering: original XP was " + ctx.XMM2f.ToString(System.Globalization.CultureInfo.InvariantCulture) + " and we replaced it with " + xp.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }

            ctx.XMM2f = xp;
        }