MalfunctionsMod is a mod for Spaceflight Simulator (SFS) that injects rare, random malfunctions into the player's rocket during flight. The goal is to give the Launch Escape System (LES) a meaningful role — most launches succeed, but occasionally something breaks and the player must abort or improvise.
- Four malfunction types with a low chance to trigger while the player rocket is in flight:
- Gimbal broken: an engine gimbal locks at an off-center angle and rotation input (Q/E) is blocked.
- Engine ignition fail: a random engine is forced off and refuses to ignite again.
- Separation fail: a random decoupler refuses to separate when staged.
- Pressure explosion: a random fuel tank is destroyed after a 5-second countdown (explosion optional).
- Triggers only on the player rocket (
isPlayer.Value == true), while inside the configured planet's SOI and after confirmed lift-off (velocity > 2 m/s). - 20-second cooldown after each event to avoid cascading failures.
- Debug keybindings to force malfunctions for demos and tests.
- A "Malfunctions" toggle is added to the in-game Cheats menu at runtime and is also bound to a configurable key.
High-level structure (see the repo for details):
MalfunctionsMod/— C# project targeting .NET Framework 4.8Main.cs— mod entry point (class derived fromMod)Settings.cs— keybindings and tunables serialized tokeybindings.txtMalfunctions/— malfunction logic (MalfunctionManager.cs,RocketState.cs)Patches/— Harmony patches for Engine, Detach, and RocketProperties/AssemblyInfo.cs
Dependencies/— game DLLs and libraries (gitignored; copy locally)docs/— technical docs and mapping to game code
- C# / .NET Framework 4.8 (AnyCPU)
- Harmony (0Harmony.dll) for runtime patching
- UnityEngine assemblies from SFS
- ModLoader for loading the mod
- Newtonsoft.Json / UniTask as required (see
Dependencies/)
- Copy the required SFS DLLs into
Dependencies/(seeenv.props.example). - Adjust
env.propsto pointModsFolderto your SFS Mods folder (copyenv.props.example). - Open
MalfunctionsMod.slnin Visual Studio and build theReleaseconfiguration. - The Release target is configured to copy
MalfunctionsMod.dllinto your localMods/folder and (optionally) launch SFS via Steam.
- Target symbols and classes come from the SFS codebase — consult
docs/malfunctions.mdand the included game reference to locate target methods (EnableEngine,Detach,RecalculateGimbal, etc.). - All patches should early-exit unless the affected
Rocketis the player (isPlayerguard). MsgDrawer.Logis used for on-screen notifications; the mod schedules repeated logs for the explosion countdown.- Use
SceneHelper.OnWorldSceneLoadedto subscribe to world-scoped singletons (e.g.,RocketManager.main,MsgDrawer.main).
keybindings.txtstores keybinds and tunables (e.g.,AllowedPlanetCodeName, debug keys, main toggle).- Local
env.propscontrols theModsFolderused by theAfterBuildtarget.
If you want to contribute:
- Open an issue describing the improvement or bug.
- Submit small, focused PRs.
- Keep compatibility with the minimum game version declared in
Main.cs.
- Mod documentation and mapping:
docs/malfunctions.mdanddocs/architecture.md. - Read-only SFS reference code as described in the repository docs.