forked from oldkcole/sg1-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy.lua
783 lines (629 loc) · 19.2 KB
/
enemy.lua
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
module (..., package.seeall)
local shield = {}
local aura = {}
local prone = {}
local asleep = {}
local crucified = {}
local prismatic = {}
local pitted = {}
lv = {} -- leaving
rt = {} -- returned
local function normalize(name)
if not name then
display.Error("Invalid enemy target name: " .. tostring(name))
return "", false
end
local en = string.lower(name)
local targ = string.lower(GetVariable("target_name") or GetVariable("target") or "")
if #targ > 0 and string.find(en, targ) then
return targ, true
end
return en, false
end
function reset(name)
display.Debug("Enemy statuses reset (" .. tostring(name) .. ")", "enemy")
if name then
local en = normalize(name)
shield[en] = nil
aura[en] = nil
prone[en] = nil
asleep[en] = nil
crucified[en] = nil
prismatic[en] = nil
pitted[en] = nil
if string.lower(flags.get("maestoso_caster") or "") == en then
failsafe.disable("maestoso")
flags.clear{"maestoso", "maestoso_caster"}
end
if string.lower(flags.get("aurawarper") or "") == en then
failsafe.disable("aurawarp")
flags.clear{"aurawarper", "scanned_aurawarp"}
end
if string.lower(flags.get("bedeviler") or "") == en then
failsafe.disable("bedevil")
flags.clear{"bedeviler", "scanned_bedeviled"}
end
else
shield = {}
aura = {}
prone = {}
asleep = {}
crucified = {}
prismatic = {}
pitted = {}
end
end
function leaving(msg, name)
local en, tf = normalize(name)
if tf then
display.enemy_alert(msg)
end
end
function gone(msg, name)
local en, tf = normalize(name)
if tf then
display.enemy_gone(msg)
end
reset(en)
en = php.strproper(en)
if raid.is_coven_member(en) then
raid.coven_gone(en)
end
end
function returned(msg, name)
local en, tf = normalize(name)
if tf then
display.enemy_returned(msg)
end
reset(en)
en = php.strproper(en)
if raid.is_coven_member(en) then
raid.coven_returned(en)
end
end
function lv.name_dir(name, line, wildcards, styles)
gone(string.upper(wildcards[2]), wildcards[1])
end
function lv.dir_name(name, line, wildcards, styles)
gone(string.upper(wildcards[1]), wildcards[2])
end
function lv.arco(name, line, wildcards, styles)
gone("Arco took target", wildcards[1])
end
function lv.barreled(name, line, wildcards, styles)
returned("Charged from the " .. string.upper(wildcards[2]), wildcards[1])
flags.set("barreler", wildcards[1])
EnableTrigger("enemy_barreling__", true)
prompt.queue(function () EnableTrigger("enemy_barreling__", false) end)
end
function lv.barreling(name, line, wildcards, styles)
if wildcards[1] == flags.get("barreler") then
gone("Charged to the " .. string.upper(wildcards[3]), wildcards[1])
gone("Barged to the " .. string.upper(wildcards[3]), wildcards[2])
end
end
function lv.beckoned(name, line, wildcards, styles)
gone("Beckoned", wildcards[1])
end
function lv.bolted(name, line, wildcards, styles)
gone("Bolted " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.bond_uniting(name, line, wildcards, styles)
leaving("Bond Uniting", wildcards[1])
end
function lv.bond_united(name, line, wildcards, styles)
gone("Bond United", wildcards[1])
end
function lv.bullkick(name, line, wildcards, styles)
EnableTrigger("enemy_bullkicked_out__", true)
prompt.queue(function () EnableTrigger("enemy_bullkicked_out__", false) end)
end
function lv.bullkicked(name, line, wildcards, styles)
gone("Bullkicked " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.burrowed(name, line, wildcards, styles)
gone("Burrowed", wildcards[1])
end
function lv.dead(name, line, wildcards, styles)
gone("Dead", wildcards[1])
end
function lv.editor(name, line, wildcards, styles)
gone("Editor", wildcards[1])
end
function lv.empress(name, line, wildcards, styles)
gone("Empress by " .. wildcards[1], wildcards[2])
end
function lv.fear(name, line, wildcards, styles)
gone("Fear", wildcards[1])
end
function lv.flying(name, line, wildcards, styles)
gone("Flying", wildcards[1])
end
function lv.geyser(name, line, wildcards, styles)
gone("Geyser - GROUND", wildcards[1])
end
function lv.ghost(name, line, wildcards, styles)
gone("Ghost", wildcards[1])
end
function lv.glide(name, line, wildcards, styles)
gone("Glided " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.gravity(name, line, wildcards, styles)
leaving("Leaving to the " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.gusted(name, line, wildcards, styles)
gone("Gusted " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.headbutt(name, line, wildcards, styles)
gone("Headbutted " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.hobbled(name, line, wildcards, styles)
gone("Hobbled " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.jumpkick(name, line, wildcards, styles)
gone("Jumpkicked " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.leaped(name, line, wildcards, styles)
gone("Leaped " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.leftarea(name, line, wildcards, styles)
gone("Left Area", wildcards[1])
end
function lv.mantrawind(name, line, wildcards, styles)
gone("Mantra Wind " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.moonbeamed(name, line, wildcards, styles)
gone("Moonbeam", wildcards[1])
end
function lv.mountjumped(name, line, wildcards, styles)
gone("Mountjumped " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.news(name, line, wildcards, styles)
gone("News", wildcards[1])
end
function lv.pogo(name, line, wildcards, styles)
gone("Pogo'd " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.polevault(name, line, wildcards, styles)
gone("Polevaulted " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.rolling(name, line, wildcards, styles)
leaving("Rolling " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.rolled(name, line, wildcards, styles)
gone("Rolled " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.rubble(name, line, wildcards, styles)
leaving("Leaving over Rubble", wildcards[1])
end
function lv.scissorflip(name, line, wildcards, styles)
EnableTrigger("enemy_scissorflipped_out__", true)
prompt.queue(function () EnableTrigger("enemy_scissorflipped_out__", false) end)
end
function lv.scissorflipped(name, line, wildcards, styles)
gone("Scissorflipped " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.shadowflight(name, line, wildcards, styles)
gone("Shadow Flight", wildcards[1])
end
function lv.somersaulting(name, line, wildcards, styles)
leaving("Somersaulting " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.somersaulted(name, line, wildcards, styles)
gone("Somersaulted " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.starleap(name, line, wildcards, styles)
gone("Starleap", wildcards[1])
end
function lv.summoning(name, line, wildcards, styles)
leaving("Being Summoned", wildcards[1])
end
function lv.summoned(name, line, wildcards, styles)
gone("Summoned", wildcards[1])
end
function lv.swam(name, line, wildcards, styles)
gone("Swam " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.tackled(name, line, wildcards, styles)
gone("Tackled " .. string.upper(wildcards[3]), wildcards[2])
gone("Tackled " .. string.upper(wildcards[3]), wildcards[1])
end
function lv.teleport(name, line, wildcards, styles)
gone("Teleport", wildcards[1])
end
function lv.tornado(name, line, wildcards, styles)
gone("Flying (Tornado)", wildcards[1])
end
function lv.treefall(name, line, wildcards, styles)
gone("Tree Fall", wildcards[1])
end
function lv.treelift(name, line, wildcards, styles)
if map.elevation() == "trees" then
returned("Trees", wildcards[1])
else
gone("Trees", wildcards[1])
end
end
function lv.trees(name, line, wildcards, styles)
gone("Trees", wildcards[1])
end
function lv.trees_climb(name, line, wildcards, styles)
gone("Climbed Down", wildcards[1])
end
function lv.tumbling(name, line, wildcards, styles)
leaving("Tumbling " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.tumbled(name, line, wildcards, styles)
gone("Tumbled " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.whirlwind(name, line, wildcards, styles)
EnableTrigger("enemy_whirlwinded_out__", true)
prompt.queue(function () EnableTrigger("enemy_whirlwinded_out__", false) end)
end
function lv.whirlwinded(name, line, wildcards, styles)
gone("Whirlwind " .. string.upper(wildcards[2]), wildcards[1])
end
function lv.willowisp(name, line, wildcards, styles)
gone("Wisped", wildcards[1])
end
function rt.name_dir(name, line, wildcards, styles)
returned(string.upper(wildcards[2]), wildcards[1])
end
function rt.dir_name(name, line, wildcards, styles)
returned(string.upper(wildcards[1]), wildcards[2])
end
function rt.air_wind(name, line, wildcards, styles)
returned("Air Wind", wildcards[1])
end
function rt.beckoned(name, line, wildcards, styles)
gone("Beckoned", wildcards[1])
end
function rt.bond_united(name, line, wildcards, styles)
returned("Bond United", wildcards[1])
end
function rt.burrowed(name, line, wildcards, styles)
returned("Burrowed", wildcards[1])
end
function rt.currents(name, line, wildcards, styles)
returned("Currents", wildcards[1])
end
function rt.empressed(name, line, wildcards, styles)
returned("Empressed", wildcards[1])
end
function rt.followed(name, line, wildcards, styles)
returned(string.upper(wildcards[2]), wildcards[1])
end
function rt.headbutted(name, line, wildcards, styles)
returned("Headbutted from the " .. string.upper(wildcards[2]), wildcards[1])
end
function rt.jumpkicked(name, line, wildcards, styles)
returned("Jumpkicked from the " .. string.upper(wildcards[2]), wildcards[1])
end
function rt.landed(name, line, wildcards, styles)
returned("Landed", wildcards[1])
end
function rt.leaped(name, line, wildcards, styles)
returned("Leaped from the " .. string.upper(wildcards[2]), wildcards[1])
end
function rt.levitated(name, line, wildcards, styles)
returned("Levitated", wildcards[1])
end
function rt.moonbeamed(name, line, wildcards, styles)
returned("Moonbeam", wildcards[1])
end
function rt.news(name, line, wildcards, styles)
returned("News", wildcards[1])
end
function rt.ozuye(name, line, wildcards, styles)
returned("Ozuye found an enemy!", wildcards[1])
end
function rt.somersaulted(name, line, wildcards, styles)
returned("Somersaulted from " .. string.upper(wildcards[2]), wildcards[1])
end
function rt.spring_trap(name, line, wildcards, styles)
returned("Spring Trap", wildcards[1])
end
function rt.summoned(name, line, wildcards, styles)
returned("Summoned", wildcards[1])
end
function rt.swam(name, line, wildcards, styles)
returned("Swam", wildcards[1])
end
function rt.teleported(name, line, wildcards, styles)
returned("Teleported", wildcards[1])
end
function rt.tumbled(name, line, wildcards, styles)
returned("Tumbled from " .. string.upper(wildcards[2]), wildcards[1])
end
function rt.unghosted(name, line, wildcards, styles)
returned("Unghosted", wildcards[1])
end
function has_aura(name)
local en = normalize(name or "nobody")
return aura[en]
end
function is_target(name)
local _, tf = normalize(name or "nobody")
return tf
end
function is_shielded(name)
local en = normalize(name or "nobody")
return shield[en]
end
function is_prone(name)
local en = normalize(name or "nobody")
if prone[en] == true or
crucified[en] == true then
return true
end
return false
end
function proned(name, flag)
local en, tf = normalize(name)
if flag == nil then
flag = true
end
local prev = prone[en]
prone[en] = flag
if prone[en] then
display.Debug("Enemy is prone [" .. en .. "]", "enemy")
else
display.Debug("Enemy stood up [" .. en .. "]", "enemy")
end
if tf and prone[en] ~= prev then
if prone[en] then
prompt.prequeue(function () display.enemy_alert("PRONE") end, "enprone")
elseif not prompt.unqueue("enprone") then
display.enemy_alert("STANDING")
end
end
end
function rebound(name, flag)
local en, tf = normalize(name)
if flag == nil then
flag = true
end
if flag then
flags.clear(en .. "_razed_aura")
end
local prev = aura[en]
aura[en] = flag
if aura[en] then
display.Debug("Enemy has aura [" .. en .. "]", "enemy")
else
display.Debug("Enemy has no aura [" .. en .. "]", "enemy")
end
if tf and aura[en] ~= prev then
if aura[en] then
display.enemy_aura()
else
display.enemy_unaura()
end
end
end
function shielded(name, flag)
local en, tf = normalize(name)
if flag == nil then
flag = true
end
if flag and tf then
flags.clear(en .. "_razed_shield")
end
local prev = shield[en]
shield[en] = flag
if shield[en] then
display.Debug("Enemy shielded [" .. en .. "]", "enemy")
else
display.Debug("Enemy unshielded [" .. en .. "]", "enemy")
end
if tf and shield[en] ~= prev then
if shield[en] then
display.enemy_alert("SHIELD UP")
else
display.enemy_alert("SHIELD DOWN")
end
end
end
function no_target(name, line, wildcards, styles)
display.Prefix()
ColourNote(display.standard_colors.en_gone_tx, display.standard_colors.en_gone_bg, "NO TARGET")
local enchant = flags.get("used_enchant")
if enchant == "window" or enchant == "scry" then
prompt.preillqueue(function () actions.activated_enchantment(enchant) end)
end
end
function handle_shielding(name, line, wildcards, styles)
shielded(wildcards[1], true)
end
function handle_unshielding(name, line, wildcards, styles)
shielded(wildcards[1], false)
end
function handle_aura(name, line, wildcards, styles)
local en = wildcards[1]
if not en or #en < 1 then
en = GetVariable("target") or ""
end
if #en < 1 then
return
end
rebound(en, true)
end
function handle_unaura(name, line, wildcards, styles)
rebound(wildcards[1], false)
shielded(wildcards[1], false)
end
function handle_rebounded(name, line, wildcards, styles)
rebound(wildcards[1], false)
rebound(wildcards[2], true)
shielded(wildcards[2], false)
end
function handle_razing(name, line, wildcards, styles)
local en, tf = normalize(wildcards[1])
if string.find(line, "to no effect") or wildcards[2] == "speed defence" then
shield[en] = false
aura[en] = false
if string.lower(wildcards[1]) == en and tf then
display.enemy_noaura()
end
end
if wildcards[2] == "magical shield" then
shielded(wildcards[1], false)
flags.clear{en .. "_razed_shield", en .. "_razed_aura"}
elseif wildcards[2] == "aura of rebounding" then
rebound(wildcards[1], false)
flags.clear(en .. "_razed_aura")
else
rebound(wildcards[1], false)
shielded(wildcards[1], false)
flags.clear{en .. "_razed_shield", en .. "_razed_aura"}
end
end
function handle_fallen(name, line, wildcards, styles)
local en = wildcards[1]
if not en or #en < 1 then
en = GetVariable("target") or ""
end
if #en < 1 then
return
end
proned(en, true)
end
function handle_unfallen(name, line, wildcards, styles)
proned(wildcards[1], false)
end
function handle_nonfallen(name, line, wildcards, styles)
local en = wildcards[1]
if not en or #en < 1 then
return
end
local en, tf = normalize(en)
prone[en] = false
display.Debug("Enemy not prone [" .. en .. "]", "enemy")
if tf then
prompt.unqueue("enprone")
end
end
function handle_hypnoticgaze(name, line, wildcards, styles)
local en, tf = normalize(wildcards[1])
if tf then
local col = wildcards[2]
local colors = {
azure = "DIZZINESS",
cerulean = "CONFUSION",
crimson = "PARALYSIS",
emerald = "VERTIGO",
fuchsia = "DAYDREAMS",
lavender = "PACIFISM",
magenta = "BLINDNESS",
mauve = "VAPORS",
pink = "HALLUCINATIONS",
purple = "BLACKOUT",
scarlet = "FEAR",
sapphire = "DEMENTIA",
topaz = "STUPIDITY",
}
local text = {}
for c,a in pairs(colors) do
if string.find(col, c) then
table.insert(text, a)
end
end
display.enemy_alert("Beast hit with " .. table.concat(text, ", "))
end
end
function handle_pitfall_announce(name, line, wildcards, styles)
local person = wildcards[1]
local vnum = tonumber(wildcards[2])
for _,v in ipairs(styles) do
if v.text == person and names.is_in_enemy_org(person) then
SetVariable("target_pitted", person)
Hyperlink("ppp", person, "Change target", RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), 0)
else
s,e = string.find(v.text, wildcards[2])
if s then
ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), string.sub(v.text, 1, s - 1))
Hyperlink("go " .. vnum, vnum, "Run to the pit", map.colors.room_vnum, "", 0)
ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), string.sub(v.text, e + 1))
else
ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), v.text)
end
end
end
Note("")
end
function handle_pitfall(name, line, wildcards, styles)
local en, tf = normalize(wildcards[1])
pitted[en] = true
if tf then
display.enemy_alert("FELL IN PIT")
end
if pitted[en] and names.is_in_enemy_org(en) then
SetVariable("target_pitted", wildcards[1])
prompt.unqueue("trapalarm")
if not affs.has("dementia") and map.current_room and map.rooms[map.current_room] then
raid.announce(string.upper(string.sub(en, 1, 1)) .. string.sub(en, 2) .. " has fallen into a pit by me: " .. map.rooms[map.current_room].name .. " (" .. map.current_room .. ")")
else
raid.announce(string.upper(string.sub(en, 1, 1)) .. string.sub(en, 2) .. " has fallen into a pit by me!")
end
end
end
function handle_unpit(name, line, wildcards, styles)
local en, tf = normalize(wildcards[1])
pitted[en] = false
if tf then
display.enemy_alert("CLIMBED OUT OF PIT")
end
end
function handle_sleep(name, line, wildcards, styles)
local en, tf = normalize(wildcards[1])
asleep[en] = true
prone[en] = true
if tf then
display.enemy_alert("ASLEEP")
end
end
function handle_unsleep(name, line, wildcards, styles)
local en, tf = normalize(wildcards[1])
asleep[en] = false
if tf then
display.enemy_alert("AWAKE")
end
end
function handle_vitae(name, line, wildcards, styles)
local en, tf = normalize(wildcards[1] or "")
if tf then
display.enemy_alert("Alive Again")
end
rebound(en, false)
shielded(en, false)
end
function handle_toaded(name, line, wildcards, styles)
if names.is_member(wildcards[1], "Serenwilde") and not flags.get("arena") then
if main.auto("stomp") then
Execute("do1 stt")
else
display.Alert(wildcards[2] .. " is Toaded!")
display.Alert("STT to Stomp!")
end
end
end
function handle_toadstomping(name, line, wildcards, styles)
if names.is_in_ally_org(wildcards[1]) and not flags.get("arena") then
if main.auto("stomp") then
Execute("do1 stt")
else
display.Alert(wildcards[1] .. " is Stomping a Toad!")
display.Alert("STT to Stomp!")
end
end
end
function handle_toadstomped(name, line, wildcards, styles)
if not string.find(wildcards[1], "warty toad") then
if main.auto("stomp") then
Execute("do1 stt")
else
display.Alert("That toad's still not dead!")
display.Alert("STT to Stomp!")
end
end
end