Aetolia Mapper

Post Reply
Riluo
Posts: 12
Joined: Sun Oct 24, 2010 5:30 am

Aetolia Mapper

Post by Riluo »

Hi guys,

I am very new to using mudlet and have noticed that the mudlet mapper in Aetolia is not using the in game PATH FIND commands to move from one area to the next.
Map Commands
---------------------

PATH FIND <room number>
- Create and display the path needed to go from your current room to
the room indicated.


PATH SHORTEST <room number>
- As above, but will not detour around enemy territory.

PATH SET <comma delimited path>
- Feeds the walker a preset path to follow. Valid entries include:
- Cardinal directions
- WORM WARP
- DUANATHAR / DUANATHARAN (if you have wings)
- VOLTDA / VOLTDARAN (if you have an amulet)

PATH GO [DASH/SPRINT/GALLOP]
- Start walking toward the room indicated in the MAP PATH command. The speedwalker will dash, sprint
or gallop if requested and you have the appropriate abilities or mount.

PATH STOP
- Stop the automatic walking.

PATH CLEAR
- Occasionally, the world turns on its head and you'll find you can't
speedwalk for some reason. Just PATH CLEAR and you should be able to
again.
It is extremely faster than the built in mudlet mapper at this point.

So my question is what do we need to change in the mudlet mapper to use PATH FIND / PATH GO<type> instead.

Thank you.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Aetolia Mapper

Post by Vadi »

Just use those commands then :) the mapper walking on its own still has advantages.

Riluo
Posts: 12
Joined: Sun Oct 24, 2010 5:30 am

Re: Aetolia Mapper

Post by Riluo »

Is there a way to edit into the mapper?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Aetolia Mapper

Post by Vadi »

For certain, the mapper is open source and all the code is there for you to view and edit.

Riluo
Posts: 12
Joined: Sun Oct 24, 2010 5:30 am

Re: Aetolia Mapper

Post by Riluo »

Any advice on what to change to add it in, as I am mudlet illiterate right now. So I am still reading the script in confusion. :oops:

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Aetolia Mapper

Post by Vadi »

Afraid no, I don't play Aetolia and don't know what do you want to do.

Riluo
Posts: 12
Joined: Sun Oct 24, 2010 5:30 am

Re: Aetolia Mapper

Post by Riluo »

Sorry what I am looking for is what is the command in mudlet mapper that makes it select the path and activate it. If I can track it down I will replace it with PATH FIND <--selects path, and PATH GO GALLOP <--starts the movement process.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Aetolia Mapper

Post by Vadi »

It is the speedwalking() function in the speedwalking script.

Riluo
Posts: 12
Joined: Sun Oct 24, 2010 5:30 am

Re: Aetolia Mapper

Post by Riluo »

I would not even know where to start to be honest, although I found the script so I guess that is a start :lol:

This is what is in mine, but I do not understand what to replace so that it does PATH FIND <roomnumber> followed by PATH GO GALLOP.
function mmp.gotoRoom(where, dashtype)
if not where or not tonumber(where) then
mmp.echo("Where do you want to go to?") return end

if tonumber(where) == mmp.currentroom then
mmp.echo("We're already at "..where.."!")
raiseEvent("mmapper arrived")
return
end

local madeduanathar, madeduanatharan, mademedallion, madefingerblade, madeblossom, madebelt, madecubix, madeprism, madescrewdriver, madewheel, mademud, madesnowglobe, madecookie, madehead, madeicicle, madetibia, madebonecurio, madeflowercurio, madetorus, madeutensilcurio, madefluttercurio, madetoolcurio, madefacecurio, madetoycurio, madefeathercurio, madefigurecurio, mademandala, madevernalcurio

