Skip to content
ASArcaneMP Scripting APIScripting reference
GuideMaintainer authored

Appearance

Save and restore how players look, open the character creator, change their clothes, house, size, disguise, animal form and what they hold, fly a winged form, and choose whether players collide.

A player’s look is their body, face, hair, voice and name. Their own game builds it and sends it to the server, which checks it and shows it to everyone else. The server can read a look, keep it and hand it back, and it controls a player’s house, size, disguise, animal form and the prop in their hand. Clothes are gear in the player’s inventory.

player.getLook() returns the player’s look as plain ids:

Field Meaning
format, version Always "arcanemp-look", and the version of the format. Looks saved before 1.12 say "hogwartsmp-look", which is still read.
gender "male" or "female"
presets The creator’s choice for each category, such as { hairStyle: "HairFemale040" }. hairColour is either a preset or a picked "#rrggbb" colour
gear What the player wears, as the game’s appearance ids
faceGear, house, scale, voice, name, hood, wandStyle Present when set: glasses, house colours, size, voice, character name, hood and wand style
facialHair The beard or moustache, such as "M_Facial_zBase_FullBeard". Absent or "" is clean-shaven.
facialHairColor "hair" to match the hair, or a "#rrggbb" colour. Absent, the facial hair keeps its own colour.
pronoun "witch" or "wizard": the creator’s Witch or Wizard pick, which decides the dormitory the game lets the player into. Absent, it follows the body: a female body is a witch.

playerAppearanceChanged fires with the player, their new look and its revision whenever the look changes, and player.appearanceRevision counts those changes for the current visit. A player’s game sends at most two looks a second.

The server writes nothing down, and every player joins looking like the game’s default character. To give players their own look back, save it as it changes and restore it once their loading screen is gone. Before then the player has no body to apply it to:

server/main.js
const restored = new Set(); // ids of players whose saved look is back on
Events.on("loadingFinished", async (player) => {
const saved = await loadLook(player);
if (!player.connected) return;
if (!saved) {
restored.add(player.id);
return;
}
player.setLook(saved, (error) => {
if (error) console.warn(`could not restore ${player.nickname}'s look: ${error.code}`);
restored.add(player.id);
});
});
Events.on("playerAppearanceChanged", (player, look) => {
if (!look || !restored.has(player.id) || Object.keys(look.presets).length === 0) return;
saveLook(player, JSON.stringify(look));
});
Events.on("playerDisconnect", (player) => restored.delete(player.id));

loadLook and saveLook stand for your own store. Three things the sample guards against:

  • The first look a joining player sends is the default character, so saving every change would overwrite their saved look before you restore it.
  • Until the player’s game sends its first look, getLook() returns one with no presets. Do not save that either.
  • setLook replaces the whole look rather than changing the fields you pass, so always pass a complete look, from getLook, the event or the creator.

player.setLook(look, callback) takes a look or its JSON text. The callback runs with (error, result) once the player’s game has rebuilt their character, within 20 seconds, and result.revision is the revision it produced. Without a callback, a malformed look throws INVALID_APPEARANCE. The server checks a look’s shape, not that its ids exist in the game, and the player’s game leaves out ids it does not know, so read the look back if it matters.

A look’s gear, hood and house show how other players see the player, but do not dress the player themselves. What they wear, their hood and the look a worn item shows all come from their inventory, so restoring it restores them. When a player raises or lowers their hood, their look changes with it and other players see it. Restore the house with player.house.

The client has no creator screen of its own: a resource builds one on the Creator API, as Foundations does, and the player sees each change on their own character as they make it.

  • Creator.begin() starts an editing session and returns false if another resource already holds one, so check it before showing your screen. Creator.isActive() says whether any resource holds one.
  • Creator.getSchema() lists every category and the ids it accepts, and Creator.applyPatch({ hairStyle: id }) changes categories. creatorChanged fires with the new selections once a change applies.
  • Creator.commit() keeps the changes, and the new look reaches the server as playerAppearanceChanged. Creator.cancel() puts the old look back.
  • CreatorPreview.setCamera(frame) points a camera at the front of the player and CreatorPreview.rotate(degrees) turns them, until CreatorPreview.restoreCamera().
  • Creator.exportLook() returns the player’s look on the client.
