-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
113 lines (98 loc) · 2.65 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
module.exports = function auto_auras(mod) {
const wait = ms => new Promise(resolve => mod.setTimeout(resolve, ms));
const command = mod.command;
const AbnormalManager = require('../battle-notify/lib/abnormal');
const AbnManager = new AbnormalManager(mod,false);
let loc, wloc,
isMystic = false;
command.add(['autoaura', '!autoaura'], {
$none() {
mod.settings.enabled = !mod.settings.enabled;
command.message('auto-aura '+(mod.settings.enabled ? 'Enabled' : 'Disabled') + '.');
},
onrez() {
mod.settings.onrez = !mod.settings.onrez;
command.message('auto-aura on rez '+(mod.settings.onrez ? 'Enabled' : 'Disabled') + '.');
},
$default() {
command.message('Error (typo?) in command! see README for the list of valid commands');
}
});
function isEnabled() {
return mod.settings.enabled && isMystic;
}
mod.game.on('enter_game', () => {
let model = mod.game.me.templateId;
let job = (model - 10101) % 100;
isMystic = (job == 7);
if(isEnabled()) {
command.message('enabling auto-auras')
}
});
async function auras() {
//command.message('activating auras (if necessary)');
//crit aura
if(hasNoAbn([700600,700601,700602,700603])) {
command.message('activating crit aura');
startSkill(130400);
await wait(1000);
}
//mana aura
if(hasNoAbn([700330,700300])) {
command.message('activating mana aura');
startSkill(160100);
await wait(1000);
}
}
function startSkill(skillId) { //not all skill types supported
mod.toServer('C_START_SKILL', 7, {
skill: { reserved: 0, npc: false, type: 1, huntingZoneId: 0, id: skillId },
w: wloc,
loc: loc,
dest: {x: 0, y: 0, z: 0},
unk: true,
moving: false,
continue: false,
target: 0n,
unk2: false
});
}
function hasNoAbn(ids) {
return ids.reduce((accumulator, currentId) => accumulator && !hasAbn(currentId),true);
}
function hasAbn(id) {
return ('added' in AbnManager.get(mod.game.me.gameId, id));
}
mod.hook('S_SPAWN_ME', 3, (event) => {
if (mod.game.me.gameId == event.gameId) {
loc = event.loc;
wloc = event.w;
if(isEnabled()) {
mod.setTimeout(auras, 2000);
}
}
});
mod.hook('C_PLAYER_LOCATION', 5, (event) => {
loc = event.loc;
wloc = event.w;
});
//reactive after rez
mod.hook('S_CREATURE_LIFE', 3, (event)=>{
if(isEnabled() && mod.settings.onrez)
{
if (event.gameId !== mod.game.me.gameId) return;
loc = event.loc
if(!event.alive)
{
isDead = true;
}
else
{
if(isDead) {
isDead = false;
mod.setTimeout(auras, 3000);
}
}
}
});
}