-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3_automez.inc
executable file
·201 lines (150 loc) · 5.91 KB
/
p3_automez.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
SUB p3_automez_init() {
/call p3RegisterCommand KILL autoMezKillCheck 5
/declare autoMezList list outer
/declare autoMezCheckTimer timer outer 0
/declare autoMezLastCastIndex int outer 0
/declare autoMezActionTakenTimer timer outer 0
/declare autoMezEnabled bool outer FALSE
/declare autoMezSpell string outer NONE
/declare autoMezTimerMarginSeconds string outer 10
/declare autoMezMustHaveName string outer -
/declare autoMezMobLevels string outer 10 65
/declare autoMezMobRadius string outer 100
/declare autoMezSpawnSearch string outer NPC LOS TARGETABLE
/varset autoMezEnabled ${getBotIniOption[AutoMez.AutoMezEnabled,${autoMezEnabled}]}
/varset autoMezSpell ${getBotIniOption[AutoMez.AutoMezSpell,${autoMezSpell}]}
/varset autoMezMobLevels ${getBotIniOption[AutoMez.AutoMezMobLevelRange,${autoMezMobLevels}]}
/varset autoMezMobRadius ${getBotIniOption[AutoMez.AutoMezMobRadius,${autoMezMobRadius}]}
/varset autoMezTimerMarginSeconds ${getBotIniOption[AutoMez.AutoMezTimerMarginSeconds,${autoMezTimerMarginSeconds}]}
/varset autoMezMustHaveName ${getBotIniOption[AutoMez.AutoMezMustHaveName,${autoMezMustHaveName}]}
/varset autoMezSpawnSearch ${autoMezSpawnSearch} RADIUS ${autoMezMobRadius} RANGE ${autoMezMobLevels}
/RETURN
}
SUB automezMaintenance() {
/if (${autoMezEnabled}==TRUE) {
/call checkAutoMez
/if (${Macro.Return}==TRUE) /varset autoMezActionTakenTimer 100
/if (${Macro.Return}==FALSE && ${autoMezActionTakenTimer}>0) {
/call clearStackActions CAST
}
/if (${autoMezActionTakenTimer}>0) /RETURN RESET
}
/RETURN
}
SUB autoMezKillCheck() {
/if (${autoMezActionTakenTimer}>0) {
/RETURN RESET
}
/RETURN
}
SUB checkAutoMez() {
/if (${autoMezCheckTimer}>0) /RETURN FALSE
/if (${Stick.Active}==TRUE) /RETURN FALSE
/if (${Me.Moving}==TRUE) /RETURN FALSE
/if (${Me.Invis}==TRUE) /RETURN FALSE
/varset autoMezCheckTimer 5
/declare spawnsInRangeCount int local ${SpawnCount[${autoMezSpawnSearch}]}
/declare i int local
/declare j int local
/declare xSpawn spawn local
/declare targetID int local
/declare xSpell spell local
/declare useMezSpell string local
/declare startIndex int local 0
/call getReadyMezSpell
/if (${Macro.Return.Equal[-]}) /RETURN
/varset useMezSpell ${Macro.Return}
/if (${isCastReady[${useMezSpell}]}==FALSE) /RETURN
| SCAN AND ADD CANDIDATES
/if (${spawnsInRangeCount}>0) {
/for i 1 to ${spawnsInRangeCount}
/vardata xSpawn NearestSpawn[${i},${autoMezSpawnSearch}]
/if (${Spawn[id ${xSpawn.ID}].ID}==${assistSpawnID}) /continue
/if (${Spawn[id ${xSpawn.ID}].Dead}==TRUE) /continue
/if (${Spawn[id ${xSpawn.ID}].ID}==NULL) /continue
/if (${Spawn[id ${xSpawn.ID}].Type.Equal[Pet]}) /continue
/if (${isNetBotAttackingID[${xSpawn.ID}]}==TRUE) /continue
/if (${assistSpawnID}==${xSpawn.ID}) /continue
/if (${autoMezMustHaveName.NotEqual[FALSE]}) {
/if (${checkAutoMezNameMatch[${xSpawn.CleanName}]}==FALSE) /continue
}
/if (${autoMezList.Index[${xSpawn.ID}]}==-1) {
|/echo add to maint list: ${xSpawn.ID} ${xSpawn}
/invoke ${autoMezList.Append[${xSpawn.ID}]}
}
/next i
}
| MAINTENANCE: CLEANUP ANYTHING THAT MIGHT BE DEAD OR GONE OR IS BEING ATTACKED BY A NETBOT
/if (${autoMezList.Count}>0) {
/for i ${Math.Calc[${autoMezList.Count}-1]} downto 0
/if (${Spawn[id ${autoMezList.Item[${i}]}].Aggressive}==FALSE || ${autoMezList.Item[${i}]}==${assistSpawnID} || ${Spawn[id ${autoMezList.Item[${i}]}].Dead}==TRUE || ${Spawn[id ${autoMezList.Item[${i}]}].ID}==NULL || ${isNetBotAttackingID[${autoMezList.Item[${i}]}]}==TRUE) {
/call wipeLockout mez_${autoMezList.Item[${i}]}
/invoke ${autoMezList.Erase[${i}]}
/continue
}
/next i
}
/if (${autoMezList.Count}==0) {
/varset autoMezActionTakenTimer 0
/RETURN FALSE
}
/if (${autoMezLastCastIndex} <= ${Math.Calc[${autoMezList.Count}-1]}) /varset startIndex ${autoMezLastCastIndex}
| PROCESS LIST AND MEZ
/for i ${startIndex} to ${Math.Calc[${autoMezList.Count}-1]}
/varset targetID ${autoMezList.Item[${i}]}
/if (${Spawn[id ${targetID}].Dead}) /continue
/call fullTarget ${targetID}
/if (${Target.Mezzed.ID}!=NULL) {
/if (${Target.Mezzed.Duration.TotalSeconds} > ${autoMezTimerMarginSeconds}) {
/echo Detected already-mezzed. locking out for ${Math.Calc[${Target.Mezzed.Duration.TotalSeconds}-${autoMezTimerMarginSeconds}]}s
/call lockout mez_${targetID} ${Math.Calc[(${Target.Mezzed.Duration.TotalSeconds}-${autoMezTimerMarginSeconds}) * 10]}
/continue
}
}
/if (${Target.Mezzed.ID}==NULL || ${isLockoutExpired[mez_${targetID}]}==TRUE) {
/call clearStackActions CAST
/invoke (${cq.Append[CAST;SPELL=${useMezSpell};TARGETID=${targetID};CANCELCONDITIONS=NETBOTATTACKING:${targetID}|TARGETISASSITTARGET;ONRESULT=mezCastRequestResult;]})
/varset autoMezLastCastIndex ${i}
/RETURN TRUE
}
/next i
/varset autoMezLastCastIndex 0
/RETURN FALSE
}
SUB mezCastRequestResult(string result, string opts) {
/declare targetID int local ${getStackCommandOpt[${opts},TARGETID]}
/declare cSpellName string local ${getStackCommandOpt[${opts},SPELL]}
/declare cSpell spell local
/call getSpellFromCastRequest "${cSpellName}"
/vardata cSpell ${Macro.Return}
/if (${result.Find[PASS_]}!=NULL) {
/call lockout mez_${targetID} ${Math.Calc[(${cSpell.Duration.TotalSeconds}-${autoMezTimerMarginSeconds})*10]}
}
/RETURN
}
SUB checkAutoMezNameMatch(string n) {
/declare i int local
/for i 1 to ${Math.Calc[${autoMezMustHaveName.Count[,]}+1]}
/if (${n.Find[${autoMezMustHaveName.Token[${i},,]]}]}!=NULL) {
/RETURN TRUE
}
/next i
/RETURN FALSE
}
SUB getReadyMezSpell() {
/declare i int local
/if (${autoMezSpell.Find[,]}==0) {
/if (${isCastReady[${autoMezSpell}]}==FALSE) {
/RETURN -
} else {
/RETURN ${autoMezSpell}
}
} else {
/for i 1 to ${Math.Calc[${autoMezSpell.Count[,]}+1]}
/if (${isCastReady[${autoMezSpell.Token[${i},,]}]}==TRUE) {
/RETURN ${autoMezSpell.Token[${i},,]}
}
/next i
}
/RETURN -
}