Lair Larrikin
Posts: 18
Joined: Tuesday, 8th May 2018, 15:50
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
Slime Squisher
Posts: 344
Joined: Tuesday, 14th April 2015, 19:56
Location: France
Lair Larrikin
Posts: 18
Joined: Tuesday, 8th May 2018, 15:50
Halls Hopper
Posts: 81
Joined: Friday, 17th April 2015, 23:46
-- 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
Lair Larrikin
Posts: 18
Joined: Tuesday, 8th May 2018, 15:50
Slime Squisher
Posts: 344
Joined: Tuesday, 14th April 2015, 19:56
Location: France
Halls Hopper
Posts: 81
Joined: Friday, 17th April 2015, 23:46
Slime Squisher
Posts: 368
Joined: Thursday, 11th April 2013, 21:07
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
Halls Hopper
Posts: 81
Joined: Friday, 17th April 2015, 23:46
-- 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
Slime Squisher
Posts: 368
Joined: Thursday, 11th April 2013, 21:07
quik wrote:I just tested the function in Wizard Mode and the repetition only stops when taking damage.
Users browsing this forum: No registered users and 148 guests