Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 10th Apr 2024 at 6:23 AM
Trouble requiring Custom Trait for interactions.
I'm making a lifestyle mod involving religious traits that will change how the sim feels (moodlets) and interacts with the world. The thing is, I have hit a snag. I didn't have too much trouble adding a trait or a custom interaction, but combining the features has proven extremely difficult.

All I want is for my interactions not to show up if they don't have my custom traits.

I looked at Arsil's custom trait manager, and I am confused.

In the Trait Guide
Code:
<RequiredTrait>	<!-- row #1 -->
	<Name></Name>
	<InteractionName></InteractionName>
	<ObjectName></ObjectName>
</RequiredTrait>

This exists so I would think I don't need to do it in the script. However, I have found no example of how to get the required Trait tag to work with custom traits.
So I moved on to Scripting following the online tutorials I made this
PasteBin
(I have moved past this version of the code when I switched to the unprotected Dll's from Nraas due to having issues)
I've been looking at how Arsil implemented the feature of requiring a custom trait with ILSpy/dnspy in his Japan Trait mod, and it really has taken me outside of my comfort zone.
https://imgur.com/a/K66FGNv
https://imgur.com/a/q2NOI6H
I have experience coding and a very basic understanding of C# as well.
I am just wondering if I am missing some easier method of doing this, if someone could point me too a resource I could learn better from or break down how to implement a trait with custom interactions.

I will say reading the tutorials this community has , has been extremely helpful.

I think I'll figure this out eventually, but I would appreciate any help.
Advertisement
Field Researcher
#2 Old 10th Apr 2024 at 12:45 PM
You should be able to do that without scripting by editing the ATREQ entry of an interaction's action data XML table; ATREQ is "actor traits required", there are a bunch of examples of its use in the SocialData_BaseGame XML you can check out (the "Accuse" interactions at the very top of the file all specify required traits)

There are also some other lines in the same section of the action data that might be useful for you later, like AKTT (actor knows target trait), ATR (actor trait restricts, so the interaction is unavailable if the actor *does* have a given trait), ATRA (actor trait restricts autonomous, user can still direct the sim to do the action but they won't do it autonomously), and ATE (actor trait encourages).
Test Subject
Original Poster
#3 Old 10th Apr 2024 at 6:26 PM
I think that will be important down the line. For later interactions and the social dynamics around them. However, I am going to have these options locked in by a hidden faith trait. If I add more I don't want the player to be able to use other faith trait interactions unless they convert (which might be a can of worms) and lose the other ones. While Autonomy would fix NPC sims, it would be immersion-breaking. I'll see if I can figure out the scripting. If I can get good, I'll spread the knowledge.
Instructor
#4 Old 12th Apr 2024 at 4:07 AM
My own script knowledge is very lite, but are your custom traits actually using Arsil's Custom Trait Manager?
The guide and the functions it describes have a hard requirement of actually having that framework installed. The XML fields are uniquely for the framework, and not universally applicable if you've already made your trait as a pure-scripting mod. The RequiredTrait field from the guide doesn't need to be done in the script only because the script was already done, by Arsil.

The script in the Japanese Culture trait is performing in place of where an ITUN would usually be able to use a RequiredTrait field- which reads the core TraitNames list and will obviously fail to validate a custom trait.
CTM is set up to automate this for the trait data it reads, so that people can make traits without having to make the above type of script.

It's also worth noting the Japanese Culture trait doesn't use Arsil's own Custom Trait Manager, and so is not implemented in the way described by the guide for CTM and the two will be confusing to use as reference side-by-side.
Which does complicate things, because I don't think any traits made with Custom Trait Manager actually exist to use as reference and know if it all actually works as described. But I do generally trust Arsil's expertise, so it could simply be a crossing of wires issue here.

If you wanted to continue with your own scripted trait, free of CTM, SimMX's Hypochondriac trait seems to use a simpler hard-coded trait requirement for the interaction he adds to the mirror- if taking a look at that is any use.

Scribe of tutorials. Oracle of questions at NRaas. Blog staller at thecardinalsims. Feel free to @ me for input on any TS3/TS4 modding questions.
Test Subject
Original Poster
#5 Old 13th Apr 2024 at 4:49 AM
I have been using the CTM. I managed to get it to apply filters with no visible errors. The problem I have is that when I do the filter with that mod, it has no actual effect on the visibility of the trait as far as I can see...
I just did some tests after reading the code. As far as I can tell, all that part of the trait mod does is tune with autonomy. It does not remove the interactions. I have been chasing something that wasn't there, oof.
This basically nails me down to scripting, as I need to be able to use the HasTrait function or something similar before adding my interactions to an actor.
But this makes sense as to why there are so few trait mods for the Sims 3.

But anyway, yes, I'll continue reading the Hypochondriac trait and the Japanese trait. They seem to have some of the same functions. I should be able to copy some of the functions. Thanks for the help
Test Subject
Original Poster
#6 Old 16th Apr 2024 at 6:01 PM
Figured it out
I actually figured it out with Arsil's Custom Trait Manager, in case anyone wants clear instructions on how to make scripting work with it. The last comment on the mod's page was quite helpful.

So basically, it adds the trait to the game; you need to call it with the hex cast as a TraitNames.

Code:
        public static bool yourtraitconditionname(Sim actor)         {             return actor.HasTrait((TraitNames)yourhex );         }

For example

Code:
        public static bool IsChristian(Sim actor)         {             return actor.HasTrait((TraitNames)0xDB8CE8B9A70DD9FB);         }


Add this condition to the part of the script that checks and then adds interactions.
Then I "borrowed" Arsils event listener to detect the trait being added. "onTraitGainedListener"
(Change the Hex, obviously, if you do the same.)
It now adds interactions if the trait is added.
I still have a lot of work to do on my mod, but the biggest roadblock is now gone.
Back to top