-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdragstop.lic
105 lines (89 loc) · 3.49 KB
/
dragstop.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
If you are dragging someone and arrive at a room tagged as 'town' (i.e. TSC) or 'voln', automatically stop dragging them.
If you are dragging someone who was dead when you started and they are no longer dead, automatically stop dragging them.
In both cases, you can 'drag <target>' again to resume automatic dragging if you did not want it to stop for some reason.
Recommended:
;autostart add --global dragstop
;repo set-updatable dragstop
;dragstop
author: LostRanger (thisgenericname@gmail.com)
game: GemStone
tags: utility
required: Lich >= 4.6.0.
version: 0.1 (2019-07-26)
changelog:
version 0.1 (2019-07-26)
* Initial release.
=end
script.want_downstream = false
script.want_downstream_xml = true
target_id = nil
target_name = nil
target_dead = false
room_id = Room.current.id
DRAG_PATTERN = /^You are now automatically attempting to drag <a exist="(-\d+)" noun="([A-Z][a-z]+)">[A-Z][a-z]+<|^Clearing your default dragging target\.$|^I could not find your default dragging target\. Clearing it\.$|^You grab .*<a exist="(-?\d+)".*with you\.\.\.$/
DEAD_PATTERN = /\bdead\b/
# Some rooms are not always ID'd correctly by Lich.
# This is a list of those that are nodes (and their IDs)
NODED_ROOMS = {
"[Town Square Central]" => 288,
}
def stop_dragging(msg)
waitrt?
_respond [
"#{monsterbold_start}#{'-'*40}",
msg,
"#{'-'*40}#{monsterbold_end}",
]
fput "drag stop"
end
while true
while (line = get)
if line =~ DRAG_PATTERN
if $1 # Starting to autodrag
target_id = $1
target_name = $2
target = GameObj.pcs.find{|x| x.id==target_id}
room_id = Room.current.id or NODED_ROOMS[XMLData.room_title]
unless target
echo "Target #{target_name} not found in room PCs!"
redo
end
target_dead = (target.status =~ DEAD_PATTERN) && true || false
echo "Target acquired: ##{target_id} #{target_name} dead:#{target_dead.inspect}"
next
end
next unless target_id # Skip all the other work if we're not dragging anything.
if $3 # Dragged something
next if $3 == target_id
echo "Target cleared since you dragged something else."
else
echo "Target lost."
end
target_id = nil
next
end
next unless target_id # Skip all the other work if we're not dragging anything.
cur = Room.current
new_room_id = cur.id or NODED_ROOMS[XMLData.room_title]
unless new_room_id == room_id
if NODED_ROOMS[XMLData.room_title] or (cur.id and cur.tags.include?("town"))
stop_dragging("Current room is #{XMLData.room_title}, in town. Stopping dragging.")
target_id = nil
next
elsif cur.id and cur.tags.include?("voln")
stop_dragging("Current room is #{XMLData.room_title}, at Voln. Stopping dragging.")
target_id = nil
next
end
end
if target_dead
target = GameObj.pcs.find{|x| x.id==target_id}
next unless target # Lich race conditions woo
unless target.status =~ DEAD_PATTERN
stop_dragging("Target #{target_name} is alive! Stopping dragging.")
target_id = nil
end
end
end
end