local function getcmd(word)
if mmp.game == "achaea" then
return mmp.settings.removewings and
[[script:sendAll("wear wings", "say *]]..(mmp.settings.winglanguage)..[[ ]]..word..[[", "remove wings", false)]]
or
[[script:send("say *]]..(mmp.settings.winglanguage)..[[ ]]..word..[[", false)]]
elseif mmp.game == "lusternia" then
if word == "snowglobe" then
return [[script:send("shake snowglobe",false)]]
elseif word == "bonecurio" then
return [[script:send("curio collection activate bone",false)]]
elseif word == "flowercurio" then
return [[script:send("curio collection activate flower",false)]]
elseif word == "utensilcurio" then
return [[script:send("curio collection activate utensil",false)]]
elseif word == "fluttercurio" then
return [[script:send("curio collection activate flutter",false)]]
elseif word == "toolcurio" then
return [[script:send("curio collection activate tool",false)]]
elseif word == "facecurio" then
return [[script:send("curio collection activate face",false)]]
elseif word == "toycurio" then
return [[script:send("curio collection activate toy",false)]]
elseif word == "feathercurio" then
return [[script:send("curio collection activate feather",false)]]
elseif word == "figurecurio" then
return [[script:send("curio collection activate figure",false)]]
elseif word == "vernalcurio" then
return [[script:send("curio collection activate vernal",false)]]
else
return [[script:send("touch ]]..word..[[", false)]]
end
end
end

-- allow mapper 'addons' to link their own exits in
raiseEvent("mmp link externals")

