import { PacketIO, Point, WorldPosData } from '@realmlib/net'; import { GameId } from '../models/game-ids'; import { MapTile } from '../models/map-tile'; import { Runtime } from '../runtime/runtime'; import { Account, CharacterInfo, MapInfo, PlayerData, Proxy, Server } from './../models'; export declare class Client { /** * The player data of the client. * @see `PlayerData` for more info. */ playerData: PlayerData; /** * The objectId of the client. */ objectId: number; /** * The current position of the client. */ worldPos: WorldPosData; /** * The PacketIO instance associated with the client. * @see `PacketIO` for more info. */ io: PacketIO; /** * The tiles of the current map. These are stored in a * 1d array, so to access the tile at x, y the index * y * height + x should be used where height is the height * of the map. * @example * ``` * getTile(client: Client, x: number, y: number): MapTile { * const tileX = Math.floor(x); * const tileY = Math.floor(y); * return client.mapTiles.mapTiles[tileY * client.mapInfo.height + tileX]; * } * ``` */ mapTiles: MapTile[]; /** * A queue of positions for the client to move towards. If * the queue is not empty, the client will move towards the first * item in it. The first item will be removed when the client has reached it. * @example * ``` * const pos: WorldPosData = client.worldPos.clone(); * pos.x += 1; * pos.y += 1; * client.nextPos.push(pos); * ``` */ readonly nextPos: WorldPosData[]; /** * Info about the current map. * @see `MapInfo` for more information. */ mapInfo: MapInfo; /** * Info about the account's characters. * @see `CharacterInfo` for more information. */ readonly charInfo: CharacterInfo; /** * The server the client is connected to. * @see `Server` for more info. */ get server(): Server; /** * The alias of the client. */ alias: string; /** * The email address of the client. */ readonly guid: string; /** * The password of the client. */ readonly password: string; /** * The runtime in which this client is running. */ readonly runtime: Runtime; /** * Whether or not the client should automatically shoot at enemies. */ autoAim: boolean; /** * A number between 0 and 1 which can be used to modify the speed * of the client. A value of 1 will be 100% move speed for the client, * a value of 0.5 will be 50% of the max speed. etc. * * @example * client.moveMultiplier = 0.8; */ set moveMultiplier(value: number); get moveMultiplier(): number; /** * A number between 0 and 1 which represents the percentage of health * at which the client will escape to the Nexus. * A value of 0.5 will be 50% of the max health. */ set autoNexusThreshold(value: number); get autoNexusThreshold(): number; /** * Indicates whether or not the client's TCP socket is connected. */ get connected(): boolean; /** * The current game id of this client. */ get gameId(): GameId; private socketConnected; private internalMoveMultiplier; private internalAutoNexusThreshold; private nexusServer; private internalServer; private lastTickTime; private lastTickId; private currentTickTime; private lastFrameTime; private connectTime; private buildVersion; private clientSocket; private proxy; private currentBulletId; private lastAttackTime; private pathfinder; private pathfinderEnabled; private pathfinderTarget; private moveRecords; private frameUpdateTimer; private needsNewCharacter; private connectionGuid; private key; private keyTime; private internalGameId; private reconnectCooldown; private projectiles; private random; private enemies; private players; private hasPet; private tileMultiplier; private clientHP; private hpLog; private safeMap; /** * Creates a new instance of the client and begins the connection process to the specified server. * @param server The server to connect to. * @param buildVersion The current build version of RotMG. * @param accInfo The account info to connect with. */ constructor(runtime: Runtime, server: Server, accInfo: Account); /** * Shoots a projectile at the specified angle. * @param angle The angle in radians to shoot towards. */ shoot(angle: number): boolean; /** * Removes all event listeners and releases any resources held by the client. * This should only be used when the client is no longer needed. */ destroy(): void; /** * Switches the client connect to a proxied connection. Setting this to * `undefined` will remove the current proxy if there is one. * @param proxy The proxy to use. */ setProxy(proxy: Proxy): void; /** * Connects the bot to the `server`. * @param server The server to connect to. * @param gameId An optional game id to use when connecting. Defaults to the current game id. */ connectToServer(server: Server, gameId?: GameId): void; /** * Connects to the Nexus. */ connectToNexus(): void; /** * Connects to `gameId` on the current server * @param gameId The gameId to use upon connecting. */ changeGameId(gameId: GameId): void; /** * Returns how long the client has been connected for, in milliseconds. */ getTime(): number; /** * Finds a path from the client's current position to the `to` point * and moves the client along the path. * @param to The point to navigate towards. */ findPath(to: Point): void; /** * Applies some damage and returns whether or not the client should * return to the nexus. * @param amount The amount of damage to apply. * @param armorPiercing Whether or not the damage should be armor piercing. */ private applyDamage; private checkProjectiles; /** * Checks whether or not the client should take damage from * the tile they are currently standing on. */ private checkGroundDamage; private onDamage; private onMapInfo; private onDeath; private onNotification; private onUpdate; private onReconnectPacket; private onGotoPacket; private onFailurePacket; private onAoe; private onNewTick; private onPing; private onEnemyShoot; private onServerPlayerShoot; private onCreateSuccess; private onFrame; private onConnect; private sendHello; private getBulletId; private onClose; private onError; /** * Fixes the character cache after a dead character has been loaded. */ private fixCharInfoCache; private connect; private moveTo; private walkTo; private getAttackMultiplier; private getSpeed; private getAttackFrequency; /** * Sends a packet only if the client is currently connected. * @param packet The packet to send. */ private send; private calcHealth; private checkHealth; private addHealth; }