[Mod Request]Combat Caculation Change: PostArmorDamage(dll)

Started by trulypanda, February 04, 2018, 07:09:20 AM

Previous topic - Next topic

trulypanda

https://ludeon.com/forums/index.php?topic=38838.0

In B18, there is hidden protection system for outside body parts,
When damage higher than limb's hp, there is chance to reduce damage result hp left 1;
It means one-single attack to destroy head chance is lower and lower than A17 version.

It could changed by editing origin Assembly-CSharp.dll file.
Keyword: ReduceDamageToPreserveOutsideParts, postArmorDamage
postArmorDamage = (float)(num-1) changed to postArmorDamage = (float)num

After changed, one-single attack could destroy body-parts;
I wanted create smaller dll files to patch origin function like mods do,
however I don't had any experience for c++ & vb.
After tried few days, I gave up;
If someone could take over the work, please share & upload, thanks.

Mehni

You're probably the only person interested in this, but I needed the practice.

Source included, but if anyone can't be bothered to download the zip (or, just as likely, the attachment got deleted), here's the source in full:


using Verse;
using Harmony;

namespace PostArmorDamage
{
    [StaticConstructorOnStartup]
    static class HarmonyPatches
    {

        static HarmonyPatches()
        {
            HarmonyInstance harmony = HarmonyInstance.Create("mehni.rimworld.postarmordamage.main");

            harmony.Patch(AccessTools.Method(typeof(DamageWorker_AddInjury), "ReduceDamageToPreserveOutsideParts"),
                new HarmonyMethod(typeof(HarmonyPatches), nameof(ReduceDamageToPreserveOutsideParts_Prefix)), null, null);
        }

        private static bool ReduceDamageToPreserveOutsideParts_Prefix(ref float __result, ref float postArmorDamage)
        {
            __result =  postArmorDamage;
            return false;
        }
    }
}


License: Public domain.

[attachment deleted due to age]

trulypanda

Thanks Mehni,
I tried it for days and I don't know how to thank you enough;
I believe not only I interested when someone found out his 50 cal could not explode pawn's head.
Please upload on steam for share; thanks.

Mehni

Too niche for me to upload on Steam, but if you or anyone else wants to they have my permission.