From 70be6ef45b30c7b36d67f070cad5cc99730a7051 Mon Sep 17 00:00:00 2001 From: Durel Date: Sat, 23 Jun 2018 22:09:12 -0400 Subject: [PATCH] 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 --- aard_inventory.changelog | 33 +++ aard_inventory.xml | 488 ++++++++++++++++++++++----------------- 2 files changed, 306 insertions(+), 215 deletions(-) diff --git a/aard_inventory.changelog b/aard_inventory.changelog index c51b813..1c727c3 100644 --- a/aard_inventory.changelog +++ b/aard_inventory.changelog @@ -1,6 +1,39 @@ 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] = { { change = drlDbotChangeLogTypeFix, diff --git a/aard_inventory.xml b/aard_inventory.xml index cf6688e..c5337ea 100644 --- a/aard_inventory.xml +++ b/aard_inventory.xml @@ -89,7 +89,7 @@ dbot.version : Module to track version and changelog information and update the save_state="y" date_written="2017-08-12 08:45:15" requires="4.98" - version="2.0043" + version="2.0045" > - - - 0)) then + 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 end -- for end -- if @@ -18805,13 +18878,17 @@ end -- dbot.mergeFields function dbot.arrayConcat(array1, array2) local mergedArray = {} - for _, entry in ipairs(array1) do - table.insert(mergedArray, entry) - end -- for + if (array1 ~= nil) then + for _, entry in ipairs(array1) do + table.insert(mergedArray, entry) + end -- for + end -- if - for _, entry in ipairs(array2) do - table.insert(mergedArray, entry) - end -- for + if (array2 ~= nil) then + for _, entry in ipairs(array2) do + table.insert(mergedArray, entry) + end -- for + end -- if return mergedArray end -- dbot.arrayConcat @@ -18923,6 +19000,50 @@ function dbot.deleteTimer(name) 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 ---------------------------------------------------------------------------------------------------- @@ -19348,6 +19469,10 @@ end -- dbot.error -- dbot.gmcp.getRoomId -- dbot.gmcp.getTier -- +-- dbot.gmcp.getHp() +-- dbot.gmcp.getMana() +-- dbot.gmcp.getMoves() +-- -- dbot.gmcp.isGood -- dbot.gmcp.isNeutral -- dbot.gmcp.isEvil @@ -19563,6 +19688,84 @@ function 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() 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 check (AddTriggerEx(dbot.execute.trigger.fenceName, - "^.*" .. uniqueString .. ".*$", + "^" .. uniqueString .. "$", "dbot.execute.fenceIsDetected = true", drlTriggerFlagsBaseline + trigger_flag.OneShot + trigger_flag.OmitFromOutput, custom_colour.Custom11, 0, "", "", sendto.script, 0)) @@ -22371,151 +22574,6 @@ function 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 - - ]]>