-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrecolor.lic
767 lines (665 loc) · 37 KB
/
recolor.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
=begin
Recolors generally-friendly NPCs in room descriptions, like spirit servants, familiars, and animal companions
Now works with both StormFront and Wizard front ends. Color options are different between the two clients and thus
are saved separately.
Should work with room descriptions from locates and PEERing as well. Other places where these creature names are
mentioned will NOT be affected.
Affectected NPCs can appear in any StormFront color preset (like the colors for says and whispers) or any of the
15 non-background colors (Wizard FE)
;recolor help shows all available presets and samples
;recolor <preset> selects that preset
;recolor by itself defaults to the speech preset (or Color #10 in WFE), unless you've previously set a different one.
author: LostRanger (thisgenericname@gmail.com)
game: any
tags: utility
required: Lich >= 4.6.0.
version: 0.6 (2019-07-30)
changelog:
version 0.6 (2019-07-30)
* Support animates from Animate Dead and animated weapons, provided the latter still begin with 'animated'
* Support matching ALL locations a name occurs rather than merely within room descriptions.
* Added slight optimizations to pattern matching.
version 0.5.1 (2019-06-05)
* Add cockatiels as recognized familiars.
version 0.5 (2019-06-04)
* Better support demons
* Add option to support illusioned demons. This setting will be defaulted to your 'demons' setting the first launch in this version.
Thanks to Katze for helping me test illusion demons.
version 0.4.1 (2019-05-??)
* Add iguanas as recognized familiars
version 0.4 (2019-05-26)
* Vastly improve Wizard FE support
* Fix ';recolor quiet' and ';recolor loud' being swapped.
* Added optional support for Grasp of the Grave (off by default)
version 0.3.4 (2019-05-22)
* Work better with demons
version 0.3.3 (2019-05-22)
* Fix conflict between 'bold' as a color choice and as an option for respecting/ignoring monsterbold.
The latter is now monsterbold/nomonsterbold
version 0.3.2 (2019-05-22)
* ;recolor now properly only detects you entering its name if it is at the start of the line. You can now
whisper about it to people ;)
* Now considers gyrfalcons as possible animal companions if allowed to patch XML.
version 0.3.1 (2019-05-22)
* Keep links by default. (If you already ran version 0.3, you'll need to re-enable them with `;recolor keeplink`)
version 0.3 (2019-05-22)
* Now also applies to room windows. As a bonus, this removes some unneeded invisible garbage that was sent
to the room window that did not need to be (effectively bolding monsters multiple times)
* ;recolor can now be invoked when it is already running to change options.
* Creatures that are targetable according to StormFront/Gameobj.targets will always be forced to hostile
* Enemies that are dead can now be recolored with ;recolor dead=<color> or reverted to normal with ;recolor dead=off
* Wizard familiars and animal companions are now patched into GameObj.type_data if they were not already previously.
This enables them to be properly recolored even without using xmlpatch until the type data is added in a proper fashion.
* Summoned minor demons should now be supported, but may not be 100% reliable.
Demon support can be turned off with ;recolor nodemons or turned back on with ;recolor demons
* You can now remove links from friendly NPCs using ;recolor nokeeplink or re-add them with ;recolor keeplink
* ;recolor can be told to apply even when monsterbold is off with ;recolor nobold
This will also apply to items that somehow resemble a creature name, if any exist.
version 0.2 (2019-05-22)
* Now says what it does in ;recolor help
* Now works when room descriptions are disabled.
version 0.1 (2019-05-21)
* Initial release
=end
# [JUST UPDATED] ;foreach 0.9, featuring filtering by marked/registered status, faster scans of premium lockers, and automatic locker opening/closing. ;repo info foreach -- ;repo download foreach -- ;foreach help
module RecolorScript
VERSION = '0.6 beta (2019-07-30)'
VERSION_INT = 600000
PATTERNS = {
# Base desc in $1, items and NPCs in $2
:room_description => /^(.*<style id="roomDesc"\/>.*<style id=""\/>You (?:also see|notice) )(.*)$/,
# Items in NPCs in $2, prefix/suffix in $1/$3
:room_window => /^(.*<component id='room objs'>\s*You (?:also see|notice))(.*)(<\/component>.*)$/,
# Strips bold tags.
:strip_bold => /<\/?b>/,
# Strips links
:strip_links => /<\/?a.*?>/,
# $1=pushbold $2=replacement base $3=id $4=noun $5=link text $6=suffix text
:item_link => /
((?:<pushBold\/>)+)?
(
(?:a\ |an\ |some\ |the\ )? # Possible article
<a\ exist="(\d+)"\ noun="([^"]+)">([^<]+)<\/a>
)
(?:(?:<popBold\/>)+)?
([^,.]*?)(?=and|[,.])
/ix, # ([^,.]*)
:dead_creature => /\Wdead(?:\W|$)/,
# Matches a spirit servant
:spirit_servant => /
(?:an?\ )? # Optional article and explicit space
(?: # Demeanors
aggravated|agitated|affronted|affrontive|angry|annoyed|antagonistic|bashful|belligerent|bereaved|bitter
|blissful|capricious|charming|concerned|cowering|coy|cunning|deleterious|delighted|depressed|desolate
|despondent|disinclined|disorderly|dolorous|dour|ebullient|ecstatic|enraged|erratic|excited|expressive
|exultant|fickle|fierce|forlorn|fluctuant|frisky|genial|glum|goofy|grieving|grouchy|grumpy|happy|huffy
|impish|irate|jaunty|jolly|jovial|jumpy|lamenting|lively|malcontent|melancholy|merry|mirthful|moping|morose
|nervous|obstreperous|persnickety|perturbed|puckish|quirky|rascally|recalcitrant|reluctant|restive|roguish
|shrinking|shy|skittish|somber|sulky|tense|tearful|terrified|timid|troublesome|uneasy|unruly|unsettled
|unstable|vacillating|variable|vengeful|volatile|whimsical|wrathful|wretched
)
[ ] # Explicit space
(?: # Types
alpine|astral|aurora|badland|bog|boulder|cavern|celestial|crevasse|desert|dune|forest|geyser|glacier
|island|lake|lavaflow|luck|marsh|mountain|ocean|oxbow|river|snow|solar|spring|stream|sun|sunburst|swamp
|taiga|tidal|tree|tropical|volcano|wasteland|will-o-wisp|wood|woodland
)
[ ]
spirit
/ix,
:grasp_of_the_grave => /^(?:pair of )?[-a-z]+ arms?$|salt-crusted .*pincer/, # Experimental
# Matches a summoned demon. Experimental
:summoned_demon => /
# Simple Demons
\w\ \w+\ # At least two adjectives
(?:abyran|aishan|arashan|grantris|grik|imp|verlok) # Noun
(?:'.*)?$ # Sometimes they have an apostrophe-words part (e.g. abyran'ra)
|
# Igaesha
cloud\ of\.*\ # Cloud of <COLOR>, can be 1-3 words.
(?:haze|rouk|brume|haar|murk|nyle|mist|smoke|vapor|fog)$ # Igaesha subtypes
|
# Shien
(?:blurred|hazy|indistinct|misty|nebulous|shifting|vaporous) # Descriptor
\ .*\ # Color
(?:darkling|shadowling)$ # Nouns
/ix,
# Demon illusions
:illusion_lookup => Set.new(
[
# Grik and Abyran
'caped figure', 'cloaked figure', 'cowled figure', 'masked figure', 'robed figure',
'coat-wrapped figure', 'cowled figure', 'dark-mantled figure',
# Arashan
'tethered hairy black tarantula', 'bound large brown arachnid', 'restrained enormous web weaver',
'harnessed huge grey spinner', 'shackled vast grey-blue spider',
# Grantris
'slender chestnut brown stoat', 'sleek beady-eyed mink', 'long light brown weasel',
'medium-sized lithe ferret', 'small bushy-tailed ermine',
# Verlok
'brightly plumed toucan', 'large glossy raven', 'lanky white stork', 'old blue parrot',
'small brown pelican',
# Shien
'aging dusty gnoll', 'haggard grey-haired gnoll', 'stooped and wizened gnoll', 'portly wrinkled gnoll',
'old fork-bearded gnoll',
# Imp
'thin elderly gnoll', 'old fork-bearded gnoll', 'haggard grey-haired gnoll',
'stooped and wizened gnoll', 'ancient bespectacled gnoll'
]
),
:illusion_pattern => /^(?:lazy wild .+ dog|listless .+ jackal|docile .+ coyote|languid .+ wolf|mangy .+ fox)$/,
# Animates
:animates => /^animated /,
# Explicit exceptions
:hostile => /(abyran'ra$|slush$)/,
}
HOOK_NAME = 'recolor_room_hook'
def self.generate_wrappers
wrappers = {
'none' => ['', ''],
'bold' => [monsterbold_start, monsterbold_end],
}
if @stormfront
%w(speech whisper thought watching link selectedLink command).each do |preset|
wrappers[preset] = ["<preset id='#{preset}'>", "</preset>"]
end
else
1.upto(15).each do |i|
wrappers["color#{i}"] = [(128+i).chr, "\240"]
end
end
return wrappers
end
if @stormfront
DEFAULT_PRESET = 'speech'
else
DEFAULT_PRESET = 'color10'
end
def self.show_changelog(prev)
prev ||= 0
CharSettings[:current_version] = VERSION_INT
changelog = {
400000 => [
"Major version 0.4 changes:",
'',
" * Vastly improved (but still experimental) support for the Wizard FE.",
'',
" * Added optional support for the arms from Grasp of the Grave (709).",
" This support is <pushBold/>OFF<popBold/> by default, because it may affect hostile arms in areas with creatures that can cast the spell. See <d>#{$lich_char}#{@script.name} help</d> for details on turning the option on.",
'',
" * `#{$lich_char}#{@script.name} loud` now toggles loud mode (mainly for debugging) and `#{$lich_char}#{@script.name} quiet` now disables it. This logic was accidentally reversed earlier.",
'',
" * Added optional support for the arms from Grasp of the Grave (709).",
" This support is <pushBold/>OFF<popBold/> by default, because it includes hostile arms in areas with creatures that can cast the spell. See <d>#{$lich_char}#{@script.name} help</d> for details on turning the option on.",
'',
" * `#{$lich_char}#{@script.name} loud` now toggles loud mode (mainly for debugging) and `#{$lich_char}#{@script.name} quiet` now disables it. This logic was accidentally reversed earlier.",
],
500000 => [
"Major version 0.5 changes:",
'',
" * Improve patterns for detecting summoned demons even more based off information on the wiki.",
'',
" * Added an option to support illusioned demons. This is a separate setting from regular demon support, and defaults to the current value of your 'demons' setting on your first launch with this version.",
],
500100 => [
"Version 0.5.1 changes:",
'',
" * Recognize cockatiels as Wizard familiars."
],
600000 => [
"Version 0.6 changes:",
'',
" * Support animates from Animate Dead and animated weapons, provided the latter still begin with 'animated'",
" To enable this, do `;recolor animates`. To disable it, `recolor noanimates`",
'',
" * Support matching ALL locations a name occurs rather than merely within room descriptions. (Experimental)",
" To enable this, do `;recolor global`. To disable it, `recolor noglobal`",
'',
" * Added slight optimizations to pattern matching.",
]
}
if prev != VERSION_INT
msg = []
msg << "<preset id='speech'>--------------------</preset>"
msg << "<preset id='speech'>Welcome to #{$lich_char}#{@script.name}</preset> <preset id='whisper'>#{VERSION}</preset>"
msg << ''
changelog.each do |version, notes|
if version > prev or version == VERSION_INT
msg += notes
msg << ''
end
end
msg << "For a more detailed changelog: <d>#{$lich_char}repo info #{@script.name}</d>."
msg << "To enable automatic updates: <d>#{$lich_char}repo set-updatable #{@script.name}</d>`."
msg << "For details on new features: <d>#{$lich_char}#{@script.name} help</d>"
msg << "For more LostRanger scripts: https://bit.ly/lostranger-scripts"
msg << ''
msg << "NOTE: Changes to NPC detection (such as identifying ranger companions and wizard familiars) may require a Lich restart."
msg << ''
msg << "This message will not be displayed again for the character '#{XMLData.name}' until a new version is downloaded."
msg << "<preset id='speech'>--------------------</preset>"
send msg
end
end
def self.get_color(k)
return @settings[k.to_sym] if @stormfront
return @settings[:"wfe_#{k.to_s}"]
end
def self.set_color(k,v)
v = nil if v == 'off'
if @stormfront
@settings[k.to_sym] = v
else
@settings[:"wfe_#{k.to_s}"] = v
end
@need_to_save_settings = true
end
def self.cleanup
self.save_settings if @need_to_save_settings
DownstreamHook.remove(HOOK_NAME)
UpstreamHook.remove(HOOK_NAME)
end
def self.reformat(match)
text = match[2]
trailer = match[6]
return nil unless match[1] or !@settings[:monsterbold]
ignore_safety = false
if match[5] =~ @friendly_pattern
if $1
friendly = false
else
friendly = true
end
elsif @settings[:illusions] and PATTERNS[:illusion_lookup].include?(match[5])
friendly = true
elsif @settings[:animates] and match[5] =~ PATTERNS[:animates]
friendly = true
ignore_safety = true
elsif @settings[:grasp] and match[5] =~ PATTERNS[:grasp_of_the_grave]
friendly = true
ignore_safety = true
else
npc = GameObj.npcs.find{|x| x.id == match[3]}
npc = GameObj.new(match[3], match[4], match[5]) unless npc
if npc.type =~ /passive npc|companion|familiar/
friendly = true
else
friendly = false
end
end
if friendly and !ignore_safety and GameObj.targets.find{|x| x.id == match[3]}
friendly = false
if @settings[:loud]
echo "Found a friendly that was not: #{match.inspect}. Do '#{$lich_char}#{@script.name} quiet' to disable this warning."
end
end
if friendly
text = text.gsub(PATTERNS[:strip_links], '') unless @settings[:keeplink]
return "#{@prefix}#{text}#{@suffix}#{(trailer or '')}"
end
if @deadprefix and trailer and trailer =~ PATTERNS[:dead_creature]
return "#{@deadprefix}#{text}#{@deadsuffix}#{trailer}"
end
if match[1]
return "<pushBold/>#{text}<popBold/>#{trailer}" # Strips excess push/popbolds.
end
end
def self.reformat_all(xml)
return xml.gsub(PATTERNS[:item_link]){|match| (reformat($~) or match)}
end
def self.hook_proc(xml)
if xml =~ PATTERNS[:room_description]
return $1 + reformat_all($2) + "\n"
elsif xml =~ PATTERNS[:room_window]
pre = $1
post = $3
text = $2.gsub(PATTERNS[:strip_bold], '')
return pre + reformat_all(text) + post + "\n"
elsif @settings[:global]
return reformat_all(xml)
else
return xml
end
end
def self.hook
self_pattern = /^(?:<c>)?\s*#{Regexp.escape("#{$lich_char}#{@script.name}")}(\s+.*)?$/
before_dying { self.cleanup }
DownstreamHook.add(HOOK_NAME, proc {|xml| hook_proc(xml)})
UpstreamHook.add(HOOK_NAME, proc {|cmd|
if cmd =~ self_pattern
if $1
self.exec($1, true)
else
send "[#{$lich_char}#{@script.name} is already running. For details, see <d>#{$lich_char}#{@script.name} help</d>.]"
end
nil
else
cmd
end
})
end
def self.preset_color(k)
return 'off' if k == 'off' or k.nil?
prefix, suffix = @wrappers[k]
unless prefix
return "??" + k + "??"
end
return prefix + k + suffix
end
def self.current_settings_string
result = [
self.preset_color(get_color(:color)),
"dead=#{self.preset_color(get_color(:deadColor))}"
]
[:keeplink, :demons, :illusions, :monsterbold, :patch, :grasp, :animates, :global].each{|k|
if @settings[k]
result << k.to_s
else
result << "no#{k.to_s}"
end
}
if @settings[:loud]
result << 'loud'
else
result << 'quiet'
end
return result.join(' ')
end
def self.echo(*what)
respond what.map{|x| "[#{@script.name}: #{x}]"}
end
def self.exec(args, running=false)
words = args.strip.downcase.split(/\s+/)
if words.include?('help')
msg = []
if @stormfront
msg << "<preset id='speech'>This is #{$lich_char}#{@script.name}</preset> <preset id='whisper'>#{VERSION}</preset>"
else
msg << "<pushBold/>This is #{$lich_char}#{@script.name} #{VERSION}<popBold/> "
end
msg << "#{@script.name} makes spirit servants, animal companions, familiars and other passive NPCs a color other than <pushBold/>monsterbold<popBold/>."
msg << "Optionally, it can also color dead creatures in a (possibly) different color."
msg << ''
msg << "<output class='mono'/>"
msg << "Usage: <d>#{$lich_char}#{@script.name} help</d> - Shows this help."
msg << " <d>#{$lich_char}#{@script.name} settings</d> - Shows current settings."
msg << " <d>#{$lich_char}#{@script.name}</d> [options] - Start recolor and/or change settings."
msg << ''
msg << "Options can include any of the following"
msg << " COLOR - Apply COLOR to friendly NPCs."
msg << " dead=COLOR - Apply COLOR to dead creatures."
msg << " dead=off - Turn off special handling of dead creatures."
msg << ''
msg << " [no]keeplink - [Don't] keep links for friendly NPCs"
msg << " [no]demons - [Don't] consider summoned demons as friendly."
msg << " [no]illusions - [Don't] consider illusioned demons as friendly."
msg << " [no]monsterbold - [Don't] skip creatures that aren't already in <pushBold/>monsterbold<popBold/>."
msg << " [no]grasp - [Don't] recolor arms from Grasp of the Grave. (May not apply to altered arms.)"
msg << " [no]animates - [Don't] recolor animated creatures/weapons"
msg << " [no]patch - [Don't] apply mini-XML patch to identify animal companions and wizard familiars."
msg << " (This has no effect in the current session if the patch has already been applied,"
msg << " by either this script or xmlpatch)"
msg << " [no]global - [Don't] apply Recolor everywhere (rather than simply in room descriptions)"
msg << ''
msg << " ignore - Don't complain about invalid options. (Useful if specifying colors for both StormFront and Wizard FEs)"
msg << " loud - Yell loudly if a creature is identified as friendly but appears in GameObj.targets. (This should never happen.)"
msg << " quiet - Stop yelling about friendly creatures that can be targetted."
msg << " exit - Equivalent to <d>#{$lich_char}kill #{@script.name}</d>"
msg << ''
msg << "Valid colors are:"
msg << (" " + @wrappers.map{|k, v| preset_color(k)}.join(" | "))
msg << ''
msg << "If no color is selected, the default is #{preset_color(DEFAULT_PRESET)}."
if @stormfront
msg << "Colors can be changed from Options -> Highlights -> Preset within Stormfront."
else
msg << "Colors correspond to your color choices in Configuration -> Text Strings."
msg << "Stormfront has a different selection of color settings, available when running Stormfront."
msg << "Wizard FE colors and StormFront FE colors are saved separately."
end
msg << ''
msg << "Current settings for #{XMLData.name} are:"
msg << " #{$lich_char}#{@script.name} #{current_settings_string}"
msg << "<output class=''/>"
send msg
return true
elsif words.include?('settings')
msg = []
msg << "<output class='mono'/>"
msg << "Current settings for #{XMLData.name} are:"
msg << " #{$lich_char}#{@script.name} #{current_settings_string}"
msg << "<output class=''/>"
send msg
return true
end
bool_settings = {
'loud' => [:loud, true],
'quiet' => [:loud, false],
}
%w(keeplink demons monsterbold patch grasp illusions animates global).each do |k|
bool_settings[k] = [k.to_sym, true]
bool_settings["no"+k] = [k.to_sym, false]
end
new_settings = {}
ignore_errors = words.include?('ignore')
words.each do |word|
if @wrappers[word]
if new_settings[:color] and !ignore_errors
echo "Cannot specify more than one color. (Saw both '#{new_settings[:color]} and '#{word}'"
return true
end
new_settings[:color] = word
elsif word =~ /^dead=(.+)$/
if new_settings[:deadColor] and !ignore_errors
echo "Cannot specify dead= more than once. (Saw both '#{new_settings[:deadColor]} and '#{$1}'"
return true
elsif $1 == 'off' or @wrappers[$1]
new_settings[:deadColor] = $1
else
echo "Unknown color #{$1}. See #{$lich_char}#{@script.name} help"
return true
end
elsif word == 'exit'
echo "#{@script.name} was not running." unless running
Script.kill(@script.name)
return true
elsif bool_settings[word]
setting, value = bool_settings[word]
if new_settings[setting].nil? or ignore_errors
new_settings[setting] = value
elsif new_settings[setting] == value
echo "Cannot specify '#{word}' more than once."
return true
else
k = (bool_settings.find{|k,v| v[0] == setting and v[1] != value}[0])
if k
echo "Options '#{k}' and '#{word}' conflict."
else
echo "Option '#{word}' conflicts with another setting."
end
return true
end
elsif !ignore_errors
echo "Unknown option or color '#{word}'."
return true
end
end
if new_settings.length > 0
if new_settings[:color]
set_color(:color, new_settings[:color])
new_settings.delete(:color)
end
if new_settings[:deadColor]
set_color(:deadColor, new_settings[:deadColor])
new_settings.delete(:deadColor)
end
# if new_settings[:deadColor] == 'off'
# new_settings[:deadColor] = nil
# else
# new_settings[:deadColor] = new_settings[:deadColor].to_sym
# end
# new_settings[:color] = new_settings[:color].to_sym unless new_settings[:color].nil?
#
if new_settings[:patch] == false and @settings[:patch]
echo "Turned off mini-XML patch. Note that this will NOT undo any effects of a previously-applied patch; to do that you must restart Lich."
elsif new_settings[:patch]
mini_xml_patch
end
@settings.merge!(new_settings)
@need_to_save_settings = true
self.update_wrappers
self.update_patterns
send "#{@script.name}: Settings changed to #{current_settings_string}" if running
end
end
def self.update_wrappers
@prefix, @suffix = @wrappers[get_color(:color)]
@deadprefix, @deadsuffix = @wrappers[get_color(:deadColor)]
#
# if @settings[:color] == 'none'
# @prefix = @suffix = ''
# else
# @prefix = "<preset id='#{@settings[:color]}'>"
# @suffix = "</preset>"
# end
#
# if @settings[:deadColor] == 'none' or @settings[:deadColor] == 'off'
# @deadprefix = @deadsuffix = ''
# else
# @deadprefix = "<preset id='#{@settings[:deadColor]}'>"
# @deadsuffix = "</preset>"
# end
end
def self.save_settings
@settings.each do |k,v|
CharSettings[k] = v
end
@need_to_save_settings = false
end
def self.send(what)
if @stormfront
return _respond(what)
end
unless what.is_a?(Array)
what = [what]
end
return _respond what.map{|line|
if line =~ /^\s*<\/?output[^>]*>$/
nil
else
line = line.gsub(/<preset.*?>(.*?)<\/preset>/, "\\1")
line.gsub!('<pushBold/>', monsterbold_start)
line.gsub!('<popBold/>', monsterbold_end)
line.gsub!(/<\/?d.*?>/, '')
line
end
}.keep_if{|x| x}
end
def self.run(script)
@script = script
@stormfront = ($frontend == 'stormfront')
@wrappers = self.generate_wrappers
unless @stormfront
msg = ["<pushBold/>* "]
if $frontend == 'wizard'
msg << "* WARNING: Wizard FE support in #{$lich_char}#{@script.name} is EXPERIMENTAL. "
else
msg << "* WARNING: #{$lich_char}#{@script.name} is only designed for use with Stormfront. "
msg << "* It may not work properly using other clients. "
end
msg << "*<popBold/> "
send msg
end
@need_to_save_settings = false
script.want_downstream = false
script.want_downstream_xml = true
settings = CharSettings.to_hash
settings[:color] ||= 'speech'
settings[:wfe_color] ||= 'color10'
if settings[:patch].nil?
settings[:patch] = true
settings[:demons] = true
settings[:loud] = false
settings[:deadColor] = nil
settings[:wfe_deadColor] = nil
settings[:keeplink] = true
settings[:monsterbold] = true
end
settings[:demons] = true if settings[:demons].nil?
settings[:keeplink] = settings[:link] if settings[:keeplink].nil?
settings[:keeplink] = true if settings[:keeplink].nil?
settings[:monsterbold] = settings[:bold] if settings[:monsterbold].nil?
settings[:monsterbold] = true if settings[:monsterbold].nil?
settings[:grasp] = false if settings[:grasp].nil?
settings[:illusions] = settings[:demons] if settings[:illusions].nil?
settings[:animates] = settings[:demons] if settings[:animates].nil?
settings[:global] = false if settings[:global].nil?
@settings = settings
exit if self.exec(script.vars[0])
self.update_wrappers
self.update_patterns
mini_xml_patch if settings[:patch]
msg = []
if @stormfront
msg << "#{@prefix}[#{@script.name} version #{VERSION} starting. For help, see '#{$lich_char}#{@script.name} help']#{@suffix}."
else
msg << "<pushBold/>[#{@script.name} version #{VERSION} starting. For help, see '#{$lich_char}#{@script.name} help']<popBold/> "
end
msg << "Current settings: #{current_settings_string}"
send msg
previous_version = settings[:current_version] || 0
changelog_when = nil
if previous_version < VERSION_INT
if (Time.now - $login_time) > 60 # Has been more than 60 seconds since login, so we probably aren't from autostart
show_changelog(previous_version)
else
changelog_when = Time.now + 10
end
end
self.hook
i_stand_alone
while get
self.save_settings if @need_to_save_settings
if changelog_when and changelog_when < Time.now
show_changelog(previous_version)
changelog_when = nil
end
end
end
def self.update_patterns
patterns = [
PATTERNS[:hostile],
PATTERNS[:spirit_servant]
]
patterns << PATTERNS[:summoned_demon] if @settings[:demons]
patterns << PATTERNS[:illusion_pattern] if @settings[:illusions]
# patterns << PATTERNS[:animates] if @settings[:animates]
@friendly_pattern = Regexp.new(patterns.map(&:to_s).join('|'))
end
def self.mini_xml_patch
# Gameobj-data as of yet has not ported familiar/companion from xmlpatch. So, in case people aren't xmlpatch,
# apply this patch manually. It should be safe.
#
data = GameObj.type_data
familiars = "(?:pink-cheeked|ruby-cheeked|croak-beaked|beady-eyed|green-faced|white-winged|white-faced|white-banded|grey-banded)?.*?(?:green|grey|yellow|albino) cockatiel|(?:short-nosed|bare-backed|little-collar|long-tailed|long-tongued)?.*?(?:small|large|fruit|spotted|pygmy) bat|(?:(?:blue-eyed|disheveled|fat|fluffy|green-eyed|long-haired|orange-eyed|plump|shabby|short-haired|sleek|emerald-eyed)?.*?(?:black|calico|charcoal|ginger|grey|tabby|white) cat|(?:silver-eyed pure white cat|silver-ruffed charcoal black cat))|(?:large|small)?.*?(?:black|brown|dwarf|forest|green|grey|leaf|mountain|ochre|spotted|veiled) chameleon|(?:iridescent)?.*?(?:purple-plumed) cormorant|lithe golden-eyed coyote|(?:large|ruffled|sleek|small)?.*?(?:long-winged|narrow-winged|red-footed|red-necked) falcon|(?:(?:disheveled|sleek)?.*?(?:arctic|bat-eared|black|blue|desert|grey|kit|red|swift) fox|black-footed plump red fox)|(?:(?:large|plump|slimy|small|speckled)?.*?(?:brown|bull|green|green tree|horned|tree) frog|heavy-set bull frog)|gyrfalcon|(?:black-tailed|white-tailed)?.*?(?:black|broom|cape|mountain|red|savanna|scrub|snowshoe|woolly) hare|(?:(?:large|ruffled|sleek|small)?.*?(?:black|black-mantled|grey-bellied|grey-headed|red-chested|red-tailed|spot-tailed|white-bellied) hawk|dappled broad-winged hawk)|rangy dappled grey jackal|(?:roly-poly)?.*?(?:flamepoint) sand kitten|(?:greater|lesser|sleek|small)?.*?(?:bamboo|black|brown|crowned|dwarf|fork-crowned|golden|fork-marked|grey|grey-headed|mouse|red-bellied|ring-tailed|red-collared|ruffled|white-collared) lemur|slim dove grey merlin|(?:fat|plump|sleek|tiny)?.*?(?:black|brown|field|forest|furry|pocket|grey|white)?.*?mouse|(?:(?:greater|lesser|ruffled|sleek|pale-faced)?.*?(?:barn|pygmy|barred|screech|bay|snowy|crested|sooty|eagle|speckled|elf|spectacled|grass|spotted|great white|striped|grey|tawny|hawk|white|horned|white-faced|maned|wood|masked) owl|dark-eyed grey barred owl)|(?:brilliant)?.*?parrot|(?:large|ruffled|small|sleek)?.*?(?:brown|pink-backed|white|spot-billed) pelican|(?:crested|emperor|king|royal|yellow-eyed|little blue) penguin|(?:rusty|hooded|red-brown|black|brown|crested) pitohui|rock ptarmigan|(?:(?:large|ruffled|small|sleek)?.*?raven|glossy coal black raven)|squat pebble-backed toad|(?:black-banded|ivory-billed|black-billed|red-billed|black-necked|red-necked|blue-banded|spot-billed|curl-crested|stripe-billed|fiery-billed|yellow-browed|grey-breasted|yellow-ridged|groove-billed)?.*?(?:blue|bright blue|collared|emerald|green|hooded|speckled)?.*?toucan|(?:(?:arctic|blue|great white|grey) wolf|amber-eyed grizzled timber wolf)|(?:cloudy-eyed|long-eared|ethereal|long-nosed|foggy-eyed|soft-featured|lithe|white-eyed)?.*?air wyrdling|(?:amber-eyed|large-nosed|crumbling|rough|crystal-eyed|round-eared|dusty|squat|dusty-eyed|stout)?.*?earth wyrdling|(?:angular|sharp-eared|ember-eyed|sharp-nosed|lanky|smoky|red-eyed|smoky-eyed|scaled|smoldering)?.*?fire wyrdling|(?:angular|nebulous|hook-nosed|scaled|jagged-eared|silver-eyed|lanky|spark-eyed)?.*?lightning wyrdling|(?:blue-eyed|misty-eyed|frothy-eyed|sleek|lithe|small-nosed|long-eared|smooth|misty)?.*?water wyrdling|(?:pale green|leafy green|grass green|russet brown|light viridian|jade green|emerald|deep green|spike-backed|short-snouted|long-snouted|three-tied|drab|aged|scaly|split-tailed)?.*?iguana|hummingbird"
#Wizard familiars
if data['familiar'].nil?
data['familiar'] = {:name => /^(?:#{familiars})$/}
echo "Added a patch for wizard familiars"
end
#Ranger companions
if data['companion'].nil?
data['companion'] = {
:noun => /^(?:albatross|badger|banishara|barrowrat|baza|beaver|boarrat|bobcat|burrowvine|bushwag|buzzard|caiverine|canid|capybara|caracal|caracara|catamount|cavecail|cheetah|condor|cougar|coyote|crow|curhound|curwolf|cygnet|dhole|dobrem|dole|eagle|elf-owl|falcon|felid|fennec|fenvaok|ferret|fox|foxhound|goshawk|graiphel|greatfang|groundhog|gyrefalcon|gyrfalcon|harrier|hawk|hawk-eagle|hedgehog|heron|hound|hyena|jackal|jaguar|jaguarundi|karet|kestrel|kingfisher|kite|kodkod|kuvasz|ledisa|leopard|lion|loper|lugger|lynx|margay|marmot|mastiff|mink|mole|mongoose|mudcat|muskrat|muzzlerat|narmo|nutria|ocelot|osprey|owl|panther|passo|peregrine|pigeonhawk|porcupine|puma|raccoon|raptor|rasper|rat|raven|rockrat|rowl|saker|samoyed|sandrat|scrabbler|screech-owl|sea-eagle|seagull|seahawk|serval|shrika|shrike|sloth|snowcat|snow-owl|sparrowhawk|stratis|swift|tiger|tothis|trakel|tunnelcat|veercat|vole|vulture|weasel|whiskrat|wildcat|wolf|wolfhound|wolverine|wombat|woodchuck|woodpecker|woodshrew|yowler)$/,
:exclude => /^(?:giant rat|mountain snowcat|bobcat|coyote|spotted lynx|blood eagle|giant marmot|giant weasel|arctic puma|black leopard|humpbacked puma|panther|puma|fire rat|ghost wolf|black panther|mountain lion|plains lion|cougar|dark panther|arctic wolverine|ice hound|night hound|wolverine|snow leopard|dobrem|martial eagle|wild hound|moor hound|colossus vulture|moor eagle|dreadnought raptor|mastodonic leopard|sabre-tooth tiger|stone mastiff|#{familiars})$/,
}
echo "Added a patch for ranger companions"
end
end
end
RecolorScript.run(script)
=begin
<resource picture="0"/><style id="roomName" />[<a exist="-10622535" noun="Meggiemae">Meggiemae</a>'s Home]
<style id=""/><style id="roomDesc"/>Walls of rough-hewn oak and a <a exist="3636382" noun="floor">dusty oak floor</a> covered by a <a exist="3636383" noun="rug">tasseled cotton rug</a> enclose this small room. In one corner lies a <a exist="3636389" noun="bed">polished oak four-poster bed</a>, and near the <a exist="3636389" noun="bed">bed</a> sits a <a exist="3636387" noun="table">sturdy oak table</a>. Above an <a exist="3636381" noun="fireplace">oak-mantled sandstone fireplace</a> hangs an <a exist="3636386" noun="plaque">Estate Holder plaque</a>. The room holds a mild scent of earthy loam.<compass></compass><style id=""/> You also see <pushBold/>a <a exist="3694975" noun="spirit">fluctuant spring spirit</a><popBold/>, <pushBold/>a <a exist="2185071" noun="snowcat">peak snowcat</a><popBold/>, the <a exist="3580220" noun="disk">Meggiemae disk</a>, the <a exist="2565920" noun="disk">Gylmour disk</a> and an <a exist="3636388" noun="door">iron-bound driftwood door</a>.
Also here: <a exist="-10622535" noun="Meggiemae">Meggiemae</a>, <a exist="-11140922" noun="Gylmour">Gylmour</a>.
=end