Skip to content
ASArcaneMP Scripting APIScripting reference
GuideMaintainer authored

Overview

What an ArcaneMP resource is, where its code runs, and which guide to open first.

ArcaneMP resources run JavaScript in one of two environments:

  • Server resources run in Node.js and own authoritative game state.
  • Client resources run in a sandboxed V8 context and control local presentation and input.

Use the navigation to browse the globals available to the selected environment. The same declarations that generate this reference can be loaded by an editor for autocomplete and type checking.

Start here:

  • Run a local server — a server on your own machine to join and reload resources on while you work.
  • Your first resource — the manifest, script roles, load order, and sharing code between resources.
  • Debugging — where output and errors go on each side, and what an error does to a resource.

The ideas everything builds on:

  • Authority — what the server owns, what clients run and report, and how to handle what a client sends.
  • Events — listeners, the client/server bridge, the runtime event catalog, and the trust boundary.
  • State bags — your own keys and values on players and other entities, replicated to the clients that need them.
  • Virtual worlds — separate copies of the world for arenas, events and spectators.

Players:

  • Join and spawn — admitting players, the events of a visit, spawn points, deaths and respawns.
  • Travel between places — teleports, fast travel and Floo flames, loading another map, and the places the game builds from several maps.
  • Walking and seating players — walking players to a point or after another player, seating them, and landing a scripted flight.
  • Chat and commands — sending chat, taking over the chat relay, and slash commands.
  • Inventory — the server-owned inventory, atomic changes, saving inventories, items the game hands out, gear capacity and using tools.
  • Appearance — saving and restoring looks, the character creator, clothes, house, size, disguises, animal forms and flying them, props and player collision.
  • Activities — the game’s own animated activities, from flying a Magic Kite Battle kite to opening a Howler, from the server or a client script.
  • Progression — levels and experience, which spells players can cast, talents, and every talent in the game.
  • Field Guide progress — reading a character’s collections and challenges, saving and restoring them between visits, and following progress as it is made.
  • Custom spells — spells of your own built on the game’s, their casts, how PvP prices them and modded spells, and lessons of your own.

NPCs and creatures:

  • NPCs — spawning enemies, who runs their AI, controlling their health, targets and size, and switching their behaviour off.
  • Moving NPCs and creatures — paths of waypoints for NPCs, beasts and characters, having them follow players and each other, idles, and arrival events.
  • Beasts and characters — tame creatures players care for, and townspeople, ghosts and other characters with looks, clips, wands and props.
  • Catching beasts — the Nab-Sack, refereeing catches, keeping a player’s bag across reconnects, and releasing beasts.

PvE:

  • Fighting NPCs — how several players fight one NPC, damage and death events, damage multipliers, and bosses.
  • Rewards and loot — what an NPC’s death pays and to whom.
  • Combat arenas — the Overland’s two combat arenas run on the server: starting them, their waves and events, and what they pay.

Encounters:

  • Encounter policy — whether Overland’s camps and roaming encounters are off, spawned by each player’s game, or run by the server.
  • Camps — server-run enemy camps, how they come back, and when they are cleared.
  • World events — the roaming encounters, their cooldowns, and starting or resetting one yourself.
  • Zones — areas the server watches for players and other entities coming and going.

PvP:

World:

  • Time and weather — the shared clock, calendar, season and weather, holiday decor, the Headmaster’s office, the Great Hall’s meals and banners, and one client’s own sky.
  • Crowds — bringing back the game’s own students, townsfolk and shopkeepers on a client, keeping chosen NPCs out, and thinning the crowd by area.
  • Objects and effects — placing and moving props from the game’s meshes and Blueprints, and visual effects that can follow an entity.
  • Text labels — text the server floats over a place or an entity for every nearby player: its look, markup, attaching it, and who sees it.
  • Physics objects — objects that fall, roll and fly, pushing and throwing them, and letting players carry them.
  • Doors — holding the game’s doors locked or open for everyone, deciding who gets in, and opening other houses’ common rooms to a player.
  • Gates — portcullises, the rune gate, goblin camp gates and crawl grates, held for everyone or set for one player.
  • Loot — server-owned chests, moonstones and foragables, per-player contents, switching off the game’s own loot, and running its deposits and foragables from the server.
  • Hogwarts Express — running the train from the server, stopping it at Hogsmeade, its events, and the Foundations timetable.
  • Line traces — finding what a line through the world hits first, from a client script.
  • Shapes — drawing rings, spheres, boxes, cylinders, polygons and lines in the world from a client script, to show zones or debug traces.

