Trying to limit apparel to a particular Faction

Started by Rafe009, September 07, 2016, 06:23:39 PM

Previous topic - Next topic

Rafe009

I'm customizing a few mods here and have been able to to quite a bit more than i expected but have run into a major problem. One of the mods (Rimarsenal  feral) i'm using creates a custom faction and with that offers guns and apparel that are thematically associated with that faction. The mod itself DOES NOT, however, restrict either the weapons or the apparel and they are effectively ubiquitous and spawn with vanilla tribals and pirates alike.

I have managed to restrict all firearms and melee to the modded faction however the apparel is causing me tremendous problems.

I assume this must be possible because in the CORE tribals somehow have the TRibalA outfit restricted to only them. I tried working backwards and came up with a few alterations but all of them have failed and the modded apparel is unassailable - it defies restriction and wishes to spawn on every other faction. Specifically i notice it emulating tuques and spawning only in the winter

Some of the designations and actual references to item names have been changed in case licensing is an issue.

  <ThingDef ParentName="HatBase">
    <defName>Apparel_HeadGear</defName>
    <label>Headgear</label>
    <description>something for heads</description>
    <graphicData>
      <texPath>Apparel/Headgear</texPath>
      <graphicClass>Graphic_Single</graphicClass>
    </graphicData>
    <statBases>
      <ArmorRating_Blunt>0.09</ArmorRating_Blunt>
      <ArmorRating_Sharp>0.04</ArmorRating_Sharp>
      <Insulation_Heat>5</Insulation_Heat>
      <Insulation_Cold>-8</Insulation_Cold>
    </statBases>
    <equippedStatOffsets>
      <SocialImpact>-0.2</SocialImpact>
    </equippedStatOffsets>
    <apparel>
      <bodyPartGroups>
        <li>FullHead</li>
      </bodyPartGroups>
      <worngraphicPath>Apparel/HeadGear</worngraphicPath>
      <layers>
        <li>Overhead</li>
      </layers>
      <commonality>1</commonality>
      <tags>
        <li>ModedFactionOutfit</li>
      </tags>
      <defaultOutfitTags>
        <li>Soldier</li>
      </defaultOutfitTags>
    </apparel>
  </ThingDef>


At this point i've tried many things, i tried redirecting the hatbase to a new base I made up. I deleted defaultOutfitTags and it's contents under the assumption that it this was the culprit that was essentially allowing any default "soldier" to grab the item and wear it, that still didn't' work. Trying to change ModedFactionOutfit caused errors but this field references nothing in vanilla and i can't find a reference for it in the mod.  If anybody could help i would appreciate it.

gamerphate

      <defaultOutfitTags>
        <li>Soldier</li>
      </defaultOutfitTags>

This person wears Soldier tagged gear.

Look through the Core Defs and find the list of Wearable things.
Find an item that you want them to wear and change Soldier to that items Tag instead.

In my mod, I did this by making my own items to wear and setting them to all wear that item.

Rafe009

#2
I'm not sure i understand you. Are you under the assumption that

a) I want a modded faction to wear vanilla clothing?
b) I want a vanilla faction to NOT wear modded clothing?

It's b. in fact the Defaultoutfittags entry you are responding to is an entry for apparel, this data is not about pawns.

I have vanilla tribals that are spawning in with non-vanilla/modded clothing. Normally vanilla raiders wear Tuques in the winter. This excerpt was taken directly from Core under things_misc, apparel for the entry related to tuque
      <defaultOutfitTags>
        <li>Worker</li>
        <li>Soldier</li>
      </defaultOutfitTags>


I have not altered core at all but in fact have been scouring it desperately trying to recreate the behavior that tribal garments exhibit so i can reverse engineer that to ensure only modded faction infantry wear modded clothing. As  you can see the item i want tribals to wear, the tuque already has the soldier tag.

I have removed the soldier tag from the modded clothing entries hoping that would hide it from Vanilla pawns but short of deleting the mod EVERY pawn will use the modded/non-vanilla garments.

Edit: the more i play around with this the more i'm beginning to suspect that somethign is countermanding or overwritting permissions here. Somebody noted in another thread on apparel i searched that pawns will select a clothign item based on it's stats - i'm not sure this is true - but if it is is migth explain what's happening here. I'm testing during the winter and summer on boreal and temperate respectively.

During mild weather this behavior doesn't manifest, tribals have no headgear, the modded wear their designated modded equipment. When i change the conditions to cold and spawn suddenly everybody, Vanilla and modded factions alike will take the modded headwear and i suspect that some <stats> element is making it more favorable and overriding normal assignment behavior. This is only a guess.

gamerphate

#3
Then the trouble is with the modded items themselves. 

Do a search for Tag in the defs for the wearables.
I suspect that its set to a vanilla name and one of the factions has that name as well.

Edit - looked at your posting again -

That code you have is the TYPE of Worker of an unit and not the "Tag" for the style.
I believe its just above that a few lines usually.

Here is an example:

         <tags>
            <li>Storm_Trooper</li>
         </tags>
         <defaultOutfitTags>
            <li>Worker</li>
         </defaultOutfitTags>


You want the TAG, not the OutfitTag ..  I know its weird.


kaptain_kavern

#4
What pawns will use and wear is defined in the <PawnKindDef> tag

