ddbot.js-0374 4.4.2 → 4.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/modules/snap.d.ts +1 -0
- package/lib/modules/snap.js +8 -0
- package/package.json +1 -1
package/lib/modules/snap.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ declare class Snap extends BaseModule {
|
|
|
36
36
|
y: number;
|
|
37
37
|
} | null;
|
|
38
38
|
get isFrozen(): boolean;
|
|
39
|
+
lookatplayer(client_id: number): void;
|
|
39
40
|
protected _start(): void;
|
|
40
41
|
protected _stop(): void;
|
|
41
42
|
on<K extends keyof SnapEvents>(event: K, listener: SnapEvents[K]): this;
|
package/lib/modules/snap.js
CHANGED
|
@@ -72,6 +72,14 @@ class Snap extends module_js_1.default {
|
|
|
72
72
|
get isFrozen() {
|
|
73
73
|
return this._isFrozen;
|
|
74
74
|
}
|
|
75
|
+
lookatplayer(client_id) {
|
|
76
|
+
const pl_character = this.bot.bot_client?.SnapshotUnpacker.getObjCharacter(client_id);
|
|
77
|
+
const own_character = this.bot.bot_client?.SnapshotUnpacker.getObjCharacter(this.bot.OwnID);
|
|
78
|
+
if (!pl_character || !own_character)
|
|
79
|
+
return;
|
|
80
|
+
const angle = Math.atan2(pl_character.character_core.y - own_character.character_core.y, pl_character.character_core.x - own_character.character_core.x);
|
|
81
|
+
this.bot.send_input({ target_x: Math.cos(angle) * 256, target_y: Math.sin(angle) * 256 });
|
|
82
|
+
}
|
|
75
83
|
_start() {
|
|
76
84
|
this.bot.on('snapshot', this.snapslistener);
|
|
77
85
|
this.bot.on('hammerhit', this.hammerHitlistener);
|