if mmp.game == "achaea" and (mmp.settings.duanathar or mmp.settings.duanatharan) and gmcp.Room and not table.contains(gmcp.Room.Info.details, "indoors") and mmp.oncontinent(getRoomArea(mmp.currentroom), "Prime") then
if mmp.settings.duanatharan then
addSpecialExit(mmp.currentroom, 4882, getcmd("duanatharan"))
addSpecialExit(mmp.currentroom, 3885, getcmd("duanathar"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madeduanatharan = true
else
addSpecialExit(mmp.currentroom, 3885, getcmd("duanathar"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madeduanathar = true
end
elseif mmp.game == "lusternia" and (mmp.settings.medallion or mmp.settings.fingerblade or mmp.settings.blossom or mmp.settings.mandala or mmp.settings.belt or mmp.settings.cubix or mmp.settings.screwdriver or mmp.settings.wheel or mmp.settings.mud or mmp.settings.snowglobe or mmp.settings.cookie or mmp.settings.head or mmp.settings.icicle or mmp.settings.tibia or mmp.settings.bonecurio or mmp.settings.flowercurio or mmp.settings.torus or mmp.settings.vernalcurio) and gmcp.Room and (not table.contains(gmcp.Room.Info.details,"indoors") or table.contains(gmcp.Room.Info.details, "an Aetherbubble")) then
if mmp.settings.medallion and mmp.usebix() then
addSpecialExit(mmp.currentroom, 13367, getcmd("medallion"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
mademedallion = true
end
if mmp.settings.fingerblade and mmp.usebix() then
addSpecialExit(mmp.currentroom, 18777, getcmd("fingerblade"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madefingerblade = true
end
if mmp.settings.blossom and mmp.usebix() then
addSpecialExit(mmp.currentroom, 18730, getcmd("blossom"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madeblossom = true
end
if mmp.settings.mandala and mmp.usebix() then
addSpecialExit(mmp.currentroom, 19563, getcmd("mandala"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
mademandala = true
end
if mmp.settings.belt and mmp.usebix() then
addSpecialExit(mmp.currentroom, 19627, getcmd("belt"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madebelt = true
end
if mmp.settings.cubix and mmp.usebix() then
addSpecialExit(mmp.currentroom, 6184, getcmd("cubix"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madecubix = true
end
if mmp.settings.screwdriver and mmp.usebubblix() then
if gmcp.Room.Info.area == "the Facility" then
addSpecialExit(mmp.currentroom, 6831, getcmd("screwdriver"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 10185, getcmd("screwdriver"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madescrewdriver = true
end
if mmp.settings.wheel and mmp.usebubblix() then
if gmcp.Room.Info.area == "the Dramube Triangle" then
addSpecialExit(mmp.currentroom, 6831, getcmd("wheel"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 10509, getcmd("wheel"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madewheel = true
end
if mmp.settings.mud and mmp.usebubblix() then
if gmcp.Room.Info.area == "Mucklemarsh" then
addSpecialExit(mmp.currentroom, 6831, getcmd("mud"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 9985, getcmd("mud"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
mademud = true
end
if mmp.settings.snowglobe and mmp.usebubblix() then
if gmcp.Room.Info.area == "the Great Spirit Tree" then
addSpecialExit(mmp.currentroom, 6831, getcmd("snowglobe"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 10992, getcmd("snowglobe"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madesnowglobe = true
end
if mmp.settings.cookie and mmp.usebubblix() then
if gmcp.Room.Info.area == "Crumkindivia" then
addSpecialExit(mmp.currentroom, 6831, getcmd("cookie"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 9888, getcmd("cookie"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madecookie = true
end
if mmp.settings.head and mmp.usebubblix() then
if gmcp.Room.Info.area == "the Bubble of Bottledowns" then
addSpecialExit(mmp.currentroom, 6831, getcmd("doll"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 11811, getcmd("doll"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madedoll = true
end
if mmp.settings.icicle and mmp.usebubblix() then
if gmcp.Room.Info.area == "Frosticia" then
addSpecialExit(mmp.currentroom, 6831, getcmd("icicle"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 10457, getcmd("icicle"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madeicicle = true
end
if mmp.settings.tibia and mmp.usebubblix() then
if gmcp.Room.Info.area == "the Cankermore Battlegrounds" then
addSpecialExit(mmp.currentroom, 6831, getcmd("tibia"))
elseif not table.contains(gmcp.Room.Info.details, "an Aetherbubble") then
addSpecialExit(mmp.currentroom, 11600, getcmd("tibia"))
end
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madetibia = true
end
if mmp.settings.bonecurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28613, getcmd("bonecurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madebonecurio = true
end
if mmp.settings.flowercurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28624, getcmd("flowercurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madeflowercurio = true
end
if mmp.settings.torus and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28548, getcmd("torus")) -- room number will vary for each torus
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madetorus = true
end
if mmp.settings.utensilcurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28617, getcmd("utensilcurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madeutensilcurio = true
end
if mmp.settings.fluttercurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28622, getcmd("fluttercurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madefluttercurio = true
end
if mmp.settings.toolcurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28586, getcmd("toolcurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madetoolcurio = true
end
if mmp.settings.facecurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28433, getcmd("facecurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madefacecurio = true
end
if mmp.settings.toycurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 21548, getcmd("toycurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madetoycurio = true
end
if mmp.settings.feathercurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28591, getcmd("feathercurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madefeathercurio = true
end
if mmp.settings.figurecurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 28312, getcmd("figurecurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madefigurecurio = true
end
if mmp.settings.prism and mmp.useprism() then
addSpecialExit(mmp.currentroom, 6182, getcmd("prism"))
mmp.clearpathcache()
madeprism = true
end
if mmp.settings.vernalcurio and mmp.usebix() then
addSpecialExit(mmp.currentroom, 29908, getcmd("vernalcurio"))
mmp.clearpathcache() -- clear cache so mmp.getPath accounts for the new way
madevernalcurio = true
end
end

-- if getPath worked, then the dirs and room #'s tables were populated for us
if not mmp.getPath(mmp.currentroom, tonumber(where)) then
mmp.echo("Don't know how to get there ("..tostring(where)..") from here :(")
mmp.speedWalkPath = {}
mmp.speedWalkDir = {}
speedWalkCounter = 0
raiseEvent("mmapper failed path")
if mmp.settings.shackle then expandAlias("wear shackle") end
if madeduanatharan then mmp.clearspecials{4882, 3885} elseif madeduanathar then mmp.clearspecials{3885} end
if mademedallion then mmp.clearspecials{13367} end
if madefingerblade then mmp.clearspecials{18777} end
if madeblossom then mmp.clearspecials{18730} end
if mademandala then mmp.clearspecials{19563} end
if madebelt then mmp.clearspecials{19627} end
if madecubix then mmp.clearspecials{6184} end
if madescrewdriver then mmp.clearspecials{6831, 10185} end
if madewheel then mmp.clearspecials{6831, 10509} end
if mademud then mmp.clearspecials{6831, 9985} end
if madesnowglobe then mmp.clearspecials{6831, 10992} end
if madecookie then mmp.clearspecials{6831, 9888} end
if madehead then mmp.clearspecials{6831, 11811} end
if madeicicle then mmp.clearspecials{6831, 10457} end
if madetibia then mmp.clearspecials{6831, 11600} end
if madebonecurio then mmp.clearspecials{28613} end
if madeflowercurio then mmp.clearspecials{28624} end
if madetorus then mmp.clearspecials{28548} end
if madeutensilcurio then mmp.clearspecials{28617} end
if madefluttercurio then mmp.clearspecials{28622} end
if madetoolcurio then mmp.clearspecials{28586} end
if madefacecurio then mmp.clearspecials{28433} end
if madetoycurio then mmp.clearspecials{21548} end
if madefeathercurio then mmp.clearspecials{28591} end
if madefigurecurio then mmp.clearspecials{28312} end
if madeprism then mmp.clearspecials{6182} end
if madevernalcurio then mmp.clearspecials{22908} end

-- allow mapper 'addons' to unlink their special exits
raiseEvent("mmp clear externals")
return
end

doSpeedWalk(dashtype)
if madeduanatharan then mmp.clearspecials{4882, 3885} elseif madeduanathar then mmp.clearspecials{3885} end
if mademedallion then mmp.clearspecials{13367} end
if madefingerblade then mmp.clearspecials{18777} end
if madeblossom then mmp.clearspecials{18730} end
if mademandala then mmp.clearspecials{19563} end
if madebelt then mmp.clearspecials{19627} end
if madecubix then mmp.clearspecials{6184} end
if madescrewdriver then mmp.clearspecials{6831, 10185} end
if madewheel then mmp.clearspecials{6831, 10509} end
if mademud then mmp.clearspecials{6831, 9985} end
if madesnowglobe then mmp.clearspecials{6831, 10992} end
if madecookie then mmp.clearspecials{6831, 9888} end
if madehead then mmp.clearspecials{6831, 11811} end
if madeicicle then mmp.clearspecials{6831, 10457} end
if madetibia then mmp.clearspecials{6831, 11600} end
if madebonecurio then mmp.clearspecials{28613} end
if madeflowercurio then mmp.clearspecials{28624} end
if madetorus then mmp.clearspecials{28548} end
if madeutensilcurio then mmp.clearspecials{28617} end
if madefluttercurio then mmp.clearspecials{28622} end
if madetoolcurio then mmp.clearspecials{28586} end
if madefacecurio then mmp.clearspecials{28433} end
if madetoycurio then mmp.clearspecials{21548} end
if madefeathercurio then mmp.clearspecials{28591} end
if madefigurecurio then mmp.clearspecials{28312} end
if madeprism then mmp.clearspecials{6182} end
if madevernalcurio then mmp.clearspecials{22908} end

-- allow mapper 'addons' to unlink their special exits
raiseEvent("mmp clear externals")
end

function mmp.gotoArea (where, number, dashtype, exact)
if not where or type(where) ~= "string" then
mmp.echo("Where do you want to go to?") return end

local where = where:lower()

number = tonumber(number)
local tmp = getRoomUserData(1, "gotoMapping")
if not tmp or tmp == '' then tmp = "[]" end

local temp, maptable = yajl.to_value(tmp), {}
for k,v in pairs(temp) do maptable[k:lower()] = v end

local goto = maptable[where]
if goto then
mmp.gotoRoom(goto, dashtype)
--mmp.gotoRoom(path go, gallop)
return
end

local possibleRooms, shortestPath, shortestBorder = {}, {}, 0

mmp.computeShortestWatch = mmp.computeShortestWatch or createStopWatch()
startStopWatch(mmp.computeShortestWatch)

local areaid, msg, multiples = mmp.findAreaID(where, exact)
if areaid then
possibleRooms = mmp.getAreaBorders(areaid)

elseif not areaid and #multiples > 0 then
if number and number<=#multiples then
mmp.gotoArea(multiples[number], nil, dashtype, true)
return
end
mmp.echo("Which area would you like to go to?")
fg("DimGrey")
for key, areaname in ipairs(multiples) do
echo" "; echoLink(key .. ") ", 'mmp.gotoArea("'..areaname..'", nil, '..(dashtype and '"'..dashtype..'"' or "nil")..', true)', "Click to go to "..areaname, true)
setUnderline(true) echoLink(areaname, 'mmp.gotoArea("'..areaname..'", nil, '..(dashtype and '"'..dashtype..'"' or "nil")..', true)', "Click to go to "..areaname, true) setUnderline(false) echo"\n"
end
resetFormat()
return
else
mmp.echo(string.format("Don't know of any area named '%s'.", where))
return
end

local getStopWatchTime, tonumber, getPath = getStopWatchTime, tonumber, mmp.getPath

--mmp.echo(string.format("Have %s area edge nodes, %ss taken so far...", table.size(possibleRooms), getStopWatchTime(mmp.computeShortestWatch)))

-- allocate only 500ms to finding the shortest path, or more if we failed to find anything
local checkedsofar, outoftime = 0
for id, _ in pairs(possibleRooms) do
if mmp.getPath(mmp.currentroom, tonumber(id)) then
if shortestBorder==0 or #shortestPath > #speedWalkPath then
shortestPath = speedWalkPath
shortestBorder = tonumber(id)
end
end
checkedsofar = checkedsofar + 1

if (getStopWatchTime(mmp.computeShortestWatch) >= .5) then outoftime = true break end
-- mmp.echo(string.format("pathed from %s to %s, running time so far: %s", mmp.currentroom, id, getStopWatchTime(mmp.computeShortestWatch)))
end

--mmp.echo(string.format("total time took: %s", getStopWatchTime(mmp.computeShortestWatch)))
stopStopWatch(mmp.computeShortestWatch)

if shortestBorder == 0 then
if outoftime then
mmp.echo(string.format(
"I checked %d of the %d possible exits \"%s\" has, but none of the ways there worked and it was taking too long :( try doing this again?",
checkedsofar, table.size(possibleRooms), where
))
else
mmp.echo("Checked "..table.size(possibleRooms).." exits in that area, and none of them worked :( I Don't know how to get you there.")
end
mmp.speedWalkPath = {}
mmp.speedWalkDir = {}
speedWalkCounter = 0
raiseEvent("mmapper failed path")
return
end

mmp.gotoRoom(shortestBorder, dashtype)
end

--- DOES NOT ACCOUNT FOR CHANGING THE MAP YET (within a profile load), because we don't know when it happens
local getpathcache = {}
--setmetatable(getpathcache, {__mode = "kv"}) -- weak keys/values = it'll periodically get cleaned up by gc

function mmp.getPath(from, to)
assert(tonumber(from) and tonumber(to), "mmp.getPath: both from and to have to be room IDs")

local key = string.format("%s_%s", from, to)
local resulttbl = getpathcache[key]

-- not in cache?
if not resulttbl then
mmp.computeGetPath = mmp.computeGetPath or createStopWatch()
startStopWatch(mmp.computeGetPath)
local boolean = getPath(from, to)
if mmp.debug then mmp.echo("a new getPath() from "..from.." to "..to.." took "..stopStopWatch(mmp.computeGetPath).."s.") end
-- save it into the cache & send away
getpathcache[key] = {boolean, speedWalkDir, speedWalkPath}
return boolean
end

-- or if it is, retrieve & send away
speedWalkDir = resulttbl[2]
speedWalkPath = resulttbl[3]
return resulttbl[1]
end

function mmp.clearpathcache()
if mmp.debug then mmp.echo("path cache cleared") end
getpathcache = {}
end
function mmp.showpathcache() return getpathcache end

function mmp.setmovetimer(time)
if mmp.movetimer then killTimer(mmp.movetimer) end
if mmp.settings.slowwalk then return end

mmp.movetimer = tempTimer(getNetworkLatency()+(time or 0.5), function ()
mmp.movetimer = false
mmp.move()
end)
end

-- moves to the next room we need to.
function mmp.move()
if mmp.paused or not mmp.autowalking or mmp.movetimer or not mmp.canmove() then return end
-- sometimes it's 0 - default to 1
if speedWalkCounter == 0 then speedWalkCounter = 1 end

local cmd
if mmp.settings["caravan"] then cmd = "lead caravan "..mmp.speedWalkDir[speedWalkCounter]
else
cmd = mmp.speedWalkDir[speedWalkCounter]
end

cmd = cmd or ''

-- timeout before loadstring, so it can set its own if it would like to.
mmp.setmovetimer()

if string.starts(cmd, "script:") then
cmd = string.gsub( cmd, "script:", "" ) loadstring(cmd)()
if mmp.settings.showcmds then cecho(string.format("<red>(<maroon>%d - <dark_slate_grey>%s<red>)", #mmp.speedWalkDir - speedWalkCounter + 1, "<script>")) end
else
send(cmd, false)
if mmp.settings.showcmds then cecho(string.format("<red>(<maroon>%d - <dark_slate_grey>%s<red>)", #mmp.speedWalkDir - speedWalkCounter + 1, cmd)) end
end
end

function mmp.swim()
-- not going anywhere? don't do anything
if not mmp.speedWalkDir[speedWalkCounter] then return end

send("swim " .. mmp.speedWalkDir[speedWalkCounter], false)
if mmp.settings.showcmds then cecho(string.format("<red>(<maroon>%d - <dark_slate_grey>swim %s<red>)", #mmp.speedWalkDir - speedWalkCounter + 1, mmp.speedWalkDir[speedWalkCounter])) end

mmp.setmovetimer(2.5)
end

function mmp.enterGrate()
-- not going anywhere? don't do anything
if not mmp.speedWalkDir[speedWalkCounter] then return end

send("enter grate " .. mmp.speedWalkDir[speedWalkCounter], false)
if mmp.settings.showcmds then cecho(string.format("<red>(<maroon>%d - <dark_slate_grey>enter grate %s<red>)", #mmp.speedWalkDir - speedWalkCounter + 1, mmp.speedWalkDir[speedWalkCounter])) end

mmp.setmovetimer(2.5)
end

function mmp.openDoor()
-- not going anywhere? don't do anything
if not mmp.speedWalkDir[speedWalkCounter] then return end

send("open door " .. mmp.speedWalkDir[speedWalkCounter], false)
if mmp.settings.showcmds then cecho(string.format("<red>(<maroon>%d - <dark_slate_grey>open door %s<red>)", #mmp.speedWalkDir - speedWalkCounter + 1, mmp.speedWalkDir[speedWalkCounter])) end

mmp.setmovetimer(getNetworkLatency())
end

function mmp.unlockDoor()
-- not going anywhere? don't do anything
if not mmp.speedWalkDir[speedWalkCounter] then return end

send("unlock door " .. mmp.speedWalkDir[speedWalkCounter], false)
if mmp.settings.showcmds then cecho(string.format("<red>(<maroon>%d - <dark_slate_grey>unlock door %s<red>)", #mmp.speedWalkDir - speedWalkCounter, mmp.speedWalkDir[speedWalkCounter])) end

mmp.setmovetimer(getNetworkLatency())
end

function mmp.customwalkdelay(delay)
mmp.setmovetimer(getNetworkLatency()+delay)
end

function mmp.stop()
mmp.speedWalkPath = {}
mmp.speedWalkDir = {}
speedWalkCounter = 0
stopStopWatch(speedWalkWatch)
--if mmp.movetimer then killTimer( mmp.movetimer ) end
mmp.autowalking = false

-- clear all the temps we've got
for trigger, ID in pairs(mmp.specials) do
killTrigger(ID)
end
mmp.specials = {}

mmp.echo("Stopped walking.")
raiseEvent("mmapper stopped")
if mmp.settings.shackle then expandAlias("wear shackle") end
end

-- Aetolia and Lusternia support showing balances in GMCP. This is easy to support, so we do!
-- if we can't move, setup a polling timer to prompt walking when we can again.
-- popular systems that expose balance & equilibrium values can be added here as well, perhaps though a similarly-named function.
function mmp.canmove(fromtimer)
if mapper_can_move and mapper_can_move() then
if fromtimer then
mmp.move()
else return true end
elseif mapper_can_move then
tempTimer(0.2, [[mmp.canmove(true)]])
return false
end

if not gmcp.Char then return true end

if (gmcp.Char and
-- Achaea
(not gmcp.Char.Vitals.bal or gmcp.Char.Vitals.bal == "1") and
(not gmcp.Char.Vitals.eq or gmcp.Char.Vitals.eq == "1") and
-- Lusternia
(not gmcp.Char.Vitals.balance or gmcp.Char.Vitals.balance == "1") and
(not gmcp.Char.Vitals.equilibrium or gmcp.Char.Vitals.equilibrium == "1") and
(not gmcp.Char.Vitals.right_arm or gmcp.Char.Vitals.right_arm == "1") and
(not gmcp.Char.Vitals.left_arm or gmcp.Char.Vitals.left_arm == "1") and
(not gmcp.Char.Vitals.right_leg or gmcp.Char.Vitals.right_leg == "1") and
(not gmcp.Char.Vitals.left_leg or gmcp.Char.Vitals.left_leg == "1") and
(not gmcp.Char.Vitals.psisuper or gmcp.Char.Vitals.psisuper ~= "0") and
(not gmcp.Char.Vitals.psisub or gmcp.Char.Vitals.psisub ~= "0") and
(not gmcp.Char.Vitals.psiid or gmcp.Char.Vitals.psiid ~= "0") and
(not gmcp.Char.Balance or gmcp.Char.Balance.List.balance == "1") and
(not gmcp.Char.Balance or gmcp.Char.Balance.List.equilibrium == "1") and
(not gmcp.Char.Balance or gmcp.Char.Balance.List.rarm == "1") and
(not gmcp.Char.Balance or gmcp.Char.Balance.List.larm == "1") and
(not gmcp.Char.Balance or gmcp.Char.Balance.List.legs == "1") and
(not gmcp.Char.Vitals.prone or (gmcp.Char.Vitals.prone == "0" or gmcp.Char.Vitals.prone == 0))
) then
if fromtimer then
mmp.move()
else return true end
else
tempTimer(0.2, [[mmp.canmove(true)]])
return false
end
end

local oldnum
function speedwalking( event, num )
local num = tonumber(num) or tonumber(gmcp.Room.Info.num)
if num ~= mmp.currentroom then mmp.previousroom = mmp.currentroom end
mmp.currentroom = num
mmp.currentroomname = getRoomName(num)

-- track if we're inside or outside, if possible
if gmcp.Room then
if mmp.inside and not table.contains(gmcp.Room.Info.details, "indoors") then
mmp.inside = false
raiseEvent("mmapper went outside")
elseif not mmp.inside and table.contains(gmcp.Room.Info.details, "indoors") then
mmp.inside = true
raiseEvent("mmapper went inside")
end
-- the event could cancel speedwalking - in this case quit
if mmp.ignore_speedwalking then
mmp.ignore_speedwalking = nil
return
end
end
if oldnum == num then return else oldnum = num end

if not mmp.autowalking then return end

if mmp.movetimer then killTimer(mmp.movetimer); mmp.movetimer = false end

if num == mmp.speedWalkPath[#mmp.speedWalkPath] then
local walktime = stopStopWatch(speedWalkWatch)
mmp.echo(string.format("We've arrived! Took us %.1fs.\n", walktime))
raiseEvent("mmapper arrived")
if mmp.settings.shackle then expandAlias("wear shackle") end
mmp.speedWalkPath = {}
mmp.speedWalkDir = {}
speedWalkCounter = 0
mmp.autowalking = false
elseif mmp.speedWalkPath[speedWalkCounter] == num then
speedWalkCounter = speedWalkCounter + 1
mmp.move()
elseif #mmp.speedWalkPath> 0 and not mmp.ferry_rooms[num] and not (gmcp.Room.Info.details and table.contains(gmcp.Room.Info.details, "ferry")) then -- ended up somewhere we didn't want to be, and this isn't a ferry room?
speedWalkMoved = false
-- re-calculate path then
mmp.echo("Ended up off the path, recalculating a new path...")
local destination = mmp.speedWalkPath[#mmp.speedWalkPath]
if not mmp.getPath(num, destination) then
mmp.echo(string.format("Don't know how to get to %d (%s) anymore :( Move into a room we know of to continue",
destination, getRoomName(destination)))
else
mmp.gotoRoom (destination)
end
end
end

function doSpeedWalk(dashtype)
mmp.speedWalkDir = mmp.deepcopy(speedWalkDir)
mmp.speedWalkPath = mmp.deepcopy(speedWalkPath)
speedWalkDir, speedWalkPath = {}, {}

resetStopWatch(speedWalkWatch)
startStopWatch(speedWalkWatch)
if mmp.settings["gallop"] or mmp.settings["dash"] or mmp.settings.sprint or dashtype then
mmp.fixPath(mmp.currentroom, mmp.speedWalkPath[#mmp.speedWalkPath],
(mmp.settings["gallop"] and "gallop") or (mmp.settings["dash"] and "dash") or (mmp.settings.sprint and "sprint") or (mmp.settings.runaway and "runaway") or dashtype)
end

mmp.fixSpecialExits(mmp.speedWalkDir)

if #mmp.speedWalkPath == 0 then
mmp.autowalking = false
mmp.echo("Couldn't find a path to the destination :(")
raiseEvent("mmapper failed path")
if mmp.settings.shackle then expandAlias("wear shackle") end
return
end

mmp.autowalking = true

-- this is a fix: convert nums to actual numbers
for i = 1, #mmp.speedWalkPath do
mmp.speedWalkPath = tonumber(mmp.speedWalkPath)
end

if mmp.settings.shackle then expandAlias("remove shackle") end
if not mmp.paused then
mmp.echon("Starting speedwalk from "..(atcp.RoomNum or gmcp.Room.Info.num).." to ") echoLink(mmp.speedWalkPath[#mmp.speedWalkPath], 'mmp.gotoRoom "' .. mmp.speedWalkPath[#mmp.speedWalkPath].. '"', 'Go to ' .. mmp.speedWalkPath[#mmp.speedWalkPath]) echo(": ")
speedWalkCounter = 1
if mmp.canmove() then mmp.move() else echo("(when we get balance back / aren't hindered)") end
else
mmp.echo("Will go to "..mmp.speedWalkPath[#mmp.speedWalkPath].." as soon as the mapper is unpaused.")
end
end

function mmp.failpath()
if mmp.movetimer then
local walktime = stopStopWatch(speedWalkWatch)
mmp.echo(string.format("Can't continue further! Took us %.1fs to get here.\n", walktime))
end

mmp.autowalking = false

if mmp.settings.shackle then expandAlias("wear shackle") end
mmp.speedWalkPath = {}
mmp.speedWalkDir = {}
speedWalkCounter = 0
if mmp.movetimer then killTimer( mmp.movetimer ); mmp.movetimer = nil end
raiseEvent("mmapper failed path")
end

function mmp.changeBoolFunc(name, option)
local en
if option then en = "will now use" else en = "will no longer use" end
mmp.echo("<green>Okay, the mapper " .. en .. " <white>" .. name .. "<green>!")
end

function mmp.fixPath(rFrom,rTo,dashtype)
local currentPath, currentIds = {}, {}
local dRef = {["n"] = "north", ["e"] = "east", ["s"] = "south", ["w"] = "west"}
if not getPath(rFrom,rTo) then return false end

-- Logic: Look for a direction repeated at least two times.

-- count the number of times it repeats, then look that many rooms ahead.
-- if that room also contains the direction we're headed, just travel that many directions.
-- otherwise, dash.

local repCount = 1
local index = 1
local dashExaust = false
while mmp.speedWalkDir[index] do
dashExaust = false
repCount = 1
while mmp.speedWalkDir[index+repCount] == mmp.speedWalkDir[index] do
repCount = repCount + 1
if repCount == 11 then
dashExaust = true
break
end
end
if repCount > 1 then
-- Found direction repitition. Calculate dash path.
local exits = getRoomExits(mmp.speedWalkPath[index+(repCount-1)])
local pname = ""
for word in mmp.speedWalkDir[index]:gmatch("%w") do pname = pname .. (dRef[word] or word) end
if not exits[pname] or dashExaust then
-- Final room in this direction does not continue, dash!
table.insert(currentPath,string.format("%s %s",dashtype,mmp.speedWalkDir[index]))
currentIds[#currentIds+1] = mmp.speedWalkPath[index+repCount-1]
else
-- Final room in this direction continues onwards, don't dash
for i = 1,repCount do
table.insert(currentPath,mmp.speedWalkDir[index])
currentIds[#currentIds+1] = mmp.speedWalkPath[index+i-1]
end
end
index = index + repCount
else
-- No repetition, just add the direction.
table.insert(currentPath,mmp.speedWalkDir[index])
currentIds[#currentIds+1] = mmp.speedWalkPath[index]
index = index + 1
end
end

mmp.speedWalkDir = currentPath
mmp.speedWalkPath = currentIds
return true
end

-- a certain version of the mapper gave us special exits prepended with 0 or 1 in the command
-- depending on if it was locked. Need to remove these before we can use them
function mmp.fixSpecialExits(directions)
for i = 1, #directions do
if directions:match("^%d") then directions = directions:sub(2) end
end
end

-- cleanup function to remove the temp special exit we made - only way to remove specials in Mudlet atm is by clearing them all
function mmp.clearspecials(ignorerooms)
local t = getSpecialExits(mmp.currentroom)
clearSpecialExits(mmp.currentroom)

for connectingroom, exits in pairs(t) do
if not table.contains(ignorerooms,connectingroom) then -- don't re-add this one back as it's our temp
for command, locked in pairs(exits) do
--debug echo: mmp.echo("need to re-link this room to "..connectingroom.." with "..command.." that is "..(locked == "1" and "locked" or "unlocked")..".")
addSpecialExit(mmp.currentroom, connectingroom, command)
if locked == "1" then lockSpecialExit(mmp.currentroom, connectingroom, command, true) end
end
end
end
end

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Aetolia Mapper

Post by Vadi »

So I think you mean can that be coded in for you, I can't help you with that - pretty busy with other things at the moment.

Post Reply