-
Notifications
You must be signed in to change notification settings - Fork 8
/
chargeimbed.lic
158 lines (146 loc) · 5.59 KB
/
chargeimbed.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
=begin
This script monitors how much mana is used per rub while using Charge Item
and reports how many charges are added to the item.
If useimbed.lic is being used to track the number of charges left in the
imbed as you use it, this script updates that tracking as you charge the
item (unless it's a common item).
author: Tillmen (tillmen@lichproject.org)
game: Gemstone
tags: magic
version: 0.2
changelog:
2015-07-06 (0.2):
pull mana directly from the XML stream to avoid race conditions
=end
added_mana = 0
added_charges = 0
item_id = nil
$items ||= Hash.new
start_mana = XMLData.mana
common_items = {
'oaken wand' => 108,
'splintered oak wand' => 108,
'blue crystal' => 117,
'twisted wand' => 702,
'pale thanot wand' => 708,
'silver wand' => 901,
'polished silver wand' => 901,
'iron wand' => 901,
'hollow iron wand' => 901,
'aquamarine wand' => 903,
'coiled aquamarine wand' => 903,
'gold wand' => 906,
'burnished gold wand' => 906,
'metal wand' => 907,
'stout metal wand' => 907,
'pinch of powdered iron filings' => 1704,
'green coral wand' => 1707,
'smooth amber wand' => 1708,
'crystal wand' => 1710,
'etched crystal wand' => 1710,
'heavy quartz orb' => 1711,
'small statue' => 1712,
'scattering of deathstone granules' => 1713,
'some fine firestone dust' => 1715,
}
mana_per_charge = proc { |spell_num|
spell_circle = spell_num.to_s[0...-2].to_i
spell_level = spell_num.to_s[-2..-1].to_i
if [4,5,9,10].include?(spell_circle)
base_cost = spell_level
elsif spell_circle == 7
base_cost = spell_level * 2
elsif [1,2,3,6,11,16].include?(spell_circle)
base_cost = spell_level * 3
elsif spell_circle == 17
if [4,7,9,10,12,13,15].include?(spell_num)
base_cost = spell_level
else
base_cost = spell_level * 3
end
else
echo 'fixme: weird spell circle'
base_cost = spell_level * 3
end
[spell_level, (base_cost - (Skills.emc/5))].max
}
show_stats = proc {
respond
respond '--- Charge Session Stats'
respond
respond 'item name charges mana'
respond '------------------------------- ------- ----'
$items.each_pair { |item_id,hash|
if hash[:added_charges]
respond "#{hash[:name].ljust(31)} #{hash[:added_charges].to_s.rjust(7)}"
else
respond "#{hash[:name].ljust(31)} #{hash[:added_mana].to_s.rjust(4)}"
end
}
respond
}
before_dying {
show_stats.call
}
status_tags
loop {
line = get
if line =~ /<.*progressBar id='mana' .*?text='mana (\d+)\/\d+'.*>You gesture over the pulsating orb while holding (?:a |an )?<a exist="([0-9]+)".*?>(.*?)<\/a> near it\./
end_mana = $1.to_i
item_id = $2
$items[item_id] ||= Hash.new
$items[item_id][:name] ||= $3
# Report the number of charges or mana added
if spell_num = common_items[$items[item_id][:name]]
added_charges = ((start_mana - end_mana)/mana_per_charge[spell_num].to_f).round
added_mana = nil
$items[item_id][:added_charges] = $items[item_id][:added_charges].to_i + added_charges
sleep 0.1
respond "[ charges added: #{added_charges}, total added: #{$items[item_id][:added_charges]} ]"
elsif spell_num = UserVars.imbeds[$items[item_id][:name]][:spell]
added_charges = ((start_mana - end_mana)/mana_per_charge[spell_num].to_f).round
added_mana = nil
$items[item_id][:added_charges] = $items[item_id][:added_charges].to_i + added_charges
UserVars.imbeds[$items[item_id][:name]][:charges] = UserVars.imbeds[$items[item_id][:name]][:charges].to_i + added_charges
sleep 0.1
respond "[ charges added: #{added_charges}, total added: #{$items[item_id][:added_charges]} ]"
respond "[ #{$items[item_id][:name]}: #{UserVars.imbeds[$items[item_id][:name]][:charges]} charges remaining. ]"
else
added_charges = nil
added_mana = start_mana - end_mana
$items[item_id][:added_mana] = $items[item_id][:added_mana].to_i + added_mana
sleep 0.1
respond "[ mana added: #{added_mana}, total added: #{$items[item_id][:added_mana]} ]"
end
start_mana = end_mana
else
if line =~ /<.*progressBar id='mana' .*?text='mana (\d+)\/\d+'.*>/
start_mana = $1.to_i
end
if line =~ /^You feel terribly drained\!/
# incorrectly figured the lost mana as charges added, undo that
respond "[ thats not right... ]"
if $items[item_id][:added_charges]
$items[item_id][:added_charges] -= added_charges
if UserVars.imbeds[$items[item_id][:name]]
UserVars.imbeds[$items[item_id][:name]][:charges] =- added_charges
sleep 0.1
respond "[ #{$items[item_id][:name]}: #{UserVars.imbeds[$items[item_id][:name]][:charges]} charges remaining. ]"
else
sleep 0.1
end
respond "[ charges added: 0, total added: #{$items[item_id][:added_charges]} ]"
else
$items[item_id][:added_mana] -= added_mana
sleep 0.1
respond "[ mana added: 0, total added: #{$items[item_id][:added_mana]} ]"
end
elsif line =~ /^The pulsating orb (?:quickly|suddenly) implodes/
show_stats.call
# break
elsif line =~ /expands into a blue pulsating orb!/
minutes = 0
Thread.new { loop { sleep 60; minutes += 1; echo "orb is #{minutes} minutes old" } }
end
end
}