Having issues getting my first mod to work (bloodfeed on animals)

Started by thenightgaunt, November 17, 2022, 09:45:44 AM

Previous topic - Next topic


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.

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

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.


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.


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


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.. You would need to modify the "verbProperties" section as well to include animals as target..