Temple Termagant
Posts: 13
Joined: Thursday, 23rd April 2015, 05:07
rc file causing lag on webtiles
Config is posted below for convenience.
- Code:
# For just the damage announcements
include += HDamage.rc
# For just the ===HDAtravel autotravel replacement macro
include += HDAtravel.rc
# For both the Message colors and Item colors
include += HDAColors.rc
# For just the Message colors
include += HDAMessageColors.rc
# For just the Item colors
include += HDAItemColors.rc
# For just the Force More prompts
include += HDAForceMore.rc
# Sources:
# https://github.com/crawl/crawl/tree/master/crawl-ref/source
# http://dobrazupa.org/rcfiles/crawl-git/qw.rc
# https://github.com/HilariousDeathArtist/DCSSConfigFile
# todo: unseen enemies, items other than bread, swap to old weapon, dont use is_traversable to check
# While wielding bread and if not at full HP and mana and if no enemies are nearby
<
function ready()
if is_wielding_nonweapon() and (not is_hp_full() or not is_mp_full()) and not is_enemy_near() then
local a = 0
local b = 0
for x = -1,1 do
for y = -1,1 do
if is_traversable(x,y) and not (x == 0 and y == 0) then
a = x
b = y
end
end
end
if a == 0 and b == 0 then
return
end
magic(control(delta_to_vi(a, b)))
end
end
function is_wielding_nonweapon()
local weapon = items.equipped_at("Weapon")
if (weapon == nil) then
return
end
return (contains_string_in(weapon:name(), {"bread","meat","beef","fruit","jelly","pizza","scroll"}))
end
function is_hp_full()
local hp, hmp = you.hp()
return (hp == hmp)
end
function is_mp_full()
local mp, mmp = you.mp()
return (mp == mmp)
end
function is_enemy_near()
local enemy_near = false
for x = -8,8 do
for y = -8,8 do
m = monster.get_monster_at(x, y)
local attitude_hostile = 0
if m and (m:attitude() == attitude_hostile) and not (m:is_firewood()) then
enemy_near = true
end
end
end
return enemy_near
end
function magic(command)
crawl.process_keys(command .. string.char(27) .. string.char(27) .. string.char(27))
end
function is_traversable(x,y)
local feat = view.feature_at(x,y)
return feat ~= "unseen" and travel.feature_traversable(feat)
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 contains_string_in(name,t)
for _, value in ipairs(t) do
if string.find(name, value) then
return true
end
end
return false
end
>
My rc uses bits of Hilarious Death Artist's rc and qw's rc. There is some custom code I wrote to automate breadswinging: when the player wields food or a scroll, the player swings that item until they're at full health. The lag occurs when player wields food or a scroll, and it often takes seconds to see a response from the server. Another issue I'm having is that my custom code seems to be suppressing some of HDA's rc from working--namely, announcements of how much damage I've taken in the last turn. Could someone check my code and see what needs to change to fix these issues? I wish there was more documentation to make debugging easier.