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

Topics - venner

#1
Outdated / [A17] FuckFriendlyFire
July 14, 2017, 09:19:44 PM

(This mod has no requirements)

Don't you just hate it when a colonist shoots another accidentally?
With this mod, you can change the chance of pawns' and turrets' bullets from hitting each other accidentally.
You can change this in a 0-99% chance in the Mod Settings. 0% disables friendly fire completely.

It can stop bullets from hitting:


  • Your colonists
  • Your animals
  • Friendly factions

It doesn't stop bullets from hitting:


  • Enemies
  • Anything you specifically target

Downloads:
#2
Hi all,

I'm trying to replace ImpactSomething in Verse.Projectile with my own method. I'm using Harmony. Here's my code:

using Verse;
using Harmony;
using RimWorld;
using System.Linq;
using System;
using System.Reflection;
using UnityEngine;
using System.Collections.Generic;

namespace NoFriendlyFire
{
    [StaticConstructorOnStartup]
    class Main
    {
        static Main()
        {
            Log.Message("Patching");
            var harmony = HarmonyInstance.Create("venner.io.nofriendlyfire");
            harmony.PatchAll(Assembly.GetExecutingAssembly());
        }
    }

    [HarmonyPatch(typeof(Verse.Projectile), "ImpactSomething")]
    public static class NoFriendlyFirePatch
    {
       
        // Harmony stuff

        static void Prefix()
        {
            Log.Message("This works for some reason, but it's not what I need.");
        }

        static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
        {
            Log.Message("Replacing method");
            MethodBase from = typeof(Verse.Projectile).GetMethod("ImpactSomething", AccessTools.all);
            MethodBase to = typeof(NoFriendlyFirePatch).GetMethod("ImpactSomethingElse", AccessTools.all);
            return instructions.MethodReplacer(from, to);
        }

        // NoFriendlyFire method

        static void ImpactSomethingElse()
        {
            Log.Message("I would appreciate it if you actually worked");
        }

    }

}


It does not work. There's no errors. The "Patching" and "Replacing method" appear in console when the game is opened. "This works for some reason, but it's not what I need." appears when a projectile hits a pawn. "I would appreciate it if you actually worked" does not appear at all. Why is this? I've searched all over GitHub for a solution to this problem with no avail.