forked from jrad2017/gs4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisarm-no-more.lic
187 lines (170 loc) · 6.59 KB
/
disarm-no-more.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
=begin
This script monitors your right hand and left hand to make sure you're carrying your weapon and shield/off hand.
The following happens if your weapon is not in your right hand or shield/off hand isn't in your left hand:
Script will kill go2 if it's running.
Script will tell you which room it thought you were in the last time it saw your weapon or shield in your hands.
Script will run back to that room if it's not the room you're currently in.
Script will automatically pick up your weapon and shield if it sees it on the ground in any room.
Script will attempt to grab your weapon and shield (in one of your containers or on the ground) when it has reached the room it thought you were in when you lost it.
This script will always attempt to pick up your weapon or shield off the ground for any reason; disarmed, itch curse, you accidentally dropped it, etc.
Start the script with your weapon in your right hand and your shield/off hand in your left hand.
Starting the script as ;disarm-no-more <#> will make the script wait X number of seconds before grabbing your weapon/off hand after you stowed it.
Example: ;disarm-no-more 5 will make the script wait 5 seconds after it sees you stow your weapon/off hand before grabbing it. Script will always grab your weapon/off hand off the ground as soon as it sees it there.
This script works with bigshot, sloot and loot (waitloot) and will not interfere with their functionality.
Author: Tgo01
Version 11
=end
have_weapon = true
have_off_hand = true
weapon = GameObj.right_hand.id
weapon_name = GameObj.right_hand.name
weapon_noun = GameObj.right_hand.noun
room = nil
weapon_search = nil
lost_weapon_updated = nil
off_hand = GameObj.left_hand.id
off_hand_name = GameObj.left_hand.name
off_hand_noun = GameObj.left_hand.noun
off_hand_room = nil
off_hand_search = nil
lost_off_hand_updated = nil
have_weapon = nil if GameObj.right_hand.id == nil
have_off_hand = nil if GameObj.left_hand.id == nil
swap_okay = nil
#NOTE: The only value which disables run is 0
Vars["#{script.name}-run"] ||= true
Thread.new {
loop{
if GameObj.right_hand.id == off_hand && swap_okay
waitrt?
fput "swap"
swap_okay = nil
end
weapon_search = GameObj.loot.find { |loot| loot.id == weapon }
if weapon_search != nil
pause_script 'bigshot' if running? 'bigshot'
wait_while{ running?('sloot') } if running? 'sloot'
wait_while{ running?('waitloot') } if running? 'waitloot'
waitrt?
fput "get ##{weapon}"
weapon_search = nil
unpause_script 'bigshot' if running? 'bigshot'
end
off_hand_search = GameObj.loot.find { |loot| loot.id == off_hand }
if off_hand_search != nil
pause_script 'bigshot' if running? 'bigshot'
wait_while{ running?('sloot') } if running? 'sloot'
wait_while{ running?('waitloot') } if running? 'waitloot'
waitrt?
fput "get ##{off_hand}"
off_hand_search = nil
unpause_script 'bigshot' if running? 'bigshot'
end
if GameObj.left_hand.id == weapon && swap_okay
waitrt?
fput "swap"
swap_okay = nil
end
sleep 0.1
}
}
Thread.new {
loop{
if GameObj.right_hand.id != weapon && lost_weapon_updated == nil && have_weapon
room = Room.current.id
lost_weapon_updated = true
end
if GameObj.left_hand.id != off_hand && lost_off_hand_updated == nil && have_off_hand
off_hand_room = Room.current.id
lost_off_hand_updated = true
end
lost_weapon_updated = nil if GameObj.right_hand.id == weapon && lost_weapon_updated == true && have_weapon
lost_off_hand_updated = nil if GameObj.left_hand.id == off_hand && lost_off_hand_updated == true && have_off_hand
sleep 0.1
}
}
def attempt_recovery noun
if Spell[218].active? && GameObj.npcs.any? { |npc| npc.noun == 'spirit' }
waitrt?
fput "tell spirit to give #{weapon_noun} #{Char.name}"
else
fput "get ##{noun}"
end
end
loop{
if (GameObj.right_hand.id != weapon && have_weapon) or (GameObj.left_hand.id != off_hand && have_off_hand) && Room.current.id != 10815 && Room.current.id != 10817 && Room.current.id != 10821
pause_script 'bigshot' if running? 'bigshot'
wait_while{ running?('sloot') } if running? 'sloot'
wait_while{ running?('waitloot') } if running? 'waitloot'
if running? 'go2'
sleep 1
elsif script.vars[1] != nil
sleep Integer(script.vars[1])
end
if GameObj.left_hand.id == weapon
waitrt?
fput "swap";sleep 0.3
end
if GameObj.right_hand.id != weapon && have_weapon
if weapon_name =~ /sonic/i
waitrt?
waitcastrt?
multifput "prep 1012", "sing #{weapon_noun}"
weapon = GameObj.right_hand.id
else
attempt_recovery weapon
swap_okay = GameObj.right_hand.id == weapon
if !swap_okay && room != nil && Vars["#{script.name}-run"] != "0"
stop_script 'go2' if running? 'go2'
stop_script 'wander' if running? 'wander'
echo "Last time you were holding your weapon was in or around room number #{room}." if have_weapon
echo "Last time you were holding your shield/off hand was in or around room number #{off_hand_room}." if off_hand_room != nil && have_off_hand
start_script "go2", [room] if Room.current.id != room && room != nil
wait_while{ running?('go2') }
waitrt?
attempt_recovery weapon
swap_okay = true
elsif !swap_okay
fput "recite I appear to have lost my #{weapon_noun} somewhere near #{room}.;Help!"
end
wait_until {GameObj.right_hand.id == weapon}
end
end
room = nil
swap_okay = nil
if GameObj.right_hand.id == off_hand
waitrt?
fput "swap"
sleep 0.3
end
if GameObj.left_hand.id != off_hand && have_off_hand
if off_hand_name =~ /sonic/i
waitrt?
waitcastrt?
multifput "prep 1009", "sing #{off_hand_noun}"
off_hand = GameObj.left_hand.id
else
attempt_recovery off_hand
swap_okay = GameObj.left_hand.id == off_hand
if !swap_okay && off_hand_room != nil && Vars["#{script.name}-run"] != "0"
stop_script 'go2' if running? 'go2'
stop_script 'wander' if running? 'wander'
echo "Last time you were holding your weapon was in or around room number #{room}." if room != nil && have_weapon
echo "Last time you were holding your shield/off hand was in or around room number #{off_hand_room}." if off_hand_room != nil && have_off_hand
start_script "go2", [off_hand_room] if Room.current.id != off_hand_room && off_hand_room != nil
wait_while{ running?('go2') }
waitrt?
attempt_recovery off_hand
swap_okay = true
elsif !swap_okay
fput "recite I appear to have lost my #{off_hand_name} near #{off_hand_room}.;Help!"
end
wait_until { GameObj.left_hand.id == off_hand}
end
end
off_hand_room = nil
swap_okay = nil
unpause_script 'bigshot' if running? 'bigshot'
end
sleep 0.1
}