当前位置: 首页 > news >正文

SpeedyAutoLoot

SpeedyAutoLoot自动拾取插件

SpeedyAutoLoot.lua

local AutoLoot = CreateFrame('Frame')SpeedyAutoLootDB = SpeedyAutoLootDB or {}
SpeedyAutoLootDB.global = SpeedyAutoLootDB.global or {}local BACKPACK_CONTAINER = BACKPACK_CONTAINER
local LOOT_SLOT_CURRENCY = LOOT_SLOT_CURRENCY
local LOOT_SLOT_ITEM = LOOT_SLOT_ITEM
local LOOT_SLOT_MONEY = LOOT_SLOT_MONEY
local NUM_BAG_SLOTS = NUM_BAG_SLOTS
local GetContainerNumFreeSlots = GetContainerNumFreeSlots
local GetCVarBool = GetCVarBool
local GetItemCount = GetItemCount
local GetItemInfo = GetItemInfo
local GetLootSlotInfo = GetLootSlotInfo
local GetLootSlotLink = GetLootSlotLink
local GetLootSlotType = GetLootSlotType
local GetNumLootItems = GetNumLootItems
local GetCursorPosition = GetCursorPosition
local IsFishingLoot = IsFishingLoot
local IsModifiedClick = IsModifiedClick
local LootSlot = LootSlot
local PlaySound = PlaySound
local SetCVar = SetCVar
local find = string.find
local select = select
local tContains = tContains
local errorList = { ERR_INV_FULL, ERR_ITEM_MAX_COUNT }
local fishingChannel = 'Master'function AutoLoot:PlayFishingSound()if IsFishingLoot() thenreturn (fishingChannel and PlaySound(SOUNDKIT.FISHING_REEL_IN, fishingChannel)) or PlaySound(SOUNDKIT.FISHING_REEL_IN)end
endfunction AutoLoot:PlayInventoryFullSound()if SpeedyAutoLootDB.global.enableSound and not self.isItemLocked thenPlaySound(SpeedyAutoLootDB.global.InventoryFullSound, 'Master')end
endfunction AutoLoot:LootUnderMouse(self, parent)if(GetCVar('lootUnderMouse') == '1') thenlocal x, y = GetCursorPosition()x = x / self:GetEffectiveScale()y = y / self:GetEffectiveScale()self:ClearAllPoints()self:SetPoint('TOPLEFT', UIParent, 'BOTTOMLEFT', x - 40, y + 20)self:GetCenter()self:Raise()elseself:ClearAllPoints()self:SetPoint('TOPLEFT', parent, 'TOPLEFT')end
endfunction AutoLoot:CalculateFreeSlots()local numTotalFree, numFreeSlots, bagFamily = 0for i = BACKPACK_CONTAINER, NUM_BAG_SLOTS donumFreeSlots, bagFamily = GetContainerNumFreeSlots(i)if bagFamily == 0 thennumTotalFree = numTotalFree + numFreeSlotsendendreturn numTotalFree
endfunction AutoLoot:ProcessLoot(itemLink, quantity, slotType)if slotType == LOOT_SLOT_MONEY thenreturn trueelseif slotType == LOOT_SLOT_CURRENCY thenreturn trueelseif slotType == LOOT_SLOT_ITEM thenif self:CalculateFreeSlots() > 0 thenreturn trueendlocal have = (GetItemCount(itemLink) or 0)if have > 0 thenlocal itemStackCount = (select(8,GetItemInfo(itemLink)) or 0)if itemStackCount > 1 thenwhile have > itemStackCount dohave = have - itemStackCountendlocal remain = itemStackCount - haveif remain >= quantity thenreturn trueendendendend
endfunction AutoLoot:ShowLootFrame(show)if self.XLoot thenif show thenself:LootUnderMouse(XLootFrame, UIParent)XLootFrame:SetParent(UIParent)XLootFrame:SetFrameStrata('DIALOG')self.isHidden = falseelseXLootFrame:SetParent(self)self.isHidden = trueendelseif self.ElvUI thenif show thenself:LootUnderMouse(ElvLootFrame, ElvLootFrameHolder)ElvLootFrame:SetParent(ElvLootFrameHolder)ElvLootFrame:SetFrameStrata('HIGH')self.isHidden = falseelseElvLootFrame:SetParent(self)self.isHidden = trueendelseif LootFrame:IsEventRegistered('LOOT_SLOT_CLEARED') thenLootFrame.page = 1;if show thenself:LootUnderMouse(LootFrame, UIParent)LootFrame_Show(LootFrame)self.isHidden = falseelseself.isHidden = trueendendself:PlayFishingSound()
endfunction AutoLoot:LootItems()local numItems = GetNumLootItems() or 0if numItems > 0 thenfor i = numItems, 1, -1 dolocal itemLink = GetLootSlotLink(i)local slotType = GetLootSlotType(i)local quantity, _, _, locked, isQuestItem = select(3, GetLootSlotInfo(i))if locked thenself.isItemLocked = lockedelseif isQuestItem or self:ProcessLoot(itemLink, quantity, slotType) thennumItems = numItems - 1LootSlot(i)endendif numItems > 0 thenself:ShowLootFrame(true)self:PlayInventoryFullSound()endend
endfunction AutoLoot:OnEvent(e, ...)if e == 'PLAYER_LOGIN' thenif XLootFrame thenself.XLoot = trueelseif ElvUI and ElvUI[1].private.general.loot thenself.ElvUI = trueendif SpeedyAutoLootDB.global.alwaysEnableAutoLoot thenSetCVar('autoLootDefault',1)endLootFrame:UnregisterEvent('LOOT_OPENED')self:ShowLootFrame(false)elseif (e == 'LOOT_READY' or e == 'LOOT_OPENED') and not self.isLooting thenself.isLooting = truelocal autoLoot = ...if autoLoot or GetCVarBool('autoLootDefault') ~= IsModifiedClick('AUTOLOOTTOGGLE') thenself:LootItems()elseself:ShowLootFrame(true)endelseif e == 'LOOT_CLOSED' thenself.isLooting = falseself.isHidden  = falseself.isItemLocked = nilself:ShowLootFrame(false)elseif e == 'UI_ERROR_MESSAGE' and tContains(errorList, select(2,...)) thenif self.isLooting and self.isHidden thenself:ShowLootFrame(true)self:PlayInventoryFullSound()endend
endSLASH_SPEEDYAUTOLOOT1, SLASH_SPEEDYAUTOLOOT2, SLASH_SPEEDYAUTOLOOT3  = '/sal', '/speedyloot', '/speedyautoloot'
function SlashCmdList.SPEEDYAUTOLOOT(msg)local _, _, cmd, args = find(msg, '%s?(%w+)%s?(.*)')if not cmd or cmd == '' or cmd == 'help' thenprint('|cffEEE4AESpeedy AutoLoot:|r |cffEF6D6D/sal /speedyautoloot /speedyloot|r')print('  |cffEF6D6D/sal auto              -|r  |cffFAD1D1Enable Auto Looting for new/all characters|r')print('  |cffEF6D6D/sal sound            -|r  |cffFAD1D1Play a Sound when Inventory is full while looting|r')print('  |cffEF6D6D/sal set (SoundID) -|r  |cffFAD1D1Set a Sound (SoundID), Example: /sal set 139|r')elseif cmd == 'auto' thenif SpeedyAutoLootDB.global.alwaysEnableAutoLoot thenSpeedyAutoLootDB.global.alwaysEnableAutoLoot = falseprint('|cffEEE4AESpeedy AutoLoot:|r |cffB6B6B6Auto Loot for all Characters disabled.')elseSpeedyAutoLootDB.global.alwaysEnableAutoLoot = trueprint('|cffEEE4AESpeedy AutoLoot:|r |cff37DB33Auto Loot for all Characters enabled.')endelseif cmd == 'sound' thenif SpeedyAutoLootDB.global.enableSound thenSpeedyAutoLootDB.global.enableSound = falseprint('|cffEEE4AESpeedy AutoLoot:|r |cffB6B6B6Don\'t play a sound when inventory is full.')elseif not SpeedyAutoLootDB.global.InventoryFullSound thenSpeedyAutoLootDB.global.InventoryFullSound = 139endSpeedyAutoLootDB.global.enableSound = trueprint('|cffEEE4AESpeedy AutoLoot:|r |cff37DB33Play a sound when inventory is full.')endelseif cmd == 'set' and args ~= '' thenlocal SoundID = tonumber(args:match('%d+'))if SoundID thenSpeedyAutoLootDB.global.InventoryFullSound = tonumber(args:match('%d+'))PlaySound(SoundID, 'Master')print('|cffEEE4AESpeedy AutoLoot: Set Sound|r |cff37DB33'..SoundID..'|r')endend
endfunction AutoLoot:OnLoad()self:SetToplevel(true)self:Hide()self:SetScript('OnEvent', function(_, ...)self:OnEvent(...)end)for _,e in next, ({	'PLAYER_LOGIN','LOOT_READY','LOOT_OPENED','LOOT_CLOSED','UI_ERROR_MESSAGE' }) doself:RegisterEvent(e)end
end
AutoLoot:OnLoad()

