-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathomegafunk.rc
840 lines (747 loc) · 22.5 KB
/
omegafunk.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
# Crawl Init file with some speedrun related things.
# See the README for further details:
# https://github.com/gammafunk/dcss-rc/blob/master/README.md
# NOTE: This file includes gammafunk.rc automatically. If you're using this RC
# as your RC file, see the notes at the top of gammafunk.rc about sections
# conditioned on my username, as those apply to this RC file as well.
################
### RC files ###
################
{
-- Prevent gammafunk.rc from attempting to load omegafunk.rc twice.
omegafunk_rc_loaded = true
-- Only load gammafunk.rc and RandomTiles.rc if we haven't already.
if not gammafunk_rc_loaded then
crawl.read_options("gammafunk.rc")
-- Only load RandomTiles for myself.
if you.name() == "omegafunk" then
crawl.read_options("RandomTiles.rc")
end
end
}
#################
### Interface ###
#################
# This doesn't seem to work when included from another RC, so set it here as
# well.
default_manual_training = true
############
## Macros ##
############
macros += M 6 ===one_turn_rest
macros += M 7 ===start_resting
macros += M ] ===save_char_defaults
# Only make these macros for my username. If copying this part of my RC
# directly into your own, remove these lines including the '{' and '}' if you
# don't want RandomTiles or save_with_message. If you want either of those,
# replace these lines with normal RC macro lines like:
#
# macros += M S ===save_with_message
# macros += M 8 ===new_random_tile
# ...
#
{
-- Must use crawl.setopt() for the name condition to work.
if you.name() == "omegafunk" then
crawl.setopt("macros += M 1 zz")
crawl.setopt("macros += M S ===save_with_message")
crawl.setopt("macros += M 8 ===new_random_tile")
crawl.setopt("macros += M 9 ===set_tile_by_name")
crawl.setopt("macros += M 0 ===toggle_tile_timer")
crawl.setopt("macros += M - ===toggle_random_tile")
end
}
###########
### Lua ###
###########
# Note: My final RC file has code from lua files found at:
# https://github.com/gammafunk/dcss-rc/blob/master/README.md
# starting from the line below. Some lua is in gammafunk.rc instead, which is
# sourced by this RC.
{
-----------------------------
---- Begin char_defaults ----
-----------------------------
-- See README.md for documentation.
weapon_skills = { "Maces & Flails", "Axes", "Polearms", "Staves",
"Unarmed Combat", "Short Blades", "Long Blades" }
ranged_skills = { "Throwing", "Ranged Weapons" }
other_skills = { "Fighting", "Armour", "Dodging", "Shields", "Stealth",
"Spellcasting", "Conjurations", "Hexes", "Summonings",
"Necromancy", "Translocations", "Alchemy", "Fire Magic",
"Ice Magic", "Air Magic", "Earth Magic", "Invocations",
"Evocations", "Shapeshifting" }
skill_glyphs = { [1] = "+", [2] = "*" }
chdat = nil
char_combo = you.race() .. you.class()
loaded_attempted = false
-- Wrapper of crawl.mpr() that prints text in white by default.
if not mpr then
mpr = function (msg, color)
if not color then
color = "white"
end
crawl.mpr("<" .. color .. ">" .. msg .. "</" .. color .. ">")
end
end
function skill_message(prefix, skill, skill_type, value)
local msg = ""
if prefix then
msg = prefix .. ";"
end
if skill_type then
msg = msg .. skill_type .. "(" .. skill .. "):" .. value
else
msg = msg .. skill .. ":" .. value
end
return msg
end
function save_char_defaults(quiet)
if you.class() == "Wanderer" then
return
end
if not c_persist.char_defaults then
c_persist.char_defaults = { }
end
c_persist.char_defaults[char_combo] = { }
chdat = c_persist.char_defaults[char_combo]
local msg = nil
local have_weapon = false
for _,sk in ipairs(weapon_skills) do
if you.train_skill(sk) > 0 then
chdat["Weapon"] = you.train_skill(sk)
msg = skill_message(nil, sk, "Weapon",
skill_glyphs[chdat["Weapon"]])
have_weapon = true
break
end
end
if not have_weapon then
chdat["Weapon"] = nil
end
local have_ranged = false
for _,sk in ipairs(ranged_skills) do
if you.train_skill(sk) > 0 then
chdat["Ranged"] = you.train_skill(sk)
msg = skill_message(msg, sk, "Ranged",
skill_glyphs[chdat["Ranged"]])
have_ranged = true
break
end
end
if not have_ranged then
chdat["Ranged"] = nil
end
for _,sk in ipairs(other_skills) do
if you.train_skill(sk) > 0 then
chdat[sk] = you.train_skill(sk)
msg = skill_message(msg, sk, nil, skill_glyphs[chdat[sk]])
else
chdat[sk] = nil
end
end
if not quiet then
mpr("Saved default for " .. char_combo .. ": " .. msg)
end
end
function have_defaults()
return you.class() ~= "Wanderer"
and c_persist.char_defaults ~= nil
and c_persist.char_defaults[char_combo] ~= nil
end
function load_char_defaults(quiet)
if not have_defaults() then
return
end
local msg = nil
local found_weapon = false
chdat = c_persist.char_defaults[char_combo]
for _,sk in ipairs(weapon_skills) do
if you.base_skill(sk) > 0 and chdat["Weapon"] then
you.train_skill(sk, chdat["Weapon"])
msg = skill_message(msg, sk, "Weapon",
skill_glyphs[chdat["Weapon"]])
found_weapon = true
else
you.train_skill(sk, 0)
end
end
if chdat["Weapon"] and not found_weapon then
you.train_skill("Unarmed Combat", chdat["Weapon"])
msg = skill_message(msg, "Unarmed Combat", "Weapon",
skill_glyphs[chdat["Weapon"]])
end
local found_ranged = false
for _,sk in ipairs(ranged_skills) do
if you.base_skill(sk) > 0 and chdat["Ranged"] then
you.train_skill(sk, chdat["Ranged"])
msg = skill_message(msg, sk, "Ranged",
skill_glyphs[chdat["Ranged"]])
found_ranged = true
else
you.train_skill(sk, 0)
end
end
if chdat["Ranged"] and not found_ranged then
you.train_skill("Throwing", chdat["Ranged"])
msg = skill_message(msg, "Throwing", "Ranged",
skill_glyphs[chdat["Ranged"]])
end
for _,sk in ipairs(other_skills) do
if chdat[sk] then
you.train_skill(sk, chdat[sk])
msg = skill_message(msg, sk, nil, skill_glyphs[chdat[sk]])
else
you.train_skill(sk, 0)
end
end
if not quiet and msg ~= "" then
mpr("Loaded default for " .. char_combo .. ": " .. msg)
end
end
function char_defaults(quiet)
if you.turns() ~= 0 then
return
end
if not load_attempted then
load_char_defaults(quiet)
load_attempted = true
-- Open the skill menu if we don't have settings to load.
if not have_defaults() then
crawl.sendkeys("m")
end
end
end
---------------------------
---- End char_defaults ----
---------------------------
-----------------------------
---- Begin speedrun_rest ----
-----------------------------
-- See README.md for documentation.
-- How many turns to rest at max.
num_rest_turns = 30
-- If true, look for a foot item inventory slot and use fallback_slot if we
-- can't find a ration. If false, always use fallback_slot.
automatic_slot = true
-- Slot where you keep your slow swing item.
fallback_slot = "c"
-- Set to true to have Na characters always walk instead of item swing if
-- they're able to walk slowly. This is not as turncount efficient for non-Chei
-- worshipers, but some Na players may prefer it over having to change the
-- wielded weapon.
naga_always_walk = false
-- Delay in milliseconds before sending the next walk command. Makes the
-- visuals a bit less jarring when using walk resting. Set to 0 to disable.
walk_delay = 50
-- To have the multi-turn rest ignore status change messages, add an entry here
-- giving the pattern of the message you'd like to ignore. The entries below
-- cover the transition messages from the regen spell, Trog's hand, and poison
-- status. The key should be the status that's seen in the output of
-- `you.status()` when the status is active, and the value should be a single
-- pattern string or an array of pattern strings matching the message you'd
-- like to ignore. See the lua string library manual for details on making
-- patterns.
status_messages = {
["poisoned"] = {"You feel[^%.]+sick%.",
"You are no longer poisoned%."},
["regenerating"] = {"You feel the effects of Trog's Hand fading%.",
"Your skin is crawling a little less now%."}
} --end status_messages
-- Like status_messages above, but for arbitrary messages. Any message matching
-- one of these patterns is ignored.
ignore_messages = {
--RandomTiles messages
"Trog roars: Now[^!]+!+",
"Sif Muna whispers: Become[^!]+!+",
"[^:]+ says: Become[^!]+!+",
--Debug messages
"Dbg:.*",
} -- end ignore_messages
-- NOTE: No configuration past this point.
ATT_NEUTRAL = 1
version = 0.15
if crawl.version then
version = tonumber(crawl.version("major"))
end
los_range = version >= 0.17 and 7 or 8
-- Wrapper of crawl.mpr() that prints text in white by default.
if not mpr then
mpr = function (msg, color)
if not color then
color = "white"
end
crawl.mpr("<" .. color .. ">" .. msg .. "</" .. color .. ">")
end
end
function control(c)
return string.char(string.byte(c) - string.byte('a') + 1)
end
function delta_to_vi(dx, dy)
local d2v = {
[-1] = { [-1] = 'y', [0] = 'h', [1] = 'b'},
[0] = { [-1] = 'k', [1] = 'j'},
[1] = { [-1] = 'u', [0] = 'l', [1] = 'n'},
} -- hack
return d2v[dx][dy]
end
function reset_rest()
if not rstate then
rstate = { }
rstate.set_slot = false
rstate.dir_x = nil
rstate.dir_y = nil
end
rstate.last_acted = nil
rstate.wielding = false
rstate.resting = false
rstate.num_turns = nil
rstate.rest_start = nil
rstate.start_hp = nil
rstate.start_status = { }
rstate.start_message = nil
end
function abort_rest(msg)
if msg then
mpr(msg, "lightred")
end
reset_rest()
end
function crawl_message(i)
local msg = crawl.messages(i):gsub("\n", "")
msg = msg:gsub("^%c* *", "")
msg = msg:gsub(" *%c*?$", "")
return msg
end
function record_status()
-- Record starting status to track any status changes.
rstate.start_status = { }
local status = you.status()
for s,_ in pairs(status_messages) do
if status:find(s) then
rstate.start_status[s] = true
end
end
rstate.start_message = get_last_message()
end
function in_water()
return view.feature_at(0, 0):find("water") and not you.status("flying")
end
function get_last_message()
local rest_type = get_rest_type()
local in_water = in_water()
-- Ignore these movement messages when walking.
local move_patterns = {"There is a[^%.]+here.",
"Things that are here:.*",
"Items here:.*"}
for i = 1,200 do
local msg = crawl_message(i)
for s,_ in pairs(rstate.start_status) do
if type(status_messages[s]) == "table" then
for _,p in ipairs(status_messages[s]) do
msg = msg:gsub(p, "")
end
else
msg = msg:gsub(status_messages[s], "")
end
end
if rest_type == "walk" then
for _,p in ipairs(move_patterns) do
-- Also remove any whitespace.
msg = msg:gsub(" *" .. p .. " *", "")
end
end
msg = msg:gsub(" *Beep! [^%.]+%. *", "")
for _,p in ipairs(ignore_messages) do
msg = msg:gsub(p, "")
end
if msg ~= "" then
return msg
end
end
return nil
end
function wield_swing_item()
rstate.wielding = true
rstate.last_acted = you.turns()
record_status()
crawl.sendkeys("w*" .. c_persist.swing_slot)
end
function find_swing_slot()
rstate.set_slot = true
if not automatic_slot then
c_persist.swing_slot = fallback_slot
return
end
c_persist.swing_slot = nil
for _,item in ipairs(items.inventory()) do
if item.class() == "Comestibles"
or item.class() == "Books"
or item.class() == "Wands"
or item.class() == "Missiles"
or item.class() == "Miscellaneous"
or (item.class() == "Hand Weapons"
and (item.subtype():find("bow")
or item.subtype():find("sling")
or item.subtype():find("crossbow")
or item.subtype():find("blowgun"))) then
c_persist.swing_slot = items.index_to_letter(item.slot)
break
end
end
if not c_persist.swing_slot then
c_persist.swing_slot = fallback_slot
end
end
function swing_item_wielded()
local weapon = items.equipped_at("Weapon")
return weapon
and c_persist.swing_slot ~= nil
and weapon.slot == items.letter_to_index(c_persist.swing_slot)
end
function hostile_in_los()
local have_t1 = false
for x = -los_range,los_range do
for y = -los_range,los_range do
m = monster.get_monster_at(x, y)
if m and not m:is_safe() then
return true
end
end
end
return false
end
function ponderous_level()
local level = 0
for _,item in ipairs(items.inventory()) do
local ego = item.ego()
if item.equipped and ego == "ponderousness" then
level = level + 1
end
end
return level
end
-- XXX See if we can move at least some of this into clua, since it's
-- recreating play_movement_speed() and player_speed(). The aim is to determine
-- if slow move is more regen-efficient and that the saving is worth the
-- hassle, this calculates the minimum move speed, which can normally vary at
-- random from randomized delay (e.g. water) and the many uses of
-- div_rand_round().
function player_move_speed()
if you.transform() == "tree" then
return 0
end
local in_water = in_water()
local walk_water = you.race() == "Merfolk"
or you.race() == "Octopode"
or you.race() == "Barachi"
or you.god() == "Beogh" and you.piety_rank() == 5
or you.transform == "ice"
-- This is player action speed, based on things that affect all actions.
local player_speed = 10
if you.status("slowed") then
player_speed = math.floor(player_speed * 3 / 2)
end
if you.status("berserking") and you.god() ~= "Cheibriados"
or you.status("hasted") then
player_speed = math.floor(player_speed * 2 / 3)
end
if you.transform() == "statue" or you.status("petrifying") then
player_speed = math.floor(player_speed * 3 / 2)
end
if in_water and not walk_water then
player_speed = math.floor(player_speed * 13 / 10)
end
-- This is the base player movement speed given all things that affect only
-- movement.
local move_speed = 10
if you.transform() == "bat" then
move_speed = 5
elseif you.transform() == "pig" then
move_speed = 7
elseif you.transform() == "porcupine" or you.transform == "wisp" then
move_speed = 8
elseif in_water and (you.transform() == "hydra"
or you.race() == "Merfolk") then
move_speed = 6
elseif you.race() == "Tengu" and you.status("flying") then
move_speed = 9
end
local boots = items.equipped_at("Boots")
local running_level = 0
if boots
and not boots.is_melded
and boots.ego()
and boots.ego() == "running" then
running_level = 1
end
move_speed = move_speed - running_level
move_speed = move_speed + ponderous_level()
if you.god() == "Cheibriados" then
-- Calculate this based on the minimum piety at the observed rank,
-- since we can't know the true piety level.
local piety_breaks = { 1, 30, 50, 75, 100, 120, 160 }
move_speed = move_speed + 2 +
math.floor(math.min(piety_breaks[you.piety_rank() + 1] / 20, 8))
end
if you.status("frozen") then
move_speed = move_speed + 4
end
if you.status("grasped by roots") then
move_speed = move_speed + 3
end
local speed_mut = you.mutation("speed")
local slow_mut = you.mutation("slowness")
if speed_mut > 0 then
move_speed = move_speed - speed_mut - 1
elseif slow_mut > 0 then
move_speed = math.floor(move_speed * (10 + slow_mut * 2) / 10)
end
if not in_water and you.status("sluggish") then
if move_speed >= 8 then
move_speed = math.floor(move_speed * 3 / 2)
elseif move_speed == 7 then
move_speed = math.floor(7 * 6 / 5)
end
elseif not in_water and you.status("swift") then
move_speed = math.floor(move_speed * 3 / 4)
end
if move_speed < 6 then
move_speed = 6
end
return math.floor(player_speed * move_speed / 10)
end
function get_rest_type()
if you.race() == "Naga" and naga_always_walk
or you.god() == "Cheibriados"
or (not swing_item_wielded()
and not weapon_can_swap()) then
return "walk"
else
return "item"
end
end
function bad_to_act()
local hp, mhp = you.hp()
local rest_type = get_rest_type()
-- Stop multiple turn action when our hp recovers.
if rstate.rest_start and rstate.start_hp < mhp and hp == mhp then
mpr("HP restored.")
reset_rest()
return true
end
if you.status("manticore barbs") then
abort_rest("You must remove the manticore barbs first.")
return true
end
if you.hunger_name() == "fainting" or you.hunger_name() == "starving" then
abort_rest("You need to eat!")
return true
end
if hostile_in_los() then
if not rstate.rest_start then
abort_rest("You can't rest with a hostile monster in view!")
else
abort_rest()
end
return true
end
-- If any unrecognized message occurs, assume we need to stop resting.
if rstate.last_acted then
local msg = get_last_message()
if not msg then
abort_rest("Unable to find a previous message!")
return true
end
local wield_pt = "^ *" .. c_persist.swing_slot .. " - .+[%)}] *$"
local swing_pt = "^ *You swing at nothing%. *$"
local pattern = rstate.wielding and wield_pt or swing_pt
if (rest_type == "item" and not msg:find(pattern))
or rest_type == "walk" and msg ~= rstate.start_message then
abort_rest()
return true
end
end
if rest_type == "walk" and player_move_speed() <= 10 then
abort_rest("You cannot walk slowly right now!")
return true
end
return false
end
function feat_is_open(feat)
local fname = feat:lower()
-- Unique substrings that identify solid features.
local solid_features = {"wall", "grate", "tree", "mangrove",
"endless_lava", "open_sea", "statue", "idol",
"malign_gateway", "sealed_door", "closed_door",
"runed_door", "explore_horizon"}
for i,p in ipairs(solid_features) do
if fname:find(p) then
return false
end
end
return true
end
function safe_walk_pos(x, y)
local in_water = in_water()
local pos_is_water = view.feature_at(x, y):find("water")
-- Don't allow walking out of water if we're in water
return (in_water and pos_is_water
-- Don't allow walking into water if we're not in it
or not in_water and not pos_is_water)
-- Require the destination to be safe.
and view.is_safe_square(x, y)
end
function safe_swing_pos(x, y)
return not monster.get_monster_at(x, y)
and feat_is_open(view.feature_at(x,y))
end
function safe_direction(x, y)
if get_rest_type() == "walk" then
return safe_walk_pos(x, y)
else
return safe_swing_pos(x, y)
end
end
function weapon_can_swap()
local weapon = items.equipped_at("Weapon")
if not weapon then
return true
end
if weapon.cursed then
return false
end
local ego = weapon.ego()
-- Some unrands like Plut. sword have no ego.
if ego
and (ego == "vampirism"
or ego == "distortion" and you.god() ~= "Lugonu") then
return false
end
if weapon.artefact then
local artp = weapon.artprops
return not (artp["*Contam"] or artp["*Curse"] or artp["*Drain"])
end
return true
end
function get_safe_direction()
local have_t1 = false
for x = -1,1 do
for y = -1,1 do
if (x ~= 0 or y ~= 0) and safe_direction(x, y) then
return x, y
end
end
end
return nil
end
function do_resting()
-- Our first turn of resting.
if not rstate.rest_start then
record_status()
rstate.rest_start = you.turns()
rstate.start_hp = you.hp()
end
rstate.last_acted = you.turns()
local rest_type = get_rest_type()
if rest_type == "item" then
crawl.sendkeys(control(delta_to_vi(rstate.dir_x, rstate.dir_y)))
else
local cur_x = rstate.dir_x
local cur_y = rstate.dir_y
-- Save the return direction as our next direction.
rstate.dir_x = -rstate.dir_x
rstate.dir_y = -rstate.dir_y
crawl.sendkeys(delta_to_vi(cur_x, cur_y))
crawl.delay(walk_delay)
end
end
function one_turn_rest()
rstate.resting = true
rstate.num_turns = 1
end
function start_resting()
rstate.resting = true
rstate.num_turns = num_rest_turns
end
function set_swing_slot()
crawl.formatted_mpr("Enter an slot letter for the swing item: ", "prompt")
local letter = crawl.c_input_line()
local index = items.letter_to_index(letter)
if not index or index < 0 then
mpr("Must be a letter (a-z or A-Z)!", "lightred")
return
end
c_persist.swing_slot = letter
rstate.set_slot = true
mpr("Set swing slot to " .. letter .. ".")
end
function speedrun_rest()
local rest_type = get_rest_type()
if rest_type == "item"
and (not c_persist.swing_slot
or you.turns() == 0 and not rstate.set_slot) then
find_swing_slot()
end
if not rstate.resting then
return
end
-- Only act once per turn.
if rstate.last_acted == you.turns() then
-- An error happened with the 'w' command
if rstate.wielding and not swing_item_wielded() then
abort_rest("Unable to wield swing item on slot " ..
c_persist.swing_slot .. "!")
end
return
end
if rstate.last_acted and rstate.rest_start
and rstate.last_acted + 1 >= rstate.rest_start + rstate.num_turns then
reset_rest()
return
end
if bad_to_act() then
return
end
if rest_type == "item" and not swing_item_wielded() then
wield_swing_item()
return
end
rstate.wielding = false
if not rstate.dir_x
-- Don't try to reuse our position if we were walk resting and did
-- something inbetween our last rest.
or swing_type == "walk" and rstat.last_acted ~= you.turns() - 1
or not safe_direction(rstate.dir_x, rstate.dir_y) then
rstate.dir_x, rstate.dir_y = get_safe_direction()
if not rstate.dir_x then
abort_rest("No safe direction found!")
return
end
end
do_resting()
end
reset_rest()
---------------------------
---- End speedrun_rest ----
---------------------------
}
# The ready() function is needed for code that has to process each turn or UI
# action.
{
function ready()
-- char_defaults.lua
char_defaults()
-- force_mores.lua
force_mores()
-- speedrun_rest.lua
speedrun_rest()
-- Enable these only for my usernames.
if you.name() == "omegafunk" then
-- load_message.lua
load_message()
-- RandomTiles
random_tile()
end
end
}