Is it possible to have apparel give a mood boost?(SOLVED)

Started by Project 06, October 15, 2016, 04:06:28 AM

Previous topic - Next topic

Project 06

Im curious if its possible to have a specific piece of apparel give a mood boost, i thought maybe the tattered clothing effect would be a good baseline to work off of but it doesnt specify apparel, and im not sure how to do that.

Shinzy

It is possible for sure but the code would be tucked away within the 'workerclass' [citation needed]
So it's not something you could do with just fiddling with the XML's

I'm unable to help you any further myself but I have a hunch it wouldn't be from the toughest end of script'o'mancy to get it done, should you want to get a bit deeper into the rabbit hole of moddeering

Project 06

I know the code is in "ThoughtWorker_ApparelDamaged", the issue is this class doesnt specify certain apparel, it just checks all apparel so i have no idea how to make something like it look for a certain piece of apparel.

Alenerel

From the absolute ignorance I tell this, but maybe you could check those clothes that give stats like the parka, cowboy hat, jacket, etc.

Project 06

I looked at all the statdefs that you can put in xml, and theres not one that you can put in for joy from what i can see.

Project 06

Just to give a better understanding of what I'm trying to work off of, here is the code for tattered apparel. I'm wanting to twist it into a mood boost effect when wearing a specific item of clothing. I know there are a few things that will be removed, such as all the additional "if" statements that check for the condition of clothing. The main thing I'm trying to figure out is how to specify a piece of apparel.

using System;
using System.Collections.Generic;
using Verse;

namespace RimWorld
{
public class ThoughtWorker_ApparelDamaged : ThoughtWorker
{
private const float MinForFrayed = 0.5f;

private const float MinForTattered = 0.2f;

protected override ThoughtState CurrentStateInternal(Pawn p)
{
float num = 999f;
List<Apparel> wornApparel = p.apparel.WornApparel;
for (int i = 0; i < wornApparel.Count; i++)
{
if (wornApparel[i].def.useHitPoints)
{
float num2 = (float)wornApparel[i].HitPoints / (float)wornApparel[i].MaxHitPoints;
if (num2 < num)
{
num = num2;
}
if (num < 0.2f)
{
return ThoughtState.ActiveAtStage(1);
}
}
}
if (num < 0.5f)
{
return ThoughtState.ActiveAtStage(0);
}
return ThoughtState.Inactive;
}
}
}

harpo99999

is it possible to add the thoughtgiver to the clothing definition?
or perhaps some other trait?

Project 06

Based on what information I can find, no. I cant find any examples of clothing having "thoughtgiver". The only way I can see this working is creating a modified tattered apparel effect, or maybe creating a some kind of hediff that gives a mood boost while wearing that piece of clothing.

Project 06

Alright I've managed to do it! It is based off of the ThoughtWorker_ApparelDamaged class. My main point of doing this was so i can create more accessories that colonists can wear, and some can provide benefits to mood. Ill post the code below just in case someone is interested in it.

using System;
using System.Collections.Generic;
using Verse;
using RimWorld;
using UnityEngine;

namespace PEMod
{
    public class PEThoughtWorker_WearingRing : ThoughtWorker
    {

        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            List<Apparel> wornApparel = p.apparel.WornApparel;
            for (int i = 0; i < wornApparel.Count; i++)
            {
                if (wornApparel[i].def.defName == "RubyRing")
                {
                    return ThoughtState.ActiveAtStage(0);
                }
            }
            return ThoughtState.Inactive;
        }
    }
}


Shinzy