Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ works with. The maintainers publish the releases of the mods in this repository.
| [gm-commands](mods/gm-commands/) | the development and testing chat commands: teleport, items, monsters, experience, test hits, protocol probes |
| [globalchat](mods/globalchat/) | talk to other LocalExile players through the LocalExile global chat server |
| [waypoint-tools](mods/waypoint-tools/) | lets Waypoint's tools reach the game without the client control bridge: the item crafter gives its items through it |
| [equipmentfusion](mods/equipmentfusion/) | automatic attributes and defences from non-weapon native skin transfers; donor gems and skills excluded; requires the companion server update |
| [backpack](mods/backpack/) | an optional native 20-slot extra backpack for every class, with safe recovery after disable |
| [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 |
Expand Down
1 change: 1 addition & 0 deletions mods.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "equipmentfusion", "name": "Equipment Fusion", "description": "Adds non-weapon skin-transfer donor attributes and defences automatically; requires the companion native skin-transfer server update.", "author": "JJ ouyang", "version": "2.0.2", "compatibleClientVersions": ["0.5.2-beta"], "kind": "feature", "type": "project", "path": "mods/equipmentfusion", "depends": ["Game"], "settings": false },
{ "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 },
Expand Down
105 changes: 105 additions & 0 deletions mods/equipmentfusion/EquipmentFusionMod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using System.Runtime.CompilerServices;
using GameServer.Core.Protocol.Instance;
using GameServer.Modding;
using static Game;

namespace LocalExile.Mods.EquipmentFusion;

/// <summary>Native skin transfers retain the items; this optional provider contributes only their non-weapon stats.</summary>
public sealed class EquipmentFusionMod : IMod, IDisposable
{
ConditionalWeakTable<InventoryItem, InventoryItem> _sources = new();
sealed class Cached
{
public readonly Lock Gate = new();
public (byte Row, InventoryItem Item)[] Hosts = [];
public IReadOnlyList<(byte Row, InventoryItem Item)> Sources = [];
}
readonly ConditionalWeakTable<ClientState, object> _views = new();
readonly Lock _cacheGate = new();
int _disposed;
static readonly HashSet<byte> Slots = [1, 4, 5, 6, 7, 8, 9, 10, 102];
static readonly HashSet<string> Classes = ["Body Armour", "Helmet", "Amulet", "Ring", "Gloves", "Boots", "Belt"];

public void Load(IModContext mod) => GameEvents.ItemStatSources.Add(mod.Manifest.Id, Sources);

public IReadOnlyList<(byte Row, InventoryItem Item)> Sources(ClientState conn,
IReadOnlyList<(byte Row, InventoryItem Item)> native)
{
if (Volatile.Read(ref _disposed) != 0) return Array.Empty<(byte, InventoryItem)>();
if (!_views.TryGetValue(conn, out var view))
lock (_cacheGate)
{
if (Volatile.Read(ref _disposed) != 0) return Array.Empty<(byte, InventoryItem)>();
if (!_views.TryGetValue(conn, out view)) _views.Add(conn, view = new Cached());
}
var cache = (Cached)view;
lock (cache.Gate)
{
if (Volatile.Read(ref _disposed) != 0)
{
_views.Remove(conn);
return Array.Empty<(byte, InventoryItem)>();
}
bool same = cache.Hosts.Length == native.Count;
for (int i = 0; same && i < native.Count; i++)
same = cache.Hosts[i].Row == native[i].Row && ReferenceEquals(cache.Hosts[i].Item, native[i].Item);
if (same) return cache.Sources;
cache.Sources = BuildSources(conn, native);
cache.Hosts = [.. native];
return cache.Sources;
}
}

IReadOnlyList<(byte Row, InventoryItem Item)> BuildSources(ClientState conn,
IReadOnlyList<(byte Row, InventoryItem Item)> native)
{
var catalog = ItemsFor(conn);
var result = new List<(byte Row, InventoryItem Item)>();
foreach (var (row, target) in native)
{
if (!Slots.Contains(row) || target.Item.SkinTransferSource is not { } donor
|| donor.SkinTransferSource is not null || target.Id >= 0x80000000u
|| catalog.ByHash(target.Item.TypeHash) is not { } a || catalog.ByHash(donor.TypeHash) is not { } b
|| !Classes.Contains(a.Class) || a.Class != b.Class) continue;
if (!_sources.TryGetValue(target, out var projected))
lock (_cacheGate)
if (!_sources.TryGetValue(target, out projected))
{
projected = new(0x80000000u | target.Id, 0, 0, Project(donor, catalog.Mods));
_sources.Add(target, projected);
}
result.Add((row, projected));
}
return result;
}

/// <summary>Only the calculation view changes. The native donor, including its sockets and all modifiers, is kept intact.</summary>
public static Item Project(Item donor, ModCatalog mods)
{
var projected = new ItemMod[donor.Mods.Count];
for (int i = 0; i < projected.Length; i++)
{
var mod = donor.Mods[i];
if (mods.ByHash(mod.Hash) is not { } row) { projected[i] = mod; continue; }
var values = new int[mod.Values.Count];
for (int index = 0; index < values.Length; index++)
values[index] = index < row.Stats.Count && SkillExecution(row.Stats[index].Id) ? 0 : mod.Values[index];
projected[i] = mod with { Values = values };
}
return donor with { Sockets = Array.Empty<ItemSocket>(), Links = null, Mods = projected };
}

// Skill grants are never enumerated from ItemStatSources. These numeric execution controls also stay out of global stats.
static bool SkillExecution(string id) => id.Contains("trigger", StringComparison.OrdinalIgnoreCase)
|| id.Contains("cast_on_", StringComparison.OrdinalIgnoreCase)
|| id.Contains("cast_when_", StringComparison.OrdinalIgnoreCase)
|| id.Contains("granted_skill", StringComparison.OrdinalIgnoreCase)
|| id.Contains("grants_skill", StringComparison.OrdinalIgnoreCase);

public void Dispose()
{
if (Interlocked.Exchange(ref _disposed, 1) != 0) return;
lock (_cacheGate) { _views.Clear(); _sources.Clear(); }
}
}
49 changes: 49 additions & 0 deletions mods/equipmentfusion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Equipment Fusion

![Equipment Fusion](icon.png)

Author: **JJ ouyang**.

When enabled, equipment with a native skin transfer automatically gains the donor's numerical attributes and local
defences. Each item retains its own modifiers, quality, sockets and gems. Use the game's skin-transfer picker and
reclaim action; the GM tool only installs the mod, changes its switch and shows its actual load status.

Choose the single **Skin Transfer**, rather than a similarly named pack, in the native microtransaction stash.
The 3.29 client requires the donor's sockets to be empty before its picker accepts the donor; remove its gems first.
The mod does not bypass that client restriction. Saved donors containing gems still retain them on reclaim, and those
gems never supply stats, requirements or skills while the item is a donor.

## Scope

- Body armour, helmets, gloves, boots, belts, amulets and rings contribute. Both weapon hands and the stored weapon sets
are excluded, including shields and quivers.
- Global numerical modifiers use the server's existing item-stat rules and requirement qualification. Local armour,
evasion, energy shield and ward are calculated on each item before the completed values are combined.
- Donor socketed gems, granted skills and triggered skills never enter the player's skill-source collections. Numeric
trigger controls are removed from the calculation view. Ordinary numerical modifiers in the same row are retained.
- Reclaim returns the original donor with all of its properties and gems. Disabling or uninstalling the mod removes
its extra contribution on the next equipment/stat refresh. Native binding, storage and reclaim remain available.
- Existing skin transfers start contributing when the mod is enabled. No additional selection or mod chat command is needed.

## Required server update

This is a dependency draft. It requires the companion LocalExile native skin-transfer implementation and the general
`GameEvents.ItemStatSources` interface. **An unmodified LocalExile 0.5.2-beta release does not support this mod.**
The manifest's 0.5.2-beta is the repository-required provisional review baseline, not a release compatibility claim.
The maintainer must set the first release containing the prerequisite before merging or publishing.

Build with `dotnet build mods/equipmentfusion/equipmentfusion.csproj -p:LocalExileRoot=<matching-checkout>`.
Install the output in `Mods/Binaries/equipmentfusion/` of that matching server. It starts disabled.

## Controls

No added commands or tunable settings. Use Waypoint or the GM tool, or the official `/mod`, `/mod_enable equipmentfusion`,
`/mod_disable equipmentfusion` and `/mod_reload equipmentfusion` commands. Native actions remain the way to bind and reclaim.

## Icon

Reuses the original 256 by 256 Equipment Fusion artwork, made from the author's game screenshots and gameplay description.

## Validation

See the accompanying change description for the tested server revision, automated checks and native-client acceptance.
5 changes: 5 additions & 0 deletions mods/equipmentfusion/equipmentfusion.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<None Update="icon.png" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>
Binary file added mods/equipmentfusion/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions mods/equipmentfusion/mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"id": "equipmentfusion",
"name": "Equipment Fusion",
"description": "Adds non-weapon skin-transfer donor attributes and defences automatically; requires the companion native skin-transfer server update.",
"author": "JJ ouyang",
"version": "2.0.2",
"compatibleClientVersions": ["0.5.2-beta"],
"kind": "feature",
"depends": ["Game"],
"enabled": false,
"requiredServerApis": ["Item.SkinTransferSource", "GameEvents.ItemStatSources"]
}