See here from Defs/PawnKindDefs_Humanlikes/PawnKinds_Pirate.xml
Quote<PawnKindDef Name="PirateBase" Abstract="True">
    <race>Human</race>
    <defaultFactionType>Pirate</defaultFactionType>
    <backstoryCategory>Raider</backstoryCategory>
    <baseRecruitDifficulty>0.65</baseRecruitDifficulty>
    <chemicalAddictionChance>0.10</chemicalAddictionChance>
    <backstoryCryptosleepCommonality>0.1</backstoryCryptosleepCommonality>
    <invNutrition>2.55</invNutrition>
    <apparelTags>
      <li>Outlander</li>
    </apparelTags>

  </PawnKindDef>

This one will wear apparels that are tagged with Outlander.   So for your particular problem I guess you have to remove vanilla tags from the modded weapons/apparels


Edit: DefaultOutfit is used for the apparels restriction menu used with your colonist

Rafe009

This is the exact code from the mod for one of the modded headgear items

<tags>
        <li>FeralOutfit</li>
      </tags>
      <defaultOutfitTags>
        <li>Soldier</li>
      </defaultOutfitTags>


This is the exact code from the VANILLA game from the Core>Defs>Things_misc within the file apparel_various for the entry on Apparel_TribalA (the tribal outfit)

<tags>
        <li>Tribal</li>
      </tags>


As you can see the is no overlap and there is no reason why the Tribals or pirates are suddenly being chaperoned or guided toward modded items because the tag FeralOutfit could not possibly exist in the vanilla game unless it's by strange coincidence. It's a special modded tag.
Quote from: kaptain_kavern on September 08, 2016, 12:20:20 AM
snip

This is from Core/Def/Pawnkinds_humanlikes in the file Pawnkinds_tribal

 
Quote<apparelTags>
      <li>Tribal</li>
    </apparelTags>

This is from Modded/Def/Thingsdefs from the file  Apparel_modded for the modded headgear the is behaving with unrelenting promiscuity and ending up on everybodies heads but only in winter.

Quote<tags>
        <li>FeralOutfit</li>
      </tags>

As you can see the modded apparel makes no reference to vanilla gear but creates an alien tag. Despite this putative restriction – if it is a restriction -  These garments have unrelentingly grappled at the faces of whoever happens to spawn into my map as long as it's winter
I scoured  pretty much all the apparel tags, files, in mod folders or Core atleast a dozen times and these modded items will persist onto the heads of any pawn be they modded or totally vanilla when the weather get's cold in rimworld. This is why I'm beginning to suspect that something is overriding clothing selection to ensure pawns don't freeze as there was a time that Tynaan had stated that pawns will not show up on ICE sheets and start losing toes and fingers, they arrive with parkas. 

I suspect something deeper in the code is ignoring all these TAGS  and just looking for the best item to wear, in an unmodded rimworld that would be tuques, with this particular mod it's the hoods/headgear.

I'm out of ideas at this point, thanks for  the help though but i'm about ready to call this one a defeat. Defeated by clothing!! >:(

kaptain_kavern

There also is this tag  in PawnKindDefs_Humanlikes :   <apparelAllowHeadwearChance>

If never truly understand what it means exactly. But maybe like you said it choose from a possible Headwear regardless of how it's tagged.

This is happening only with headgear types apparels right?

If I find the courage too I will try to look at the C# parts of code  that use this tag (I'm really bad at C# ^^)

Rafe009

Yeah i'm looking at that now  <apparelAllowHeadwearChance>0.7</apparelAllowHeadwearChance>

This entry is for a pirate. I think this just represents that this particular type of pirate, of which there are 4 types : Drifter, thrasher, scavenger, and pirate have various probabilities of wearing some sort of headgear, in this case a 70% chance. Still none of this is directly pointing to the new mod. I mean vanilla has no means to interface with the mod other than when install it manually.

I'm seeing other strange things. This mod Rimarsenal feral has different types of pawns too, each one has their own helmet but all of them ignore their assigned helmets when winter rolls around and they all wear the same uniformed helmet. I'm betting the Tynaan is overriding something in the code.

My last chance is to go into the Defs for the modded helmets and downgrade their stats so Tynaan's code just ignores them. I've actually never done much coding at all, not formally so i wouldn't know but thanks if  you do look into it.

Shinzy

you can have a select pawn ignore the seasonal changes with
    <apparelIgnoreSeasons>true</apparelIgnoreSeasons>
(Spacer/Colonist pawns use that)

But It does sound like the feral hat just has way too good cold insulation :p
if it spawns on vanilla people, aswell. You might want to let Rook1 know, aswell that's probably not intended, at all


Rafe009

Quote from: Shinzy on September 08, 2016, 07:29:52 AM
you can have a select pawn ignore the seasonal changes

Yeah but that would just be cheating as i would have tribals spawning in in tribal gear in a boreal forest in the middle of winter. Their toes would become necrotic by the time they to got to my defensive line.

I'm thinking my only real means of defeating these hoods is to just screw with their stats till they become unpalatable for pawns to select them prior to raids in the event of the weather override that's presumably causing pawns to ignore apparel restriction tags.

Adding a cost to them, reducing their cold insulation quality could possibly do the trick?

kaptain_kavern

Quote from: Rafe009 on September 08, 2016, 05:31:58 PM
Adding a cost to them, reducing their cold insulation quality could possibly do the trick?
I really think it will. Explanation seems to fit well with how I saw the game behave, provided they're really the only non price-tagged items.
If you add Shinzy explanations about having the same problem at some point with Apparello, I think it's like NekoEternal explained in the link I posted just above.
Quote from: NekoEternalnpc's are probably assembled with a budget target when they are spawned in, and those hoods being free probably makes it real easy for the algorythm to stuff them on just about everyone.