From 7e061666ff94ee05d08028ab0e4ac41afd3d4419 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 07 十一月 2018 11:50:00 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/SnxxServerCode
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerDogz.py | 254 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 198 insertions(+), 56 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 3f9c581..79917ff 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,12 @@
import IpyGameDataPY
import ChConfig
import ChEquip
+import PassiveBuffEffMng
+import SkillCommon
+import SkillShell
+import PlayerSuccess
+
+import time
'''
神兽编号: 1~20,上线后不可修改
@@ -36,6 +42,8 @@
'''
DogzEquipCount = 5 # 神兽装备位数量,固定5个,策划说打死也不改
+
+g_helpBattleNotifyTimeDict = {} # 助战广播时间记录 {神兽ID:广播time, ...}
def GetDogzEquipPlaceIndex(equipPlace):
## 获取神兽装备位对应的索引
@@ -53,6 +61,9 @@
## 设置神兽是否助战状态
GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_DogzFightState, dogzID - 1, 1 if isFight else 0)
Sync_DogzHelpbattleState(curPlayer, dogzID, isFight)
+
+ # 设置成功后才能刷技能
+ PassiveBuffEffMng.PlayerDogzSkill(curPlayer)
return
@@ -76,56 +87,68 @@
#{
# tagHead Head;
# BYTE DogzID; // 神兽ID
-# BYTE EquipIndex; //神兽装备所在神兽背包索引
+# BYTE EquipIndexCount;
+# BYTE EquipIndexList[EquipIndexCount]; //神兽装备所在神兽背包索引列表
#};
def OnDogzEquipItem(index, clientData, tick):
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
playerID = curPlayer.GetPlayerID()
dogzID = clientData.DogzID
- equipIndex = clientData.EquipIndex
+ equipIndexList = clientData.EquipIndexList
ipyData = IpyGameDataPY.GetIpyGameData("Dogz", dogzID)
if not ipyData:
return
- dogzItemPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzItem)
- curEquip = dogzItemPack.GetAt(equipIndex)
- if not ItemCommon.CheckItemCanUse(curEquip):
- GameWorld.DebugLog("物品不可用: equipIndex=%s" % equipIndex)
- return
- if not ItemCommon.GetIsDogzEquip(curEquip):
- GameWorld.DebugLog("非神兽装备: equipIndex=%s" % equipIndex)
+ GameWorld.DebugLog("神兽穿戴装备: dogzID=%s,equipIndexList=%s" % (dogzID, equipIndexList), playerID)
+ if not equipIndexList:
return
- equipPlace = curEquip.GetEquipPlace()
- equipPlaceIndex = GetDogzEquipPlaceIndex(equipPlace)
- equipPlaceColorList = ipyData.GetEquipPlaceColorList()
- if equipPlaceIndex < 0 or equipPlaceIndex >= len(equipPlaceColorList):
- GameWorld.ErrLog("神兽装备位异常: equipPlace=%s,equipPlaceIndex=%s" % (equipPlace, equipPlaceIndex))
- return
+ succIndexList = []
+ for equipIndex in equipIndexList:
+ dogzItemPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzItem)
+ curEquip = dogzItemPack.GetAt(equipIndex)
+ if not ItemCommon.CheckItemCanUse(curEquip):
+ GameWorld.DebugLog("物品为空或不可用: equipIndex=%s" % equipIndex, playerID)
+ continue
+ if not ItemCommon.GetIsDogzEquip(curEquip):
+ GameWorld.DebugLog("非神兽装备: equipIndex=%s" % equipIndex, playerID)
+ continue
+
+ equipPlace = curEquip.GetEquipPlace()
+ equipPlaceIndex = GetDogzEquipPlaceIndex(equipPlace)
+ equipPlaceColorList = ipyData.GetEquipPlaceColorList()
+ if equipPlaceIndex < 0 or equipPlaceIndex >= len(equipPlaceColorList):
+ GameWorld.ErrLog("神兽装备位异常: equipIndex=%s,equipPlace=%s,equipPlaceIndex=%s"
+ % (equipIndex, equipPlace, equipPlaceIndex), playerID)
+ continue
+
+ dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
+ equipPackIndex = GetDogzEquipPackIndex(dogzID, equipPlaceIndex)
+ if equipPackIndex < 0 or equipPackIndex >= dogzEquipPack.GetCount():
+ GameWorld.ErrLog("神兽装备背包索引异常: dogzID=%s,equipIndex=%s,equipPlace=%s,equipPackIndex=%s"
+ % (dogzID, equipIndex, equipPlace, equipPackIndex), playerID)
+ continue
+
+ equipColor = curEquip.GetItemColor()
+ limitColor = equipPlaceColorList[equipPlaceIndex]
+ if equipColor < limitColor:
+ GameWorld.Log("神兽装备位穿戴颜色限制:dogzID=%s,equipIndex=%s,equipPlaceIndex=%s,limitColor=%s > equipColor=%s"
+ % (dogzID, equipIndex, equipPlaceIndex, limitColor, equipColor), playerID)
+ continue
+
+ destEquip = dogzEquipPack.GetAt(equipPackIndex)
+ if ItemCommon.DoLogicSwitchItem(curPlayer, curEquip, destEquip, ShareDefine.rptDogzEquip):
+ succIndexList.append(equipIndex)
- dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
- equipPackIndex = GetDogzEquipPackIndex(dogzID, equipPlaceIndex)
- if equipPackIndex < 0 or equipPackIndex >= dogzEquipPack.GetCount():
- GameWorld.ErrLog("神兽装备背包索引异常: dogzID=%s,equipPlace=%s,equipPackIndex=%s" % (dogzID, equipPlace, equipPackIndex))
- return
-
- equipColor = curEquip.GetItemColor()
- limitColor = equipPlaceColorList[equipPlaceIndex]
- if equipColor < limitColor:
- GameWorld.Log("神兽装备位穿戴颜色限制:dogzID=%s,equipPlaceIndex=%s,limitColor=%s > equipColor=%s"
- % (dogzID, equipPlaceIndex, limitColor, equipColor), playerID)
- return
-
- destEquip = dogzEquipPack.GetAt(equipPackIndex)
- isOK = ItemCommon.DoLogicSwitchItem(curPlayer, curEquip, destEquip, ShareDefine.rptDogzEquip)
- if not isOK:
+ GameWorld.DebugLog(" 穿戴成功索引列表: %s" % succIndexList, playerID)
+ if not succIndexList:
return
# 助战状态换装需要刷属性
if GetDogzIsHelpFight(curPlayer, dogzID):
- RefreshDogzAttr(curPlayer)
-
+ RefreshDogzAttr(curPlayer, True)
+ PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
return
@@ -200,7 +223,8 @@
# 助战状态换装需要刷属性
if GetDogzIsHelpFight(curPlayer, dogzID):
SetDogzIsHelpFight(curPlayer, dogzID, False) # 因为脱下了状态,所以必须设置为非助战状态
- RefreshDogzAttr(curPlayer)
+ RefreshDogzAttr(curPlayer, True)
+ PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
return
@@ -215,6 +239,8 @@
# BYTE BatteState; //助战状态,0-召回,1-助战
#};
def OnDogzBattleStateChange(index, clientData, tick):
+ global g_helpBattleNotifyTimeDict
+
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
playerID = curPlayer.GetPlayerID()
dogzID = clientData.DogzID
@@ -257,11 +283,22 @@
if curItem.IsEmpty():
GameWorld.DebugLog("神兽有装备未穿戴,无法助战!dogzID=%s,packIndex=%s" % (dogzID, i), playerID)
return
-
+ PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_DogzBattle, 1, [dogzID])
+
isFight = True if batteState else False
GameWorld.DebugLog("神兽助战状态变更!dogzID=%s,isFight=%s" % (dogzID, isFight), playerID)
SetDogzIsHelpFight(curPlayer, dogzID, isFight)
- RefreshDogzAttr(curPlayer)
+ RefreshDogzAttr(curPlayer, True)
+ PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+
+ if isFight and ipyData.GetHelpBattleNotify():
+ curTime = int(time.time())
+ playerName = curPlayer.GetPlayerName()
+ notifyKey, notifyParamList, notifyCD = ipyData.GetHelpBattleNotify()
+ lastNotifyTime = g_helpBattleNotifyTimeDict.get(dogzID, 0)
+ if curTime - lastNotifyTime >= notifyCD * 60:
+ PlayerControl.WorldNotify(0, notifyKey, [playerName] + notifyParamList)
+ g_helpBattleNotifyTimeDict[dogzID] = curTime
return
@@ -299,6 +336,7 @@
GameWorld.DebugLog("购买神兽助战位! updBuyCount=%s" % updBuyCount, playerID)
Sync_DogzInfo(curPlayer)
+ PlayerControl.WorldNotify(0, "DogzNumberUp", [curPlayer.GetPlayerName(), needItemID, curHelpFightCount + 1])
return
@@ -311,6 +349,7 @@
# BYTE EquipIndex; //神兽装备背包中索引
# BYTE IndexCount; //材料所在神兽物品背包索引的数量
# BYTE IndexList[IndexCount]; //材料所在神兽物品背包索引列表
+# BYTE IndexUseCountList[IndexCount]; //材料所在神兽物品背包索引对应使用个数列表
# BYTE IsDouble; //是否双倍强化
#};
def OnDogzEquipPlus(index, clientData, tick):
@@ -318,8 +357,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)
@@ -354,7 +399,7 @@
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
@@ -367,24 +412,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)
@@ -398,8 +444,8 @@
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
doCount, maxDoCount = 0, maxPlusLV * 2
@@ -431,8 +477,10 @@
% (curPlusLV, curPlusExpTotal, addExpTotal, updPlusLV, updPlusExpTotal), playerID)
if isRefreshAtrr:
- RefreshDogzAttr(curPlayer)
+ RefreshDogzAttr(curPlayer, True)
+ PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+ curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitDogzEquipPlus, 1)
return
def GetDogzEquipPlusLVExpInfo(equipColor, equipPlace, totalExp):
@@ -457,10 +505,14 @@
return retLV, retExp
-def RefreshDogzAttr(curPlayer):
+def RefreshDogzAttr(curPlayer, isUpdateSucc=False):
## 刷新神兽属性
-
+ totalPlusLv = 0 #出战神兽装备总强化等级
+ fightPowerEx = 0
allAttrList = [{} for _ in range(4)]
+ allAttrListEquip = [{} for _ in range(4)]
+ allAttrListEquipPlus = [{} for _ in range(4)]
+ equipScoreTotal = 0 #为解决装备评分、战力不一致的情况,装备战力改为由评分作为参数计算战力
dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
equipPackCount = dogzEquipPack.GetCount()
@@ -491,6 +543,8 @@
if curEquip.IsEmpty():
continue
+ equipScoreTotal += ItemCommon.GetEquipGearScore(curEquip)
+
#itemID = curEquip.GetItemTypeID()
# 装备基础属性
for effIndex in xrange(curEquip.GetEffectCount()):
@@ -501,11 +555,12 @@
if not effID or effID == ChConfig.Def_Effect_DogzEquipPlusExp:
continue
effValue = curEffect.GetEffectValue(0)
- PlayerControl.CalcAttrDict_Type(effID, effValue, allAttrList)
- #GameWorld.DebugLog(" 装备基础: itemID=%s,effID=%s,effValue=%s, %s" % (itemID, effID, effValue, allAttrList))
+ PlayerControl.CalcAttrDict_Type(effID, effValue, allAttrListEquip)
+ #GameWorld.DebugLog(" 装备基础: itemID=%s,effID=%s,effValue=%s, %s" % (itemID, effID, effValue, allAttrListEquip))
# 强化属性
curPlusLV = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 0)
+ totalPlusLv += curPlusLV
plusIpyData = IpyGameDataPY.GetIpyGameData("DogzEquipPlus", curEquip.GetEquipPlace(), curPlusLV)
if plusIpyData:
plusAttrTypeList = plusIpyData.GetPlusAttrTypes()
@@ -513,17 +568,104 @@
if plusAttrTypeList and len(plusAttrTypeList) == len(plusAttrValueList):
for plusIndex, plusAttrID in enumerate(plusAttrTypeList):
plusAttrValue = plusAttrValueList[plusIndex]
- PlayerControl.CalcAttrDict_Type(plusAttrID, plusAttrValue, allAttrList)
- #GameWorld.DebugLog(" 装备强化: itemID=%s,plusAttrID=%s, plusAttrValue=%s, %s" % (itemID, plusAttrID, plusAttrValue, allAttrList))
+ PlayerControl.CalcAttrDict_Type(plusAttrID, plusAttrValue, allAttrListEquipPlus)
+ #GameWorld.DebugLog(" 装备强化: itemID=%s,plusAttrID=%s, plusAttrValue=%s, %s" % (itemID, plusAttrID, plusAttrValue, allAttrListEquipPlus))
# 传奇属性
- ChEquip.CalcAttr_LegendAttr(curPlayer, curEquip, allAttrList)
- #GameWorld.DebugLog(" 装备传奇: itemID=%s,%s" % (itemID, allAttrList))
+ ChEquip.CalcAttr_LegendAttr(curPlayer, curEquip, allAttrListEquip)
+ #GameWorld.DebugLog(" 装备传奇: itemID=%s,%s" % (itemID, allAttrListEquip))
+ # 附加战力
+ fightPowerEx += ipyData.GetFightPowerEx()
+
# 保存计算值
PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Dogz, allAttrList)
+ PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_DogzEquip, allAttrListEquip)
+ PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_DogzEquipPlus, allAttrListEquipPlus)
+
+ #计算装备基础属性附加战力 (目前组成: 评分战力 + ...)
+ equipFightPowerEx = eval(IpyGameDataPY.GetFuncCompileCfg("FightpowerFormula", 2))
+ #GameWorld.DebugLog("神兽装备评分战力: equipScoreTotal=%s,equipFightPowerEx=%s" % (equipScoreTotal, equipFightPowerEx))
+ fightPowerEx += equipFightPowerEx
+ curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_Dogz, fightPowerEx)
+
+ # 技能属性,从Def_CalcAttrFunc_Dogz获取
+ skillAttrList = CalcDogzBattleSkillAttr(curPlayer)
+ PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_DogzBattleSkill, skillAttrList)
+ #成就
+ if isUpdateSucc:
+ PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_DogzEquipPlus)
+ PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_DogzEquipPlus, totalPlusLv)
return
+def GetFightDogzTotalPlusLv(curPlayer):
+ #出战的神兽装备总强化等级
+ totalPlusLv = 0
+ dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
+ equipPackCount = dogzEquipPack.GetCount()
+ ipyDataMgr = IpyGameDataPY.IPY_Data()
+ for dogzIndex in xrange(ipyDataMgr.GetDogzCount()):
+ if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_DogzFightState, dogzIndex):
+ continue
+ ipyData = ipyDataMgr.GetDogzByIndex(dogzIndex)
+ dogzID = ipyData.GetDogzID()
+ startIndex = (dogzID - 1) * DogzEquipCount
+ for equipIndex in range(startIndex, startIndex + DogzEquipCount):
+ if equipIndex < 0 or equipIndex >= equipPackCount:
+ break
+ curEquip = dogzEquipPack.GetAt(equipIndex)
+ if curEquip.IsEmpty():
+ continue
+ curPlusLV = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 0)
+ totalPlusLv += curPlusLV
+ return totalPlusLv
+
+# 助战神兽技能属性,必须在 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)
+
+ # Def_SkillType_AttrSkillNoLearn 非学习属性技能 叠加属性计算
+ ipyDataMgr = IpyGameDataPY.IPY_Data()
+ for i in xrange(ipyDataMgr.GetDogzCount()):
+ ipyData = ipyDataMgr.GetDogzByIndex(i)
+ if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_DogzFightState, i):
+ #未助战
+ continue
+
+ for skillID in ipyData.GetHelpBattleSkills():
+
+ skillData = GameWorld.GetGameData().GetSkillBySkillID(skillID)
+ if not skillData:
+ continue
+ # 同技能类型ID可多个叠加的属性时直接取表
+ if skillData.GetSkillType() != ChConfig.Def_SkillType_AttrSkillNoLearn:
+ continue
+
+ for effectIndex in xrange(skillData.GetEffectCount()):
+ curEffect = skillData.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