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:
11
dist/Bot.js
vendored
11
dist/Bot.js
vendored
@@ -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
2
dist/Bot.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -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';
|
||||
|
||||
14
lib/Bot.ts
14
lib/Bot.ts
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user