forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmech-lore.lic
More file actions
118 lines (100 loc) · 3.45 KB
/
mech-lore.lic
File metadata and controls
118 lines (100 loc) · 3.45 KB
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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#mech-lore
=end
custom_require.call(%w[common common-items common-arcana events drinfomon equipmanager])
class MechLore
include DRC
include DRCI
include DRCA
def initialize
@settings = get_settings
@training_spells = @settings.crafting_training_spells
Flags.add('mech-magic-ready', 'You feel fully prepared to cast your spell.')
@equipment_manager = EquipmentManager.new(@settings)
@equipment_manager.wear_equipment_set?('standard')
@equipment_manager.empty_hands
pause 1
fput "remove #{@settings.hand_armor}"
fput "stow #{@settings.hand_armor}"
pause 1
release_invisibility
if @settings.braid_item
braid_to_fail(@settings.braid_item)
else
braid_to_fail(DRSkill.getrank('Outdoorsmanship') < 110 ? 'grass' : 'vine')
end
@equipment_manager.empty_hands
fput "get my #{@settings.hand_armor}"
fput "wear my #{@settings.hand_armor}"
end
def braid_to_fail(item)
return if left_hand || right_hand
return unless forage?(item)
loop do
waitrt?
magic_routine
case bput("braid my #{item}", 'You need to have more', 'Roundtime', 'You need both hands to do that', 'You can\'t braid the .* into your braided', 'is already as long as you can make it', 'You are in no condition')
when 'Roundtime'
rt = reget(10, 'Roundtime').last.scan(/\d+/).first.to_i
break if rt >= 8 || DRSkill.getxp('Mechanical Lore') >= 30
when 'is already as long as you can make it'
waitrt?
break
when 'You need both hands to do that', /into your braided/
waitrt?
empty_trash
return
when 'You are in no condition'
dispose_trash(item)
wait_for_script_to_complete('safe-room')
return
else
break unless forage?(item)
end
end
pause 1
waitrt?
bput("pull my #{item}", 'You tug and pull')
pause 1
waitrt?
empty_trash
magic_cleanup
end
# TODO: Share code with crossing-training
def empty_trash
trash_nouns = get_data('items').trash_nouns
if trash_nouns.any? { |noun| /\b#{noun}/i =~ GameObj.right_hand.noun } && !@equipment_manager.is_listed_item?(right_hand)
dispose_trash(right_hand)
end
if trash_nouns.any? { |noun| /\b#{noun}/i =~ GameObj.left_hand.noun } && !@equipment_manager.is_listed_item?(left_hand)
dispose_trash(left_hand)
end
end
def magic_routine
return unless @training_spells
needs_training = %w[Warding Utility Augmentation]
.select { |skill| @training_spells[skill] }
.select { |skill| DRSkill.getxp(skill) < 31 }
.sort_by { |skill| DRSkill.getxp(skill) }.first
return unless needs_training
data = @training_spells[needs_training]
if Flags['mech-magic-ready'] && mana > 40
crafting_cast_spell(data, @settings)
Flags.reset('mech-magic-ready')
@preparing = false
end
return if @preparing
crafting_prepare_spell(data, @settings)
@preparing = true
end
def magic_cleanup
return unless @training_spells
bput('release spell', 'You let your concentration lapse', "You aren't preparing a spell")
bput('release mana', 'You release all', "You aren't harnessing any mana")
bput('release symb', "But you haven't", 'You release', 'Repeat this command')
end
end
before_dying do
Flags.delete('mech-magic-ready')
end
MechLore.new