MoreGames
Framework for mod creators to build custom gambling machines
| Last updated | 8 hours ago |
| Total downloads | 67 |
| Total rating | 0 |
| Categories | Tools |
| Dependency string | Syd4r-MoreGames-1.0.0 |
| Dependants | 1 other package depends on this package |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2305README
GWYF_MoreGames
Framework mod for making new casino games in "Game With Your Friends".
How to make your own custom game
Note: The Fishing Game mod: https://github.com/Syd4r/FishingGame is a good reference for how to build a game using this framework.
To build a compatible mod you will need to set up your file structure as such:
- YourModName/
- Games/
- YourGameName/
- YourGameName (Unity Asset Bundle)
- YourGameName.dll (C# class extending GameBase)
- gamemanifest.json
- YourGameName2/ (if you want multiple games in one mod you can add both to the games folder)
- YourGameName2 (Unity Asset Bundle)
- YourGameName2.dll (C# class extending GameBase)
- gamemanifest.json
- YourGameName/
- Games/
As you can see there are 3 main things you need for a game to work properly:
- A compatible unity asset bundle
- A dll containing a class extending GameBase
- A json defining important things about your mod
In the next sections, I will go through how to set up each of these correcly.
Asset Bundle
To build a compatible unity asset bundle you must first set up a good Unity scene. I highly recommend using AssetRipper on the Gamble With Your Friends_data folder in steamapps\common\Gamble With Your Friends. Then, in AssetRipper, export the ripped files to a Unity project. In Unity Hub make sure to download Unity version 6000.3.6f1 and open the Unity project with this version. This will give you all of the materials, meshes, and prefabs that the game has. The major issue is that all of the scripts get disconnected, so you should delete all C# scripts in the folder. Then find a prefab that already exists in the game like Crash CasinoGame. You can edit this prefab and use it as a base to build what you want. Make sure to remove all dangling components that use scripts, as these will throw error. Also, make sure to add the TextMeshPro package so that you can add TextMeshPro components to any text. To get the game's font look for Assets/Font/Dangrek-Regular.ttf and use it to build Dangrek-Regular SDF.asset which you should place in Assets/Resources/fonts & materials/ then just select Dangrek-Regular in TextMeshPro.
If you look at a prefab for a preexisting casino game it will look something like this:
- Example CasinoGame
- GameName (This needs a TextMeshPro)
- Model
- (Any 3D model) (Make sure that the material has a shader used by the game, I know that 01_GWYF/ and AllIn1SpriteShader/ work correctly, however these shaders make the 3D model look flat so make sure to prebake some lighting)
- Play Button (This has a BoxCollider)
- Model
- Text (This needs a TextMeshPro)
- SM_button_1 (This uses mesh: Cube.002, a mesh renderer, a BoxCollider and a material)
- Feedbacks
- PressFB
- Model
- (Any other buttons)
- Feedbacks
- GameResultFB
- GameWinFB
- GameLoseFB
- FloatingText Spawner
- GameWinVFX
- (A whole bunch of particles)
- GameLoseVFX
- (A whole bunch of particles)
- GameTieVFX
- (A whole bunch of particles)
- KeypadPoint
- Keypad (This has a BoxCollider)
- SM_keypad_base (This uses mesh: Cube_4)
- Keypad (This has a BoxCollider)
- NavMeshModifier (This has a nav mesh obstacle component)
If you set up your Unity scene to have these things and set up asset bundling, after you bundle just rename the bundle to your game name and drag it into your game folder.
C# script
Download Visual Studio and setup a new project using "Class Library (.Net Framework)".
Make a new C# script. In this file you will only need to add a new public class extending gamebase. For example:
public class ExampleGameName : GameBase {}
I highly recommend using dnSpy to look at the classes for the base casino games or looking at https://github.com/Syd4r/FishingGame to understand how to do things.
Here are a few helpful things you should know:
void Start() {} This will run when the object gets instantiated.
public override bool Weaved() { return true; } I think you need to include this but I'm not too sure.
protected override void StartGame() Your play button will run this function when it gets clicked.
void Update() {} This will run every frame
NETWORK STUFF IMPORTANT!!!
If you want a visual thing to occur in your game it must get synced across the network, thus it is not enough if your function just updates the visuals for the client, here is how to correctly set up networking:
public void BroadcastTestMethod(string text) {
if (!NetworkServer.active) return;
string methodSignature = "System.Void TestMod.TestGameName::UserRpcTestMethod(System.String)";
int rpcHash = methodSignature.GetStableHashCode();
NetworkWriterPooled writer = NetworkWriterPool.Get();
writer.WriteString(text);
this.SendRPCInternal(methodSignature, rpcHash, writer, 0, true);
NetworkWriterPool.Return(writer);
}
public void UserRpcTestMethod(string networkText) {
if (!NetworkClient.active) return;
--DO THE VISUAL THING--
}
If your function is one that runs when you push a button it must be set up like this:
[Server]
public void TestButtonClicked(PlayerInteract interact = null) {
if (!NetworkServer.active) return;
-- DO SOMETHING --
}
When you want to payout just use the this.Payout function:
this.Payout((double)multiplier, ChangeType.GameResult, null, -1L);
This C# script will be doing all of the logic of your game, if you have any issues just message me on discord: syd4r
Game Manifest
The game manifest is by far the easiest part of this whole setup. Here is an example game manifest:
{
"name": "TestGameName", //This should match your folder name and all of your file names
"baseMinBet": 20, //Min bet on keypad for first floor
"baseMaxBet": 360, //Max bet on keypad for first floor (this will be off by 10-20 for some reason)
"directions": [ //Currently unused but will define how multiple machines will spawn when I implement the feature
"North",
"South",
],
"floorWeights": { //Weight of being picked on each floor, these are the values to get the machine to spawn in the same as the others
"1": 0.167,
"2": 0.111,
"3": 0.091,
"4": 0.063
},
"buttons": [ //Define which function to call when clicking the button with this name in Unity
{
"objectName": "PlayButton", //Play button must call TryStartGame
"functionName": "TryStartGame"
},
{
"objectName": "TestButton", //Other buttons can call whatever
"functionName": "TestFunction"
},
],
"fields": [ //If you want to be able to access things from your asset bundle in your C# script, add them here
{
"fieldName": "testField", //field name in C# script
"source": "child", //it will almost always be child
"targetName": "Test_Object" //unity object name
},
{
"fieldName": "testPrefabs",
"source": "child",
"targetNames": [ //you can also make an array of unity objects
"test_1", "test_2", "test_3", "test_4",
"test_5", "test_6", "test_7", "test_8",
"test_9", "test_10", "test_11", "test_12"
]
}
]
}
Make sure to set up the gamemanifest.json like this and include it in the game folder.
Hopefully it works??
If you follow these steps, hopefully you should be able to make your own custom game. If you run into any issues feel free to reach out. I would highly recommend checking out how I made my custom game at https://github.com/Syd4r/FishingGame