Room of Requirement:

  • Rooms — loading rooms under ids of your own, letting players decorate them, and saving what they build.
  • Doors and visits — where each player’s door leads, taking players in, visitors, and who is where.
  • Wings, vivariums and recipes — opening a room’s expansions, vivarium biomes and lighting, and giving players the conjuration recipes.
  • Vivarium beasts — the beasts a room keeps in its vivariums, refereeing players’ moves, harvests and breeds, and saving the beasts with the room.

User interface:

  • Web views — HTML interfaces in the game, and messages between the page and your scripts.
  • Avatar preview — the player’s own live figure framed in a web page, for gear panes and wardrobes, on a backdrop that can match the page.
  • HUD, prompts and nametags — hiding the game’s HUD, interaction prompts, and what players’ nametags show.
  • Map markers — markers, search circles and routes on the map, the player’s own waypoint, player blips, the game’s own map icons, and the minimap.
  • Keys and menus — key bindings, locking the controls, jump, sprint, dodge and gravity holds, keeping the game’s own menus shut, and following the player’s spell sets.

Camera and sound:

  • Camera — taking over the view with shots, paths and orbits, mouse look, fades and handing it back, and moving the game’s own camera back.
  • Post-processing — grading a player’s view with photo-mode presets, settings and full-screen materials, faded in and out.
  • Audio — the game’s sounds from the server or a client, soundbanks, music, and muting the game’s own dialogue.
  • Voice chat — who hears whom, voice ranges and tiers, muting, and each player’s voice settings.

Mounts and races:

  • Brooms and mounts — giving players brooms and creatures, mounting and dismounting, flight overrides, aiming from a broom, and keeping riders out.
  • Races — the game’s broom races on tracks of your own, for several players, timed by the server.

Quidditch:

  • Running a match — hoops, a quaffle players carry and throw, bludgers and the snitch, all run on the server.

Running a server:

  • Hosting a server — installing on Windows or Linux, Foundations, ports, the masterlist, and updates.
  • Server configuration — every server.json key, command-line flags, passwords, and required mods.
  • Docker and game panels — the public server image, Compose, and the Pterodactyl and Pelican egg.
  • Player guide — the page to send your players: installing the client, joining, updates and bug reports.
Events.on("playerConnect", (player) => {
player.sendChat(`Welcome to the castle, ${player.nickname}!`);
const npc = NPC.create("Goblin_Grunt", { x: 250, y: 120, z: 0 });
if (npc) {
npc.setMaxHealth(500);
}
});

Server resources load and save inventory however they choose. The framework only owns the connected session shadow and its projection into the native client:

Events.on("playerConnect", (player) => {
loadInventory(player, (items) => {
player.inventory.replace(items, (error) => {
if (error) player.kick(`Inventory sync failed: ${error.code}`);
});
});
});
function reward(player, itemId, count) {
player.inventory.give(itemId, count, {}, (error, result) => {
if (error) {
console.error(error.code, error.message);
return;
}
console.log(`inventory revision ${result.revision} sent`);
});
}

player.inventory.list(), count(), and has() read only server memory. Client inventory state never grants items to the server inventory.

Events.on("season", (payload) => {
Game.notify(`The season is now ${payload.name}`);
});
const pos = LocalPlayer.getPosition();
if (pos) {
console.log(pos.x, pos.y, pos.z);
}
Key.bind("f6", () => {
if (Camera.active) {
Camera.clearLookAt();
Camera.restore({ duration: 0.5, curve: "easeOut" });
return;
}
const target = LocalPlayer.getPosition();
const view = Camera.capture();
if (!target || !view) return;
Camera.activate({ position: { x: target.x + 300, y: target.y, z: target.z + 100 }, rotation: view.rotation });
Camera.orbit(target, { radius: 300, height: 100, speed: 25 });
});

Server and client declarations must be loaded separately. A global shown in one environment is not automatically available in the other.