-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsortedskills.lic
214 lines (195 loc) · 6.14 KB
/
sortedskills.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
=begin
Shows the output of SKILLS, SKILLS FULL or SKILLS BASE FULL in the same order they appear on the Excel character trainer spreadsheet
Usage:
;sortedskills
;sortedskills full
;sortedskills base
;sortedskills base full
Maybe:
;alias add skills=;sortedskills
author: LostRanger (thisgenericname@gmail.com)
game: gs
tags: utility
version: 0.2 (2019-07-09)
changelog:
version 0.2 (2019-07-09)
* Fix Multi Opponent Combat and Disarming Traps being out of order.
version 0.1 (2019-07-09)
* First release.
=end
module SortedSkills
def self.indexed(*list)
result = {}
list.each_with_index do |k, v|
result[k] = v
end
return result
end
@skills_order = {
nil => indexed(
"Armor Use",
"Shield Use",
"Edged Weapons",
"Blunt Weapons",
"Two-Handed Weapons",
"Ranged Weapons",
"Thrown Weapons",
"Polearm Weapons",
"Brawling",
"Two Weapon Combat",
"Combat Maneuvers",
"Multi Opponent Combat",
"Ambush",
"Physical Fitness",
"Dodging",
"Climbing",
"Swimming",
"Disarming Traps",
"Picking Locks",
"Stalking and Hiding",
"Perception",
"First Aid",
"Trading",
"Pickpocketing",
"Survival",
"Arcane Symbols",
"Magic Item Use",
"Harness Power",
"Spell Aiming",
"Elemental Mana Control",
"Spirit Mana Control",
"Mental Mana Control"
),
"Spell Lists" => nil,
"Elemental Lore" => indexed("Air", "Earth", "Fire", "Water"),
"Spiritual Lore" => indexed("Blessings", "Religion", "Summoning"),
"Sorcerous Lore" => indexed("Demonology", "Necromancy"),
"Mental Lore" => indexed("Divination", "Manipulation", "Telepathy", "Transference", "Transformation")
}
def self.quiet_command(command, start_pattern, end_pattern = /<prompt/, include_end = true, timeout=5)
result = []
name = "sortedskills_downstream_hook"
filter = false
begin
Timeout::timeout(timeout, Interrupt) {
DownstreamHook.add(name, proc {|xml|
if filter
if xml =~ end_pattern
DownstreamHook.remove(name)
filter = false
# result << xml.rstrip if include_end
# thread.raise(Interrupt)
# next(include_end ? nil : xml)
else
# result << xml.rstrip
next(nil)
end
elsif xml =~ start_pattern
filter = true
# result << xml.rstrip
next(nil)
else
xml
end
})
fput command
until (xml = get) =~ start_pattern; end
result << xml.rstrip
until (xml = get) =~ end_pattern
result << xml.rstrip
end
if include_end
result << xml.rstrip
end
}
rescue Interrupt
nil
end
return result
end
def self.run(script)
@script = script
script.want_downstream = false
script.want_downstream_xml = true
before_dying { DownstreamHook.remove('sortedskills_downstream_hook') }
word = script.vars[1] || ''
word.downcase!
unless word == '' or word =~ /^(?:fu|ful|full|b|ba|bas|base)$/
put "skills #{script.vars[0]}"
exit
end
result = quiet_command(
"skills #{script.vars[0]}",
/^(?:<dialogData.*<\/dialogData>)? <a.*\/a> \(at level \d+.*skill bonuses/,
/^<prompt/,
true,
10
)
footer = []
category = nil
skills = {}
body = []
mode = :header
result.each do |line|
case mode
when :header
body << line
if line =~ /\| Bonus Ranks/
mode = :body
end
next
when :body
if line =~ /^Training Points:/
mode = :footer
footer << line
next
end
else
footer << line
end
if line == ''
category = nil
next
elsif line == 'Spell Lists'
category = 'Spell Lists'
next
elsif line =~ /^ *((?:Elemental|Mental|Spiritual|Sorcerous) Lore) - (.*?)\./
skills[$1] ||= []
skills[$1] << [$2, line]
elsif line =~ /^ (.*?)\./
skills[category] ||= []
skills[category] << [$1, line]
end
end
first_category = true
@skills_order.each do |category, ordering|
entries = skills[category]
next unless entries
entries.sort_by!{|name, line| ordering[name] or 999} if ordering
if first_category
first_category = false
else
body << ''
end
body << category if category
body += entries.map{|name, line| line}
skills.delete(category)
end
skills.each do |category, entries|
if first_category
first_category = false
else
body << ''
end
body << category if category
body += entries.map{|name, line| line}
end
body += footer
if $frontend == 'wizard'
_respond body.map{|x| strip_xml(x)}
else
_respond body
end
end
end
SortedSkills.run(script)