forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossing-repair.lic
134 lines (110 loc) · 4.56 KB
/
crossing-repair.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#crossing-repair
=end
custom_require.call(%w[common common-money common-travel drinfomon equipmanager])
class CrossingRepair
include DRC
include DRCM
include DRCT
def initialize
settings = setup
start_script('performance', ['noclean'])
@repair_info.each do |repairer, items|
echo "Repairing at #{repairer}" if UserVars.crossing_repair_debug
repair_at(repairer['name'], repairer['id'], items)
end
@repair_info.to_a.reverse.each do |(repairer, _items)|
while tickets_left?(repairer)
end
end
deposit_coins(@keep_copper, settings) unless settings.sell_loot_skip_bank
end
def repair(repairer, item, repeat = false)
return unless repairer
return unless item
release_invisibility
if repeat
fput('swap') unless right_hand
command = "give #{repairer}"
else
return unless @equipment_manager.get_item?(item)
command = "give my #{item.short_name} to #{repairer}"
end
case bput(command, "There isn't a scratch on that", "I don't work on those here", "I don't repair those here", 'Just give it to me again', "You don't need to specify the object", "I will not repair something that isn't broken", "Please don't lose this ticket!", "You hand.*#{repairer}", "Lucky for you! That isn't damaged!", 'You will need more coin if I am to be repairing that!', "You can't hand this weapon to another person!")
when "There isn't a scratch on that", "I will not repair something that isn't broken", "Lucky for you! That isn't damaged!", 'You will need more coin if I am to be repairing that!', "I don't repair those here", "You can't hand this weapon to another person!"
@equipment_manager.empty_hands
when "I don't work on those here"
echo "*** ITEM HAS IMPROPER is_leather FLAG: #{item.short_name} ***"
@equipment_manager.empty_hands
when "You don't need to specify the object", 'Just give it to me again'
repair(repairer, item, true)
when "Please don't lose this ticket!", "You hand.*#{repairer}"
bput('stow my ticket', 'You put')
end
end
def tickets_left?(repairer)
if bput("get my #{repairer['name']} ticket", 'What were you referring', 'You get') == 'What were you referring'
return false
end
walk_to(repairer['id'])
turn_in_ticket(repairer['name'])
@equipment_manager.empty_hands
true
end
def turn_in_ticket(repairer, failed = false)
if failed
fput('swap') unless right_hand
command = "give #{repairer}"
else
command = "give my ticket to #{repairer}"
end
case bput(command, 'You hand', 'takes your ticket', "You don't need to specify the object", 'almost done', "Well that isn't gonna be done")
when "You don't need to specify the object"
turn_in_ticket(repairer, true)
when 'almost done', "Well that isn't gonna be done"
pause 30
turn_in_ticket(repairer)
end
end
def repair_at(repairer, target_room, items)
return if items.nil? || items.empty?
return unless walk_to target_room
items.each { |item| repair(repairer, item) }
end
def setup
arg_definitions = [
[
{ name: 'town', regex: /Crossing|River.*|Theren.*|Shard|Hib.*|Ratha/i, optional: true, description: 'Town to sell in' }
]
]
args = parse_args(arg_definitions)
town = args.town.capitalize
if town.start_with?('Hib')
town = 'Hibarnhvidar'
elsif town.start_with?('River')
town = 'Riverhaven'
elsif town.start_with?('Theren')
town = 'Therenborough'
end
settings = get_settings
settings['hometown'] = town if town
@equipment_manager = EquipmentManager.new
@equipment_manager.wear_equipment_set?('standard')
@equipment_manager.empty_hands
@hometown = settings.hometown
@skip_bank = settings.sell_loot_skip_bank
amount, denom = settings.sell_loot_money_on_hand.split(' ')
@keep_copper = convert_to_copper(amount, denom)
@repair_withdrawal_amount = settings.repair_withdrawal_amount
hometown_data = get_data('town')[settings.hometown]
ensure_copper_on_hand(@repair_withdrawal_amount, settings)
# Merge, do not overwrite
@repair_info = { hometown_data['leather_repair'] => @equipment_manager.items.select(&:leather).reject(&:skip_repair) }
.merge(hometown_data['metal_repair'] => @equipment_manager.items.reject(&:leather).reject(&:skip_repair)) { |_key, old, new| old + new }
settings
end
end
before_dying do
stop_script('performance') if Script.running?('performance')
end
CrossingRepair.new