"Sticky" clothing possible? Permanent irremovable apparel needed!

Started by joaonunes, June 01, 2016, 06:22:49 AM

Previous topic - Next topic

joaonunes

Hey  8)

I want to change my mustache mod so it will be independent from the heads textures, and mustaches would be added as Things instead of Heads.

The thing is, the mustaches should be able o be spawned at the start (like normal apparel) or "equipped" later on (because some men can choose to grow a mustache ;D), and be only possible to remove the mustache by using something similar to a surgery (pretend it is a barber ::))

Is this possible at all?

Maybe it could be like a prosthetic that is visible, or a piece of clothing similar to sunglasses that you can only remove by using some item (razors)?

Any help will be appreciated :)
Do you want your colonists to look manlier?
Get a free mustache sample here!

joaonunes

Quote from: pestilenz on June 01, 2016, 09:02:00 AM
Maybe as some kind of HeDiff, like a scar attached to the body part?

Yes, but is it possible to make it visible?
That is in other words what I could do...
Do you want your colonists to look manlier?
Get a free mustache sample here!

joaonunes

Quote from: pestilenz on June 01, 2016, 09:08:34 AM
Just edited m last reply. Should be possible. I haven't looked at your mod yet, but I guess it requires dll generation and not only xml.

Thanks, will look it up once I have some time available :D With so much school work to do I only have time to post stuff on the forums and try to look at "some" code...
Do you want your colonists to look manlier?
Get a free mustache sample here!

joaonunes

Quote from: pestilenz on June 01, 2016, 09:02:00 AM
Maybe as some kind of HeDiff, like a scar attached to the body part?

Some diseases have an invisible stage0, like pregnancy or flu, so this is not visible ingame but existent on the health stat. From there you could try something like <if HediffDeffWithComps = "Mustache" ... DrawTexture xy>.

Gave a quick look at this and the idea sounds great, and I am already aware that dll generation is necessary, it already was with my previous idea, but I am still headbanging at the rendering code to find out how will I render my mustaches in the right places... I need to take a more serious look at the way facial gear like glasses is rendered, maybe that way I can salvage some code or force my way into tricking the game to think the mustaches are goggles or something... :P
Do you want your colonists to look manlier?
Get a free mustache sample here!

joaonunes

The code appears to make the rendering according to the face types (average or narrow) automatically, so in theory I'd only need to put the mustaches in the correct position (centered?) in the 128x128 pixel image, just like what happens with hats, goggles, etc...
Do you want your colonists to look manlier?
Get a free mustache sample here!

RawCode

just hook 3 methods:

equpment to prevent replacement
drop to prevent dropping
and strip to prevent stripping from dead bodies

???

done

joaonunes

Quote from: RawCode on June 09, 2016, 05:39:38 AM
just hook 3 methods:

equpment to prevent replacement
drop to prevent dropping
and strip to prevent stripping from dead bodies

???

done

??? = profit xD
thanks!!
Do you want your colonists to look manlier?
Get a free mustache sample here!

Shinzy

Quote from: pestilenz on June 09, 2016, 08:43:51 AM
EDIT: I've found the relatively unused BodyPartsGroups "Teeth" and "Mouth", which cover the jaw. Suggestion is that a moustache covers the teeth, while a full beard covers the jaw.

The BodyPartGroup mouth isn't used (As far as I've noticed playing around with my apparel) and the bodypart group "teeth" covers the jaw

joaonunes

Quote from: pestilenz on June 09, 2016, 10:53:44 AM
EDIT: attached also my basic mod. Only downside is that the beards can't be worn with helmets, but can be covered with a dll. If you want to I can help you out with some graphics.

Because you are probably using the defs for Hairs. The only possible way would be to use the beards as apparel with Hediff proprieties.

Basically the "perfect" way to make the mod work wold be to:
- Beards are apparel;
- Can't be removed (by use of tags probably);
- Can have the same color as the pawn's hair (c#);
- Beards have Hediff (to be able to be removed by cutting, trimming it, etc...);

And thanks for the availability to help me with the graphics :)

EDIT: humm... you can't equip the beards simultaneously with hats?
Do you want your colonists to look manlier?
Get a free mustache sample here!

joaonunes

