-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3_buffrequests.inc
executable file
·182 lines (138 loc) · 5.4 KB
/
p3_buffrequests.inc
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
SUB p3_buffrequests_init {
|WORKING VARS
/declare buffQueue list outer
/declare brOOMEmoteTimer timer outer 0
/declare repeatBuffsQueue list outer
/declare needsBuffPlayerQueue list outer
| INI DEFAULTS
/declare brEnabled bool outer FALSE
/declare brSameGuildOnly bool outer TRUE
/declare brMinMana int outer 25
/declare brReplyViaTell bool outer TRUE
/declare brDoEmotes bool outer TRUE
| IMPORT INI
/varset brEnabled ${getBotIniOption[BuffRequestOptions.AcceptBuffRequests,${brEnabled}]}
/varset brSameGuildOnly ${getBotIniOption[BuffRequestOptions.SameGuildOnly,${brSameGuildOnly}]}
/varset brMinMana ${getBotIniOption[BuffRequestOptions.MinimumMana,${brMinMana}]}
/varset brReplyViaTell ${getBotIniOption[BuffRequestOptions.ReplyViaTell,${brReplyViaTell}]}
/varset brDoEmotes ${getBotIniOption[BuffRequestOptions.DoEmotes,${brDoEmotes}]}
/if (${iniBuffRequests[1,1].Equal[-]}) /varset brEnabled FALSE
/RETURN
}
SUB buffrequestsMaintenance() {
/if (${brEnabled}==TRUE) {
/if (${Me.Invis}==TRUE) /return
/if (${Me.Casting.ID}!=0) /return
/if (${movingTimer}>0 && ${canCastWhileMoving}==FALSE) /return
/call checkNeedsBuffsQueue
/call checkBuffRequestQueue
/call checkRepeatBuffsQueue
}
/RETURN
}
SUB checkNeedsBuffsQueue() {
/if (${needsBuffPlayerQueue.Count}==0) /return
/if (${buffQueue.Count}>0) /return
/declare i int local
/declare buffName string local
/declare spawnID int local
/declare queueEntry string local
/declare spellName string local
/declare spawnName string local
/varset spawnID ${Spawn[pc ${needsBuffPlayerQueue.Head[]}].ID}
/varset spawnName ${Spawn[id ${spawnID}].CleanName}
/call fullTarget ${spawnID}
/if (${Macro.Return}==FALSE) /RETURN
/for i 1 to ${iniBuffRequests.Size}
/if (${iniBuffRequests[${i},1].Equal[-]}) /break
/varset spellName ${iniBuffRequests[${i},1]}
/varset queueEntry ${spawnID}_${spellName}_${i}
/if (${Select[EMOTABLE,${iniBuffRequests[${i},${bKeyword}]},]}==0) /continue
/if (${iniBuffRequests[${i},${bRequireTargetClass}].NotEqual[-]}) {
/if (${Select[${Spawn[id ${spawnID}].Class.ShortName},${iniBuffRequests[${i},${bRequireTargetClass}]}]}==0) /continue
}
/if (${Target.Buff[${spellName}].ID}==NULL) {
/invoke ${buffQueue.Append[${queueEntry}]}
}
/next i
/RETURN
}
SUB checkBuffRequestQueue() {
/declare e string local
/declare targetID int local
/declare buffName string local
/declare createRecheckTimer bool local FALSE
/declare ei int local
/declare i int local
/declare lockoutSecs int local
/if (${buffQueue.Count}==0) /return
/if (${Me.PctMana} < ${brMinMana} && ${buffQueue.Count}>0) {
/if (${brOOMEmoteTimer}==0) {
/em is low on mana and will continue buff requests later.
/varset brOOMEmoteTimer 60s
}
/return
}
/for i 0 to ${Math.Calc[ ${buffQueue.Count}-1 ]}
/varset e ${buffQueue.Item[${i}]}
/varset targetID ${e.Token[1,_]}
/varset buffName ${e.Token[2,_]}
/varset ei ${e.Token[3,_]}
/varset createRecheckTimer ${e.Token[4,_]}
/if (${Spawn[pc id ${targetID}].ID}==NULL) {
/invoke ${buffQueue.Erase[${i}]}
/break
}
/if (${iniBuffRequests[${ei},${bSelfOverMana}].NotEqual[-]}) {
/if (${Me.PctMana} < ${iniBuffRequests[${ei},${bSelfOverMana}]}) /continue
}
/if (${iniBuffRequests[${ei},${bMemInGem}].NotEqual[-]} && ${Me.Gem[${buffName}]}==NULL) {
/call memorizeSpellInGem "${buffName}" ${iniBuffRequests[${ei},${bMemInGem}]}
}
/if (${isCastReady[${buffName}]}==FALSE) {
/continue
}
/invoke (${cq.Append[CAST;SPELL=${buffName};TARGETID=${targetID};SRC=iniBuffRequests;SRCIDX=${ei};ONRESULT=onBuffRequestCastResult;BUFFQUEUEIDX=${i}]})
/next i
/RETURN
}
SUB onBuffRequestCastResult(string result, string opts) {
/declare buffQueueIndex int local ${getStackCommandOpt[${opts},BUFFQUEUEIDX]}
/declare buffIniIndex int local ${getStackCommandOpt[${opts},SRCIDX]}
/declare lockoutSecs int local 0
/declare targetID int local ${buffQueue.Item[${buffQueueIndex}].Token[1,_]}
/declare buffName string local ${buffQueue.Item[${buffQueueIndex}].Token[2,_]}
/declare repeatMode bool local ${buffQueue.Item[${buffQueueIndex}].Token[4,_]}
/if (${result.Find[PASS_]}!=NULL || ${result.Find[FAIL_NOHOLD]}!=NULL) {
/echo Buff request satisfied. Removing from queue. (${buffName})
/invoke ${buffQueue.Erase[${buffQueueIndex}]}
/if (${repeatMode}==TRUE) {
/varset lockoutSecs ${getSpellDurationByRequestName[${buffName}]}
/if (${lockoutSecs}==0) /varset lockoutSecs 30
/if (${lockoutSecs}>45) /varset lockoutSecs ${Math.Calc[${lockoutSecs}-12]}
/call lockout "${targetID}_${buffIniIndex}" ${Math.Calc[${lockoutSecs}*10]}
/echo Locked out ${buffName} from repeat-buff queue for ${lockoutSecs}s.
}
} else {
/echo Buff did not apply. Will leave in queue.
}
/RETURN
}
SUB checkRepeatBuffsQueue
/declare i int local
/declare e string local
/declare targetID int local
/declare entryIndex int local
/declare castRequest string local
/if (${repeatBuffsQueue.Count}==0) /return
/for i 0 to ${Math.Calc[ ${repeatBuffsQueue.Count}-1 ]}
/varset e ${repeatBuffsQueue.Item[${i}]}
/if (${isLockoutExpired[${e}]}==TRUE) {
/varset targetID ${e.Token[1,_]}
/varset entryIndex ${e.Token[2,_]}
/varset castRequest ${iniBuffRequests[${entryIndex},1]}
/if (${buffQueue.Index[${targetID}_${castRequest}_${entryIndex}_1]}>-1) /continue
/invoke ${buffQueue.Append[${targetID}_${castRequest}_${entryIndex}_1]}
}
/next i
/RETURN