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 - AlexandrosPrice

#1
Help / Re: DefendBase Harmony Patch Help Please
February 07, 2020, 01:51:38 PM
Awesome! That worked! It's making them wait five days before counter-attacking! Thank you LWM and K! The only problem now is the fact that there was one single enemy pawn that aggro'd before all the others (you sure this shouldn't be a prefix?), the map tile un-select-ability (someone on discord said that the mod could be 'suppressing inputs'?), and the duplicate 'tabs'/alerts (how is this messing with the alerts?). p.s.-I'll work on the debug when I get back home.

Can I use this?:
https://ludeon.com/forums/index.php?topic=4664.0
#2
Help / Re: DefendBase Harmony Patch Help Please
February 07, 2020, 02:37:42 AM
I posted this to the Harmony Tools forum here:
Quote from: AlexandrosPrice on February 06, 2020, 02:24:56 PM
Alright, so I'm having some trouble with a Harmony mod.

using RimWorld;
using Harmony;
using Verse.AI.Group;
using System.Reflection;
using System.Linq;

namespace RimGetReady
{
    public class RimGetReadyMain
    {
        public static void DoRimGetReadyMain()
        {

            HarmonyInstance.Create("com.Steam.RimWorld.Mod.RimGetReady").PatchAll(Assembly.GetExecutingAssembly());

        }
   
    }
    [HarmonyPatch(typeof(LordJob_DefendBase))]
    [HarmonyPatch("CreateGraph")]
    public class LordJob_DefendBase_Patch
    {
        public static void Postfix(ref StateGraph __result)
        {
            Transition trans = __result.transitions.Last();
            trans.triggers.Clear();
            trans.AddTrigger(new Trigger_TicksPassed(GenDate.TicksPerDay * 5));
        }
    }
}

I'm very new to C# and modding. I've been getting help from the forum and the Rimworld Discord. But I've run into a problem. When I test this in game it doesn't allow me to select world tiles unless they are occupied and zoomed out, it creates duplicate side-tabs(ex: Low Food), and it doesn't do what the code says to do. Anyone know what I'm doing wrong? I was testing in a clean environment, so there shouldn't be any conflicts.
So yeah, even when the code is stripped to its bare bones, it still doesn't work. I even realized that the [StaticConstructorOnStartup] was missing, and put it in the code. But no dice. LWM, do you know what might be happening?
#3
Tools / Re: [LIB] Harmony v1.2.0.1
February 06, 2020, 02:24:56 PM
Alright, so I'm having some trouble with a Harmony mod.

using RimWorld;
using Harmony;
using Verse.AI.Group;
using System.Reflection;
using System.Linq;

namespace RimGetReady
{
    public class RimGetReadyMain
    {
        public static void DoRimGetReadyMain()
        {

            HarmonyInstance.Create("com.Steam.RimWorld.Mod.RimGetReady").PatchAll(Assembly.GetExecutingAssembly());

        }
   
    }
    [HarmonyPatch(typeof(LordJob_DefendBase))]
    [HarmonyPatch("CreateGraph")]
    public class LordJob_DefendBase_Patch
    {
        public static void Postfix(ref StateGraph __result)
        {
            Transition trans = __result.transitions.Last();
            trans.triggers.Clear();
            trans.AddTrigger(new Trigger_TicksPassed(GenDate.TicksPerDay * 5));
        }
    }
}

I'm very new to C# and modding. I've been getting help from the forum and the Rimworld Discord. But I've run into a problem. When I test this in game it doesn't allow me to select world tiles unless they are occupied and zoomed out, it creates duplicate side-tabs(ex: Low Food), and it doesn't do what the code says to do. Anyone know what I'm doing wrong? I was testing in a clean environment, so there shouldn't be any conflicts.
#4
Help / Re: DefendBase Harmony Patch Help Please
February 05, 2020, 02:35:10 PM
Okay, so this is what I have now:


using RimWorld;
using Harmony;
using Verse.AI.Group;
using Verse;
using System.Reflection;

namespace RimGetReady
{
    public class RimGetReadyMain
    {
        public static void DoRimGetReadyMain()
        {

            var harmony = HarmonyInstance.Create("com.Steam.Rimworld.Mod.RimGetReady");
            harmony.PatchAll(Assembly.GetExecutingAssembly());

        }
   
    }
    [HarmonyPatch(typeof(LordJob_DefendBase))]
    [HarmonyPatch("CreateGraph")]
    public class LordJob_DefendBase_Patch
    {
        public static StateGraph Postfix(ref StateGraph __result,Faction __faction, IntVec3 __baseCenter)
        {
            __result.transitions.Clear();
            LordToil_DefendBase lordToil_DefendBase = new LordToil_DefendBase(__baseCenter);
            LordToil_DefendBase lordToil_DefendBase2 = new LordToil_DefendBase(__baseCenter);
            LordToil_AssaultColony lordToil_AssaultColony = new LordToil_AssaultColony(true)
            {
                useAvoidGrid = true
            };
            Transition myTransition = new Transition(lordToil_DefendBase, lordToil_AssaultColony, false, true);
            myTransition.AddSource(lordToil_AssaultColony);
            myTransition.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            __result.AddTransition(myTransition, false);
            Transition myTransition2 = new Transition(lordToil_DefendBase, lordToil_AssaultColony, false, true);
            //myTransition2.AddTrigger(new Trigger_FractionPawnsLost(0.15f));
            //myTransition2.AddTrigger(new Trigger_PawnHarmed(0.2f, false, null));
            //myTransition2.AddTrigger(new Trigger_ChanceOnTickInteval(60000, 0.05f));
            myTransition2.AddTrigger(new Trigger_TicksPassed(300000));
            //myTransition2.AddTrigger(new Trigger_UrgentlyHungry());
            //myTransition2.AddTrigger(new Trigger_PawnExperiencingDangerousTemperatures());
            //myTransition2.AddTrigger(new Trigger_ChanceOnPlayerHarmNPCBuilding(0.5f));
            myTransition2.AddPostAction(new TransitionAction_WakeAll());
            string message = "MessageDefendersAttacking".Translate(__faction.def.pawnsPlural, __faction.Name, Faction.OfPlayer.def.pawnsPlural).CapitalizeFirst();
            myTransition2.AddPreAction(new TransitionAction_Message(message, MessageTypeDefOf.ThreatBig, null, 1f));
            __result.AddTransition(myTransition2, false);
            Transition myTransition3 = new Transition(lordToil_DefendBase2, lordToil_DefendBase, false, true);
            myTransition3.AddTrigger(new Trigger_BecamePlayerEnemy());
            __result.AddTransition(myTransition3, false);
            return __result;
        }
    }
}


It seems to still not be working. I have made sure that when I test, I just have the TicksPassed so that it is the only trigger. But they counter attack earlier than five days. Do I need to move the third transition back to after the first transition?
#5
Help / Re: DefendBase Harmony Patch Help Please
February 05, 2020, 01:34:36 AM
Yeah, but now its saying: "There is no argument given that corresponds to the required formal parameter 'match' of 'List<Transition>.RemoveAll(Predicate<Transition>)'" because there is nothing in between the ().
What "Predicate<Transition>"'s do I add after the RemoveAll?

Something like this?
(trans => trans.triggers.TrueForAll(new Trigger))
or
(new Transition(LordToil,LordToil,bool,bool));
#6
Help / Re: DefendBase Harmony Patch Help Please
February 04, 2020, 09:38:48 PM
Hmmm. I don't have a PatchAll but it seems like the patch is working anyway...
Where would I put it in the code? Is there anything that I'm doing that would negate the need for it?
#7
Help / Re: DefendBase Harmony Patch Help Please
February 04, 2020, 05:21:40 PM
In the documentation I said that my main class starts the mod, and the next { } after is where I created the Harmony instance. So I'm pretty sure that the instance.PatchAll(); is in there... I'll check when I get home.
#8
Help / Re: DefendBase Harmony Patch Help Please
February 04, 2020, 06:27:54 AM
I GOT IT!!! ;D
You are awesome K!
I'll be sure to give credit where credit is due when I try and submit this!
I don't know if I should keep all the triggers or values,  or if I should try and make a mod settings section. But I'll distribute this to get people to test it out.
#9
Help / Re: DefendBase Harmony Patch Help Please
February 04, 2020, 03:22:00 AM
So started with the creation of the mod and initialization of harmony in a 'Main'.

using System.Collections.Generic;
using System.Messaging;
using System.Reflection;
using Harmony;
using RimWorld;
using Verse;
using Verse.AI.Group;

namespace RimGetReady
{
    [StaticConstructorOnStartup]
    public class RimGetReadyMain
    {
        public HarmonyInstance instance = HarmonyInstance.Create("LordJob_DefendBase_Patch");
    }
}

And with your help I made this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RimWorld;
using RimWorld.Planet;
using UnityEngine;
using Harmony;
using Verse.AI.Group;
using Verse;

namespace RimGetReady
{
   
   
    [HarmonyPatch(typeof(LordJob_DefendBase))]
    [HarmonyPatch("CreateGraph")]
    public class LordJob_DefendBase_Patch
    {
        public static void Postfix(ref StateGraph __result, IntVec3 __baseCenter)
        {
            __result.transitions.RemoveAll(trans => trans.triggers.Count == 8);

        LordToil_DefendBase lordToil_DefendBase = new LordToil_DefendBase(__baseCenter);
            LordToil_DefendBase lordToil_DefendBase2 = new LordToil_DefendBase(__baseCenter);
            LordToil_AssaultColony lordToil_AssaultColony = new LordToil_AssaultColony(true);
            lordToil_AssaultColony.useAvoidGrid = true;
            Transition myTransition = new Transition(lordToil_DefendBase, lordToil_AssaultColony, false, true);
            myTransition.AddTrigger(new Trigger_BecameNonHostileToPlayer());
            __result.AddTransition(myTransition);
            Transition myTransition2 = new Transition(lordToil_DefendBase2, lordToil_DefendBase, false, true);
            myTransition2.AddTrigger(new Trigger_BecamePlayerEnemy());
            __result.AddTransition(myTransition2);
            Transition myTransition3 = new Transition(lordToil_DefendBase, lordToil_AssaultColony, false, true);
            myTransition3.AddTrigger(new Trigger_FractionPawnsLost(0.15f));
            myTransition3.AddTrigger(new Trigger_PawnHarmed(0.2f, false, null));
            myTransition3.AddTrigger(new Trigger_ChanceOnTickInteval(60000, 0.05f));
            myTransition3.AddTrigger(new Trigger_TicksPassed(300000));
            myTransition3.AddTrigger(new Trigger_UrgentlyHungry());
            myTransition3.AddTrigger(new Trigger_ChanceOnPlayerHarmNPCBuilding(0.5f));
            __result.AddTransition(myTransition3);
        }
    }
}

I figured that we'd have to remove all triggers and set up new transitions, should I not have?
When I tested it by sending an SRTS (Maybe a conflict with this?) to a faction base map, it froze at the "Creating map for new encounter". Do you know what might be the problem?

Oh, wait no, it worked! I mean it loaded the map, but the enemy immediately attacked...
So something must have happened or there's a conflict I guess. Would increasing the priority of the Harmony Instance help?

... or maybe somebody's just urgently hungry...
#10
Help / Re: DefendBase Harmony Patch Help Please
February 03, 2020, 04:44:40 PM
Thank you for responding, I've been getting some help  from the rimworld discord, but I have more questions. Making a class that runs the Harmony instance first right? Then use the __return function to get back the graph, but they were talking about "removing" the triggers from the code. I don't suppose you know a good example of Harmony in action with the __return.transition in use? Any help would be much appreciated , I've made a promise to myself of not playing my save until I make this mod. *And have it be stable XD I'll send what I have now soon, if that's alright with you, could you give me some tips? I have some programming experience, but not at all with C#.
#11
Help / DefendBase Harmony Patch Help Please
February 02, 2020, 07:29:08 AM
Hi everyone, I had requested an "Offensive Stealth/Detection Indicator" in the mod forum. I don't have much experience coding, but now I want to try and create the mod myself, but stripped down to just change the variables in the triggers for their counter attack. How would I go about patching the LordJob_DefendBase transitions with Harmony? So that the triggers for the third transition are now:

FractionPawnsLost(0.15f) //to make it so that if the enemy losses are at 15% and not 20%, they attack
PawnHarmed(0.2f, false, null) //to make it so that if enemies injured are 20% and not 30%, they attack
ChanceOnTickInterval(60000, 0.05f) //enemies check every day not every hour, with a 5% chance instead of 3% of detecting
TicksPassed(300000) //enemies will automatically attack after 5 days instead of 4.2 days
UrgentlyHungry() //keep this the same
ChanceOnPlayerHarmNPCBuilding(0.5f) //enemies will attack 50% of the time if you harm their stuff, not 40%

Just to re-balance the time that it takes to be detected by the enemies on their faction base map, but increase the risk in attacking first. As long as the enemies will automatically attack if colonists get in their weapon range, just making these changes is all I'm looking to have to do.

I've looked at the examples on the Harmony Ludeon page and the GitHub Harmony Wiki, but i'm still confused on how the patches are put together. And I don't understand how one would hook up the transpiler to the transition3.

Any help with this would be much appreciated!
#12
Mods / [Request] Offensive Stealth/Detection Indicator
January 30, 2020, 04:37:52 PM
Hi. I'm wondering if anyone could create a mod that displays how soon/likely enemies are to detect you on their faction base map. I asked a question on steam for reference: https://steamcommunity.com/app/294100/discussions/0/1749021365357321272/
I was told that detection may be influenced by line of sight (obviously), wealth, and caravan stealth on entering the map.
Or is really a random amount of time that they start counter-attacking?