From f2fc5e799e2edfdbf87c37399033bddbb2f4f36f Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期五, 21 九月 2018 21:08:41 +0800 Subject: [PATCH] 3428 子 【开发】神兽技能 / 【后端】神兽技能 --- 修复报错 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py | 141 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 111 insertions(+), 30 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py index 8e6639b..d919299 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py @@ -25,6 +25,9 @@ import IpyGameDataPY import ChConfig import ChEquip +import PassiveBuffEffMng +import SkillCommon +import SkillShell ''' 神兽编号: 1~20,上线后不可修改 @@ -53,6 +56,9 @@ ## 设置神兽是否助战状态 GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_DogzFightState, dogzID - 1, 1 if isFight else 0) Sync_DogzHelpbattleState(curPlayer, dogzID, isFight) + + # 设置成功后才能刷技能 + PassiveBuffEffMng.PlayerDogzSkill(curPlayer) return @@ -125,6 +131,7 @@ # 助战状态换装需要刷属性 if GetDogzIsHelpFight(curPlayer, dogzID): RefreshDogzAttr(curPlayer) + PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return @@ -201,6 +208,7 @@ if GetDogzIsHelpFight(curPlayer, dogzID): SetDogzIsHelpFight(curPlayer, dogzID, False) # 因为脱下了状态,所以必须设置为非助战状态 RefreshDogzAttr(curPlayer) + PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return @@ -262,6 +270,7 @@ GameWorld.DebugLog("神兽助战状态变更!dogzID=%s,isFight=%s" % (dogzID, isFight), playerID) SetDogzIsHelpFight(curPlayer, dogzID, isFight) RefreshDogzAttr(curPlayer) + PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return @@ -311,6 +320,7 @@ # BYTE EquipIndex; //神兽装备背包中索引 # BYTE IndexCount; //材料所在神兽物品背包索引的数量 # BYTE IndexList[IndexCount]; //材料所在神兽物品背包索引列表 +# BYTE IndexUseCountList[IndexCount]; //材料所在神兽物品背包索引对应使用个数列表 # BYTE IsDouble; //是否双倍强化 #}; def OnDogzEquipPlus(index, clientData, tick): @@ -318,8 +328,14 @@ playerID = curPlayer.GetPlayerID() equipIndex = clientData.EquipIndex indexList = clientData.IndexList + indexUseCountList = clientData.IndexUseCountList isDouble = clientData.IsDouble - GameWorld.DebugLog("神兽装备强化: equipIndex=%s,indexList=%s,isDouble=%s" % (equipIndex, indexList, isDouble), playerID) + GameWorld.DebugLog("神兽装备强化: equipIndex=%s,indexList=%s,indexUseCountList=%s,isDouble=%s" + % (equipIndex, indexList, indexUseCountList, isDouble), playerID) + + if len(indexList) != len(indexUseCountList): + GameWorld.DebugLog(" 指定消耗的个数数据长度错误!") + return dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip) curEquip = dogzEquipPack.GetAt(equipIndex) @@ -328,31 +344,33 @@ % (equipIndex, curEquip.GetItemTypeID()), playerID) return + equipColor = curEquip.GetItemColor() + colorPlusMaxLVDict = IpyGameDataPY.GetFuncEvalCfg("DogzAssist", 4) # {颜色:等级上限, ...} + if equipColor not in colorPlusMaxLVDict: + return + maxPlusLV = colorPlusMaxLVDict[equipColor] + equipPlace = curEquip.GetEquipPlace() curPlusLV = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 0) curPlusExpTotal = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 1) + if curPlusLV >= maxPlusLV: + GameWorld.Log("神兽装备已满级, 无法强化!equipColor=%s,curPlusLV=%s,maxPlusLV=%s" % (equipColor, curPlusLV, maxPlusLV), playerID) + return ipyData = IpyGameDataPY.GetIpyGameData("DogzEquipPlus", equipPlace, curPlusLV) if not ipyData: return - curLVUPTotalExp = ipyData.GetPlusLVUPTotalExp() - if not curLVUPTotalExp: + lvUPTotalExp = ipyData.GetPlusLVUPTotalExp() + if not lvUPTotalExp: GameWorld.Log("神兽装备升级所需总经验为0, 无法强化!equipPlace=%s,curPlusLV=%s" % (equipPlace, curPlusLV), playerID) return - - nextLVIpyData = None - if curPlusExpTotal >= curLVUPTotalExp: - nextLVIpyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, curPlusLV + 1) - if not nextLVIpyData: - GameWorld.Log("神兽装备已满级, 无法强化!equipPlace=%s,curPlusLV=%s" % (equipPlace, curPlusLV), playerID) - return costGoldTotal = 0 addExpTotal = 0 delItemList = [] dogzItemPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzItem) dogzItemPackCount = dogzItemPack.GetCount() - for i in indexList: + for listIndex, i in enumerate(indexList): if i < 0 or i >= dogzItemPackCount: GameWorld.ErrLog("神兽背包索引不存在,无法强化!i=%s" % (i), playerID) return @@ -365,24 +383,25 @@ GameWorld.ErrLog("神兽背包物品无经验效果,无法强化!i=%s,itemID=%s" % (i, curItem.GetItemTypeID()), playerID) return + delCount = max(1, min(curItem.GetCount(), indexUseCountList[listIndex])) baseExp = effect.GetEffectValue(0) doubleCostGold = effect.GetEffectValue(1) - addExp = baseExp + addExp = baseExp * delCount plusInfoCount = curItem.GetUserAttrCount(ShareDefine.Def_IudetDogzEquipPlus) if not plusInfoCount: if isDouble and doubleCostGold: - addExp = (baseExp * 2) - costGoldTotal += doubleCostGold - GameWorld.DebugLog(" 强化: addExp=%s,baseExp=%s,isDouble=%s,doubleCostGold=%s,costGoldTotal=%s" - % (addExp, baseExp, isDouble, doubleCostGold, costGoldTotal), playerID) + addExp = (baseExp * 2 * delCount) + costGoldTotal += doubleCostGold * delCount + GameWorld.DebugLog(" 强化: addExp=%s,delCount=%s,baseExp=%s,isDouble=%s,doubleCostGold=%s,costGoldTotal=%s" + % (addExp, delCount, baseExp, isDouble, doubleCostGold, costGoldTotal), playerID) else: #plusLV = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 0) plusExpTotal = curItem.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 1) addExp += plusExpTotal - GameWorld.DebugLog(" 强化: addExp=%s,baseExp=%s,plusExpTotal=%s" % (addExp, baseExp, plusExpTotal), playerID) + GameWorld.DebugLog(" 强化: addExp=%s,delCount=%s,baseExp=%s,plusExpTotal=%s" % (addExp, delCount, baseExp, plusExpTotal), playerID) addExpTotal += addExp - delItemList.append(curItem) + delItemList.append([curItem, delCount]) if not delItemList: GameWorld.DebugLog(" 没有材料可强化!", playerID) @@ -396,20 +415,23 @@ ChConfig.Def_Cost_DogzEquipPlus, infoDict): return - for delItem in delItemList: - ItemCommon.DelItem(curPlayer, delItem, curItem.GetCount(), False, ChConfig.ItemDel_DogzEquipPlus, infoDict) + for delItem, delCount in delItemList: + ItemCommon.DelItem(curPlayer, delItem, delCount, False, ChConfig.ItemDel_DogzEquipPlus, infoDict) updPlusLV = curPlusLV - if updPlusExpTotal >= curLVUPTotalExp: - doCount = 0 - while nextLVIpyData and updPlusExpTotal >= nextLVIpyData.GetPlusLVUPTotalExp() and doCount < 100: - doCount += 1 - nextLV = updPlusLV + 1 - nextLVIpyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, nextLV) - if not nextLVIpyData: - break - updPlusLV = nextLV - + doCount, maxDoCount = 0, maxPlusLV * 2 + while updPlusExpTotal >= lvUPTotalExp and updPlusLV < maxPlusLV and doCount < maxDoCount: + doCount += 1 + nextLV = updPlusLV + 1 + nextLVIpyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, nextLV) + if not nextLVIpyData: + GameWorld.DebugLog(" 没有下一级数据,不能升级!nextLV=%s" % (nextLV), playerID) + break + updPlusLV = nextLV + lvUPTotalExp = nextLVIpyData.GetPlusLVUPTotalExp() + GameWorld.DebugLog(" 升级: equipPlace=%s,maxPlusLV=%s,updPlusLV=%s,updPlusExpTotal=%s,lvUPTotalExp=%s" + % (equipPlace, maxPlusLV, updPlusLV, updPlusExpTotal, lvUPTotalExp), playerID) + isRefreshAtrr = False # 未强化过 if not curPlusExpTotal: @@ -427,12 +449,37 @@ if isRefreshAtrr: RefreshDogzAttr(curPlayer) + PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() + curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitDogzEquipPlus, 1) return + +def GetDogzEquipPlusLVExpInfo(equipColor, equipPlace, totalExp): + ## 获取当前神兽装备最高强化等级的强化熟练度 + retLV, retExp = 0, 0 + colorPlusMaxLVDict = IpyGameDataPY.GetFuncEvalCfg("DogzAssist", 4) # {颜色:等级上限, ...} + if equipColor not in colorPlusMaxLVDict: + return retLV, retExp + maxPlusLV = colorPlusMaxLVDict[equipColor] + for lv in xrange(maxPlusLV + 1): + ipyData = IpyGameDataPY.GetIpyGameDataNotLog("DogzEquipPlus", equipPlace, lv) + if lv and not ipyData: + break + + lvUPTotalExp = ipyData.GetPlusLVUPTotalExp() + if not lvUPTotalExp: + break + + if totalExp < lvUPTotalExp: + return lv, totalExp + retLV, retExp = lv, lvUPTotalExp + + return retLV, retExp def RefreshDogzAttr(curPlayer): ## 刷新神兽属性 + fightPowerEx = 0 allAttrList = [{} for _ in range(4)] dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip) @@ -493,10 +540,44 @@ ChEquip.CalcAttr_LegendAttr(curPlayer, curEquip, allAttrList) #GameWorld.DebugLog(" 装备传奇: itemID=%s,%s" % (itemID, allAttrList)) + # 附加战力 + fightPowerEx += ipyData.GetFightPowerEx() + # 保存计算值 PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Dogz, allAttrList) + curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_Dogz, fightPowerEx) + + # 技能属性,从Def_CalcAttrFunc_Dogz获取 + skillAttrList = CalcDogzBattleSkillAttr(curPlayer) + PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_HorseSkill, skillAttrList) return +# 助战神兽技能属性,必须在 SetDogzIsHelpFight后调用 +def CalcDogzBattleSkillAttr(curPlayer): + skillAttrList = [{} for _ in range(4)] + skillManager = curPlayer.GetSkillManager() + + for i in range(0 , skillManager.GetSkillCount()): + curSkill = skillManager.GetSkillByIndex(i) + if not curSkill: + continue + + if curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_Dogz: + continue + + if not SkillCommon.isPassiveAttr(curSkill): + continue + + + for effectIndex in xrange(curSkill.GetEffectCount()): + curEffect = curSkill.GetEffect(effectIndex) + SkillShell.CalcBuffEffAttr(curPlayer, curEffect, skillAttrList) + + + #GameWorld.DebugLog("神兽技能属性: skillFPEx=%s, %s" % ( skillFPEx, skillAttrList)) + return skillAttrList + + def Sync_DogzInfo(curPlayer): ## 同步神兽信息 dogzInfoPack = ChPyNetSendPack.tagMCDogzInfo() -- Gitblit v1.8.0