forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperformance.lic
123 lines (105 loc) · 3.27 KB
/
performance.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#performance
=end
custom_require.call(%w[common common-items drinfomon spellmonitor events])
class Performance
def initialize
no_pause_all
start_time = Time.new.to_i
arg_definitions = [
[
{ name: 'noclean', regex: /noclean/i, optional: true, description: 'Skip cleaning your instrument' },
{ name: 'checksong', regex: /checksong/i, optional: true, description: 'Only check what song to play for best learning then exit.' },
{ name: 'mindstate_goal', regex: /(\d+)/, optional: true, description: 'Train until mindstate >= mindstate_goal' }
]
]
args = parse_args(arg_definitions)
@settings = get_settings
song_list = get_data('perform').perform_options
@mindstate_goal = (args.mindstate_goal || @settings.performance_mindstate_goal).to_i
skip_clean = args.noclean
check_song_only = args.checksong
worn_instrument = @settings.worn_instrument
@instrument = @settings.instrument
is_instrument_worn = @instrument.nil?
@instrument_out = false
@hand_armor = @settings.hand_armor
@hand_armor_removed = false
if worn_instrument
unless DRCI.exists?(worn_instrument)
DRC.message("Could not find #{worn_instrument}")
exit
end
end
if @instrument
if DRCI.exists?(@instrument)
remove_hand_armor_and_get_instrument
else
DRC.message("Could not find #{@instrument}")
exit
end
end
return unless DRC.play_song?(@settings, song_list, is_instrument_worn, skip_clean)
exit if check_song_only
loop do
run_time = Time.new.to_i - start_time
break if run_time > 600
break if done_training?
line = get
pause 0.05 unless line
case line
when /muster the strength to perform/
pause 30
when /You begin (.*)/, /You continue (.*)/, /You find yourself relaxing (.*)/, /You concentrate on your sense of rhythm (.*)/, /You cannot use the/
if done_training?
wear_hand_armor_and_put_away_instrument
exit
end
when /You finish (.*)/
if done_training?
wear_hand_armor_and_put_away_instrument
exit
else
DRC.play_song?(@settings, song_list, is_instrument_worn, skip_clean)
end
when /Perhaps you should find somewhere drier/
wear_hand_armor_and_put_away_instrument
exit
end
end
end
def remove_hand_armor_and_get_instrument
if DRCI.remove_item?(@hand_armor) && DRCI.stow_item?(@hand_armor)
@hand_armor_removed = true
else
DRC.message("Could not remove or stow #{@hand_armor}, exiting")
exit
end
if DRCI.get_item?(@instrument)
@instrument_out = true
else
DRC.message("Could not get #{@instrument}, exiting")
exit
end
end
def wear_hand_armor_and_put_away_instrument
if @instrument_out
DRCI.stow_item?(@instrument)
end
if @hand_armor_removed
DRCI.get_item?(@hand_armor)
DRCI.wear_item?(@hand_armor)
end
end
def done_training?
DRSkill.getxp('Performance') >= @mindstate_goal
end
def stop_play
DRC.stop_playing
Flags['ct-song'] = true
end
end
before_dying do
fput('stop play')
end
Performance.new