[Solved] How can I restrict specific apparel from traders' inventory?

Started by Granitecosmos, March 11, 2017, 08:26:02 PM

Previous topic - Next topic

Granitecosmos

Let's say I don't want Power Armor to appear in any trader's inventory so I can sell them one but I can't buy a new one from them.

But here's the catch: how do I do this without changing any of the TraderKinds.xml files?

RawCode

obviously code injection

probably you can inject custom code right into stock renderer, this will prevent ever power armor you just sold from appearing in trade dialog, but won't actually remove it from stock.

Granitecosmos

Too bad I have no idea how to do that.

Alternatively, creating a new ThingCategory for Power Armor removes it from the traders. It doesn't allow trading the item at all but that's not a big deal. The new problem is that the outfit manager seems to point to the Apparel ThingCategory only. So how do I change the outfit manager to include another ThingCategory?

RawCode

you can't have new logic or replace existing with XML period

Granitecosmos

I think I've found what I need. In OutfitDatabase:
outfit.filter.SetAllow(ThingCategoryDefOf.Apparel, true)

So if I make a new ThingCategory defined as PowerArmor in ThingCategories.xml and then somehow add
outfit.filter.SetAllow(ThingCategoryDefOf.PowerArmor, true)
in there, it might work.

The problem is, I don't know how to add that with a DLL. Could someone help me out?

EDIT: Sometimes the solution is right in front of us, yet we fail to notice. Ever wondered why traders never have Tribalwear for sale?

The answer is the
<tradeability>Sellable</tradeability>
line in the xml.