diff --git a/mods.json b/mods.json index 89582f9..0d2667d 100644 --- a/mods.json +++ b/mods.json @@ -8,7 +8,7 @@ { "id": "itemquantity", "name": "Item Quantity", "description": "10 times as many item drops from every kill.", "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/itemquantity", "depends": [], "settings": true }, { "id": "itemrarity", "name": "Item Rarity", "description": "10 times the chance of magic, rare and unique equipment.", "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/itemrarity", "depends": [], "settings": true }, { "id": "liveeconomy", "name": "Live Economy", "description": "Faustus's Currency Exchange as a live market: the official Path of Exile leagues' prices, a spread, depth, and orders that fill with time.", "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/liveeconomy", "depends": [], "settings": true }, - { "id": "petloot", "name": "Pet Loot", "description": "Worn pets collect selected currency with per-character filters and an immediate pause switch.", "author": "zj1022", "version": "1.1.0", "compatibleClientVersions": ["0.5.2-beta"], "kind": "feature", "type": "script", "path": "mods/petloot", "depends": ["Game", "Cosmetics"], "settings": true }, + { "id": "petloot", "name": "Pet Loot", "description": "Worn pets collect selected currency with per-character filters and an immediate pause switch.", "author": "zj1022", "version": "1.2.0", "compatibleClientVersions": ["0.5.2-beta"], "kind": "feature", "type": "script", "path": "mods/petloot", "depends": ["Game", "Cosmetics"], "settings": true }, { "id": "pob", "name": "POB", "description": "Preview and import a character build through a configured external PoB converter.", "author": "nikolos89", "version": "1.0.4", "compatibleClientVersions": ["0.4.3-beta", "0.5.0-beta", "0.5.1-beta", "0.5.2-beta"], "kind": "feature", "type": "project", "path": "mods/pob", "depends": [], "settings": true }, { "id": "waypoint-tools", "name": "Waypoint Tools", "description": "Lets Waypoint's tools reach the game without the client control bridge: the item crafter gives its items through it.", "author": "Waypoint", "version": "1.0.3", "compatibleClientVersions": ["0.4.3-beta", "0.5.0-beta", "0.5.1-beta", "0.5.2-beta"], "kind": "feature", "type": "project", "path": "mods/waypoint-tools", "depends": ["Game"], "settings": false }, { "id": "zoom", "name": "Zoom", "description": "A wider view in normal play: the camera stands further back, and /zoom sets how far.", "author": "evrydayjunglist", "version": "1.0.1", "compatibleClientVersions": ["0.5.1-beta", "0.5.2-beta"], "kind": "feature", "type": "project", "path": "mods/zoom", "depends": ["Game"], "settings": true } diff --git a/mods/petloot/PetLootMod.cs b/mods/petloot/PetLootMod.cs index 9614532..1c8367e 100644 --- a/mods/petloot/PetLootMod.cs +++ b/mods/petloot/PetLootMod.cs @@ -8,11 +8,17 @@ public sealed class PetLootMod : IMod public sealed record Profile(bool Enabled, bool Gold, int Range, bool CommonCurrency, Dictionary Rules) { public double MovementSpeed { get; init; } = 2; + public bool AllCurrency { get; init; } + public bool DivinationCards { get; init; } + public bool MapFragments { get; init; } } public sealed record Choices(bool Enabled, bool Gold, int Range, bool CommonCurrency, Dictionary Rules, Dictionary Profiles) { public double MovementSpeed { get; init; } = 2; + public bool AllCurrency { get; init; } + public bool DivinationCards { get; init; } + public bool MapFragments { get; init; } } static readonly HashSet Common = new(StringComparer.OrdinalIgnoreCase) @@ -71,7 +77,10 @@ Profile ProfileOf(ClientState conn) lock (choicesGate) return choices.Profiles.GetValueOrDefault(Key(conn)) ?? new(choices.Enabled, choices.Gold, choices.Range, choices.CommonCurrency, choices.Rules) - { MovementSpeed = choices.MovementSpeed }; + { + MovementSpeed = choices.MovementSpeed, AllCurrency = choices.AllCurrency, + DivinationCards = choices.DivinationCards, MapFragments = choices.MapFragments, + }; } sealed record Candidate(uint Id, WorldItemObject Item, ItemCatalog.BaseType Type); @@ -94,7 +103,7 @@ static Candidate[] Nearby(ClientState conn, Profile profile) var pos = conn.Walk.Position(conn.Clock.Elapsed.TotalSeconds); var items = Game.ItemsFor(conn); var nearby = new List(); - foreach (var (id, item) in conn.Instance.Ground.Within(pos.X, pos.Y, Math.Clamp(profile.Range, 5, 80), _ => true)) + foreach (var (id, item) in conn.Instance.Ground.Within(pos.X, pos.Y, Math.Clamp(profile.Range, 5, 100), _ => true)) if (Visible(conn, id) && items.ByHash(item.Item.TypeHash) is { } type) nearby.Add(new(id, item, type)); return nearby.ToArray(); @@ -108,7 +117,17 @@ static bool Accept(Candidate drop, Profile profile) || (gold ? !profile.Gold : drop.Type.MaxStack <= 1)) return false; if (!profile.Rules.TryGetValue(drop.Type.Id, out int minimum) && !profile.Rules.TryGetValue(drop.Type.Name, out minimum)) - minimum = gold || profile.CommonCurrency && Common.Contains(drop.Type.Name) ? 1 : 0; + { + bool selected = gold || profile.CommonCurrency && Common.Contains(drop.Type.Name) + || drop.Type.Class switch + { + "StackableCurrency" => profile.AllCurrency, + "DivinationCard" => profile.DivinationCards, + "MapFragment" => profile.MapFragments, + _ => false, + }; + minimum = selected ? 1 : 0; + } return minimum > 0 && drop.Item.Item.StackSize >= minimum; } @@ -132,12 +151,19 @@ async Task Tick(ClientState conn, double seconds) foreach (uint old in state.RetryAfter.Where(e => e.Value <= state.Seconds).Select(e => e.Key).ToArray()) state.RetryAfter.Remove(old); var at = conn.Walk.Position(conn.Clock.Elapsed.TotalSeconds); - var candidates = Nearby(conn, profile).Where(i => Accept(i, profile) && !state.RetryAfter.ContainsKey(i.Id)); - var drop = state.Item is uint target ? candidates.FirstOrDefault(i => i.Id == target) - : candidates.MinBy(i => Distance(at.X, at.Y, i.Item.GridX, i.Item.GridY)); + Candidate? matching = null, nearest = null; + double nearestDistance = double.PositiveInfinity; + foreach (var candidate in Nearby(conn, profile)) + { + if (!Accept(candidate, profile) || state.RetryAfter.ContainsKey(candidate.Id)) continue; + if (candidate.Id == state.Item) { matching = candidate; break; } + double distance = Distance(at.X, at.Y, candidate.Item.GridX, candidate.Item.GridY); + if (distance < nearestDistance) { nearestDistance = distance; nearest = candidate; } + } + var drop = matching ?? nearest; if (drop is null) { await Release(conn, state); return; } var to = (X: drop.Item.GridX, Y: drop.Item.GridY); - if (state.Item is null) + if (matching is null) { double now = conn.Clock.Elapsed.TotalSeconds; lock (conn.Pets) @@ -159,7 +185,7 @@ async Task Tick(ClientState conn, double seconds) var current = ProfileOf(conn); double now = conn.Clock.Elapsed.TotalSeconds; var owner = conn.Walk.Position(now); var collector = pet.Walk.Position(now); - if (Accept(drop, current) && Distance(owner.X, owner.Y, to.X, to.Y) <= Math.Clamp(current.Range, 5, 80)) + if (Accept(drop, current) && Distance(owner.X, owner.Y, to.X, to.Y) <= Math.Clamp(current.Range, 5, 100)) { if (Distance(collector.X, collector.Y, to.X, to.Y) <= 2) pickup = Game.TakeGroundStack(conn, drop.Id, drop.Item); @@ -168,8 +194,12 @@ async Task Tick(ClientState conn, double seconds) } } if (pickup is not null) + { + state.Item = null; await Game.SendPickup(conn.Wire.Remote, conn.Wire.Stream, conn.Wire.Ciphers, conn, drop.Id, pickup); - else state.RetryAfter[drop.Id] = state.Seconds + 2; + return; + } + state.RetryAfter[drop.Id] = state.Seconds + 2; await Release(conn, state); } finally { state.Gate.Release(); } @@ -189,9 +219,9 @@ async Task Command(ClientState conn, string[] args) if (action is "status" or "list") { string rules = string.Join(", ", profile.Rules.OrderBy(r => r.Key).Select(r => $"{r.Key}: {(r.Value == 0 ? "blocked" : "min " + r.Value)}")); - await conn.Commands!.Reply($"Pet Loot: {(profile.Enabled ? "on" : "paused")}; gold {profile.Gold}; common currency {profile.CommonCurrency}; range {profile.Range}; pet speed {profile.MovementSpeed.ToString(System.Globalization.CultureInfo.InvariantCulture)}x.\n" + await conn.Commands!.Reply($"Pet Loot: {(profile.Enabled ? "on" : "paused")}; gold {profile.Gold}; common currency {profile.CommonCurrency}; all currency {profile.AllCurrency}; cards {profile.DivinationCards}; fragments {profile.MapFragments}; range {profile.Range}; pet speed {profile.MovementSpeed.ToString(System.Globalization.CultureInfo.InvariantCulture)}x.\n" + $"Overrides: {(rules.Length == 0 ? "none" : rules)}\n" - + "/petloot on|off|toggle; gold|common on|off; range 5-80; speed 0.25-10; allow [minimum]; block|remove ; nearby; reset"); + + "/petloot on|off|toggle; gold|common on|off; range 5-100; speed 0.25-10; allow [minimum]; block|remove ; nearby; reset"); return; } if (action == "nearby") @@ -204,7 +234,7 @@ async Task Command(ClientState conn, string[] args) profile = profile with { Enabled = action == "on" || action == "toggle" && !profile.Enabled }; else if (action is "gold" or "common" && args.Length == 2 && args[1] is "on" or "off") profile = action == "gold" ? profile with { Gold = args[1] == "on" } : profile with { CommonCurrency = args[1] == "on" }; - else if (action == "range" && args.Length == 2 && int.TryParse(args[1], out int range) && range is >= 5 and <= 80) + else if (action == "range" && args.Length == 2 && int.TryParse(args[1], out int range) && range is >= 5 and <= 100) profile = profile with { Range = range }; else if (action == "speed") { diff --git a/mods/petloot/README.md b/mods/petloot/README.md index 03388b0..ec2d1cc 100644 --- a/mods/petloot/README.md +++ b/mods/petloot/README.md @@ -1,10 +1,10 @@ # Pet Loot -An opt-in mod: a worn cosmetic pet walks to nearby selected currency and picks it up. It is disabled on installation; +An opt-in mod: a worn cosmetic pet walks to nearby selected stackable items and picks them up. It is disabled on installation; enable it with `/mod_enable petloot` or Waypoint. `/petloot off` pauses pickup for this character, including after an area change or restart; `/petloot on` resumes it. Removing or disabling the mod leaves normal pets following the player. -1.1.0 requires LocalExile v0.5.2-beta or later, the first release with the movement-speed hook +Versions 1.1.0 and later require LocalExile v0.5.2-beta or later, the first release with the movement-speed hook ([LocalExile PR #1045](https://github.com/LocalExile/LocalExile/pull/1045)); it does not load on v0.5.1-beta, where 1.0.5 is the version to use. Pickup runs in leagues with both Game and Cosmetics. @@ -21,7 +21,8 @@ pet speed on the next player tick, including a walk already in progress. Other e Defaults: gold and 20 common currencies, within 60 cells. The preset includes Chaos, Divine, Exalted and Annulment Orbs, Mirrors, Alteration, Alchemy, Augmentation, Chance, Transmutation, Fusing, Chromatic, Jeweller's, Regret, Scouring, Regal, Blessed and Vaal Orbs, Gemcutter's Prisms and Glassblower's Baubles. Scrolls, shards, fragments, essences, cards -and scarabs are left down unless explicitly allowed. Equipment, gems, quest items and hand-dropped items are never taken. +and scarabs are left down unless enabled by category or explicitly allowed. Waypoint can enable all stackable currency, +divination cards, and map fragments independently. Existing profiles keep the common-currency preset and saved overrides. Equipment, gems, quest items and hand-dropped items are never taken. An explicit rule overrides the preset: `0` blocks an item; a positive number is its minimum ground-stack size. Exact metadata ids take precedence over display names; names are matched case-insensitively, without substring matching. @@ -39,7 +40,7 @@ Gold disabled here means **pet pickup** disabled: the game's ordinary nearby gol - `/petloot remove Chaos Orb`: remove its override and use the preset again. - `/petloot common on|off`: common-currency preset. - `/petloot gold on|off`: pet gold pickup. -- `/petloot range 40`: collection radius, 5–80 cells. +- `/petloot range 40`: collection radius, 5–100 cells. - `/petloot speed 2`: pet movement multiplier, 0.25–10 (default 2). - `/petloot nearby`: up to twelve nearby names, stack sizes and metadata ids. - `/petloot reset`: discard this character's overrides and use server defaults. @@ -50,4 +51,4 @@ league and character; another player's choices are unaffected. A character's fir defaults. Reset that profile to follow future default changes again. Keep this user's settings file private. The mod orders one walk per target. The server checks the pet and the item again when collecting. -An interrupted or expired walk returns to ordinary pet following. +If a target disappears, the pet can take another eligible target on the same tick. With no target, it returns to ordinary pet following. diff --git a/mods/petloot/mod.json b/mods/petloot/mod.json index 1a14267..d48b80a 100644 --- a/mods/petloot/mod.json +++ b/mods/petloot/mod.json @@ -3,7 +3,7 @@ "name": "Pet Loot", "description": "Worn pets collect selected currency with per-character filters and an immediate pause switch.", "author": "zj1022", - "version": "1.1.0", + "version": "1.2.0", "compatibleClientVersions": ["0.5.2-beta"], "kind": "feature", "depends": ["Game", "Cosmetics"], diff --git a/mods/petloot/settings.json b/mods/petloot/settings.json index 5041d49..aa38815 100644 --- a/mods/petloot/settings.json +++ b/mods/petloot/settings.json @@ -16,7 +16,7 @@ "type": "integer", "default": 60, "min": 5, - "max": 80, + "max": 100, "label": "Pickup radius", "unit": "cells" }, @@ -60,7 +60,7 @@ "type": "integer", "default": 60, "min": 5, - "max": 80, + "max": 100, "label": "Pickup radius", "unit": "cells" }, @@ -89,6 +89,21 @@ "format": "multiplier", "label": "Pet movement speed", "description": "Multiplier for following, collecting and returning; 1 is normal speed, 2 is double speed." + }, + "allCurrency": { + "type": "bool", + "default": false, + "label": "All stackable currency" + }, + "divinationCards": { + "type": "bool", + "default": false, + "label": "Stackable divination cards" + }, + "mapFragments": { + "type": "bool", + "default": false, + "label": "Stackable map fragments" } } } @@ -101,6 +116,21 @@ "format": "multiplier", "label": "Pet movement speed", "description": "Multiplier for following, collecting and returning; 1 is normal speed, 2 is double speed." + }, + "allCurrency": { + "type": "bool", + "default": false, + "label": "All stackable currency" + }, + "divinationCards": { + "type": "bool", + "default": false, + "label": "Stackable divination cards" + }, + "mapFragments": { + "type": "bool", + "default": false, + "label": "Stackable map fragments" } } }