forked from brycole/gemstone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlnet.lic
1666 lines (1605 loc) · 71.5 KB
/
lnet.lic
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
=begin
Chat client for Lich.
;lnet help
author: Tillmen ([email protected])
game: any
tags: core
required: Lich >= 4.3.12
version: 1.6
changelog:
1.6 (2016-01-10):
fixed room id lookup for ;locate command
added alias feature
1.5 (2015-11-25):
added reply command (DR:Etreu)
1.4 (2015-05-13):
move channel owners and moderators to the front of the ;who list
=end
=begin
1.3 (2015-01-21):
give a warning if the system date is outside the range of the CA cert date
disable SSLv2 and SSLv3
1.2 (2015-01-16):
new host name
1.1 (2014-10-25):
workaround to deal with the plat_updater script disabling OpenSSL::SSL::VERIFY_PEER
=end
if $SAFE > 0
echo "error: This script needs to be trusted to work. (;trust #{script.name})"
exit
end
# fixme: option to separate private messages to familiar window
# fixme: scrub
require 'openssl'
toggle_unique
clear
hide_me
class LNet
@@server ||= nil
@@script ||= nil
@@options ||= Hash.new
@@waiting ||= Array.new
@@last_recv ||= Time.now
@@last_send ||= Time.now
@@last_priv ||= nil
@@secret ||= Array.new
@@version = '1.6'
@@server_restart = false
def LNet.server; if $SAFE==0; @@server; else; nil; end; end
def LNet.server=(val); if $SAFE==0; @@server=val; else; nil; end; end
def LNet.script; if $SAFE==0; @@script; else; nil; end; end
def LNet.script=(val); if $SAFE==0; @@script=val; else; nil; end; end
def LNet.options; if $SAFE==0; @@options; else; nil; end; end
def LNet.options=(val); if $SAFE==0; @@options=val; else; nil; end; end
def LNet.alias; if $SAFE==0; @@alias; else; nil; end; end
def LNet.alias=(val); if $SAFE==0; @@alias=val; else; nil; end; end
def LNet.server_restart; if $SAFE==0; @@server_restart; else; nil; end; end
def LNet.server_restart=(val); if $SAFE==0; @@server_restart=val; else; nil; end; end
def LNet.store_secret=(val); if $SAFE==0; @@secret=val; else; nil; end; end
def LNet.secret=(val); if $SAFE==0; @@secret[0]=val; else; nil; end; end
def LNet.last_send
@@last_send
end
def LNet.last_recv
@@last_recv
end
def LNet.last_priv
@@last_priv
end
def LNet.connect
begin
hostname = 'lnet.lichproject.org'
port = 7155
ca_cert = OpenSSL::X509::Certificate.new("-----BEGIN CERTIFICATE-----\nMIIDlTCCAn2gAwIBAgIJAKuu65i5NsruMA0GCSqGSIb3DQEBCwUAMGExCzAJBgNV\nBAYTAlVTMREwDwYDVQQIDAhJbGxpbm9pczESMBAGA1UECgwJTWF0dCBMb3dlMQ8w\nDQYDVQQDDAZSb290Q0ExGjAYBgkqhkiG9w0BCQEWC21hdHRAaW80LnVzMB4XDTE0\nMDYwNzE3NDUwMFoXDTI0MDYwNDE3NDUwMFowYTELMAkGA1UEBhMCVVMxETAPBgNV\nBAgMCElsbGlub2lzMRIwEAYDVQQKDAlNYXR0IExvd2UxDzANBgNVBAMMBlJvb3RD\nQTEaMBgGCSqGSIb3DQEJARYLbWF0dEBpbzQudXMwggEiMA0GCSqGSIb3DQEBAQUA\nA4IBDwAwggEKAoIBAQCcIRn0IMCNYeL5agKmkdedgJXsIyTJS8qKrY6EvQsq4tt0\nmO3Or9K8IaDl7qFdQ9nfSJ5phNgoCy9wZ9rDWv5FhY5MnnVHGr3fCa7RkMxJFR/N\nwiD4ihQlixOUly76glceyc/6QQS9bNe96evZDstERGAFfzgHY4qAlyurR6mBu9Mb\nyyCRok6xMRnjrbTMNkvvOsuG0sY9ot+SLHGgU3qT7+wVh/CbWcjeF7/Qwa//fbFk\nmq5c1FuvhU3DanSSz+VuWudPFSyZ3r5pYrLMJWsyomDa4gkL2bJ5jya2BWDMXvSS\nCpdQgPDIlClMfAFLd/Ss8ZIGa6uNFcSK6Xca51ClAgMBAAGjUDBOMB0GA1UdDgQW\nBBScbglRiGzz9yzuhgBwFYjgimeByDAfBgNVHSMEGDAWgBScbglRiGzz9yzuhgBw\nFYjgimeByDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQA7MLZYfqam\n5aaSBqQpT6sOGDtVc9koIok59oTQmNXqe+awg2VUnAiesxtLd+FWGUMp8XzHdGWw\nH3O6kAUkPm/in001X7TRAhbgDujfTRbTzxND0XrjuEzDMALs3YpDM1pMXqC7RXWA\n7z+N0gRaUgmh1rMbk/qA3cAfC2dwf2j3NYy3bDw3lMpdyIwAfOQxiZVglYgX3dgT\nU9b//gsUyPCvlpL0mYcmhOOLt6oqQhMJaw1I6A9xMe2kO2L+8KPGK2u1B+P5/Sx0\nFE8LIp5KA3a7yRbOty19NsGR+yW7WwV7BL6c6GOKb/iKJBLYzTmNG6m16hRrxDGj\ntGu91I0ORptB\n-----END CERTIFICATE-----")
if ca_cert.not_before > Time.now
respond "\n---\n--- warning: The current date is set incorrectly on your computer. This will\n--- cause the SSL certificate verification to fail and prevent LNet\n--- from connecting to the server. Fix it.\n---\n\n"
sleep 3
end
if ca_cert.not_after < Time.now
respond "\n---\n--- warning: Your computer thinks the date is #{Time.now.strftime("%m-%d-%Y")}. If this is the\n--- correct date, you need an updated version of this script. If \n--- this is not the correct date, you need to change it. In either\n--- case, this date makes the SSL certificate in this script\n--- invalid and will prevent LNet from connecting to the server.\n---\n\n"
sleep 3
end
cert_store = OpenSSL::X509::Store.new
ssl_context = OpenSSL::SSL::SSLContext.new
ssl_context.cert_store = cert_store
ssl_context.options = (OpenSSL::SSL::OP_NO_SSLv2 + OpenSSL::SSL::OP_NO_SSLv3)
cert_store.add_cert(ca_cert)
if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE
# the plat_updater script redefines OpenSSL::SSL::VERIFY_PEER, disabling it for everyone
ssl_context.verify_mode = 1 # probably right
else
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
end
socket = TCPSocket.open(hostname, port)
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)
ssl_socket.sync_close = true
ssl_socket.connect
if (ssl_socket.peer_cert.subject.to_a.find { |n| n[0] == 'CN' }[1] != 'lichproject.org') and (ssl_socket.peer_cert.subject.to_a.find { |n| n[0] == 'CN' }[1] != 'LichNet')
echo "error: server certificate hostname mismatch"
ssl_socket.close
exit
end
LNet.server = ssl_socket
xml = REXML::Document.new
element = xml.add_element('login')
element.add_attribute('name', XMLData.name)
element.add_attribute('game', XMLData.game)
element.add_attribute('client', @@version)
element.add_attribute('lich', $version)
if @@secret[0]
element.add_attribute('password', @@secret[0])
end
@@server.puts(xml)
@@last_send = Time.now
xml = element = nil
rescue
echo $!
respond $!.backtrace[0..1]
end
end
def LNet.send_ping
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('ping')
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.send_ping."
end
end
def LNet.send_message(attributes, message)
return false if @@server.closed?
# causes errors in Ruby 1.9.2
#message.gsub!(/\x80|\x81|\x86|\x87|\x8D|\x8F|\x90|\x95|\x9C|\x9D/, '?')
#message.gsub!(/\x83/, 'f')
#message.gsub!(/\x84/, ',,')
#message.gsub!(/\x85/, '...')
#message.gsub!(/\x88/, '^')
#message.gsub!(/\x89/, '%o')
#message.gsub!(/\x8A/, 'S')
#message.gsub!(/\x8B/, '<')
#message.gsub!(/\x8C/, 'CE')
#message.gsub!(/\x8E/, 'Z')
#message.gsub!(/\x91|\x92/, "'")
#message.gsub!(/\x93|\x94/, '"')
#message.gsub!(/\x96|\x97|\x98/, '-')
#message.gsub!(/\x99/, '(tm)')
#message.gsub!(/\x9A/, 's')
#message.gsub!(/\x9B/, '>')
#message.gsub!(/\x9E/, 'z')
#message.gsub!(/\x9F/, 'Y')
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('message')
attributes.each_pair { |name,val| element.add_attribute(name, val) }
element.text = message
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.send_message."
end
end
def LNet.send_query(attributes)
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('query')
attributes.each_pair { |name,val| element.add_attribute(name, val) }
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.send_query."
end
end
def LNet.send_request(attributes)
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('request')
attributes.each_pair { |name,val| element.add_attribute(name, val) }
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.send_request."
end
end
def LNet.send_data(attributes, data)
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('data')
attributes.each_pair { |name,val| element.add_attribute(name, val) }
element.text = [Marshal.dump(data)].pack('m').strip
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.send_data."
end
end
def LNet.tune_channel(channel)
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('tune')
element.add_attribute('channel', channel)
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.tune_channel."
end
end
def LNet.untune_channel(channel)
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('untune')
element.add_attribute('channel', channel)
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.untune_channel."
end
end
def LNet.moderate(attributes)
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('moderate')
attributes.each_pair { |name,val| element.add_attribute(name, val) }
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.moderate."
end
end
def LNet.admin(attributes)
return false if @@server.closed?
if $SAFE == 0
xml = REXML::Document.new
element = xml.add_element('admin')
attributes.each_pair { |name,val| element.add_attribute(name, val) }
@@server.puts(xml)
@@last_send = Time.now
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.admin."
end
end
def LNet.echo_thought(from, message, channel)
if $SAFE == 0
aliased_from = (LNet.alias[from] || from)
channel = "[#{channel}]-" unless from == '[server]'
if @@options['timestamps']
timestamp = " (#{Time.now.strftime('%X')})"
else
timestamp = String.new
end
if @@options['fam_window']
xml_thought = "<pushStream id=\"familiar\" ifClosedStyle=\"watching\"/>#{channel}#{aliased_from}: \"#{message.gsub('&', '&').gsub('<', '<').gsub('>', '>')}\"#{timestamp}\n<popStream/>\n"
else
# xml_thought = "<stream id=\"thoughts\">#{channel}#{aliased_from}: \"#{message.gsub('&', '&').gsub('<', '<').gsub('>', '>')}\"#{timestamp}</stream>\n"
xml_thought = "<pushStream id=\"thoughts\"/>#{channel}#{aliased_from}: \"#{message.gsub('&', '&').gsub('<', '<').gsub('>', '>')}\"#{timestamp}\n<popStream/>\n"
end
unless LNet.ignored?(from)
if $frontend =~ /wizard|avalon/
if @@options['fam_window']
$_CLIENT_.puts("\034GSe\r\n#{channel}#{aliased_from}: \"#{message}\"#{timestamp}\r\n\034GSf\r\n")
else
$_CLIENT_.puts("You hear the faint thoughts of #{channel}#{aliased_from} echo in your mind:\n\"#{message}\"#{timestamp}\r\n")
end
Script.new_downstream("#{channel}#{aliased_from}: \"#{message}\"#{timestamp}")
else
if defined?(_respond)
_respond(xml_thought)
else
$_CLIENT_.puts(xml_thought)
end
end
end
$_SERVERBUFFER_.push(xml_thought)
Script.new_downstream_xml(xml_thought)
Script.new_downstream("#{channel}#{aliased_from}: \"#{message}\"#{timestamp}")
else
respond "--- Lich: Untrusted script (#{Script.self.name}) called LNet.echo_thought."
end
end
def LNet.allow?(action, name)
if @@options['permission'][action] == 'all'
true
elsif @@options['permission'][action] == 'friends'
if LNet.friend?(name)
true
else
false
end
elsif @@options['permission'][action] == 'enemies'
if LNet.enemy?(name)
false
else
true
end
else
false
end
end
def LNet.ignored?(name)
@@options['ignore'].include?(name) or @@options['ignore'].include?(name.slice(/[A-Z][a-z]+$/))
end
def LNet.friend?(name)
@@options['friends'].include?(name) or @@options['friends'].include?(name.slice(/[A-Z][a-z]+$/))
end
def LNet.enemy?(name)
@@options['enemies'].include?(name) or @@options['enemies'].include?(name.slice(/[A-Z][a-z]+$/))
end
def LNet.get_data(name, type)
if $SAFE == 0
return false if (name.class != String) or name.empty? or (type.class != String) or type.empty? or @@server.closed?
name.capitalize!
waiter = { 'type'=>type, 'name'=>name, 'data'=>:waiting }
@@waiting.push(waiter)
begin
LNet.send_request(attr={'type'=>type, 'to'=>name})
80.times { sleep 0.1; break unless waiter['data'] == :waiting }
ensure
@@waiting.delete(waiter)
end
if waiter['data'] == :waiting
false
else
waiter['data']
end
else
UNTRUSTED_LNET_GET_DATA.call(name, type)
end
end
def LNet.upload_spell_ranks
if $SAFE == 0
begin
return false if @@server.closed?
data = {
'minorspiritual' => Spells.minorspiritual,
'majorspiritual' => Spells.majorspiritual,
'cleric' => Spells.cleric,
'minorelemental' => Spells.minorelemental,
'majorelemental' => Spells.majorelemental,
'ranger' => Spells.ranger,
'sorcerer' => Spells.sorcerer,
'wizard' => Spells.wizard,
'bard' => Spells.bard,
'empath' => Spells.empath,
'paladin' => Spells.paladin,
'arcanesymbols' => Skills.arcanesymbols,
'magicitemuse' => Skills.magicitemuse,
}
begin
data['minormental'] = Spells.minormental
rescue
nil
end
LNet.send_data(attr={'type'=>'spell-ranks'}, data)
return true
rescue
return false
end
else
UNTRUSTED_LNET_UPLOAD_SPELL_RANKS.call
end
end
def initialize
@active_tags = Array.new
@active_attributes = Array.new
end
def tag_start(tag_name, attributes)
begin
@@last_recv = Time.now
@active_tags.push(tag_name)
@active_attributes.push(attributes)
if tag_name == 'ping'
xml = REXML::Document.new
xml.add_element('pong')
@@server.puts(xml)
@@last_send = Time.now
elsif (tag_name == 'request') and (type = attributes['type']) and (name = attributes['from'])
if LNet.ignored?(name)
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
elsif type == 'spells'
if LNet.allow?('spells', name)
echo "sending spell info to #{name}..."
active_spells = Hash.new
Spell.active.each { |spell| active_spells[spell.num.to_s] = spell.timeleft }
LNet.send_data(attr={'type'=>type, 'to'=>name}, active_spells)
else
echo "rejecting request from #{name} for spell info..."
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
end
elsif type == 'skills'
if LNet.allow?('skills', name)
echo "sending skills to #{name}..."
skills = Hash.new
skills['Two Weapon Combat'] = Skills.twoweaponcombat if Skills.twoweaponcombat > 0
skills['Armor Use'] = Skills.armoruse if Skills.armoruse > 0
skills['Shield Use'] = Skills.shielduse if Skills.shielduse > 0
skills['Combat Maneuvers'] = Skills.combatmaneuvers if Skills.combatmaneuvers > 0
skills['Edged Weapons'] = Skills.edgedweapons if Skills.edgedweapons > 0
skills['Blunt Weapons'] = Skills.bluntweapons if Skills.bluntweapons > 0
skills['Two-Handed Weapons'] = Skills.twohandedweapons if Skills.twohandedweapons > 0
skills['Ranged Weapons'] = Skills.rangedweapons if Skills.rangedweapons > 0
skills['Thrown Weapons'] = Skills.thrownweapons if Skills.thrownweapons > 0
skills['Polearm Weapons'] = Skills.polearmweapons if Skills.polearmweapons > 0
skills['Brawling'] = Skills.brawling if Skills.brawling > 0
skills['Ambush'] = Skills.ambush if Skills.ambush > 0
skills['Multi Opponent Combat'] = Skills.multiopponentcombat if Skills.multiopponentcombat > 0
skills['Combat Leadership'] = Skills.combatleadership if Skills.combatleadership > 0
skills['Physical Fitness'] = Skills.physicalfitness if Skills.physicalfitness > 0
skills['Dodging'] = Skills.dodging if Skills.dodging > 0
skills['Arcane Symbols'] = Skills.arcanesymbols if Skills.arcanesymbols > 0
skills['Magic Item Use'] = Skills.magicitemuse if Skills.magicitemuse > 0
skills['Spell Aiming'] = Skills.spellaiming if Skills.spellaiming > 0
skills['Harness Power'] = Skills.harnesspower if Skills.harnesspower > 0
skills['Elemental Mana Control'] = Skills.emc if Skills.emc > 0
skills['Mental Mana Control'] = Skills.mmc if Skills.mmc > 0
skills['Spirit Mana Control'] = Skills.smc if Skills.smc > 0
skills['Elemental Lore - Air'] = Skills.elair if Skills.elair > 0
skills['Elemental Lore - Earth'] = Skills.elearth if Skills.elearth > 0
skills['Elemental Lore - Fire'] = Skills.elfire if Skills.elfire > 0
skills['Elemental Lore - Water'] = Skills.elwater if Skills.elwater > 0
skills['Spiritual Lore - Blessings'] = Skills.slblessings if Skills.slblessings > 0
skills['Spiritual Lore - Religion'] = Skills.slreligion if Skills.slreligion > 0
skills['Spiritual Lore - Summoning'] = Skills.slsummoning if Skills.slsummoning > 0
skills['Sorcerous Lore - Demonology'] = Skills.sldemonology if Skills.sldemonology > 0
skills['Sorcerous Lore - Necromancy'] = Skills.slnecromancy if Skills.slnecromancy > 0
skills['Mental Lore - Divination'] = Skills.mldivination if Skills.mldivination > 0
skills['Mental Lore - Manipulation'] = Skills.mlmanipulation if Skills.mlmanipulation > 0
skills['Mental Lore - Telepathy'] = Skills.mltelepathy if Skills.mltelepathy > 0
skills['Mental Lore - Transference'] = Skills.mltransference if Skills.mltransference > 0
skills['Mental Lore - Transformation'] = Skills.mltransformation if Skills.mltransformation > 0
skills['Survival'] = Skills.survival if Skills.survival > 0
skills['Disarming Traps'] = Skills.disarmingtraps if Skills.disarmingtraps > 0
skills['Picking Locks'] = Skills.pickinglocks if Skills.pickinglocks > 0
skills['Stalking and Hiding'] = Skills.stalkingandhiding if Skills.stalkingandhiding > 0
skills['Perception'] = Skills.perception if Skills.perception > 0
skills['Climbing'] = Skills.climbing if Skills.climbing > 0
skills['Swimming'] = Skills.swimming if Skills.swimming > 0
skills['First Aid'] = Skills.firstaid if Skills.firstaid > 0
skills['Trading'] = Skills.trading if Skills.trading > 0
skills['Pickpocketing'] = Skills.pickpocketing if Skills.pickpocketing > 0
skills['Major Elemental'] = Spells.majorelemental if Spells.majorelemental > 0
skills['Minor Elemental'] = Spells.minorelemental if Spells.minorelemental > 0
begin
skills['Minor Mental'] = Spells.minormental if Spells.minormental > 0
rescue
nil
end
skills['Major Spirit'] = Spells.majorspiritual if Spells.majorspiritual > 0
skills['Minor Spirit'] = Spells.minorspiritual if Spells.minorspiritual > 0
skills['Wizard'] = Spells.wizard if Spells.wizard > 0
skills['Sorcerer'] = Spells.sorcerer if Spells.sorcerer > 0
skills['Ranger'] = Spells.ranger if Spells.ranger > 0
skills['Paladin'] = Spells.paladin if Spells.paladin > 0
skills['Empath'] = Spells.empath if Spells.empath > 0
skills['Cleric'] = Spells.cleric if Spells.cleric > 0
skills['Bard'] = Spells.bard if Spells.bard > 0
LNet.send_data(attr={'type'=>type, 'to'=>name}, skills)
else
echo "rejecting request from #{name} for skills..."
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
end
elsif type == 'info'
if LNet.allow?('info', name)
echo "sending stats to #{name}..."
info = {
'Race' => Stats.race,
'Profession' => Stats.prof,
'Gender' => Stats.gender,
'Age' => Stats.age,
'Expr' => Stats.exp,
'Level' => XMLData.level,
'Strength' => Stats.str,
'Constitution' => Stats.con,
'Dexterity' => Stats.dex,
'Agility' => Stats.agi,
'Discipline' => Stats.dis,
'Aura' => Stats.aur,
'Logic' => Stats.log,
'Intuition' => Stats.int,
'Wisdom' => Stats.wis,
'Influence' => Stats.inf,
'Mana' => mana,
}
LNet.send_data(attr={'type'=>type, 'to'=>name}, info)
else
echo "rejecting request from #{name} for stats..."
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
end
elsif type == 'locate'
if LNet.allow?('locate', name)
echo "sending location to #{name}..."
room = {
'title' => XMLData.room_title,
'description' => XMLData.room_description,
'exits' => XMLData.room_exits_string,
'loot' => GameObj.loot.collect { |loot| loot.name },
}
room['pcs'] = Array.new
GameObj.pcs.each { |pc| room['pcs'].push(hash={'name'=>pc.name, 'status'=>pc.status}) }
unless hidden? or invisible?
status = Array.new
status.push 'dead' if dead?
status.push 'webbed' if webbed?
status.push 'stunned' if stunned?
if kneeling?
status.push 'kneeling'
elsif sitting?
status.push 'sitting'
elsif !standing?
if GameObj.pcs.any? { |pc| pc.status =~ /prone/ } or GameObj.pcs.any? { |pc| pc.status =~ /prone/ }
status.push 'prone'
else
status.push 'lying down'
end
end
if status.empty?
room['pcs'].push(h={'name'=>Char.name, 'status'=>nil})
else
room['pcs'].push(h={'name'=>Char.name, 'status'=>status.join(' ')})
end
end
room['npcs'] = Array.new
GameObj.npcs.each { |npc| room['npcs'].push(hash={'name'=>npc.name, 'status'=>npc.status}) }
LNet.send_data(attr={'type'=>type, 'to'=>name}, room)
else
echo "rejecting request from #{name} for location..."
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
end
elsif type == 'health'
if LNet.allow?('health', name)
echo "sending health to #{name}..."
health = {
'injuries' => XMLData.injuries,
'health' => XMLData.health,
'max_health' => XMLData.max_health,
'spirit' => XMLData.spirit,
'max_spirit' => XMLData.max_spirit,
'stamina' => XMLData.stamina,
'max_stamina' => XMLData.max_stamina,
}
LNet.send_data(attr={'type'=>type, 'to'=>name}, health)
else
echo "rejecting request from #{name} for health info..."
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
end
elsif type == 'bounty'
if LNet.allow?('bounty', name)
LNet.send_data(attr={'type'=>type, 'to'=>name}, bounty?)
else
echo "rejecting request from #{name} for bounty info..."
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
end
else
echo "rejecting unknown request (#{type}) from #{name}..."
LNet.send_data(attr={'type'=>type, 'to'=>name}, nil)
end
elsif (tag_name == 'notify')
if (attributes['type'] == 'new-spell-ranks') and defined?(SpellRanks)
LNet.send_request(attr={'type'=>'spell-ranks', 'to'=>'server', 'timestamp'=>SpellRanks.timestamp.to_s})
elsif attributes['type'] == 'server-restart'
@@server_restart = true
@@server.close rescue()
end
end
rescue
echo $!
respond $!.backtrace[0..1]
end
end
def text(text)
begin
if @active_tags.last == 'message'
if @active_attributes.last['type'] == 'greeting'
respond text if @@options['greeting']
elsif @active_attributes.last['type'] == 'server'
if text =~ /(?!kill).*(?:incorrect password|password required)/
output = "\n"
output.concat "If you have forgotten your password, visit https://lnet.lichproject.org to reset it."
output.concat "\n"
output.concat "To attempt to log in with a different password, type: #{$clean_lich_char}#{@@script.name} password=<password>\n"
output.concat "\n"
respond output
Script.self.kill
end
LNet.echo_thought('[server]', text, '')
elsif (@active_attributes.last['type'] == 'private') and (from = @active_attributes.last['from'])
@@last_priv = from
LNet.echo_thought(from, text, 'Private')
elsif (@active_attributes.last['type'] == 'privateto') and (to = @active_attributes.last['to'])
LNet.echo_thought(to, text, 'PrivateTo')
elsif (@active_attributes.last['type'] == 'channel') and (from = @active_attributes.last['from']) and (channel = @active_attributes.last['channel'])
LNet.echo_thought(from, text, channel)
end
elsif (@active_tags.last == 'data')
begin
data = Marshal.load(text.unpack('m').first)
rescue
return
end
if @active_attributes.last['from'] and @active_attributes.last['type'] and (waiter = @@waiting.find { |w| (@active_attributes.last['from'] =~ /^#{Regexp.escape(w['name'])}/i) and (w['type'] == @active_attributes.last['type']) and w['data'] == :waiting })
waiter['data'] = data
elsif (@active_attributes.last['type'] == 'connected') and (@active_attributes.last['from'] == 'server')
output = String.new
sort_by_game = Hash.new
for name in data
if name =~ /^(.+)\:(.+)$/
sort_by_game[$1] ||= Array.new
sort_by_game[$1].push($2)
else
sort_by_game['unknown'] ||= Array.new
sort_by_game['unknown'].push(name)
end
end
who_columns = 5
sort_by_game.each_pair { |game,name_list|
name_list = name_list.sort { |a,b| if (a =~ /\^$/) or (a =~ /\*$/ and b !~ /\^$/); 1; else; 0; end }
output.concat "\n#{game} (#{name_list.length}):\n\n"
column = Array.new
longest = Array.new
who_columns.times {
column.push Array.new
longest.push 0
}
until name_list.empty?
for i in 0..(who_columns-1)
if name = name_list.pop
column[i].push(name)
longest[i] = [ longest[i], name.length ].max
end
end
end
until column[0].empty?
for i in 0..(who_columns-1)
if name = column[i].shift
output.concat name.ljust(longest[i]+3)
end
end
output = output.strip.concat "\n"
end
}
if channel = @active_attributes.last['channel']
output.concat "\nTotal tuned to #{channel}: #{data.length}\n\n"
else
output.concat "\nTotal connected: #{data.length}\n\n"
end
respond "\n#{output}"
elsif (@active_attributes.last['type'] == 'channels') and (@active_attributes.last['from'] == 'server')
total = @active_attributes.last['total']
name_width = tuned_width = 0
data.each { |channel|
name_width = [ name_width, channel['name'].length ].max
tuned_width = [ tuned_width, channel['tuned'].to_s.length ].max
}
output = "\nAvailable channels:\n\n"
data.each { |channel|
output.concat "#{if channel['status'] == 'default'; '+' elsif channel['status'] == 'tuned'; '-'; else ' '; end} #{channel['name'].rjust(name_width)} #{channel['tuned'].to_s.rjust(tuned_width)} #{channel['description']}\n"
}
output.concat "\nuse \";channels full\" to see #{total.to_i - data.length} more\n" if data.length < total.to_i
output.concat "\n"
respond output
elsif (@active_attributes.last['type'] == 'server stats') and (@active_attributes.last['from'] == 'server')
format_time = proc { |time|
seconds = time.to_i % 60
difference = (time - seconds) / 60
minutes = difference % 60
difference = (difference - minutes) / 60
hours = difference % 24
days = (difference - hours) / 24
formatted_time = Array.new
formatted_time.push "#{days.to_i} day#{'s' unless days == 1}" if days > 0
formatted_time.push "#{hours.to_i} hour#{'s' unless hours == 1}" if hours > 0
formatted_time.push "#{minutes.to_i} minute#{'s' unless minutes == 1}" if minutes > 0
formatted_time.push "#{seconds.to_i} second#{'s' unless seconds == 1}" if (seconds > 0) and (days < 1) and (hours < 1)
formatted_time = formatted_time.join(', ').sub(/^1 day$/, '24 hours')
formatted_time
}
output = "\n"
if data['uptime'] and data['uptime'].to_i > 0
output.concat "No major accidents in the last #{format_time.call(data['uptime'])}\n"
end
if data['character connections'] and not data['character connections'].empty?
for length,num in data['character connections']
output.concat "#{num} characters have connected in the last #{format_time.call(length)}\n"
end
end
if data['ip connections'] and not data['ip connections'].empty?
for length,num in data['ip connections']
output.concat "About #{num} players have connected in the last #{format_time.call(length)}\n"
end
end
output.concat "\n"
for channel_name,channel_data in data['own_channels']
output.concat "#{channel_name} (owner)\n"
if channel_data['moderators'].empty?
output.concat " moderators: none\n"
else
output.concat " moderators: #{channel_data['moderators'].join(', ')}\n"
end
if channel_data['invited'].nil?
nil
elsif channel_data['invited'].empty?
output.concat " invited: none\n"
else
output.concat " invited: #{channel_data['invited'].join(', ')}\n"
end
if channel_data['banned'].nil?
nil
elsif channel_data['banned'].empty?
output.concat " banned: none\n"
else
output.concat " banned:\n"
for name,ban_time in channel_data['banned']
if ban_time.nil?
ban_time = 'indefinite'
else
ban_time = format_time.call(ban_time)
end
output.concat " #{name.ljust(16)} (#{ban_time})\n"
end
end
if channel_data['gagged'].empty?
output.concat " gagged: none\n"
else
output.concat " gagged:\n"
for name,gag_time in channel_data['gagged']
if gag_time.nil?
gag_time = 'indefinite'
else
#echo "gag_time: #{gag_time.inspect}"
gag_time = format_time.call(gag_time)
end
output.concat " #{name.ljust(16)} (#{gag_time})\n"
end
end
end
for channel_name,channel_data in data['mod_channels']
output.concat "#{channel_name} (moderator)\n"
if channel_data['invited'].nil?
nil
elsif channel_data['invited'].empty?
output.concat " invited: none\n"
else
output.concat " invited: #{channel_data['invited'].join(', ')}\n"
end
if channel_data['banned'].nil?
nil
elsif channel_data['banned'].empty?
output.concat " banned: none\n"
else
output.concat " banned:\n"
for name,ban_time in channel_data['banned']
if ban_time.nil?
ban_time = 'indefinite'
else
ban_time = format_time.call(ban_time)
end
output.concat " #{name.ljust(16)} (#{ban_time})\n"
end
end
if channel_data['gagged'].empty?
output.concat " gagged: none\n"
else
output.concat " gagged:\n"
for name,gag_time in channel_data['gagged']
if gag_time.nil?
gag_time = 'indefinite'
else
gag_time = format_time.call(gag_time)
end
output.concat " #{name.ljust(16)} (#{gag_time})\n"
end
end
end
output.concat "\n" unless data['own_channels'].empty? and data['mod_channels'].empty?
respond output
elsif (@active_attributes.last['type'] == 'spell-ranks') and (@active_attributes.last['from'] == 'server') and defined?(SpellRanks)
begin
# fixme: really really slow to do the whole list, also too large (1.7mb or something)
format = data['_format_']
for name,ranks in data
next if name =~ /^_/
name = name.sub(/^.*\:/, '')
char = SpellRanks[name] || SpellRanks.new(name)
data['_format_'].each_index { |i|
char.send("#{data['_format_'][i]}=", ranks[i].to_i) rescue()
}
end
SpellRanks.timestamp = data['_timestamp_']
SpellRanks.save
rescue
echo $!
echo $!.backtrace[0..2]
end
elsif (@active_attributes.last['type'] == 'spells') and (name = @active_attributes.last['from'])
unless LNet.ignored?(name)
if data.nil?
echo "#{name} declined your request for spell information."
elsif data == false
echo 'no such user'
elsif data.empty?
echo "#{name} has no spells."
else
output = "\n#{name}:\n"
last_circle = nil
data.sort.each { |spell|
unless last_circle == Spell[spell[0]].circlename
last_circle = Spell[spell[0]].circlename
output.concat "\n- #{last_circle}:\n"
end
output.concat "#{spell[0].to_s.rjust(4)}: #{Spell[spell[0]].name.ljust(22)}- #{spell[1].as_time}\n"
}
output.concat "\n"
respond output
end
end
elsif (@active_attributes.last['type'] == 'skills') and (name = @active_attributes.last['from'])
order = [ 'Two Weapon Combat', 'Armor Use', 'Shield Use', 'Combat Maneuvers', 'Edged Weapons', 'Blunt Weapons', 'Two-Handed Weapons', 'Ranged Weapons', 'Thrown Weapons', 'Polearm Weapons', 'Brawling', 'Ambush', 'Multi Opponent Combat', 'Combat Leadership', 'Physical Fitness', 'Dodging', 'Arcane Symbols', 'Magic Item Use', 'Spell Aiming', 'Harness Power', 'Elemental Mana Control', 'Mental Mana Control', 'Spirit Mana Control', 'Elemental Lore - Air', 'Elemental Lore - Earth', 'Elemental Lore - Fire', 'Elemental Lore - Water', 'Spiritual Lore - Blessings', 'Spiritual Lore - Religion', 'Spiritual Lore - Summoning', 'Sorcerous Lore - Demonology', 'Sorcerous Lore - Necromancy', 'Mental Lore - Divination', 'Mental Lore - Manipulation', 'Mental Lore - Telepathy', 'Mental Lore - Transference', 'Mental Lore - Transformation', 'Survival', 'Disarming Traps', 'Picking Locks', 'Stalking and Hiding', 'Perception', 'Climbing', 'Swimming', 'First Aid', 'Trading', 'Pickpocketing', 'Major Elemental', 'Minor Elemental', 'Minor Mental', 'Major Spirit', 'Minor Spirit', 'Wizard', 'Sorcerer', 'Ranger', 'Paladin', 'Empath', 'Cleric', 'Bard' ]
unless LNet.ignored?(name)
if data.nil?
echo "#{name} declined your request for skill information."
elsif data == false
echo 'no such user'
else
output = "\n#{name}:\n\n"
output.concat " Skill Name | Current Current\n"
output.concat " | Bonus Ranks\n"
order.each { |skill_name|
if data[skill_name]
if skill_name =~ /Minor Elemental|Major Elemental|Minor Mental|Minor Spirit|Major Spirit|Wizard|Sorcerer|Ranger|Paladin|Empath|Cleric|Bard/
output.concat "\nSpell Lists\n"
output.concat " #{skill_name.ljust(35, '.')}|#{data[skill_name].to_s.rjust(16)}\n"
else
output.concat " #{skill_name.ljust(35, '.')}|#{Skills.to_bonus(data[skill_name]).to_s.rjust(8)}#{data[skill_name].to_s.rjust(8)}\n"
end
data.delete(skill_name)
end
}
# data should be empty by now, but just in case..
data.each_pair { |skill_name,ranks|
if skill_name =~ /Minor Elemental|Major Elemental|Minor Mental|Minor Spirit|Major Spirit|Wizard|Sorcerer|Ranger|Paladin|Empath|Cleric|Bard/
output.concat "\nSpell Lists\n"
output.concat " #{skill_name.ljust(35, '.')}|#{ranks.to_s.rjust(16)}\n"
else
output.concat " #{skill_name.ljust(35, '.')}|#{Skills.to_bonus(ranks).to_s.rjust(8)}#{ranks.to_s.rjust(8)}\n"
end
}
output.concat "\n"
respond output
end
end
elsif (@active_attributes.last['type'] == 'info') and (name = @active_attributes.last['from'])
unless LNet.ignored?(name)
if data.nil?
echo "#{name} declined your request for stat information."
elsif data == false
echo 'no such user'
else
output = String.new
output.concat "\nName: #{name} Race: #{data['Race']} Profession: #{data['Profession']}\n"
output.concat "Gender: #{data['Gender']} Age: #{data['Age']} Expr: #{data['Expr']} Level: #{data['Level']}\n"
output.concat " Normal (Bonus) ... Enhanced (Bonus)\n"
output.concat " Strength (STR): #{data['Strength'][0].to_s.rjust(3)} (#{data['Strength'][1].to_s.rjust(2)}) ... #{data['Strength'][0].to_s.rjust(3)} (#{data['Strength'][1].to_s.rjust(2)})\n"
output.concat "Constitution (CON): #{data['Constitution'][0].to_s.rjust(3)} (#{data['Constitution'][1].to_s.rjust(2)}) ... #{data['Constitution'][0].to_s.rjust(3)} (#{data['Constitution'][1].to_s.rjust(2)})\n"
output.concat " Dexterity (DEX): #{data['Dexterity'][0].to_s.rjust(3)} (#{data['Dexterity'][1].to_s.rjust(2)}) ... #{data['Dexterity'][0].to_s.rjust(3)} (#{data['Dexterity'][1].to_s.rjust(2)})\n"
output.concat " Agility (AGI): #{data['Agility'][0].to_s.rjust(3)} (#{data['Agility'][1].to_s.rjust(2)}) ... #{data['Agility'][0].to_s.rjust(3)} (#{data['Agility'][1].to_s.rjust(2)})\n"
output.concat " Discipline (DIS): #{data['Discipline'][0].to_s.rjust(3)} (#{data['Discipline'][1].to_s.rjust(2)}) ... #{data['Discipline'][0].to_s.rjust(3)} (#{data['Discipline'][1].to_s.rjust(2)})\n"
output.concat " Aura (AUR): #{data['Aura'][0].to_s.rjust(3)} (#{data['Aura'][1].to_s.rjust(2)}) ... #{data['Aura'][0].to_s.rjust(3)} (#{data['Aura'][1].to_s.rjust(2)})\n"
output.concat " Logic (LOG): #{data['Logic'][0].to_s.rjust(3)} (#{data['Logic'][1].to_s.rjust(2)}) ... #{data['Logic'][0].to_s.rjust(3)} (#{data['Logic'][1].to_s.rjust(2)})\n"
output.concat " Intuition (INT): #{data['Intuition'][0].to_s.rjust(3)} (#{data['Intuition'][1].to_s.rjust(2)}) ... #{data['Intuition'][0].to_s.rjust(3)} (#{data['Intuition'][1].to_s.rjust(2)})\n"
output.concat " Wisdom (WIS): #{data['Wisdom'][0].to_s.rjust(3)} (#{data['Wisdom'][1].to_s.rjust(2)}) ... #{data['Wisdom'][0].to_s.rjust(3)} (#{data['Wisdom'][1].to_s.rjust(2)})\n"
output.concat " Influence (INF): #{data['Influence'][0].to_s.rjust(3)} (#{data['Influence'][1].to_s.rjust(2)}) ... #{data['Influence'][0].to_s.rjust(3)} (#{data['Influence'][1].to_s.rjust(2)})\n"
output.concat "Mana: #{data['Mana']}\n\n"
respond output
end
end
elsif (@active_attributes.last['type'] == 'health') and (name = @active_attributes.last['from'])
unless LNet.ignored?(name)
if data.nil?
echo "#{name} declined your request for health information."
elsif data == false
echo 'no such user'
else
wound_message = {
'head' => [ '', 'minor bruises about the head', 'minor lacerations about the head and a possible mild concussion', 'severe head trauma and bleeding from the ears' ],
'neck' => [ '', 'minor bruises on your neck', 'moderate bleeding from your neck', 'snapped bones and serious bleeding from the neck' ],
'chest' => [ '', 'minor cuts and bruises on your chest', 'deep lacerations across your chest', 'deep gashes and serious bleeding from your chest' ],
'abdomen' => [ '', 'minor cuts and bruises on your abdominal area', 'deep lacerations across your abdominal area', 'deep gashes and serious bleeding from your abdominal area' ],
'back' => [ '', 'minor cuts and bruises on your back', 'deep lacerations across your back', 'deep gashes and serious bleeding from your back' ],
'rightEye' => [ '', 'a bruised right eye', 'a swollen right eye', 'a blinded right eye' ],
'leftEye' => [ '', 'a bruised left eye', 'a swollen left eye', 'a blinded left eye' ],
'rightLeg' => [ '', 'some minor cuts and bruises on your right leg', 'a fractured and bleeding right leg', 'a completely severed right leg' ],
'leftLeg' => [ '', 'some minor cuts and bruises on your left leg', 'a fractured and bleeding left leg', 'a completely severed left leg' ],
'rightArm' => [ '', 'some minor cuts and bruises on your right arm', 'a fractured and bleeding right arm', 'a completely severed right arm' ],
'leftArm' => [ '', 'some minor cuts and bruises on your left arm', 'a fractured and bleeding left arm', 'a completely severed left arm' ],
'rightHand' => [ '', 'some minor cuts and bruises on your right hand', 'a fractured and bleeding right hand', 'a completely severed right hand' ],
'leftHand' => [ '', 'some minor cuts and bruises on your left hand', 'a fractured and bleeding left hand', 'a completely severed left hand' ],
'nsys' => [ '', 'a strange case of muscle twitching', 'a case of sporadic convulsions', 'a case of uncontrollable convulsions' ],
'rightFoot' => [ '', 'missing message', 'missing message', 'missing message' ],
'leftFoot' => [ '', 'missing message', 'missing message', 'missing message' ],
}
scar_message = {
'head' => [ '', 'a scar across your face', 'several facial scars', 'old mutilation wounds about your head' ],
'neck' => [ '', 'a scar across your neck', 'some old neck wounds', 'terrible scars from some serious neck injury' ],
'chest' => [ '', 'an old battle scar across your chest', 'several painful-looking scars across your chest', 'terrible, permanent mutilation of your chest muscles' ],
'abdomen' => [ '', 'an old battle scar across your abdominal area', 'several painful-looking scars across your abdominal area', 'terrible, permanent mutilation of your abdominal muscles' ],
'back' => [ '', 'an old battle scar across your back', 'several painful-looking scars across your back', 'terrible, permanent mutilation of your back muscles' ],
'rightEye' => [ '', 'a black-and-blue right eye', 'severe bruises and swelling around your right eye', 'a missing right eye' ],
'leftEye' => [ '', 'a black-and-blue left eye', 'severe bruises and swelling around your left eye', 'a missing left eye' ],
'rightLeg' => [ '', 'old battle scars on your right leg', 'a mangled right leg', 'a missing right leg' ],
'leftLeg' => [ '', 'old battle scars on your left leg', 'a mangled left leg', 'a missing left leg' ],
'rightArm' => [ '', 'old battle scars on your right arm', 'a mangled right arm', 'a missing right arm' ],
'leftArm' => [ '', 'old battle scars on your left arm', 'a mangled left arm', 'a missing left arm' ],
'rightHand' => [ '', 'old battle scars on your right hand', 'a mangled right hand', 'a missing right hand' ],
'leftHand' => [ '', 'old battle scars on your left hand', 'a mangled left hand', 'a missing left hand' ],
'nsys' => [ '', 'developed slurred speech', 'constant muscle spasms', 'a very difficult time with muscle control' ],
'rightFoot' => [ '', 'missing message', 'missing message', 'missing message' ],
'leftFoot' => [ '', 'missing message', 'missing message', 'missing message' ],
}
output = "\n#{name}:\n\n"
if data['injuries'].values.any? { |hash| (hash['wound'].to_i > 0) or (hash['scar'].to_i > 0) }
wound_array = data['injuries'].to_a.collect { |inj| wound_message[inj[0]][inj[1]['wound'].to_i] }.delete_if { |msg| msg.nil? or msg.empty? }
if wound_array.length == 1
output.concat "You have #{wound_array.first}.\n"
elsif wound_array.length > 1
output.concat "You have #{wound_array[0..-2].join(', ')}, and #{wound_array[-1]}.\n"
end
scar_array = data['injuries'].to_a.collect { |inj| scar_message[inj[0]][inj[1]['scar'].to_i] }.delete_if { |msg| msg.nil? or msg.empty? }
if scar_array.length == 1
output.concat "You have #{scar_array.first}.\n"
elsif scar_array.length > 1
output.concat "You have #{scar_array[0..-2].join(', ')}, and #{scar_array[-1]}.\n"
end
else
output.concat "You seem to be in one piece.\n"
end
output.concat "\n"
output.concat " Maximum Health Points: #{data['max_health']}\n"
output.concat " Remaining Health Points: #{data['health']}\n"
output.concat "\n"
output.concat " Maximum Spirit Points: #{data['max_spirit']}\n"
output.concat " Remaining Spirit Points: #{data['spirit']}\n"
output.concat "\n"
output.concat " Maximum Stamina Points: #{data['max_stamina']}\n"
output.concat " Remaining Stamina Points: #{data['stamina']}\n"
output.concat "\n"
respond output
end
end
elsif (@active_attributes.last['type'] == 'locate') and (name = @active_attributes.last['from'])
unless LNet.ignored?(name)
if data.nil?
echo "#{name} declined your request for location information."
elsif data == false
echo 'no such user'