-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleAI.baf
442 lines (402 loc) · 9.54 KB
/
SimpleAI.baf
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
//Note
//if a check succeeds it disables the current modal so we have to avoid successful checks except combat
IF
Global("BEPASSIVE","LOCALS",0)
HotKey(V)
THEN
RESPONSE #100
SetGlobal("BEPASSIVE","LOCALS",1)
DisplayStringHead(Myself,95137) // Not attacking enemies
ClearActions()
SetGlobal("IMHELPING","LOCALS",0)
END
IF
Global("BEPASSIVE","LOCALS",1)
HotKey(V)
THEN
RESPONSE #100
SetGlobal("BEPASSIVE","LOCALS",0)
DisplayStringHead(Myself,95135) // Attacking enemies
END
IF
OR(3)
ModalState(STEALTH)
StateCheck(Myself,STATE_INVISIBLE)
StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
THEN
RESPONSE #100
END
IF
Global("IMHELPING","LOCALS",1)
OR(3)
SpellCast(Myself,0)
SpellCastInnate(Myself,0)
ActionListEmpty()
THEN
RESPONSE #100
SetGlobal("IMHELPING","LOCALS",0)
Continue()
END
////////////////////////////////////////////////////////////////////////////////////////////
//If you manually changed your weapon then update the preferred weapon
IF
Global("PREFERMELEE","LOCALS",0)
Global("BowEquipped","LOCALS",1)
!IsWeaponRanged(Myself)
THEN
RESPONSE #100
SetGlobal("PREFERMELEE","LOCALS",1)
SetGlobal("BowEquipped","LOCALS",0)
Continue()
END
IF
Global("PREFERMELEE","LOCALS",1)
Global("BowEquipped","LOCALS",0)
IsWeaponRanged(Myself)
THEN
RESPONSE #100
SetGlobal("PREFERMELEE","LOCALS",0)
SetGlobal("BowEquipped","LOCALS",1)
Continue()
END
////////////////////////////////////////////////////////////////////////////////////////////
//If combat starts start the timers that limit modals
IF
Global("INCOMBAT","LOCALS",1)
!Exists([Enemy])
CombatCounter(0)
THEN
RESPONSE #100
SetGlobal("INCOMBAT","LOCALS",0)
SetGlobal("IMHELPING","LOCALS",0)
SetGlobal("SKILLTIME","LOCALS",1)
END
IF
Global("INCOMBAT","LOCALS",0)
!IsWeaponRanged(Myself)
OR(2)
Exists([Enemy])
CombatCounterGT(0)
THEN
RESPONSE #100
SetGlobal("PREFERMELEE","LOCALS",1)
SetGlobal("BowEquipped","LOCALS",0)
Continue()
END
IF
Global("INCOMBAT","LOCALS",0)
IsWeaponRanged(Myself)
OR(2)
Exists([Enemy])
CombatCounterGT(0)
THEN
RESPONSE #100
SetGlobal("PREFERMELEE","LOCALS",0)
SetGlobal("BowEquipped","LOCALS",1)
Continue()
END
IF
Global("INCOMBAT","LOCALS",0)
OR(2)
Exists([Enemy])
CombatCounterGT(0)
THEN
RESPONSE #100
SetGlobal("INCOMBAT","LOCALS",1)
SetGlobal("SKILLTIME","LOCALS",0)
END
// Fighters can't activate anything, so make them keep fighting forever
IF
DELAY(12)
Global("INCOMBAT","LOCALS",1)
OR(3)
!ButtonDisabled(BUTTON_TURNUNDEAD) //Turn undead
!ButtonDisabled(BUTTON_THIEVING) //Thieving
!ButtonDisabled(BUTTON_BATTLESONG) //Bardsong
THEN
RESPONSE #100
SetGlobal("SKILLTIME","LOCALS",1)
StartTimer(111,3)
Continue()
END
IF
Global("SKILLTIME","LOCALS",1)
Global("INCOMBAT","LOCALS",1)
TimerExpired(111)
THEN
RESPONSE #100
SetGlobal("SKILLTIME","LOCALS",0)
Continue()
END
////////////////////////////////////////////////////////////////////////////////////
//See who is near you
IF
OR(7)
See(Nearest([ENEMY]))
See(SecondNearest([ENEMY]))
See(ThirdNearest([ENEMY]))
See(FourthNearest([ENEMY]))
See(FifthNearest([ENEMY]))
See(SixthNearest([ENEMY]))
See([ENEMY])
FALSE()
THEN
RESPONSE #100
NoAction()
END
///////////////////////////////////////////////
IF
!ModalState(SHAMANDANCE)
AttackedBy([EVILCUTOFF],DEFAULT)
!Range(LastSeenBy(Myself),5)
THEN
RESPONSE #100
Shout(1234)
Continue()
END
/////////////////////////////////////////////////////////////////////////////////////////
//If an enemy is close by and you prefer melee, swap weapons
IF
Global("BEPASSIVE","LOCALS",0)
Range(LastSeenBy(Myself),5)
Global("PREFERMELEE","LOCALS",1)
OR(2)
Global("IMHELPING","LOCALS",1)
ActionListEmpty()
IsWeaponRanged(Myself)
NotStateCheck(LastSeenBy(Myself),state_panic)
Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
RESPONSE #100
EquipMostDamagingMelee()
SetGlobal("BowEquipped","LOCALS",0)
Continue()
END
//Fight nearby people
IF
Global("BEPASSIVE","LOCALS",0)
OR(2)
Global("IMHELPING","LOCALS",1)
ActionListEmpty()
OR(2)
HasWeaponEquiped()
Class(Myself,MONK)
OR(2)
IsWeaponRanged(Myself)
!TargetUnreachable(LastSeenBy(Myself))
Range(LastSeenBy(Myself),5)
CheckStatLT(Myself,21,THAC0)
!InParty(LastSeenBy(Myself))
NotStateCheck(LastSeenBy(Myself),state_panic)
Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
RESPONSE #100
help()
SetGlobal("IMHELPING","LOCALS",0)
SetInterrupt(TRUE)
AttackReevaluate(LastSeenBy(Myself),1)
END
//IF you prefer melee then grab your axe and get going if you hear someone call for help
IF
Global("BEPASSIVE","LOCALS",0)
Global("SKILLTIME","LOCALS",0)
Global("PREFERMELEE","LOCALS",1)
ActionListEmpty()
IsWeaponRanged(Myself)
HPGT(Myself,6)
HPPercentGT(Myself,70)
CHECKSTATGT(Myself,4,VISUALRANGE)
CheckStatLT(Myself,21,THAC0)
Help([PC])
OR(7)
Class(Myself,PALADIN_ALL)
Class(Myself,FIGHTER_ALL)
Class(Myself,RANGER_ALL)
Class(Myself,MONK)
Class(Myself,THIEF_ALL)
Class(Myself,CLERIC_ALL)
Class(Myself,DRUID_ALL)
!ModalState(SHAMANDANCE)
!TargetUnreachable(LastHelp(Myself))
!Range(LastHelp(Myself),1)
THEN
RESPONSE #100
EquipMostDamagingMelee()
SetGlobal("BowEquipped","LOCALS",0)
Continue()
END
//This makes the archer stop moving and attack if they previously heeded a call for help
IF
Global("IMHELPING","LOCALS",1)
IsWeaponRanged(Myself)
CHECKSTATGT(Myself,4,VISUALRANGE)
CheckStatLT(Myself,21,THAC0)
Range(LastSeenBy(Myself),30)
!InParty(LastSeenBy(Myself))
Allegiance(LastSeenBy(Myself),EVILCUTOFF)
!ModalState(SHAMANDANCE)
THEN
RESPONSE #100
SetGlobal("IMHELPING","LOCALS",0)
SetInterrupt(TRUE)
AttackReevaluate(LastSeenBy(Myself),1)
END
//Attack with your bow if you aren't helping people
IF
Global("BEPASSIVE","LOCALS",0)
Global("SKILLTIME","LOCALS",0)
ActionListEmpty()
IsWeaponRanged(Myself)
HaveUsableWeapon()
!ModalState(SHAMANDANCE)
!InParty(LastSeenBy(Myself))
Allegiance(LastSeenBy(Myself),EVILCUTOFF)
WeaponCanDamage(LastSeenBy(Myself),MAINHAND)
CHECKSTATGT(Myself,4,VISUALRANGE)
CheckStatLT(Myself,21,THAC0)
THEN
RESPONSE #100
SetGlobal("IMHELPING","LOCALS",0)
SetInterrupt(TRUE)
AttackReevaluate(LastSeenBy(Myself),1)
END
////////////////////////////////////////////////////////////////////////////////////////////
//If you're a competent archer help anyone who shouted out for help from a ranged opponent
IF
Heard([PC],1234)
IsWeaponRanged(Myself)
Global("PREFERMELEE","LOCALS",0)
Global("SKILLTIME","LOCALS",0)
Global("BEPASSIVE","LOCALS",0)
ActionListEmpty()
HPPercentGT(Myself,50)
CHECKSTATGT(Myself,4,VISUALRANGE)
CheckStatLT(Myself,21,THAC0)
OR(4)
Class(Myself,PALADIN_ALL)
Class(Myself,FIGHTER_ALL)
Class(Myself,RANGER_ALL)
Class(Myself,THIEF_ALL)
!ModalState(SHAMANDANCE)
!TargetUnreachable(LastHeardBy(Myself))
!Range(LastHeardBy(Myself),1)
THEN
RESPONSE #100
SetGlobal("IMHELPING","LOCALS",1)
SetInterrupt(TRUE)
MoveToObject(LastHeardBy(Myself))
END
////////////////////////////////////////////////////////////////////////////////////////////
// If you're a fighter or not a weakling and you have >70% of your health, help others
IF
Global("SKILLTIME","LOCALS",0)
Global("BEPASSIVE","LOCALS",0)
ActionListEmpty()
HPGT(Myself,6)
HPPercentGT(Myself,70)
CHECKSTATGT(Myself,4,VISUALRANGE)
CheckStatLT(Myself,21,THAC0)
Help([PC])
OR(7)
Class(Myself,PALADIN_ALL)
Class(Myself,FIGHTER_ALL)
Class(Myself,RANGER_ALL)
Class(Myself,MONK)
Class(Myself,THIEF_ALL)
Class(Myself,CLERIC_ALL)
Class(Myself,DRUID_ALL)
!ModalState(SHAMANDANCE)
!TargetUnreachable(LastHelp(Myself))
!Range(LastHelp(Myself),1)
THEN
RESPONSE #100
SetGlobal("IMHELPING","LOCALS",1)
SetInterrupt(TRUE)
MoveToObject(LastHelp(Myself))
END
//IF you can't help anyone but still see enemies then maybe you need a bow out
IF
!ModalState(SHAMANDANCE)
Global("BEPASSIVE","LOCALS",0)
Global("SKILLTIME","LOCALS",0)
Global("IMHELPING","LOCALS",0)
ActionListEmpty()
!Range(LastSeenBy(Myself),5)
!IsWeaponRanged(Myself)
CanEquipRanged()
THEN
RESPONSE #100
EquipRanged()
SetGlobal("BowEquipped","LOCALS",1)
END
/////////////////////////////////////////////////////////////////////////////////////////
// If you're using ranged weapons or are using a melee but aren't in combat, use your abilities
// A couple of timers here lets you alternate skills and combat optimally
//This stops the below trying to run when you're in a container
IF
ButtonDisabled(BUTTON_DIALOG)
THEN
RESPONSE #100
END
//If you're a cleric and there's undead turn undead
IF
ActionListEmpty()
!ButtonDisabled(BUTTON_TURNUNDEAD)
Global("INCOMBAT","LOCALS",1)
Exists([ENEMY.UNDEAD])
!Exists([ALLY.UNDEAD])
!Exists([NEUTRAL.UNDEAD])
!ModalState(BATTLESONG)
!ModalState(TURNUNDEAD)
!ModalState(SHAMANDANCE)
!ModalState(DETECTTRAPS)
InParty(Myself)
OR(2)
Class(Myself,CLERIC_ALL)
Class(Myself,PALADIN_ALL)
THEN
RESPONSE #100
Turn()
END
// Detect traps if you can
IF
ActionListEmpty()
!ButtonDisabled(BUTTON_THIEVING)
!ModalState(BATTLESONG)
!ModalState(TURNUNDEAD)
!ModalState(SHAMANDANCE)
!ModalState(DETECTTRAPS)
InParty(Myself)
OR(3)
Class(Myself,THIEF_ALL)
Class(Myself,MONK)
Class(Myself,SHAMAN)
THEN
RESPONSE #100
FindTraps()
END
//If you're a bard try singing
IF
ActionListEmpty()
!ButtonDisabled(BUTTON_BATTLESONG)
!ModalState(BATTLESONG)
!ModalState(TURNUNDEAD)
!ModalState(SHAMANDANCE)
!ModalState(DETECTTRAPS)
Class(Myself,BARD)
NumInPartyAliveGT(2)
Global("INCOMBAT","LOCALS",1)
THEN
RESPONSE #100
BattleSong()
END
IF
Global("SKILLTIME","LOCALS",0)
Global("BEPASSIVE","LOCALS",0)
!ModalState(SHAMANDANCE)
Allegiance(LastSeenBy(Myself),EVILCUTOFF)
Range(LastSeenBy(Myself),5)
THEN
RESPONSE #100
Help()
END