From 1cf37b4b51fc287ca3e443afb72604ec88f72cc4 Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期三, 09 七月 2025 19:33:55 +0800 Subject: [PATCH] 0312 玩家物品支持DWORD数量 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py | 42 +++++++++++++++++++++++++++++++++--------- 1 files changed, 33 insertions(+), 9 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py index 090cf01..73211db 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorld.py @@ -507,6 +507,8 @@ # @return 返回值. 是否通过检查 # @remarks 概率相关, 这个事件是否能够出现 def CanHappen(rate, maxRate=ShareDefine.Def_MaxRateValue): + if rate <= 0: + return 0 if random.randint(0, maxRate -1) < rate: return 1 @@ -608,8 +610,6 @@ if not curPlayer or curPlayer.GetID() == 0 or curPlayer.IsEmpty(): return False #if not curPlayer.GetInitOK(): - # return False - #if IsTJGPlayer(curPlayer): # return False if IsMirrorPlayer(curPlayer): return False @@ -1162,9 +1162,6 @@ if npcObj == IPY_GameWorld.gnotSummon: return GetNPCManager().FindSummonNPCByID(curTagNPC.GetID()) - elif npcObj == IPY_GameWorld.gnotTruck: - return GetNPCManager().FindTruckByID(curTagNPC.GetID()) - elif npcObj == IPY_GameWorld.gnotPet: return GetNPCManager().FindPetByID(curTagNPC.GetID()) @@ -1320,10 +1317,6 @@ ## 服务器组ID,必须唯一,代表这台物理服务器 return ToIntDef(ReadChConfig.GetPyMongoConfig("platform", "GroupID"), 0) -def GetServerID(): - ## 当前服务器ID - return 87 - def GetMainServerID(serverID): ## 获取服务器ID所属主服ID ServerIDMainServerDict = IpyGameDataPY.GetConfigEx("ServerIDMainServerDict") @@ -1364,6 +1357,8 @@ # @return def GetPlatform(): return ReadChConfig.GetPyMongoConfig("platform", "PlatformName") + +def IsTestPlatform(platform): return platform in ["test", "yun"] #=============================================================================== # ##获得当前服务器ID @@ -1410,6 +1405,9 @@ return mainServerID return 0 +def GetDBPlayerAccIDByID(playerID): + ## 获取玩家表账号ID - 根据玩家ID, 可用于判断是否本服玩家 + return PyGameData.g_dbPlayerIDMap.get(playerID, "") #=============================================================================== # 平台ID = appid @@ -2107,6 +2105,32 @@ numValue += pow(10, dataIndex)*(dataValue - lastTagLV) return numValue +def GetValue(dataValue, fromRight, bits): + '''获取某个数值中,从右往左数第x位开始,截图n位得到的数据 + @param dataValue: 原始数值 + @param fromRight: 从右往左数第x位开始,从1开始 + @param bits: 截取n位 + @return: 数值value + ''' + lPow = pow(10, fromRight) + rPow = pow(10, fromRight - bits) + curValue = dataValue % lPow / rPow + return curValue + +def SetValue(dataValue, fromRight, bits, updValue): + '''修改某个数值,从右往左数第x位开始,截图n位得到的数据,替换为具体数值 + @param dataValue: 原始数值 + @param fromRight: 从右往左数第x位开始,从1开始 + @param bits: 截取n位 + @param updValue: 替换值 + @return: 修改后的value值 + ''' + lPow = pow(10, fromRight) + rPow = pow(10, fromRight - bits) + leftValue = dataValue / lPow * lPow + rightValue = dataValue % rPow + return leftValue + updValue * rPow + rightValue + def GetBitValue(dataValue, index): """ 得到某个字节值中某一位(Bit)的值 @param dataValue: 待取值的字节值 -- Gitblit v1.8.0