From 41b05ee60f9dc94d119c729f6ea034d0a21dc4f8 Mon Sep 17 00:00:00 2001 From: zj1022 Date: Wed, 18 Nov 2026 19:50:46 +0800 Subject: [PATCH] feat(currencyloot): add configurable bonus currency rolls --- README.md | 1 + mods.json | 1 + mods/currencyloot/CurrencyLootMod.cs | 37 ++++++++++++++++++++++++++++ mods/currencyloot/README.md | 12 +++++++++ mods/currencyloot/mod.json | 11 +++++++++ mods/currencyloot/settings.json | 13 ++++++++++ 6 files changed, 75 insertions(+) create mode 100644 mods/currencyloot/CurrencyLootMod.cs create mode 100644 mods/currencyloot/README.md create mode 100644 mods/currencyloot/mod.json create mode 100644 mods/currencyloot/settings.json diff --git a/README.md b/README.md index 0b2bd1f..08ebb77 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ works with. The maintainers publish the releases of the mods in this repository. | [petloot](mods/petloot/) | optional pet pickup with per-character filters, minimum stacks, pause/resume and configurable 2x pet speed | | [zoom](mods/zoom/) | a wider view in normal play: the camera stands further back, the mouse wheel reaches it, `/zoom` sets how far | | [itemquantity](mods/itemquantity/) | 10× as many item drops | +| [currencyloot](mods/currencyloot/) | Configurable bonus currency per eligible kill | | [pob](mods/pob/) | preview and import character builds through an external converter; requires LocalExile #639 | | [itemrarity](mods/itemrarity/) | 10× the chance of magic, rare and unique equipment | diff --git a/mods.json b/mods.json index b2360d0..174ec68 100644 --- a/mods.json +++ b/mods.json @@ -2,6 +2,7 @@ "version": 1, "mods": [ { "id": "backpack", "name": "Extra Backpack", "description": "An optional native 20-slot extra backpack for every character class.", "author": "zj1022", "version": "1.0.3", "compatibleClientVersions": ["0.5.1-beta", "0.5.2-beta"], "kind": "feature", "type": "script", "path": "mods/backpack", "depends": [], "settings": false }, + { "id": "currencyloot", "name": "Currency Loot", "description": "Adds configurable bonus rolls for specific currencies on monster kills.", "author": "zj1022", "version": "1.0.0", "compatibleClientVersions": ["0.5.2-beta"], "kind": "feature", "type": "script", "path": "mods/currencyloot", "depends": [], "settings": true }, { "id": "fastcampaign", "name": "Fast Campaign", "description": "A faster campaign: 5x kill experience, +50% movement speed, and /fast lists the commands that skip ahead.", "author": "LocalExile", "version": "1.1.4", "compatibleClientVersions": ["0.4.3-beta", "0.5.0-beta", "0.5.1-beta", "0.5.2-beta"], "kind": "feature", "type": "project", "path": "mods/fastcampaign", "depends": [], "settings": true }, { "id": "globalchat", "name": "Global Chat", "description": "Talk to other LocalExile players: global, trade and whisper chat go through the LocalExile global chat server.", "author": "JetStream", "version": "1.1.4", "compatibleClientVersions": ["0.4.3-beta", "0.5.0-beta", "0.5.1-beta", "0.5.2-beta"], "kind": "feature", "type": "project", "path": "mods/globalchat", "depends": [], "settings": true }, { "id": "gm-commands", "name": "GM Commands", "description": "The development and testing chat commands: teleport, items, monsters, experience, quest flags, test hits and protocol probes.", "author": "LocalExile", "version": "1.5.0", "compatibleClientVersions": ["0.5.2-beta"], "kind": "feature", "type": "project", "path": "mods/gm-commands", "depends": ["Game"], "settings": false }, diff --git a/mods/currencyloot/CurrencyLootMod.cs b/mods/currencyloot/CurrencyLootMod.cs new file mode 100644 index 0000000..9dd5613 --- /dev/null +++ b/mods/currencyloot/CurrencyLootMod.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Nodes; +using GameServer.Modding; + +namespace LocalExile.Mods.CurrencyLoot; + +public sealed class CurrencyLootMod : IMod +{ + public void Load(IModContext mod) + { + var settings = mod.Settings(); + var rates = new Dictionary(StringComparer.OrdinalIgnoreCase); + if (settings["items"] is JsonObject items) + foreach (var (name, value) in items) + { + if (value is not JsonValue amount || !amount.TryGetValue(out double rate) + || !double.IsFinite(rate) || rate <= 0) continue; + if (Program.Items.Find(name) is not { Supported: true, Stackable: true, Class: "StackableCurrency", Quest: null } type + || type.Id == ItemDrops.GoldId) + { + mod.Log($"Currency Loot: skipping unknown or unsupported currency '{name}'."); + continue; + } + rates[type.Id] = (Math.Min(rate, 20), type.DropLevel); + if (rates.Count == 40) break; + } + GameEvents.Drops.Add(mod.Manifest.Id, drops => + { + foreach (var (id, (rate, level)) in rates) + { + if (drops.Monster.Level < level) continue; + int count = (int)rate; + if (rate > count && Random.Shared.NextDouble() < rate - count) count++; + for (int i = 0; i < count; i++) drops.Items.Add(id); + } + }); + } +} diff --git a/mods/currencyloot/README.md b/mods/currencyloot/README.md new file mode 100644 index 0000000..eb92e04 --- /dev/null +++ b/mods/currencyloot/README.md @@ -0,0 +1,12 @@ +# Currency Loot + +Add configurable bonus currency to eligible monster kills alongside the normal loot. Each entry uses the currency's +existing base drop level. The mod accepts supported stackable currency and skips gold and quest items. + +Enable with Waypoint or `/mod_enable currencyloot`. It starts disabled and adds no chat commands. Use the +**Bonus currency per kill** setting in Waypoint, or edit `data/mods/currencyloot.json` in the server folder. +Use an exact currency name or metadata ID as the key. A value of `1.25` gives one extra item and a 25% chance +of a second. The default gives an extra Chaos Orb on 5% of eligible kills. + +Inspired by the configurable currency drops in [mingyue8621/LocalExile-Mods](https://github.com/mingyue8621/LocalExile-Mods). +Compatible with LocalExile 0.5.2-beta. diff --git a/mods/currencyloot/mod.json b/mods/currencyloot/mod.json new file mode 100644 index 0000000..85ae2ed --- /dev/null +++ b/mods/currencyloot/mod.json @@ -0,0 +1,11 @@ +{ + "id": "currencyloot", + "name": "Currency Loot", + "description": "Adds configurable bonus rolls for specific currencies on monster kills.", + "author": "zj1022", + "version": "1.0.0", + "compatibleClientVersions": ["0.5.2-beta"], + "kind": "feature", + "depends": [], + "enabled": false +} diff --git a/mods/currencyloot/settings.json b/mods/currencyloot/settings.json new file mode 100644 index 0000000..2a53425 --- /dev/null +++ b/mods/currencyloot/settings.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "settings": { + "items": { + "type": "map", + "label": "Bonus currency per kill", + "description": "Use the exact currency name or metadata ID. For example, 0.05 gives one additional item on 5% of eligible kills.", + "default": { "Chaos Orb": 0.05 }, + "maxItems": 40, + "value": { "type": "number", "min": 0, "max": 20 } + } + } +}