本帖最后由 MTFX001 于 2025-11-2 11:03 PM 编辑
这个是改进代码可以不用其他宏帮助!很方便
[Lua] 纯文本查看 复制代码 -- 完全静默版本 - 几乎无提示
local isDrinking = false
local lastActionTime = 0
local function IsEatingOrDrinking()
local buffIndex = 1
while true do
local buffName = UnitBuff("player", buffIndex)
if not buffName then break end
if string.find(buffName, "进食") or string.find(buffName, "喝水") then
return true
end
buffIndex = buffIndex + 1
end
return false
end
-- 自动交易功能
if TradeFrame:IsVisible() then
BeeRun("/run for b=0,4 do for s=1,GetContainerNumSlots(b) do local l=GetContainerItemLink(b,s) if l and (string.find(l,'魔法冰川水') or string.find(l,'魔法羊角面包')) then UseContainerItem(b,s) end end end")
TradeFrameTradeButton:Click()
--BeeRun("/click TradeFrameTradeButton")
--BeeRun("/script AcceptTrade()")
end
-- 自动离队功能
BeeRun("/run local w=GetItemCount('魔法冰川水')or 0 local f=GetItemCount('魔法羊角面包')or 0 if w==0 and f==0 and (GetNumPartyMembers()>0 or GetNumRaidMembers()>0) then LeaveParty() end")
local function Main()
local currentTime = GetTime()
if currentTime - lastActionTime < 1 then return end
if IsEatingOrDrinking() then
isDrinking = true
return
elseif isDrinking then
isDrinking = false
BeeRun("/stand")
return
end
local manaPercentage = UnitMana("player") / UnitManaMax("player") * 100
local waterCount = GetItemCount("魔法冰川水") or 0
local gemCount = GetItemCount("法力刚玉") or 0
if UnitCastingInfo("player") or UnitChannelInfo("player") then return end
-- 蓝量管理
if manaPercentage < 15 then
if waterCount > 0 and not UnitAffectingCombat("player") then
if GetUnitSpeed("player") > 0 then
BeeRun("StrafeLeft")
BeeRun("StrafeRight")
return
end
BeeRun("/sit")
BeeRun("/use 魔法冰川水")
isDrinking = true
return
elseif BeeSpellCoolDown("唤醒") == 0 and not UnitAffectingCombat("player") then
BeeRun("唤醒")
return
elseif gemCount > 0 then
BeeRun("/use 法力刚玉")
return
end
end
-- 制造和造水造食
if gemCount < 1 and BeeSpellCoolDown("制造法力宝石") == 0 then
BeeRun("制造法力宝石")
return
end
if GetItemCount("魔法冰川水") < 51 and BeeSpellCoolDown("造水术") == 0 then
BeeRun("造水术")
return
end
if GetItemCount("魔法羊角面包") < 51 and BeeSpellCoolDown("造食术") == 0 then
BeeRun("造食术")
return
end
lastActionTime = currentTime
end
-- 主执行逻辑:在非骑乘、非死亡、非战斗状态下执行主循环和自动交易/离队检查
if not IsMounted() and not UnitIsDead("player") and not UnitAffectingCombat("player") then
Main()
end |