Skip to content

Modding support #3

@DarkPro1337

Description

@DarkPro1337
  • Implement ModManager
  • Implement *.arcpak archive support
  • Implement metadata handling
  • Implement WASM (WebAssembly) entrypoint execution
  • Implement API:
    • Proper ModApi within ModManager
    • AssemblyScript environment file (env.ts) for the Modding API
  • Implement resource loading:
    • PCK
    • YAML
    • CSV

About arcpak

*.arcpak is the Arcomage Package file format, essentially a ZIP archive.
Each arcpak must include a metadata.yaml file that describes the package contents.

At launch, arcpak should support:

  • Modifying existing game resources and adding new ones.
  • Creating new localizations and translations as mods.
  • Introducing entirely new card decks.
  • Executing WASM scripts.
  • Managing dependencies between packages.

The first planned arcpak will feature the MM7 deck.


Why WASM (WebAssembly)?

Recently, I researched executing custom user scripts in Arcomage and discovered that Microsoft Flight Simulator uses WebAssembly (WASM) for modding. This approach caught my attention, so I explored why WASM is a solid choice.

In short, WASM is safe (as code runs in a sandbox) and highly portable, making it an excellent option for modding.


Environment File (env.ts) for the Modding API

The env.ts file defines external functions provided by the host environment that are accessible to WebAssembly modules. These functions allow mods to interact with the game engine through a predefined set of host-side APIs.

For example, a basic env.ts file might look like this:

@external("env", "host_log")
declare function host_log(ptr: i32, len: i32): void;

export function log(message: string): void {
  const encoded = String.UTF8.encode(message);
  host_log(changetype<i32>(encoded), encoded.byteLength);
}

Here, host_log is a function exposed by the host, allowing mods to log messages from within WebAssembly.

The env.ts file serves as a bridge between the game engine and WebAssembly-based mods, enabling them to call predefined host functions for seamless integration.

Metadata

Metadata

Assignees

Labels

moddingMod creation support

Projects

Status
InProgress

Relationships

None yet

Development

No branches or pull requests

Issue actions