Adding a custom skill to a rabbithole career metric

Talk nerdy to us here.
Post Reply
zoeoe
Reactions:
Posts: 15
Joined: September 27th, 2020, 6:46 am

Adding a custom skill to a rabbithole career metric

Post by zoeoe » December 5th, 2021, 4:41 pm

Hellooo,

Another simmer, Olomaya from MTS, was asking about adding a custom skill to a career, as it worked for Arsil's Programming skill, but not others. I thought the answer was needing to use an AddEnumValue function to add the skill to the SkillNames enum so if the game does TryParseEnum, it would get the skill guid rather than returning none. Arsil uses that function in his Mangaka career code, as well as the programming skill, and as it's also needed to get a skill dreamtree working for a custom skill, I thought that's the missing piece. But that's not the case :p

There doesn't seem to be an issue of the game loading the career with the custom skill, but when a sim tries to get the job, there's a script error and the metrics don't show up at all.
The script error says there was a null value found when an object instance was required, at Sims3.gameplay.Careers.MetricSkillX:MetricTitle.

The code is

Code: Select all

public override string MetricTitle(Career career)
	{
		string name = SkillManager.GetStaticSkill(SkillGuid).Name;
		return Localization.LocalizeString("Gameplay/Careers/Metrics:TitleSkillX", name);
	}
But when I do that line in my code, I get my skill name returning, no errors or anything weird, so I'm really not sure why it gets upset there when the sim tries to join the career?

And I also can't see what Arsil does differently to make the skill compatible, though he has an awful lot of code :p

A possibly helpful note, is that if I use the NRaas Careers skill metric (that the mobster career uses for assassination skill), the metrics do show up, but with my skill metric as blank (so just an angry face with no info). I saw that the NRaas version does some extra checking so will return null if the skill can't be found, so I'm guessing that's why it shows up better than the EA one, but it's probably important that it fails in this specific code both times.

So I'm pretty confused about it all, any insight would be cool!

zoeoe
Reactions:
Posts: 15
Joined: September 27th, 2020, 6:46 am

Adding a custom skill to a rabbithole career metric

Post by zoeoe » December 9th, 2021, 6:36 am

Updating this to say I seemed to have figured it out :p
The issue was that the skill wasn't being loaded before the career, so the SkillGuid of the metric was null/none, which caused issues when trying to get the metric title.

I saw that NRaas careers loads the skills and THEN careers straight away in the "Instantiator" constructor, so I did the same for my skill and it it worked! Rather than doing it in OnStartupApp that is.

However it does leave me with some questions:
1. Why does Arsil's Programming skill work as a career metric, even though he loads the skill in OnStartupApp?
2. If both NRaas Careers's careers and custom skills load in their mod's Instantiator's, if NRaas Careers is read by the game before a custom skill, wouldn't that mean the skill wouldn't be recognised as a valid skill for a career? If that's the case, how would we ensure that the skill is loaded first? I did try putting my skill in Overrides, to see if it would prevent it working as a career metric but it seemed fine, so how the game reads scripts isn't so obvious I don't think :p
3. Is there any reason that the custom skill tutorial on Simlogical has you load the skill in OnPreload? Or any reason to load the skill anywhere like that eg OnStartupApp, as opposed to straight away in the constructor like NRaas does it?

So evidently solving this issue has left me more confused in some ways :D

User avatar
diplace
Reactions:
Posts: 167
Joined: January 21st, 2017, 6:00 pm
Location: Texas, USA

Adding a custom skill to a rabbithole career metric

Post by diplace » January 2nd, 2023, 7:40 am

I have written a basic career using the Flower Arranging Skill (by zoeoe) and the career works, but when I use the zoeoeKnitting Skill or the LyraleiSewingSkillName, the same thing happens to zoeoe. I tried all the other testing, changing the career to only one "special" (Non EA) skill, etc and nothing is working. Confused also.

Post Reply