forked from emmjayh/Gathering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
164 lines (146 loc) · 4.79 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
module.exports = function Gathering(mod) {
let mobid = [],
gatherMarker = []
function gatheringStatus() {
sendStatus(
"Gathering: "+ (mod.settings.enabled ? "On" : "Off"),
"SendAlert: " + (mod.settings.sendToAlert ? "Enable" : "Disable"),
"plants: " + (mod.settings.plants ? "Show" : "Hide"),
"ore: " + (mod.settings.ore ? "Show" : "Hide"),
"energy: " + (mod.settings.energy ? "Show" : "Hide"),
"grass: " + (mod.settings.grass ? "Show" : "Hide"),
"stone: " + (mod.settings.stone ? "Show" : "Hide"),
"achromic: " + (mod.settings.achromic ? "Show" : "Hide"),
)
}
function sendStatus(msg) {
sendMessage([...arguments].join('\n\t - '))
}
mod.command.add("gathering", (arg) => {
if (!arg) {
mod.settings.enabled = !mod.settings.enabled
if (!mod.settings.enabled) {
for (let itemId of mobid) {
despawnItem(itemId)
}
}
sendMessage("Gathering: "+ (mod.settings.enabled ? "On" : "Off"))
} else {
switch (arg) {
case "alert":
mod.settings.sendToAlert = !mod.settings.sendToAlert
sendMessage("SendAlert" + (mod.settings.sendToAlert ? "Enable" : "Disable"))
break
case "status":
gatheringStatus()
break
case "all":
mod.settings.plants = true
mod.settings.ore = true
mod.settings.energy = true
mod.settings.grass = true
mod.settings.stone = true
mod.settings.achromic = true
gatheringStatus()
break
case "none":
mod.settings.plants = false
mod.settings.ore = false
mod.settings.energy = false
mod.settings.grass = false
mod.settings.stone = false
mod.settings.achromic = false
gatheringStatus()
break
case "plants":
mod.settings.plants = !mod.settings.plants
sendMessage("plant " + (mod.settings.plants ? "Show" : "Hide"))
break
case "ore":
mod.settings.ore = !mod.settings.ore
sendMessage("ore " + (mod.settings.ore ? "Show" : "Hide"))
break
case "energy":
mod.settings.energy = !mod.settings.energy
sendMessage("energy " + (mod.settings.energy ? "Show" : "Hide"))
break
case "grass":
mod.settings.grass = !mod.settings.grass
sendMessage("grass " + (mod.settings.grass ? "Show" : "Hide"))
break
case "stone":
mod.settings.stone = !mod.settings.stone
sendMessage("Plain stone " + (mod.settings.stone ? "Show" : "Hide"))
break
case "achromic":
mod.settings.achromic = !mod.settings.achromic
sendMessage("Achromic Essence " + (mod.settings.achromic ? "Show" : "Hide"))
break
default :
sendMessage("invalid prompt!")
break
}
}
})
mod.game.me.on('change_zone', (zone, quick) => {
mobid = []
})
mod.hook('S_SPAWN_COLLECTION', 4, (event) => {
if (mod.settings.enabled) {
if (mod.settings.plants && (gatherMarker = mod.settings.Plants.find(obj => obj.id === event.id))) {
sendAlert( ("Found [" + gatherMarker.name + "] " + gatherMarker.msg), 44)
sendMessage("Found [" + gatherMarker.name + "] " + gatherMarker.msg)
} else if (mod.settings.ore && (gatherMarker = mod.settings.Ore.find(obj => obj.id === event.id))) {
sendAlert( ("Found [" + gatherMarker.name + "] " + gatherMarker.msg), 44)
sendMessage("Found [" + gatherMarker.name + "] " + gatherMarker.msg)
} else if (mod.settings.energy && (gatherMarker = mod.settings.Energy.find(obj => obj.id === event.id))) {
sendAlert( ("Found [" + gatherMarker.name + "] " + gatherMarker.msg), 44)
sendMessage("Found [" + gatherMarker.name + "] " + gatherMarker.msg)
} else if (mod.settings.grass && event.id == 1) {
sendAlert( ("Found [Harmony Grass] "), 44)
sendMessage("Found [Harmony Grass] ")
} else if (mod.settings.stone && event.id == 101) {
sendAlert( ("Found [Plain Stone] "), 44)
sendMessage("Found [Plain Stone] ")
} else if (mod.settings.achromic && event.id == 201) {
sendAlert( ("Found [Achromic Essence] "), 44)
sendMessage("Found [Achromic Essence] ")
} else {
return true
}
spawnItem(event.gameId, event.loc)
mobid.push(event.gameId)
}
})
mod.hook('S_DESPAWN_COLLECTION', 2, (event) => {
if (mobid.includes(event.gameId)) {
gatherMarker = []
despawnItem(event.gameId)
mobid.splice(mobid.indexOf(event.gameId), 1)
}
})
function spawnItem(gameId, loc) {
mod.send('S_SPAWN_DROPITEM', 8, {
gameId: gameId*10n,
loc: loc,
item: mod.settings.markerId,
amount: 1,
expiry: 999999,
owners: [{}]
})
}
function despawnItem(gameId) {
mod.send('S_DESPAWN_DROPITEM', 4, {
gameId: gameId*10n
})
}
function sendMessage(msg) { mod.command.message(msg) }
function sendAlert(msg, type) {
mod.send('S_DUNGEON_EVENT_MESSAGE', 2, {
type: type,
chat: false,
channel: 0,
message: msg,
})
}
}