-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinvoke.lic
92 lines (80 loc) · 2.3 KB
/
invoke.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
=begin
This script rummages for a scroll and invokes it
It will empty your hands if needed.
If a target is provided, it will cast at the target. If not, it will leave the spell prepared.
UserVars.scrollsack should be set (;set change scrollsack <container name>)
https://github.com/matt-lowe/lich-scripts
=end
unless defined?(dothis)
echo 'Your version of Lich is too old for this script.'
exit
end
if UserVars.scrollsack.nil? or UserVars.scrollsack.empty?
echo 'You need to set your scrollsack. ;setting change scrollsack <container>'
exit
end
if (script.vars[1] =~ /help/i) or script.vars.empty?
respond
respond 'Usage: ;invoke <spell#> [target]'
respond
exit
elsif script.vars[2]
spell = script.vars[1]
target = script.vars[2..-1].join(' ')
else
spell = script.vars[1]
target = nil
end
return_scroll = proc {
if checkleft =~ /(scroll|paper|papyrus|vellum|palimpsest|parchment)/ || checkright =~ /(scroll|paper|papyrus|vellum|palimpsest|parchment)/
put 'put my ' + $1 + ' in my ' + UserVars.scrollsack
end
}
empty_hands
#
# find the scroll
#
close_scrollsack = false
loop {
rummage_result = dothis "rummage in my #{UserVars.scrollsack} for spell #{spell}", /^What spell are you looking for\?$|^What were you wanting to rummage through\?$|^You'll have to open|^(In the .+)?You rummage/
if rummage_result =~ /and remove/
break
elsif rummage_result =~ /^You'll have to open/
dothis "open my #{UserVars.scrollsack}", /^You open/
close_scrollsack = true
next
else
fill_hands
exit
end
}
#
# if a spell is prepared, release it
#
unless checkprep == 'None'
dothis 'release', /^You feel the magic of your spell rush away from you\.$|^You don't have a prepared spell to release!$/
end
#
# invoke the scroll
#
invoke_result = dothis "invoke #{spell}", /^That spell is not on the|and gesture to invoke/
if invoke_result =~ /^That spell is not on the/
return_scroll.call
fill_hands
exit
end
#
# cast the spell if a target was given
#
if target
dothistimeout "cast at #{target}", 5, /^You gesture|^(?:Cast|Sing) Roundtime/
end
return_scroll.call
fill_hands
#
# close the scrollsack if it was opened
#
if close_scrollsack
dothis "close my #{UserVars.scrollsack}", /^(In the.+)?You close/
end