Need a macro for Necromutation and Channel Energy


Ask fellow adventurers how to stay alive in the deep, dark, dangerous dungeon below, or share your own accumulated wisdom.

Temple Termagant

Posts: 5

Joined: Thursday, 9th June 2011, 04:13

Post Friday, 7th October 2011, 17:49

Need a macro for Necromutation and Channel Energy

Hello Guys,

I was wondering if someone can show me a code that will basically do something like this

If in LichForm
-Loop Channel Energy (Sif Muna) Until
--Hostile Encounter
--OR
--Full of Mana
-

Thanks
User avatar

Tomb Titivator

Posts: 857

Joined: Monday, 31st January 2011, 23:19

Post Friday, 7th October 2011, 21:34

Re: Need a macro for Necromutation and Channel Energy

That would be nice even without necromutation. You can probably channel the entire game and still never run out of food.
User avatar

Dungeon Master

Posts: 4031

Joined: Thursday, 16th December 2010, 20:37

Location: France

Post Friday, 7th October 2011, 21:38

Re: Need a macro for Necromutation and Channel Energy

There was a lua script once, designed for mummy of Sif to make them use channeling when resting. I think I lost it, but it's certainly possible to write one.
<+Grunt> You dereference an invalid pointer! Ouch! That really hurt! The game dies...
User avatar

Tomb Titivator

Posts: 857

Joined: Monday, 31st January 2011, 23:19

Post Friday, 14th October 2011, 09:31

Re: Need a macro for Necromutation and Channel Energy

I found this but I can't seem to get it to work.

  Code:
---------------------------------------------------------------------------
-- autochannel.lua:
-- Automatically fill up on mana from Sif Muna or staff of channeling.
--
-- To use this, add this line to your init.txt:
--   lua_file = lua/autochannel.lua
-- ... or inline it.
-- Then macro any key to "===autochannel_staff" or "===autochannel_sif".
--
-- WARNING! Make sure channel energy is still on 'a' or autochannel_sif won't
-- work, probably getting stuck in an infinite loop.
--
-- Written by ekiM, suggestions or additions welcome!
-- Created: 2011-03-20
-- Last updated: 2011-03-21
---------------------------------------------------------------------------
-- BUGS
-- If 'aa' is not channel energy then autochannel_sif may loop forever.
---------------------------------------------------------------------------
-- TODO: Remove spurious mpr('')s when CDO updates Trunk
-- TODO: Check wield of staff was successful.
-- TODO: If currently wielded item is cursed, can't wield.
-- TODO: Check for infinite loops, just in case. Idea: if MP didn't increase
-- after X uses of command, ask if the player is sure they want to do this.
-- TODO: Give a message explaining what interrupted autochanneling.
-- TODO: Find the slot for the channel energy ability.  Alternatively, call
-- channel energy directly, if that's possible.
-- TODO: Switch back to previously wielded item (or ask?) when done or
-- interrupted.
-- TODO: Some way to quit early?
-- TODO: More checking for whether autochanneling is advisable?
-- e.g., very low hp, poisoned, glowing, rotting...
-- TODO: Make gaining Invocations skill/levels interrupt channeling.
-- Maybe ask if the player want to turn off Invocations?
-- TODO: Create a function that asks how much MP to channel then does
-- channel_loop until that much MP has been channeled, or we max out, or
-- we are interrupted.
-- TODO: Create a function to save how much energy the player likes to
-- autochannel
-- TODO: The above functions, as percentages of max mp?
---------------------------------------------------------------------------

function autochannel_staff()
    -- Try to get a staff of channeling wielded, then loop channeling
    to_match = "channeling"
    if mp_full() then return end
    if items.equipped_at(0) == nil or
        not string.find(items.equipped_at(0).name(),to_match) then
        local found = false
        for k,v in pairs(items.inventory()) do
            if string.find(v.name(),to_match) then
                if not v.cursed or v.cursed and
                    crawl.yesno("Wield cursed staff?",true,'n') then
                    v.wield()
                    coroutine.yield(true)
                    crawl.mpr('')
                    found = true
                    break
                end
            end
        end
        if not found then
            crawl.mpr("You need a suitable staff in order to channel. Sorry!")
            return
        end
    end
    if not mp_full() then channel_loop('v') end
end

function autochannel_sif()
    -- Check you have the channel energy (a)bility, then loop channeling
    local can_channel = false
    for k,v in pairs(you.abilities()) do
        if v == "Channel Energy" then can_channel = true end
    end
    if not can_channel then
        crawl.mpr('Sif Muna is not letting you channel energy. Sorry!')
        return
    end
    if not mp_full() then channel_loop('aa') end
end

function mp_full()
    -- return true if mp == max_mp else false
    local mp, max_mp = you.mp()
    if mp == max_mp then
        crawl.mpr("Your mana batteries are already full!")
        return true
    else
        return false
    end
end

function channel_loop(command)
    -- Repeat command while mp < max_mp, prompting for breaks if hungry or
    -- if hunger status changes.
    local mp, max_mp = you.mp()
    local hungry_ok, very_hungry_ok, near_starving_ok = false

    while you.mp() < max_mp do
        local hunger = you.hunger()
        if not hungry_ok and hunger == "hungry" then
            if crawl.yesno("Autochannel while hungry?",false,'n') then
                hungry_ok = true
            else
                return
            end
        elseif not very_hungry_ok and hunger == "very hungry" then
            if crawl.yesno("Autochannel while very hungry?",false,'n') then
                very_hungry_ok = true
            else
                return
            end
        elseif not near_starving_ok and hunger == "near starving" then
            if crawl.yesno("Autochannel while near starving?",false,'n') then
                near_starving_ok = true
            else
                return
            end
        elseif hunger == "starving" then
            crawl.mpr("You are starving! You should eat RIGHT NOW!")
            return
        else
            crawl.process_keys(command)
            coroutine.yield(true)
            crawl.mpr('')
        end
    end
end


function channeling_interrupt_macro(interrupt_name)
    return interrupt_name == "force" or
    interrupt_name == "statue" or
    interrupt_name == "message" or
    interrupt_name == "hp_loss" or
    interrupt_name == "burden" or
    interrupt_name == "stat" or
    interrupt_name == "monster" or
    interrupt_name == "monster_attack" or
    interrupt_name == "teleport"
end

chk_interrupt_macro.autochannel_sif = channeling_interrupt_macro
chk_interrupt_macro.autochannel_staff = channeling_interrupt_macro


Return to Dungeon Crawling Advice

Who is online

Users browsing this forum: No registered users and 57 guests

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