Skip to content

Commit

Permalink
sort-scrolls - Added unleash option
Browse files Browse the repository at this point in the history
Added option to specify a scroll to pull out, cast unleash on it, and then cast the spell if it was successful.

A waggle set for unleash is needed for this.  It needs to be set as follows, but you can edit how much mana you want to cast unleash at:

```
waggle_sets:
  unleash:
    Unleash:
      mana: 15
      cast: cast scroll
```
For this functionality I added 2 new yaml settings, `unleash_mana` and `unleash_harnesses`.  They are both integers and `unleash_mana` is the total mana you want to cast the unleased spell at and `unleash_harnesses` is how many times you want to harness to hold that much mana for the cast.

For example, if you set `unleash_mana` to 100 and then cast unleash on a scroll, it will perceive to see how much mana the spell is prepped at, take 100 - that, and then harness the rest by harnessing `unleash_harnesses` times.

I also added the option to specify the  spell by abbreviation so instead of this:
`;sort-scrolls find "whispers of the muse"'
You can now do this:
`;sort-scrolls find wotm`
  • Loading branch information
BinuDR authored Jan 7, 2025
1 parent 62b6212 commit aa678c8
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions sort-scrolls.lic
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ class ScrollSorter
@stacker_container = @settings.scroll_sorter['stacker_container']
@custom_nouns = @settings.scroll_sorter['scroll_nouns']
@scroll_nouns = get_data('items').scroll_nouns + @custom_nouns
@unleash_mana = @settings.scroll_sorter['unleash_mana']
@unleash_harnesses = @settings.scroll_sorter['unleash_harnesses']

arg_definitions =
[
[
{ name: 'container', regex: /\w+/, optional: true, description: 'The container to collect scrolls from' }
{ name: 'container', regex: /\w+/, optional: true, description: 'The container to collect scrolls from.' }
],

[
{ name: 'find', regex: /find/i, description: 'Find the specified spell scroll in your stackers' },
{ name: 'spell', regex: /\w+/i, optional: false, description: 'Name of spell to find. Use full name, enclose in double quotes if more than one word' }
{ name: 'find', regex: /find/i, description: 'Find the specified spell scroll in your stackers.' },
{ name: 'spell', regex: /\w+/i, optional: false, description: 'Name of spell to find. Use full name, enclose in double quotes if more than one word.' }
],
[
{ name: 'unleash', regex: /unleash/i, description: 'Unleash the specified spell scroll in your stackers.'},
{ name: 'spell', regex: /\w+/i, optional: false, description: 'Name of spell to unleash. Use full name, enclose in double quotes if more than one word.' }
]
]

Expand All @@ -38,6 +44,9 @@ class ScrollSorter

if args.find
find_spell(args.spell)
elsif args.unleash
find_spell(args.spell)
unleash_spell
else
sort_scrolls
end
Expand Down Expand Up @@ -82,6 +91,10 @@ class ScrollSorter
return @all_spells.select { |s, _g| s.casecmp(spell) == 0 }.flatten[2]
end

def find_full_spell_name(abbrev)
return @all_spells.select { |s, g, a| a.casecmp(abbrev) == 0 }.flatten[0]
end

def check_scroll(scroll)
case DRC.bput("look my #{scroll}", /It is labeled "(.*)\."/, /Illustrations of complex/)
when /Illustrations of complex/
Expand Down Expand Up @@ -141,6 +154,10 @@ class ScrollSorter
def find_spell(name, guild = nil)
if guild.nil?
guild = find_guild(name)
if guild.nil?
name = find_full_spell_name(name)
guild = find_guild(name)
end
unknown(guild) if guild.nil? || guild == 'Analogous'
end
ord = find_case(guild)
Expand Down Expand Up @@ -171,7 +188,30 @@ class ScrollSorter
end
DRC.bput("pull my #{@stacker}", /This was the last copy/, /Carefully, you remove a copy/)
end
DRC.bput("put my #{@stacker} in my #{@stacker_container}", /You put your/)
stow_and_refactor_cases(guild)
end

def unleash_spell
DRC.wait_for_script_to_complete('buff', ['unleash'])
if DRCA.spell_preparing?
/You are preparing.*spell at (.*) mana/ =~ DRC.bput('per', /You are preparing.*spell at (.*) mana/)
mana = DRC.text2num(Regexp.last_match(1).to_s)
harn = calculate_harness_array((@unleash_mana - mana), @unleash_harnesses)
pause 1 until DRCA.spell_prepared?
DRCA.harness_mana(harn)
DRCA.cast?
else
DRC.message('Unleash failed!')
end
stack_scroll('scroll', check_scroll('scroll'))
end

def calculate_harness_array(number, n)
base_part = number / n
remainder = number % n
parts = Array.new(n, base_part)
remainder.times { |i| parts[i] += 1 }
parts
end
end

Expand Down

0 comments on commit aa678c8

Please sign in to comment.