Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 16th Jul 2019 at 11:34 PM
Default "Simplified" Roaring Heights Car
I'm totally new to modding and scripting, but I've been learning a lot through youtube and peeking around at the code for other objects. My goal is to make a modified object that is basically a clone of the roaring heights car. I plant to remove all of the social actions as well as the action for getting into the car. Then there is the whole deal about getting sims to line up so the animation looks decent. I guess I will cross that bridge if I get to it. I thought I would start with the code because I'm slowly starting to understand that part. Feel free to point me toward valuable resources about sims 3 modding or C# in general. This is the starting code I have so far.

Code:
using Sims3.Gameplay;
using Sims3.Gameplay.Abstracts;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.CAS;
using Sims3.Gameplay.Core;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.InteractionsShared;
using Sims3.Gameplay.Interfaces;
using Sims3.Gameplay.ObjectComponents;
using Sims3.Gameplay.Objects.Electronics;
using Sims3.Gameplay.Objects.Vehicles;
using Sims3.Gameplay.Seasons;
using Sims3.Gameplay.Skills;
using Sims3.Gameplay.Socializing;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using Sims3.SimIFace.CustomContent;
using Sims3.SimIFace.Enums;
using Sims3.UI.Controller;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace Sims3.Gameplay.Objects.Miscellaneous.LBIllusion
{
    public class FixedCar : FixerCar
    {


I believe I can delete the socializing and seasons references because I don't want the option to socialize or to put the top down. I then pretty much copied the code but took out the lines that added functionality I didn't want. I can post more of the code, but it's nearing 500 lines at this point even with the omissions. Is this a good method or will it yield trash results in your opinion? I thought this would be a simple start into modding given my ambitions.
Advertisement
Space Pony
#2 Old 17th Jul 2019 at 1:33 AM
Quote: Originally posted by Lbillusion
I'm totally new to modding and scripting, but I've been learning a lot through youtube and peeking around at the code for other objects. My goal is to make a modified object that is basically a clone of the roaring heights car. I plant to remove all of the social actions as well as the action for getting into the car. Then there is the whole deal about getting sims to line up so the animation looks decent. I guess I will cross that bridge if I get to it. I thought I would start with the code because I'm slowly starting to understand that part. Feel free to point me toward valuable resources about sims 3 modding or C# in general. This is the starting code I have so far.

I believe I can delete the socializing and seasons references because I don't want the option to socialize or to put the top down. I then pretty much copied the code but took out the lines that added functionality I didn't want. I can post more of the code, but it's nearing 500 lines at this point even with the omissions. Is this a good method or will it yield trash results in your opinion? I thought this would be a simple start into modding given my ambitions.


I'd suggest reading up on how inheritance in C# works. Since you are deriving your class FixedCar from the game object FixerCar, every method and interaction from FixerCar will already be present in FixedCar by default; any code that you copy-paste from FixerCar into FixedCar is redundant and unnecessary. So, then, if all the properties and functionality of FixerCar are already present in FixedCar, then this is all you would need to write:

Code:
namespace Sims3.Gameplay.Objects.Miscellaneous.LBIllusion
{
    public class FixedCar : FixerCar
    {
        public override void OnStartup();
        {
            base.OnStartup();
            base.RemoveInteractionByType([Singleton of the interaction you want to remove]);
            //Repeat the method above for each interaction you want removed
        }
    }
}


What this is saying is "When my FixedCar object is created by the game (i.e. when it 'starts up'), then run the OnStartup() method contained within the FixerCar class (which adds all the FixerCar interactions), then remove some of those interactions that I've listed here by their static singletons."

And there you go! No 500 lines necessary

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Test Subject
Original Poster
#3 Old 17th Jul 2019 at 7:17 AM
Thanks for the advice. I'll come back to this after reading some more. I was looking through the code and so far this jumped out to me. I used the transmogrifier to copy the script to a regular car and when it's complete it reverts to the fixed version of the car. That is what this command in the spoiler does correct? There are two interactions to fix the car and four "states" the car can be in. The work on body command seems to work on a few cars, the work on engine command causes routing failures more than does working on the body.



This what I meant by the four states. These are three and the fourth is being fixed. It doesn't change at all during these states but it does play the VFX when it reaches the completion percentage. I'm gonna try and do some more general C# cramming and get a better understanding of that. It seems like I have many of the pieces, but I have to find the missing ones and put this puzzle together. I know the code may be formatted slightly wrong, but I was lazy copying pasting the code. I'm still learning...

More Conjecture

Check out my blog - Nostalgia Gamez
Space Pony
#4 Old 18th Jul 2019 at 3:08 AM
Quote: Originally posted by Lbillusion
Thanks for the advice. I'll come back to this after reading some more. I was looking through the code and so far this jumped out to me. I used the transmogrifier to copy the script to a regular car and when it's complete it reverts to the fixed version of the car. That is what this command in the spoiler does correct? There are two interactions to fix the car and four "states" the car can be in. The work on body command seems to work on a few cars, the work on engine command causes routing failures more than does working on the body.



This what I meant by the four states. These are three and the fourth is being fixed. It doesn't change at all during these states but it does play the VFX when it reaches the completion percentage. I'm gonna try and do some more general C# cramming and get a better understanding of that. It seems like I have many of the pieces, but I have to find the missing ones and put this puzzle together. I know the code may be formatted slightly wrong, but I was lazy copying pasting the code. I'm still learning...

More Conjecture

Yes, you're right: what the ReplaceBadCarWithFixedCarIfComplete() method is doing is removing the run-down version of the car from the game completely, and replacing it with the working, drivable version -- honestly, a pretty odd way of doing things if you ask me, but understandable given what we have to work with. Anyway, you'd have to replace this method with one that creates an instance of whatever car you're working with, and "Sims3.Gameplay.Objects.Miscellaneous.LBIllusion.FixedCar" as the script class.

The material state issues and awkward interaction animations are a by-product of forcing them onto car models they were not intended for. You'd have to ask someone who is more well-versed in object creation than I am what to do about that

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Test Subject
Original Poster
#5 Old 18th Jul 2019 at 5:35 AM Last edited by Lbillusion : 18th Jul 2019 at 9:35 AM. Reason: Removed a question
I possibly found a tutorial on how to fix how the animations and VFX line up, but I have to find it again. I start putting the code into Visual Studio and I see your point about the redundancy. That's how I also learned the car isn't merged with the core dll. I may change my methodology slightly. If I wrote it like this instead, could I still reference the interactions and animations linked to the FixedCar? I wish I had a better understanding of the terminology...I hope I make sense.

I know the rest of the code is missing. I don't know which classes I can get rid of. I don't mind it acting as a radio, I'm pretty sure that's what IDanceable class does. I changed the namespace to a vehicle because I thought this would be more appropriate or are all mods misc. for a reason? An example of what I mean of referencing the interaction below:
Code:
 private sealed class WorkOnBody : Interaction<Sim, FixerCar> 

How I understand this is that WorkOnBody is derived from Interaction<A,T>, so could I then derive an interaction from that like, FixBody : WorkOnBody or would my interaction need to be its own class? (FixBody : Interaction <Sim, MechanicCar>) and then reference the animation later? I'm thinking the latter option is correct. Am I on the right track? I'm still doing a lot of reading, but looking at different code is helping it make more sense. I'll do some more digging in the meantime. I hope I am making some sense, lol.

Check out my blog - Nostalgia Gamez
Space Pony
#6 Old 18th Jul 2019 at 12:20 PM
Quote: Originally posted by Lbillusion
I possibly found a tutorial on how to fix how the animations and VFX line up, but I have to find it again. I start putting the code into Visual Studio and I see your point about the redundancy. That's how I also learned the car isn't merged with the core dll. I may change my methodology slightly. If I wrote it like this instead, could I still reference the interactions and animations linked to the FixedCar? I wish I had a better understanding of the terminology...I hope I make sense.

I know the rest of the code is missing. I don't know which classes I can get rid of. I don't mind it acting as a radio, I'm pretty sure that's what IDanceable class does. I changed the namespace to a vehicle because I thought this would be more appropriate or are all mods misc. for a reason? An example of what I mean of referencing the interaction below:
Code:
 private sealed class WorkOnBody : Interaction<Sim, FixerCar> 

How I understand this is that WorkOnBody is derived from Interaction<A,T>, so could I then derive an interaction from that like, FixBody : WorkOnBody or would my interaction need to be its own class? (FixBody : Interaction <Sim, MechanicCar>) and then reference the animation later? I'm thinking the latter option is correct. Am I on the right track? I'm still doing a lot of reading, but looking at different code is helping it make more sense. I'll do some more digging in the meantime. I hope I am making some sense, lol.

Namespaces just serve as a way to organize code in your projects; you can pretty much name them whatever you want.

The way you described makes sense to me. You can say FixBody : WorkOnBody, however one thing you will need to do is override the definition -- this is a gotcha that's caused me some frustration on multiple occasions. You can do that like so:

Code:
new public class Definition : InteractionDefinition<Sim, MechanicCar, FixBody>
{
    //You can copy-paste code from the old definition here
}


You'll notice that the third type specified in the inherited InteractionDefinition type was FixBody; if we had inherited the definition instead, it would still point to WorkOnBody and all of its methods, meaning FixBody would never be properly injected.

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Back to top