--时装染色
function x900007_OnDressPaint_OK( sceneId, selfId, pos,isAuto)
if not pos or pos < 0 or pos > BAG_DAOJU then
return
end
local nItemId = GetItemTableIndexByIndex(sceneId, selfId, pos)
local EquipPoint = GetItemEquipPoint( nItemId )
local index = 0
if EquipPoint ~= 2 then
x900007_NotifyTip( sceneId, selfId, "#{SZPR_091023_17}" ) --只有时装才能进行这个操作
return
end
local ret = LuaFnIsItemAvailable( sceneId, selfId, pos )
if ret ~= 1 then
x900007_NotifyTip( sceneId, selfId, "#{SZPR_091023_18}" ) --对不起,该时装不符合染色要求。
return
end
if LuaFnGetAvailableItemCount(sceneId, selfId, x900007_HongYaoShiItemID) < 1 then
if isAuto == 1 then
x900007_NotifyTip( sceneId, selfId, "#{YJRS_140613_13}" ) --你的虹耀石数量不足,自动染色结束,请前往元宝商店购买虹耀石。
else
x900007_NotifyTip( sceneId, selfId, "#{SZPR_091023_21}" ) --你缺少虹耀石
end
return
end
local PlayerMoney = GetMoney( sceneId, selfId ) + GetMoneyJZ(sceneId, selfId)
if PlayerMoney < x900007_DressPraint then
if isAuto == 1 then
x900007_NotifyTip( sceneId, selfId, "#{YJRS_140613_14}" ) --金钱不足,自动染色结束。
else
x900007_NotifyTip( sceneId, selfId, "#{JXSQ_170804_44}" ) --金钱不足,无法进行开蒙神器育灵!
end
return
end
--重写的部分
--nColorRate_Table 0 未染色时装 1 普通染色 2 高级染色 3 更高级染色[部分时装无] 4 稀有染色 5 绝版染色
--1 100
--2 50
--3 30
--4 1
--5 0.1
if x900007_DressColor[nItemId] == nil then
x900007_NotifyTip( sceneId, selfId, "#{SZPR_091023_18}")
return
end
local nNormalID,nHighID,nHighExID,nSepcialID,nBoomID = {},{},{},{},{}
for i = 1,getn(x900007_DressColor[nItemId]) do
local nColorRate = x900007_DressColor[nItemId][i][2]
local nColorID = x900007_DressColor[nItemId][i][1]
if nColorRate == 1 then
tinsert(nNormalID,nColorID)
end
if nColorRate == 2 then
tinsert(nHighID,nColorID)
end
if nColorRate == 3 then
tinsert(nHighExID,nColorID)
end
if nColorRate == 4 then
tinsert(nSepcialID,nColorID)
end
if nColorRate == 5 then
tinsert(nBoomID,nColorID)
end
end
local nIsSepcial = 0
local nRandom = random(1,1000)
local nFinalTable = {}
if nRandom <= 1000 then
nFinalTable = nNormalID
end
if nRandom <= 300 then
nFinalTable = nHighID
end
if nRandom <= 200 then
nFinalTable = nHighExID
end
if nRandom <= 10 then
nFinalTable = nSepcialID
end
if nRandom == 1 then
nFinalTable = nBoomID
nIsSepcial = 1
end
if getn(nFinalTable) == nil or getn(nFinalTable) == 0 then
x900007_NotifyTip( sceneId, selfId, "染色失败!非常可惜哦!")
return
end
local nFinalRandom = nFinalTable[random(1,getn(nFinalTable))]
local _,nEquipData = LuaFnGetItemCreator( sceneId, selfId,pos)
if nEquipData ~= nil then
local nPos1,nPos2,nColorId = strfind(nEquipData,"&CO(%w%w%w%w)")
if nPos1 ~= nil and nPos2 ~= nil then
if tonumber(nColorId) == nFinalRandom then
while nFinalRandom == tonumber(nColorId) do
nFinalRandom = nFinalTable[random(1,getn(nFinalTable))]
end
end
end
end
if nFinalRandom ~= 0 then
nFinalRandom = format("%04d",nFinalRandom)
local nColorCode = "&CO"..nFinalRandom
local nFinalData = ""
if nEquipData == nil then
nFinalData = nColorCode
else
local nPos1,nPos2,nColorId = strfind(nEquipData,"&CO(%w%w%w%w)")
if nPos1 ~= nil and nPos2 ~= nil then
nFinalData = gsub(nEquipData,"&CO(%w%w%w%w)",nColorCode)
else
nFinalData = nColorCode..nEquipData
end
end
-- 异常处理,检查是否有多个&CO
local _, count = gsub(nFinalData, "&CO", "")
if count > 1 then
-- 如果有多个&CO,则将多余的&CO替换为""
nFinalData = gsub(nFinalData, "&CO", "", count-1)
end
LuaFnDelAvailableItem(sceneId,selfId,x900007_HongYaoShiItemID,1) --材料扣除
LuaFnCostMoneyWithPriority(sceneId, selfId, x900007_DressPraint) --扣钱
LuaFnSetItemCreator( sceneId, selfId,pos,nFinalData)
LuaFnSendSpecificImpactToUnit(sceneId, selfId, selfId, selfId, 151, 0)
x900007_NotifyTip( sceneId, selfId, "恭喜,时装染色成功")
BeginUICommand( sceneId )
UICommand_AddInt( sceneId, nFinalRandom ) --visualid
UICommand_AddInt( sceneId, pos ) --pos
UICommand_AddInt( sceneId, nIsSepcial)
EndUICommand( sceneId )
DispatchUICommand( sceneId, selfId, 1000000011 )
return
end
end