client/main.js
Events.on("creator:open", () => {
if (!Creator.begin()) return; // another resource is editing the look
// ... show your creator screen
});
Events.on("creator:confirm", () => {
Creator.commit();
Events.emitServer("creator:done");
});
Events.on("creator:cancel", () => Creator.cancel());

A disguised player’s game stops sending their look, so take off a disguise before starting a session.

Facial hair is two categories, facialHair and facialHairColor, which take the look’s own values. The schema lists the game’s beards and moustaches and a few natural shades, applyPatch also takes any "#rrggbb" colour, and an empty id takes the facial hair off or gives it back its own colour. Offer them only when Creator.getCapabilities().facialHair is true, as older builds do not have them.

hairColour takes a "#rrggbb" colour too, in applyPatch and in a look’s presets, beside the game’s own hair colours. A later hair colour preset, or a full-body preset, replaces it. Offer a colour picker only when Creator.getCapabilities().hairColourHex is true.

The creator’s dormitory choice, witch or wizard, reaches the look as pronoun when the player confirms. Creator.getState().pronoun reads the pick the game holds, when Creator.getCapabilities().pronoun is true.

Portrait.capture(request) renders a picture of a player, or of a saved look, for a web view. One capture runs at a time and takes a second or so: check Portrait.busy(), then Portrait.lastImage() returns it as a data URI.

What a player wears is gear in their inventory. player.inventory.give(itemId, 1, { equipped: true }) hands them a piece already worn, and player.gear.apply(changes, callback) dresses them in gear they own, slot by slot:

server/main.js
function wearUniform(player) {
player.gear.apply({ Outfit: "Outfit_001_Basic", Head: null }, (error) => {
if (error) player.sendChat(`You do not own the uniform (${error.code}).`);
});
}

player.gear.slots() lists the slots, player.gear.equipped() what is worn in each, and player.gear.available(slot) what the player owns for one. A gear change reaches the server as a new look, and playerGearChanged fires with the player.

player.house reads or sets the player’s house: "Gryffindor", "Hufflepuff", "Ravenclaw", "Slytherin" or "Unaffiliated", the default. Setting it changes their robes and crest.

player.gender is the player’s Witch or Wizard pronoun: "female" for a witch and "male" for a wizard, which the dormitory staircases check. It follows the look’s pronoun whenever the player wears a look that has one. Setting it changes the pronoun in the player’s game without rebuilding their character, and their next look carries it. It does not change their body, which follows the look’s gender.

player.setScale(scale, mode) resizes a player for everyone, from 0.1 to 10 times. In the default "full" mode their collision and the target others lock on to grow with them, and their feet stay on the ground as they do; "visual" resizes only the body and what they wear. player.getScale() and player.getScaleMode() read it back.

server/main.js
function startGiantDuel(first, second) {
first.setScale(3);
second.setScale(3);
}

A look saved while a player is resized carries the size, and restoring it resizes them again.

player.setTransmog(characterId) makes a player look like one of the game’s characters, to everyone including themselves, and player.setTransmog("") takes it off. The server accepts any well-formed id. Character.isAllowed(characterId) checks it against the human characters Character.create can place. The game’s ghosts work as disguises too, though most of them fail that check, and a ghost disguise looks ghostly to the player as well. player.getTransmog() reads it back.

A disguise is not part of the look: getLook never includes it, and setLook takes it off.

player.setAnimalForm(form) turns a player into one of the game’s beasts, on every client including their own. Their human body is hidden and the beast stands in its place, walking, trotting or galloping to match how fast the player moves. player.setAnimalForm(null) turns them back, and player.getAnimalForm() reads the form, or null.

Option Meaning
species Any species in Beast.catalog(), such as "Niffler", "Hippogriff" or "KneazleOffspring"
look "species", the default, or "cat", which dresses a Kneazle as the castle’s grey cat
size The animal against its natural size: 1 by default, 2 for twice as big
color The coat: one of the species’ colors in the catalog. The cat look has its own ten: "Default", the castle cat’s grey, and "Variation1" to "Variation9", which are black, calico, orange, Siamese, Somali, spotted, striped, tortoiseshell and Turkish Van
gender "male" or "female"
server/main.js
Events.on("chatCommand", (player, message, command, args) => {
if (command !== "cat") return;
if (player.getAnimalForm()) {
player.setAnimalForm(null);
return;
}
const size = args.length > 0 ? Number(args[0]) : 1;
if (!(size > 0)) {
player.sendChat("Usage: /cat [size], such as /cat 2 for a cat twice as big.");
return;
}
player.setAnimalForm({ species: "Kneazle", look: "cat", size });
});

