Package Exports
- alclient
- alclient/build/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (alclient) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ALClient
This is a node client for the game Adventure Land - The Code MMORPG.
This code is NOT compatible with scripts written directly in the game. If you are just looking for a way to run your code headless, or with fewer resources, I recommend trying caracAL.
Basic Usage
- Install the latest version of node.
- Create a new folder for your project
- Run
npm init
and enter prompts. Check out this link for more information. - If you are using Typescript, which is strongly recommended, install it by running
npm install typescript
. Save your files as.ts
files instead of.js
files. - If you are using Typescript, build your code by running
npx tsc
.
Notes
In your tsconfig.json, make sure "esModuleInterop": true
is set.
In your package.json, make sure "type": "module"
is set.
General Steps
- Install the package using
npm install alclient
. - Add a
credentials.json
file that looks like this:
{
"email": "hyprkookeez@gmail.com",
"password": "thisisnotmyrealpasswordlol"
}
You can also optionally add a Mongo URI to track various data with a mongo database.
{
"email": "hyprkookeez@gmail.com",
"password": "thisisnotmyrealpasswordlol",
"mongo": "mongodb://localhost:27017/alclient"
}
- Copy and run this example script that prepares the pathfinder, logs in, moves your character around to different maps, then disconnects.
import AL from "alclient"
async function run() {
await Promise.all([AL.Game.loginJSONFile("../credentials.json"), AL.Game.getGData()])
await AL.Pathfinder.prepare(AL.Game.G)
// Set `<<MERCHANT_NAME>>` to your merchant
const merchant = await AL.Game.startMerchant("<<MERCHANT_NAME>>", "ASIA", "I")
console.log("Moving to main")
await merchant.smartMove("main")
console.log("Moving to cyberland")
await merchant.smartMove("cyberland")
console.log("Moving to halloween")
await merchant.smartMove("halloween")
merchant.disconnect()
}
run()
- While the code is running, you should be able to see your character using /comm
Notable differences from 'native' Adventure Land code.
- Most actions like
move()
are on theCharacter
in alclient.
import AL from "alclient"
async function run() {
await AL.Game.loginJSONFile("../credentials.json")
const ranger = await AL.Game.startRanger("earthiverse", "US", "I")
while (true) {
await ranger.move(50, 50)
await ranger.move(50, -50)
await ranger.move(-50, -50)
await ranger.move(-50, 50)
}
}
run()
- Some functions are renamed, most notably
attack()
isbasicAttack()
.
import AL from "alclient"
async function run() {
await Promise.all([AL.Game.loginJSONFile("../credentials.json"), AL.Game.getGData()])
await AL.Pathfinder.prepare(AL.Game.G)
const ranger = await AL.Game.startRanger("earthiverse", "US", "I")
await ranger.smartMove("hen")
while (true) {
if (ranger.canUse("attack") && ranger.isPVP()) {
// We can attack players
for (const [, player] of ranger.players) {
if (AL.Tools.distance(ranger, player) > ranger.range) continue // Too far to attack
// We found a player to attack!
await ranger.basicAttack(player.id)
break
}
}
if (ranger.canUse("attack")) {
for (const [, entity] of ranger.entities) {
if (AL.Tools.distance(ranger, entity) > ranger.range) continue // Too far to attack
// We found an entity to attack!
await ranger.basicAttack(entity.id)
break
}
}
}
}
run()