Quote from: pestilenz on June 09, 2016, 12:36:03 PM
Hats are no problem, as they cover the UpperHead. Helmets cover the FullHead, which can't be worn together with something below the hierarchy. Like Helmet vs. Hat. Only one item per group. See the Bodies_Humanlike.xml

Maybe a barber's / cosmetic table would be nice, where women can put on some lipstick. Also, the beards / lipstick could give some attractiveness or add insulation to cold.

Cool, and then maybe add some "Beard Hater" traits or something similar to prosthophobe :P
Do you want your colonists to look manlier?
Get a free mustache sample here!

joaonunes

Some defs sloppily made :P

ThoughtDefs:

<?xml version="1.0" encoding="utf-8" ?>

<Defs>

  <ThoughtDef>
    <defName>PogonophileHappy</defName>
    <workerClass>ThoughtWorker_Hediff</workerClass>
    <requiredTraits>
      <li>Pogonophile</li>
    </requiredTraits>
    <stages>
      <li>
        <label>has a mustache</label>
        <description>I don't know why, but I feel manlier than usual...</description>
        <baseMoodEffect>5</baseMoodEffect>
      </li>
    </stages>
  </ThoughtDef>

  <ThoughtDef>
    <defName>PogonophileNoMustache</defName>
    <workerClass>ThoughtWorker_HasMustache</workerClass>
    <invert>true</invert>
    <requiredTraits>
      <li>Pogonophile</li>
    </requiredTraits>
    <stages>
      <li>
        <label>lacks a mustache</label>
        <description>Mustaches are great, most women love them too!</description>
        <baseMoodEffect>-2</baseMoodEffect>
      </li>
    </stages>
  </ThoughtDef>

  <ThoughtDef>
    <defName>PogonophobeUnhappy</defName>
    <workerClass>ThoughtWorker_HasMustache</workerClass>
    <requiredTraits>
      <li>Pogonophobe</li>
    </requiredTraits>
    <stages>
      <li>
        <label>has a mustache</label>
        <description>Yuck, I have hair all over my face...</description>
        <baseMoodEffect>-5</baseMoodEffect>
      </li>
    </stages>
  </ThoughtDef>

</Defs>


TraitDefs:

<?xml version="1.0" encoding="utf-8"?>
<TraitDefs>

<TraitDef>
<defName>Pogonophobe</defName>
<commonality>0.05</commonality>
<degreeDatas>
<li>
<label>pogonophobe</label>
<description>NAME thinks mustaches are ugly and unclean.</description>
</li>
</degreeDatas>
<conflictingTraits>
<li>Pogonophile</li>
</conflictingTraits>
</TraitDef>

<TraitDef>
<defName>Pogonophile</defName>
<commonality>0.05</commonality>
<degreeDatas>
<li>
<label>pogonophile</label>
<description>Mustache makes someone classier and more charismatic, or so NAME thinks.</description>
</li>
</degreeDatas>
<conflictingTraits>
<li>Pogonophobe</li>
</conflictingTraits>
</TraitDef>

</TraitDefs>


Hediffs:

<Defs>
  <HediffDef>
    <defName>Mustache</defName>
    <hediffClass>Hediff_Mustache</hediffClass>
    <defaultLabelColor>(0.75, 0.3, 0)</defaultLabelColor>
    <label>mustache</label>
    <comps>
      <li>
        <compClass>HediffComp_VerbGiver</compClass> <!-- HELP!!! Should this have a comp at all??? -->
      </li>
    </comps>
<addedPartProps>
  <isSolid>false</isSolid>
      <partEfficiency>1</partEfficiency>
    </addedPartProps>
    <stages>
      <li>
        <label>Manly</label>
        <everVisible>false</everVisible>
        <capMods>
          <li>
            <capacity>Consciousness</capacity>
            <offset>0.05</offset>
          </li>
        </capMods>
      </li>
    </stages>
  </HediffDef>
</Defs>



Regarding c#, the thing complicates a bit...


public class AddedBodyPartProps_Mustache : AddedBodyPartProps
{
        /*public bool isBionic;

        public bool isSolid = true;

        public float partEfficiency = 1f;

        public bool isGoodWeapon;*/

        public bool isMustache;
    }

The commented code is what already exists in "AddedBodyPartProps", I would only need to add a bool "isMustache" to act similarly to the "isBionic".
EDIT: I think I'll just use the vanilla "AddedBodyPartProps" and set the mustaches to "<isSolid>false</isSolid>" for increased compatibility and ease of coding.


