[GUIDE]How to make mods for MySummerCar?
NOTE: This is a work in progress please let me know if anything is wrong, something feels like its missing or you have any questions.
NOTE: Some of the code/snippets have been written on the fly and has not been tested. Some may be faulty but please notify if they are and I will correct it!
NOTE: If you have any questions, need help or perhaps are thinking about something NOT covered in this thread PLEASE POST YOUR "OFF TOPIC" QUESTION IN THIS THREAD:
http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/
Skip to actual guide!
Scoll down to the headline "So where should I start?" and begin there!
What will I cover?
I will cover where to start in order to start making mods.
I will provide some very helpful snippets of code.
I will provide useful links and a FAQ.
Why are you doing this?
When I got introduced to the game and my friend showed me the mods I thought it would be fun trying to make one myself but that was not as easy as I thought.
(I NEVER inteded to ever release the mod I created either... but it became too good lol)
With a bit if research I managed to find MSCLoader Wiki and that got me started and setup.
Once everything was setup and working I started by creating a mod-project using the template provided by @piotrulos (The creator of the MSCLoader and forever a legend) and here is where I ended up stuck.
If I wanted to make some changes to an object in the game... How would I proceed?
If I wanted to make some changes to information in-game... How would I proceed?
This is where I ended up researching further and how I ended up finding the new thread created just 30 minutes earlier.
This thread is where I ended up being active in for a while when I was getting around and learning the process of making mods. (This is my first time ever...)
You can find this thread here: http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/
... and this is why I'm creating this guide, simple as that
(This part bellow is optional)
My initial instinct was to create a plugin that would make a list of all gameobjects in the current scene (World)... that way I knew what I could work with..
MySummerCar SceneObjects SourceCode: https://pastebin.com/pVqttvzH
MySummerCar Scene Objects list: https://pastebin.com/tkXq5mYd (Version: Dec 2017, this has changed!)
This was however, very, unnecessary since @zamp has created, litteraly, the ultimate developer toolkit for modding!
Also, after this I started PM conversations with @kunedo who has been very helpful with Ideas... hes just a really friendly and amazing guy all around helping etc. Thanks, really!
So where should I start?
First, you will need an IDE; Visual Studio.
You can find it here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15
Secondly, you should start with finding the MSCLoader Wiki and start setting up your environment. Read through and learn how to use the MSCLoader:
You can find MSCLoader Wiki here:
https://github.com/piotrulos/MSCModLoader/wiki
NOTE: You may download either x86 or x64 bit version of Unity and reading both for player and developer is very useful.
Third, start by downloading and "installing" the "Developer Toolkit" so you can easily find and quickly modify gameobjects in the world.
Saves a lot of time not having to make changes, build and restart the game every time you try a new set of code for example in placing or re-placing gameobject in the world.
You can find Developer Toolkit here:
http://www.racedepartment.com/downloads/plugin-developer-toolkit.17214/
NOTE: Some Objects/Components also needs referenses to Assembly-CSharp.dll file.
("Steam\steamapps\common\My Summer Car\mysummercar_Data\Managed\Assembly-CSharp.dll")
Drivetrain, for example, does need this reference to work properly.
Thanks to @tommojphillips for finding this!
How can I make changes in-game?
This is fairly easy and basic kowledge. MySummerCar is created using Unity® software and that opens up a whole lot of methods, classes and libraries we can use.
Transforms, for example, is used to store an objects position, rotation, scale and parenting state.
MySummerCar is also using an asset called PlayMaker which makes it a whole lot harder at the same time. Depending on your goal ofcourse.
First, if you would like to make changes to example the car, Satsuma for example...
We need to create a variable/reference name:
Right now the reference is empty and we need to give it a reference to the object in the game..
Give it a reference/value:
Now the reference is set and we can access for example the transforms of the object to move or make changes. We can also activate/deactivate the object in the world. Now that we know how to access an object... How can I make changes to the information in the game?
This part is a bit tricky.. You need to find out which GameObject in the scene is "hosting" the component which makes these changes in order to change them... Unless they are maintained by a singleton instance. If they are maintained by singleton and are instanced they can, globally, be read or changed without the need of the "hosting" object.
Making changes to a component/variable:
This means that you are getting the component "DriveTrain" on the Object "SATSUMA(557kg, 248)" and you may make changes or read values/variables from that component.
If it is a singleton variable or information you are looking for you may use a foreach method to get what you want to find:
Making a foreach for PlayMaker FSM:
How do I detect if a player is in vehicle/car/"drive mode"?
Taking a look back to our code earlier we can use the PlayMaker FSM here and check if player is in any vehicle.
How do I use custom assets?
(I cant find the player!)
How do I find player?
OLD TUTORIAL; MSCLoader <= 0.3.5;
Finding the player is a bit tricky compared to finding another object in the world since it is "spawing" rather late.
Once OnLoad has finished running in your mod it has most likely not spawned yet and will result in a nullreference exception.
How do we make this work?
There are multiple options but I'm going to show you two:
**Threading removed**
Good luck and have fun!
Annoyances (and tips) of building mods:
When you are making mods you'll be, eventually, annoyed by three (major) things...
1: As a developer you need to manually copy the mod to the mod folder every time you makes changes/build the mod.
But that can be fixed by using this piece of code:
It's basicly a "batch"/CMD command to copy the mod dll file to the location of your MSC mod folder.
How do I do that?
A: Right-click -> Properties
B: Find the tab "Build Events"
C: Find "Post-Build Event Command line" textarea and modify/copy the code above for everything you want to move with the build on each seperate lines.
D: Save.
E: Build and Enjoy!
2: You will need to restart the game a lot in order to test out the mod and check it out. (There, currently, isn't a way around this atm)
3: Bad reviews.
You may get bad reviews from users who doesn't "install" the mod correct, haven't bought the actual game and is playing on pirate copies etc.
My advice.. Brush it off and don't bother. If you enjoy creating, create and if you get a bad review or someone is being mean, ignore them and continue with your work.
My experiences and mods:
My experience has been great, No dubt. BUT lately i must admit that my interests have turned and I have been forced to focus on diffrent things. Work as an example has been very hectic.
I caught a break now and I wanted to help out the community
MySummerMultiMod: http://www.racedepartment.com/downloads/mysummermultimod.19405/
Useful links:
MSCLoader Wiki : https://github.com/piotrulos/MSCModLoader/wiki
PlayMakerFSM : All PlayMaker FSM
@zamp : https://github.com/zamp/MSC-Mods
@Roman266 : https://github.com/GishaSeven/Plugins-for-MSC-ModLoader
@tommojphillips : 2 Links below.
ModAPI: https://github.com/tommojphillips/ModAPI/wiki
Demo: https://github.com/tommojphillips/AttachObjectDemo
Special thanks to everyone who has provided information or helped with some outdated information!
Good nite everyone
NOTE: This is a work in progress please let me know if anything is wrong, something feels like its missing or you have any questions.
NOTE: Some of the code/snippets have been written on the fly and has not been tested. Some may be faulty but please notify if they are and I will correct it!
NOTE: If you have any questions, need help or perhaps are thinking about something NOT covered in this thread PLEASE POST YOUR "OFF TOPIC" QUESTION IN THIS THREAD:
http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/
Skip to actual guide!
Scoll down to the headline "So where should I start?" and begin there!
What will I cover?
I will cover where to start in order to start making mods.
I will provide some very helpful snippets of code.
I will provide useful links and a FAQ.
Why are you doing this?
When I got introduced to the game and my friend showed me the mods I thought it would be fun trying to make one myself but that was not as easy as I thought.
(I NEVER inteded to ever release the mod I created either... but it became too good lol)
With a bit if research I managed to find MSCLoader Wiki and that got me started and setup.
Once everything was setup and working I started by creating a mod-project using the template provided by @piotrulos (The creator of the MSCLoader and forever a legend) and here is where I ended up stuck.
If I wanted to make some changes to an object in the game... How would I proceed?
If I wanted to make some changes to information in-game... How would I proceed?
This is where I ended up researching further and how I ended up finding the new thread created just 30 minutes earlier.
This thread is where I ended up being active in for a while when I was getting around and learning the process of making mods. (This is my first time ever...)
You can find this thread here: http://www.racedepartment.com/threads/how-too-start-programming-mods-for-my-summer-car.146394/
... and this is why I'm creating this guide, simple as that
(This part bellow is optional)
My initial instinct was to create a plugin that would make a list of all gameobjects in the current scene (World)... that way I knew what I could work with..
MySummerCar SceneObjects SourceCode: https://pastebin.com/pVqttvzH
MySummerCar Scene Objects list: https://pastebin.com/tkXq5mYd (Version: Dec 2017, this has changed!)
This was however, very, unnecessary since @zamp has created, litteraly, the ultimate developer toolkit for modding!
Also, after this I started PM conversations with @kunedo who has been very helpful with Ideas... hes just a really friendly and amazing guy all around helping etc. Thanks, really!
So where should I start?
First, you will need an IDE; Visual Studio.
You can find it here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15
Secondly, you should start with finding the MSCLoader Wiki and start setting up your environment. Read through and learn how to use the MSCLoader:
You can find MSCLoader Wiki here:
https://github.com/piotrulos/MSCModLoader/wiki
NOTE: You may download either x86 or x64 bit version of Unity and reading both for player and developer is very useful.
Third, start by downloading and "installing" the "Developer Toolkit" so you can easily find and quickly modify gameobjects in the world.
Saves a lot of time not having to make changes, build and restart the game every time you try a new set of code for example in placing or re-placing gameobject in the world.
You can find Developer Toolkit here:
http://www.racedepartment.com/downloads/plugin-developer-toolkit.17214/
NOTE: Some Objects/Components also needs referenses to Assembly-CSharp.dll file.
("Steam\steamapps\common\My Summer Car\mysummercar_Data\Managed\Assembly-CSharp.dll")
Drivetrain, for example, does need this reference to work properly.
Thanks to @tommojphillips for finding this!
How can I make changes in-game?
This is fairly easy and basic kowledge. MySummerCar is created using Unity® software and that opens up a whole lot of methods, classes and libraries we can use.
Transforms, for example, is used to store an objects position, rotation, scale and parenting state.
MySummerCar is also using an asset called PlayMaker which makes it a whole lot harder at the same time. Depending on your goal ofcourse.
First, if you would like to make changes to example the car, Satsuma for example...
We need to create a variable/reference name:
Code:
GameObject satsuma; // Making a variable
Give it a reference/value:
Code:
satsuma = GameObject.Find("SATSUMA(557kg, 248)"); // Giving our variable a reference/value
This part is a bit tricky.. You need to find out which GameObject in the scene is "hosting" the component which makes these changes in order to change them... Unless they are maintained by a singleton instance. If they are maintained by singleton and are instanced they can, globally, be read or changed without the need of the "hosting" object.
Making changes to a component/variable:
Code:
satsumaDriveTrain = GameObject.Find("SATSUMA(557kg, 248)").GetComponent<Drivetrain>();
If it is a singleton variable or information you are looking for you may use a foreach method to get what you want to find:
Making a foreach for PlayMaker FSM:
Code:
// FloatVariables can be BoolVariables, StringVariables, GameObjectVariables, ObjectVariables, MaterialVariables and IntVariables
foreach (var flt in PlayMakerGlobals.Instance.Variables.FloatVariables)
{
switch (flt.Name)
{
case "PlayerCurrentVehicle": // This is not a float
_carCurrent = flt.Value.ToString();
break;
case "PlayerFatigue":
_fatigue = flt;
break;
case "PlayerThirst":
_thirst = flt;
break;
case "PlayerHunger":
_hunger = flt;
break;
case "PlayerStress":
_stress = flt;
break;
}
}
How do I detect if a player is in vehicle/car/"drive mode"?
Taking a look back to our code earlier we can use the PlayMaker FSM here and check if player is in any vehicle.
Code:
if (FsmVariables.GlobalVariables.FindFsmString("PlayerCurrentVehicle").Value != "")
{
//Player is in drive mode
}
How do I use custom assets?
Code:
//Define objects
AssetBundle assets;
GameObject turbo;
//Onload.. We load, initialize and give references.
assets = LoadAssets.LoadBundle(this, "turbo.unity3d"); // Load this asset
turbo = assets.LoadAsset("turbo_prefab.prefab") as GameObject; //get specific prefab
assets.Unload(false); //Unload once all prefabs has been gathered to clean memory
//Placement
turbo = GameObject.Instantiate(turbo); //Instantiate object in the world
// OPTIONAL: turbo.transform.SetParent(GameObject.Find("satsu").transform, false); // We can set it as child object
//We set pos, rot & scale | Be aware, there are localPosition and Position. Choose relative to the use.
turbo.transform.localPosition = new Vector3(0.3f, 0.16f, 1.02f);
turbo.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
turbo.transform.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);
(I cant find the player!)
How do I find player?
When OnLoad is called you can simply use this code:@piotrulos stated in an early comment/reply that:
In 0.4 OnLoad will be called after game is fully loaded.
Code:
GameObject player = GameObject.Find("PLAYER"); // Simple as this
OLD TUTORIAL; MSCLoader <= 0.3.5;
Finding the player is a bit tricky compared to finding another object in the world since it is "spawing" rather late.
Once OnLoad has finished running in your mod it has most likely not spawned yet and will result in a nullreference exception.
How do we make this work?
There are multiple options but I'm going to show you two:
Code:
//First option is the Coroutine method:
void Something()
{
//Start coroutine
StartCoroutine(setup());
}
IEnumerator setup()
{
yield return new WaitForSeconds(15f); // Wait for something 15 sec
ModConsole.Print("Success!");
}
Code:
//Second option is the update method:
public override void Update()
{
//Loops untill player has spawned. May cause some lagg...
if((GameObject)player == null)
player = GameObject.Find("PLAYER");
//Wrap other codes inside this container
if(player != null)
{
//Run mod...
}
}
**Threading removed**
Good luck and have fun!
Annoyances (and tips) of building mods:
When you are making mods you'll be, eventually, annoyed by three (major) things...
1: As a developer you need to manually copy the mod to the mod folder every time you makes changes/build the mod.
But that can be fixed by using this piece of code:
Code:
copy /Y "$(TargetDir)$(TargetName).dll" "C:\Users\YOURUSERNAME\Documents\MySummerCar\Mods"
How do I do that?
A: Right-click -> Properties
B: Find the tab "Build Events"
C: Find "Post-Build Event Command line" textarea and modify/copy the code above for everything you want to move with the build on each seperate lines.
D: Save.
E: Build and Enjoy!
2: You will need to restart the game a lot in order to test out the mod and check it out. (There, currently, isn't a way around this atm)
3: Bad reviews.
You may get bad reviews from users who doesn't "install" the mod correct, haven't bought the actual game and is playing on pirate copies etc.
My advice.. Brush it off and don't bother. If you enjoy creating, create and if you get a bad review or someone is being mean, ignore them and continue with your work.
My experiences and mods:
My experience has been great, No dubt. BUT lately i must admit that my interests have turned and I have been forced to focus on diffrent things. Work as an example has been very hectic.
I caught a break now and I wanted to help out the community
MySummerMultiMod: http://www.racedepartment.com/downloads/mysummermultimod.19405/
Useful links:
MSCLoader Wiki : https://github.com/piotrulos/MSCModLoader/wiki
PlayMakerFSM : All PlayMaker FSM
@zamp : https://github.com/zamp/MSC-Mods
@Roman266 : https://github.com/GishaSeven/Plugins-for-MSC-ModLoader
@tommojphillips : 2 Links below.
ModAPI: https://github.com/tommojphillips/ModAPI/wiki
Demo: https://github.com/tommojphillips/AttachObjectDemo
Special thanks to everyone who has provided information or helped with some outdated information!
Good nite everyone
Last edited: