Ludeon Forums

RimWorld => Mods => Topic started by: thenightgaunt on November 17, 2022, 09:45:44 AM

Title: Having issues getting my first mod to work (bloodfeed on animals)
Post by: thenightgaunt on November 17, 2022, 09:45:44 AM
I'm trying to learn how to mod rimworld and I've been following some tutorials. I'm trying to start out with something that seems like a simple concept but might not be that simple in reality.
I want to add animals as a valid target that sanguophages can use the bloodfeed ability on.

I found the file with the value that I need to patch (biotech/defs/abilitydefs/abilities.xml)
So I'm trying to patch into that the ability to target animals.

<Patch>
<Operation Class="PatchOperationAdd">
<xpath>/Defs/AbilityDef[defName = "Bloodfeed"]/verbProperties/targetParams</xpath>
<value>
<canTargetAnimals>True</canTargetAnimals>
</value>
</Operation>
</Patch>


I've got to the point where it's not throwing out errors in the log. But when testing in-game, it doesn't seem to work. If I target an animal the red "no" circle appears around it and the error message "cannot target animals only humans" pops up on the screen.

So I'm not sure if I messed up with my patch code there, or if I'm missing a value somewhere else that needs to be changed instead.

The error message makes me think that I need to be patching a different file as well, but I'm not sure which. Where would targeting rules be stored?

Thank you.
Title: Re: Having issues getting my first mod to work (bloodfeed on animals)
Post by: Kopp on November 18, 2022, 11:21:29 AM
I was curious and took a peek what might be the issue, so I am not sure if I am correct here:

It seems that the class CompProperties_AbilityBloodfeederBite checks if the target is humanlike or not at some point.
So I dont think that you can solve that issue with xml. But I may be wrong.
Title: Re: Having issues getting my first mod to work (bloodfeed on animals)
Post by: LWM on February 21, 2023, 01:41:10 PM
Yeah, you would have to use C# and Harmony to modify RimWorld/CompAbilityEffect_BloodfeederBite's Valid(...) function.  You could use a Harmony prefix, and test if it's an animal and if it's a valid animal, then skip the vanilla Valid(...) function and give your result.

It wouldn't be too hard, all things considered, but it would require setting up the C# environment
Title: Re: Having issues getting my first mod to work (bloodfeed on animals)
Post by: vincentlnalls on April 23, 2023, 01:08:00 PM
If the "Bloodfeed" ability is defined to only target humans in its "verbProperties" section, then your patch code won't be enough to make it work on animals. (https://ropeheroapk.com/). You would need to modify the "verbProperties" section as well to include animals as target..