Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - DaStormDragon

#1
Tools / Re: [LIB] Harmony v1.2.0.1
April 12, 2020, 05:46:48 PM
It works! Thanks!
#2
Tools / Re: [LIB] Harmony v1.2.0.1
April 12, 2020, 11:31:13 AM
I get a bunch of 'CS0103 The name 'pawn' does not exist in the current context' errors doing that.
#3
Tools / Re: [LIB] Harmony v1.2.0.1
April 12, 2020, 10:38:44 AM
Me again, sorry.
Tried this:

static void Postfix(Pawn otherPawn, Pawn pawn, ref float __result)
        {
            if (!LoadedModManager.RunningModsListForReading.Any(x => x.Name == "[RF] Rational Romance (Continued)"))
            {
                if (pawn.def is ThingDef_AlienRace alienProps && alienProps.alienRace.generalSettings.immuneToAge && pawn.ageTracker.AgeBiologicalYearsFloat >= 18 && otherPawn.ageTracker.AgeBiologicalYearsFloat >= 18)
                {
                    if (pawn.def != otherPawn.def || pawn == otherPawn)
                    {
                        __result = 0f;
                    }
                    if (pawn.story != null && pawn.story.traits != null)
                    {
                        if (pawn.story.traits.HasTrait(TraitDefOf.Asexual))
                        {
                            __result = 0f;
                        }
                        if (!pawn.story.traits.HasTrait(TraitDefOf.Bisexual))
                        {
                            if (pawn.story.traits.HasTrait(TraitDefOf.Gay))
                            {
                                if (otherPawn.gender != pawn.gender)
                                {
                                    __result = 0f;
                                }
                            }
                            else if (otherPawn.gender == pawn.gender)
                            {
                                __result = 0f;
                            }
                        }
                    }
                    float num = 0.2f;
                    float num4 = 0f;
                    if (otherPawn.RaceProps.Humanlike)
                    {
                        num4 = otherPawn.GetStatValue(StatDefOf.PawnBeauty);
                    }
                    float num5 = 1f;
                    if (num4 < 0f)
                    {
                        num5 = 0.3f;
                    }
                    else if (num4 > 0f)
                    {
                        num5 = 2.3f;
                    }
                    __result = num * num5;
                }
            }
        }

but got this error:

### Patch: System.Single RimWorld.Pawn_RelationsTracker::SecondaryLovinChanceFactor(Verse.Pawn otherPawn)
### Replacement: static System.Single RimWorld.Pawn_RelationsTracker::SecondaryLovinChanceFactor_Patch1(RimWorld.Pawn_RelationsTracker this, Verse.Pawn otherPawn)
### Exception from user "rimworld.dsd.archai", Harmony v2.0.0.8
### Original: System.Single RimWorld.Pawn_RelationsTracker::SecondaryLovinChanceFactor(Verse.Pawn otherPawn)
### Patch class: Archai.Pawn_RelationsTracker_LovinChance
### System.Exception: Parameter "pawn" not found in method System.Single RimWorld.Pawn_RelationsTracker::SecondaryLovinChanceFactor(Verse.Pawn otherPawn)
###   at HarmonyLib.MethodPatcher.EmitCallParameter (System.Reflection.MethodInfo patch, System.Collections.Generic.Dictionary`2[TKey,TValue] variables, System.Boolean allowFirsParamPassthrough) [0x00539] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.MethodPatcher+<>c__DisplayClass31_0.<AddPrefixes>b__0 (System.Reflection.MethodInfo fix) [0x00069] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.CollectionExtensions.Do[T] (System.Collections.Generic.IEnumerable`1[T] sequence, System.Action`1[T] action) [0x00014] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.MethodPatcher.AddPrefixes (System.Collections.Generic.Dictionary`2[TKey,TValue] variables, System.Reflection.Emit.LocalBuilder runOriginalVariable) [0x00033] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.MethodPatcher.CreateReplacement (System.Collections.Generic.Dictionary`2[System.Int32,HarmonyLib.CodeInstruction]& finalInstructions) [0x0015d] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) [0x00057] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.PatchClassProcessor.ProcessPatchJob (HarmonyLib.PatchJobs`1+Job[T] job) [0x0015d] in <2161c8330234450b8141397c32c11571>:0
### Exception from user "rimworld.dsd.archai", Harmony v2.0.0.8
### Original: System.Single RimWorld.Pawn_RelationsTracker::SecondaryLovinChanceFactor(Verse.Pawn otherPawn)
### Patch class: Archai.Pawn_RelationsTracker_LovinChance
### System.Exception: Parameter "pawn" not found in method System.Single RimWorld.Pawn_RelationsTracker::SecondaryLovinChanceFactor(Verse.Pawn otherPawn)
###   at HarmonyLib.MethodPatcher.EmitCallParameter (System.Reflection.MethodInfo patch, System.Collections.Generic.Dictionary`2[TKey,TValue] variables, System.Boolean allowFirsParamPassthrough) [0x00539] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.MethodPatcher+<>c__DisplayClass31_0.<AddPrefixes>b__0 (System.Reflection.MethodInfo fix) [0x00069] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.CollectionExtensions.Do[T] (System.Collections.Generic.IEnumerable`1[T] sequence, System.Action`1[T] action) [0x00014] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.MethodPatcher.AddPrefixes (System.Collections.Generic.Dictionary`2[TKey,TValue] variables, System.Reflection.Emit.LocalBuilder runOriginalVariable) [0x00033] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.MethodPatcher.CreateReplacement (System.Collections.Generic.Dictionary`2[System.Int32,HarmonyLib.CodeInstruction]& finalInstructions) [0x0015d] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.PatchFunctions.UpdateWrapper (System.Reflection.MethodBase original, HarmonyLib.PatchInfo patchInfo) [0x00057] in <2161c8330234450b8141397c32c11571>:0
###   at HarmonyLib.PatchClassProcessor.ProcessPatchJob (HarmonyLib.PatchJobs`1+Job[T] job) [0x0015d] in <2161c8330234450b8141397c32c11571>:0
#4
Tools / Re: [LIB] Harmony v1.2.0.1
April 12, 2020, 05:09:29 AM
Dammit. Apparently I need to modify a bunch of other things aswell. Sorry.
#5
Tools / Re: [LIB] Harmony v1.2.0.1
April 10, 2020, 05:30:30 AM
I get the message that it isn't overridden when it's two humans, but the mod doesn't affect the alien races I want it to
#6
Tools / Re: [LIB] Harmony v1.2.0.1
April 09, 2020, 05:01:50 PM
Yep. Checked the log, right place.

