From fbe9c6468d6e290562ef6ae0028f7829e1dda91d Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期日, 28 四月 2024 12:15:45 +0800
Subject: [PATCH] 10033 【后端】仙树升级系统及砍树产出规则(增加使用仙树升级减时道具,支持自动购买;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini | 6 +
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py | 56 ++++++++++++++++++
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py | 56 ++++++++++++++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/MakeItemCount.py | 2
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py | 53 +++++++++++++++++
5 files changed, 171 insertions(+), 2 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
index c8826b9..57a4778 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetPack.py
@@ -19428,6 +19428,62 @@
#------------------------------------------------------
+# B2 24 使用仙树升级减时物品 #tagCMUseTreeLVUPTimeItem
+
+class tagCMUseTreeLVUPTimeItem(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ("Cmd", c_ubyte),
+ ("SubCmd", c_ubyte),
+ ("UseCount", c_int), # 使用个数
+ ("IsAutoBuy", c_ubyte), # 不足个数是否自动购买
+ ]
+
+ def __init__(self):
+ self.Clear()
+ self.Cmd = 0xB2
+ self.SubCmd = 0x24
+ return
+
+ def ReadData(self, stringData, _pos=0, _len=0):
+ self.Clear()
+ memmove(addressof(self), stringData[_pos:], self.GetLength())
+ return _pos + self.GetLength()
+
+ def Clear(self):
+ self.Cmd = 0xB2
+ self.SubCmd = 0x24
+ self.UseCount = 0
+ self.IsAutoBuy = 0
+ return
+
+ def GetLength(self):
+ return sizeof(tagCMUseTreeLVUPTimeItem)
+
+ def GetBuffer(self):
+ return string_at(addressof(self), self.GetLength())
+
+ def OutputString(self):
+ DumpString = '''// B2 24 使用仙树升级减时物品 //tagCMUseTreeLVUPTimeItem:
+ Cmd:%s,
+ SubCmd:%s,
+ UseCount:%d,
+ IsAutoBuy:%d
+ '''\
+ %(
+ self.Cmd,
+ self.SubCmd,
+ self.UseCount,
+ self.IsAutoBuy
+ )
+ return DumpString
+
+
+m_NAtagCMUseTreeLVUPTimeItem=tagCMUseTreeLVUPTimeItem()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMUseTreeLVUPTimeItem.Cmd,m_NAtagCMUseTreeLVUPTimeItem.SubCmd))] = m_NAtagCMUseTreeLVUPTimeItem
+
+
+#------------------------------------------------------
# B3 17 情戒解锁 #tagCMLoveRingUnlock
class tagCMLoveRingUnlock(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
index 7df6828..1348bb2 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/PyNetPack.ini
@@ -1879,7 +1879,7 @@
Writer = hxp
Releaser = hxp
RegType = 0
-RegisterPackCount = 3
+RegisterPackCount = 4
PacketCMD_1=0xB2
PacketSubCMD_1=0x21
@@ -1893,6 +1893,10 @@
PacketSubCMD_3=0x23
PacketCallFunc_3=OnTreeLVUP
+PacketCMD_4=0xB2
+PacketSubCMD_4=0x24
+PacketCallFunc_4=OnUseTreeLVUPTimeItem
+
;福地
[PlayerMineArea]
ScriptName = Player\PlayerMineArea.py
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
index c8826b9..57a4778 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetPack.py
@@ -19428,6 +19428,62 @@
#------------------------------------------------------
+# B2 24 使用仙树升级减时物品 #tagCMUseTreeLVUPTimeItem
+
+class tagCMUseTreeLVUPTimeItem(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ("Cmd", c_ubyte),
+ ("SubCmd", c_ubyte),
+ ("UseCount", c_int), # 使用个数
+ ("IsAutoBuy", c_ubyte), # 不足个数是否自动购买
+ ]
+
+ def __init__(self):
+ self.Clear()
+ self.Cmd = 0xB2
+ self.SubCmd = 0x24
+ return
+
+ def ReadData(self, stringData, _pos=0, _len=0):
+ self.Clear()
+ memmove(addressof(self), stringData[_pos:], self.GetLength())
+ return _pos + self.GetLength()
+
+ def Clear(self):
+ self.Cmd = 0xB2
+ self.SubCmd = 0x24
+ self.UseCount = 0
+ self.IsAutoBuy = 0
+ return
+
+ def GetLength(self):
+ return sizeof(tagCMUseTreeLVUPTimeItem)
+
+ def GetBuffer(self):
+ return string_at(addressof(self), self.GetLength())
+
+ def OutputString(self):
+ DumpString = '''// B2 24 使用仙树升级减时物品 //tagCMUseTreeLVUPTimeItem:
+ Cmd:%s,
+ SubCmd:%s,
+ UseCount:%d,
+ IsAutoBuy:%d
+ '''\
+ %(
+ self.Cmd,
+ self.SubCmd,
+ self.UseCount,
+ self.IsAutoBuy
+ )
+ return DumpString
+
+
+m_NAtagCMUseTreeLVUPTimeItem=tagCMUseTreeLVUPTimeItem()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagCMUseTreeLVUPTimeItem.Cmd,m_NAtagCMUseTreeLVUPTimeItem.SubCmd))] = m_NAtagCMUseTreeLVUPTimeItem
+
+
+#------------------------------------------------------
# B3 17 情戒解锁 #tagCMLoveRingUnlock
class tagCMLoveRingUnlock(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/MakeItemCount.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/MakeItemCount.py
index 21ddd5a..4f600f4 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/MakeItemCount.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/MakeItemCount.py
@@ -49,7 +49,7 @@
GameWorld.DebugAnswer(curPlayer, "放入物品失败!")
return
- setAttrDict = {ShareDefine.Def_CItemKey_AppointID:appointID}
+ setAttrDict = {ShareDefine.Def_CItemKey_AppointID:appointID} if appointID else {}
# 拍品
if auctionGroup > 0:
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py
index 064e51e..9cdf7b6 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerCutTree.py
@@ -293,6 +293,59 @@
SyncTreeInfo(curPlayer)
return
+#// B2 24 使用仙树升级减时物品 #tagCMUseTreeLVUPTimeItem
+#
+#struct tagCMUseTreeLVUPTimeItem
+#{
+# tagHead Head;
+# DWORD UseCount; // 使用个数
+# BYTE IsAutoBuy; // 不足个数是否自动购买
+#};
+def OnUseTreeLVUPTimeItem(index, clientData, tick):
+ curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+ useCount = clientData.UseCount
+ isAutoBuy = clientData.IsAutoBuy
+
+ playerID = curPlayer.GetPlayerID()
+ lvupState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreeLVUPState)
+ LVUPRemainTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreeLVUPRemainTime)
+ if not lvupState or not LVUPRemainTime:
+ GameWorld.DebugLog("仙树非升级中或剩余时间为0,不需要减少时间! lvupState=%s,LVUPRemainTime=%s"
+ % (lvupState, LVUPRemainTime), playerID)
+ return
+
+ costItemID, reduceSeconds = IpyGameDataPY.GetFuncEvalCfg("TreeLVUP", 2)
+ GameWorld.DebugLog("使用仙树升级减时物品! costItemID=%s,reduceSeconds=%s,useCount=%s" % (costItemID, reduceSeconds, useCount), playerID)
+ if not costItemID or not useCount:
+ return
+
+ costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, useCount)
+ lackCnt = useCount - bindCnt - unBindCnt
+ if lackCnt > 0 and not isAutoBuy:
+ GameWorld.DebugLog("消耗道具不足! costItemID=%s,useCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s"
+ % (costItemID, useCount, bindCnt, unBindCnt, lackCnt), playerID)
+ return
+
+ delCnt = useCount
+ if lackCnt > 0:
+ moneyType = IPY_GameWorld.TYPE_Price_Gold_Money
+ lackCost = ItemCommon.GetAutoBuyItemNeedGold({costItemID:lackCnt})
+ if lackCost <= 0:
+ return
+ GameWorld.DebugLog("自动购买道具: lackCnt=%s,moneyType=%s,lackCost=%s" % (lackCnt, moneyType, lackCost), playerID)
+ infoDict = {ChConfig.Def_Cost_Reason_SonKey:costItemID}
+ if not PlayerControl.PayMoney(curPlayer, moneyType, lackCost, ChConfig.Def_Cost_BuyStoreItem, infoDict):
+ return
+ delCnt -= lackCnt
+
+ # 扣除消耗
+ if delCnt:
+ ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, "TreeLVUPTimeItem")
+
+ reduceTime = reduceSeconds * useCount
+ ReduceTreeLVUPTime(curPlayer, reduceTime)
+ return
+
def RefreshTreeLVUPTime(curPlayer):
## 刷新仙树升级剩余时间
lvupState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreeLVUPState)
--
Gitblit v1.8.0