Channel staff macro


If it doesn't fit anywhere else, it belongs here. Also, come here if you just need to get hammered.

Lair Larrikin

Posts: 18

Joined: Tuesday, 8th May 2018, 15:50

Post Tuesday, 22nd May 2018, 16:40

Channel staff macro

Is it possible to set up a marcro to channel your staff of energy?

Slime Squisher

Posts: 344

Joined: Tuesday, 14th April 2015, 19:56

Location: France

Post Tuesday, 22nd May 2018, 16:55

Re: Channel staff macro

It is, look at this post : https://crawl.develz.org/tavern/viewtopic.php?f=5&t=25127&p=326294#p326294.
Copy the code into your rcfile and macro a key to ===launch_auto_channel and it will use the staff until your MP is full or a monster comes into view or you find yourself in a cloud.

P.S. Don't launch the macro next to an acid wall, it doesn't check that.
3 runes : MiMo^Ru, HOFi^Beogh, TrMo^Yredelemnul, GrFi^Ru, FoFi^Gozag, MiGl^Okawaru
4 runes : DDFi^Makhleb
5 runes : GrEE^Vehumet
15 runes : MiFi^Ru, NaWz^Sif Muna, GrWz^Sif Muna
I mostly play offline or online on CXC

Lair Larrikin

Posts: 18

Joined: Tuesday, 8th May 2018, 15:50

Post Tuesday, 22nd May 2018, 17:26

Re: Channel staff macro

thanks

Halls Hopper

Posts: 81

Joined: Friday, 17th April 2015, 23:46

Post Wednesday, 23rd May 2018, 21:07

Re: Channel staff macro

EDIT: Don't use this function without fixing it first. It only checks if there are monsters in LoS before channeling, instead of every turn.

Another macro, which I don't know if it is better or worse, I just took it a long time ago from ElanMorin's rc.

  Code:
-- Global variables for storing channeling information.
channel_switched_weapon = false
pre_channel_slot        = nil

-- Custom function for equipping a staff of energy and channeling until
-- full MP is full (if no enemies are visible).
-- Bind via macro definition:
-- M:6
-- A:===custom_channel
function custom_channel()
  channel_switched_weapon = false
  local have_staff        = false
  local weapon            = items.equipped_at("Weapon")

  if mp_percent() == 100 then
    crawl.mpr("You already have full MP!")
    return
  end

  if weapon and (weapon.name():find("staff of energy") or
                 weapon.name():find("staff of Wucad")) then
    have_staff = true
  else
    for it in iter.invent_iterator:new(items.inventory()) do
      if it and (it.name():find("staff of energy") or
                 it.name():find("staff of Wucad")) then
        have_staff              = true
        channel_switched_weapon = true
        pre_channel_slot        = items.index_to_letter(weapon.slot)
        local slot              = items.index_to_letter(it.slot)
        crawl.sendkeys('w' .. slot)
        break
      end
    end
  end

  if is_enemy_in_los() then
    crawl.mpr("Don't channel like a madman with enemies in LOS ;)")
  elseif not have_staff then
    crawl.mpr("No staff of energy for channeling!")
  else
    crawl.sendkeys('0' .. '1' .. '0' .. '0' .. 'v')
  end
end

-- Helper function returning true if a hostile creature is in LOS
function is_enemy_in_los()
  local x,y
  for x = -7,7 do
    for y = -7,7 do
      m = monster.get_monster_at(x,y)
      -- 0 = hostile, 1 = neutral, 2 = friendly
      if m and m:attitude() < 1 then
        return true
      end
    end
  end
  return false
end

function ready()
  AnnounceDamage()
  OpenSkills()

  -- Change back to the original weapon if it was changed by channeling
  -- and no enemies are in LOS.
  if channel_switched_weapon then
    if not is_enemy_in_los() then
      crawl.sendkeys('w' .. pre_channel_slot)
    end

    pre_channel_slot        = nil
    channel_switched_weapon = false
  end
   
end



Last edited by quik on Friday, 25th May 2018, 11:40, edited 2 times in total.

Lair Larrikin

Posts: 18

Joined: Tuesday, 8th May 2018, 15:50

Post Thursday, 24th May 2018, 17:16

Re: Channel staff macro

thanks :)

Slime Squisher

Posts: 344

Joined: Tuesday, 14th April 2015, 19:56

Location: France

Post Thursday, 24th May 2018, 17:48

Re: Channel staff macro

I'm not too sure how the command '0' works, but I think that quik's macro would keep channelling if a monster comes into view, which might be dangerous. Or does '0' stop firing if a monster enters LOS?
3 runes : MiMo^Ru, HOFi^Beogh, TrMo^Yredelemnul, GrFi^Ru, FoFi^Gozag, MiGl^Okawaru
4 runes : DDFi^Makhleb
5 runes : GrEE^Vehumet
15 runes : MiFi^Ru, NaWz^Sif Muna, GrWz^Sif Muna
I mostly play offline or online on CXC

Halls Hopper

Posts: 81

Joined: Friday, 17th April 2015, 23:46

Post Friday, 25th May 2018, 09:01

