-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgroup_ajar.lic
153 lines (142 loc) · 4.02 KB
/
group_ajar.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
=begin
This script:
- opens your group when you die and closes it again when you get a life
- opens your group when you're stunned and closes it again when you recover
- joins someone when they try to add you to their group, if they're in the list
- adds someone to your group when they try to join you, if they're in the list
;group_ajar help
author: Tillmen ([email protected])
game: Gemstone
version: 0.1
=end
# [group_ajar]>group open You can't do that while being digested!
hide_me
usage_string = "\n"
usage_string.concat "Usage:\n"
usage_string.concat " #{$lich_char}#{script.name} make the script do stuff and junk\n"
usage_string.concat " #{$lich_char}#{script.name} add <name> add a name to the auto join/group list\n"
usage_string.concat " #{$lich_char}#{script.name} del <name> delete a name from the list\n"
usage_string.concat " #{$lich_char}#{script.name} list list the list\n"
usage_string.concat "\n"
CharSettings['allow'] ||= Array.new
if script.vars.empty?
# put 'group close'
Thread.new {
loop {
begin
wait_until { dead? and XMLData.room_title != '[The Belly of the Beast]' }
loop {
loop {
break unless dead?
break if (checkpcs.to_a & UserVars.attacked_me.to_a).empty?
sleep 0.1
}
break unless dead?
put 'group open'
loop {
break unless dead?
break unless (checkpcs.to_a & UserVars.attacked_me.to_a).empty?
sleep 0.1
}
break unless dead?
put 'group close'
}
put 'group close' unless stunned?
rescue
echo $!
puts $!.backtrace[0..1]
end
}
}
Thread.new {
loop {
begin
wait_until { stunned? }
if (UserVars.attacked_me.nil? or (checkpcs.to_a & UserVars.attacked_me.to_a).empty?) and not $_SERVERBUFFER_.any? { |line| line =~ /^<spell exist='spell'>Raise Dead<\/spell>/ }
put 'group open'
end
wait_while { stunned? }
put 'group close' unless dead?
rescue
echo $!
puts $!.backtrace[0..1]
end
}
}
action = proc { |client_string|
begin
if client_string =~ /^(?:<c>)?#{$lich_char}#{script.name} (.*)/
script.downstream_buffer.push(client_string)
nil
else
client_string
end
rescue
UpstreamHook.remove(script.name)
client_string
end
}
before_dying { UpstreamHook.remove(script.name) }
UpstreamHook.add(script.name, action)
while line = get
if line =~ /^(?:<c>)?#{$lich_char}#{script.name} (.*)/
cmd, name = $1.split(' ')
cmd.downcase!
name.capitalize!
if cmd == 'add'
if CharSettings['allow'].include?(name)
echo "#{name} has already been added."
else
CharSettings['allow'].push(name)
echo "#{name} has been added."
end
elsif (cmd == 'del') or (cmd == 'delete')
if CharSettings['allow'].delete(name)
echo "#{name} has been deleted."
else
echo "#{name} was not found."
end
elsif cmd == 'list'
if CharSettings['allow'].empty?
echo '<empty>'
else
echo CharSettings['allow'].join(', ')
end
else
respond usage_string
end
elsif line =~ /^([A-Z][a-z]+) tried to join your group, but your group status is closed\./
if CharSettings['allow'].include?($1)
waitrt?
fput "group #{$1}"
end
elsif line =~ /^([A-Z][a-z]+) tried to (?:add you to (?:his|her) group|hold your hand), but your group status is closed\./
if CharSettings['allow'].include?($1)
waitrt?
fput "join #{$1}"
end
end
end
elsif (script.vars[1].downcase == 'add') and (name = script.vars[2].capitalize)
if CharSettings['allow'].include?(name)
echo "#{name} has already been added."
else
CharSettings['allow'].push(name)
echo "#{name} has been added."
end
exit
elsif (script.vars[1] =~ /^del(?:ete)?$/i) and (name = script.vars[2].capitalize)
if CharSettings['allow'].delete(name)
echo "#{name} has been deleted."
else
echo "#{name} was not found."
end
elsif script.vars[1].downcase == 'list'
if CharSettings['allow'].empty?
echo '<empty>'
else
echo CharSettings['allow'].join(', ')
end
else
respond usage_string
end