public class ThoughtWorker_HasMustache : ThoughtWorker
    {
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            List<Hediff> hediffs = p.health.hediffSet.hediffs;
            for (int i = 0; i < hediffs.Count; i++)
            {
                AddedBodyPartProps addedPartProps = hediffs[i].def.addedPartProps;
                if (addedPartProps != null && addedPartProps.isMustache)
                {
                    return true;
                }
            }
            return false;
        }
    }

It would look something like that, but I'd need to replace the "AddedBodyPartProps" by "AddedBodyPartProps _Mustache", which i can't decide how to make next because "AddedBodyPartProps" is also one of the variables existing in the superclass "Hediff"...

EDIT: Maybe I could instead use the vanilla "AddedBodyPartProps" but make it so all my mustaches have the tags "isSolid" and "isBionic" as FALSE and TRUE respectively. That way no code would need to be changed, but there is a problem because there are other "ThoughtWorker" classes that compare at least one of those tags. I can only think of the "ThoughtWorker_HasBionicBodyPart" right now, but that would be enough for someone being prosthophobe also receiving the negative mood from having the mustache, while no prosthetics are on the pawn... Tips?
EDIT 2: The "isSolid" is being used in the "BodyPartDef", so there should be no problems if I only use that tag instead of both.
EDIT 3: I'll just use the "<isSolid>false</isSolid>".

The only file not quite edited yet is this:

public class Hediff_Mustache : HediffWithComps
    {
       
    }

Still no code but it should be something like that, inheriting from "HediffWithComps" just like the "Hediff_Pregnant", right?
See the Hediffs file above.


What do you guys think? Am I on a good track?
Need some pointers from now on... :( My skills at modding Rimworld are not as good as I'd like to...
Do you want your colonists to look manlier?
Get a free mustache sample here!

milon

I can't speak to any of the C# stuff, but I can take a stab at some of the XML stuff.

The thoughts and traits look fine at a glance, but I'm confused about the Hediff.  Why does it affect consciousness?  Seem a little unusual...  Also, if it's never going to be visible on the health tab you don't need to specify a color for the label.

joaonunes

Quote from: milon on June 11, 2016, 06:30:51 PM
I can't speak to any of the C# stuff, but I can take a stab at some of the XML stuff.

The thoughts and traits look fine at a glance, but I'm confused about the Hediff.  Why does it affect consciousness?  Seem a little unusual...  Also, if it's never going to be visible on the health tab you don't need to specify a color for the label.

Ohh yeah, the colour is a leftover :p will remove it tomorrow.

The hediff is afecting consciousness because maybe it'd be cool to have some boost when wearing a mustache other than just social boost similar to "beautiful" or "ugly". As you said, it is unusual, and a manly man wearing a manly mustachw should have something to labwl himvas a real man. Since consciousness affects the speed at which a pawn is put down (it has some weight to it, right?) a little boost should fir peefectly xD
Do you want your colonists to look manlier?
Get a free mustache sample here!

joaonunes

Quote from: pestilenz on June 11, 2016, 11:36:05 PM
With CCL and what I've learned so far, I've accomplished beards for every male colonist!
I detoured the ResolveAllGraphics in PawnGraphicSet and managed to merge facial hair textures with the head. No chance of adding my own render layer, so I hijacked it :) Hair is glued to the head and beards are visible even below helmets.

Basic experiment consists of a moustache + a grown beard, applied separately. I don't know yet if the save remembers the styling. Needs more testing. Screenshot attached. Tired now. More xplain morw.#รค-.

Wow, what a cool looking group xD

Editing ResolveAllGraphics and PawnGraphicSet was my first idea but I put in on the shelf because of the complexity of the classes and because I couldnt really find a way to merge images and set their "commonality" rates so only some colonists would have beards :P

I'd be really interested in knowing how you edited those files though, specially ResolveAllGraphics, that thing is a beast...
You have all the reasons to be tired after fighting that thing, congratz on the work :)
Do you want your colonists to look manlier?
Get a free mustache sample here!

Fluffy (l2032)

damn pestilenz, creating readable copies of textures is something I've been trying to do for ages! That snippet alone is already amazingly useful. Mind if I steal it? :D