1) Fixed a bug that didn't properly handle identifying weapons that were tempered or envenomed

when the temper/envenom added a stat that was not previously on the weapon.
2) Fixed extraneous "fence" messages that were not suppressed when the mud was running using
   the echocommand mode
master
Durel 7 years ago
parent 21eb9a0935
commit 70be6ef45b

@ -1,6 +1,39 @@
dbot.changelog = {} dbot.changelog = {}
dbot.changelog[2.0045] =
{
{ change = drlDbotChangeLogTypeFix,
desc = [[Fixed a bug that didn't properly handle identifying weapons that were tempered or envenomed
when the temper/envenom added a stat that was not previously on the weapon]]
},
{ change = drlDbotChangeLogTypeFix,
desc = [[Fixed extraneous "fence" messages that were not suppressed when the mud was running using
the echocommand mode]]
}
}
dbot.changelog[2.0044] =
{
{ change = drlDbotChangeLogTypeFix,
desc = [[Fixed bug where weapon identification did not account for temporary stats on a tempered
or envenomed weapon]]
},
{ change = drlDbotChangeLogTypeFix,
desc = [[Added a workaround for quivers. Aard reports a quiver wearable location as "ready" but
you can't wear anything at the "ready" location. Instead, you must wear it as the "readied"
location. Dinv now translates "ready" to "readied" as necessary.]]
},
{ change = drlDbotChangeLogTypeNew,
desc = [[Added "@Gdinv consume display owned@W" mode to list only items in your consumable table
that you actually have in your inventory. This gives you a quick summary of what you are
actually carrying and suppresses items if you don't have any of that item type.]]
},
{ change = drlDbotChangeLogTypeMisc,
desc = [[Removed experimental "dinv auto" mode]]
}
}
dbot.changelog[2.0043] = dbot.changelog[2.0043] =
{ {
{ change = drlDbotChangeLogTypeFix, { change = drlDbotChangeLogTypeFix,

@ -89,7 +89,7 @@ dbot.version : Module to track version and changelog information and update the
save_state="y" save_state="y"
date_written="2017-08-12 08:45:15" date_written="2017-08-12 08:45:15"
requires="4.98" requires="4.98"
version="2.0043" version="2.0045"
> >
<description trim="y"> <description trim="y">
<![CDATA[ <![CDATA[
@ -641,8 +641,8 @@ Feature Wishlist
</alias> </alias>
<alias <alias
script="inv.cli.debug.fn" script="inv.cli.commlog.fn"
match="^[ ]*dinv[ ]+debug(.*)$" match="^[ ]*dinv[ ]+commlog( .*)?$"
enabled="y" enabled="y"
regexp="y" regexp="y"
send_to="12" send_to="12"
@ -651,18 +651,8 @@ Feature Wishlist
</alias> </alias>
<alias <alias
script="inv.cli.autoQueue.fn1" script="inv.cli.debug.fn"
match="^[ ]*dinv[ ]+auto[ ]+(halt)[ ]*$" match="^[ ]*dinv[ ]+debug( .*)?$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
</alias>
<alias
script="inv.cli.autoQueue.fn2"
match="^[ ]*dinv[ ]+auto[ ]+([0-9]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+([^ ]+)[ ]+(.*?)$"
enabled="y" enabled="y"
regexp="y" regexp="y"
send_to="12" send_to="12"
@ -1699,9 +1689,6 @@ end -- inv.config.new
-- inv.cli.help.usage() -- inv.cli.help.usage()
-- inv.cli.help.examples() -- inv.cli.help.examples()
-- --
-- inv.cli.autoQueue.fn1(name, line, wildcards)
-- inv.cli.autoQueue.fn2(name, line, wildcards)
--
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
inv.cli = {} inv.cli = {}
@ -4690,6 +4677,10 @@ use this: "@Gdinv consume small heal 3@W".
The plugin will always choose to consume items that are in your main inventory The plugin will always choose to consume items that are in your main inventory
before using an equivalent item from a container unless you specify a container. before using an equivalent item from a container unless you specify a container.
I find it very convenient to list which consumable items I actually have in my inventory.
As a result, you can use "@Gdinv consume display owned@W" as a shorthand to suppress the
display output for items you do not currently have in your inventory or containers.
Examples: Examples:
1) Add a consumable item ("nachos") that gives something of type "mana". Nachos 1) Add a consumable item ("nachos") that gives something of type "mana". Nachos
can be found at "runto bard; run wn" and you should be at the shopkeeper to can be found at "runto bard; run wn" and you should be at the shopkeeper to
@ -4708,22 +4699,25 @@ Examples:
5) Display info about each consumable item that is of type "mana" 5) Display info about each consumable item that is of type "mana"
"@Gdinv consume display mana@W" "@Gdinv consume display mana@W"
6) Buy 5 "mana" items that are the highest level available in the table 6) Display info about each consumable item that is currently in your inventory
"@Gdinv consume display owned@W"
7) Buy 5 "mana" items that are the highest level available in the table
"@Gdinv consume buy mana 5@W" "@Gdinv consume buy mana 5@W"
7) Buy 10 "heal" items and put them into 3.bag 8) Buy 10 "heal" items and put them into 3.bag
"@Gdinv consume buy heal 10 3.bag@W" "@Gdinv consume buy heal 10 3.bag@W"
8) Consume (quaff, eat, etc.) the lowest level "mana" item in your inventory 9) Consume (quaff, eat, etc.) the lowest level "mana" item in your inventory
This is useful when you want to clean out low-level potions. You probably won't This is useful when you want to clean out low-level potions. You probably won't
use this option in combat but it is convenient out of combat. use this option in combat but it is convenient out of combat.
"@Gdinv consume small mana@W" "@Gdinv consume small mana@W"
9) Consume (quaff, eat, etc.) 2 of the highest-level items in your inventory that 10) Consume (quaff, eat, etc.) 2 of the highest-level items in your inventory that
are of type "mana". This is handy in combat. are of type "mana". This is handy in combat.
"@Gdinv consume big mana 2@W" "@Gdinv consume big mana 2@W"
10) Consume 3 of your highest-level mana items and look in container 2.bag before 11) Consume 3 of your highest-level mana items and look in container 2.bag before
checking for the items in other locations checking for the items in other locations
"@Gdinv consume big mana 3 2.bag@W" "@Gdinv consume big mana 3 2.bag@W"
]]) ]])
@ -5003,45 +4997,28 @@ Examples:
end -- inv.cli.help.examples end -- inv.cli.help.examples
inv.cli.autoQueue = {}
function inv.cli.autoQueue.fn1(name, line, wildcards)
dbot.autoQueueState = dbot.autoQueueHalted
dbot.note("Auto Queue: halting...")
end -- inv.cli.autoQueue.fn1
function inv.cli.autoQueue.fn2(name, line, wildcards)
local maxCmds = wildcards[1] or ""
local cmdTimeout = wildcards[2] or ""
local totTimeout = wildcards[3] or ""
local state = wildcards[4] or ""
local command = wildcards[5] or ""
local paramStr = (command or "none") .. ", maxCommands=" .. (maxCmds or "nil") inv.cli.commlog = {}
local endTag = inv.tags.new(paramStr, nil, nil, nil) function inv.cli.commlog.fn(name, line, wildcards)
local msg = Trim(wildcards[1] or "")
if (state == "active") then local outerColor = "@x105"
state = "3" local innerColor = "@x39"
elseif (state == "combat") then
state = "8"
end -- if
dbot.debug("Auto Queue: cmd=\"" .. command .. "\", maxCmds=" .. maxCmds .. ", cmdTO=" .. cmdTimeout .. dbot.debug("Commlog message = \"" .. msg .. "\"")
", totTO=" .. totTimeout .. ", state=" .. state)
local retval = dbot.autoQueue(command, maxCmds, cmdTimeout, totTimeout, state, endTag) dbot.commLog(outerColor .. "[" .. innerColor .. "DINV" .. outerColor .. "]@w " .. msg .. "@w")
return retval end -- inv.cli.commlog.fn
end -- inv.cli.autoQueue.fn2
inv.cli.debug = {} inv.cli.debug = {}
function inv.cli.debug.fn(name, line, wildcards) function inv.cli.debug.fn(name, line, wildcards)
local command = wildcards[1] or "" local params = Trim(wildcards[1] or "")
command = Trim(command)
dbot.note("Debug params = \"" .. params .. "\"")
dbot.note("Debug params = \"" .. command .. "\"") dbot.commLog("[DINV] " .. params)
dbot.shell(command)
end -- inv.cli.debug.fn end -- inv.cli.debug.fn
@ -7712,6 +7689,12 @@ function inv.items.wearItem(objId, targetLoc, commandArray, doCheckLocation)
end -- if end -- if
end -- if end -- if
-- Aard is a bit quirky for quivers. The location reported via identify is "ready" but aard will
-- only wear a quiver at the "readied" slot. Ugh.
if (targetLoc == inv.wearLoc[invWearableLocReady]) then
targetLoc = invWearableLocReadyWorkaround
end -- if
local wearCommand = "wear " .. objId .. " " .. targetLoc local wearCommand = "wear " .. objId .. " " .. targetLoc
if (commandArray ~= nil) then if (commandArray ~= nil) then
@ -9523,7 +9506,7 @@ function inv.items.trigger.itemIdStart(line)
-- Watch for the end of the item description so that we can stop scanning -- Watch for the end of the item description so that we can stop scanning
AddTriggerEx(inv.items.trigger.itemIdEndName, AddTriggerEx(inv.items.trigger.itemIdEndName,
inv.items.identifyFence, "^" .. inv.items.identifyFence .. "$",
"inv.items.trigger.itemIdEnd()", "inv.items.trigger.itemIdEnd()",
drlTriggerFlagsBaseline + trigger_flag.OmitFromOutput + trigger_flag.OneShot, drlTriggerFlagsBaseline + trigger_flag.OmitFromOutput + trigger_flag.OneShot,
custom_colour.Custom11, custom_colour.Custom11,
@ -9631,6 +9614,17 @@ function inv.items.trigger.itemIdStats(line)
_, _, weaponType = string.find(line, "Weapon Type:%s+(%a+)%s+") _, _, weaponType = string.find(line, "Weapon Type:%s+(%a+)%s+")
_, _, specials = string.find(line, "Specials%s+:%s+(%a+)%s+") _, _, specials = string.find(line, "Specials%s+:%s+(%a+)%s+")
local tmpAvedam, tmpHR, tmpDR, tmpInt, tmpWis, tmpLuck, tmpStr, tmpDex, tmpCon
_, _, tmpAvedam = string.find(line, ":%s+adds [+-](%d+) average damage%s+")
_, _, tmpHR = string.find(line, ":%s+hit roll [+-](%d+)")
_, _, tmpDR = string.find(line, ":%s+damage roll [+-](%d+)")
_, _, tmpInt = string.find(line, ":%s+intelligence [+-](%d+)")
_, _, tmpWis = string.find(line, ":%s+wisdom [+-](%d+)")
_, _, tmpLuck = string.find(line, ":%s+luck [+-](%d+)")
_, _, tmpStr = string.find(line, ":%s+strength [+-](%d+)")
_, _, tmpDex = string.find(line, ":%s+dexterity [+-](%d+)")
_, _, tmpCon = string.find(line, ":%s+constitution [+-](%d+)")
if (id ~= nil) then if (id ~= nil) then
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldId, dbot.tonumber(id or "")) inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldId, dbot.tonumber(id or ""))
dbot.debug("Id = \"" .. id .. "\"") dbot.debug("Id = \"" .. id .. "\"")
@ -10015,6 +10009,69 @@ function inv.items.trigger.itemIdStats(line)
dbot.debug("avedam = \"" .. avedam .. "\"") dbot.debug("avedam = \"" .. avedam .. "\"")
end -- if end -- if
if (tmpAvedam ~= nil) then
local currentAvedam = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldAveDam) or 0
local newAvedam = dbot.tonumber(tmpAvedam) + currentAvedam
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldAveDam, newAvedam)
dbot.debug("tmpAvedam = \"" .. tmpAvedam .. "\"")
end -- if
if (tmpHR ~= nil) then
local currentHR = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldHit) or 0
local newHR = dbot.tonumber(tmpHR) + currentHR
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldHit, newHR)
dbot.debug("tmpHR = \"" .. tmpHR .. "\"")
end -- if
if (tmpDR ~= nil) then
local currentDR = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldDam) or 0
local newDR = dbot.tonumber(tmpDR) + currentDR
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldDam, newDR)
dbot.debug("tmpDR = \"" .. tmpDR .. "\"")
end -- if
if (tmpInt ~= nil) then
local currentInt = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldInt) or 0
local newInt = dbot.tonumber(tmpInt) + currentInt
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldInt, newInt)
dbot.debug("tmpInt = \"" .. tmpInt .. "\"")
end -- if
if (tmpWis ~= nil) then
local currentWis = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldWis) or 0
local newWis = dbot.tonumber(tmpWis) + currentWis
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldWis, newWis)
dbot.debug("tmpWis = \"" .. tmpWis .. "\"")
end -- if
if (tmpLuck ~= nil) then
local currentLuck = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldLuck) or 0
local newLuck = dbot.tonumber(tmpLuck) + currentLuck
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldLuck, newLuck)
dbot.debug("tmpLuck = \"" .. tmpLuck .. "\"")
end -- if
if (tmpStr ~= nil) then
local currentStr = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldStr) or 0
local newStr = dbot.tonumber(tmpStr) + currentStr
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldStr, newStr)
dbot.debug("tmpStr = \"" .. tmpStr .. "\"")
end -- if
if (tmpDex ~= nil) then
local currentDex = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldDex) or 0
local newDex = dbot.tonumber(tmpDex) + currentDex
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldDex, newDex)
dbot.debug("tmpDex = \"" .. tmpDex .. "\"")
end -- if
if (tmpCon ~= nil) then
local currentCon = inv.items.getStatField(inv.items.identifyPkg.objId, invStatFieldCon) or 0
local newCon = dbot.tonumber(tmpCon) + currentCon
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldCon, newCon)
dbot.debug("tmpCon = \"" .. tmpCon .. "\"")
end -- if
if (inflicts ~= nil) then if (inflicts ~= nil) then
inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldInflicts, inflicts) inv.items.setStatField(inv.items.identifyPkg.objId, invStatFieldInflicts, inflicts)
dbot.debug("inflicts = \"" .. inflicts .. "\"") dbot.debug("inflicts = \"" .. inflicts .. "\"")
@ -10654,6 +10711,11 @@ inv.wearLoc[invWearableLocPortal] = "portal"
inv.wearLoc[invWearableLocSleeping] = "sleeping" inv.wearLoc[invWearableLocSleeping] = "sleeping"
inv.wearLoc[invWearableLocReady] = "ready" inv.wearLoc[invWearableLocReady] = "ready"
-- Aard is a bit inconsistent with the "ready" location. Items such as quivers report their wearable
-- location as "ready" in identify but you can't wear an item at the "ready" location. Instead, you
-- must wear it at the "readied" location. Ugh. This is a work-around for that issue.
invWearableLocReadyWorkaround = "readied"
inv.wearables = { light = { "light" }, inv.wearables = { light = { "light" },
head = { "head" }, head = { "head" },
@ -16961,7 +17023,6 @@ invTagsForget = "forget"
invTagsNotify = "notify" invTagsNotify = "notify"
invTagsCache = "cache" invTagsCache = "cache"
invTagsVersion = "version" invTagsVersion = "version"
invTagsAutoQueue = "autoQueue"
invTagsHelp = "help" invTagsHelp = "help"
inv.tags.modules = invTagsBuild .. " " .. inv.tags.modules = invTagsBuild .. " " ..
@ -16985,7 +17046,6 @@ inv.tags.modules = invTagsBuild .. " " ..
invTagsNotify .. " " .. invTagsNotify .. " " ..
invTagsCache .. " " .. invTagsCache .. " " ..
invTagsVersion .. " " .. invTagsVersion .. " " ..
invTagsAutoQueue .. " " ..
invTagsHelp invTagsHelp
@ -17311,7 +17371,7 @@ end -- inv.tags.cleanup.info
-- inv.consume.addCR() -- async so that we can appraise the new item -- inv.consume.addCR() -- async so that we can appraise the new item
-- inv.consume.remove(typeName, itemName) -- inv.consume.remove(typeName, itemName)
-- inv.consume.display(typeName) -- if typeName is missing, display all types -- inv.consume.display(typeName) -- if typeName is missing, display all types
-- inv.consume.displayType(typeName) -- inv.consume.displayType(typeName, isOwned)
-- --
-- inv.consume.buy(typeName, numItems, containerName) -- inv.consume.buy(typeName, numItems, containerName)
-- inv.consume.buyCR() -- async so that we can run to the shopkeeper -- inv.consume.buyCR() -- async so that we can run to the shopkeeper
@ -17575,9 +17635,14 @@ end -- inv.consume.remove
-- If typeName is nil or "", display all types in the table -- If typeName is nil or "", display all types in the table
function inv.consume.display(typeName) function inv.consume.display(typeName)
local retval = DRL_RET_SUCCESS local retval = DRL_RET_SUCCESS
local numEntries = 0 local numEntries = 0
if (typeName ~= nil) and (typeName ~= "") then
local isOwned = false
if (typeName == "owned") then
isOwned = true
end -- if
if (typeName ~= nil) and (typeName ~= "") and (not isOwned) then
numEntries = inv.consume.displayType(typeName) numEntries = inv.consume.displayType(typeName)
else else
local sortedTypes = {} local sortedTypes = {}
@ -17587,7 +17652,7 @@ function inv.consume.display(typeName)
table.sort(sortedTypes, function (v1, v2) return v1 < v2 end) table.sort(sortedTypes, function (v1, v2) return v1 < v2 end)
for _, itemType in ipairs(sortedTypes) do for _, itemType in ipairs(sortedTypes) do
numEntries = numEntries + inv.consume.displayType(itemType) numEntries = numEntries + inv.consume.displayType(itemType, isOwned)
end -- for end -- for
end -- if end -- if
@ -17600,7 +17665,7 @@ function inv.consume.display(typeName)
end -- inv.consume.display end -- inv.consume.display
function inv.consume.displayType(typeName) function inv.consume.displayType(typeName, isOwned)
local numEntries = 0 local numEntries = 0
if (inv.consume.table == nil) or (typeName == nil) or (typeName == "") or if (inv.consume.table == nil) or (typeName == nil) or (typeName == "") or
@ -17610,7 +17675,9 @@ function inv.consume.displayType(typeName)
return numEntries, DRL_RET_MISSING_ENTRY return numEntries, DRL_RET_MISSING_ENTRY
end -- if end -- if
dbot.print(string.format("\n@W@C%-10s@W Level Room # Avail Name", (typeName or "nil"))) local header = string.format("\n@W@C%-10s@W Level Room # Avail Name", (typeName or "nil"))
local didPrintHeader = false
if (inv.consume.table[typeName] ~= nil) then if (inv.consume.table[typeName] ~= nil) then
for _, entry in ipairs(inv.consume.table[typeName]) do for _, entry in ipairs(inv.consume.table[typeName]) do
local count = 0 local count = 0
@ -17630,8 +17697,14 @@ function inv.consume.displayType(typeName)
countColor = "@M" countColor = "@M"
end -- if end -- if
dbot.print(string.format(" %3d %5d %s%4d@w %s", if (isOwned == nil) or (isOwned == false) or (isOwned and (count > 0)) then
(entry.level or 0), (entry.room or 0), countColor, count, (entry.name or "nil"))) if (not didPrintHeader) then
dbot.print(header)
didPrintHeader = true
end -- if
dbot.print(string.format(" %3d %5d %s%4d@w %s",
(entry.level or 0), (entry.room or 0), countColor, count, (entry.name or "nil")))
end -- if
numEntries = numEntries + 1 numEntries = numEntries + 1
end -- for end -- for
end -- if end -- if
@ -18805,13 +18878,17 @@ end -- dbot.mergeFields
function dbot.arrayConcat(array1, array2) function dbot.arrayConcat(array1, array2)
local mergedArray = {} local mergedArray = {}
for _, entry in ipairs(array1) do if (array1 ~= nil) then
table.insert(mergedArray, entry) for _, entry in ipairs(array1) do
end -- for table.insert(mergedArray, entry)
end -- for
end -- if
for _, entry in ipairs(array2) do if (array2 ~= nil) then
table.insert(mergedArray, entry) for _, entry in ipairs(array2) do
end -- for table.insert(mergedArray, entry)
end -- for
end -- if
return mergedArray return mergedArray
end -- dbot.arrayConcat end -- dbot.arrayConcat
@ -18923,6 +19000,50 @@ function dbot.deleteTimer(name)
end -- dbot.deleteTimer end -- dbot.deleteTimer
----------------------------------------------------------------------------------------------------
-- dbot.commLog sends the given string parameter to the communication log window
----------------------------------------------------------------------------------------------------
function dbot.commLog(msg)
local clPlugin = "b555825a4a5700c35fa80780"
local clFunction = "storeFromOutside"
if (msg == nil) or (msg == "") then
dbot.warn("dbot.commLog: Missing message parameter")
return DRL_RET_INVALID_PARAMS
end -- if
local retval = DRL_RET_INTERNAL_ERROR
local mushRetval = CallPlugin(clPlugin, clFunction, msg)
if (mushRetval == error_code.eNoSuchPlugin) then
dbot.warn("dbot.commLog: target plugin does not exist")
elseif (mushRetval == error_code.ePluginDisabled) then
dbot.warn("dbot.commLog: target plugin is disabled")
elseif (mushRetval == error_code.eNoSuchRoutine) then
dbot.warn("dbot.commLog: target routine does not exist")
elseif (mushRetval == error_code.eErrorCallingPluginRoutine) then
dbot.warn("dbot.commLog: error calling plugin routine")
elseif (mushRetval == error_code.eBadParameter) then
dbot.warn("dbot.commLog: bad parameter detected")
retval = DRL_RET_INVALID_PARAM
elseif (mushRetval == error_code.eOK) then
retval = DRL_RET_SUCCESS
else
dbot.warn("dbot.commLog: Unknown return value from CallPlugin: " .. (mushRetval or "nil"))
end -- if
return retval
end -- dbot.commLog
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
-- dbot.normalizeMobName strips out prefix articles from a mob's name -- dbot.normalizeMobName strips out prefix articles from a mob's name
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
@ -19348,6 +19469,10 @@ end -- dbot.error
-- dbot.gmcp.getRoomId -- dbot.gmcp.getRoomId
-- dbot.gmcp.getTier -- dbot.gmcp.getTier
-- --
-- dbot.gmcp.getHp()
-- dbot.gmcp.getMana()
-- dbot.gmcp.getMoves()
--
-- dbot.gmcp.isGood -- dbot.gmcp.isGood
-- dbot.gmcp.isNeutral -- dbot.gmcp.isNeutral
-- dbot.gmcp.isEvil -- dbot.gmcp.isEvil
@ -19563,6 +19688,84 @@ function dbot.gmcp.getTier()
end -- dbot.gmcp.getTier end -- dbot.gmcp.getTier
function dbot.gmcp.getHp()
local charVitals, charMaxStats
local currentHp = 0
local maxHp = 0
if dbot.gmcp.isInitialized then
charVitals = gmcp("char.vitals")
if (charVitals ~= nil) and (charVitals.hp ~= nil) then
currentHp = tonumber(charVitals.hp)
end -- if
charMaxStats = gmcp("char.maxstats")
if (charMaxStats ~= nil) and (charMaxStats.maxhp ~= nil) then
maxHp = tonumber(charMaxStats.maxhp)
end -- if
else
dbot.note("dbot.gmcp.getTier: GMCP is not initialized")
end -- if
return currentHp, maxHp
end -- dbot.gmcp.getHp
function dbot.gmcp.getMana()
local charVitals, charMaxStats
local currentMana = 0
local maxMana = 0
if dbot.gmcp.isInitialized then
charVitals = gmcp("char.vitals")
if (charVitals ~= nil) and (charVitals.mana ~= nil) then
currentMana = tonumber(charVitals.mana)
end -- if
charMaxStats = gmcp("char.maxstats")
if (charMaxStats ~= nil) and (charMaxStats.maxmana ~= nil) then
maxMana = tonumber(charMaxStats.maxmana)
end -- if
else
dbot.note("dbot.gmcp.getTier: GMCP is not initialized")
end -- if
return currentMana, maxMana
end -- dbot.gmcp.getMana
function dbot.gmcp.getMoves()
local charVitals, charMaxStats
local currentMoves = 0
local maxMoves = 0
if dbot.gmcp.isInitialized then
charVitals = gmcp("char.vitals")
if (charVitals ~= nil) and (charVitals.moves ~= nil) then
currentMoves = tonumber(charVitals.moves)
end -- if
charMaxStats = gmcp("char.maxstats")
if (charMaxStats ~= nil) and (charMaxStats.maxmoves ~= nil) then
maxMoves = tonumber(charMaxStats.maxmoves)
end -- if
else
dbot.note("dbot.gmcp.getTier: GMCP is not initialized")
end -- if
return currentMoves, maxMoves
end -- dbot.gmcp.getMoves
function dbot.gmcp.isGood() function dbot.gmcp.isGood()
local align = dbot.gmcp.getAlign() local align = dbot.gmcp.getAlign()
@ -21722,7 +21925,7 @@ function dbot.execute.queue.fence()
-- Add a one-shot trigger to catch the fence message that we will echo to the mud -- Add a one-shot trigger to catch the fence message that we will echo to the mud
check (AddTriggerEx(dbot.execute.trigger.fenceName, check (AddTriggerEx(dbot.execute.trigger.fenceName,
"^.*" .. uniqueString .. ".*$", "^" .. uniqueString .. "$",
"dbot.execute.fenceIsDetected = true", "dbot.execute.fenceIsDetected = true",
drlTriggerFlagsBaseline + trigger_flag.OneShot + trigger_flag.OmitFromOutput, drlTriggerFlagsBaseline + trigger_flag.OneShot + trigger_flag.OmitFromOutput,
custom_colour.Custom11, 0, "", "", sendto.script, 0)) custom_colour.Custom11, 0, "", "", sendto.script, 0))
@ -22371,151 +22574,6 @@ function dbot.version.update.releaseCR()
end -- dbot.version.update.releaseCR end -- dbot.version.update.releaseCR
----------------------------------------------------------------------------------------------------
-- dbot.autoQueue: Module to repeatedly execute a command under a specific set of circumstances
--
-- dbot.autoQueue(command, maxCommands, commandTimeout, totalTimeout, state, endTag)
-- dbot.autoQueueCR()
--
-- Note: The "state" parameter refers to a gmcp state, such as dbot.stateActive or dbot.stateCombat
--
-- Note2: If the character's room changes before the queue completes, the queue is aborted
--
----------------------------------------------------------------------------------------------------
dbot.autoQueueEnabled = "enabled"
dbot.autoQueueDisabled = "disabled"
dbot.autoQueueHalted = "halted"
dbot.autoQueueState = dbot.autoQueueEnabled
dbot.autoQueuePkg = nil
function dbot.autoQueue(command, maxCommands, commandTimeout, totalTimeout, state, endTag)
local numMaxCommands = tonumber(maxCommands or "")
local numCommandTimeout = tonumber(commandTimeout or "")
local numTotalTimeout = tonumber(totalTimeout or "")
local startRoom = dbot.gmcp.getRoomId()
if (command == nil) or (numMaxCommands == nil) or (numCommandTimeout == nil) or (numTotalTimeout == nil) then
dbot.warn("dbot.autoQueue: Invalid parameters")
return inv.tags.stop(invTagsAutoQueue, endTag, DRL_RET_INVALID_PARAM)
end -- if
if (dbot.autoQueuePkg ~= nil) then
dbot.info("Skipping auto queue request: another request is in progress")
return inv.tags.stop(invTagsAutoQueue, endTag, DRL_RET_BUSY)
end -- if
dbot.autoQueuePkg = {}
dbot.autoQueuePkg.command = command
dbot.autoQueuePkg.maxCommands = numMaxCommands
dbot.autoQueuePkg.commandTimeout = numCommandTimeout
dbot.autoQueuePkg.totalTimeout = numTotalTimeout
dbot.autoQueuePkg.startRoom = startRoom
dbot.autoQueuePkg.state = state
dbot.autoQueuePkg.endTag = endTag
dbot.autoQueueState = dbot.autoQueueEnabled
wait.make(dbot.autoQueueCR)
return DRL_RET_SUCCESS
end -- drlAutoQueue
dbot.autoQueueFence = "Fence: auto queue"
dbot.autoQueueFenceIdx = 1
function dbot.autoQueueCR()
if (dbot.autoQueuePkg == nil) then
dbot.warn("dbot.autoQueueCR: package is nil!?!")
return DRL_INTERNAL_ERROR
end -- if
local retval = DRL_RET_SUCCESS
local endTag = dbot.autoQueuePkg.endTag
local startRoom = dbot.autoQueuePkg.startRoom
local stateName = dbot.stateNames[dbot.autoQueuePkg.state] or "unknown"
local startTime = dbot.getTime()
local numCmds = 1
dbot.debug("Running up to " .. dbot.autoQueuePkg.maxCommands .. " instances of \"" ..
dbot.autoQueuePkg.command .. "\", timeouts=" .. dbot.autoQueuePkg.commandTimeout ..
"/" .. dbot.autoQueuePkg.totalTimeout)
while (dbot.autoQueueState == dbot.autoQueueEnabled) do
local fence = dbot.autoQueueFence .. " " .. dbot.autoQueueFenceIdx
local iterInfo = "@C" .. dbot.autoQueuePkg.command .. " @W" .. numCmds .. "@w/@W" ..
dbot.autoQueuePkg.maxCommands
local haltInfo = "@C" .. dbot.autoQueuePkg.command .. "@W"
local currentState = dbot.gmcp.getState() or "Unknown"
dbot.autoQueueFenceIdx = dbot.autoQueueFenceIdx + 1
-- I don't like one-off work-arounds, but here is one anyway...It is a common situation to want to
-- use a series of combat commands. However, the auto queue won't run combat commands if we are in
-- the active state. As a result, the user would need to engage a mob (or mobs) manually and then
-- kick off the auto queue to continue combat. The work-around below allows the queue to execute one
-- iteration if the user currently is in the active state and the queue runs in the combat state.
-- That allows the user to initiate combat with a command in the auto queue. IMPORTANT: starting the
-- auto queue should *always* be done manually and never with a trigger -- that could potentially be
-- botting.
local useCombatKickstart = false
if (currentState == dbot.stateActive) and
(dbot.autoQueuePkg.state == dbot.stateCombat) and
(numCmds == 1) then
useCombatKickstart = true
end -- if
-- Execute the next command in the queue if we are still in our starting room and haven't changed state.
-- Otherwise, halt the queue because we don't want to "bot" by changing rooms in the middle of the
-- series of commands.
if (startRoom ~= dbot.gmcp.getRoomId()) then
dbot.info("@YAuto queue @WHALTED " .. haltInfo .. "@Y You changed rooms")
dbot.autoQueueState = dbot.autoQueueDisabled
retval = DRL_RET_HALTED
elseif (currentState ~= dbot.autoQueuePkg.state) and (not useCombatKickstart) then
dbot.info("@YAuto queue @WHALTED " .. haltInfo .. "@Y You are not in the @G" .. stateName ..
"@Y state")
dbot.autoQueueState = dbot.autoQueueDisabled
retval = DRL_RET_HALTED
else
dbot.debug("@YAuto queue @Wstarted " .. iterInfo)
check (Execute(dbot.autoQueuePkg.command))
check (Execute("echo " .. fence))
local line, wildcards = wait.regexp("^" .. fence .. "$",
dbot.autoQueuePkg.commandTimeout,
trigger_flag.OmitFromOutput)
if (line == nil) or (line == "") or (dbot.getTime() - startTime > dbot.autoQueuePkg.totalTimeout) then
dbot.info("@YAuto queue @WHALTED " .. haltInfo .. "@Y Request timed out")
dbot.autoQueueState = dbot.autoQueueDisabled
retval = DRL_RET_TIMEOUT
else
dbot.info("@YAuto queue @Wcompleted " .. iterInfo)
-- Break if we completed all of the requested commands
if (numCmds >= dbot.autoQueuePkg.maxCommands) then
dbot.autoQueueState = dbot.autoQueueDisabled
end -- if
end -- if
end -- if
numCmds = numCmds + 1
end -- while
if (dbot.autoQueueState == dbot.autoQueueHalted) then
retval = DRL_RET_HALTED
end -- if
dbot.autoQueuePkg = nil
return inv.tags.stop(invTagsAutoQueue, endTag, retval)
end -- dbot.autoQueueCR
]]> ]]>
</script> </script>

Loading…
Cancel
Save