-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3_spellcombat.inc
executable file
·254 lines (194 loc) · 7.94 KB
/
p3_spellcombat.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
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
SUB p3_spellcombat_init {
/call p3RegisterCommand TAGSCHANGED spellcombatTagsChanged 10
/call p3RegisterCommand KILL spellcombatKill 50
/call p3RegisterCommand STOP spellcombatStop 50
/declare combatSpellsCheckTimer timer outer 0
/declare spellKillID int outer 0
/call validateTagsFromArray iniCombatSpells
/RETURN
}
SUB spellcombatTagsChanged() {
/call validateTagsFromArray iniCombatSpells
/RETURN
}
SUB spellcombatKill(string cmd, string opts) {
/varset spellKillID ${getStackCommandOpt[${opts},SPAWNID]}
/RETURN
}
SUB spellcombatStop(string cmd, string opts) {
/varset spellKillID 0
/RETURN
}
SUB spellcombatMaintenance() {
/declare killSpawn spawn local
/if (${spellKillID}==0) /RETURN
/if (${Target.ID} != ${spellKillID}) /RETURN
/if (${Spawn[id ${spellKillID}].ID}==NULL || ${Spawn[id ${spellKillID}].Dead}==TRUE) {
/call spellcombatStop
/RETURN
}
/vardata killSpawn Spawn[id ${spellKillID}]
/if (${killSpawn.ID}==NULL || ${killSpawn.Dead}==TRUE) {
/call spellcombatStop
/RETURN
}
/if (${assistMustHaveName.NotEqual[FALSE]}) {
/if (${killSpawn.CleanName.Upper.Find[${assistMustHaveName.Upper}]}==NULL) {
/call spellcombatStop
/RETURN
}
}
/if (${assistMustNotHaveName.NotEqual[FALSE]}) {
/if (${killSpawn.CleanName.Upper.Find[${assistMustNotHaveName.Upper}]}!=NULL) {
/call spellcombatStop
/RETURN
}
}
/if (${spellKillID}!=0) {
/call checkCombatSpells
}
/RETURN
}
SUB checkCombatSpells {
/if (${combatSpellsCheckTimer}>0) /return
/if (${Me.Casting.ID}!=NULL && ${Me.Class.ShortName.NotEqual[BRD]}) /return
/varset combatSpellsCheckTimer 5
/declare i int local
/declare cSpell spell local
/declare cSpellName string local
/declare maxResists int local 5
/declare currentResistCount int local 0
/declare cancelConditions string local
/declare ignoreDistanceCheck bool local FALSE
/declare lifeDeficit int local
/declare lifeRatio int local
/for i 1 to ${iniCombatSpells.Size}
/varset cSpellName ${iniCombatSpells[${i},1]}
/varset currentResistCount 0
/varset maxResists 5
/varset cancelConditions TARGETDEAD|
/varset ignoreDistanceCheck FALSE
/if (${cSpellName.Equal[-]}) /break
/if (${iniCombatSpells[${i},${bEnabled}].Equal[NO]}) /continue
/if (${iniCombatSpells[${i},${bTagsInvalidated}].Equal[YES]}) /continue
/if (${iniCombatSpells[${i},${bNotIfMounted}].NotEqual[-]}) {
/if (${Me.Mount.ID}!=NULL) /CONTINUE
}
/if (${iniCombatSpells[${i},${bAutoDebuffOnly}].NotEqual[-]}) {
/continue
}
/if (${iniCombatSpells[${i},${bSelfOverAggro}].NotEqual[-]}) {
/if (${Me.PctAggro} < ${iniCombatSpells[${i},${bSelfOverAggro}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bSelfUnderAggro}].NotEqual[-]}) {
/if (${Me.PctAggro} > ${iniCombatSpells[${i},${bSelfUnderAggro}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bRequireCastIdle}].NotEqual[-]}) {
/if (${idleCastingTimer}>0) /CONTINUE
}
/if (${iniCombatSpells[${i},${bGiftOfMana}].NotEqual[-]}) {
/if (${Me.Song[Gift Of Mana].ID}==NULL) /continue
}
/if (${iniCombatSpells[${i},${bTargetHasBuff}].NotEqual[-]}) {
/if (${Target.Buff[${iniCombatSpells[${i},${bTargetHasBuff}]}].ID}==NULL) /continue
}
/if (${iniCombatSpells[${i},${bTargetDoesntHaveBuff}].NotEqual[-]}) {
/if (${Target.Buff[${iniCombatSpells[${i},${bTargetDoesntHaveBuff}]}].ID}!=NULL) /continue
}
/if (${iniCombatSpells[${i},${bMaxResists}].NotEqual[-]}) {
/varset maxResists ${iniCombatSpells[${i},${bMaxResists}]}
}
/if (${iniCombatSpells[${i},${bSelfOverMana}].NotEqual[-]}) {
/if (${Me.PctMana} <= ${iniCombatSpells[${i},${bSelfOverMana}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bSelfUnderHP}].NotEqual[-]}) {
/if (${Me.PctHPs} >= ${iniCombatSpells[${i},${bSelfUnderHP}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bSelfOverHP}].NotEqual[-]}) {
/if (${Me.PctHPs} < ${iniCombatSpells[${i},${bSelfOverHP}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bSelfUnderMana}].NotEqual[-]}) {
/if (${Me.PctMana} >= ${iniCombatSpells[${i},${bSelfUnderMana}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bSelfOverMana}].NotEqual[-]}) {
/if (${Me.PctMana} < ${iniCombatSpells[${i},${bSelfOverMana}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bSelfUnderEnd}].NotEqual[-]}) {
/if (${Me.PctEndurance} >= ${iniCombatSpells[${i},${bSelfUnderEnd}]} ) /CONTINUE
}
/if (${iniCombatSpells[${i},${bSelfOverEnd}].NotEqual[-]}) {
/if (${Me.PctEndurance} < ${iniCombatSpells[${i},${bSelfOverEnd}]} ) /CONTINUE
}
/if (${iniCombatSpells[${i},${bTargetOverLevel}].NotEqual[-]}) {
/if (${Spawn[id ${spellKillID}].Level} < ${iniCombatSpells[${i},${bTargetOverLevel}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bTargetUnderLevel}].NotEqual[-]}) {
/if (${Spawn[id ${spellKillID}].Level} >= ${iniCombatSpells[${i},${bTargetUnderLevel}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bRequireBodyType}].NotEqual[-]}) {
/if (${Select[${Spawn[id ${spellKillID}].Body.Name},${iniCombatSpells[${i},${bRequireBodyType}]}]}==0) /CONTINUE
}
/if (${iniCombatSpells[${i},${bTargetRace}].NotEqual[-]}) {
/if (${Select[${Spawn[id ${spellKillID}].Race},${iniCombatSpells[${i},${bTargetRace}]}]}==0) /CONTINUE
}
/if (${iniCombatSpells[${i},${bRequireMobsInProximity}].NotEqual[-]}) {
/if (${SpawnCount[npc loc ${Me.X} ${Me.Y} radius 25]} < ${iniCombatSpells[${i},${bRequireMobsInProximity}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bRequireMaxMobsInProximity}].NotEqual[-]}) {
/if (${SpawnCount[npc loc ${Me.X} ${Me.Y} radius 45]} > ${iniCombatSpells[${i},${bRequireMaxMobsInProximity}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bRequireTargetClass}].NotEqual[-]}) {
/if (${Select[${Spawn[id ${spellKillID}].Class.ShortName},${iniCombatSpells[${i},${bRequireTargetClass}]}]}==0) /CONTINUE
}
/if (${iniCombatSpells[${i},${bTargetOverHP}].NotEqual[-]}) {
/call fullTarget ${spellKillID}
/if (${Macro.Return}==FALSE) /CONTINUE
/if (${Target.PctHPs} < ${iniCombatSpells[${i},${bTargetOverHP}]}) /CONTINUE
/varset cancelConditions ${cancelConditions}TARGETUNDERHP:${iniCombatSpells[${i},${bTargetOverHP}]}|
}
/if (${iniCombatSpells[${i},${bTargetUnderHP}].NotEqual[-]}) {
/call fullTarget ${spellKillID}
/if (${Macro.Return}==FALSE) /CONTINUE
/if (${Target.PctHPs} >= ${iniCombatSpells[${i},${bTargetUnderHP}]}) /CONTINUE
}
/if (${iniCombatSpells[${i},${bTargetLifeManaRatio}].NotEqual[-]}) {
/call fullTarget ${spellKillID}
/if (${Macro.Return}==FALSE) /CONTINUE
/varset lifeDeficit ${Math.Calc[100-${Target.PctHPs}]}
/varset lifeRatio ${iniCombatSpells[${i},${bTargetLifeManaRatio}]}
/if (${Me.PctMana} < ${Math.Calc[100-(${lifeDeficit}/${lifeRatio})]}) {
/CONTINUE
}
}
/if (${iniCombatSpells[${i},${bMemInGem}].NotEqual[-]} && ${Me.Gem[${cSpellName}]}==NULL) {
/call memorizeSpellInGem "${cSpellName}" ${iniCombatSpells[${i},${bMemInGem}]}
}
/if (${isCastReady[${cSpellName}]}==FALSE) {
/CONTINUE
}
/if (${iniCombatSpells[${i},${bNoCancelChecks}].NotEqual[-]}) {
/varset cancelConditions TARGETDEAD|
}
/if (${iniCombatSpells[${i},${bIgnoreRangeCheck}].NotEqual[-]}) {
/varset ignoreDistanceCheck TRUE
}
/call getSpellFromCastRequest "${cSpellName}"
/if (${Macro.Return.Equal[UNKNOWN]}) {
/bc Warning: checkCombatSpells() getSpellFromCastRequest() returned UNKNOWN. Not sure what to do.
} else {
/vardata cSpell ${Macro.Return}
/if (${isLockoutExpired[detriTimer_${cSpell.ID}]}==FALSE) /CONTINUE
/if (${isLockoutExpired[detriTimer_${spellKillID}_${cSpell.ID}]}==FALSE) /CONTINUE
/if (${cSpell.MyCastTime}>0 && ${movingTimer}>0) /CONTINUE
}
/if (${ignoreDistanceCheck}==FALSE && ${Spawn[id ${spellKillID}].Distance}>${cSpell.MyRange}) {
/CONTINUE
}
/invoke (${cq.Append[CAST;SPELL=${cSpellName};SPELLID=${cSpell.ID};TARGETID=${spellKillID};CANCELCONDITIONS=${cancelConditions};SRC=combatSpells;SRCIDX=${i};ONRESULT=onCombatCastResult]})
/BREAK
/next i
/RETURN
}
SUB onCombatCastResult(string result, string opts) {
/RETURN
}