PDA

View Full Version : Applying Makeup to Sim


Diriel
16th Sep 2011, 10:25 PM
Yo, again!

I hate to make another topic but well, technically this is a new topic, just for the same mod. Ah, semantics. Well, this'll make it more search friendly for anyone in the future.

Anyway details on what I'm trying to do can be found here (http://nene.modthesims.info/showthread.php?p=3644781).

I need some assistance in figuring out how to add/change a sims full face (costume) makeup during gameplay. Shouldn't matter to which we're trying to change to here, I just need to know how it's actually done.

I'm almost certain it's possible, since I can change the hair colour during gameplay, which would usually be in the realm of CAS.

I've been trying to figure out a way to do this, and I hate to beg for help... But I'm begging for help.


I'm afraid I don't have any broking coding attempts to paste at you, as I can't even seem to find a place to start with this. I've looked into SimDescription, SimBuilder, CASUtils and just can't find any reference to it at all.

My original guess was that I would load a SimDescription into SimBuilder and use the AddPart() function to add the makeup, then have it build a new description that I would set the sims description to. Alas, that speculation didn't come to pass as it doesn't seem to do that. :(

There are no pure script mods that do this that I can find with my searching skills, so I've nothing to dissect, stumped is the word I'm looking for.

I'm not sure if this has been done before, but even any speculation could be handy. Of course if anyone has the answer then lots of hugs for them... Or something less intimate if they prefer.

twallan
16th Sep 2011, 11:01 PM
You are looking for mods that alter outfits on sims ?

I would suggest looking at Dresser mod. The coding in NRaas.DresserSpace.Tasks.CheckOutfitTask:OnPerform() is the best example I can provide of altering and replacing an existing sim outfit.

Of course, MasterController contains coding for altering outfits as well, however its approach is probably more complicated than you require.

:)

Diriel
17th Sep 2011, 12:11 AM
You are looking for mods that alter outfits on sims ?

I would suggest looking at Dresser mod. The coding in NRaas.DresserSpace.Tasks.CheckOutfitTask:OnPerform() is the best example I can provide of altering and replacing an existing sim outfit.

Of course, MasterController contains coding for altering outfits as well, however its approach is probably more complicated than you require.

:)

I'll take a look at both, thanks for the point in a direction.

Diriel
18th Sep 2011, 03:51 AM
Sorry for the double post, but as it's been a couple of days an edit would go unnoticed, and I have something new to ask.

Thanks to twallan reference I have managed to apply CostumeMakeup to a sim. However, I'm now having a new problem which is rather annoying.

No matter which CostumeMakeup I attempt to apply, it always seems to come out as the tiger paint. As you can see here:

CostumeMakeup when applied using CAS:
http://www.vorix.net/misc/test1.png

CostumeMakeup when applied by script:
http://www.vorix.net/misc/test2.png
(The extra line showing the type was just something I was trying out, it's not relevant.)

I made a quick command that get's the ResourceKey of the currently applied CostumeMakeup.

As you can see, they both have the same instance ID, group and type. So I'm pretty sure it's the correct CASPart, unfortunately for me I've never played around with CASParts, so I've little clue as to how two things with the same Instance ID can be different. (The CostumeMakeup is custom and is contained within another package file. Simply a test as the mod will allow users to select their own. Or something along those lines.)

Here's the bit of code that's relevant;
private static void SetFullFaceMakeup(Sim sim)
{
try
{
SimBuilder builder = new SimBuilder();

SimDescription mSim = sim.SimDescription;

CASPart bloodMask = new CASPart();
PartSearch partSearch = new PartSearch();
foreach (CASPart value in partSearch)
{
if (value.Key.InstanceId == 9358671749869544017)
{
bloodMask = value;
SimpleMessageDialog.Show("Info!", "Found blood CASPart!");
}
}
partSearch.Reset();

foreach (OutfitCategories outfitCategories in Enum.GetValues(typeof(OutfitCategories)))
{
if (outfitCategories != OutfitCategories.Special)
{
ArrayList arrayList2 = mSim.GetCurrentOutfits()[outfitCategories] as ArrayList;

if (arrayList2 != null)
{
int count = arrayList2.Count;
for (int j = 0; j < count; j++)
{
builder.Clear(false);

SimOutfit simOutfit = arrayList2[j] as SimOutfit;

OutfitUtils.SetOutfit(builder, simOutfit, mSim);

builder.AddPart(bloodMask);

SimOutfit outfit = new SimOutfit(builder.CacheOutfit(mSim.FullName + outfitCategories.ToString() + j.ToString()));
if (mSim.GetOutfitCount(outfitCategories) > j)
{
mSim.RemoveOutfit(outfitCategories, j, true);
}
mSim.AddOutfit(outfit, outfitCategories, j);

Sleep(0u);
}
}
}
}

if (mSim.CreatedSim != null)
{
mSim.CreatedSim.UpdateOutfitInfo();
mSim.CreatedSim.RefreshCurrentOutfit(false);
}
SimOutfit outfit2 = mSim.GetOutfit(OutfitCategories.Everyday, 0);
if (outfit2 != null)
{
ThumbnailManager.GenerateHouseholdSimThumbnail(outfit2.Key, outfit2.Key.InstanceId, 0u, ThumbnailSizeMask.All, ThumbnailTechnique.Default, true, false);
}
}
catch (Exception ex)
{
SimpleMessageDialog.Show("Info!", sim.Name + "\nApply outfit failed!\n" + ex);
}
}I've now got most everything sorted except for this little snag. Does anyone have an inkling as to what is happening here?

--Update
Okay, it would seem that all costume makeup is the same CASPart with different presets applied, and I've found this;
CASUtils.ApplyPresetToPart

Trouble is I have no clue how to get the preset I'm looking for. =/

Why do I always pick things that seem simple for my practices, then they turn out to be quite complex? Ah well, come this far now.

Anyone with any idea? Or am I going completely down the wrong path?