TheMorningStar-Loot_Topup icon

Loot Topup

Tracks the value on a level and spawns a few more valuables if you drop below what's needed to finish. Guarantees at least 8 at level start, catches mid-level softlocks, and stands down for Hunting Season.

Last updated 2 hours ago
Total downloads 11
Total rating 0 
Categories Valuables Server-side AI Generated Quality Of Life
Dependency string TheMorningStar-Loot_Topup-1.0.0
Dependants 0 other packages depend on this package

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2100 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2100

README

Loot Topup

Small mod that tracks the value of the valuables on a level, and if you drop below the number needed to complete the level, spawns a few more valuables around the map. Patch included for Mutators for the one variant that gets rid of all the valuables on purpose.

What it does

  • Some maps spawn only a handful of items, with one high-value piece carrying the whole quota. Lose it and the run is dead. At level start it tops up to at least 8 valuables.
  • If enough value is destroyed that what is left cannot reach the haul goal, a check every 4 seconds, and again the moment an item breaks, tops up until the achievable value reaches 1.3x the haul goal.
  • Topups are copies of the level's own valuables, spawned near existing loot spots. Nothing is removed or devalued.
  • It stops at 60 spawned items per level.
  • If the Hunting Season mutator is on, the one that removes all valuables on purpose, it does nothing.

Configuration

Setting Default What it does
TargetMultiplier 1.3 Top up until achievable value is at least the haul goal times this. 1.0 is exactly completable.
MinValuables 8 At least this many valuables at level start. 0 disables it.
Watchdog.Enabled true Catch mid-level softlocks.
Watchdog.IntervalSeconds 4 How often the watchdog re-checks.
Mutators.RespectNoLootMutators true Do nothing when a no-loot mutator is active.
Mutators.SkipMutatorNames Hunting Season Comma-separated mutator names to skip.
MaxSpawnsPerLevel 60 Hard cap per level.

Host-side. Only the host's copy acts.

For developers - detailed breakdown

GUID: themorningstar.loottopup, BepInEx only, no REPOLib dependency.

Three Harmony patches.

Prefix on LevelGenerator.Start. Resets per-level state, the spawn counter and template list.

Postfix on RoundDirector.StartRoundLogic. Gated on SemiFunc.IsMasterClientOrSingleplayer(). Waits 2.5s for ValuableDirector to finish spawning, snapshots every live ValuableObject as a spawn template with its prefab reference, Valuables/<name> resource path, and current value, runs the first evaluation, then loops the watchdog at IntervalSeconds, clamped to at least 1s.

Postfix on PhysGrabObjectImpactDetector.BreakRPC. Re-evaluates the moment an item takes break damage, so a softlock is caught at once rather than on the next tick.

The completability math mirrors the game's accounting. achievable = sum of live ValuableObject.dollarValueCurrent + extractionPointsCompleted * (haulGoal / extractionPoints). Topup runs while achievable < haulGoal * TargetMultiplier or liveCount < MinValuables, capped at 500 placement attempts and MaxSpawnsPerLevel total.

To spawn, it picks a template. Value shortfalls draw from the full pool. Count-only shortfalls draw from templates at or below average value, so a sparse map is not topped up with copies of its most expensive item. It places the copy at the template's position plus or minus 1.2m on X and Z and plus 0.7 up, with a random rotation. Multiplayer goes through PhotonNetwork.InstantiateRoomObject with the Valuables/<name> path, singleplayer through a plain Instantiate. Each copy re-rolls DollarValueSetLogic(), so values are fresh rather than cloned.

It can only duplicate what the level spawned. A template whose last live instance was destroyed drops out of the pool, because the Unity object is gone, and if every template is gone before a topup fires it logs "no templates to spawn from" and stops. Placement is near existing loot positions, not new spawn volumes, so copies land next to where loot already was and now and then somewhere silly.