-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDynesKillTracker.xml
310 lines (275 loc) · 8.27 KB
/
DynesKillTracker.xml
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on torsdag, februari 11, 2021, 7:40 -->
<!-- MuClient version 5.06 -->
<!-- Plugin "DynesKillTracker" generated by Plugin Wizard -->
<muclient>
<plugin
name="DynesKillTracker"
author="Dyne"
id="5acdf51053649069b5a2f9a7"
language="JScript"
purpose="To track and present your kills!"
save_state="y"
date_written="2021-02-11 07:39:03"
requires="5.06"
version="1.0"
>
</plugin>
<!-- Triggers -->
<triggers>
<trigger
custom_colour="0"
enabled="y"
match="You kill *"
name="killTrigger"
script="addKill"
sequence="100"
variable="killTrigger"
>
</trigger>
</triggers>
<!-- Aliases -->
<aliases>
<alias
name="killHelp"
script="trackHelp"
match="killtrackhelp"
enabled="y"
sequence="100"
>
</alias>
<alias
name="killAlias"
script="showKills"
match="killtrack"
enabled="y"
sequence="100"
>
</alias>
<alias
name="killShow"
script="trackShow"
match="killtrackshow"
enabled="y"
sequence="100"
>
</alias>
<alias
name="killLookup"
script="trackLookup"
match="killtrack *"
enabled="y"
sequence="100"
>
</alias>
<alias
name="killToggle"
script="trackToggle"
match="killtracktoggle"
enabled="y"
sequence="100"
>
</alias>
</aliases>
<!-- Script -->
<script>
<![CDATA[
//#####################################\\
//### Dyne's JS MUSHClient Plugin ###\\
//### for ###\\
//### Tracking Your Kills ###\\
//### for ###\\
//### Absolutely no good reason ###\\
//#####################################\\
// Check if variable "killShow" exists
if (world.getVariable("killShow" == null)) {
world.SetVariable("killShow", true);
}
// Check if variable "killList" exists
if (world.getVariable("killList" == null)) {
// Variable doesn't exist, create variable "killList"
//world.Note("Initializing Dyne's totally necessary kill list variable..."); // <-- Debugging
world.SetVariable("killList", "");
var killList = {};
} else {
// Variable exists
var killList = parseTextToObject(world.getVariable("killList"));
//world.Note("Dyne's totally necessary kill list already in place!"); // <-- Debugging
}
//for (x in killList) { // <-- Debugging
// world.Note(x + ": " + killList[x]);
//}
// ### Functions that run when triggering triggers ###
function addKill() {
// This function is used when "killTrigger" is triggered
var totalLines = world.GetLinesInBufferCount(); // <-- Get how many lines
var matchText = GetLineInfo(totalLines, 1); // <-- Store the last line
// world.Note(matchText); // <-- Debugging
matchText = matchText.replace("You kill ", ""); // <-- Replace text
matchText = matchText.replace(".", ""); // <-- Replace more text
if (matchText.substr(0,4) == "the ") {
matchText = matchText.replace("the ", "");
}
// world.Note(matchText); //<-- Entry to add (debugging)
if (!(killList[matchText])) {
// world.Note("Attempting to set object...") // <-- Debugging
killList[matchText] = 1;
//world.Note(killList[matchText] + " is new value!");
if (!(killList[matchText])) {
world.Note("Could not set object!")
}
} else {
// world.Note("Object found, adding one to total...") // <-- Debugging
killList[matchText] += 1;
}
//for (var entry in killList) { // <-- Debugging
// world.Note(entry + ": " + killList[entry]);
//}
if (world.GetVariable("killShow") != 0) {
afterKillShow(matchText);
}
world.SetVariable("killList", objectToString(killList));
return
}
function afterKillShow(killedThing) {
// Shows killtext after player kills something
// world.Note("0. " + killedThing);
if (killedThing.substr(0,1) != killedThing.substr(0,1).toUpperCase()) {
// world.Note("1. It's not a named NPC!");
var vowelsFromHell = "aieou";
killedThing = killedThing.split(" ");
var nameLength = killedThing.length;
killedThing = killedThing[parseInt(nameLength) - 1];
var killedText = "You have killed ";
if (vowelsFromHell.match(killedThing.substr(0,1).toLowerCase())) {
killedText += "an ";
} else {
killedText += "a ";
}
} else {
var killedText = "You have killed ";
}
killedText += killedThing + " ";
// world.Note("2. " + killedText);
var lookupCount = 0;
for (var entry in killList) {
if (entry.toLowerCase().match(killedThing.toLowerCase())) {
// world.Note("3. " + entry);
lookupCount += killList[entry];
}
}
killedText += lookupCount;
if (lookupCount > 1) {
killedText += " times!";
} else {
killedText += " time!";
}
world.Note(killedText);
}
// ### Functions that run from aliases ###
function showKills() {
// Shows a list of the kills you have accumulated so far!
world.Note("Your kill list (Entity: Number of kills):")
var totalKillCount = 0;
for (entry in killList) {
if (entry == "Entity") { // <-- Just in case, we don't want the Entity-value
continue
}
world.Note(entry + ":\t" + killList[entry] + " times!");
totalKillCount += killList[entry];
}
world.Note("You have left " + totalKillCount + " deaths in your wake (so far)!")
return
}
function trackToggle() {
// Toggles "killTrigger" on/off
if (GetTriggerOption("killTrigger", "enabled")) {
world.Note("Killtracking off!");
EnableTrigger("killTrigger", false);
} else {
world.Note("Killtracking on!");
EnableTrigger("killTrigger", true);
}
return
}
function trackLookup(name, line, wildcards) {
// Function to lookup kills in the list, takes one argument
// world.Note("Alias " + name + " was triggered!"); // <-- Debugging
var lookup = line.replace("killtrack ", "");
var lookupText = "The following creatures match your query:";
var lookupCount = 0;
for (var entry in killList) {
if (entry.toLowerCase().match(lookup.toLowerCase())) {
lookupText += "\n" + entry + ": killed " + killList[entry] + " times!";
lookupCount += killList[entry];
}
}
lookupText += "\nTotal kills: " + lookupCount;
//if (killList[lookup]) {
// world.Note(lookup + ": " + killList[lookup] + " kills!");
//} else {
// world.Note(lookup + " has not been killed by you... Yet!");
//}
world.Note(lookupText);
return
}
function trackHelp() {
// Function to list commands and their uses
var helpText = "Commands for Dyne's Killtracker:\n";
helpText += "killtrack:\t\t\tLists all kills! Ex: killtrack\n";
helpText += "killtracktoggle:\t\tToggle trigger on/off. Ex: killtracktoggle\n";
helpText += "killtracklookup <creature>:\tLookup specific kills. Ex: killtracklookup Cohen\n";
helpText += "killtrackshow:\t\t\tToggle kill messages off/on. Ex: killtrackshow\n";
world.Note(helpText);
return
}
function trackShow() {
// Function to toggle messages after each kill on/off
if (world.GetVariable("killShow") == -1) {
world.Note("Fine! Guess I won't show kill messages then!")
world.SetVariable("killShow", false);
} else {
world.Note("Yeah, let's count the kills together!")
world.SetVariable("killShow", true);
}
return
}
// ### General functions ###
function parseTextToObject(text) {
// Parses a text to object, delimiters in order: "\n" and ";"
if (!(text)) {
text = "Entity;Kills";
}
var splitArray = text.split("\n");
var object = {};
for (var i=0;i<splitArray.length;i++) {
//world.Note(splitArray[i].split(";")[0] + ": " + parseInt(splitArray[i].split(";")[1])); // <-- Debugging
if (splitArray[i].split(";")[0] == "Entity") {
continue
}
object[splitArray[i].split(";")[0]] = parseInt(splitArray[i].split(";")[1]);
}
//for (x in object) // <-- Debugging
// world.Note(x + ": " + object[x]);
//}
//world.Note("Object created!")
return object
}
function objectToString(object) {
// Converts the object to our multiline-string that can be stored
var string = "Entity;Killed" // <-- Debugging
// Go through each key/value pair in object and put in string variable...
for (key in object) {
if (key == "Entity") { // <-- If key is Entity, we want to skip that...
continue
} else {
string += "\n" + key + ";" + object[key]; // <-- Add new line, then "key;value"
}
}
// world.Note(string); // <-- Debugging
return string
}
]]>
</script>
</muclient>