-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3_autoloot.inc
executable file
·241 lines (177 loc) · 5.57 KB
/
p3_autoloot.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
SUB p3_autoloot_init() {
/declare looter bool outer FALSE
/declare canLootDuringCombat bool outer FALSE
/declare lootEntries[256,2] string outer -
/declare lootCheckTimer timer outer 0
/declare lootCheckTimerTime string outer 5s
/declare skipCorpseIDs list outer
/declare skipCorpseTrigger bool outer FALSE
/varset looter ${getBotIniOption[Misc.Looter,${looter}]}
/varset canLootDuringCombat ${getBotIniOption[Misc.CanLootDuringCombat,${canLootDuringCombat}]}
/if (${looter}==TRUE) {
/hidec looted
/call loadLootIni
}
/RETURN
}
SUB autolootMaintenance() {
/if (${looter}==FALSE) /RETURN
/if (${lootCheckTimer}>0) /RETURN
/if (${canLootDuringCombat}==FALSE && ${combatStateTimer}>0) /RETURN
/if (${Stick.Active}==TRUE || ${Nav.Active}==TRUE) /return
/if (${Me.FreeInventory}==0 && ${Cursor.ID} != NULL) {
/beep
/g Destroying ${Cursor}
/keypress delete
/delay 3
}
/call checkLoot
/if (${Macro.Return}==FALSE) /RETURN FALSE
/RETURN
}
SUB checkLoot() {
/declare i int local 0
/declare j int local 0
/declare k int local 0
/declare lootString string local
/declare lootTries int local 0
/declare needsLoot bool local FALSE
/declare xCorpseID int local 0
:BEGIN LOOT CYCLE
/declare corpseIDs[128] int local
/declare corpseCount int local ${SpawnCount[npccorpse LOS radius 100]}
/if (${corpseCount}==0) /return
/for k 1 to ${SpawnCount[npccorpse LOS radius 100]}
/varset corpseIDs[${k}] ${NearestSpawn[${k},npccorpse LOS radius 100].ID}
/next k
| CHECK SKIP CORPSES FOR IDs THAT DONT EXIST
/if (${skipCorpseIDs.Count}>0) {
/for k ${Math.Calc[ ${skipCorpseIDs.Count}-1]} downto 0
/if (${Spawn[id ${skipCorpseIDs.Item[${k}]}].ID}==NULL) {
/bc Removing corpseID ${skipCorpseIDs.Item[${k}]} from skip-corpse list becaust it seems to have disappeared from the zone.
/invoke ${skipCorpseIDs.Erase[${i}]}
}
/next k
}
/if (${corpseCount}==0) /RETURN
/for k 1 to ${corpseCount}
/doevents
/if (${hardLoopReset}==TRUE) /RETURN FALSE
/call ensureNoLootWindow
/call ensureNoItemDisplayWindows
/varset xCorpseID ${corpseIDs[${k}]}
/if (${skipCorpseIDs.Contains[${xCorpseID}]}==TRUE) /continue
/if (${Nav.PathExists[id ${xCorpseID}]}==FALSE) {
/bc p3-loot: [+y+] Can't nav to corpse to loot. Abandoning. ID: ${xCorpseID}
/invoke ${skipCorpseIDs.Append[${xCorpseID}]}
/continue
}
:tryLoot
/echo Trying to loot ${xCorpseID}...
/nav id ${xCorpseID}
| this needs to be distance3d
/call waitForIntLTE "Spawn[id ${xCorpseID}].Distance" 13
/call waitForIntLTE "Me.Speed" 1
/tar id ${corpseIDs[${k}]}
/if (${hardLoopReset}==TRUE) /RETURN FALSE
/if (${Spawn[id ${xCorpseID}].ID}==NULL) /goto :loopnextk
/tar id ${xCorpseID}
/delay 2
/doevents
/if (${hardLoopReset}==TRUE) /RETURN FALSE
/if (${stopWait}) {
/goto :loopnextk
/varset stopWait FALSE
}
/hidec looted
/loot
/delay 5
/doevents
/if (${skipCorpseTrigger}==TRUE) {
/varset skipCorpseTrigger FALSE
/invoke ${skipCorpseIDs.Append[${xCorpseID}]}
/bc p3-loot: [+y+] Abandoning corpse ID ${xCorpseID} - I can't loot it for some reason.
/continue
}
/if (${Spawn[id ${xCorpseID}].ID}==NULL) /goto :loopnextk
/if (${Target.ID}==NULL) /tar id ${xCorpseID}
/if (${Window[LootWnd]}==FALSE) /goto :tryLoot
/varset lootString Loot on ${xCorpseID}:
/for i 0 to 10
/if (${Window[LootWnd].Child[LW_LootSlot${i}].Tooltip.Length} == 0) /continue
/varset lootString ${lootString}, ${Window[LootWnd].Child[LW_LootSlot${i}].Tooltip}
/for j 1 to 256
/varset needsLoot FALSE
/if (${lootEntries[${j},1].Equal[-]}) /continue
/if (${lootEntries[${j},2].Equal[1]}) {
/if (${Window[LootWnd].Child[LW_LootSlot${i}].Tooltip.Find[${lootEntries[${j},1]}]}!=NULL) /varset needsLoot TRUE
}
/if (${lootEntries[${j},2].Equal[2]}) {
/if (${Window[LootWnd].Child[LW_LootSlot${i}].Tooltip.Equal[${lootEntries[${j},1]}]}!=NULL) /varset needsLoot TRUE
}
/if (${needsLoot}==FALSE) /continue
/shift /notify LootWnd LW_LootSlot${i} rightmouseup
/bc p3-loot: [+m+] Looting: ${Window[LootWnd].Child[LW_LootSlot${i}].Tooltip}
/delay 5
/doevents
/if (${skipCorpseTrigger}==TRUE) {
/varset skipCorpseTrigger FALSE
/invoke ${skipCorpseIDs.Append[${xCorpseID}]}
/bc p3-loot: [+y+] Abandoning corpse ID ${xCorpseID} - there's a lore item on it I can't loot.
/goto :loopnextk
}
/break
/next j
/next i
/bc p3-loot: [+g+] ${lootString}
/mqlog p3-loot: ${lootString}
/varset lootString
:loopnextk
/next k
:loopesck
/call ensureNoLootWindow
/call ensureNoItemDisplayWindows
/RETURN
}
SUB loadLootIni() {
/declare i int local 0
/declare lootKeys string local ${Ini[loot,loot]}
/declare entryName string local
/declare entryValue string local
/declare count int local 0
/deletevar lootEntries
/declare lootEntries[256,2] string outer -
|/invoke ${lootEntries.Clear}
| IMPORT LOOT ENTRIES INTO PERSISTENT ARRAY
/for i 1 to 256
/varset entryName ${lootKeys.Arg[${i},|]}
/if (${entryName.Equal[NULL]}) {
|/echo skip
/goto :loopnext
}
/varset entryValue ${Ini[loot,loot,${entryName}]}
/varset lootEntries[${i},1] ${entryName}
/varset lootEntries[${i},2] ${entryValue}
|/echo ${entryName} ${entryValue}
/varset count ${Math.Calc[${count}+1]}
:loopnext
/next i
/echo Loaded ${count} loot entries.
/RETURN
}
SUB ensureNoItemDisplayWindows
:again
/if (${Window[ItemDisplayWindow]}==TRUE) {
/keypress ESC
/delay 2
/goto :again
}
/RETURN
SUB ensureNoLootWindow
:again
/if (${Window[LootWnd]}==TRUE) {
/keypress ESC
/delay 1
/goto :again
}
/RETURN