-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrinfomon.lic
More file actions
442 lines (425 loc) · 15.4 KB
/
drinfomon.lic
File metadata and controls
442 lines (425 loc) · 15.4 KB
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
=begin
Info tracking for use in other scripts in DragonRealms.
;banks
tracks your money and converts copper strings to plat format. -not all locations tracked
;vault
tracks vault contents and location. -not all location included
-skill tracking
name/rank/xp
-info tracking
everything listed under info other than debt wealth and birthdate
-Thank you Scorius for gathering the room names.
=end
#todo --grand total split for currency
unless XMLData.game =~ /^(?:DRF|DR|DRPlat)$/
echo "This script is meant for DragonRealms Prime, Platinum, or Fallen. It will likely cause problems on whatever game you're trying to run it on..."
exit
end
if $SAFE > 0
echo "WARNING: This script may not work if not trusted and other scripts that rely on this one may not work. (;trust #{script.name.downcase})"
end
no_kill_all
no_pause_all
#hide_me
setpriority(0)
class DRStats
@@race ||= 'unknown'
@@guild ||= 'unknown'
@@gender ||= 'unknown'
@@age ||= 0
@@circle ||= 0
@@strength ||= 0
@@stamina ||= 0
@@reflex ||= 0
@@agility ||= 0
@@intelligence ||= 0
@@wisdom ||= 0
@@discipline ||= 0
@@charisma ||= 0
@@concentration ||= 0
@@favors ||= 0
@@tdps ||= 0
@@encumbrance ||= 'unknown'
def DRStats.race; @@race; end
def DRStats.race=(val); @@race=val; end
def DRStats.guild; @@guild; end
def DRStats.guild=(val); @@guild=val; end
def DRStats.gender; @@gender; end
def DRStats.gender=(val); @@gender=val; end
def DRStats.age; @@age; end
def DRStats.age=(val); @@age=val; end
def DRStats.circle; @@circle; end
def DRStats.circle=(val); @@circle=val; end
def DRStats.strength; @@strength; end
def DRStats.strength=(val); @@strength=val; end
def DRStats.stamina; @@stamina; end
def DRStats.stamina=(val); @@stamina=val; end
def DRStats.reflex; @@reflex; end
def DRStats.reflex=(val); @@reflex=val; end
def DRStats.agility; @@agility; end
def DRStats.agility=(val); @@agility=val; end
def DRStats.intelligence; @@intelligence; end
def DRStats.intelligence=(val); @@intelligence=val; end
def DRStats.wisdom; @@wisdom; end
def DRStats.wisdom=(val); @@wisdom=val; end
def DRStats.discipline; @@discipline; end
def DRStats.discipline=(val); @@discipline=val; end
def DRStats.charisma; @@charisma; end
def DRStats.charisma=(val); @@charisma=val; end
def DRStats.concentration; @@concentration; end
def DRStats.concentration=(val); @@concentration=val; end
def DRStats.favors; @@favors; end
def DRStats.favors=(val); @@favors=val; end
def DRStats.tdps; @@tdps; end
def DRStats.tdps=(val); @@tdps=val; end
def DRStats.encumbrance; @@encumbrance; end
def DRStats.encumbrance=(val); @@encumbrance=val; end
def DRStats.serialize
[@@race,@@guild,@@gender,@@age,@@circle,@@strength,@@stamina,@@reflex,@@agility,@@intelligence,@@wisdom,@@discipline,@@charisma,@@concentration,@@favors,@@tdps,@@encumbrance]
end
def DRStats.load_serialized=(array)
@@race,@@guild,@@gender,@@age = array[0..3]
@@circle,@@strength,@@stamina,@@reflex,@@agility,@@intelligence,@@wisdom,@@discipline,@@charisma,@@concentration,@@favors,@@tdps,@@encumbrance = array[5..17]
end
end
class DRSkill
@@list ||= Array.new
attr_reader :name, :rank, :exp
attr_writer :rank, :exp
def initialize (name,rank,exp)
@name = name
@rank = rank
@exp = exp
@@list.push(self) unless @@list.find { |skill| skill.name == @name }
end
def DRSkill.include?(val)
ary = @@list.collect{|x| x.name }
return ary.include?(val)
end
def DRSkill.update(name,ra,xp)
ary = @@list.collect{|x| x.name}
if i = ary.index(name)
@@list[i].rank = ra
@@list[i].exp = xp
end
end
def DRSkill.getrank(val)
ary = @@list.collect{|x| x.name}
if i = ary.index(val)
return @@list[i].rank
end
end
def DRSkill.getxp(val)
ary = @@list.collect{|x| x.name}
if i = ary.index(val)
return @@list[i].exp
end
end
def DRSkill.listall
@@list.each{|i|
puts i.name+": "+i.rank+"% ["+i.exp+"/34] --"
}
end
def DRSkill.list
@@list
end
end
def convert2copper (amt, denomination)
if denomination =~ /platinum/
return (amt.to_i * 10000)
elsif denomination =~ /gold/
return (amt.to_i * 1000)
elsif denomination =~ /silver/
return (amt.to_i * 100)
elsif denomination =~ /bronze/
return (amt.to_i * 10)
else
return amt
end
end
def convert2plats (copper)
coins = copper.to_s.reverse
coins = coins.scan(/(?:\d*\.)?\d{1,4}-?/) #if it has plats move them to their own index
if coins[1]
coins[1] = coins[1].reverse+" platinum"
end
coins[0] = coins[0].scan(/\d/)
if coins[0][3]
coins[0][3] = coins[0][3] + " gold"
end
if coins[0][2]
coins[0][2] = coins[0][2] + " silver"
end
if coins[0][1]
coins[0][1] = coins[0][1] + " bronze"
end
coins[0][0] = coins[0][0] + " copper"
coins[0].delete_if {|x| x =~/0/ }
coins[0].reverse!
coins[0].flatten!
coins.reverse!
coins = coins.join(', ')
return coins
end
sleep(0.1) until Char.name and not Char.name.empty?
CharSettings['bank_accounts'] = Hash.new unless CharSettings['bank_accounts'].class == Hash
CharSettings['vault_info'] = Hash.new unless CharSettings['vault_info'].class == Hash
kronar_banks=["Crossings","Dirge","Leth Deriel","Ilaya Taipa"]
lirum_banks=["Aesry Surlaenis'a","Hara'jaal","Mer'Kresh","Muspar'i","Ratha","Riverhaven","Rossman's Landing","Therenborough","Throne City"]
dokora_banks=["Ain Ghazal","Boar Clan","Chyolvea Tayeu'a","Hibarnhvidar","Shard"]
bank_titles = {
"Aesry Surlaenis'a" => ["[[Tona Kertigen, Deposit Window]]"],
"Ain Ghazal" => ["Unknown Description"],
"Boar Clan" => ["Unknown Description"],
"Chyolvea Tayeu'a" => ["[[Chyolvea Tayeu'a, Teller]]"],
"Crossings" => ["[[Provincial Bank, Teller]]"],
"Dirge" => ["Unknown Description"],
"Hara'jaal" => ["Unknown Description"],
"Hibarnhvidar" => ["[[Second Provincial Bank of Hibarnhvidar, Teller]]"],
"Ilaya Taipa" => ["Unknown Description"],
"Leth Deriel" => ["[[Imperial Depository, Domestic Branch]]"],
"Mer'Kresh" => ["Unknown Description"],
"Muspar'i" => ["Unknown Description"],
"Ratha" => ["[[Lower Bank of Ratha, Cashier]]", "[[Sshoi-sson Palace, Grand Provincial Bank, Bursarium]]"],
"Riverhaven" => ["[[Bank of Riverhaven, Teller]]"],
"Rossman's Landing" => ["Unknown Description"],
"Shard" => ["[[First Bank of Ilithi, Teller's Windows]]"],
"Therenborough" => ["[[Bank of Therenborough, Teller]]"],
"Throne City" => ["[[Faldesu Exchequer, Teller]]"],
}
vault_titles = {
"Crossings" => ["[[Crossing, Carousel Chamber]]"],
"Leth Deriel" => ["[[Leth Deriel, Carousel Chamber]]"],
"Muspar'i" => ["[[Muspar'i, Carousel Square]]"],
"Ratha" => ["[[Ratha, Carousel Square]]"],
"Riverhaven" => ["[[Riverhaven, Carousel Chamber]]"],
"Shard" => ["[[Shard, Carousel Square]]"],
"Mer'Kresh" => ["[[Mer'Kresh, Carousel Square]]"],
"Therenborough" => ["[[Therenborough, Carousel Square]]"],
}
#
# Register ;banks ;vault commands
action = proc { |client_string|
if client_string =~ /^(?:<c>)?#{$lich_char}((?:banks|vault).*)/i
if scr = (Script.running).find { |val| val.name == 'drinfomon' }
scr.downstream_buffer.shove("#{$clean_lich_char}#{$1}") #if this script is still running send the command
else
UpstreamHook.remove('drinfomon') #if the script isnt running remove the hook
end
nil #its a command that shouldnt be sent to the game
else
client_string #didnt find a command we should watch for send the string as normal
end
}
UpstreamHook.remove('drinfomon')
UpstreamHook.add('drinfomon', action)
#End Register commands
xp_pools = ["clear","dabbling","perusing","learning","thoughtful","thinking","considering","pondering","ruminating",
"concentrating","attentive","deliberative","interested","examining","understanding","absorbing","intrigued",
"scrutinizing","analyzing","studious","focused","very focused","engaged","very engaged","cogitating","fascinated",
"captivated","engrossed","riveted","very riveted","rapt","very rapt","enthralled","nearly locked","mind lock" ]
xpaction = proc { |server_string|
if server_string =~ /\<d cmd..skill (.*)\'.*:\s+(.*)\s\d+%\s*\[\s?(\d+)\/34\]\</
skill = $1; rank = $2; xp = $3;
if DRSkill.include?(skill)
DRSkill.update(skill,rank,xp)
else
DRSkill.new(skill,rank,xp)
end
elsif server_string =~ /><preset id='whisper'>\s+(.*):\s+(\d+) \d+% (.*)<\/preset>/
skill = $1; rank = $2; xp = $3.strip;
if DRSkill.include?(skill)
DRSkill.update(skill,rank,xp_pools.index(xp))
else
DRSkill.new(skill,rank,xp_pools.index(xp))
end
elsif server_string =~ /<component id='exp .*'>\s+(.*):\s+(\d+) \d+% (.*)<\/component>/
skill = $1; rank = $2; xp = $3.strip;
if DRSkill.include?(skill)
DRSkill.update(skill,rank,xp_pools.index(xp))
else
DRSkill.new(skill,rank,xp_pools.index(xp))
end
end
server_string
}
DownstreamHook.remove('xpAction')
DownstreamHook.add('xpAction', xpaction)
save_proc = proc {
CharSettings.save
}
#
# Save current status every five minutes in case of crash
#
Thread.new {
begin
loop {
sleep 300
save_proc.call
}
rescue
echo $!
echo $!.backtrace[0..1]
end
}#end save ever 5 min
before_dying {
save_proc.call
UpstreamHook.remove('drinfomon');
DownstreamHook.remove('xpAction');
DownstreamHook.remove('coinAction');
}
while line = script.gets
begin
# Note: Ruby CASE statements are substantially slower than IF, as they're more full-featured than simple equality checking.
msgsave = $&.dup
if line =~ /^#{$lich_char}banks$/
if CharSettings['bank_accounts'].empty?
respond
respond 'No bank account info recorded.'
respond
else
respond
for town,amount in CharSettings['bank_accounts']
respond "#{town.rjust(27)}:#{amount.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse.rjust(13)}"+" or "+convert2plats(amount).to_s
end
respond ' ------------------------------------------------------------------------------------------'
total = 0
kronar_banks.each{|city|
if CharSettings['bank_accounts'][city] then total += CharSettings['bank_accounts'].fetch(city); end
}
respond " Kronar Total:#{total.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse.rjust(13)}"+" or "+convert2plats(total).to_s
total = 0
lirum_banks.each{|city|
if CharSettings['bank_accounts'][city] then total += CharSettings['bank_accounts'].fetch(city); end
}
respond " Lirum Total:#{total.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse.rjust(13)}"+" or "+convert2plats(total).to_s
total = 0
dokora_banks.each{|city|
if CharSettings['bank_accounts'][city] then total += CharSettings['bank_accounts'].fetch(city); end
}
respond " Dokora Total:#{total.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse.rjust(13)}"+" or "+convert2plats(total).to_s
end
elsif line =~ /^#{$lich_char}vault$/
if CharSettings['vault_info'].empty?
respond
respond 'No vault info recorded.'
respond
else
respond
respond " Your vault is located in #{CharSettings['vault_info']['location']}"
respond ' ---------------------------------------'
respond " #{CharSettings['vault_info']['contents']}"
respond
end
elsif line =~ /(?:In the secure vault you see|You rummage through a secure vault and see)\s(.*)\./
for town,titles in vault_titles
if titles.include?(checkroom)
contents = $1
if line =~ /a (\w+ shelf|rack|box|case|tree) with some stuff (on|in) it/
fput "look "+$2+" "+$1
if get =~ /(?:On|In) the \w+ (?:shelf|rack|box|case|tree) you see(.*)\./
contents = contents + $1
end
end
CharSettings['vault_info']['location'] = checkarea.slice(/\w+/)
CharSettings['vault_info']['contents'] = contents
end
end
elsif line =~ /^Name:\s+.+Race:\s+([-A-z\s]+)\s+Guild:\s+([-A-z\s]+)/
#info checked record stats
DRStats.race = $1.strip
DRStats.guild = $2.strip
if get =~ /Gender:\s+([A-z]+)\s+Age:\s+([0-9]+)\s+Circle:\s+([0-9]+)/
DRStats.gender = $1
DRStats.age = $2.to_i
DRStats.circle = $3.to_i
get
get
while get =~ /((?:Strength||Agility|Discipline|Intelligence|Concentration|Favors|TDPs|Encumbrance)\s:\s.*)/
#keep checking the next line until it doesnt match a stat.
line = $1 #save $1 since it'll be overwritten in the if statements
if line =~ /^\s*(Strength||Agility|Discipline|Intelligence|Concentration)\s:\s([0-9]+)\s*(Stamina|Reflex|Charisma|Wisdom)\s:\s([0-9]+)/
if $3 and $3 == "Max"
#if we see max only record current concentration.
DRStats.send("#{$1.downcase}=", $2.to_i)
else
#otherwise record both stats on the line
DRStats.send("#{$1.downcase}=", $2.to_i)
DRStats.send("#{$3.downcase}=", $4.to_i)
end
elsif line =~ /^\s*(Favors|TDPs|Encumbrance)\s:\s(.*)/
#only one stat on these lines
if $1 == "Encumbrance"
DRStats.send("#{$1.downcase}=", $2)
else
DRStats.send("#{$1.downcase}=", $2.to_i)
end
end
end
end
CharSettings['Stats'] = DRStats.serialize
elsif line =~ /The clerk slides a small metal box across the counter into which you drop (\d+) (\w+) (?:Kronars|Lirums|Dokoras)./
#you deposited a portion of your money
for town,titles in bank_titles
if titles.include?(checkroom)
copper = convert2copper($1.to_i,$2)
CharSettings['bank_accounts'][town] = CharSettings['bank_accounts'][town].to_i + copper
break
end
end
elsif line =~ /^The clerk slides a small metal box across the counter into which you drop all your (?:Kronars|Lirums|Dokoras). She counts them carefully and records the deposit in her ledger\./
#you deposited all your money
fput "balance"
elsif line =~ /^The clerk counts out ([0-9]+) (platinum|gold|silver|bronze|copper) (?:Kronars|Lirums|Dokoras) and hands them over, making a notation in her ledger\./
#you withdrew some money
for town,titles in bank_titles
if titles.include?(checkroom)
CharSettings['bank_accounts'][town] = CharSettings['bank_accounts'][town].to_i - $1.to_i
break
end
end
elsif line =~ /^The clerk counts out all your (?:Kronars|Lirums|Dokoras) and hands them over, making a notation in her ledger\./
#you withdrew all your money
for town,titles in bank_titles
if titles.include?(checkroom)
CharSettings['bank_accounts'][town] = 0
break
end
end
elsif line =~ /[it looks like|\"Here we are.]\s[y]our current balance is (.*)\s(?:Kronars|Lirums|Dokoras)\.\"/i
#you checked your balance
copper = 0
$1.each(', ') {|m|
m.to_s
a = m.match(/([0-9]+).[a-z]+/)
copper = copper + convert2copper(a.to_s.to_i,m)
}
for town,titles in bank_titles
if titles.include?(checkroom)
CharSettings['bank_accounts'][town] = copper.to_i
break
end
end
elsif line =~ /you do not seem to have an account with us/
#you have no account
for town,titles in bank_titles
if titles.include?(checkroom)
CharSettings['bank_accounts'][town] = 0
break
end
end
end
rescue Exception
echo $!
echo $!.backtrace.first
sleep 1
rescue ThreadError
echo $!
echo $!.backtrace.first
sleep 1
rescue
echo $!
echo $!.backtrace.first
sleep 1
end
end