bot.stayPut( .. ); - The bot will constantly attempt to teleport back to its set position. Good for recovery after region restarts.

This commit is contained in:
Casper Warden
2018-10-09 20:17:32 +01:00
parent da9fe9710c
commit fefdada38e
4 changed files with 33 additions and 1 deletions

11
dist/Bot.js vendored
View File

@@ -189,6 +189,7 @@ class Bot {
yield circuit.waitForAck(circuit.sendMessage(handshakeReply, PacketFlags_1.PacketFlags.Reliable), 10000);
this.currentRegion.handshake(handshakeMessage).then(() => {
regionName = this.currentRegion.regionName;
console.log('Arrived in region: ' + regionName);
if (agentPosition !== null) {
if (this.stayRegion === '' || requested) {
this.stayPut(this.stay, regionName, agentPosition);
@@ -212,6 +213,16 @@ class Bot {
this.lastSuccessfulPing = new Date().getTime();
this.ping = setInterval(() => __awaiter(this, void 0, void 0, function* () {
this.pingNumber++;
if (this.pingNumber % 12 === 0 && this.stay) {
if (this.currentRegion.regionName !== this.stayRegion) {
console.log('Stay Put: Attempting to teleport to ' + this.stayRegion);
this.clientCommands.teleport.teleportTo(this.stayRegion, this.stayPosition, this.stayPosition).then(() => {
console.log('I found my way home.');
}).catch(() => {
console.log('Cannot teleport home right now.');
});
}
}
if (this.pingNumber > 255) {
this.pingNumber = 0;
}

2
dist/Bot.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -23,6 +23,13 @@ const options = nmv.BotOptionFlags.LiteObjectStore | nmv.BotOptionFlags.StoreMyA
const bot = new nmv.Bot(loginParameters, options);
// This will tell the bot to keep trying to teleport back to the 'stay' location.
// You can specify a region and position, such as:
// bot.stayPut(true, 'Izanagi', new Vector3([128, 128, 21]));
// Note that the 'stay' location will be updated if you request or accept a lure (a teleport).
// If no region is specified, it will be set to the region you log in to.
bot.stayPut(true);
let isConnected = false;
const master = 'd1cd5b71-6209-4595-9bf0-771bf689ce00';

View File

@@ -253,6 +253,7 @@ export class Bot
this.currentRegion.handshake(handshakeMessage).then(() =>
{
regionName = this.currentRegion.regionName;
console.log('Arrived in region: ' + regionName);
if (agentPosition !== null)
{
if (this.stayRegion === '' || requested)
@@ -285,6 +286,19 @@ export class Bot
this.ping = setInterval(async () =>
{
this.pingNumber++;
if (this.pingNumber % 12 === 0 && this.stay)
{
if (this.currentRegion.regionName !== this.stayRegion)
{
console.log('Stay Put: Attempting to teleport to ' + this.stayRegion);
this.clientCommands.teleport.teleportTo(this.stayRegion, this.stayPosition, this.stayPosition).then(() =>
{
console.log('I found my way home.');
}).catch(() => {
console.log('Cannot teleport home right now.');
});
}
}
if (this.pingNumber > 255)
{
this.pingNumber = 0;