This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
forked from Cybours/auto-aura
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
142 lines (115 loc) · 3.32 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
"use strict";
const Vec3 = require("tera-vec3");
module.exports = function autoAuras(mod) {
let locking = false;
let lockingTimerId = null;
let playerLocation = null;
let playerDirection = null;
let timerId = null;
let intervalId = null;
mod.game.initialize("me.abnormalities");
mod.command.add("autoaura", {
$none() {
mod.settings.enabled = !mod.settings.enabled;
mod.command.message(`auto-aura ${mod.settings.enabled ? "Enabled" : "Disabled"}.`);
},
pvp() {
mod.settings.pvp = !mod.settings.pvp;
mod.command.message(`auto-aura PvP ${mod.settings.pvp ? "Enabled" : "Disabled"}.`);
},
$default() {
mod.command.message("Error (typo?) in command! see README for the list of valid commands");
}
});
mod.hook("S_SPAWN_ME", 3, { "order": Infinity }, event => {
playerLocation = event.loc;
playerDirection = event.w;
if (isEnabled() && event.alive) {
mod.setTimeout(() => enableAuras(), 3000);
}
});
mod.hook("C_PLAYER_LOCATION", 5, { "order": Infinity }, event => {
playerLocation = event.loc;
playerDirection = event.w;
});
mod.hook("S_ACTION_STAGE", 9, { "order": -Infinity, "filter": { "fake": null } }, event => {
if (!isEnabled() || !mod.game.me.is(event.gameId)) return;
mod.clearTimeout(lockingTimerId);
locking = true;
});
mod.hook("S_ACTION_END", 5, { "order": -Infinity, "filter": { "fake": null } }, event => {
if (!isEnabled() || !mod.game.me.is(event.gameId)) return;
mod.clearTimeout(lockingTimerId);
lockingTimerId = mod.setTimeout(() => locking = false, 300);
});
mod.hook("C_CANCEL_SKILL", 3, { "order": -Infinity }, () => {
if (!isEnabled()) return;
mod.clearTimeout(lockingTimerId);
locking = false;
});
function isEnabled() {
return mod.settings.enabled && mod.game.me.class === "elementalist";
}
function enableAuras() {
if (intervalId) return;
mod.clearTimeout(timerId);
timerId = null;
mod.command.message("Enabling auto-auras");
intervalId = mod.setInterval(() => {
// Aura of the Merciless
if (hasNoAbn([700600, 700601, 700602, 700603])) {
startSkill(130400);
}
// Aura of the Unyielding
if (hasNoAbn([700203, 700233]) && mod.settings.pvp) {
startSkill(150400);
}
// Aura of the Tenacious
if (hasNoAbn([700330, 700300]) && !mod.settings.pvp) {
startSkill(160100);
}
// Thrall Augmentation
if (hasNoAbn([702000, 702005])) {
startSkill(450100);
}
if (!hasNoAbn([700600, 700601, 700602, 700603]) &&
!hasNoAbn([700203, 700233, 700330, 700300]) &&
!hasNoAbn([702000, 702005])
) {
mod.clearInterval(intervalId);
intervalId = null;
}
}, 100);
timerId = mod.setTimeout(() => {
if (intervalId) {
mod.clearInterval(intervalId);
intervalId = null;
}
}, 8000);
}
function hasNoAbn(abnormalities) {
return Object.keys(mod.game.me.abnormalities).filter(a => abnormalities.includes(Number(a))).length === 0;
}
function startSkill(skillId) {
if (locking || !playerLocation) return;
mod.clearTimeout(lockingTimerId);
locking = true;
mod.send("C_START_SKILL", 7, {
"skill": {
"reserved": 0,
"npc": false,
"type": 1,
"huntingZoneId": 0,
"id": skillId
},
"loc": playerLocation,
"w": playerDirection,
"dest": new Vec3(0, 0, 0),
"unk": true,
"moving": false,
"continue": false,
"target": 0n,
"unk2": false
});
}
};