TA的每日心情 | 擦汗 2024-10-8 12:00 |
---|
签到天数: 5 天 [LV.2]偶尔看看I
管理员
- 积分
- 1153
|
用法介绍:将以下代码复制后另存为gem_compound.lua,并按照路径进行覆盖
文件路径:tlbb\Public\Data\Script\event\liveabilityevent
文件名称:gem_compound.lua
- -- 宝石合成
- -- 脚本号
- x701602_g_scriptId = 701602
- -- 脚本名称
- x701602_g_scriptName = "合成宝石"
- -- 合成规则表
- x701602_g_CompoundRule = {
- {
- [1] = { SpecialStuff = 30900015, MoneyCost = 5000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- [2] = { SpecialStuff = 30900015, MoneyCost = 6000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- [3] = { SpecialStuff = 30900015, MoneyCost = 7000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- [4] = { SpecialStuff = 30900016, MoneyCost = 8000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- [5] = { SpecialStuff = 30900016, MoneyCost = 9000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- [6] = { SpecialStuff = 30900016, MoneyCost = 10000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- [7] = { SpecialStuff = 30900016, MoneyCost = 11000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- [8] = { SpecialStuff = 30900016, MoneyCost = 12000, CountTable = { [3] = { SuccOdds = 25, SuccOddsWithSpecStuff = 50, }, [4] = { SuccOdds = 50, SuccOddsWithSpecStuff = 75, }, [5] = { SuccOdds = 75, SuccOddsWithSpecStuff = 100, }, }, },
- },
- {
- [1] = { SpecialStuff = -1, MoneyCost = 500, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- [2] = { SpecialStuff = -1, MoneyCost = 1000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- [3] = { SpecialStuff = -1, MoneyCost = 1500, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- [4] = { SpecialStuff = -1, MoneyCost = 5000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, }, -- modify by cuiyinjie 开放4级3精合成
- -- [5] = { SpecialStuff = -1, MoneyCost = 2500, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [6] = { SpecialStuff = -1, MoneyCost = 3000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [7] = { SpecialStuff = -1, MoneyCost = 3500, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [8] = { SpecialStuff = -1, MoneyCost = 4000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- },
- {
- [1] = { SpecialStuff = -1, MoneyCost = 10000, CountTable = { [3] = { SuccOdds = 0, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 0, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [2] = { SpecialStuff = -1, MoneyCost = 1000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [3] = { SpecialStuff = -1, MoneyCost = 1500, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [4] = { SpecialStuff = -1, MoneyCost = 2000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [5] = { SpecialStuff = -1, MoneyCost = 2500, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [6] = { SpecialStuff = -1, MoneyCost = 3000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [7] = { SpecialStuff = -1, MoneyCost = 3500, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- -- [8] = { SpecialStuff = -1, MoneyCost = 4000, CountTable = { [3] = { SuccOdds = 50, SuccOddsWithSpecStuff = 0, }, [4] = { SuccOdds = 75, SuccOddsWithSpecStuff = 0, }, [5] = { SuccOdds = 100, SuccOddsWithSpecStuff = 0, }, }, },
- },
- }
- -- 合成材料玄天寒玉
- x701602_g_HanYu_MaterialId = 20310110
- -- 生成物寒玉精碎
- x701602_g_HanYu_OutPutId = 20310111
- --**********************************************************************
- -- 任务入口函数
- --**********************************************************************
- function x701602_OnDefaultEvent( sceneId, selfId, targetId )
- BeginUICommand(sceneId)
- EndUICommand(sceneId)
- DispatchUICommand(sceneId,selfId, 23)
- end
- --**********************************************************************
- -- 列举事件
- --**********************************************************************
- function x701602_OnEnumerate( sceneId, selfId, targetId )
- AddNumText(sceneId, x701602_g_scriptId, x701602_g_scriptName,6,-1)
- end
- --**********************************************************************
- -- 判断是否宝石
- --**********************************************************************
- function x701602_IsGem( itemIndex )
- if floor( itemIndex / 10000000 ) == 5 then
- return 1
- end
- return 0
- end
- --**********************************************************************
- -- 判断是否材料
- --**********************************************************************
- function x701602_IsMaterial( itemIndex )
- if floor( itemIndex / 100000 ) == 205 then
- return 1
- end
- return 0
- end
- --**********************************************************************
- -- 根据一个物品号得到该物品的大分类
- --**********************************************************************
- function x701602_GetStuffClass( itemIndex )
- if x701602_IsGem( itemIndex ) == 1 then
- return 1
- elseif x701602_IsMaterial( itemIndex ) == 1 then
- return 2
- elseif itemIndex == x701602_g_HanYu_MaterialId then
- return 3
- end
- return -1
- end
- --**********************************************************************
- -- 根据一个物品号得到该物品的类型
- --**********************************************************************
- function x701602_GetStuffType( itemIndex )
- if x701602_IsGem( itemIndex ) == 1 then
- return mod( itemIndex, 100000 )
- elseif x701602_IsMaterial( itemIndex ) == 1 then
- return LuaFnGetItemType( itemIndex )
- elseif itemIndex == x701602_g_HanYu_MaterialId then
- return LuaFnGetItemType( itemIndex )
- end
- return -1
- end
- --**********************************************************************
- -- 根据一个物品号得到该物品的等级
- --**********************************************************************
- function x701602_GetStuffGrade( itemIndex )
- if x701602_IsGem( itemIndex ) == 1 then
- return GetItemQuality( itemIndex )
- elseif x701602_IsMaterial( itemIndex ) == 1 then
- return GetCommonItemGrade( itemIndex )
- elseif itemIndex == x701602_g_HanYu_MaterialId then
- return GetCommonItemGrade( itemIndex )
- end
- return -1
- end
- --**********************************************************************
- -- 根据一个物品号得到该物品的升级物品号
- --**********************************************************************
- function x701602_GetStuffUpgraded( itemIndex )
- if x701602_IsGem( itemIndex ) == 1 then
- return ( itemIndex + 100000 )
- elseif x701602_IsMaterial( itemIndex ) == 1 then
- return ( itemIndex + 1 )
- elseif itemIndex == x701602_g_HanYu_MaterialId then
- return x701602_g_HanYu_OutPutId
- end
- return -1
- end
- --**********************************************************************
- -- 宝石以及材料合成接口
- -- bagIndex1, bagIndex2 ... bagIndex5:五个宝石或材料所在的格子
- -- bagIndex6:特殊材料
- --**********************************************************************
- function x701602_GemCompound( sceneId, selfId, bagIndex1, bagIndex2, bagIndex3, bagIndex4, bagIndex5, bagIndex6 )
- local bagIndexList = { bagIndex1, bagIndex2, bagIndex3, bagIndex4, bagIndex5 }
- local stuffList = { -1, -1, -1, -1, -1 }
- local stuffCount = 0 -- 材料个数
- local specialStuff = -1 -- 特殊材料
- local CompoundClass = -1 -- 材料大类[分为宝石和材料]
- local CompoundType = -1 -- 材料种类[各种宝石以及各种材料]
- local stuffGrade = -1 -- 材料等级
- local standardStuff = -1
- local IsBind = 0;
-
- -- 不允许有重复的bagIndexList出现 added by dun.liu 2009.2.5
- local isUnique = ScriptGlobal_IsUniqueNumberTable(bagIndexList);
- if isUnique == 0 then
- return OR_ERROR;
- end
- for i = 1, 5 do
- if bagIndexList[i] ~= -1 then
- if LuaFnIsItemAvailable( sceneId, selfId, bagIndexList[i] ) < 1 then -- 使用有问题的物品则退出流程
- return OR_STUFF_LACK
- else
- stuffList[i] = LuaFnGetItemTableIndexByIndex( sceneId, selfId, bagIndexList[i] )
- stuffCount = stuffCount + 1
- if CompoundClass == -1 and stuffGrade == -1 and CompoundType == -1 then
- standardStuff = stuffList[i]
- CompoundClass = x701602_GetStuffClass( standardStuff )
- stuffGrade = x701602_GetStuffGrade( standardStuff )
- CompoundType = x701602_GetStuffType( standardStuff )
- end
-
- --判断材料是否符合
- if x701602_IsMaterial( stuffList[i] ) == 1 and
- mod( stuffList[i], 10 ) > 8 then
- return OR_STUFF_LACK
- end
-
- --判断宝石是否绑定
- if(LuaFnGetItemBindStatus( sceneId, selfId, bagIndexList[i]) == 1) then
- IsBind = 1;
- end
-
- end
- end
- end
- local CompoundRule = x701602_g_CompoundRule[CompoundClass]
- if not CompoundRule then
- return OR_ERROR
- end
- if bagIndex6 ~= -1 then
- if LuaFnIsItemAvailable( sceneId, selfId, bagIndex6 ) < 1 then -- 使用有问题的物品则忽略
- bagIndex6 = -1
- else
- specialStuff = LuaFnGetItemTableIndexByIndex( sceneId, selfId, bagIndex6 )
- end
- end
- for i = 1, 5 do
- if stuffList[i] ~= -1 then
- if CompoundClass ~= x701602_GetStuffClass( stuffList[i] )
- or stuffGrade ~= x701602_GetStuffGrade( stuffList[i] )
- or CompoundType ~= x701602_GetStuffType( stuffList[i] )
- then
- return OR_STUFF_LACK
- end
- end
- end
- --if not CompoundRule[stuffGrade] then -- 这种情况通常都是已经 9 级了
- --return OR_CANNOT_UPGRADE
- --end
-
-
- local selfMoney = GetMoney( sceneId, selfId ) + GetMoneyJZ(sceneId, selfId) --交子普及 Vega
-
- if selfMoney < CompoundRule[stuffGrade].MoneyCost then
- return OR_NOTENOUGH_MONEY -- 钱不够,一般由客户端自行提示
- end
- if not CompoundRule[stuffGrade].CountTable[stuffCount] then
- return OR_STUFF_LACK
- end
- local SuccOdds = CompoundRule[stuffGrade].CountTable[stuffCount].SuccOdds
- if specialStuff ~= -1 then
- if specialStuff ~= CompoundRule[stuffGrade].SpecialStuff then -- 滥竽充数的特殊材料处理
- bagIndex6 = -1
- specialStuff = -1
- else
- SuccOdds = CompoundRule[stuffGrade].CountTable[stuffCount].SuccOddsWithSpecStuff
- end
- end
-
- -- 必须特殊材料
- if specialStuff == -1 then
- if 1 == CompoundClass then --如果材料为宝石,则必须需要特殊材料
- return OR_ERROR
- end
- end
- -- 计算新物品编号
- local newItemIndex = x701602_GetStuffUpgraded( standardStuff )
- -- 扣除材料, 一定要全部扣除成功,才能继续进行 added by dun.liu 2009.2.5
- for i = 1, 5 do
- if bagIndexList[i] ~= -1 then
- local isEraseSuc = LuaFnEraseItem( sceneId, selfId, bagIndexList[i] );
- if( isEraseSuc == 0 ) then
- return OR_ERROR;
- end
- end
- end
- -- 扣除特殊材料
- if bagIndex6 ~= -1 then
- --判断特殊材料是否绑定 add by xindefeng
- if(LuaFnGetItemBindStatus( sceneId, selfId, bagIndex6) == 1) then
- IsBind = 1;--设置强制绑定标志
- end
- LuaFnEraseItem( sceneId, selfId, bagIndex6 )
- end
- -- 扣除金钱
- local ret = LuaFnCostMoneyWithPriority( sceneId, selfId, CompoundRule[stuffGrade].MoneyCost ) --交子普及 Vega
- if ret < 0 then
- return OR_NOTENOUGH_MONEY
- end
- -- 生成合成物,最后一个 1 是品质,不影响本类型合成物
- local maxStuffCountChange = 3;
- local maxSpecialStuffChange = 2;
- local maxStuffGrade = 8;
-
- local selectRandomIndex = 0;
- if CompoundClass == 2 then
- selectRandomIndex = 1;
- end
-
- if CompoundClass == 3 then
- selectRandomIndex = 2;
- end
-
- selectRandomIndex = selectRandomIndex * maxStuffGrade;
- selectRandomIndex = selectRandomIndex + (stuffGrade - 1);
- selectRandomIndex = selectRandomIndex * maxSpecialStuffChange;
- if specialStuff ~= -1 then
- selectRandomIndex = selectRandomIndex + 1;
- end
- selectRandomIndex = selectRandomIndex * maxStuffCountChange;
- selectRandomIndex = selectRandomIndex + (stuffCount - 3);
- local randValue = LuaFnCompoundRandom(selectRandomIndex);
- if randValue > SuccOdds then -- 合成失败
- LuaFnSendAbilityFailureMsg( sceneId, selfId, -1, -1, -1 )
- LuaFnAuditGemCompound( sceneId, selfId, 0,
- stuffList[1], stuffList[2], stuffList[3], stuffList[4], stuffList[5], -1 )
- else
- res = LuaFnTryRecieveItemIgnoreFatigueState( sceneId, selfId, newItemIndex, QUALITY_MUST_BE_CHANGE)
- if res == -1 then
- return OR_FAILURE
- end
- --强制绑定
- if(IsBind == 1) then
- LuaFnItemBind( sceneId, selfId, res);
- end
-
- --增加特效
- LuaFnSendSpecificImpactToUnit(sceneId, selfId, selfId, selfId, 49, 0);
-
- --醒目提示
- BeginEvent( sceneId )
- AddText( sceneId, "合成成功" )
- EndEvent( sceneId )
- DispatchMissionTips( sceneId, selfId )
-
- if x701602_IsGem( newItemIndex ) == 1 then
- stuffGrade = x701602_GetStuffGrade( newItemIndex )
- --公告精简,小于4级的宝石合成不发公告
- if stuffGrade >= 4 then
- local szTransferItem = GetBagItemTransfer( sceneId, selfId, res )
- BroadMsgByChatPipe( sceneId, selfId, "#W#{_INFOUSR" .. GetName( sceneId, selfId ) .. "}#H经过一番努力,终于合成出了#W#{_INFOMSG" .. szTransferItem .. "}#H。", 4 )
- end
- end
- LuaFnSendAbilitySuccessMsg( sceneId, selfId, -1, -1, newItemIndex ) -- 提示生成物
- LuaFnAuditGemCompound( sceneId,selfId, 1,
- stuffList[1], stuffList[2], stuffList[3], stuffList[4], stuffList[5], newItemIndex )
- end
- return OR_OK
- end
复制代码
|
|