From 1ea73e1885835466265ce788d93556b7030ee0e8 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期日, 30 十二月 2018 18:42:00 +0800 Subject: [PATCH] 5424 【后端】【1.4】跨服竞技场开发(GM工具增加子服服务器维护,文字翻译版) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py | 375 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 323 insertions(+), 52 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py index f7bbd52..4e6acb2 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_ItemCompound.py @@ -25,10 +25,14 @@ import IpyGameDataPY import ChConfig import PlayerSuccess +import DataRecordPack import PlayerWing +import PlayerDogz +import EventShell import random import math + #//A3 03 物品合成 #tagCMItemCompound @@ -45,6 +49,8 @@ # BYTE AddonsItemIndexCnt; // 附加物品在背包中索引个数 # BYTE AddonsItemIndex[AddonsItemIndexCnt]; // 附加物品在背包的索引列表 # BYTE AddonsItemCount[AddonsItemIndexCnt]; // 附加物品在背包的索引对应扣除数量列表 +# BYTE RateIncreaseItemIndexCnt; // 提升概率物品在背包中索引个数 +# BYTE RateIncreaseItemIndex[RateIncreaseItemIndexCnt]; // 提升概率物品在背包的索引列表 #}; def OnItemCompound(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) @@ -56,20 +62,32 @@ fixedItemIndexList = clientData.FixedItemIndex addonsItemIndexList = clientData.AddonsItemIndex addonsItemCountList = clientData.AddonsItemCount - GameWorld.DebugLog("物品合成: ID=%s,compoundCnt=%s,unfixedItemIndexList=%s,fixedItemIndexList=%s,addonsItemIndexList=%s,addonsItemCountList=%s" - % (compoundID, compoundCnt, unfixedItemIndexList, fixedItemIndexList, addonsItemIndexList, addonsItemCountList), playerID) + incRateItemIndexList = clientData.RateIncreaseItemIndex + GameWorld.DebugLog("物品合成: ID=%s,compoundCnt=%s,unfixedItemIndexList=%s,fixedItemIndexList=%s,addonsItemIndexList=%s,addonsItemCountList=%s,incRateItemIndexList=%s" + % (compoundID, compoundCnt, unfixedItemIndexList, fixedItemIndexList, addonsItemIndexList, addonsItemCountList, incRateItemIndexList), playerID) ipyData = IpyGameDataPY.GetIpyGameData("ItemCompound", compoundID) if not ipyData: GameWorld.ErrLog("找不到该合成表数据配置! ID=%s" % compoundID) return + composeGroup = ipyData.GetComposeGroup() makeIDList = ipyData.GetMakeID() unfixedItemIDList = ipyData.GetUnfixedItemID() fixedItemIDList = ipyData.GetFixedItemID() fixedItemCountList = ipyData.GetFixedItemCount() - makeItemID = random.choice(makeIDList) # 从可合成物品列表里随机一个 + isFirstSuccMakeJobItem = False + if ipyData.GetIsFirstSuccMakeJobItem() and not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstSuccMakeJobItem % compoundID): + isFirstSuccMakeJobItem = True + makeItemID = 0 + for jobItemID in makeIDList: + itemData = GameWorld.GetGameData().GetItemByTypeID(jobItemID) + if itemData and ItemCommon.CheckJob(curPlayer, itemData): + makeItemID = jobItemID + break + else: + makeItemID = random.choice(makeIDList) # 从可合成物品列表里随机一个 makeItemData = GameWorld.GetGameData().GetItemByTypeID(makeItemID) if not makeItemData: GameWorld.ErrLog("不存在该合成物品! makeItemID=%s" % makeItemID) @@ -88,10 +106,10 @@ needMoney = ipyData.GetNeedMoney() successRate = ipyData.GetSuccessRate() successRateMax = ipyData.GetSuccessRateMax() + successRateIncrease = ipyData.GetSuccessRateIncrease() addonsCountMax = ipyData.GetAddonsCountMax() # 可叠加的算叠加数量 - msgMark = ipyData.GetSysMark() # 可使用非固定道具 或 附加道具的 单次合成数默认为1 - if unfixedItemIDList or addonsCountMax > 0: + if unfixedItemIDList or addonsCountMax > 0 or incRateItemIndexList: compoundCnt = 1 totalNeedMoney = needMoney * compoundCnt @@ -99,44 +117,81 @@ GameWorld.DebugLog("货币不足合成! totalNeedMoney=%s" % totalNeedMoney, playerID) return + # 目标物品可否拆解判断 + canDecompoundItemTypeList = IpyGameDataPY.GetFuncEvalCfg("ItemDecompound", 1) + decompoundMinColor = IpyGameDataPY.GetFuncCfg("ItemDecompound", 2) + canDecompound = makeItemData.GetType() in canDecompoundItemTypeList and makeItemData.GetItemColor() >= decompoundMinColor + decompoundItemInfo = [] # 拆解返还物品列表 [装备ID,材料1ID,个数,是否绑定,材料2ID,个数,是否绑定,...] + itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) + itemExpireTime = 0 wingItemExpInfo = None #材料翅膀精炼信息 + dogzEquipPlusExp = 0 #神兽装备强化熟练度 # 检查不固定消耗道具 if unfixedItemIDList: - unfixedItemCostInfo = __CheckUnfixedItem(playerID, compoundID, makeItemData, itemPack, unfixedItemIndexList, + unfixedItem = GameWorld.GetGameData().GetItemByTypeID(unfixedItemIDList[0]) + if not unfixedItem: + return + if ItemCommon.GetIsDogzEquip(unfixedItem): + unfixedItemPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzItem) + else: + unfixedItemPack = itemPack + unfixedItemCostInfo = __CheckUnfixedItem(playerID, compoundID, makeItemData, unfixedItemPack, unfixedItemIndexList, unfixedItemIDList, needUnfixedItemCount) if not unfixedItemCostInfo: return - unfixedItemCostList, wingItemExpInfo = unfixedItemCostInfo - + unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime = unfixedItemCostInfo + if expireTime: + itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime) + # 检查固定消耗道具 if fixedItemIDList: fixedItemInfo = __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt) if not fixedItemInfo: return - fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt = fixedItemInfo - + fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime = fixedItemInfo + if expireTime: + itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime) + # 检查附加道具增加成功率消耗 - addSuccRate = 0 + addSuccRate, addSuccRateItemInfo = 0, [] if addonsCountMax > 0: - addSuccRate = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax) - if addSuccRate == None: + addSuccRateInfo = __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax) + if addSuccRateInfo == None: return + addSuccRate, addSuccRateItemInfo, expireTime = addSuccRateInfo + if expireTime: + itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime) + # 检查提升概率道具 + incRateItemCostList, needIncRateItemCount, incRate = [], 0, 0 + if successRateIncrease and len(successRateIncrease) == 3 and incRateItemIndexList: + incRateItemID, needIncRateItemCount, incRate = successRateIncrease + incRateItemInfo = __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount) + if not incRateItemInfo: + return + incRateItemCostList, expireTime = incRateItemInfo + if expireTime: + itemExpireTime = expireTime if not itemExpireTime else min(itemExpireTime, expireTime) + # 扣铜钱 PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, totalNeedMoney, ChConfig.Def_Cost_ItemProduce, {ChConfig.Def_Cost_Reason_SonKey:makeItemID, "CompoundCount":compoundCnt}) - drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt} + drDict = {"CompoundID":compoundID, "MakeItemID":makeItemID, "CompoundCount":compoundCnt, "itemExpireTime":itemExpireTime} makeItemBind = False # 扣不固定消耗物品 if unfixedItemIDList: bindUnfixedIndexList, unbindUnfixedIndexList = unfixedItemCostList - hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, bindUnfixedIndexList + unbindUnfixedIndexList, needUnfixedItemCount, + hasBind = ItemCommon.ReduceItem(curPlayer, unfixedItemPack, bindUnfixedIndexList + unbindUnfixedIndexList, needUnfixedItemCount, False, ChConfig.ItemDel_ItemCompound, drDict) makeItemBind = True if hasBind else makeItemBind - + + if canDecompound: + decompoundUnfixedItemID = 0 if not unfixedItemIDList else random.choice(unfixedItemIDList) # 拆解时随机返还一件不固定消耗道具 + decompoundItemInfo.append(decompoundUnfixedItemID) + # 扣固定消耗物品 if fixedItemIDList: for fixedItemID, countInfo in fixedItemNeedCntDict.items(): @@ -145,9 +200,17 @@ if delBindCnt: makeItemBind = True ItemCommon.ReduceItem(curPlayer, itemPack, bindFixedIndexList, delBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict) + if canDecompound: + decompoundItemInfo.append(fixedItemID) + decompoundItemInfo.append(delBindCnt) + decompoundItemInfo.append(1) # 绑定 if delUnBindCnt: ItemCommon.ReduceItem(curPlayer, itemPack, unbindFixedIndexList, delUnBindCnt, False, ChConfig.ItemDel_ItemCompound, drDict) - + if canDecompound: + decompoundItemInfo.append(fixedItemID) + decompoundItemInfo.append(delUnBindCnt) + decompoundItemInfo.append(0) # 不绑定 + # 扣附加道具 if addonsCountMax > 0: for i, addonsItemIndex in enumerate(addonsItemIndexList): @@ -155,26 +218,64 @@ False, ChConfig.ItemDel_ItemCompound, drDict) #makeItemBind = True if hasBind else makeItemBind #策划说附加材料不决定合成物品是否绑定 + # 扣提升概率道具 + if incRateItemCostList: + bindIncRateItemIndexList, unBindIncRateItemIndexList = incRateItemCostList + hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, bindIncRateItemIndexList + unBindIncRateItemIndexList, needIncRateItemCount, + False, ChConfig.ItemDel_ItemCompound, drDict) + if compoundCnt == 1 and makeItemBind: compoundBindCnt = 1 # 给合成物品 - totalSuccRate = successRate + addSuccRate + totalSuccRate = successRate + addSuccRate + incRate if successRateMax: totalSuccRate = min(successRateMax, totalSuccRate) - GameWorld.DebugLog("合成成功率: successRate=%s,addSuccRate=%s,successRateMax=%s,totalSuccRate=%s" - % (successRate, addSuccRate, successRateMax, totalSuccRate), playerID) - # 首次合成一代翅膀成功率百分百 - if makeItemData.GetType() == ChConfig.Def_ItemType_retWing and ItemCommon.GetWingLV(makeItemData) == 1: - if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HadCompoundWing): + GameWorld.DebugLog("合成成功率: successRate=%s,addSuccRate=%s,incRate=%s,successRateMax=%s,totalSuccRate=%s" + % (successRate, addSuccRate, incRate, successRateMax, totalSuccRate), playerID) + # 前X次合成成功率百分百 + composeMustSuccessDict = IpyGameDataPY.GetFuncEvalCfg("ComposeMustSuccess", 1, {}) + if composeGroup in composeMustSuccessDict: + mustSuccessCountTotal = composeMustSuccessDict[composeGroup] + hisComposeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ComposeMustSuccess % composeGroup) + if hisComposeCount < mustSuccessCountTotal: totalSuccRate = ShareDefine.Def_MaxRateValue - PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_HadCompoundWing, 1) - GameWorld.DebugLog("首次合成一代翅膀,必定成功!totalSuccRate=%s" % totalSuccRate, playerID) + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ComposeMustSuccess % composeGroup, hisComposeCount + 1) + GameWorld.DebugLog("前X次合成必定成功!composeGroup=%s,hisComposeCount=%s,mustSuccessCountTotal=%s,totalSuccRate=%s" + % (composeGroup, hisComposeCount, mustSuccessCountTotal, totalSuccRate), playerID) # 合成成功 - if GameWorld.CanHappen(totalSuccRate, ShareDefine.Def_MaxRateValue): - GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s" % (makeItemID, compoundCnt, compoundBindCnt), playerID) - GiveNewCompoundItem(curPlayer, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, msgMark) + maxRateValue = ShareDefine.Def_MaxRateValue + randValue = random.randint(1, maxRateValue) + canHappen = randValue <= totalSuccRate + GameWorld.DebugLog("canHappen=%s,randValue=%s,totalSuccRate=%s,maxRateValue=%s" + % (canHappen, randValue, totalSuccRate, maxRateValue), playerID) + # 不是百分百成功的记录合成流向 + if successRate != maxRateValue: + drDict = {"PlayerID":curPlayer.GetPlayerID(), "AccID":curPlayer.GetAccID(), "ID":compoundID, "MakeItemID":makeItemID, "IsSuccess":canHappen, + "RateInfo":{"totalSuccRate":"%s(%s+%s+%s)" % (totalSuccRate, successRate, addSuccRate, incRate), "randValue":randValue, "maxRateValue":maxRateValue}, + "AddSuccRateItemInfo":addSuccRateItemInfo + } + DataRecordPack.SendEventPack("ItemCompound", drDict, curPlayer) + + if canHappen: + GameWorld.DebugLog("合成成功: makeItemID=%s,compoundCnt=%s,compoundBindCnt=%s,itemExpireTime=%s" % (makeItemID, compoundCnt, compoundBindCnt, itemExpireTime), playerID) + userData = GiveNewCompoundItem(curPlayer, makeItemID, compoundCnt, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime) + + msgMark = ipyData.GetSysMark() + paramType = ipyData.GetSysMarkParamType() + if msgMark not in ['0', '', '-']: + if paramType == 2 and fixedItemIDList and fixedItemCountList: + PlayerControl.WorldNotify(0, msgMark, [curPlayer.GetName(), fixedItemCountList[0], fixedItemIDList[0], makeItemID, userData]) + else: + PlayerControl.WorldNotify(0, msgMark, [curPlayer.GetName(), makeItemID, userData]) + + if isFirstSuccMakeJobItem: + PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstSuccMakeJobItem % compoundID, 1) + GameWorld.DebugLog("标记首次合成成功给本职业物品!", playerID) + + # 通知合成成功 + ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Sucess, makeItemID) #成功合成1个物品成就 PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundItemEx, compoundCnt, [makeItemID]) #合成X阶X颜色X星级以上装备 @@ -182,10 +283,11 @@ itemColor = makeItemData.GetItemColor() itemQuality = makeItemData.GetItemQuality() PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_CompoundEquip, compoundCnt, [classLV, itemColor, itemQuality]) - + EventShell.EventRespons_CompoundEquip(curPlayer, itemColor, itemQuality) # 合成失败 else: GameWorld.DebugLog("合成失败!") + __SendDogzEquipRemainExpMail(playerID, dogzEquipPlusExp, False) ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Fail, 0) #curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Fail) @@ -197,7 +299,9 @@ def __CheckUnfixedItem(playerID, compoundID, makeItemData, itemPack, unfixedItemIndexList, unfixedItemIDList, needUnfixedItemCount): ## 检查不固定消耗道具, 只要客户端提交的数据有不符合要求的,则直接返回 None + expireTime = 0 wingItemExpInfo = None + dogzEquipPlusExp = 0 unfixedItemTotalCount = 0 unfixedItemCostList = [[], []] # [[绑定索引], [非绑定索引]] maxPackCount = itemPack.GetCount() @@ -215,6 +319,13 @@ % (compoundID, index, itemID, unfixedItemIDList), playerID) return + isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem) + if isExpireItem: + if not remainingTime: + GameWorld.Log("不固定消耗道具时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID) + return + expireTime = remainingTime if not expireTime else min(expireTime, remainingTime) + isBind = curItem.GetIsBind() itemCount = curItem.GetCount() unfixedItemTotalCount += itemCount @@ -223,13 +334,19 @@ #记录翅膀精炼值 if curItem.GetType() == ChConfig.Def_ItemType_retWing: wingItemExpInfo = PlayerWing.GetWingItemChangeExp(curItem, ItemCommon.GetItemClassLV(makeItemData)) - + elif ItemCommon.GetIsDogzEquip(curItem): + equipExpEff = ItemCommon.GetItemEffectByEffectID(curItem, ChConfig.Def_Effect_DogzEquipPlusExp) + baseExp = 0 if not equipExpEff else equipExpEff.GetEffectValue(0) + plusExp = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 1) + dogzEquipPlusExp += (baseExp + plusExp) + GameWorld.DebugLog(" 神兽合成材料: index=%s,itemID=%s,baseExp=%s,plusExp=%s" % (index, itemID, baseExp, plusExp)) + if unfixedItemTotalCount < needUnfixedItemCount: GameWorld.Log("不固定消耗道具不足,无法合成!ID=%s,unfixedItemIDList=%s,needUnfixedItemCount=%s > unfixedItemTotalCount=%s" % (compoundID, unfixedItemIDList, needUnfixedItemCount, unfixedItemTotalCount), playerID) return - return unfixedItemCostList, wingItemExpInfo + return unfixedItemCostList, wingItemExpInfo, dogzEquipPlusExp, expireTime def __CheckFixedItem(playerID, compoundID, itemPack, fixedItemIndexList, fixedItemIDList, fixedItemCountList, compoundCnt): @@ -243,6 +360,7 @@ % (fixedItemIDList, fixedItemCountList), playerID) return + expireTime = 0 for index in fixedItemIndexList: if index >= maxPackCount: GameWorld.Log("该物品格子索引不存在!无法合成!index=%s,maxPackCount=%s" % (index, maxPackCount), playerID) @@ -257,6 +375,13 @@ % (compoundID, index, fixedItemID, fixedItemIDList), playerID) return + isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem) + if isExpireItem: + if not remainingTime: + GameWorld.Log("固定消耗道具时效物品已失效,无法合成! index=%s,fixedItemID=%s" % (index, fixedItemID), playerID) + return + expireTime = remainingTime if not expireTime else min(expireTime, remainingTime) + isBind = curItem.GetIsBind() itemCount = curItem.GetCount() bindIndex = 0 if isBind else 1 @@ -340,7 +465,7 @@ return GameWorld.DebugLog("最终消耗材料个数: %s" % (fixedItemNeedCntDict)) - return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt + return fixedItemIndexDict, fixedItemNeedCntDict, compoundBindCnt, expireTime def __CheckAddonsItem(playerID, compoundID, itemPack, addonsItemIndexList, addonsItemCountList, addonsCountMax): @@ -350,6 +475,7 @@ # ComposeAddonsQuality 4|2 0 0 0 0 阶数和颜色 # ComposeAddonsFormula level*10 0 0 0 0 计算合成时附加材料增加的几率公式 + addSuccRateItemInfo = [] composeAddonsTypeList = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsType") classLV, color = IpyGameDataPY.GetFuncEvalCfg("ComposeAddonsQuality", 1) ComposeAddonsFormula = IpyGameDataPY.GetFuncCfg("ComposeAddonsFormula") @@ -360,6 +486,7 @@ % (addonsItemIndexList, addonsItemCountList), playerID) return + expireTime = 0 useCount = 0 addTotalSuccRate = 0 for i, index in enumerate(addonsItemIndexList): @@ -399,11 +526,56 @@ GameWorld.Log("附加物品总个数超出限制,无法合成! useCount=%s > addonsCountMax=%s" % (useCount, addonsCountMax), playerID) return + isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem) + if isExpireItem: + if not remainingTime: + GameWorld.Log("附加材料时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID) + return + expireTime = remainingTime if not expireTime else min(expireTime, remainingTime) + addSuccRate = eval(FormulaControl.GetCompileFormula("ComposeAddonsFormula", ComposeAddonsFormula)) addTotalSuccRate += (addSuccRate*costCount) + addSuccRateItemInfo.append({"ItemID":itemID, "ItemColor":itemColor, "ItemClassLV":itemClassLV, "addSuccRate":addSuccRate, "costCount":costCount}) - return int(addTotalSuccRate) + return int(addTotalSuccRate), addSuccRateItemInfo, expireTime +def __CheckIncRateItem(playerID, compoundID, itemPack, incRateItemIndexList, incRateItemID, needIncRateItemCount): + ## 检查提升概率道具, 只要客户端提交的数据有不符合要求的,则直接返回 None + expireTime = 0 + incRateItemTotalCount = 0 + incRateItemCostList = [[], []] # [[绑定索引], [非绑定索引]] + maxPackCount = itemPack.GetCount() + for index in incRateItemIndexList: + if index >= maxPackCount: + GameWorld.Log("该物品格子索引不存在!无法合成!index=%s,maxPackCount=%s" % (index, maxPackCount), playerID) + return + curItem = itemPack.GetAt(index) + if not __CheckItemCanUseCompound(playerID, index, curItem): + GameWorld.Log("该物品不可使用!无法合成! ID=%s,index=%s" % (compoundID, index), playerID) + return + itemID = curItem.GetItemTypeID() + if itemID != incRateItemID: + GameWorld.Log("该物品不可用于提升合成目标物品概率!ID=%s,index=%s,itemID=%s != incRateItemID=%s" + % (compoundID, index, itemID, incRateItemID), playerID) + return + isExpireItem, remainingTime = ItemCommon.GetItemRemainingTime(curItem) + if isExpireItem: + if not remainingTime: + GameWorld.Log("提升概率时效物品已失效,无法合成! index=%s,itemID=%s" % (index, itemID), playerID) + return + expireTime = remainingTime if not expireTime else min(expireTime, remainingTime) + + isBind = curItem.GetIsBind() + itemCount = curItem.GetCount() + incRateItemTotalCount += itemCount + incRateItemCostList[0].append(index) if isBind else incRateItemCostList[1].append(index) + + if incRateItemTotalCount < needIncRateItemCount: + GameWorld.Log("提升概率消耗道具不足,无法合成!ID=%s,incRateItemID=%s,needIncRateItemCount=%s > incRateItemTotalCount=%s" + % (compoundID, incRateItemID, needIncRateItemCount, incRateItemTotalCount), playerID) + return + + return incRateItemCostList, expireTime def __CheckItemCanUseCompound(playerID, index, curItem): if not ItemCommon.CheckItemCanUse(curItem): @@ -429,32 +601,21 @@ # @param newItem: 新物品 # @param itemCount: 合成数量 # @return None -def GiveNewCompoundItem(curPlayer, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, msgMark): +def GiveNewCompoundItem(curPlayer, newItemID, itemCount, compoundBindCnt, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime): compoundUnBindCnt = itemCount - compoundBindCnt if compoundBindCnt > 0: - userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundBindCnt, True, wingItemExpInfo) + userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundBindCnt, True, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime) if compoundUnBindCnt > 0: - userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundUnBindCnt, False, wingItemExpInfo) + userData = __GivePlayerCompoundItem(curPlayer, newItemID, compoundUnBindCnt, False, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, itemExpireTime) - if userData == None: - return - - if msgMark not in ['0', '', '-']: - PlayerControl.WorldNotify(0, msgMark, [curPlayer.GetName(), newItemID, userData]) - - # 您获得了物品XX XX个 - #PlayerControl.NotifyCode(curPlayer, "ObtainRes01", [newItemID, itemCount]) - # 通知放入特效 - #curPlayer.Sync_GetItemView(newItemID, itemCount) - # 通知合成成功 - ItemCommon.SyncMakeItemAnswer(curPlayer, ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Sucess, newItemID) - #curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitItemCompound, ChConfig.Def_ComposeState_Sucess) - return True + if not userData: + return "" + return userData -def __GivePlayerCompoundItem(curPlayer, newItemID, itemCount, isBind, wingItemExpInfo): +def __GivePlayerCompoundItem(curPlayer, newItemID, itemCount, isBind, wingItemExpInfo, dogzEquipPlusExp, decompoundItemInfo, expireTime): playerID = curPlayer.GetPlayerID() - curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, isBind) + curSingleItem = ItemControler.GetOutPutItemObj(newItemID, itemCount, isBind, expireTime) if not curSingleItem: GameWorld.ErrLog("创造物品失败, give item itemid:%s,count:%s" % (newItemID, itemCount), playerID) return @@ -475,6 +636,22 @@ if wingFinalExp:#继承翅膀精炼值 PlayerWing.WingProgressUP(curSingleItem, wingFinalExp, materialItemDict) + if dogzEquipPlusExp:#继承神兽装备熟练度 + dogzEquipLV, dogzEquipExp = PlayerDogz.GetDogzEquipPlusLVExpInfo(curSingleItem.GetItemColor(), curSingleItem.GetEquipPlace(), dogzEquipPlusExp) + curSingleItem.AddUserAttr(ShareDefine.Def_IudetDogzEquipPlus, dogzEquipLV) + curSingleItem.AddUserAttr(ShareDefine.Def_IudetDogzEquipPlus, dogzEquipExp) + remainExp = max(0, dogzEquipPlusExp - dogzEquipExp) + GameWorld.DebugLog("合成神兽装备成功, dogzEquipLV=%s,dogzEquipExp=%s,remainExp=%s,总EXP=%s" + % (dogzEquipLV, dogzEquipExp, remainExp, dogzEquipPlusExp), playerID) + __SendDogzEquipRemainExpMail(playerID, remainExp, True) + + # 保留合成材料消耗,拆解时用 + if decompoundItemInfo: + curSingleItem.ClearUserAttr(ShareDefine.Def_IudetItemDecompound) + for decompoundValue in decompoundItemInfo: + curSingleItem.AddUserAttr(ShareDefine.Def_IudetItemDecompound, decompoundValue) + GameWorld.Log("保存可拆解装备拆解物品信息: %s" % decompoundItemInfo, playerID) + userData = curSingleItem.GetUserData() if not ItemControler.PlayerItemControler(curPlayer).PutInItem(IPY_GameWorld.rptItem, curSingleItem, event=[ChConfig.ItemGive_ItemCompound, False, {}]): @@ -484,3 +661,97 @@ return userData +def __SendDogzEquipRemainExpMail(playerID, remainExp, isSucc): + if not remainExp: + return + + expItemID = IpyGameDataPY.GetFuncCfg("DogzAssist", 5) + itemData = GameWorld.GetGameData().GetItemByTypeID(expItemID) + if not itemData: + return + + effect = ItemCommon.GetItemEffectByEffectID(itemData, ChConfig.Def_Effect_DogzEquipPlusExp) + if not effect: + GameWorld.ErrLog("神兽装备合成返回熟练度物品ID错误! expItemID=%s,remainExp=%s" % (expItemID, remainExp), playerID) + return + baseExp = effect.GetEffectValue(0) + if not baseExp: + GameWorld.ErrLog("神兽装备合成返回熟练度物品ID错误! expItemID=%s,baseExp=%s,remainExp=%s" + % (expItemID, baseExp, remainExp), playerID) + return + + giveItemCount = int(remainExp/baseExp) + if giveItemCount <= 0: + return + + mailTypeKey = "DogzComposeSuc" if isSucc else "DogzComposeLose" + GameWorld.DebugLog("合成神兽装备, 返还强化熟练度=%s,baseExp=%s,expItemID=%s,giveItemCount=%s" + % (remainExp, baseExp, expItemID, giveItemCount), playerID) + + isBind = 1 + PlayerControl.SendMailByKey(mailTypeKey, [playerID], [[expItemID, giveItemCount, isBind]]) + return + +#// A3 13 物品拆解 #tagCMItemDecompound +# +#struct tagCMItemDecompound +#{ +# tagHead Head; +# BYTE Index; // 拆解物品所在背包索引 +#}; +def OnItemDecompound(index, clientData, tick): + curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) + playerID = curPlayer.GetPlayerID() + + decompoundItemIndex = clientData.Index + GameWorld.DebugLog("玩家拆解物品: decompoundItemIndex=%s" % decompoundItemIndex, playerID) + + itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) + if decompoundItemIndex < 0 or decompoundItemIndex >= itemPack.GetCount(): + return + curEquip = itemPack.GetAt(decompoundItemIndex) + + if not ItemCommon.CheckItemCanUse(curEquip): + return + + attrCount = curEquip.GetUserAttrCount(ShareDefine.Def_IudetItemDecompound) + if not attrCount: + GameWorld.DebugLog(" 该物品没有记录拆解物品信息,无法拆解!", playerID) + return + + giveItemList = [] + giveEquipID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, 0) + if giveEquipID: + giveItemList.append([giveEquipID, 1, curEquip.GetIsBind()]) + + if attrCount > 1: + for i in range(1, attrCount)[::3]: + if i + 3 > attrCount: + break + itemID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i) + itemCount = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i + 1) + isBind = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetItemDecompound, i + 2) + giveItemList.append([itemID, itemCount, isBind]) + + needSpace = len(giveItemList) + emptySpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace) + #验证背包空间 + if needSpace > emptySpace: + PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580") + return + + decompoundItemNoteDict = ItemCommon.GetItemNoteDict(curEquip, curEquip.GetCount()) + + # 删除拆解的物品 + saveDataDict = {"giveItemList":giveItemList} + ItemCommon.DelItem(curPlayer, curEquip, curEquip.GetCount(), False, "ItemDecompound", saveDataDict, isForceDR=True) + + # 返还物品 + for itemID, itemCount, isBind in giveItemList: + ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem], + event=["ItemDecompound", True, {"decompoundItemNoteDict":decompoundItemNoteDict}]) + + GameWorld.Log("拆解物品成功: decompoundItemNoteDict=%s" % str(decompoundItemNoteDict), playerID) + GameWorld.Log(" giveItemList=%s" % str(giveItemList), playerID) + return + -- Gitblit v1.8.0