Creating roulette in cyberpunk 2077 was the biggest project I’ve worked on to date. I learned so many new topics of development and struggled equally as many times, but I’m so proud of how it turned out! As this was my 10th mod making project for Cyberpunk 2077, I had a good amount of knowledge about how to make a project like this happen. Though I won’t say I knew how to do most of this project at the start. First and foremost, the Cyberpunk Modding Discord Server has been instrumental to my this project coming to life. It literally would not have happened without some of the coding savants over there that helped many times with this project. (10 people were credited for support of this roulette project alone!)

The first major building block of the project was the scripting. Using Cyber Engine Tweaks (CET), a script compiler for Cyberpunk, I could write plain Lua code and create the logic that powers the mod. Thanks to my experience building the Adaptive Item Stock, a logic dependency I wrote with Lua in 2023, I was experienced with the basics of Cyberpunk scripting and interacting with the game world. The logic was where I spent the most time throughout this project. One of the biggest lessons I learned from this project was modularization. As I continued development and adding features, the main script became too long to manage and new files were needed to separate major functions. Some of the code I spent the most time on was the ‘animations’ for different actions. Due to the limitations of the cyberpunk modding tools, the only control I have on objects is their location in the world. Since I cannot animate functions, long script controls were needed to manually teleport objects as the game logic determined. The most difficult parts included the roulette ball with it’s randomized ‘physics-based’ bounces, the player chips which animated to fit your real money, and the roulette board that updated live based on real bets the player selects.
Another major part of this project was 3D modeling. I’ve never been a big fan of 3D work, but my projects always seem to force me! (This, video production, 3D printing, to name a few) I did get significant help learning cyberpunk modeling while developing my Mini Cooper mod from last year. This projected involved a lot of 3D work in various areas. Due to how Cyberpunk 2077 was developed, the base-game casino only includes a static 3D model of a roulette table. This model is great, however it wasn’t designed with interaction, animation, or motion in any way. To get it working I had to chop up the source model and rework the parts to fit the functions I have with Lua as listed above, only creation and location. Some details also needed editing. For example, the wheel has a visual layer to provide a nice shine effect. However due to the actual world location and the player’s viewing angle, it becomes a solid yellow block and the wheel’s numbers aren’t visible. There are also a lot of models that don’t already exist, like the casino chips. These I found online via Sketchfab with an open use license. (Thanks Jack Kelly!) I resized and reworked some model issues and made some changes for easier logic use later on.

The last major block to get the project finished was connecting my code to the game world. Running print statements and basic math is great and all, but we need it to control in-game values and actions. Almost every game function is made available through CET (Cyber Engine Tweaks). For example, if one wants to freeze the player (like as they start a UI game spinning a random wheel, hypothetically), they simple run this code:
StatusEffectHelper.ApplyStatusEffect(Game.GetPlayer(), "GameplayRestriction.NoMovement")
Use the status object, run the apply function, target the player, specify the status. Most game relations work this way, and libraries of game functions are available online with tools like nativedb by red4ext. There are also some functions which can be complicated, but have been semi-solved by the community with some public script modules. Popular modules include Cron.lua and GameUI.lua, both by psiberx. Each module provides some much needed convenience to our Lua project. Cron.lua provides nice time/sync/waiting tools. interactionUI by keanuwheeze creates easy world interactions, like the join button for my roulette game, or an indicator of where an action spot is. GameLocale and GameSession are the last 2 I’ll mention, both by psiberx, they control alternative language support and Game session data (load screen, inventory screen, etc.), respectively.
One last thing I gloss over here is Wolvenkit. It really is the heart of all Cyberpunk 2077 mod development. It basically is the perfect mod project managing software, connecting all your various files and importing files to fit RedEngine (Cyberpunk’s engine, which is proprietary btw) formats. Wolvenkit really is an amazing tool and is one that takes some decent learning to understand, but it’s features are an amazing community project and it is instrumental to every Cyberpunk mod created. I’ve done plenty of mods now so I glossed over this part, but a huge amount of time developing mods is setting things up within Wolvenkit. A huge shoutout to everyone on the Wolvenkit open-source development team!