How to make turrets target a pawn or faction?

Started by Evul, June 09, 2014, 12:12:18 PM

Previous topic - Next topic

Evul

How do i make a turret target a pawn or faction?

mrofa

You would need to make a new class for turrets, so basicly copy entire Building_turret.
And then change this line from "TryStartShoot" function
return pawn == null || ((pawn.RaceDef.humanoid || pawn.RaceDef.mechanoid) && !GenAI.MachinesLike(base.Faction, pawn));

If you kick out the humanoid part to it will shoot to animals :D
All i do is clutter all around.

Justin C

It's Building_TurretGun that you'll want to copy if you're replacing the vanilla turrets.

Another way is to make sure the faction is hostile and that its raiders are humanoids.

mrofa

If he change the class name or namespace then this wont replace ingame turrets
All i do is clutter all around.

Justin C

Quote from: mrofa on June 10, 2014, 05:01:15 PM
If he change the class name or namespace then this wont replace ingame turrets
The class name doesn't really matter (it's not possible to replace the old class, or to create a class with the same name in the same namespace). What matters is the ThingDef in the XML.

So you have a few options here. Changing the turrets will be pretty simple to do. Changing your enemies to make them shootable by the vanilla turrets will be a bit more difficult, but it will also ensure that your enemies are compatible with other turret mods and things like that.

If you want to turn your enemies into Humanoids you will likely run into a few issues, but it's still doable.

mrofa

Cool didnt know you can replace classes same way you can replace xml :D
All i do is clutter all around.

Justin C

You can replace the class used by an object in the XML. That's pretty much it.