forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmm.lic
105 lines (96 loc) · 3.39 KB
/
mm.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#mm
=end
custom_require.call(%w[common-arcana common-moonmage events])
class MoonMagery
def initialize
args = get_args
create_flags(args)
@settings = get_settings
if args.locate
locate?(args.person)
elsif args.rift
rift(args.person)
end
destroy_flags
end
def get_args
arg_defs = [
[
{ name: 'locate', regex: /locate/i },
{ name: 'person', regex: /\w+/, description: 'Name of person to locate' }
],
[
{ name: 'rift', regex: /rift/i },
{ name: 'person', regex: /\w+/, description: 'Name of person to rift' }
]
]
parse_args(arg_defs)
end
def create_flags(args)
Flags.add('locate-fail', 'You see a very vague vision of', "The details of #{args.person}'s location are unclear", 'Your vision is not clear enough for your spell to succeed.', 'There doesn\'t seem to be anyone by that name under the skies') if args.person
end
def destroy_flags
Flags.delete('locate-fail')
end
def rift(person)
person = person.capitalize
DRCMM.check_moonwatch
unless UserVars.moons.any? { |moon_name, moon_data| UserVars.moons['visible'].include?(moon_name) && moon_data['timer'] >= 0 }
echo 'No moons available to cast Rift'
return
end
data = if @settings.waggle_sets['rs']
@settings.waggle_sets['rs'].values.first
else
echo "Using discern values for RS. Make a waggle_set called 'rs' to avoid this in the future"
DRCA.check_discern({ 'abbrev' => 'RS' }, @settings)
end
unless locate?(person)
echo "Unable to rift #{person} due to failed locate"
return
end
data['cast'] = "cast #{person}"
DRCA.cast_spell(data, @settings)
end
def locate?(person)
person = person.capitalize
data = if @settings.waggle_sets['locate']
@settings.waggle_sets['locate'].values.first
else
echo "Using discern values for locate. Make a waggle_set called 'locate' to avoid this in the future"
DRCA.check_discern({ 'abbrev' => 'locate' }, @settings)
end
data['cast'] = "cast #{person}"
DRCA.cast_spell(data, @settings)
pause 0.25
if Flags['locate-fail']
case Flags['locate-fail'][0]
when /Your vision is not clear/
echo 'Clear vision was not active when attempting to cast locate. Try again.'
when /seem to be anyone by that name/
echo "#{person} is not in-game"
when /You see a very vague vision of/
echo "Your locate was too weak to pinpoint #{person}"
when /The details of #{person}'s location are unclear/i
echo "Couldn't find #{person}, it is possible they are in a locate warded room."
end
false
else
lines = reget(30).map(&:chomp)
index = lines.find_index('You gesture.')
unless index
echo 'Unable to determine room number'
return false
end
lines = lines[index..-1]
line = lines.find { |each_line| each_line =~ /^\[.*\]$/ }
index = lines.find_index(line)
room_description = lines[index + 1]
room_data = Room.list.find { |room| room.description.find { |item| item =~ /#{room_description.split('.').first}/i } }
echo "#{person} appears to be in room ##{room_data.id}" if room_data
room_data.id
end
end
end
MoonMagery.new