Re: Channel staff macro

I have no clue what that line does, but I've used this macro in some games and it seems to work perfectly fine. Sorry I can't give you a better reply :)

Slime Squisher

Posts: 368

Joined: Thursday, 11th April 2013, 21:07

Post Friday, 25th May 2018, 11:12

Re: Channel staff macro

quik wrote:Another macro, which I don't know if it is better or worse, I just took it a long time ago from ElanMorin's rc.
Spoiler: show
  Code:
-- Global variables for storing channeling information.
channel_switched_weapon = false
pre_channel_slot        = nil

-- Custom function for equipping a staff of energy and channeling until
-- full MP is full (if no enemies are visible).
-- Bind via macro definition:
-- M:6
-- A:===custom_channel
function custom_channel()
  channel_switched_weapon = false
  local have_staff        = false
  local weapon            = items.equipped_at("Weapon")

  if mp_percent() == 100 then
    crawl.mpr("You already have full MP!")
    return
  end

  if weapon and (weapon.name():find("staff of energy") or
                 weapon.name():find("staff of Wucad")) then
    have_staff = true
  else
    for it in iter.invent_iterator:new(items.inventory()) do
      if it and (it.name():find("staff of energy") or
                 it.name():find("staff of Wucad")) then
        have_staff              = true
        channel_switched_weapon = true
        pre_channel_slot        = items.index_to_letter(weapon.slot)
        local slot              = items.index_to_letter(it.slot)
        crawl.sendkeys('w' .. slot)
        break
      end
    end
  end

  if is_enemy_in_los() then
    crawl.mpr("Don't channel like a madman with enemies in LOS ;)")
  elseif not have_staff then
    crawl.mpr("No staff of energy for channeling!")
  else
    crawl.sendkeys('0' .. '1' .. '0' .. '0' .. 'v')
  end
end



Don't use the channeling macro quik posted above if you want your dudes to live. It's suicidal to use that macro on an uncleared dungeon floor.

Firing repeat actions with '0' does not check for enemies present onscreen in-between repeating its keypresses. If something dangerous comes into view after you have fired your 100 channeling attempts, your character is done. ed: your character will end up adjacent to it and have taken some damage before you're given another chance to act. Whoever wrote the macro made a halfhearted attempt to prevent this by at least making sure no enemies were onscreen at the time it fires the repeat command, but that does nothing to prevent something dangerous from walking onscreen and splatting your dude in the 100 turns of blind channeling it does after it has been fired. (Also, I don't think that is_enemy_in_los() is actually defined by default, and there's presumably another portion of that .rcfile that remains unposted that would be necessary for that macro to work as intended..)


Fingolfin's macro checks los every turn for enemies, and doesn't use Crawl's repeat keypress at all. In comparison, this is much safer, although there are a lot of further improvements that could be done.
Last edited by Implojin on Friday, 25th May 2018, 12:01, edited 1 time in total.

For this message the author Implojin has received thanks:
Fingolfin

Halls Hopper

Posts: 81

Joined: Friday, 17th April 2015, 23:46

Post Friday, 25th May 2018, 11:28

Re: Channel staff macro

Sorry, my bad. This is the part of the code missing, just in case the behavior of the function changes:

  Code:
-- Helper function returning true if a hostile creature is in LOS
function is_enemy_in_los()
  local x,y
  for x = -7,7 do
    for y = -7,7 do
      m = monster.get_monster_at(x,y)
      -- 0 = hostile, 1 = neutral, 2 = friendly
      if m and m:attitude() < 1 then
        return true
      end
    end
  end
  return false
end

function ready()
  AnnounceDamage()
  OpenSkills()

  -- Change back to the original weapon if it was changed by channeling
  -- and no enemies are in LOS.
  if channel_switched_weapon then
    if not is_enemy_in_los() then
      crawl.sendkeys('w' .. pre_channel_slot)
    end

    pre_channel_slot        = nil
    channel_switched_weapon = false
  end
   
end

Halls Hopper

Posts: 81

Joined: Friday, 17th April 2015, 23:46

Post Friday, 25th May 2018, 11:39

Re: Channel staff macro

I just tested the function in Wizard Mode and the repetition only stops when taking damage. I guess I was lucky when I used it. Thanks, Implojin.

For this message the author quik has received thanks:
Implojin

Slime Squisher

Posts: 368

Joined: Thursday, 11th April 2013, 21:07

Post Friday, 25th May 2018, 11:58

Re: Channel staff macro

quik wrote:I just tested the function in Wizard Mode and the repetition only stops when taking damage.

Oh, that's less suicidal than I thought. Good to know!

I tested it against a rat, which was missing enough to not trigger AI_HP_LOSS. (Also, AI_MONSTER_ATTACKS might not be working as intended? It doesn't seem to fire on a dodge.)

Still, probably not a great idea to use unless you want to risk letting something dangerous walk adjacent to your character and get a free swing in.

For this message the author Implojin has received thanks:
Fingolfin

Return to Crazy Yiuf's Corner

Who is online

Users browsing this forum: No registered users and 48 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.