Every client draws the same coat and sex. Left out, color and gender stay as they are when a call keeps the species and look, as one that only changes the size does. For a new animal, the server picks a coat on the game’s own spawn odds, and the sex follows the player’s own gender.

setAnimalForm throws a RangeError for a species the catalog does not list, for the cat look on anything but a Kneazle, for a colour the form does not have, for a gender other than the two, and for a size of 0 or less.

The player is still themselves under the beast. They move at a human’s pace, and their collision, camera, hitbox and nametag are fitted to the animal. Their own game does not let them cast spells, and other players see no wand or held prop. A species that flies in the game, one with canFly in the catalog, takes its flight poses whenever the player is more than 1.2 m above the ground, but the form does not lift them there: see Flying.

getAnimalForm() returns the species, the look, the color and gender worn, the size worn and the scale: how large the player is against a human. That scale is held to setScale’s range of 0.1 to 10. A size that would take it further is cut back to fit, and size reads back the size worn. setScale and getScale keep working on the human meanwhile: a size set during the form is the one the player comes back at.

The form swaps the body at once, with no animation of its own. An animagus is yours to build around it: play the game’s own human-to-cat clips with LocalPlayer.playClip and its morph effects before the swap, set setDamageGivenMultiplier(0) while a player is an animal if animals should not fight, leave a player who is down or riding as they are, and change players back when they die. The hidden human still rolls on the dodge key, and blinks with the Swift talent, so hold dodge off on the player’s client with LocalPlayer.setDodgeEnabled(false) while they are an animal, and pass true when they change back.

A form gives a flier its poses, not flight. The game has no flight for a player on foot, so a client script flies the local player itself, the way a scripted flight does: it stops their controls, turns off their collision, and moves them a short step at a time, steered by the camera and the movement keys.

Every game, the player’s own included, watches the ground under each flier. One more than 1.2 m up takes off and flies, glides while it sinks, hovers when it slows and faces the way it moves, and it lands once it comes back within 40 cm of the ground. Only the player’s position crosses the network, so anything that lifts a flier gives it the same poses: a script like this one, a teleport or a launch.

The server checks that the form can fly and tells the player’s client to take off or land:

server/main.js
const flying = new Set();
function setFlying(player, on) {
if (on) flying.add(player.id);
else flying.delete(player.id);
const size = player.getAnimalForm()?.size ?? 1;
player.emit("my-forms:fly", JSON.stringify({ on, speed: 900 * size }));
}
Events.on("chatCommand", (player, message, command) => {
if (command !== "fly") return;
const form = player.getAnimalForm();
if (!form || !Beast.catalog().some((beast) => beast.id === form.species && beast.canFly)) {
player.sendChat("Only a winged form can fly.");
return;
}
setFlying(player, !flying.has(player.id));
});
Events.on("playerDisconnect", (player) => flying.delete(player.id));

The client flies them, setting the position on every step, even while hovering. It also takes the player’s gravity away for the flight. With collision off, gravity would drop the player through the ground, and to the game a flier is a player falling: one that hovers for 5 seconds more than 10 m above the last ground it stood on reads as stuck in a fall, which kills them:

