forked from CL-LA/macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shares.macro
329 lines (314 loc) · 8.75 KB
/
shares.macro
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
setglobal sharesfilerevision "20210225-0100-0001"
//------------------------------------------------
// shares.macro
//------------------------------------------------
// From Gorvin via clmacros.com
// Dynamic Sharecads - This is an enhanced, less-spammy version of Sharecads.
// It takes into consideration the 3 second delay between shares and does not
// waste time trying to share someone you're already sharing with. If several
// healers are cadding you at once, it will try to maintain shares with the
// most recent 5 who have healed you (or less depending on if any shares are
// locked). This also has the added benefit of avoiding the annoying effect
// where you would sometimes share a cadder, only to accidentally unshare another
// who was still healing you (that cadder should automatically be reshared).
// Use "/shcads" to turn on or off.
set gShare_messages 1
set gShare_on 0
set gShare[0] ""
set gShare[1] ""
set gShare[2] ""
set gShare[3] ""
set gShare[4] ""
set gShareCad[0] ""
set gShareCad[1] ""
set gShareCad[2] ""
set gShareCad[3] ""
set gShareCad[4] ""
set gShareIgnore[0] 1
set gShareIgnore[1] 1
set gShareIgnore[2] 1
set gShareIgnore[3] 1
set gShareIgnore[4] 1
set gShare_erase 60
"/shcads"
{
if gShare_on == 1
setglobal gShare_on 0
else
setglobal gShare_on 1
setglobal gShare[0] ""
setglobal gShare[1] ""
setglobal gShare[2] ""
setglobal gShare[3] ""
setglobal gShare[4] ""
setglobal gShareCad[0] ""
setglobal gShareCad[1] ""
setglobal gShareCad[2] ""
setglobal gShareCad[3] ""
setglobal gShareCad[4] ""
setglobal gShareIgnore[0] 1
setglobal gShareIgnore[1] 1
setglobal gShareIgnore[2] 1
setglobal gShareIgnore[3] 1
setglobal gShareIgnore[4] 1
message "* Sharecads is now on."
if @env.textLog.word[0] > 0
set share_ts 2
else
set share_ts 0
end if
set share_init 0
set share_free 5
set share_delay 0
set share_erase 0
set share_check 0
label SHARECADS
if gShare_on == 1
set share_word share_ts
set share_msg @env.textLog
if share_msg.word[share_word] == "You"
set share_word + 1
if share_msg.word[share_word] == "are"
set share_word + 1
if share_msg.word[share_word] == "sharing"
set share_word + 1
if share_msg.word[share_word] == "experiences"
set share_word + 2
call "fShare_update"
set share_init 1
end if
end if
end if
else if share_msg.word[share_word] >= "You"
if share_msg >= "You sense healing energy from"
set share_word + 5
call "fShare_get_who"
set share_ignore 0
call "fShare_push"
set share_check 1
if gShare_messages == 1
message "Healing detected."
end if
end if
end if
if share_erase > 0
set share_erase - 1
if share_erase == 0
setglobal gShare_which 0
label SHAREFLUSH
if gShare_which < 5
setglobal gShareCad[gShare_which] ""
setglobal gShare_which + 1
goto "SHAREFLUSH"
end if
end if
end if
if share_delay > 0
set share_delay - 1
else if share_check == 1
call "fShare_check"
if share_check == 1
set share_erase gShare_erase
set share_delay 12
"/share " share_who "\r"
setglobal gShare_which 5
setglobal gShare_which - share_free
set share_bump share_who
label SHAREADJ
if gShare_which < 5
set share_temp gShare[gShare_which]
setglobal gShare[gShare_which] share_bump
set share_bump share_temp
setglobal gShare_which + 1
goto "SHAREADJ"
end if
end if
end if
pause 1
goto "SHARECADS"
end if
message "* Sharecads is now off."
end if
}
// Checks if need to share cadder.
// Returns:
// share_check - 1 if need to share.
// share_who - who to share if need to.
fShare_check
{
set share_check 0
setglobal gShare_which share_free
label SHARECHECK
// Go through as many cadders in list as have non-locked shares.
if gShare_which > 0
setglobal gShare_which - 1
set share_who gShareCad[gShare_which]
if share_who != ""
if gShareIgnore[gShare_which] == 0
set share_shares 0
// See if already sharing with this cadder.
label SHARECHECKSH
if share_shares < 5
if share_who != gShare[share_shares]
set share_shares + 1
goto "SHARECHECKSH"
// If already sharing with this cadder, do not share.
end if
// If not already sharing with this cadder, share.
else
set share_check 1
goto "SHARECHECKOUT"
end if
end if
end if
goto "SHARECHECK"
end if
label SHARECHECKOUT
}
// Pushes name into recent cadders list.
// Requires:
// share_new - name to bump
fShare_push
{
setglobal gShare_which 0
set share_lock 5
set share_lock - share_free
// Check if this cadder is already a locked share.
label SHARELOCK
if gShare_which < share_lock
// If is locked share, do not add to cadder list.
if share_new == gShare[gShare_which]
goto "SHAREPUSHOUT"
else
setglobal gShare_which + 1
goto "SHARELOCK"
end if
end if
set share_erase gShare_erase
setglobal gShare_which 0
set share_bump share_new
label SHAREPUSH
set share_temp gShareCad[gShare_which]
set share_tempp gShareIgnore[gShare_which]
setglobal gShareCad[gShare_which] share_bump
setglobal gShareIgnore[gShare_which] share_ignore
set share_bump share_temp
set share_ignore share_tempp
setglobal gShare_which + 1
if share_bump == share_new
else if share_bump == ""
else if gShare_which < share_free
goto "SHAREPUSH"
end if
label SHAREPUSHOUT
setglobal gShare_which share_free
label SHAREREM
if gShare_which < 5
setglobal gShareCad[gShare_which] ""
setglobal gShare_which + 1
goto "SHAREREM"
end if
}
// Updates list of current shares.
// Requires:
// share_msg - @env.textLog message to get info from.
// share_word - word where names begin at.
fShare_update
{
set share_prev[0] gShare[0]
set share_prev[1] gShare[1]
set share_prev[2] gShare[2]
set share_prev[3] gShare[3]
set share_prev[4] gShare[4]
setglobal gShare_who 0
set share_free 5
label SHAREUPDATE
if share_msg.word[share_word] != ""
call "fShare_get_who"
// Check if not expected share.
if share_lock == 0
if share_init == 1
set share_shares 0
// Check if was already in list.
label SHAREALREADY
if share_shares < 5
if share_prev[share_shares] != ""
// If was already in list, not unexpected.
if share_new == share_prev[share_shares]
goto "SHARECONT"
else
set share_shares + 1
goto "SHAREALREADY"
end if
end if
end if
// If were not expecting share, bump onto cadders list
// so it does not accidentally get bumped off.
set share_delay 12
set share_ignore 1
call "fShare_push"
end if
end if
label SHARECONT
setglobal gShare[gShare_who] share_new
setglobal gShare_who + 1
goto "SHAREUPDATE"
end if
label SHAREERASE
if gShare_who < 5
setglobal gShare[gShare_who] ""
setglobal gShare_who + 1
goto "SHAREERASE"
end if
if gShare_messages == 1
message "Share list updated."
end if
}
// Fetches a name from text string.
// Requires:
// share_msg - @env.textLog message to get info from.
// share_word - word where name begin at.
// Returns:
// share_new - new name.
// share_lock - 1 if from share list and locked.
fShare_get_who
{
set share_lock 0
set share_new ""
label SHAREWHO
if share_msg.word[share_word] == ""
else if share_msg.word[share_word] == "and"
set share_word + 1
if share_new == ""
goto "SHAREWHO"
end if
else if share_msg.word[share_word] >= "(*)"
set share_lock 1
set share_free - 1
set share_word + 1
else if share_msg.word[share_word] >= ","
set share_letters share_msg.word[share_word]
set share_which 0
label SHAREL
set share_letter share_letters.letter[share_which]
if share_letter == ","
else if share_letter == "."
else if share_letter == " "
else if share_letter == ""
else
set share_new + share_letter
set share_which + 1
goto "SHAREL"
end if
set share_word + 1
else if share_msg.word[share_word] >= "."
set share_letters share_msg.word[share_word]
set share_which 0
goto "SHAREL"
else
set share_new + share_msg.word[share_word]
set share_word + 1
goto "SHAREWHO"
end if
}
message "===> Loaded shares.macro"