float centerY = 1.5f;
            centerY = Rand.Gaussian(centerY, 0.3f);
            if (centerY < 0.5f)
            {
                centerY = 0.5f;
            }
            ThingDef_AlienRace thingDef_AlienRace = ((Thing)pawn).def as ThingDef_AlienRace;
            if (thingDef_AlienRace != null && thingDef_AlienRace.alienRace.generalSettings.immuneToAge)
            {
                __result = (int)(centerY * 2500f);
                Log.Message("Debug: Age curve overridden");
            }
            Log.Message("Debug: Age curve not overridden");

Tried Log.Message, showed up as not overridden when two humans did it but no go for the mod.
#7
Tools / Re: [LIB] Harmony v1.2.0.1
April 09, 2020, 10:13:49 AM
Trying to make a patch that prevents ImmuneToAge races from suffering the reduced Lovin' chance from age, but I get: (IDE0051   Private member 'JobDriver_Lovin_GenerateRandomMinTicksToNextLovin.Postfix' is unused.) and the patch doesn't work.

using RimWorld;
using HarmonyLib;
using AlienRace;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using Verse;
using Verse.AI;

namespace Archai
{
    [StaticConstructorOnStartup]
    static class HarmonyPatches
    {
        static HarmonyPatches()
        {
            Harmony.DEBUG = true;
            var harmony = new Harmony("rimworld.dsd.archai");
            harmony.PatchAll(Assembly.GetExecutingAssembly());
            Log.Message("Test");
        }
    }

    [HarmonyPatch(typeof(JobDriver_Lovin), "GenerateRandomMinTicksToNextLovin")]
    public class JobDriver_Lovin_GenerateRandomMinTicksToNextLovin
    {
        static void Postfix(Pawn pawn, ref int __result)
        {
            float centerY = 1.5f;
            centerY = Rand.Gaussian(centerY, 0.3f);
            if (centerY < 0.5f)
            {
                centerY = 0.5f;
            }
            ThingDef_AlienRace thingDef_AlienRace = ((Thing)pawn).def as ThingDef_AlienRace;
            if (thingDef_AlienRace != null && thingDef_AlienRace.alienRace.generalSettings.immuneToAge)
            {
                __result = (int)(centerY * 2500f);
            }
        }
    }
}
#8
When there is a compatibility patch for humanoid alien framework, it will be awesome. Aliens are better than toddlers on the rimworlds I think