-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathqw.rc
8618 lines (7998 loc) · 222 KB
/
qw.rc
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
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This rcfile is elliptic's DCSS bot "qw", the first (and thus far only) bot
# to win DCSS with no human assistance. A substantial amount of code here was
# contributed by elliott or borrowed from N78291's bot "xw", and many others
# have contributed as well.
# For brief instructions and the most up-to-date version of qw, see
# https://github.com/elliptic/qw.
## qw's settings:
#
# Set this to true when playing online.
: DELAYED = false
# Delay per action in milliseconds.
# Set this to at least 100 or so when playing online.
: DELAY_TIME = 125
# whether to start playing immediately when a new game is started
# unfortunately this doesn't work if the game starts with a -more-
: AUTO_START = false
# experimental: do second lair rune branch before depths
: EARLY_SECOND_RUNE = true
# experimental: wait to do Orc until after D:15
: LATE_ORC = true
# lair rune preferences, current options are:
# * random - no preference, chooses randomly
# * nowater - does Snake/Spider first
# * smart - currently prefers Spider > Snake/Swamp > Shoals
# * dsmart - Swamp/Spider > Snake > Shoals (DsBe data)
: RUNE_PREFERENCE = "random"
# plan for post-V:5, should end with zot
# maximal example: "tso,tomb,hells,pan,slime,abyss,zig,zot"
: ENDGAME_PLAN = "zot"
# depth to attempt to dive in ziggurats
: ZIG_DIVE = 27
# burn books with Trog, may theoretically cause navigation problems
: BURN_BOOKS = true
# enable certain somewhat spammy notes
: SPAM = false
# tab just takes a single action (for testing)
: SINGLE_STEP = false
# panic (stop) at full inventory
: FULL_INVENTORY_PANIC = true
# quit after this number of turns while stuck
: QUIT_TURNS = 1000
# use a shield at all cost
: SHIELD_CRAZY = true
# acceptable gods (join whichever one we find first)
# gods who have been at least partially implemented: BCHLMOQRTUXY1
# gods who are actually pretty decent on qw: CMORT
: GOD_LIST = { "Trog", }
# use faded altar, abandoning if we don't get one of the gods in GOD_LIST
: FADED_ALTAR = false
# cycle through combos using c_persist.options
: COMBO_CYCLE = false
# combos to cycle through - uses the same syntax as the regular combo option
# with an optional "^<god initials>" suffix to overwrite the GOD_LIST
# list above. Here are some sample choices:
: COMBO_CYCLE_LIST = "DDFi.waraxe^M, DDBe.handaxe^T, GrBe.handaxe^T, GrFi.waraxe^O, MiFi.waraxe^O"
# Choose randomly between these combos. This will not apply if the COMBO_CYCLE
# option was on in your _previous_ game.
combo = GrBe.handaxe
# For random berserkers, use these combos:
#combo = CeBe.handaxe, DDBe.handaxe, DEBe.handaxe, DrBe.handaxe, DsBe.handaxe
#combo += FeBe.claws, FoBe.handaxe, GrBe.handaxe, GhBe.claws, HaBe.falchion
#combo += HEBe.falchion, HOBe.handaxe, HuBe.handaxe, KoBe.mace, MfBe.spear
#combo += MiBe.handaxe, MuBe.handaxe, NaBe.handaxe, OgBe.mace, OpBe.handaxe
#combo += SpBe.shortsword, TeBe.handaxe, TrBe.claws, VSBe.handaxe, VpBe.handaxe
# For a totally random combo (with chosen weapon type), hyperqwcombo.rc can
# be created using hyperqwcombogen.sh and used:
#combo =
#include += hyperqwcombo.rc
## The accomplishments of qw:
# online wins: CeFi^O DDBe DDFi^C DDFi^O DDFi^Q DDFi^Y DDGl^M DDGl^R DrFi^O
# DsBe FoFi^O GhFi^O GrBe HOBe HuBe MfBe MiBe MiFi^C MiFi^O
# MiFi^Q MiFi^R MiFi^Y MuFi^O NaBe OgFi^O TeBe TrBe VSBe
# offline wins: HaFi^O HEBe HEFi^O VpBe VpFi^O
# (offline) runes: DgFi FeFi^O KoBe KoFi^O OpBe OpFi^O
#####################################
# enum values :/
: ENUM_MONS_PANDEMONIUM_LORD = 344
: ATT_FRIENDLY = 4
: ATT_NEUTRAL = 1
: ATT_HOSTILE = 0
: LOS = 7
: if you.race() == "Barachi" then
: LOS = 8
: end
#####################################
# miscellaneous simple options
name = qw
restart_after_game = false
bold_brightens_foreground = true
equip_bar = true
ability_menu = false
view_delay = 0
use_animations =
darken_beyond_range = false
clear_messages = true
travel_delay = -1
explore_delay = -1
rest_delay = -1
travel_key_stop = false
default_manual_training = true
autopickup_no_burden = false
auto_exclude =
hp_warning = 0
show_more = false
show_newturn_mark = false
list_rotten = false
force_more_message =
show_travel_trail = false
skill_focus = false
autoinscribe += slay:mikee
autoinscribe += (inedible|mutagenic|forbidden).*(chunk|corpse):noeat
flush.failure = false
char_set = ascii
cset = cloud:xa4
cset = item_orb:0
use_fake_player_cursor = true
equip_unequip = true
dump_order = header,hiscore,stats,misc,mutations,skills,spells,inventory
dump_order += overview
dump_order += messages,screenshot,monlist,kills,notes,vaults,skill_gains,action_counts
dump_order += xp_by_level
ood_interesting = 6
note_hp_percent = 25
note_skill_levels = 1,3,6,9,12,15,18,21,24,27
note_all_spells = true
fire_order = launcher, rock, javelin, tomahawk
auto_eat_chunks = false
read_persist_options = true
message_colour ^= mute:Unknown command
####################################
# not sure exactly how important or correct these settings are
explore_stop =
explore_stop += items,branches,portals,stairs,altars
explore_stop += greedy_visited_item_stack,greedy_pickup_smart
stop := runrest_stop_message
ignore := runrest_ignore_message
stop =
ignore =
ignore += .*
runrest_ignore_poison = 3:15
runrest_ignore_monster += butterfly:1
runrest_ignore_monster += orb of destruction:1
####################################
# These keys are useful to answer prompts and aren't critical for manual play
bindkey = [Y] CMD_NO_CMD_DEFAULT
bindkey = [N] CMD_NO_CMD_DEFAULT
bindkey = [B] CMD_NO_CMD_DEFAULT
bindkey = [C] CMD_NO_CMD_DEFAULT
bindkey = [.] CMD_NO_CMD_DEFAULT
bindkey = [^D] CMD_LUA_CONSOLE
####################################
# Don't get interrupted!
: chk_interrupt_activity["blurry vision"] = function (iname, cause, extra)
: return nil
: end
####################################
# autopickup is all handled via lua
autopickup =
autopickup_exceptions =
################################################################
# now the lua, beginning with global variables
{
-- some global variables:
local initialized = false
local time_passed
local update_coroutine
local do_dummy_action
local dump_count = you.turns() + 100 - (you.turns() % 100)
local skill_count = you.turns() - (you.turns() % 5)
local danger
local immediate_danger
local cloudy
local where
local where_shafted_from = nil
local expect_new_location
local expect_portal
local automatic = false
local ignore_list = { }
local failed_move = { }
local invisi_count = 0
local next_delay = 100
local dd_hw_meter = 0
local sigmund_dx = 0
local sigmund_dy = 0
local invisi_sigmund = false
local sgd_timer = -200
local stuck_turns = 0
local stepped_on_lair = false
local stepped_on_tomb = false
local lair_step_mode = false
-- are these still necessary?
local did_move = false
local move_count = 0
local did_move_towards_monster = 0
local target_memory_x
local target_memory_y
local last_wait = 0
local wait_count = 0
local old_turn_count = you.turns()-1
local hiding_turn_count = -100
local travel_destination = nil
local game_status = "normal"
local have_message = false
local read_message = true
local monster_array
local enemy_list
local upgrade_phase = false
local tactical_step
local tactical_reason
local is_waiting
local did_first_turn = false
local stairdance_count = {}
local clear_exclusion_count = {}
local v5_entry_turn
local last_swamp_fail_count = -1
local swamp_rune_reachable = false
local offlevel_travel = true
local last_min_delay_skill = 18
local only_linear_resists = false
local no_spells = false
local level_map
local stair_dists
local waypoint_parity
local cur_where
local prev_where
local did_waypoint = false
local good_stair_list
local target_stair
local last_flee_turn = -100
local ABYSSAL_RUNE = false
local SLIMY_RUNE = false
local PAN_RUNE = false
local HELL_RUNE = false
local GOLDEN_RUNE = false
local TSO_CONVERSION = false
local LUGONU_CONVERSION = false
local WILL_ZIG = false
local MIGHT_BE_GOOD = false
local endgame_plan_list = {}
local which_endgame_plan = 1
local dislike_pan_level = false
local prev_hatch_dist = 1000
local prev_hatch_x
local prev_hatch_y
-- options to set while qw is running
-- maybe should add more mutes for watchability
function set_options()
crawl.setopt("confirm_butcher = always")
crawl.setopt("pickup_mode = multi")
crawl.setopt("message_colour += mute:Search for what")
crawl.setopt("message_colour += mute:Can't find anything")
crawl.setopt("message_colour += mute:Drop what")
crawl.setopt("message_colour += mute:Okay, then")
crawl.setopt("message_colour += mute:Use which ability")
crawl.setopt("message_colour += mute:Read which item")
crawl.setopt("message_colour += mute:Drink which item")
crawl.setopt("message_colour += mute:not good enough")
crawl.setopt("message_colour += mute:Attack whom")
crawl.setopt("message_colour += mute:move target cursor")
crawl.setopt("message_colour += mute:Aim:")
crawl.setopt("message_colour += mute:You reach to attack")
crawl.enable_more(false)
end
function unset_options()
crawl.setopt("always_confirm_butcher = auto")
crawl.setopt("pickup_mode = auto")
crawl.setopt("message_colour -= mute:Search for what")
crawl.setopt("message_colour -= mute:Can't find anything")
crawl.setopt("message_colour -= mute:Drop what")
crawl.setopt("message_colour -= mute:Okay, then")
crawl.setopt("message_colour -= mute:Use which ability")
crawl.setopt("message_colour -= mute:Read which item")
crawl.setopt("message_colour -= mute:Drink which item")
crawl.setopt("message_colour -= mute:not good enough")
crawl.setopt("message_colour -= mute:Attack whom")
crawl.setopt("message_colour -= mute:move target cursor")
crawl.setopt("message_colour -= mute:Aim:")
crawl.setopt("message_colour -= mute:You reach to attack")
crawl.enable_more(true)
end
-------------------------------------
-- equipment valuation and autopickup
-- We assign a numerical value to all armour/weapon/jewellery, which
-- is used both for autopickup (so it has to work for unIDed items) and
-- for equipment selection. A negative value means we prefer an empty slot.
-- The valuation functions either return a pair of numbers - minimum
-- minimum and maximum potential value - or the current value. Here
-- value should be viewed as utility relative to not wearing anything in
-- that slot. For the current value calculation, we can specify an equipped
-- item and try to simulate not wearing it (for resist values).
-- We pick up an item if its max value is greater than our currently equipped
-- item's min value. We swap to an item if it has a greater cur value.
-- if cur, return the current value instead of minmax
-- if it2, pretend we aren't equipping it2
-- if sit = "hydra", assume we are fighting a hydra at lowish XL
-- = "extended", assume we are in (or about to enter) Pan
-- if TSO_CONVERSION, we need this weapon to be TSO-friendly
-- = "bless", assume we want to bless the weapon with TSO eventually
function equip_value(it, cur, it2, sit)
if not it then
return 0,0
end
local class = it.class(true)
if class == "armour" then
return armour_value(it, cur, it2)
elseif class == "weapon" then
return weapon_value(it, cur, it2, sit)
elseif class == "jewellery" then
if equip_slot(it) == "Amulet" then
return amulet_value(it, cur, it2)
else
return ring_value(it, cur, it2)
end
end
return -1,-1
end
-- Returns the amount of an artprop granted by an item - not all artprops are
-- currently handled here.
function item_resist(str, it)
if not it then
return 0
end
if it.artefact and it.artprops and it.artprops[str] then
return it.artprops[str]
else
local name = it.name()
local ego = it.ego()
local subtype = it.subtype()
if str == "rF" then
if name:find("fire dragon") then
return 2
elseif ego == "fire resistance" or ego == "resistance"
or subtype == "ring of protection from fire"
or name:find("gold dragon") or subtype == "ring of fire" then
return 1
elseif name:find("ice dragon") or subtype == "ring of ice" then
return -1
else
return 0
end
elseif str == "rC" then
if name:find("ice dragon") then
return 2
elseif ego == "cold resistance" or ego == "resistance"
or subtype == "ring of protection from cold"
or name:find("gold dragon") or subtype == "ring of ice" then
return 1
elseif name:find("fire dragon") or subtype == "ring of fire" then
return -1
else
return 0
end
elseif str == "rElec" then
if name:find("storm dragon") then
return 1
else
return 0
end
elseif str == "rPois" then
if ego == "poison resistance" or subtype == "ring of poison resistance"
or name:find("swamp dragon") or name:find("gold dragon") then
return 1
else
return 0
end
elseif str == "rN" then
if ego == "positive energy" or subtype == "ring of positive energy"
or name:find("pearl dragon") then
return 1
else
return 0
end
elseif str == "MR" then
if ego == "magic resistance" or subtype == "ring of protection from magic"
or name:find("quicksilver dragon") then
return 1
else
return 0
end
elseif str == "rCorr" then
if subtype == "ring of resist corrosion" or name:find("acid dragon") then
return 1
else
return 0
end
elseif str == "SInv" then
if ego == "see invisible" or subtype == "ring of see invisible" then
return 1
else
return 0
end
elseif str == "Spirit" then
if ego == "spirit shield" or subtype == "amulet of guardian spirit" then
return 1
else
return 0
end
elseif str == "Str" then
if subtype == "ring of strength" then
return it.plus or 0
elseif ego == "strength" then
return 3
end
elseif str == "Dex" then
if subtype == "ring of dexterity" then
return it.plus or 0
elseif ego == "dexterity" then
return 3
end
elseif str == "Int" then
if subtype == "ring of intelligence" then
return it.plus or 0
elseif ego == "intelligence" then
return 3
end
elseif str == "Slay" then
if subtype == "ring of slaying" then
return it.plus or 0
end
elseif str == "AC" then
if subtype == "ring of protection" then
return it.plus or 0
elseif ego == "protection" then
return 3 -- wrong for weapons but we scale things differently for weapons
end
elseif str == "EV" then
if subtype == "ring of evasion" then
return it.plus or 0
end
elseif str == "SH" then
if subtype == "amulet of reflection" then
return it.plus or 0
end
end
end
return 0
end
-- Returns the player's intrinsic level of an artprop string.
function intrinsic_resist(str)
if str == "rF" then
return you.mutation("fire resistance")
elseif str == "rC" then
return you.mutation("cold resistance")
elseif str == "rElec" then
return you.mutation("electricity resistance")
elseif str == "rPois" then
if intrinsic_rpois() or (you.mutation("poison resistance") > 0) then
return 1
else
return 0
end
elseif str == "rN" then
local val = you.mutation("negative energy resistance")
if you.god() == "the Shining One" then
val = val + math.floor(you.piety_rank() / 3)
end
return val
elseif str == "MR" then
return you.mutation("magic resistance") + ((you.god() == "Trog") and 1 or 0)
elseif str == "rCorr" then
return 0
elseif str == "SInv" then
if intrinsic_sinv() or (you.mutation("see invisible") > 0) then
return 1
else
return 0
end
elseif str == "Spirit" then
return ((you.race() == "Vine Stalker") and 1 or 0)
end
return 0
end
-- Returns the current level of "resistance" to an artprop string. If an
-- item is provided, assume the item is equipped and try to pretend that
-- it is unequipped. Does not include some temporary effects.
function player_resist(str, it)
local it_res = it and it.equipped and item_resist(str, it) or 0
if str == "Str" then
stat,_ = you.strength()
return stat-it_res
elseif str == "Dex" then
stat,_ = you.dexterity()
return stat-it_res
elseif str == "Int" then
stat,_ = you.intelligence()
return stat-it_res
end
local other_res = intrinsic_resist(str)
for it2 in inventory() do
if it2.equipped and slot(it2) ~= slot(it) then
other_res = other_res + item_resist(str, it2)
end
end
if str == "rF" or str == "rC" or str == "rN" or str == "MR" then
return other_res
else
return ((other_res > 0) and 1 or 0)
end
end
function equip_slot(it)
local class = it.class(true)
if class == "armour" then
return good_slots[it.subtype()]
elseif class == "weapon" then
return "Weapon"
elseif class == "jewellery" then
local sub = it.subtype()
if sub and sub:find("amulet") or not sub and it.name():find("amulet") then
return "Amulet"
else
return "Ring" -- not the actual slot name
end
end
return
end
-- The current utility of having a given amount of an artprop.
function absolute_resist_value(str, n)
if str == "Str" or str == "Int" or str == "Dex" then
if n > 4 then
return 0 -- handled by linear_resist_value()
elseif n > 2 then
return -100
elseif n > 0 then
return -250
else
return -10000
end
end
if n == 0 then
return 0
end
if slime_soon() and (str == "rF" or str == "rElec" or str == "rPois" or
str == "rN" or str == "MR" or str == "SInv") then
return 0
end
local val = 0
if str == "rF" or str == "rC" then
if n < 0 then
val = -150
elseif n == 1 then
val = 125
elseif n == 2 then
val = 200
elseif n >= 3 then
val = 250
end
if str == "rF" and zot_soon() then
val = val * 2.5
elseif str == "rC" and slime_soon() then
val = val * 1.5
end
return val
elseif str == "rElec" then
return 75
elseif str == "rPois" then
return ((easy_runes() < 2) and 225 or 75)
elseif str == "rN" then
return 25*n
elseif str == "MR" then
if n <= 2 then
return 75*n
else
return 200
end
elseif str == "rCorr" then
return (slime_soon() and 1200 or 50)
elseif str == "SInv" then
return 200
elseif str == "Spirit" then
return ((you.race() == "Deep Dwarf") and -10000 or 75)
end
return 0
end
function max_resist_value(str, d)
if d <= 0 then
return 0
end
local val = 0
local ires = intrinsic_resist(str)
if str == "rF" or str == "rC" then
if d == 1 then
val = 150
elseif d == 2 then
val = 275
elseif d == 3 then
val = 350
end
if str == "rF" then
val = val * 2.5
elseif str == "rC" and SLIMY_RUNE then
val = val * 1.5
end
return val
elseif str == "rElec" then
return ((ires < 1) and 75 or 0)
elseif str == "rPois" then
return ((ires < 1) and ((easy_runes() < 2) and 225 or 75) or 0)
elseif str == "rN" then
return ((ires < 3) and 25*d or 0)
elseif str == "MR" then
return 75*d
elseif str == "rCorr" then
return (ires < 1 and (SLIMY_RUNE and 1200 or 50) or 0)
elseif str == "SInv" then
return ((ires < 1) and 200 or 0)
elseif str == "Spirit" then
if ires > 0 then
return 0
elseif you.race() == "Deep Dwarf" then
return -10000
else
return 75
end
end
return 0
end
function min_resist_value(str, d)
if str == "Spirit" and you.race() == "Deep Dwarf" then
return -10000
end
if d >= 0 then
return 0
end
if str == "rF" then
return -375
elseif str == "rC" then
return (SLIMY_RUNE and -225 or -150)
elseif str == "MR" then
return 75*d
end
return 0
end
function resist_value(str, it, cur, it2)
local d = item_resist(str, it)
if d == 0 then
return 0,0
end
if cur then
local c = player_resist(str, it2)
local diff = absolute_resist_value(str,c+d) - absolute_resist_value(str,c)
return diff,diff
else
return min_resist_value(str,d),max_resist_value(str,d)
end
end
function linear_resist_value(str)
if str == "Slay" or str == "AC" or str == "EV" then
return 50
elseif str == "SH" then
return 40
elseif str == "Str" then
return 30
elseif str == "Dex" then
return 20
end
return 0
end
function total_resist_value(it, cur, it2)
resistlist = { "rF", "rC", "rElec", "rPois", "rN", "MR", "rCorr", "SInv", "Spirit", "Str", "Dex", "Int" }
linearlist = { "Str", "Dex", "Slay", "AC", "EV", "SH" }
local val = 0
for _,str in ipairs(linearlist) do
val = val + item_resist(str, it)*linear_resist_value(str)
end
local val1, val2 = val,val
if not only_linear_resists then
for _,str in ipairs(resistlist) do
local a,b = resist_value(str, it, cur, it2)
val1 = val1 + a
val2 = val2 + b
end
end
return val1,val2
end
function resist_vec(it)
local resistlist = { "rF", "rC", "rElec", "rPois", "rN", "MR", "rCorr", "SInv", "Spirit" }
local vec = { }
for _,str in ipairs(resistlist) do
local a,b = resist_value(str, it)
table.insert(vec, b > 0 and b or a)
end
return vec
end
function base_equip_value(it)
only_linear_resists = true
local val1, val2 = equip_value(it)
only_linear_resists = false
return val1,val2
end
-- complicated check:
-- is it going to be worse than it2 no matter what other resists we have?
function resist_dominated(it,it2)
local bmin, bmax = base_equip_value(it)
local bmin2, bmax2 = base_equip_value(it2)
local diff = bmin2 - bmax
if diff < 0 then
return false
end
local vec = resist_vec(it)
local vec2 = resist_vec(it2)
local l = #vec
for i = 1,l do
if vec[i] > vec2[i] then
diff = diff - (vec[i] - vec2[i])
end
end
return (diff >= 0)
end
function rune_goal()
return 3 + (ABYSSAL_RUNE and 1 or 0) + (SLIMY_RUNE and 1 or 0) + (PAN_RUNE and 5 or 0) + (HELL_RUNE and 4 or 0) + (GOLDEN_RUNE and 1 or 0)
end
function easy_runes()
return (you.have_rune("decaying") and 1 or 0)
+ (you.have_rune("serpentine") and 1 or 0)
+ (you.have_rune("barnacled") and 1 or 0)
+ (you.have_rune("gossamer") and 1 or 0)
end
function update_game_status()
if you.have_orb() then
game_status = "orbrun"
return
end
if game_status == "normal" and you.have_rune("silver")
and not where:find("Vaults") and not where:find("Abyss") then
game_status = "shopping"
end
if game_status == "shopping" and c_persist.done_shopping then
game_status = endgame_plan_list[1]
end
while (game_status == "slime" and you.have_rune("slimy") and not where:find("Slime")
or game_status == "pan" and have_pan_runes() and where ~= "Pan"
and not where:find("Abyss")
or game_status == "abyss" and you.have_rune("abyssal") and not where:find("Abyss"))
or game_status == "hells" and have_hell_runes() and where ~= "Hell"
and not where:find("Dis") and not where:find("Geh")
and not where:find("Coc") and not where:find("Tar")
and not where:find("Abyss")
or game_status == "tomb" and you.have_rune("golden")
and not where:find("Tomb") and not where:find("Abyss")
or game_status == "tso" and you.god() == "the Shining One"
or game_status == "zig" and c_persist.entered_zig and not where:find("Zig") do
which_endgame_plan = which_endgame_plan + 1
game_status = endgame_plan_list[which_endgame_plan]
end
end
function zot_soon()
return (game_status == "zot")
end
function slime_soon()
return (game_status == "slime")
end
function in_extended()
return (game_status == "pan" or game_status == "hells" or game_status == "tomb")
end
-- list of armour slots, this is used to normalize names for them and also
-- to iterate over the slots
good_slots = {cloak="Cloak", helmet="Helmet",
gloves="Gloves", boots="Boots", body="Armour", shield="Shield"}
function armour_value(it, cur, it2)
local name = it.name()
local value = 0
local val1,val2 = total_resist_value(it, cur, it2)
local ego = it.ego()
if it.artefact then
if not it.fully_identified then -- could be good or bad
val2 = val2 + 400
val1 = val1 + (cur and 400 or -400)
end
ap = it.artprops
if ap and (ap["-Tele"] or ap["*Tele"]) and you.race() ~= "Formicid" then
return -1,-1
end
if ap and ap["*Rage"] and you.race() ~= "Mummy"
and you.race() ~= "Ghoul" and you.race() ~= "Formicid" then
return -1,-1
end
if name:find("Pondering") or name:find("hauberk") then
return -1,-1
end
if ap and ap["Fragile"] then
return -1,-1
end
if ap and ap["*Slow"] and you.race() ~= "Formicid" then
value = value - 100
end
if ap and ap["*Corrode"] then
value = value - 100
end
elseif name:find("runed") or name:find("glowing") or name:find("dyed") or
name:find("embroidered") or name:find("shiny") then
val2 = val2 + 400
val1 = val1 + (cur and 400 or -200)
elseif ego then -- names in armour_ego_name()
if ego == "running" then
value = value + 25
if you.god() == "Cheibriados" then
return -1,-1
end
elseif ego == "flying" and not intrinsic_flight() then
if not intrinsic_flight() then
value = value + 200
end
elseif ego == "ponderousness" then
return -1,-1
elseif ego == "repulsion" then
value = value + 200
end
end
value = value + 50*expected_armour_multiplier()*it.ac
if it.plus then
value = value + 50*it.plus
end
st, _ = it.subtype()
if good_slots[st] == "Shield" then
if it.encumbrance == 0 then
if not want_buckler() then
return -1,-1
end
elseif (not want_shield()) and (have_two_hander() or you.base_skill("Shields") == 0) then
return -1,-1
end
end
-- name always starts with {boots armour} here
-- ^ is no longer true I think?
if good_slots[st] == "Boots" then
if you.race() == "Centaur" then
if not (name:find("centaur barding")
or name:find("horse barding")) then
return -1,-1
end
elseif you.race() == "Naga" then
if not (name:find("naga barding")
or name:find("lightning scales")) then
return -1,-1
end
else
if name:find("barding") then
return -1,-1
end
end
end
if good_slots[st] == "Armour" then
if unfitting_armour() then
value = value - 25*it.ac
end
evp = it.encumbrance
ap = armour_plan()
if ap == "heavy" or ap == "large" then
if evp >= 20 then
value = value - 100
elseif name:find("pearl dragon") then
value = value + 100
end
elseif ap == "dodgy" then
if evp > 11 then
return -1,-1
elseif evp > 7 then
value = value - 100
end
else
if evp > 7 then
return -1,-1
elseif evp > 4 then
value = value - 100
end
end
end
return value+val1,value+val2
end
function weapon_value(it, cur, it2, sit)
local hydra_swap = (sit == "hydra")
local extended = (sit == "extended")
local tso = you.god() == "the Shining One" or extended and TSO_CONVERSION
or you.god() == "Elyvilon"
or you.god() == "Zin"
or you.god() == "No God" and MIGHT_BE_GOOD
if it.class(true) ~= "weapon" then
return -1,-1
end
local name = it.name()
local value = 1000
if it.weap_skill ~= wskill() then
weap = items.equipped_at("Weapon")
if weap and weap.weap_skill == wskill() or wskill() == "Unarmed Combat"
or it.weap_skill == "Crossbows" or it.weap_skill == "Bows"
or it.weap_skill == "Slings" then
if not (hydra_swap and (it.weap_skill == "Maces & Flails" and wskill() == "Axes" or it.weap_skill == "Short Blades" and wskill() == "Long Blades")) then
return -1,-1
end
end
end
if it.hands == 2 and want_buckler() then
return -1,-1
end
if sit == "bless" then
local val1, val2 = 0, 0
if it.artefact then
return -1,-1
elseif name:find("runed") or name:find("glowing")
or name:find("enchanted")
or it.ego() and not it.fully_identified then
val2 = val2 + 150
val1 = val1 + (cur and 150 or -150)
end
if it.plus then
value = value + 30*it.plus
end
delay_estimate = min(7,math.floor(it.delay / 2))
if it.weap_skill == "Short Blades" and delay_estimate > 5 then
delay_estimate = 5
end
value = value + 1200*it.damage/delay_estimate
return value+val1, value+val2
end