[SOLVED] Adding Trait Does Not Disable Work Type/Tag

Started by O Negative, January 06, 2019, 03:04:40 PM

Previous topic - Next topic

O Negative

I've found that using the debug tool to add a trait to a pawn doesn't add the disabled worktags, and the same thing applies to methods that Add traits to pawns.

These method calls also don't do the trick:
pawn.skills.Notify_SkillDisablesChanged();
pawn.workSettings.Notify_GainedTrait();

What am I missing here?

Note: Dev Mode (Give trait...) also has the same issue...

Razuhl

The debug menu action is bugged, it adds the trait directly in a collection instead of using the pawn.story.traits.GainTrait(trait) method. Therefore all the cached values are invalid.

For adding traits the method can be used and it handles the caches. For removing you have to invoke the cache clears yourself, you already have the code in your previous topic just don't skip lines.

O Negative

Ugh, you're 100% RIGHT...

I was using the wrong stupid method...

I was using pawn.story.trait.AllTraits.Add(...); Instead of pawn.story.traits.GainTrait(...);

To think, I spent hours trying to figure out what was going wrong T-T