-
Notifications
You must be signed in to change notification settings - Fork 178
/
esp.lic
84 lines (74 loc) · 3.06 KB
/
esp.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#esp
=end
custom_require.call(%w[common common-items])
class ESP
def initialize
@all_channels = ['General', 'Trade', 'Guild', 'Race', 'Local', 'Private', 'Personal']
settings = get_settings
channels = settings.esp_channels.map { |channel| channel.downcase.capitalize }
esp_listen_all = settings.esp_listen_all
default_channel = settings.esp_default_channel
if activate_gweth?
listen_to_these_channels_and_not_others(channels) unless esp_listen_all
fput("esp listen all") if esp_listen_all
set_default_send_channel(default_channel)
show_channel_subscriptions
end
end
def show_channel_subscriptions
fput('esp channel')
end
def set_default_send_channel(channel)
DRC.bput("esp send #{channel}", "You prepare to project your thoughts into the #{channel} channel", "You are already sending thoughts to the #{channel} channel")
end
def listen_to_these_channels_and_not_others(channels)
@all_channels.each do |channel|
listen = channels.include?(channel)
update_channel_subscription(channel, listen)
end
end
def update_channel_subscription(channel, listen)
# We don't have an easy way to know whether you are or are not currently
# listening to a channel, but the `esp listen <channel>` command toggles it.
# So we check if the listen attempt aligns with our goal, and if not, retry.
case DRC.bput("esp listen #{channel}", /With a moment of focus,? you (open|close) your mind to the #{channel} channel/, /ESP controls your ability to listen and send/)
when /With a moment of focus,? you (open|close) your mind to the #{channel} channel/
listening = Regexp.last_match[1] == 'open'
if listen != listening
update_channel_subscription(channel, listen)
end
else
DRC.message("Unrecognized channel: #{channel}")
end
end
def activate_gweth?(retry_on_fail = true)
case DRC.bput("touch my gweth", { 'timeout' => 3, 'suppress_no_match' => true }, "A chorus of foreign thoughts joins your own", "Since you already have telepathy, nothing more happens", "Touch what?", "The chain snaps in two places and falls to the ground")
when /A chorus of foreign thoughts joins your own/, /Since you already have telepathy, nothing more happens/
return true
when /Touch what?/
DRC.message("You don't have a gweth!")
exit
when /The chain snaps in two places and falls to the ground/
DRC.message("Uh oh, your gweth broke!")
exit
else
# Not wearing a gweth, try to wear one and retry
if retry_on_fail
unless DRCI.get_item_if_not_held?('gwethdesuan')
DRC.message("Failed to get gweth to wear!")
exit
end
unless DRCI.wear_item?('gwethdesuan')
DRC.message("Failed to wear gweth!")
exit
end
# Avoid loop and don't retry if this fails, too
return activate_gweth?(false)
end
return false
end
end
end
# Don't auto-run during unit tests
ESP.new unless $_TEST_MODE_