View Full Version : TUTORIAL: Object Modding (aka adding interactions) - UPDATE 1/17/10
Kolipoki
9th Aug 2009, 12:14 AM
:alarm: This tutorial has been updated and wiki'd :alarm:
Tutorial:Sims_3_Object_Modding
Update1/17/10
This tutorial was extremely outdated with S3oc and s3pe updates as well as Sims 3 updates. The tutorial is now updated for all of these, BUT THE PICTURES ARE NOT. The pictures stop being correct with the S3oc. Also updated was the code, Sims 3 decided to take out the ktip styled notification and made it stop working. Sorry for the long wait, and good luck.
Video Version
This tutorial is now on video and can be found at The Sims Supply, here (http://thesimsupply.com/showthread.php?tid=231).
Object Modding is not a very well - defined category. Usually an object mod is one that will clone an object and give it new interactions for it to be able to run. This tutorial will show you how you would set up to create an object mod, and add an interaction to it. By all means interactions are not all you can do with it. With codding experience you tell it to do a lot of things.
What You Need:
1. Microsoft Visual Studip C# 2008 Express Edition (http://www.microsoft.com/express/vcsharp/) : You will use this for making the your new object do what you want it to do instead of just being another cloned object.
2. You need the modding framework and Resource.cfg for your Sims 3 directory, in order to run any mod, and you MUST have the included d3dx9_31.dll file, in the correct directory, to run any core mod. If you don't already have 'em, get them here: Framework (http://www.moreawesomethanyou.com/smf/index.php?topic=15184.0) .
3. Sims 3 Object Cloner (http://www.modthesims.info/showthread.php?t=362413/)
4. Sims 3 Package Editor (http://www.modthesims.info/showthread.php?t=362412/)
5. The Net Reflector (http://www.red-gate.com/products/reflector/) : This will be used to explore through the Sims 3's code content.
6. Knowledge of C# Code: If you have no knowledge of C# code then you will be totally lost some time in this tutorial and will have to start asking questions about everything in your code. I highly advise you to read up on C# before starting this tutorial. (I know from personal experience). This is a pretty good site but it will not teach you everything: http://www.csharp-station.com/Tutorial.aspx
Setting Up:
Its best. when making mods, to create a folder for all of your things. The best place is on the desktop, its easy to reference. After you have your folder you will need to obtain some main Sims 3 dlls that will be used as references later in coding. If you have all ready core modding then you will know what to do.
Open the S3pe
Hit - File - Open
Navigate to your Sims 3 main directory folder (usually in the c drive)
From there go to the Game Folder and then the Bin Folder
You will see 3 packages. These packages contain the dlls that you will be needing.
First open the gameplay package
Four files will appear, you will be exporting 3 of them.
Click on the first sting and hit value. Scroll down the lot of words untill you see Manifest Module:
If the Manifest Module says TestGameplay, you can close out of the window and continue to the next item on the list. If it doesnt say TestGameplay close out of the the window and hit "Grid". At the top of the data grid should be called Assemly. His the down arrow next to the Import/Export and hit "Export"
S3pe will then prompt you to save. Navigate to your mod folder and save the file as what the Manifest Module said followed by ".dll"
After you have saved, hit cancel in the datagrid and move on to the next item in the package.
Extract it the same way you did the first one nameing it with the Manifest Module it has followed by ".dll"
Do these for all of the items in that package.
When done with that pick open up one of the other 3 packages in the Game/Bin directory and do the same. (be sure not to take the test gameplay, it is not needed)
When finished with that package move on to the last package and do the same.
Making you Object
The next step in this process is to make your new cloned object. Start by opening the S3oc (Sims 3 Object Cloner). First time users will have to navigate to their Sims 3 folder to start off the program. Once opened we will want to make our new clone so hit Cloning - and choose the type of object you will be using. For this tutorial we are using Normal Objects. S3oc will then load the object catalog with all the objects in the game. Next you need to choose witch object you want to clone. In this example i'm going to use the Teddy Bear witch is called ToyStufffedAnimalTeddyBear. When you have picked out your object hit the "Clone or Fix" button. S3oc will then ask you to determine some options. You will need to make sure you give it a unique name. We will name ours "Kolipoki_AddInteractiontoBear". At this time you might also want to give it a new name, catalog description, price, and even which categories it will go into. Then hit start, and S3oc will then create your new object and ask you to save it to a new location.
http://thumbs2.modthesims2.com/img/2/1/8/9/6/0/1/MTS2_Kolipoki_979895_editbear.JPG
Congratulations you have your own cloned object.
Setting Up MVSC# (Microsoft Visual Studio C#)
Before we start coding we need to set up MVSC# So that we can use it and make the code work. Of course there is all ready a tutorial on that out there. http://www.sims2wiki.info/wiki.php?title=Sims_3:Creating_a_game_compatible_Visual_Studio_project. Its small but you need to follow it. The files in step 4 are the files that we extracted in the beginning of this tutorial.
Finding the Original Object's Name
This next step is important because it will later be used to make your script be derived from the previous object making it the same so it will work in game. Start off by open your cloned object in the S3pe (in my case Kolipoki_AddInteractiontoTeddy). Next your going want to make sure that names and tags are on. Click the buttons right next to them as shown in the screen shot. Afterwards find the item in the list with a tag name of OBJK. Open the OBJK with the grid button.
http://thumbs2.modthesims2.com/img/2/1/8/9/6/0/1/MTS2_Kolipoki_979898_openobjk.JPG
You should see a "Component Data" category click on the category and a small button with three little dots appears to the far right. Click on this button and it will bring up a new menu. On the left of that new pop-up, you should see two items. Click on the second item labeled "[1]CDTString". The data row should have a rather long name usually starting with "Sims3....." That is the original name and how to call that item. Be sure to write it, or paste it somewhere else so that we can use it later. In the case of a cloned teddy bear the co-string is "Sims3.Gameplay.Objects.Miscellaneous.StuffedAnimal".
http://thumbs2.modthesims2.com/img/2/1/8/9/6/0/1/MTS2_Kolipoki_979896_finging_costring.JPG
Starting Your Code
Open up your project that you made in step "Setting up MVSC#". We are going to start off by changing the namespace and the class. The namespace is what contains classes and separates out two of the same classes. Lets name our research after Yourname Followed by mod. For Example:
namespace Sims3.Gameplay.Objects.Miscellaneous.KolipokiMod
Next we need to change the class name. Its needs to be something that will tell you what you are doing. Since we are adding a simple interaction i'm going to make it:
public class TalkingTeddy : StuffedAnimal
Now you may notice in my class name that i have what functions as a deriver. What it does is it takes the code with the StuffedAnimal and assigns the TalkingTeddy to it. The deriver should be what was in your co-string. You may be wondering what your co-string was way longer then that and it was. MVSC# will the things before it for you. If it does not right click on it and hit resolve and then it should work. What it is doing is that on the top of the code it is adding a Using qualifier witch makes it so you dont have to say that name space over and over again when calling something within it.
Adding the interaction
Through this step we will be using the reflector for a while so make sure you have it opened and that you opened the dlls that we extracted in the first step.
If you do not know how the game calls an interaction it is best to see how to they do it. Because all we are doing is telling the interaction to tell us hi we need an immediate interaction. In the Sims 3 immediate interactions have those orange circle things next to their name. We are going to be exploring the Stereo TurnOnOff function.
Expand your Sims3GameplayObjects - Sims3GameplayObjects.dll - Sims3.Gameplay.Objects.Electronics - Stero - TurnOnOff. We now need to open the Dissasembler. To open the dissasembler hit space. Once open click on the TurnOnOff to see what it does. Be sure to hit the expand method at the bottom of the dissasembler so you can see the hole code. Look through the disassembler and see how the code works.
When you have finished exploring we are going to need most of the code of the TurnOnOff Method so select the code in the disassembler and copy it. Paste it within your class definition in MVSC#. Because this is for the stero we will need to be changing it.
Change the private sealed class name of TurnOnOff to what you want the name of it to be, make it something that describes the interaction. I'll be naming mine TalktoMe. Also make note that that class is derived from an immediateInteraction class. be sure to change the Stero to the name of your object (the first class). In my case it will say TalkingTeddy instead of stero.
Allot of this stuff we took we will not be needing and we will have to change. With your C# knowledge you can figure out what you have to change and edit but for our example after removing the code. You will also need to change the code so that where it says stereo you refer to your object and where it says TurnOnOff you refer to your interaction name.
private sealed class TalktoMe : ImmediateInteraction<Sim, TalkingTeddy>
{
// Fields
public static readonly InteractionDefinition Singleton = new Definition();
private const string sLocalizationKey = "Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe";
// Methods
private static string LocalizeString(string name, params object[] parameters)
{
return Localization.LocalizeString("Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe:" + name, parameters);
}
protected override bool Run()
{
//do interaction here
return true;
}
// Nested Types
private sealed class Definition : ImmediateInteractionDefinition<Sim, TalkingTeddy, TalkingTeddy.TalktoMe>
{
// Methods
protected override string GetInteractionName(Sim a, TalkingTeddy target, InteractionObjectPair interaction)
{
return TalkingTeddy.TalktoMe.LocalizeString("TalktoMe", new object[0]);
}
protected override bool Test(Sim a, TalkingTeddy target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
return !isAutonomous;
}
}
}
Making the Interaction Do Something
With the right code, interactions could do anything. They could start a fire to a whole lot like in the ChaosMagePainting. They could lock doors such as in the Lockable door.
For this tutorial i will simply make it say "Hi". The Sims 3 has a nice way of setting up a notification. It's simply:
base.Actor.ShowTNSIfSelectable("Hello", StyledNotification.NotificationStyle.kTip, ObjectGuid.InvalidObjectGuid, base.Actor.ObjectId);
base.Target.mRevealingSim = base.Actor;
The first line in this code is calling the ShowTNSIfSelectable, which is a nice method of telling things through notifications. If you search in the relfector for the ShowTNSIfSelectable you will find that the parameters are 1)what you want it to say, 2)the theme of the notification is this case kTip(there are i believe 5 different themes, so go look them up and choose one you like), 3)thumbnail 1 and 4) thumbnail 2. This code will going into the "protected override bool Run" inside your interaction class.
Congratulations now your code will add the interaction and tell you hello. Here is what the final product should look like:
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay.Objects.Miscellaneous;
using Sims3.Gameplay.Utilities;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.SimIFace;
using Sims3.Gameplay.Skills;
using Sims3.UI;
using Sims3.Gameplay.Objects;
namespace Sims3.Gameplay.Objects.Miscellaneous.KolipokiMod
{
public class TalkingTeddy : StuffedAnimal
{
protected Sim mRevealingSim;
public override void OnStartup()
{
base.OnStartup();
base.AddInteraction(TalktoMe.Singleton);
}
private sealed class TalktoMe : ImmediateInteraction<Sim, TalkingTeddy>
{
// Fields
public static readonly InteractionDefinition Singleton = new Definition();
private const string sLocalizationKey = "Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe";
// Methods
private static string LocalizeString(string name, params object[] parameters)
{
return Localization.LocalizeString("Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe:" + name, parameters);
}
protected override bool Run()
{
//Do the interaction here.
base.Actor.ShowTNSIfSelectable("Hello", StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, base.Actor.ObjectId);
base.Target.mRevealingSim = base.Actor;
return true;
}
// Nested Types
private sealed class Definition : ImmediateInteractionDefinition<Sim, TalkingTeddy, TalkingTeddy.TalktoMe>
{
// Methods
protected override string GetInteractionName(Sim a, TalkingTeddy target, InteractionObjectPair interaction)
{
return TalkingTeddy.TalktoMe.LocalizeString("TalktoMe", new object[0]);
}
protected override bool Test(Sim a, TalkingTeddy target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
return !isAutonomous;
}
}
}
}
}
Now that your script is complete save the project and hit "f6". This will build the project see if it has any errors and if it doesn't it will create a nice dll for you. This dll is stored in the Visual Studio 2008 - Projects - [name of saved project here] - [name of saved project here] - obj - release - [nameofproject].dll . That file will be used to add your script to your nice cloned object and make it work. If you ever change the code be sure to run "f6" again or you will get the old dll.
Adding your script to your package
The next step in this process is to add the script to the package. First your going to need to open S3pe and then open your cloned object.
We are going to be making a new resource that will have the tag S3SA. Before we go making a new resource we need to FNV Hash and get an instance name. In s3pe hit ctrl - f or go Tools - FNV Hash. Inside the box that says text to has write the class name of your object. For me i would write "TalkingTeddy". Copy the FNV64 number. That will become the new instance.
http://thumbs2.modthesims2.com/img/2/1/8/9/6/0/1/MTS2_Kolipoki_979897_fnvhash.JPG
Close out of the FNV Hash and hit Resource - Add. The Type number for all S3SA files is 0x073FAA07, and the group number is 0x00000000. The instance number is the number you just obtained in the FNV Hash. Ep flags are used to tell the object if it requires the EP or not (i assume). For those who do not have WA the EP name is 0x00. Hit ok and you will have a new S3SA type resource.
http://thumbs2.modthesims2.com/img/2/1/8/9/6/0/1/MTS2_Kolipoki_979899_Resource.JPG
After your new resource is created go to the OBJK, Collection of Keys, 2nd Key and type "[Your Namespace Name].[Your Class Name] For this example it would say Sims3.Gameplay.Objects.Miscellaneous.KolipokiMod.TalkingTeddy. Next you need to import your dll. Click on the S3SA and hit grid. The first item on the list should have an import/export click on it, bring the drop down menu down and click import. Navigate to your dll of your code "Visual Studio 2008 - Projects - [name of saved project here] - [name of saved project here] - obj - release - [nameofproject].dl" and hit open, after that hit commit and save your project. If all went well then you know have a nice object that will tell you Hi.
Finishing Up
If you testing your object in game after finishing the last step you may have noticed that the interaction would say Something like KolipokiMod.TalkingTeddy.TalktoMe . If you would like to change that open your cloned object in s3pe. FNV Hash the name that shows up in game and copy the instance in the FNV64. Find the file with an STBL file type (make sure its your language) and hit editor. A STBL Resource Editor will appear. Change the instance in the bottom to the FNV64 Hash and hit add. A new string will appear. Click on it and in the box to the right write out what you want it to say.
Congratulations
You have now finished your object and should have an understanding of how to make your own object mod. I cannot wait to see what you guys create.
Special Thanks
Special Thanks goes specially to Wito who helped me start out in object modding. I'd also like to thank Rick, Tiger, and ChaosMage for there help answering questions that i had come across. Thanks for Sri for telling me to try Object Modding.
Flabaliki
9th Aug 2009, 12:16 AM
This is absolutely awesome, thank you so so much for writing this tutorial!! This is great! :lovestruc
jadaytime
9th Aug 2009, 12:46 AM
Yes! I know a bit of Java and can kind of understand C, so I think I can maybe attempt this. Thanks!
PigiePower
15th Aug 2009, 05:43 AM
Hello and thank you for this. I'm just having one problem importing my .dll into the package. At The Part at "Click on the S3SA and hit grid" Grid is grayed out and S3PE displays this in the value preview... Error reading resource 073FAA07:00000000:EDCD663D13E88570
Exception has been thrown by the target of an invocation.
Destination array is not long enough to copy all the items in the collection. Check array index and length.
----
Stack trace:
at System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at s3pi.WrapperDealer.WrapperDealer.WrapperForType(String type, Int32 APIversion, Stream s)
at S3PIDemoFE.MainForm.browserWidget1_SelectedResourceChanged(Object sender, ResourceChangedEventArgs e)
----
Stack trace:
at System.BitConverter.ToInt64(Byte[] value, Int32 startIndex)
at System.BitConverter.ToUInt64(Byte[] value, Int32 startIndex)
at ScriptResource.ScriptResource.decrypt()
at ScriptResource.ScriptResource.Parse(Stream s) By Any Chance would you know what i missed or did'nt do right? :(
Kolipoki
15th Aug 2009, 07:57 AM
Did you make sure to change the script of the OBJK to your new code instead of the old object code?
PigiePower
15th Aug 2009, 07:40 PM
I have changed the second key in OBJK to KolipokiMod.TalkingTeddy. If that what your asking.
EDIT: I downgraded my S3PE to the second newest one and it works! :bunny:
Carrigon
16th Aug 2009, 02:27 AM
I'm stuck on getting it to say what it's supposed to say. It just shows my namespace and class when it's moused over in game. I did the hashing and added a new key for the dialog, I even did it for all three STBL's. Just won't go. Deleted the game's cache files, too. Is there some missing step here, or when we hash it, does it have to have the dot in it or do you just hash it as a full name? I hashed it with the dot in it.
bojinda
19th Aug 2009, 04:45 AM
How would I go about getting it to perform an action of some sort?
Kolipoki
19th Aug 2009, 07:12 AM
bojinda: an action in what way? This tutorial shows you how to make it say something to you, but if you mean have your sims do something, there are many different ways in order to do that you just have to use the proper code to make it do what you want.
bojinda
19th Aug 2009, 10:19 PM
bojinda: an action in what way? This tutorial shows you how to make it say something to you, but if you mean have your sims do something, there are many different ways in order to do that you just have to use the proper code to make it do what you want.
Ah thanks for the reply sorry for not being more specific, I mean make it do something like the cheer that the sim (excitable ones maybe) will sometimes do autonomously if you just let them stand there for a while
jadaytime
24th Aug 2009, 09:41 PM
If we wanted a certain item to do more than one ting (E.G, say hi for one interaction, then start a fire for another, etc.) could we organize each of these functions into different classes?
Kolipoki
25th Aug 2009, 12:52 AM
If you wanted to make the object have more then one interaction you would just make a new class such as "private sealed class TalktoMe : ImmediateInteraction<Sim, TalkingTeddy>". If you wanted to have it where you click on something, something else would come up try looking at the Chaos Mage Painting.
Kartesk
31st Aug 2009, 05:38 PM
Thx this Thread is a great help !! would give 5 ***** if it would be possible ;)
Regards
Kartesk
Cytron
2nd Sep 2009, 01:35 PM
Hello! I have a problem with microsoft visual c# 2008 express edition (german).
If I create a new Project, I can't select ".NET Framework 2.0".. Why?
Here a screenshot:
http://img90.imageshack.us/img90/6600/mvs.jpg
(Klassenbibliothek = Class Library)
And here the screenshot from the tutorial:
http://www.sims2wiki.info/images/0/00/Sims_3-VS_New_Project.png
(sorry for my english!)
twallan
2nd Sep 2009, 05:07 PM
Hello! I have a problem with microsoft visual c# 2008 express edition (german).
If I create a new Project, I can't select ".NET Framework 2.0".. Why?
The tutorial appears to have been written using the full version of Visual C# (or perhaps an older Express edition), rather than the current Express version.
You'll find the Setting for ".NET Framework 2.0" in the Properties for the project.
Right click on top-level item for your project in the Solution Explorer, and use the "Properties" menu operation. Then go to the "Application" tab, and the "Target Framework" should be there.
Cheers. :)
Cytron
3rd Sep 2009, 12:02 PM
The tutorial appears to have been written using the full version of Visual C# (or perhaps an older Express edition), rather than the current Express version.
You'll find the Setting for ".NET Framework 2.0" in the Properties for the project.
Right click on top-level item for your project in the Solution Explorer, and use the "Properties" menu operation. Then go to the "Application" tab, and the "Target Framework" should be there.
Cheers. :)
Thank you very much :) :up:
EDIT: Next Problem: I can't find "TurnOnOff" :( .. Screenshot:
http://img257.imageshack.us/img257/9373/vs2o.jpg
twallan
4th Sep 2009, 08:59 PM
EDIT: Next Problem: I can't find "TurnOnOff"
If you are looking to turn off a Stereo, use the function
Sims3.Gameplay.Objects.Electronics.Stereo.TurnOff()
If you want to turn it on, use the function
Sims3.Gameplay.Objects.Electronics.Stereo.TurnOn()
The Sims3.Gameplay.Objects.Electronics.Stereo.ToggleStereo() function is a protected member of the class, and is not available for direct call. It is called by the TurnOn() and TurnOff() functions.
If you wish to call the ToggleStereo() function directly, you will need to change the protection level in the Sims3GameplaySystems.dll .
Cheers. :)
Cytron
9th Sep 2009, 06:52 PM
If you are looking to turn off a Stereo, use the function
Sims3.Gameplay.Objects.Electronics.Stereo.TurnOff()
If you want to turn it on, use the function
Sims3.Gameplay.Objects.Electronics.Stereo.TurnOn()
The Sims3.Gameplay.Objects.Electronics.Stereo.ToggleStereo() function is a protected member of the class, and is not available for direct call. It is called by the TurnOn() and TurnOff() functions.
If you wish to call the ToggleStereo() function directly, you will need to change the protection level in the Sims3GameplaySystems.dll .
Cheers. :)
Thanks again :up:
EDIT: I copied the script from this thread, but I think the interaction-name is wrong.. where exactly can I edit this?:
http://img75.imageshack.us/img75/2271/bild2i.jpg
twallan
9th Sep 2009, 08:28 PM
Thanks again :up:
EDIT: I copied the script from this thread, but I think the interaction-name is wrong.. where exactly can I edit this?:
This one provides the name for the menu item.
protected override string GetInteractionName(Sim a, TalkingTeddy target, InteractionObjectPair interaction)
{
return TalkingTeddy.TalktoMe.LocalizeString("TalktoMe", new object[0]);
}
It calls this function, which creates the long name you are seeing.
private static string LocalizeString(string name, params object[] parameters)
{
return Localization.LocalizeString("Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe:" + name, parameters);
}
Cheers. :)
Jinxx
25th Sep 2009, 12:30 PM
First of all thank you so much for this. its awesome!!
I think im in over my head a little though. What I want to do is make a BodySculptor (found in Sims3.Gameplay.Objects.Rewards) teach you a skill like logic, but at the same time, take hunger, bladder, and sleep down.
I figured I'd start simply with a copy and paste job of the bodysculptor code. With my namespace etc.
this is what I have:
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.SimIFace;
using Sims3.UI;
using Sims3.Gameplay;
using Sims3.Gameplay.Abstracts;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.Core;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Objects;
using Sims3.Gameplay.Objects.Rewards;
using Sims3.Gameplay.Skills;
using Sims3.Gameplay.Socializing;
using Sims3.Gameplay.Utilities;
namespace JinxxMod
{
public class Simhancer : Rewards
{
protected Sim mRevealingSim;
public static float[] kPowerLevelPercentages;
public static float[] kChancesOfFailure;
public static int[] kRunTimes;
public static int[] kRechargeTimes;
public static int kSocialFailureLtrDelta;
public static int kSocialFailureStcDelta;
public static string kSocialFailureStc;
public static readonly string sLocalizationKey;
private PowerLevel mPowerLevel;
private DateAndTime mLastUsed;
private PowerLevel mPowerLevelLastUsed;
private AlarmHandle mRechargeAlarm;
public override void OnStartup()
{
base.OnStartup();
base.AddInteraction(SimhanceMe.Singleton);
}
private enum Option
{
Thin = 0,
Fat = 1,
Weak = 2,
Strong = 3,
Original = 4
}
private enum PowerLevel
{
Low = 0,
Medium = 1,
High = 2
}
internal void OnUse()
{
this.mLastUsed = SimClock.CurrentTime();
this.mPowerLevelLastUsed = this.mPowerLevel;
base.SetMaterial("Default");
Audio.StartObjectSound(base.ObjectId, "bodysculpt_light_red", false);
base.AddOrResetAlarm(ref this.mRechargeAlarm, (float)this.ChargeTimeRemaining, TimeUnit.Minutes, new AlarmTimerCallback(this.RechargeAlarmCallback), "RechargeAlarmCallback", AlarmType.AlwaysPersisted);
}
public bool Charged
{
get
{
return (SimClock.ElapsedTime(TimeUnit.Minutes, this.mLastUsed, SimClock.CurrentTime()) > kRechargeTimes[(int)this.mPowerLevelLastUsed]);
}
}
public static string LocalizeString(Sim actor, string name, params object[] parameters)
{
return Localization.LocalizeString((actor != null) && actor.IsFemale, sLocalizationKey + ":" + name, parameters);
}
private sealed class SimhanceMe : Interaction<Sim, Simhancer>
{
// Fields
private bool mFailure;
private IGameObject mReservedTile;
public static readonly InteractionDefinition Singleton = new Definition();
// Methods
public override void Cleanup()
{
if (this.mReservedTile != null)
{
this.mReservedTile.Destroy();
this.mReservedTile = null;
}
base.Cleanup();
}
private void PlayStopSound(StateMachineClient smc, IEvent evt)
{
string name = "fx_bodysculpt";
if (this.mFailure)
{
name = name + "_fail";
}
Audio.StartObjectSound(base.Target.ObjectId, name, false);
base.Target.SetMaterial("Default");
}
protected override bool Run()
{
Simhancer.Option mOption = (base.InteractionDefinition as ItemDefinition).mOption;
Sim mInstigator = (base.InteractionDefinition as ItemDefinition).mInstigator;
if (!base.Actor.RouteToSlotAndCheckInUse(base.Target, Slot.RoutingSlot_0))
{
return false;
}
base.StandardEntry();
this.mReservedTile = Sims3.Gameplay.GlobalFunctions.CreateObject("ReservedTile", base.Actor.Position, base.Actor.Level, base.Actor.ForwardVector);
base.EnterStateMachine("Simhancer", "Enter", "x");
base.SetActor("Simhancer", base.Target);
base.SetParameter("Set", base.Actor.SimDescription.Child ? "child" : (base.Actor.IsFemale ? "female" : "male"));
base.SetParameter("Q", (base.Actor.SimDescription.Child || base.Actor.IsFemale) ? "" : (RandomUtil.CoinFlip() ? "1" : "2"));
Simhancer.PowerLevel mPowerLevel = base.Target.mPowerLevel;
int num = Simhancer.kRunTimes[(int) mPowerLevel];
float num2 = Simhancer.kPowerLevelPercentages[(int) mPowerLevel];
float fitness = base.Actor.SimDescription.Fitness;
float num4 = base.Actor.SimDescription.Weight + 1f;
switch (mOption)
{
case Simhancer.Option.Thin:
num4 -= num2 * num4;
break;
case Simhancer.Option.Fat:
num4 += num2 * (2f - num4);
break;
case Simhancer.Option.Weak:
fitness -= num2 * fitness;
break;
case Simhancer.Option.Strong:
fitness += num2 * (1f - fitness);
break;
}
num4--;
float num5 = 0f;
if (num4 < 0f)
{
num5 = 1f + num4;
num4 = 0f;
}
this.mFailure = false;
if (RandomUtil.RandomChance01(Simhancer.kChancesOfFailure[(int)mPowerLevel]))
{
this.mFailure = true;
bool flag = false;
switch (RandomUtil.GetInt(2))
{
case 0:
fitness = 0f;
break;
case 1:
fitness = 1f;
break;
case 2:
flag = true;
break;
}
switch (RandomUtil.GetInt(flag ? 1 : 2))
{
case 0:
num4 = 1f;
num5 = 0f;
break;
case 1:
num4 = 0f;
num5 = 1f;
break;
}
}
base.BeginCommodityUpdates();
base.AnimateSim("Use");
base.Actor.WaitForExitReason((float) (num / 2), ExitReason.HigherPriorityNext);
if ((mOption == Simhancer.Option.Original) && !this.mFailure)
{
base.Actor.SimDescription.ResetBodyShape();
}
else
{
base.Actor.SimDescription.SetBodyShape(num4 - num5, fitness);
}
base.Actor.WaitForExitReason((float) (num - (num / 2)), ExitReason.HigherPriorityNext);
base.AddOneShotScriptEventHandler(0x3e9, new SacsEventHandler(this.PlayStopSound));
base.AnimateSim("Get Out");
base.EndCommodityUpdates(!this.mFailure);
base.Target.OnUse();
if (this.mFailure)
{
base.Actor.PlayReaction(ReactionTypes.TantrumIntense, ReactionSpeed.ImmediateWithoutOverlay);
if (mInstigator != null)
{
Relationship relationship = Relationship.Get(base.Actor, mInstigator, true);
if (relationship != null)
{
relationship.UpdateSTCAndLTR(base.Actor, mInstigator, Simhancer.kSocialFailureStc, (float) Simhancer.kSocialFailureStcDelta);
}
if ((mInstigator.CurrentInteraction != null) && (mInstigator.CurrentInteraction.InteractionDefinition == Simhancer.WatchChange.Singleton))
{
mInstigator.AddExitReason(ExitReason.CanceledByScript);
}
}
}
else
{
if (((mInstigator != null) && (mInstigator.CurrentInteraction != null)) && (mInstigator.CurrentInteraction.InteractionDefinition == Simhancer.WatchChange.Singleton))
{
mInstigator.AddExitReason(ExitReason.Finished);
}
base.AnimateSim("React " + mOption);
}
base.StandardExit();
return true;
}
// Nested Types
public sealed class Definition : InteractionDefinition<Sim, Simhancer, Simhancer.SimhanceMe>
{
// Methods
protected override void AddInteractions(InteractionObjectPair iop, Sim actor, Simhancer target, List<InteractionObjectPair> results)
{
InteractionInstanceParameters parameters = new InteractionInstanceParameters(iop, actor, actor.InheritedPriority(), false, true);
GreyedOutTooltipCallback greyedOutTooltipCallback = null;
if (this.Test(ref parameters, ref greyedOutTooltipCallback))
{
if (!target.Charged)
{
results.Add(iop);
}
else
{
Simhancer.Option option = actor.SimDescription.IsInitialBodyShape() ? Simhancer.Option.Strong : Simhancer.Option.Original;
for (int i = 0; i <= option; i++)
{
Simhancer.SimhanceMe.ItemDefinition interaction = new Simhancer.SimhanceMe.ItemDefinition();
interaction.mOption = (Simhancer.Option) i;
results.Add(new InteractionObjectPair(interaction, target));
}
}
}
}
protected override string GetInteractionName(Sim a, Simhancer target, InteractionObjectPair interaction)
{
return Simhancer.LocalizeString(null, "SimhanceMe", new object[0]);
}
protected override bool Test(Sim a, Simhancer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
GreyedOutTooltipCallback callback = null;
if (target.Charged)
{
return true;
}
if (callback == null)
{
callback = delegate {
return Simhancer.LocalizeString(null, "TipNotCharged", new object[] { target.ChargeTimeRemaining });
};
}
greyedOutTooltipCallback = callback;
return false;
}
}
[DoesntRequireTuning]
public sealed class ItemDefinition : InteractionDefinition<Sim, Simhancer, Simhancer.SimhanceMe>
{
// Fields
public Sim mInstigator;
public Simhancer.Option mOption;
// Methods
protected override string GetInteractionName(Sim a, Simhancer target, InteractionObjectPair interaction)
{
return Simhancer.LocalizeString(null, "SimhanceMeOption" + this.mOption, new object[0]);
}
public override string[] GetPath()
{
return new string[] { Simhancer.LocalizeString(null, "SimhanceMe", new object[0]) };
}
protected override bool Test(Sim a, Simhancer target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
return (target.Charged && !target.InUse);
}
}
}
}
}
I get a lot of errors just in that.... can anyone tell me what I'm doing wrong please :)
Thank you all in advance :D
ani_
26th Sep 2009, 08:51 PM
Jinxx: VS usually gives you quite descriptive error messages, you should try reading them through.
I have a question about object modding.
Has anybody succesfully managed to get a custom JAZZ file attached to their object mod? Is there any specific thing one should take into consideration?
I can successfully get the game to use a pre-existing state, and do the animations in that, but not when I try it to use the jazz file I attached.
---edit---
ignore my question, figured it out.
Jinxx
28th Sep 2009, 09:03 AM
thanks for your reply ani,
I have read the errors and not sure how to fix them. Sorry, I thought I'd put them in the original post.....
Error 1 The type or namespace name 'Rewards' could not be found (are you missing a using directive or an assembly reference?) C:\Games\The Sims 3\Mods\Jinxx.Sims3Game.Test\Jinxx.Sims3Game.Test\Class1.cs 23 30 Jinxx.Sims3Game.Test
Error 2 The type or namespace name 'IGameObject' could not be found (are you missing a using directive or an assembly reference?) C:\Games\The Sims 3\Mods\Jinxx.Sims3Game.Test\Jinxx.Sims3Game.Test\Class1.cs 101 21 Jinxx.Sims3Game.Test
from what I can see, I'm not missing a using directive. Any ideas?
cheezegrate
28th Sep 2009, 11:51 AM
How do I open the disassembler exactly, I am pressing the space bar yet nothing is coming up?
ani_
28th Sep 2009, 12:24 PM
Jinxx: Click on those two that are giving you a problem with your mouse right button, then select resolve and it should give you options on references you need, you can straight click them from the list it gives you.
cheezegrate: You as well need to click the class you want to see with the right side mouse button and selecte it from there, I also couldn't launce it with space.
Colour
30th Sep 2009, 07:12 AM
Ah well
Kolipoki
3rd Oct 2009, 12:39 AM
Ani: tiger created a jazz script mod thing, ive never tried it but go ahead if you want:
http://www.modthesims.info/download.php?t=365465
cwurts00
12th Oct 2009, 11:07 PM
You sent us to another tutorial with 4 steps. The first one says "use the Visual Studio C# Template, but I have no idea what program I should be running for these steps.
Edit: I downloaded "Microsoft Visual C# 2008, but it doesn't appear to be the right program, and I was unable to find a copy of "Microsoft Visual Studio 2008 Express" anywhere. I am now stuck on that one step.
Jasumi
15th Oct 2009, 02:13 AM
Thanks for the useful info.
Now I am wondering if anyone has located all the scripts for the Inventory, as I am not in the mood to hunt them down unnecessarily. By "inventory", I am referring to the "virtual napsack" sims store items in, as I would like to override some of it's functions a bit.
zomgwowlolz
24th Nov 2009, 12:13 AM
Quick Problem: The sims 3 package editor demo link is not working. i downloaded a different program called 3-something, but just in case it doesnt work, could you fix the link?
Odistant
29th Nov 2009, 01:06 PM
Quick Problem: The sims 3 package editor demo link is not working. i downloaded a different program called 3-something, but just in case it doesnt work, could you fix the link?
http://modthesims.info/forumdisplay.php?f=604
That's the link to the forums. It has s3pe and s3oc witch are the two programs you need to download.
This guide is a bit out of date with the current way these programs work, but I was able to follow it perfectly fine.
ChaosMageX
5th Dec 2009, 05:36 PM
Here's a little something extra for your tutorial, Kolipoki:
If you want to add an interaction to object when it's in a sim's inventory, simply add this code to the object's OnStartup() overridden method:
public override void OnStartup()
{
//Add these first two lines ONLY ONCE:
base.OnStartup();
base.AddComponent<Sims3.Gameplay.ObjectComponents.ItemComponent>(new object[] { false, typeof(sim) });
//Add this line for each interaction you want to add:
base.AddInventoryInteraction(TalktoMe.Singleton);
}
Of course, you have to make sure you've cloned your object from an object that you can actually place in a sim's inventory.
gnowor
16th Dec 2009, 09:11 AM
When I try to modify objects in S3PE and add the key to refer to my new code, I'm running into a bit of a problem. When hit Grid on the OBJK, it doesn't give me a collection of keys (thus causing problems for where I should add a key referring to my new code). Attached you'll find a screen shot (this is actually taken off a cloned bear like the one you used in your example - originally I thought it might just be due the fact that I was using a Dive Well).
I'm wondering if EA changed the way objects are stored in World Adventures and that's why S3PE is having an issue? Any advice is appreciated.
kjmarket
16th Dec 2009, 09:00 PM
Same problem here. Was thinking it was just me. Is it a change in the game or the latest version of S3PE?
gnowor
20th Dec 2009, 11:51 PM
Thanks to some help on another thread I learned that now you just have to hit the "Edit" button under external. It will open up the OBJK editor. Make sure "Script" is checked in this new window, and then input the namespace.class reference to your mod (as you did in Keys previously). That's all it takes.
OBJK editor. How convenient!
Smotty
26th Dec 2009, 06:30 AM
Thanks for the Tutorial, unfourtunatly I'm running into a lot of proplems, First up the link to the package editor is dead, but I managed to get the non demo version(one compatible for WAetc.)
Problem starts with the coding though, in Visual Studio I cant find the active configuration refered to in step 3 of the setup link. When ever I ty to do any coding I get one or two error messages, even when I try to copy an exsiting code or your final code in the tutorial (no changes to either), some one else refered to right clicking the error to fix/resolve, but I don't get any options along those lines.
Ended up giving up on that program and went to play around with the s3pe program, and when I get to add resource part of the process I can't seem to get the ok button to highlight, all fields where filled in, tried using the drop down as well as just typing it in and nothing.
All of the other steps work fine, just going around in circles with these two problems, any advice would be appreciated. Thanks.
bella3lek4
16th Jan 2010, 10:48 PM
Hi ..
i am having a problem ..
i tried to do the Talking Teddy exactly like it's written in the tutorial ..
[ I copied the text in the final results .. from the tutorial .. and i pasted it in my C# project ..]
i did everything as written .. i exported the Dll's and everything ..
i think i did everything right ..
But in game .. when i buy the Talking Teddy and try to click at it .. it gives me the hand grab tool .. and its written .. [ there are no interactions available ] ...
Please help !
Thanks everybody! :)
--> Sorry for my bad English :( <--
PigiePower
17th Jan 2010, 05:53 PM
I'm having the same problem as bella3lek4 :(
HugeLunatic
17th Jan 2010, 06:59 PM
Sounds like a framework issue if instead of the object having an interaction menu available it only has the hand for grabbing.
Use Delphy's Framework Installer to make sure your framework is set up correctly.
bella3lek4
17th Jan 2010, 10:34 PM
I don't think that's the problem ..
because i have Dexter the bear .. and it works perfectly for me
so i guess it's something else .
Thanks for help!
Kolipoki
18th Jan 2010, 12:22 AM
A) I'm surprised that you could get anything working out of the old tutorial as it was so outdated.
B) It does sound like you are missing the framework, but another cause would be the code. If you would have run it you should have gotten an error saying there is no ktip styled notification. I have updated the tutorial and the code so I advise you to try again. If it still does not work, then it has something to do with your computer. I have just gone through the entire new tutorial and have gotten it to work. Good luck.
PigiePower
18th Jan 2010, 01:44 AM
A) I'm surprised that you could get anything working out of the old tutorial as it was so outdated.
B) It does sound like you are missing the framework, but another cause would be the code. If you would have run it you should have gotten an error saying there is no ktip styled notification. I have updated the tutorial and the code so I advise you to try again. If it still does not work, then it has something to do with your computer. I have just gone through the entire new tutorial and have gotten it to work. Good luck.
I don't know what did it but ether 1)useing Delphys framework tool or 2) using C# 2008 express to code in (i like the intellisence) and use Digitalchaos' Assembly Generator to acttualy make the .dll. anyways it works Now ^^
Kolipoki
18th Jan 2010, 06:47 AM
This tutorial is now on video and can be found at The Sims Supply, here (http://thesimsupply.com/showthread.php?tid=231).
bella3lek4
18th Jan 2010, 01:58 PM
Thanks !
It worked !
Glad that you made the video tutorial ..
it made it easier to understand ! :]
Thank you so much!
Amazing! :)
Edit:! Adding custom interactions is really really hard ..
can you add In-Depth .. how to add custom interactions .. with some samples .. because it is really hard .. and you didn't explain how to do it ..
you just show us the stereo function ..
so i suggest to explain more .. and give us some examples .. [ Text .. not Video ]
Thanks!
........
Edit ..:
Thanks for explaining ! ..
but could you please show us the code that we should type every new interaction we want to add .. and where can we find the game interactions names?
Thanks! you are amazing!
..........
Edit: I just don't know what to do .. i tried so many things ! Non of them works .. i keep getting errors ! D: :( !
I really need help .. i am about to die DX ..
Please ..
Give me an example .. to a functional interaction .. lets say .. [ Burn sim .. Get pregnant ]
Please explain .. a functional interaction .. not just a message !
Sorry i am being so weeny .. please be patient with me ..
Kolipoki
18th Jan 2010, 05:20 PM
How about I explain the one I have:
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay.Objects.Miscellaneous;
using Sims3.Gameplay.Utilities;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.SimIFace;
using Sims3.Gameplay.Skills;
using Sims3.UI;
using Sims3.Gameplay.Objects;
namespace KolipokiMod
{
public class TalkingTeddy : StuffedAnimal
{
protected Sim mRevealingSim;
public override void OnStartup()
{
base.OnStartup();
base.AddInteraction(TalktoMe.Singleton);
}
private sealed class TalktoMe : ImmediateInteraction<Sim, TalkingTeddy>
{
// Fields
public static readonly InteractionDefinition Singleton = new Definition();
private const string sLocalizationKey = "Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe";
// Methods
private static string LocalizeString(string name, params object[] parameters)
{
return Localization.LocalizeString("Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe:" + name, parameters);
}
protected override bool Run()
{
//Do the interaction here.
base.Actor.ShowTNSIfSelectable("Hello", StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, base.Actor.ObjectId);
base.Target.mRevealingSim = base.Actor;
return true;
}
// Nested Types
private sealed class Definition : ImmediateInteractionDefinition<Sim, TalkingTeddy, TalkingTeddy.TalktoMe>
{
// Methods
protected override string GetInteractionName(Sim a, TalkingTeddy target, InteractionObjectPair interaction)
{
return TalkingTeddy.TalktoMe.LocalizeString("TalktoMe", new object[0]);
}
protected override bool Test(Sim a, TalkingTeddy target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
{
return !isAutonomous;
}
}
}
}
}
This could be a very bad job but here it goes.
So to start in the class we have protected Sim mRevealingSim. This statement makes a new definition that we can store things in and gives it a protected feature meaning that it cannot be accessed out of the script. This is used later to determine what sim the teddy bear is acting on.
The public override on startup should always be there I believe, but the add interaction is used so it know to make the new interaction
You need actually need to add the interaction and tell it do something. So you make a new class with the interaction name and derive it from the ImmediateInteractions so it will Immediately happen and the sim doesn't have to walk over to it. I haven't tried other interactions but I assume these are easier (or they might be the same).
Next in the script the strings are listed to name the interaction.
As well in the script is the protected override bool Run() which will tell the interaction to do something when called. For this instance we are using the the styled notification to have the game tell the user something.
The last bit of the code, I believe its for like testing to make sure the interaction worked, and the object is not null.
mesher
27th Jan 2010, 03:45 PM
Thanks for this tut, kolipoli, and for the video at thesimsupply.
My new teddy works like a charm, but there is only one problem : it´s impossible to change the interaction string, like you describe on the last part of your tutorial. I tried it several times, triple-checking the class name (myMod.TalkingTeddy.TalktoMe) and the new generated hash (0xCE472847CC83DDFE), but that long scary string stills on teddy´s interaction menu. Intersting, the other changes that i made, like the name of the object on the first item of STBL, are accepted and showed.
May this be a sims cache issue ?
Kolipoki
27th Jan 2010, 09:28 PM
Okay, so there is an easier way that I use to change the string name. In the
private static string LocalizeString(string name, params object[] parameters)
{
return Localization.LocalizeString("Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe:" + name, parameters);
}
Change the return Localization.LocalizeString("Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe:" + name, parameters); to simple return "Interaction Name" and whatever you put in the Interaction Name will appear.
mesher
28th Jan 2010, 10:49 PM
You did it again, Kolipoki, it works fine now !
(.... gosh, read the code, mesher, just read the code ....) :deal:
There is a new universe to explore now, after a few explorations I was able to create interactions to change several variables, like sim's motives. Now I have some ideas to try...
Thanks a lot, Kolipoki.
desecrate
3rd Feb 2010, 07:49 AM
Regarding localization, the string to hash in the STBL resources must match what you pass in to the LocalizeString method, i.e. in this example you should hash "Gameplay/Objects/Miscellaneous/TalkingTeddy/TalktoMe:TalktoMe" (0x0629857C465A244D).
But you can use anything else as long as what you pass in LocalizeString matches the Hash:
Localization.LocalizeString("AnythingElse", parameters); would look for a a Hash in the resources for "AnythingElse" (0xADD4D8E85F8C9868).
Although I think it's a good idea to follow EA's naming convention [DashSeparatedNamespace]/[ClassName]:[StringName] to avoid having reapeated hashes in the resources.
For avoiding things to look wierd if I forgot to add an Hash on the STBL for some language, I replaced the localization method with this:
private const string sLocalizationKey = "Desecrate/Sims3Mod/TalkingTeddy";
private static string LocalizeString(string name, params object[] parameters)
{
string key = sLocalizationKey + ":" + name;
string localizedString = "";
if (Localization.HasLocalizedString(key))
localizedString = Localization.LocalizeString(key, parameters);
else
localizedString = name;
return localizedString;
}
ani_
14th Feb 2010, 06:09 AM
As I haven't yet found a script mod tutorial (actually I did find on another forum but forgot where it was), I'v been trying to make my first script mod with combining this tutorial, with spying on already made script mods, like twallan's woohooer and the abortion mod.
My problem is that when I'm in the OnWorldLoadFinishedHandler method, and I'm trying to get the list of object already existing,
List<Sim> list = new List<Sim>(Queries.GetObjects<Sim>());
I get the following error.
The non-generic method 'Sims3.SimIFace.Queries.GetObjects(System.Type)' cannot be used with type arguments.
Google is being of no help, as it's telling me to use System.Collections.Generic, but I'm already using it. Any ideas?
Kolipoki
14th Feb 2010, 07:37 AM
Try this instead...
List<Sim> list = new List<Sim>(Sims3.Gameplay.Queries.GetObjects<Sim>());
The reason is, is that there are two Queries, one (the one it automatically goes to) is withing the Sims 3 IFace while the one you want is in the Gameplay.
ani_
14th Feb 2010, 04:44 PM
Thanks, that helped :)
jo_humphreys
15th Feb 2010, 08:55 AM
Hey I'm having trouble getting the package editor from your link, it gives me the 404 error when I click on it...
Kolipoki
15th Feb 2010, 03:53 PM
Sorry about that, I never changed it from when they moved over to this site. Links should be working now, If not just go to the s3pi and library forum under the create - sims 3 drop down.
rebecah
16th Feb 2010, 04:03 PM
Thank you very much for this tutorial and the video.
ani_
3rd Apr 2010, 07:27 PM
A quick question. Is it possible to find the object id in s3pe? or can you only get it in code?
jadaytime
13th Apr 2010, 10:51 PM
I'm having trouble with the new version of s3pe, specifically trouble with adding the resource key. What do I put in the data part?
killovicz
19th Apr 2010, 02:14 PM
Thanks a lot for this tutorial :),,,
but I got one problem, :( I DL'ed: Microsoft Visual C# 2010 and not able to load mscorlib.dll as the reference :(, :(.
I did check the "Do not reference mscorlib.dll" in the build-prop, however I can not find "Set the active configuraiton to All Configurations"-part anywhere. There are no Configuration/Platform boxes on the top of the build configuration screen :(... I'm probably missing something obvious.
Should I un-install 2010 and go for 2008 ver. instead??
ssjbrily
2nd May 2010, 05:07 PM
for some reason when i try to open the dll files from in the tutorial video. s3pe gives me this message :(
Could not open package:
C:\Program Files (x86)\Electronic Arts\The Sims 3\Game\Bin\Gameplay.package
Front-end Distribution: 1003-06-1044
Library Distribution: 1003-06-1044
Access to the path 'C:\Program Files (x86)\Electronic Arts\The Sims 3\Game\Bin\Gameplay.package' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at s3pi.Package.Package.OpenPackage(Int32 APIversion, String PackagePath, Boolean readwrite)
at S3PIDemoFE.MainForm.MainForm_PackageFilenameChanged(Object sender, EventArgs e)
-----
brujah236
7th May 2010, 04:36 PM
for some reason when i try to open the dll files from in the tutorial video. s3pe gives me this message :(
Could not open package:
-----
I ran across that problem myself today... easy fix. Run as administrator. :)
ssjbrily
7th May 2010, 06:50 PM
Thank you sooo much brujah236 :DD
LoofahFlufferduff
15th May 2010, 04:22 AM
Question: is it possible to find the 'manifest modules' with postal? I'm not really familiar with postal, but s3pe keeps crashing when I try to view the resources. That would just be a mono thing, but it means s3pe is out.
Anyone got any insights?
PigiePower
25th May 2010, 01:17 AM
Thanks again for the wonderful tut. I was wondering how do you make nested interactions? like when you click "buy" more items come up like "1", "10","20"?
Buzzler
28th May 2010, 03:17 PM
Thanks again for the wonderful tut. I was wondering how do you make nested interactions? like when you click "buy" more items come up like "1", "10","20"?
Well, the low-brain approach would be to actually make three interactions, whose GetInteractionName() methods return "1", "10" and "20". Their GetPath() method would return {"Buy"} in this case.
You can see an example of the smart way implemented for the TurnOn interactions in the light class.
I usually use the low-brain approach BTW. ;)
Nukael
10th Jul 2010, 03:28 AM
I was doing your tutorial and noticed that since the notice box has changed since patch 1.12, the kTip isn't valid anymore.
I searched through the new patch code and ended up using kSimTalking.
The rest worked fine except for two issues: the interaction name in the game shows up as blank, even if I don't put in a string name for the interaction (and also if I do). The teddybear has the "talk to me" interaction I added (which works as expected), but also retains the two teddy interactions: "Give name to" and "pick up", is this supposed to happen? I changed the script class in the OBJK, and I don't know where else it would be finding these interactions.
Buzzler
11th Jul 2010, 12:30 PM
The teddybear has the "talk to me" interaction I added (which works as expected), but also retains the two teddy interactions: "Give name to" and "pick up", is this supposed to happen?Look at the declaration of the TalkingTeddy class:
public class TalkingTeddy : StuffedAnimalThe StuffedAnimal after the colon means that the TalkingTeddy will have everything the StuffedAnimal class has.
In OO language:
- TalkingTeddy inherits from StuffedAnimal
- TalkingTeddy is derived from StuffedAnimal
- TalkingTeddy is a sub class to StuffedAnimal
- StuffedAnimal is a base class to TalkingTeddy
- TalkingTeddy IS_A StuffedAnimal
The last one is key to the understanding of the OO principle. If you use the Sims3.Gameplay.Queries.GetObjects() method for example to find all objects of the StuffedAnimal class, it will find all objects from derived classes too, i.e. in this case the TalkingTeddy. That's because TalkingTeddy is a StuffedAnimal. Just like a German shepherd is a dog and a rottweiler is a dog. If you told someone to bring you all dogs in the area, you probably wouldn't be surprised to find him/her bringing you rottweilers as well as German shepherds.
That being said, you can still change the TalkingTeddy to stop the other interactions from showing up. Look at the OnStartup() method from TalkingTeddy:public override void OnStartup()
{
base.OnStartup();
base.AddInteraction(TalktoMe.Singleton);
}base.OnStartup(); will call the OnStartup() method from StuffedAnimal, i.e. this one.
public override void OnStartup()
{
base.AddComponent<ItemComponent>(new object[] { false, new List<Type>(new Type[] { typeof(Sim) }) });
base.AddComponent<NameComponent>(new object[0]);
base.AddInteraction(PickUp.Singleton);
base.AddInteraction(PlayWith.Singleton);
base.AddInteraction(TalkThrough.Singleton);
base.AddInventoryInteraction(PickUp.Singleton);
base.AddInventoryInteraction(PlayWith.Singleton);
base.AddInventoryInteraction(TalkThrough.Singleton);
this.StartPose(false);
}There you can see the interactions being added. To not add these interactions, remove the base.OnStartup(); from the TalkingTeddy.OnStartup() method and copy everything but the interactions stuff from StuffedAnimal.OnStartup(). The resulting TalkingTeddy.OnStartup() would look like this:public override void OnStartup()
{
base.AddComponent<ItemComponent>(new object[] { false, new List<Type>(new Type[] { typeof(Sim) }) });
base.AddComponent<NameComponent>(new object[0]);
this.StartPose(false);
base.AddInteraction(TalktoMe.Singleton);
}
Nukael
14th Jul 2010, 06:06 AM
Oh, wow, thanks so much for your reply. That helped a lot! :D
Sukhavati
14th Jul 2010, 09:09 AM
Thanks for this great tutorial.
However, no matter what I do, what I try, I can't get it to work. :/
I'm using VS2010 but I used .NET 2.0 as stated in the tutorial.
I tried to make my own object and failed so then I decided to just follow the tutorial step by step with the TeddyBear and even so it doesn't work.
I then watched carefully the video tutorial and changed what was different (no compression when creating the S3SA entry, and hashing the namespace.classname instead of just the classname as stated in the text tutorial).
Sadly, it still didn't work...
When I load the object ingame it just sits there and says "no interactions possible" when I click on it.
I downloaded Delphy's Framework installer and it says everything is fine...
I also tried using the .dll compiled using the AssemblyGenerator instead of VS2010...
I even tried with different versions of s3pe...
I've been trying to make this work for 2 days now and I have to admit it's starting to affect my sanity. :help:
Buzzler
14th Jul 2010, 04:47 PM
@Sukhavati: The "no interactions possible" means that script didn't get loaded. From my experience I can tell that the absolute value of the instance doesn't matter. It only needs to be unique. There's a distinct possibility for an instance conflict, but that's really unlikely. When a GameObject gets instantiated without a script, it's usually because the script class entry in the OBJK resource isn't set correctly.
You might want to upload your package so people can have a look at it.
Sukhavati
14th Jul 2010, 05:18 PM
As I said, I tried many things following this tutorial and reading up the comments after, still don't know why it's not working as I specified each time namespace.classname in the OBJK resource. :(
Here's the latest package I tried.
Buzzler
14th Jul 2010, 06:08 PM
@Sukhavati: Your package works fine. If you're loading a savegame (without deleting the scriptcache) with the teddy already placed, the script won't get updated when you update the package. Always buy a new object from the catalog to make sure it gets the latest version of the script. It's either that or you're having framework failure, i.e. the game doesn't load custom scripts to begin with.
Sukhavati
14th Jul 2010, 06:28 PM
:wtf:
I buy a new item each time I try... And I have a few other mods installed (and they're working)...
Hmmm... I'm really gonna lose the last shred of sanity I have...
Ok, well, at least it eliminates some variables as to why it's not working, up until now I thought the package was to blame... :)
I'm gonna try deleting the scriptcache, without any other mod, etc...until this damn thing works!!!!
Thanks for the help. :up:
Buzzler
14th Jul 2010, 06:33 PM
And I have a few other mods installed (and they're working)...Yes, but are these script mods? Tuning mods won't tell you anything.
Sukhavati
14th Jul 2010, 06:43 PM
Hmm, not sure, only got the nointro and nomosaic mods.
I just tried ingame after deleting the cache and removing the other mods and still no luck...
I'll keep looking...
Sukhavati
14th Jul 2010, 06:58 PM
AHHH!!!!
I found it!!!
And indeed, it's working :D
I installed the Resource.cfg and the mods something like a year ago when the mod folder was going into the game folder.
Now it goes into "my documents"..............
I wish I had looked this up sooner... :rolleyes:
My bad...
And many thanks for the help, I could have kept on recreating that package for weeks (or give up before killing someone :p) without your insight.
Now it's time to try and create the package I had in mind. :lovestruc
Melodia91
1st Sep 2010, 09:26 PM
Thank you so much! I had a lot of difficulty following the written tutorial, but the video made it a whole lot easier.
Thank you :)
IdrilR
14th Sep 2010, 03:36 PM
Hi.
Thanks for this tutorial, it is really helpful. I managed to make my bear talk without problem, but I tried to modify an other object (a fence gate) and it won't appear in the catalog, I don't know why...
Agent_N
1st Nov 2010, 02:15 PM
Hi,
I have a problem when i want to test my object. The game just crashes with a stack overflow exception when I click on my cloned object in the buy catalog. It seems that it can not find my code file as the object cloning works as long I do not change the OBJK to my class. (The game do not crash if I change it to the stereo class, the object is just not placeable then).
I'm having AMB and WA as expansion packs and use the latest version available (1.17 for base game). I'm using the new way for installing .package files.
I have checked that no other mod/download is conflicting my object by using new sims 3 folder under my documents. I have also tested the package from Sukhavati available above and have the same effect so it seems not to be an error while creating the object itself. If it does matter I tried the create the object using the latest version of s3pe and s3oc and tried to generate the assembly file with Visual Studio 2010 and alternative with the Assembly Generator available on this website.
Anyone an idea whats going wrong?
uranoxyd
1st Nov 2010, 06:32 PM
Exactly the same (Agent_N) problem here.
Base Game: v1.17.60
WA: 2.12.8
Ambitions: 4.5.6
The problem also appears with the StatueOfLife Mod wich worked well until i patched to (i think 1.17.60)
Greets
David
claudiasharon
2nd Nov 2010, 11:41 AM
How do I open the disassembler exactly, I am pressing the space bar yet nothing is coming up?
cheezegrate: You as well need to click the class you want to see with the right side mouse button and selecte it from there, I also couldn't launce it with space.
I'm having the same problem and I don't understand the solution...I'm kind of new to this program. :\
gladosrev2
3rd Nov 2010, 06:41 PM
First of all, thanks for the in-depth tutorial! It's just what I was looking for :)
The game just crashes with a stack overflow exception when I click on my cloned object in the buy catalog.
I have the same problem. I did all exactly as in the tutorial, using Visual C# 2010 Express. The Teddy works, when it's only cloned, but when I add the dll, clicking on it in Buy Mode crashes the game to desktop. I have deleted the 4 cache files and am not using any saved games.
I thought maybe I used the wrong original .dlls, so I tried it again, this time with the .dlls from World Adventures Bin folder (I think they are the same as in the base game anyway), but after recompiling and reattaching my .dll, the game crashed just like before when clicking on the teddy.
My framework is working, I use the Extended Core Mod and some cosmetic mods, nothing that conflicts. On a side note, when I use the Chaos Painting by ChaosMageX, the game crashes in exactly the same way (that mod is not updated).
I have only WA installed, latest patch: 2.12.8.009002
Does anyone have a solution please? :(
[Edit]
SOLUTION:
It seems the game crashes because it does not recognize the custom namespace name. Simply change the namespace name to the name of the object's original namespace. In the example code in this tutorial, change
namespace KolipokiMod
to
namespace Sims3.Gameplay.Objects.Miscellaneous
recompile the project, reattach the .dll, adjust the key and all works! :)
I found the solution here: http://www.modthesims.info/showthread.php?t=423291
How do I open the disassembler exactly, I am pressing the space bar yet nothing is coming up?
Double clicking with the left mouse button on a function name in the Reflector should open the Disassembler on the right side, showing the function code.
Thanks a lot for this tutorial :),,,
but I got one problem, :( I DL'ed: Microsoft Visual C# 2010 and not able to load mscorlib.dll as the reference :(, :(.
I did check the "Do not reference mscorlib.dll" in the build-prop, however I can not find "Set the active configuraiton to All Configurations"-part anywhere. There are no Configuration/Platform boxes on the top of the build configuration screen :(... I'm probably missing something obvious.
Should I un-install 2010 and go for 2008 ver. instead??
I got this to work with Microsoft Visual C# 2010 Express. Couldn't find the configurations as well, so skipped it (seems to be set to Release by default). I actually had to uncheck "Do not reference mscorlib.dll" to get the project to compile, it threw an error otherwise.
nytwish
18th Nov 2010, 12:02 AM
nice tutorial btw and thanks for sharing sir, but i cant seem to understand this part. perhaps can you tell me where can i see this? thank very much. :) :gjob:
After your new resource is created go to the OBJK, Collection of Keys, 2nd Key and type "[Your Namespace Name].[Your Class Name] For this example it would say KolipokiMod.TalkingTeddy. Next you need to import your dll. Click on the S3SA and hit grid. The first item on the list should have an import/export click on it, bring the drop down menu down and click import. Navigate to your dll of your code "Visual Studio 2008 - Projects - [name of saved project here] - [name of saved project here] - obj - release - [nameofproject].dl" and hit open, after that hit commit and save your project. If all went well then you know have a nice object that will tell you Hi.
EDIT
after reading the comments , i changed the string key in objk with Sims3.Gameplay.Objects.Miscellaneous.KolipokiMod.TalkingTeddy with the namespace on my dll file named Kolipoki. i also got the problem no interaction.. here is my package and dll file..
Files Here (http://dl.dropbox.com/u/1410596/Desktop.rar)
ps. i tried using the monkey bar and no problems with framework whatsoever, can someone tell me what i need to do? :faceslap:
velocitygrass
18th Nov 2010, 06:39 PM
The change of namespace needs to be BOTH in the code for your .dll AND in the OBJK.
The .dll in your package still has the namespace KolipokiMod
namespace KolipokiMod
{
public class TalkingTeddy : StuffedAnimal
// more stuff
}Change this to:
namespace Sims3.Gameplay.Objects.Miscellaneous.KolipokiMod
{
public class TalkingTeddy : StuffedAnimal
// more stuff
} then recompile, import the .dll again and it should work.
Gekedec
19th Dec 2010, 11:15 PM
Hi people! I've got a problem with the Object Modding tutorial, specifically while testing the new object....I did everything Kolipoki said, I even used the same names and the same Teddy bear as the new object so it would say hi to me in-game. However, when I start the game, get into a family and go to Buy Mode, I can see the new teddy but I can't buy it.....I can grab it with the hand tool but it never releases the bear....leaving me unable to buy it...Does anyone know why? Thanks! :cry:
HugeLunatic
20th Dec 2010, 02:11 PM
Did you update the scriptclass as discussed in this thread? http://www.modthesims.info/showthread.php?t=423291
Gekedec
21st Dec 2010, 04:20 PM
Did you update the scriptclass as discussed in this thread? http://www.modthesims.info/showthread.php?t=423291
I think I did this....but I don't know if I did something wrong. The tutorial says to go to the OBJK so I can change the second key....so I chose the OBJK, hit grid, went to "Component data" and hit "...", there I found "CDTAssetResourceName" and "CDTString"...I chose the second one and went to the "key" field. It said "scriptclass" so I changed it for "Sims3.Gameplay.Objects.Miscellaneous.KolipokiMod.TalkingTeddy"...is it correct? or I had to change the key field of CDTAssetResourceName?
I even tried changing the namespace as suggested in the thread but nothing happens...I can't still buy the bear.
EDIT: I can now buy the Bear! I had to change the "Data" field NOT the "Key" field....silly mistake! Thanks for making me pay attention to the scriptclass in OBJK ;)
SeeMyu
21st Dec 2010, 09:51 PM
Hello, well im having a problem which i think it's either scripting or something else. Okay first, I did this tutorial and wrote out the code on this tutorial for me to actually understand code (sorta helped) and just incase, i erased all that i wrote out and copied and pasted the code in this tutorial (i was afraid it had mistakes) and i did everything it told me to do..but when i go into the game, i just get "No Interactions Available" <I read about that on the previous page so you dont have to tell me.
okay well.. I do have the framework, i do have a couple of scripting mods though, could that be the reason? I've tried this multiple times with Visual C# and Assembly Generator and still no luck.
The scripting mods i am using are:
NRaas DebugEnabler
Buzzlers Scribbling Pad
and some mod that changes the color of your CAS, not sure if that's a scripting mod
EDIT: I also changed the namespace to i.e. Sims3.Gameplay.Objects.Decorations.Mimics.MysteryMirror
and it still doesn't work :faceslap:
SeeMyu
21st Dec 2010, 10:21 PM
I now am getting this error message on Visual C# whenever i code D:
"Predefined type 'System.Objects' is not defined or imported"
and it doesnt give me the line or column number :wtf:
http://i51.tinypic.com/e9ddoh.jpg
:(
Gekedec
23rd Dec 2010, 05:48 AM
I now am getting this error message on Visual C# whenever i code D:
"Predefined type 'System.Objects' is not defined or imported"
and it doesnt give me the line or column number :wtf:
http://i51.tinypic.com/e9ddoh.jpg
:(
It also happened to me...and I solved it by unchecking the "Do not reference mscorlib.dll" in the project's properties as opposed to what the VS tutorial said...I completely ignored that step that involves the configuration and the mscorlib....plus I didn't even extract the mscorlib.dll from the game's packages... You should watch the tutorial's video suggested by Kolipoki because it shows exactly what you have to do....and you will notice that mscorlib.dll is completely ignored and excluded from the references that are supposed to be called by the VS project.
Now I have a question for everyone...I can buy the bear and make it say hello as intended but the action's in-game text (the one that is supposed to be long and changed for something shorter and clearer, when you click on the object) doesn't exist!! There is nothing there....just a blank space...but as I said, even though it doesn't show the name of the action, I can still click on it and it will execute the hello thing. Any ideas regarding this issue?
SeeMyu
29th Dec 2010, 07:48 PM
Okay I seriously need help. I even tried this and It's not working at all. I keep getting "No Interactions Available"!
Its not conflicting, I removed all my scripting mods, deleted all cache, and checked if i had my framework and I do.
This is really starting to bug me that I cannot get this to work..
Help anyone?
lenglel
11th Jan 2011, 04:13 PM
Personally, I work on the theory that if my game was working with my other mods,
and quit working when I install my latest attempt, then the problem must be within
my latest attempt at mod creation. Saves a lot of file shuffling, and lets me focus
on finding the difference between my non-functioning mod and the tutorial author's
example. Lately that turned out to be a .dll with a namespace that differed from
the cloned objects. Have you checked that? It's why my object didn't have any
interactions. Look under "Finding the original objects name" in the first post for
help with that.
Enirei
17th Feb 2011, 02:45 AM
Just in case someone is watching this thread and could help me. I've been having trouble with the disassembler portion. I tried space bar and right clicking but nothing shows up other than copy and a couple of view options. I've tried in both Visual Studio C# 2010 Express and Visual Studio 2008. Any help and/or suggestions would be greatly appreciated.
HugeLunatic
17th Feb 2011, 03:54 AM
I believe the disassembler portion is referring to Reflector, not Visual Studio. That is where your looking up the EA class and determining what it does. You can either hit space bar or double click.
Enirei
17th Feb 2011, 05:46 AM
Oh. That explains a lot. Thank you :3
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.