forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_remedies.lic
68 lines (62 loc) · 2.95 KB
/
create_remedies.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#create_remedies
=end
custom_require.call(%w[common])
class CreateRemedies
def initialize
arg_definitions = [
[
{ name: 'target', regex: /\w+/, description: 'Recipe.' },
{ name: 'tools', regex: /tools/i, optional: true, description: 'Use clerk-tools to get and store tools.' },
{ name: 'debug', regex: /debug/i, optional: true, description: 'Debug mode.' },
{ name: 'catalyst', regex: /\w+/i, variable: true, optional: true, description: 'Catalyst to use. Default is coal.' }
]
]
args = parse_args(arg_definitions)
tools = args.tools
debug = args.debug
catalyst = args.catalyst || "coal nugget"
DRC.message("catalyst = #{catalyst}") if debug
# Get recipe
recipe = get_data('recipes').crafting_recipes.find { |each_recipe| each_recipe['name'] =~ /#{args.target}/i }
DRC.message("Recipe is: #{recipe}.") if debug
# Gather first herb section based on settings
herb1 = recipe['herb1']
if herb1 == "red flower"
DRC.message("In herb1 red flower check") if debug
get_prep_herb(herb1) unless DRC.bput("tap first dried flower", "You tap", "What were", "I could not") =~ /You tap/
herb1 = "dried flower"
DRC.message("recipe herb1 is now: #{herb1}") if debug
elsif herb1 == "blue flower"
DRC.message("In herb1 blue flower check") if debug
get_prep_herb(herb1) unless DRC.bput("tap first crushed flower", "You tap", "What were", "I could not") =~ /You tap/
herb1 = "crushed flower"
DRC.message("recipe herb1 is now: #{herb1}") if debug
else
get_prep_herb(recipe['herb1']) unless DRC.bput("tap first #{recipe['herb1']}", "You tap", "What were", "I could not") =~ /You tap/
end
# Gather second herb if necessary
get_prep_herb(recipe['herb2']) unless recipe['herb2'].nil? || DRC.bput("tap first #{recipe['herb2']}", "You tap", "What were", "I could not") =~ /You tap/
# Get tools?
get_store_tools("get") if tools
# Craft call section
if recipe['herb2'].nil?
herb2_needed = 'na'
DRC.wait_for_script_to_complete('remedy', ['remedies', recipe['chapter'], recipe['name'], herb1, herb2_needed, catalyst, recipe['container'], recipe['noun']])
else
DRC.wait_for_script_to_complete('remedy', ['remedies', recipe['chapter'], recipe['name'], herb1, recipe['herb2'], catalyst, recipe['container'], recipe['noun']])
end
# Store tools?
get_store_tools("store") if tools
end
def get_prep_herb(herb)
DRC.wait_for_script_to_complete('alchemy', [herb, 'forage', 25])
DRC.wait_for_script_to_complete('alchemy', [herb, 'prepare'])
end
def get_store_tools(option)
DRC.message("Option for tools is: {option}.") if debug
DRC.wait_for_script_to_complete('clerk-tools', ['alchemy', 'get']) if option == "get"
DRC.wait_for_script_to_complete('clerk-tools', ['alchemy', 'store']) if option == "store"
end
end
CreateRemedies.new