How to use s3pe to make a custom script for an object

This How-to was correct at version 0908-21-0806

 

 

As an example, let's assumed you have cloned the Expensive Toilet in s3oc, and wish to make it an object class of its own, with a view to letting it at least have its own tuning file.

 

 

 

Creating your script dll

 

* First, if necessary, read Sims 3 script coding guidance from:

Core modding tutorial

Sims 3-Creating a game compatible Visual Studio project

ILL and DLL overview

 

* Write your script.  I made mine by copying part of the existing Expensive Toilet script.  You can see it below

 

* Compile your script into a dll

 

 

 

Getting your script into your new toilet package

 

* Open your custom toilet package in s3pe.  It doesn't matter whether or not you have yet "made unique" in s3oc.

 

* Use the menu to Resource|Add.  In the dialog dropdown select Type S3SA 0x073FAA07.  Any group will do (suggest 0x0).   The instance ID needs to be the fnv64 hash of the filename, including the .dll extension.  The rest of the settings are irrelevant and personal choice.

 

* Highlight your new type 0x073FAA07 resource.  Click the Grid button.  Use the dropdown for Assembly -> Import/Export...  Click Import.

 

* Browse to and open your new dll, then click the Commit button in the Grid dialog.  This is a good time to save, also.

 

 

 

Letting your object know about its new class

 

* Select your object's OBJK resource (Type ID 0x02DC343F).  Open in Grid view.

 

* Click the ... against Keys.  One of the entries will be scriptClass.  Edit the CcString to have the name of your new class.  For instance, in my toilet, it would be Sims3.Gameplay.Objects.Plumbing.Mimics.ToiletInge. Commit, and save again.

 

 

 

Giving your new object its own tuning

 

Assuming you cloned an original object that already had a tuning file, you can give it its own tuning file.  At its easiest, this step is

 

* Find and the tuning xml the belonged to the object you cloned (in GameplayData.package), and import it to your custom object package.

 

* Obtain the fnv64 hash of  the scriptClass (eg Sims3.Gameplay.Objects.Plumbing.Mimics.ToiletInge) and use it for the Instance ID of the tuning xml.

 

* Edit the tuning file with values of your choice.

 

 

 

My new toilet class

 

using Sims3.Gameplay.ObjectComponents;
using Sims3.Gameplay.Abstracts;
using Sims3.Gameplay.Objects.Plumbing;
using Sims3.SimIFace;

[assembly: Tunable]

namespace Sims3.Gameplay.Objects.Plumbing.Mimics
{
    public class ToiletInge : Toilet
    {
        // Fields
        [Tunable]
        private static CleanableComponent.Tuning kCleanableTuning = new CleanableComponent.Tuning();
        [Tunable]
        private static GameObject.EnvironmentMotive kEnvironmentTuning = new GameObject.EnvironmentMotive();
        [Tunable]
        private static RepairableComponent.Tuning kRepairableTuning = new RepairableComponent.Tuning();
        [Tunable]
        private static Toilet.Tuning kToiletTuning = new Toilet.Tuning();

        // Properties
        public override CleanableComponent.Tuning CleanableTuning
        {
            get
            {
                return kCleanableTuning;
            }
        }

        public override GameObject.EnvironmentMotive EnvironmentTuning
        {
            get
            {
                return kEnvironmentTuning;
            }
        }

        protected override string OverflowFxName
        {
            get
            {
                return "s30_toiletExpensiveOverflow";
            }
        }

        public override RepairableComponent.Tuning RepairableTuning
        {
            get
            {
                return kRepairableTuning;
            }
        }

        public override Toilet.Tuning ToiletTuning
        {
            get
            {
                return kToiletTuning;
            }
        }
    }

}