SpeedyAutoLoot.toc

## Interface: 11302
## Title: |cffEEE4AESpeedy AutoLoot|r
## Notes: |cff58C6FALoot at ludicrous speed!|r
## Author: Yuyuli
## Version: 2.0.9
## SavedVariables: SpeedyAutoLootDBSpeedyAutoLoot.lua

相关文章:

  • Linux中的shell脚本练习
  • MCP之二_服务器与客户端实现
  • Python实例题:Pvthon实现键值数据库
  • 【计网】认识跨域,及其在go中通过注册CORS中间件解决跨域方案,go-zero、gin
  • 对VTK中的Volume Data体数据进行二维图像处理
  • 电子电器架构 ---电气/电子架构将在塑造未来出行方面发挥啥作用?
  • React速通笔记
  • OpenGL----OpenGL纹理与纹理缓存区
  • 系统架构-架构评估
  • Golang|使用函数作为参数和使用接口的联系
  • 如何使用 Redis 缓存验证码
  • 【MCP Node.js SDK 全栈进阶指南】高级篇(1):MCP多服务器协作架构
  • 在视图中交互 闪退问题
  • 有哪些和PPT自动生成有关的MCP项目?
  • 多实例情况下,实例名较长dbca失败
  • TimDbg
  • Shell脚本-随机数实战案例
  • 排序--数据结构初阶(4)(C/C++)
  • Vuex(二) —— 用Vuex完成购物车案例
  • Python3:Jupyterlab 安装和配置
  • 五一期间上海景观照明开启重大活动模式,外滩不展演光影秀
  • 柴德赓、纪庸与叫歇碑
  • 中纪报:五一节前公开通报释放强烈信号,以铁律狠刹歪风邪气
  • 女乘客遭顺风车甩客、深夜丢高速服务区,滴滴霸道回应:赔五百元
  • 规范涉企案件审判执行工作,最高法今天发布通知
  • 巴达玛·利斯瓦达恭当选世界羽联主席,张军任理事会理事