Page 1 of 1

RC options for stopping manual exploration

PostPosted: Monday, 25th May 2020, 11:23
by Odds
I would like my movement keys to stop working until I press Enter whenever a monster appears on the screen (so that I can manually explore somewhat fast without accidentally continuing moving after seeing a monster). My attempt of adding "force_more_message += into view" to my rc file nearly works, but not every monster triggers this - I think monsters I've seen before don't trigger any message, though I'm not 100% sure what the logic is.

I've had a look at https://github.com/crawl/crawl/blob/mas ... _guide.txt, but I can't see a way to do this - any tips?

Re: RC options for stopping manual exploration

PostPosted: Tuesday, 26th May 2020, 11:32
by VeryAngryFelid
I believe it is not possible. I investigated it and had to create my own version of crawl to solve the "monster already seen" problem. It was several years ago, but most likely it is still current situation.

Re: RC options for stopping manual exploration

PostPosted: Tuesday, 26th May 2020, 12:21
by vt
I think if you go the route where you put force_mores on messages, you will want to catch it when you discover some monster when it "opens the door" or "opens the gate," too.

Another approach is to use the safe moves listed in safe_move_shift.txt. These allow you to move but only when you're not in danger (when i_feel_safe() is true, if you want to look at the conditions). I have bound my movement keys to functions executing these or the normal movement, depending on the state of a global variable in the rcfile; I toggle the state by pressing escape. The effect is that I can hold down keys if I want until something comes into view (or something else makes me in danger), at which point the keys stop moving me, and I press escape to regain control. I just have to remember to press escape when the battle is over to go back into hold-down-movement-keys-mode.

A nice thing about this is that it's easy to turn off the whole thing and just play normally without the interruptions when I feel like it.

The lua interface gives you access to the i_feel_safe function with you.feel_safe, so a similar idea is write some lua to keep track of whether you feel safe each turn and trigger a force_more when you go from feeling safe to not feeling safe.

Good luck finding something that works for you!

Re: RC options for stopping manual exploration

PostPosted: Tuesday, 26th May 2020, 14:35
by Odds
vt wrote:I think if you go the route where you put force_mores on messages, you will want to catch it when you discover some monster when it "opens the door" or "opens the gate," too.

Another approach is to use the safe moves listed in safe_move_shift.txt. These allow you to move but only when you're not in danger (when i_feel_safe() is true, if you want to look at the conditions). I have bound my movement keys to functions executing these or the normal movement, depending on the state of a global variable in the rcfile; I toggle the state by pressing escape. The effect is that I can hold down keys if I want until something comes into view (or something else makes me in danger), at which point the keys stop moving me, and I press escape to regain control. I just have to remember to press escape when the battle is over to go back into hold-down-movement-keys-mode.

A nice thing about this is that it's easy to turn off the whole thing and just play normally without the interruptions when I feel like it.

The lua interface gives you access to the i_feel_safe function with you.feel_safe, so a similar idea is write some lua to keep track of whether you feel safe each turn and trigger a force_more when you go from feeling safe to not feeling safe.

Good luck finding something that works for you!

Your solution to this sounds good! Would you mind sharing the rcfile settings for it? I'm not sure how to either toggle a global variable, or to conditionally bind keys.

Re: RC options for stopping manual exploration

PostPosted: Wednesday, 27th May 2020, 18:00
by vt
Of course! Fair warning, I wouldn't call this elegant code :

  Code:
{
function custom_move_dl()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_DOWN_LEFT"
    else
        a[1] = "CMD_MOVE_DOWN_LEFT"
    end
    crawl.do_commands(a)
end

function custom_move_l()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_LEFT"
    else
        a[1] = "CMD_MOVE_LEFT"
    end
    crawl.do_commands(a)
end

function custom_move_d()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_DOWN"
    else
        a[1] = "CMD_MOVE_DOWN"
    end
    crawl.do_commands(a)
end

function custom_move_r()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_RIGHT"
    else
        a[1] = "CMD_MOVE_RIGHT"
    end
    crawl.do_commands(a)
end

function custom_move_dr()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_DOWN_RIGHT"
    else
        a[1] = "CMD_MOVE_DOWN_RIGHT"
    end
    crawl.do_commands(a)
end

function custom_move_u()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_UP"
    else
        a[1] = "CMD_MOVE_UP"
    end
    crawl.do_commands(a)
end

function custom_move_ur()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_UP_RIGHT"
    else
        a[1] = "CMD_MOVE_UP_RIGHT"
    end
    crawl.do_commands(a)
end

function custom_move_ul()
    a = {}
    if safe_move_toggle then
        a[1] = "CMD_SAFE_MOVE_UP_LEFT"
    else
        a[1] = "CMD_MOVE_UP_LEFT"
    end
    crawl.do_commands(a)
end

safe_move_toggle = true
crawl.setopt("mon_glyph += player : green")

function toggle_safe_move()
    if safe_move_toggle then
        safe_move_toggle = false
        crawl.message("<cyan>safe move off</cyan>", 0)
        crawl.setopt("mon_glyph += player : red")
    else
        safe_move_toggle = true
        crawl.message("<cyan>safe move on</cyan>", 0)
        crawl.setopt("mon_glyph += player : green")
    end
end
}

macros += M b ===custom_move_dl
macros += M h ===custom_move_l
macros += M j ===custom_move_d
macros += M k ===custom_move_u
macros += M l ===custom_move_r
macros += M n ===custom_move_dr
macros += M u ===custom_move_ur
macros += M y ===custom_move_ul

macros += M \{27} ===toggle_safe_move



Dump that whole thing in your rcfile. The macros at the bottom are where the actual keys are bound, so change those if you don't use vikeys to move or want the toggle to be on something other than escape.

I mocked up a version of the third idea too, which uses a force more instead of two modes for movement commands, and which is much more concise. This seems to work in a casual try-out but I haven't actually tested it in a real game or anything.

  Code:
{
  safe = you.feel_safe()

  function update_safe()
    local old_safe = safe
    safe = you.feel_safe()
    if not safe and old_safe then
      crawl.mpr("Danger!")
      crawl.more()
    end
  end

  function ready()
    update_safe()
  end
}

Re: RC options for stopping manual exploration

PostPosted: Wednesday, 27th May 2020, 20:57
by Odds
That's awesome, thanks! I'm using the second snippet (with the tiny change of logging "Danger!" in red using "warning"), and it's working great. My exploration has never been so safe.