Skip to content

105-Code/MalfunctionsMod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MalfunctionsMod

Description

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.

Key Features

  • 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.

Project Layout

High-level structure (see the repo for details):

  • MalfunctionsMod/ — C# project targeting .NET Framework 4.8
    • Main.cs — mod entry point (class derived from Mod)
    • Settings.cs — keybindings and tunables serialized to keybindings.txt
    • Malfunctions/ — malfunction logic (MalfunctionManager.cs, RocketState.cs)
    • Patches/ — Harmony patches for Engine, Detach, and Rocket
    • Properties/AssemblyInfo.cs
  • Dependencies/ — game DLLs and libraries (gitignored; copy locally)
  • docs/ — technical docs and mapping to game code

Tech & Dependencies

  • 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/)

Local Install & Deploy

  1. Copy the required SFS DLLs into Dependencies/ (see env.props.example).
  2. Adjust env.props to point ModsFolder to your SFS Mods folder (copy env.props.example).
  3. Open MalfunctionsMod.sln in Visual Studio and build the Release configuration.
  4. The Release target is configured to copy MalfunctionsMod.dll into your local Mods/ folder and (optionally) launch SFS via Steam.

Development Notes

  • Target symbols and classes come from the SFS codebase — consult docs/malfunctions.md and the included game reference to locate target methods (EnableEngine, Detach, RecalculateGimbal, etc.).
  • All patches should early-exit unless the affected Rocket is the player (isPlayer guard).
  • MsgDrawer.Log is used for on-screen notifications; the mod schedules repeated logs for the explosion countdown.
  • Use SceneHelper.OnWorldSceneLoaded to subscribe to world-scoped singletons (e.g., RocketManager.main, MsgDrawer.main).

Configuration

  • keybindings.txt stores keybinds and tunables (e.g., AllowedPlanetCodeName, debug keys, main toggle).
  • Local env.props controls the ModsFolder used by the AfterBuild target.

Contributing

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.

References

  • Mod documentation and mapping: docs/malfunctions.md and docs/architecture.md.
  • Read-only SFS reference code as described in the repository docs.

About

Add malfuntions

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages