- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Mod to add traits
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Mod to add traits
Replies: 2 (Who?), Viewed: 824 times.
#1
8th Feb 2015 at 10:07 PM
Posts: n/a
Mod to add traits
I could have sworn I saw a tutorial on how to create a mod that adds a new trait. I want to make a new hidden trait.
Can anyone point me in the right direction? I tried a search and failed. All I get is a bunch of links to Sims 4 mods. I want to make new traits for Sims 3.
Help?
Advertisement
#2
9th Feb 2015 at 8:57 AM
Last edited by Arsil : 9th Feb 2015 at 12:00 PM.
Posts: 997
Thanks: 22090 in 95 Posts
I think that my mod, Japanese Culture Trait, is the easiest case study (but I don't
recommend my coding style and can't guarantee that is robust or issues-free).
The xml with the trait data is commented and I can provide the sourcecode with
some comments that may help (and also because it uses constants and maybe
decompiling the code they will look weird, I don't know and I don't care to check).
EDIT: I confused constants (const) with macros (#define of C language).
An important thing is using unique names/ids for trait, traitTip and commodityKind.
Of course, having a custom trait that does nothing is not much fun, so you'll have
to program some behaviour. You can also create a custom motive whose value
decreases with time, so sims with will have the urge to do trait-related stuff.
My mod doesn't do that, the trait is only used as requirement to perform 2 custom
(and bugged) interactions.
Other sources that might help (they sure helped me). I'm too lazy to search links.
- Sims MX's Hypochondriasis Mod
- AwesomeMod
- Tutorial that also talks about "editing" enum, by velocitygrass
Needless to say, it's a pure scripting mod.
recommend my coding style and can't guarantee that is robust or issues-free).
The xml with the trait data is commented and I can provide the sourcecode with
some comments that may help (and also because it uses constants and maybe
decompiling the code they will look weird, I don't know and I don't care to check).
EDIT: I confused constants (const) with macros (#define of C language).
An important thing is using unique names/ids for trait, traitTip and commodityKind.
Of course, having a custom trait that does nothing is not much fun, so you'll have
to program some behaviour. You can also create a custom motive whose value
decreases with time, so sims with will have the urge to do trait-related stuff.
My mod doesn't do that, the trait is only used as requirement to perform 2 custom
(and bugged) interactions.
Other sources that might help (they sure helped me). I'm too lazy to search links.
- Sims MX's Hypochondriasis Mod
- AwesomeMod
- Tutorial that also talks about "editing" enum, by velocitygrass
Needless to say, it's a pure scripting mod.
Code:
namespace Arsil.JapCulture { public static class Instantiator { [Tunable] internal static bool kInstantiator = false; //internal static bool kLoaded = false; private static XmlDbData mXdb = null; public const ulong JAPCULTURE_TRAIT = 15572421960754265911uL; // decimal value of the hex declared in the xml private const int JC_CK = 286210343; // unique value, not already used in CommodityKind enum (or by custom CKs) private const int JC_TRAIT_TIP = 9715; // unique value, not already used in TraitTip enum (or by custom TTs) public const TraitNames JC_TRAIT_GUID = (TraitNames)JAPCULTURE_TRAIT;//15572421960754265911uL; public const CommodityKind JC_COMMODITYKIND = (CommodityKind)JC_CK;//286210343; public static bool HasJCTrait(Sim actor) { return actor.HasTrait(JC_TRAIT_GUID);//(TraitNames)15572421960754265910uL); } static Instantiator() { //kLoaded = false; mXdb = XmlDbData.ReadData("ArsilJapCultureTrait"); if (mXdb == null) return; World.OnStartupAppEventHandler += new EventHandler(OnStartupApp); // THIS IS FOR INJECTING INTERACTIONS, IT HAS NOTHING TO DO WITH ADDING THE TRAIT World.OnWorldLoadFinishedEventHandler += new EventHandler(OnWorldLoadFinished); } /* TRAIT ********************* */ public static void OnStartupApp(object sender, EventArgs e) { AddEnumValue<CommodityKind>("TraitJapCulture", JC_CK);//286210343); AddEnumValue<TraitTipsManager.TraitTipCounterIndex>("JapCulture", JC_TRAIT_TIP); LoadTrait(); ParseEnumValues<TraitNames>("TraitList", "Name", "Hex"); //UIManager.NewHotInstallStoreTraitsData = (UIManager.NewHotInstallStoreTraitsCallback)Delegate.Combine(UIManager.NewHotInstallStoreTraitsData, new UIManager.NewHotInstallStoreTraitsCallback(this.AddTraits)); UIManager.NewHotInstallStoreTraitsData += new UIManager.NewHotInstallStoreTraitsCallback(AddTrait); } private static void ParseEnumValues<T>(string table, string nameCol, string enumCol) where T : struct { // SEE DECOMPILED CODE } private static void AddTrait(ResourceKey[] keys) { TraitManager.ParseTraitData(mXdb, true); } public static void AddEnumValue<T>(string key, object value) where T : struct { // SEE DECOMPILED CODE } private static void LoadTrait() { TraitManager.ParseTraitData(Instantiator.mXdb, true); } // ALL THAT COMES AFTER THIS IS NOT DIRECTLY RELATED WITH ADDING THE TRAIT
Who Posted
|