How to differentiate between mechanoids and other pawns in C#?

Started by Desmond, June 25, 2023, 04:11:57 PM

Previous topic - Next topic

Desmond

After following the plague gun tutorial, I changed the Hediff to anesthesia to effectively make a stun gun similar to those in just about any sci-fi show in existence.

This works rather well, but there is one problem.

It works on mechanoids as well.

Now, while seeing a mechanoid get downed due to being anesthetized is rather entertaining, it's also not at all the functionality I want as a part of the mod.

So how could I tell the projectile I'm using to not affect pawns based on their type/verbs/race/faction etc..?

Kopp

The plague gun tutorial I found and refer to:
https://rimworldwiki.com/wiki/Modding_Tutorials/Plague_Gun_(1.1)#Writing_the_Projectile

In 5.3.1 you can find the projectile class with a method that defines what happens on impact.

There is the line
   if (Props != null && hitThing != null && hitThing is Pawn hitPawn)

Simply add another condition to the statement, so it returns false if the pawn is a mech:
   if (Props != null && hitThing != null && hitThing is Pawn hitPawn && !hitPawn.RaceProps.IsMechanoid)

Desmond