# LethalSmokes

Cigarettes for Lethal Company. They show up as low-value scrap on the moons: sell them, or
light one up. A lit cigarette hangs from your mouth for a minute, glowing, smoking and burning
down, and every player in the lobby sees and hears it. It gives you a small edge while it
burns, and a craving once it's gone.

## How it plays

- **Find it:** cigarettes spawn as scrap on every moon in small numbers. They weigh next to
  nothing and sell for about 8-20 credits. You can scan, grab, pocket, drop and sell them and
  keep them on the ship like any other scrap.
- **Light it** (left mouse button while holding one). A lighter flicks, the cigarette leaves
  your hand and hangs from your mouth for 60 seconds, burning down with a glowing, flickering
  ember and ash that builds up and drops off (it lights up the area around you a little), and
  trailing a curling ribbon of smoke. You can't light a second one
  while the first still burns. At the end it fades out.
- **Drags:** every 8-10 seconds you take a drag: your hand comes up to your face (only with
  empty hands), the ember flares hot and throws a few sparks with a crackling inhale, and you
  blow out a cloud of smoke. Everyone
  nearby sees and hears it. The lighter flick is a tiny noise enemies close by can hear.
- **While it burns:** about 10% faster movement, slowly growing stamina capacity and slow
  health regeneration.
- **Afterwards:** withdrawal. Your stamina capacity slowly sinks and your health slowly drains
  (never below 50, and it can never kill you) until you light the next one.
- Everything resets when you die, the round ends or you leave.
- Stamina capacity makes your sprint meter drain slower (or, in withdrawal, faster); the meter
  still shows a full bar as full and refills in the usual time. Withdrawal health drain pauses
  in orbit, where the game makes you invulnerable anyway.

## Config

`BepInEx/config/com.roandegraaf.lethalsmokes.cfg`

| Section | Entry | Default | What it does |
|---|---|---|---|
| Spawning | `RarityLowTier` / `RarityMidTier` / `RarityHighTier` / `RarityModded` | 15 / 15 / 15 / 15 | Spawn weight on Experimentation, Assurance, Vow / Offense, March, Adamance / Rend, Dine, Titan, Artifice, Embrion / modded moons (0 = none) |
| Spawning | `MinValue` / `MaxValue` | 20 / 51 | Raw scrap value range; the game scales it by about 0.4, so it sells for 8-20 |
| Smoking | `BurnDuration` | 60 | Seconds a cigarette burns (the host's value is used) |
| Smoking | `DragIntervalMin` / `DragIntervalMax` | 8 / 10 | Seconds between drags, picked at random in this range (the host's values are used) |
| Effects | `SpeedBoostPercent` | 10 | Extra movement speed while smoking |
| Effects | `CapacityRisePercentPerSecond` / `CapacityMaxPercent` | 0.5 / 130 | Stamina capacity growth while smoking |
| Effects | `CapacityFallPercentPerSecond` / `CapacityFloorPercent` | 0.25 / 70 | Stamina capacity loss during withdrawal |
| Effects | `HealAmount` / `HealIntervalSeconds` | 1 / 3 | Health regeneration while smoking |
| Effects | `WithdrawalDrainAmount` / `WithdrawalDrainIntervalSeconds` / `WithdrawalHealthFloor` | 1 / 5 / 50 | Health drain during withdrawal |
| Visuals | `LightRange` / `LightIntensity` | 3.5 / 40 | The ember's glow, in metres and lumens (each player's own value) |
| Audio | `SoundVolume` | 0.8 | Volume of the lighter, inhale, exhale and burnout (each player's own value) |
| Audio | `EnemyNoiseOnLight` | true | Whether the lighter flick makes a very small noise enemies can hear (the host's value is used) |
| Debug | `CigarettesInShip` | 0 | When hosting, top the ship up to this many cigarettes on load |

**Which values follow the host:** every client uses the host's `BurnDuration`,
`DragIntervalMin`/`DragIntervalMax`, `EnemyNoiseOnLight` and all `Effects` values (a client
uses its own until the host's arrive, right after joining). `Spawning` only matters on the
host, since only the host spawns scrap. `Visuals` and `SoundVolume` are each player's own.

## Dependencies

- [BepInExPack](https://thunderstore.io/c/lethal-company/p/BepInEx/BepInExPack/)
- [LethalLib](https://thunderstore.io/c/lethal-company/p/Evaisa/LethalLib/) 1.2.0
- [LethalNetworkAPI](https://thunderstore.io/c/lethal-company/p/xilophor/LethalNetworkAPI/) 3.4.2

## Multiplayer

- Every player in the lobby needs the mod (it registers a networked item and messages).
- Lighting, drags and burnout are decided by the host and sent to everyone, so all players see
  the same cigarette at the same length. The effects run on the smoker's own game.
- A player who joins while someone is smoking sees that cigarette at its current length (the
  lighting sound is not replayed).

## Known limitations

- The cigarette is built in code from the game's own materials, light and particles; the smoke
  texture and every sound (lighter, inhale, exhale, burnout) are generated at startup. There is no custom model or animation.
- The hand-to-face motion of a drag is the vanilla TZP inhalant animation and only plays with
  empty hands; with an item in hand you still see the ember brighten and the puff.
- There is no HUD element; the sprint meter just drains slower or faster.
- The effects last for the round only: dying, the round ending, the ship leaving or
  disconnecting resets everything. Nothing carries over between days.
- No shop purchase, no lighter item, no lighting or passing a cigarette to someone else.
- Tested on game version v81 with LethalLib 1.2.0 and LethalNetworkAPI 3.4.2. Compatibility
  with other mods is not tested beyond not changing vanilla behaviour.

## Building

Needs the .NET 8 SDK. Works on Linux without Windows or Unity.

```sh
./fetch-libs.sh              # reference assemblies into libs/ (only needed without a local game install)
dotnet build -c Release      # LethalSmokes/bin/Release/LethalSmokes.dll
dotnet test tests/LethalSmokes.Tests
```

The build prefers the local Steam install of Lethal Company and the `LethalSmokes-Test`
r2modman profile when they exist, and falls back to `libs/`.

### Packaging

```sh
./package.sh                 # Release build + LethalSmokes-<version>.zip for Thunderstore
```

It checks that the versions in `Plugin.cs`, the csproj, `manifest.json` and `CHANGELOG.md`
agree, that the manifest's dependencies and the 256x256 icon are valid, and that the zip holds
only the mod (no test harness). `python3 tools/make-icon.py` regenerates `icon.png`.

### Running it

```sh
tests/setup-test-profile.sh  # creates the LethalSmokes-Test r2modman profile with the dependencies
./deploy.sh --launch         # builds, copies the DLL into the profile and starts the game through Steam
```

Tests: see [tests/README.md](tests/README.md) (unit tests and the in-game harness, single
player and `--multiplayer`).
