From b813aa21bc48546c8e5adead95ba4cb4e8e02148 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 14 十一月 2018 14:11:10 +0800
Subject: [PATCH] 4730 【后端】【1.3】神兵系统修改(激活方式修改、升级支持自动锤炼)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/ItemCommon.py | 5 ++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py | 12 +++++-
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py | 86 +++++++++++++++++++++++++++++++++++--------
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py | 12 +++++-
4 files changed, 94 insertions(+), 21 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
index 7d701e2..a462748 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -8910,6 +8910,8 @@
("SubCmd", c_ubyte),
("WeaponType", c_int), # 神兵类型
("ItemID", c_int), #消耗的物品ID
+ ("ItemCount", c_ubyte), #消耗个数,默认1
+ ("IsAutoBuy", c_ubyte), #是否自动购买,默认0
]
def __init__(self):
@@ -8928,6 +8930,8 @@
self.SubCmd = 0x55
self.WeaponType = 0
self.ItemID = 0
+ self.ItemCount = 0
+ self.IsAutoBuy = 0
return
def GetLength(self):
@@ -8941,13 +8945,17 @@
Cmd:%s,
SubCmd:%s,
WeaponType:%d,
- ItemID:%d
+ ItemID:%d,
+ ItemCount:%d,
+ IsAutoBuy:%d
'''\
%(
self.Cmd,
self.SubCmd,
self.WeaponType,
- self.ItemID
+ self.ItemID,
+ self.ItemCount,
+ self.IsAutoBuy
)
return DumpString
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
index 7d701e2..a462748 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -8910,6 +8910,8 @@
("SubCmd", c_ubyte),
("WeaponType", c_int), # 神兵类型
("ItemID", c_int), #消耗的物品ID
+ ("ItemCount", c_ubyte), #消耗个数,默认1
+ ("IsAutoBuy", c_ubyte), #是否自动购买,默认0
]
def __init__(self):
@@ -8928,6 +8930,8 @@
self.SubCmd = 0x55
self.WeaponType = 0
self.ItemID = 0
+ self.ItemCount = 0
+ self.IsAutoBuy = 0
return
def GetLength(self):
@@ -8941,13 +8945,17 @@
Cmd:%s,
SubCmd:%s,
WeaponType:%d,
- ItemID:%d
+ ItemID:%d,
+ ItemCount:%d,
+ IsAutoBuy:%d
'''\
%(
self.Cmd,
self.SubCmd,
self.WeaponType,
- self.ItemID
+ self.ItemID,
+ self.ItemCount,
+ self.IsAutoBuy
)
return DumpString
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/ItemCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/ItemCommon.py
index fb44051..2a711d8 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/ItemCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/ItemCommon.py
@@ -1337,8 +1337,9 @@
return hasEnough, itemIndexList, findItemIsBind, needCnt
-def GetPackItemBindStateIndexInfo(curPlayer, itemID):
+def GetPackItemBindStateIndexInfo(curPlayer, itemID, needCount=0):
''' 获取背包消耗道具绑定及未绑定索引情况
+ @param needCount: 所需个数, 默认绑定优先,当找到已经足够的个数后不再遍历,减少无用遍历
@return: 可消耗物品列表[[绑定物品索引], [不绑定物品索引]], 绑定个数, 未绑定个数
'''
consumeItemIndexList = [[], []] # 可消耗物品列表[[绑定物品索引], [不绑定物品索引]]
@@ -1359,6 +1360,8 @@
if curItem.GetIsBind():
consumeItemIndexList[0].append(i)
bindCnt += itemCount
+ if needCount > 0 and bindCnt >= needCount:
+ break
else:
consumeItemIndexList[1].append(i)
unBindCnt += itemCount
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py
index 7e0f89c..57f43a4 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGodWeapon.py
@@ -80,7 +80,11 @@
allAttrList = [{} for i in range(4)]
for gwType in xrange(1, maxType + 1):
+ # 因为神兵解锁条件做了调整,由之前的0~1阶解锁改为由前置神兵类型等级解锁,默认解锁后为1阶
+ # 为兼容老号,刷属性时只要判断等级是否大于0,不管是否解锁,新号解锁由神兵升级的时候进行解锁
attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % gwType)
+ if not attrLV:
+ continue
godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', gwType, attrLV)
if not godWeaponData:
continue
@@ -88,25 +92,30 @@
for i, attrID in enumerate(attrTypeList):
PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList)
+ GameWorld.DebugLog("神兵属性:%s" % allAttrList)
# 保存计算值
PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_GodWeapon, allAttrList)
return
#---------------------------------------------------------------------------------------------------
#===============================================================================
-# // A5 55 神兵升级 #tagCMGodWeaponPlus
-#
-# struct tagCMGodWeaponPlus
-# {
+#// A5 55 神兵升级 #tagCMGodWeaponPlus
+#
+#struct tagCMGodWeaponPlus
+#{
# tagHead Head;
# DWORD WeaponType; // 神兵类型
# DWORD ItemID; //消耗的物品ID
-# };
+# BYTE ItemCount; //消耗个数,默认1
+# BYTE IsAutoBuy; //是否自动购买,默认0
+#};
#===============================================================================
def OnPlusGodWeapon(index, clientData, tick):
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
weaponType = clientData.WeaponType
useItemID = clientData.ItemID
+ useItemCount = max(1, clientData.ItemCount)
+ isAutoBuy = clientData.IsAutoBuy
if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon):
#等级不足
@@ -114,6 +123,10 @@
#1.判断表中有没此类型,2.是否满级,3.判断是否有物品
attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % weaponType)
+ if not attrLV:
+ GameWorld.DebugLog("神兵未解锁,无法升级!weaponType=%s,attrLV=%s" % (weaponType, attrLV))
+ return
+
beforeAttrLV = attrLV # 用于提示
godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV)
if not godWeaponData:
@@ -129,12 +142,10 @@
if useItemID not in IpyGameDataPY.GetFuncEvalCfg("GodWeapon%s"%weaponType):
return
- curItem = ItemCommon.FindItemInPackByItemID(curPlayer, useItemID, IPY_GameWorld.rptItem)
- if not curItem:
- GameWorld.DebugLog('###神兵假包,没有物品ID=%s'%useItemID)
+ itemData = GameWorld.GetGameData().GetItemByTypeID(useItemID)
+ if not itemData:
return
-
- effect = ItemCommon.GetItemEffectByEffectID(curItem, ChConfig.Def_Item_Eff_GodWeaponExp)
+ effect = ItemCommon.GetItemEffectByEffectID(itemData, ChConfig.Def_Item_Eff_GodWeaponExp)
if not effect:
GameWorld.DebugLog('###神兵假包,物品ID=%s没有经验值'%useItemID)
return
@@ -143,16 +154,37 @@
GameWorld.DebugLog('###神兵假包,物品ID=%s没有经验值'%useItemID)
return
- delCnt = 1
- ItemCommon.DelItem(curPlayer, curItem, delCnt, False, ChConfig.ItemDel_GodWeapon)
-
- curExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % weaponType)
- curExp = curExp + addExp
+ costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, useItemID, useItemCount)
+ lackCount = max(0, useItemCount - (bindCnt + unBindCnt))
+ if lackCount > 0:
+ if not isAutoBuy:
+ GameWorld.DebugLog("神兵升级消耗不足!useItemID=%s,useItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCount=%s"
+ % (useItemID, useItemCount, bindCnt, unBindCnt, lackCount))
+ return
+ lackCost = ItemCommon.GetAutoBuyItemNeedGold({useItemID:lackCount})
+ if lackCost <= 0:
+ return
+
+ infoDict = {ChConfig.Def_Cost_Reason_SonKey:useItemID}
+ if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, lackCost,
+ ChConfig.Def_Cost_BuyStoreItem, infoDict, lackCount):
+ return
+
+ delUseItemCount = useItemCount - lackCount
+ # 扣除消耗
+ if delUseItemCount:
+ ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delUseItemCount, ChConfig.ItemDel_GodWeapon)
+
+ addTotalExp = addExp * useItemCount
+ befExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % weaponType)
+ curExp = befExp + addTotalExp
+ GameWorld.DebugLog("执行神兵升级: weaponType=%s,beforeAttrLV=%s,befExp=%s,addTotalExp=%s(%s*%s),curExp=%s"
+ % (weaponType, beforeAttrLV, befExp, addTotalExp, addExp, useItemCount, curExp))
isLVUP = False
# 安全为主不用while
- for i in xrange(100):
+ for _ in xrange(100):
if curExp < totalExp:
break
godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV+1)
@@ -160,6 +192,7 @@
GameWorld.DebugLog('神兵升级找不到数据 %s-%s'%(weaponType, attrLV))
break
+ GameWorld.DebugLog(" 神兵升级: attrLV=%s,needExp=%s" % (attrLV, totalExp))
curExp = curExp - totalExp
attrLV += 1
isLVUP = True
@@ -175,6 +208,7 @@
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponExp % weaponType, curExp)
if isLVUP:
+ GameWorld.DebugLog("神兵升级结果: attrLV=%s,curExp=%s" % (attrLV, curExp))
RefreshGodWeaponAttr(curPlayer)
#x神器达到X级成就
PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GodWeapon, attrLV, [weaponType])
@@ -190,6 +224,26 @@
if beforeAttrLV < notifyLV and attrLV >= notifyLV:
PlayerControl.WorldNotify(0, 'GodWeaponLv', [curPlayer.GetName(), weaponType, notifyLV])
+ #升级判断是否可解锁其他神兵
+ godWeaponUnlockDict = IpyGameDataPY.GetFuncEvalCfg("GodWeaponActive", 2, {})
+ for unlockGodWeaponType, unlockConditionList in godWeaponUnlockDict.items():
+ unlockGodWeaponType = int(unlockGodWeaponType)
+ if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % unlockGodWeaponType):
+ GameWorld.DebugLog("已经解锁的神兵不需要再判断!unlockGodWeaponType=%s" % unlockGodWeaponType)
+ continue
+ isUnlock = True
+ for needType, needLV in unlockConditionList:
+ needTypeLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % needType)
+ if needTypeLV < needLV:
+ isUnlock = False
+ GameWorld.DebugLog("所需前置神兵等级不足,无法解锁!unlockGodWeaponType=%s,needType=%s,needLV=%s > needTypeLV(%s)"
+ % (unlockGodWeaponType, needType, needLV, needTypeLV))
+ break
+ if isUnlock:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponLV % unlockGodWeaponType, 1)
+ GameWorld.DebugLog("解锁神兵: unlockGodWeaponType=%s" % unlockGodWeaponType)
+ Sync_GodWeaponLVInfo(curPlayer, unlockGodWeaponType)
+
Sync_GodWeaponLVInfo(curPlayer, weaponType)
#任务
EventShell.EventRespons_PlusGodWeapon(curPlayer)
--
Gitblit v1.8.0