mirror of
https://github.com/ornfelt/azerothcore_lua_scripts
synced 2026-08-22 06:26:03 -04:00
113 lines
4.9 KiB
Lua
113 lines
4.9 KiB
Lua
|
|
--[[
|
|||
|
|
简介: ELUNA 物品升级
|
|||
|
|
原作者:5L
|
|||
|
|
修改:烟雨江南
|
|||
|
|
致谢:ayase,愈
|
|||
|
|
|
|||
|
|
CREATE TABLE IF NOT EXISTS `item_up` (
|
|||
|
|
`id` int(10) NOT NULL,
|
|||
|
|
`id1` int(10) NOT NULL,
|
|||
|
|
`id2` int(10) NOT NULL DEFAULT '0',
|
|||
|
|
`amount` int(10) NOT NULL DEFAULT '0',
|
|||
|
|
`amount1` int(10) NOT NULL DEFAULT '0',
|
|||
|
|
`amount2` int(10) NOT NULL DEFAULT '0',
|
|||
|
|
`upid` int(10) NOT NULL DEFAULT '0',
|
|||
|
|
`chance` int(10) NOT NULL DEFAULT '0',
|
|||
|
|
`crazing` int(10) NOT NULL DEFAULT '0',
|
|||
|
|
`baoshi` int(10) NOT NULL DEFAULT '0'
|
|||
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|||
|
|
|
|||
|
|
|
|||
|
|
]]--
|
|||
|
|
print(">>Script: Item_up loading...OK")
|
|||
|
|
math.randomseed(tonumber(tostring(os.time()):reverse():sub(1,6)))
|
|||
|
|
local ITEMID = 71000 --合成宝珠(无效, target:GetEntry()直接写ID可以)
|
|||
|
|
UP ={};
|
|||
|
|
|
|||
|
|
function Item_Up(event, player, item, target)
|
|||
|
|
player:MoveTo(0,player:GetX()+0.01,player:GetY(),player:GetZ())
|
|||
|
|
U = target:GetEntry();
|
|||
|
|
--------------------------0----1------2-------3-------4--------5-----6------7---------8---
|
|||
|
|
Q = WorldDBQuery("SELECT id1, id2, amount, amount1, amount2, upid, chance, crazing, baoshi FROM item_up WHERE `id` = '"..U.."';");
|
|||
|
|
if (Q == nil) then
|
|||
|
|
player:SendBroadcastMessage("装备无法升级。")
|
|||
|
|
player:SendAreaTriggerMessage("装备无法升级。")
|
|||
|
|
return;
|
|||
|
|
end
|
|||
|
|
UP[U] = {
|
|||
|
|
upid = Q:GetString(5), --升级后的ID
|
|||
|
|
amount = Q:GetString(2), --原始装备的数量
|
|||
|
|
chance = Q:GetString(6), --成功几率
|
|||
|
|
crazing = Q:GetString(7), --失败是否碎裂:0不碎,1碎
|
|||
|
|
id1 = Q:GetString(0), --需要的物品1的ID
|
|||
|
|
amount1 = Q:GetString(3), --需要的物品1的数量
|
|||
|
|
id2 = Q:GetString(1), --需要的物品2的ID
|
|||
|
|
amount2 = Q:GetString(4), --需要的物品2的数量
|
|||
|
|
baoshi = Q:GetString(8) --防爆宝石ID
|
|||
|
|
};
|
|||
|
|
player:GossipClearMenu();
|
|||
|
|
player:GossipMenuAddItem(1," 需要材料:"..GetItemLink(U).."×"..UP[U].amount.."件",0,99);
|
|||
|
|
if (tonumber(UP[U].id1) > 0 and tonumber(UP[U].amount1) > 0) then
|
|||
|
|
player:GossipMenuAddItem(1," 需要材料:"..GetItemLink(UP[U].id1).."×"..UP[U].amount1.."件",0,99);
|
|||
|
|
end
|
|||
|
|
if (tonumber(UP[U].id2) > 0 and tonumber(UP[U].amount2) > 0) then
|
|||
|
|
player:GossipMenuAddItem(1," 需要材料:"..GetItemLink(UP[U].id2).."×"..UP[U].amount2.."件",0,99);
|
|||
|
|
end
|
|||
|
|
player:GossipMenuAddItem(1," 升级后装备:"..GetItemLink(UP[U].upid),0,99);
|
|||
|
|
player:GossipMenuAddItem(1," 成功几率:"..UP[U].chance.."%",0,99);
|
|||
|
|
if (tonumber(UP[U].crazing) == 0) then
|
|||
|
|
player:GossipMenuAddItem(1," 失败后不会碎裂",0,99);
|
|||
|
|
end
|
|||
|
|
if (tonumber(UP[U].crazing) == 1) then
|
|||
|
|
player:GossipMenuAddItem(1," 失败后道具消失",0,99);
|
|||
|
|
end
|
|||
|
|
player:GossipMenuAddItem(1," |CFFFF1100确认合成|R",1,1);
|
|||
|
|
player:GossipSendMenu(1,item);
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
function Item_Select(event, player, object, sender, intid, code, menu_id)
|
|||
|
|
if (intid == 1) then
|
|||
|
|
local ChanceUp = math.random(0,100)
|
|||
|
|
if player:HasItem(U, tonumber(UP[U].amount)) and (tonumber(UP[U].id1) == 0 or tonumber(UP[U].amount1) == 0 or player:HasItem(tonumber(UP[U].id1), tonumber(UP[U].amount1))) and (tonumber(UP[U].id2) == 0 or tonumber(UP[U].amount2) == 0 or player:HasItem(tonumber(UP[U].id2), tonumber(UP[U].amount2))) then
|
|||
|
|
if tonumber(UP[U].id1) > 0 and tonumber(UP[U].amount1) > 0 then
|
|||
|
|
player:RemoveItem(UP[U].id1, UP[U].amount1);
|
|||
|
|
end
|
|||
|
|
if tonumber(UP[U].id2) > 0 and tonumber(UP[U].amount2) > 0 then
|
|||
|
|
player:RemoveItem(UP[U].id2, UP[U].amount2);
|
|||
|
|
end
|
|||
|
|
if tonumber(UP[U].chance) >= ChanceUp then
|
|||
|
|
if player:HasItem(tonumber(UP[U].baoshi), 1) then
|
|||
|
|
player:RemoveItem(tonumber(UP[U].baoshi), 1);
|
|||
|
|
end
|
|||
|
|
player:RemoveItem(U,UP[U].amount);
|
|||
|
|
player:AddItem(UP[U].upid, 1);
|
|||
|
|
player:SendBroadcastMessage("|CFFFF0000合成成功!!|R");
|
|||
|
|
player:SendAreaTriggerMessage("|CFFFF0000合成成功!!|R");
|
|||
|
|
else
|
|||
|
|
if (tonumber(UP[U].crazing) == 0) then
|
|||
|
|
player:SendBroadcastMessage("|CFFFF0000合成失败!!|R");
|
|||
|
|
player:SendAreaTriggerMessage("|CFFFF0000合成失败!!|R");
|
|||
|
|
elseif player:HasItem(tonumber(UP[U].baoshi), 1) then
|
|||
|
|
player:RemoveItem(tonumber(UP[U].baoshi), 1);
|
|||
|
|
player:SendBroadcastMessage("|CFFFF0000合成失败!破碎的防爆宝石抵消了灾厄的降临!!|R");
|
|||
|
|
player:SendAreaTriggerMessage("|CFFFF0000合成失败!破碎的防爆宝石抵消了灾厄的降临!!|R");
|
|||
|
|
else
|
|||
|
|
player:RemoveItem(U, UP[U].amount);
|
|||
|
|
player:SendBroadcastMessage("|CFFFF0000合成失败!物品破碎!|R");
|
|||
|
|
player:SendAreaTriggerMessage("|CFFFF0000合成失败!物品破碎!|R");
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
player:SendBroadcastMessage("|CFFFF0000装备或材料数量不足|R");
|
|||
|
|
player:SendAreaTriggerMessage("|CFFFF0000装备或材料数量不足|R");
|
|||
|
|
end
|
|||
|
|
player:GossipComplete();
|
|||
|
|
end
|
|||
|
|
if(intid == 99) then
|
|||
|
|
player:SendBroadcastMessage("|CFFFF0000请点击确定合成按钮!!!|R");
|
|||
|
|
player:SendAreaTriggerMessage("|CFFFF0000请点击确定合成按钮!!!R");
|
|||
|
|
player:GossipComplete();
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
RegisterItemEvent(ITEMID, 2, Item_Up);
|
|||
|
|
RegisterItemGossipEvent(ITEMID, 2, Item_Select);
|