client/main.js
const STEP_MS = 16;
const WALL_CM = 40;
let flight = null;
function groundBelow(at) {
const hit = World.lineTrace(at, { x: at.x, y: at.y, z: at.z - 20000 });
return hit && !hit.startPenetrating ? hit : null;
}
function step() {
const view = Camera.capture()?.rotation ?? LocalPlayer.getControlRotation();
if (!flight || !view) return;
const yaw = (view.yaw * Math.PI) / 180;
const pitch = ((((view.pitch + 180) % 360) - 180) * Math.PI) / 180;
const ahead = (Key.isDown("w") ? 1 : 0) - (Key.isDown("s") ? 1 : 0);
const side = (Key.isDown("d") ? 1 : 0) - (Key.isDown("a") ? 1 : 0);
const lift = (Key.isDown("space") ? 1 : 0) - (Key.isDown("ctrl") ? 1 : 0);
const wish = {
x: Math.cos(pitch) * Math.cos(yaw) * ahead - Math.sin(yaw) * side,
y: Math.cos(pitch) * Math.sin(yaw) * ahead + Math.cos(yaw) * side,
z: Math.sin(pitch) * ahead + lift,
};
const length = Math.hypot(wish.x, wish.y, wish.z);
const at = flight.at;
if (length > 0) {
const reach = (flight.speed * STEP_MS) / 1000;
const dir = { x: wish.x / length, y: wish.y / length, z: wish.z / length };
const to = { x: at.x + dir.x * reach, y: at.y + dir.y * reach, z: at.z + dir.z * reach };
// Nothing stops a player without collision, so the step stops short of whatever it would enter.
const wall = World.lineTrace(at, { x: to.x + dir.x * WALL_CM, y: to.y + dir.y * WALL_CM, z: to.z + dir.z * WALL_CM });
if (!wall || wall.startPenetrating) flight.at = to;
}
LocalPlayer.clearVelocity();
LocalPlayer.setPosition(flight.at.x, flight.at.y, flight.at.z);
}
function takeOff(speed) {
const at = LocalPlayer.getPosition();
if (flight || !at) return;
const ground = groundBelow(at);
flight = { at, speed, stand: ground ? at.z - ground.location.z : 50, timer: setInterval(step, STEP_MS) };
LocalPlayer.stopPlayerInput();
LocalPlayer.suspendGravity();
LocalPlayer.setCollision(false);
}
function land() {
if (!flight) return;
clearInterval(flight.timer);
const { at, stand } = flight;
flight = null;
const ground = groundBelow(at);
LocalPlayer.clearVelocity();
LocalPlayer.setPosition(at.x, at.y, ground ? ground.location.z + stand : at.z);
LocalPlayer.resetFall();
LocalPlayer.restoreGravity();
LocalPlayer.setCollision(true);
LocalPlayer.restorePlayerInput();
}
Events.on("my-forms:fly", (payload) => (payload.on ? takeOff(payload.speed) : land()));

LocalPlayer.stopPlayerInput() stops the hidden human from walking off on the movement keys, while the camera still turns and Key.isDown still reads them. stand is how far the player’s middle sits above the ground at takeoff, so a landing puts any size of animal back on its feet, and LocalPlayer.resetFall() keeps the trip from counting as one long fall. Gravity explains suspendGravity and restoreGravity. This flight drops straight to the ground when it lands. For a gentler landing, keep stepping down until the player is just above the ground, then land.

Land a flier before turning them back, and when they die: call setFlying(player, false) before player.setAnimalForm(null), or the client goes on flying a human.

player.equipProp(path, options) puts one of the game’s meshes in a player’s hand, and everyone sees it. options.socket picks the attachment point, WandSocket by default, and options.offset adjusts its position (in centimetres), rotation and scale. player.getProp() reads it, and player.clearProp() takes it away.

server/main.js
function handApple(player) {
player.equipProp("/Game/Environment/BanditCamps/Bandit_Camp_Shared_Props/Food/SM_BCProps_Apple_A_2bite.SM_BCProps_Apple_A_2bite", {
socket: "SKT_RightHandSocket",
});
}

A prop handed to a player before they have a body is dropped, so wait for loadingFinished.

On the client, LocalPlayer.setVisibility(false) hides the player’s own body, wand and held prop on their screen only, for a first-person camera or a cutscene. Everyone else still sees them, unless the server hides them with player.setVisible(false). It lasts through respawns and travel until you change it.

Players walk through each other by default. World.setPlayerCollision(true) makes them block each other’s movement on every client, and World.playerCollision reads the setting back.

server/main.js
World.setPlayerCollision(true);
Events.on("loadingFinished", (player) => {
if (isStaff(player)) player.setCollidable(false); // staff walk through crowds
});

It only stops players walking into each other. NPCs, beasts, spells and the world are untouched, and nobody can push anyone. Two players who end up inside each other, after a teleport or at a shared spawn point, pass through until they have moved apart. Players who are hidden with setVisible(false), riding a broom or creature, dead, disillusioned or in an animal form never block.

player.setCollidable(false) takes one player out of it: they pass through everyone, and everyone through them. player.isCollidable() reads it, true by default. Both settings belong to the server, and a player’s own client cannot undo them.

House, size, disguise, animal form, props and whether a player collides last for the visit and are gone when the player reconnects, like the look itself. Save what should last and set it again on loadingFinished.