From 111eed9d95db759319ef0be9731d06188f3a8e38 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 02 九月 2025 18:12:17 +0800
Subject: [PATCH] 129 【战斗】战斗系统-服务端(B413兼容发4可在非小怪战斗状态直接开始小怪战斗;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py | 454 ++++++++------------------------------------------------
1 files changed, 64 insertions(+), 390 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
index e9bb496..b82cb93 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerControl.py
@@ -14,14 +14,10 @@
#"""Version = 2017-07-17 15:00"""
#---------------------------------------------------------------------
import GameWorld
-import ChEquip
import SkillShell
import ChConfig
-import EffGetSet
import PlayerHorse
-import PlayerTeam
import SkillCommon
-import MirrorAttack
import GameMap
import FBLogic
import GameWorldProcess
@@ -37,42 +33,21 @@
import PlayerBillboard
import GameServerRefresh
import IPY_GameWorld
-import PlayerGameWallow
import ChPyNetSendPack
import NetPackCommon
import DataRecordPack
-import CalcNoLineEffect
-import CalcLineEffect
-import PlayerEquipDecompose
-import FormulaControl
-import PlayerDienstgrad
import PlayerPrestigeSys
-import OpenServerCampaign
-import PlayerGodWeapon
-import PlayerExpandPackCfgMgr
import PlayerActivity
import FBCommon
import PassiveBuffEffMng
import EventReport
-import PlayerGatherSoul
-import PlayerGatherTheSoul
import PlayerSuccess
-import PlayerPet
import ItemControler
import GameFuncComm
import IpyGameDataPY
-import PlayerRune
import PyGameData
-import PlayerMagicWeapon
import PlayerFeastTravel
import PlayerActTurntable
-import GameLogic_SealDemon
-import GameLogic_ZhuXianBoss
-import GameLogic_CrossDemonKing
-import PlayerVip
-import PlayerRefineStove
-import PlayerFamilyTech
-import PlayerFamilyZhenfa
import PlayerCostRebate
import PlayerActLunhuidian
import PlayerActGarbageSorting
@@ -80,24 +55,13 @@
import PlayerTongTianLing
import FunctionNPCCommon
import PlayerGoldInvest
-import IPY_PlayerDefine
import CrossRealmPlayer
import CrossPlayerData
-import NPCHurtManager
import ChNetSendPack
-import PlayerLianTi
-import PlayerCoat
-import PlayerAssist
import PlayerState
-import PlayerDogz
-import PlayerFaQi
-import PlayerLove
import PlayerGubao
-import PlayerShentong
import PlayerOnline
-import PlayerCharm
import PlayerTask
-import PlayerFace
import PlayerMail
import ChPlayer
import GameObj
@@ -605,7 +569,7 @@
# @return 返回值无意义
def ClearPyPlayerAction(curPlayer):
#清除py自定义状态
- PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_PyPlayerAction, 0)
+ NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_PyPlayerAction, 0)
return
#---------------------------------------------------------------------
@@ -777,21 +741,6 @@
curPlayer.Stand()
- return
-#---------------------------------------------------------------------
-##玩家播放表情
-# @param curPlayer 玩家实例
-# @return 返回值无意义
-# @remarks 玩家播放表情
-def DoPlayerShowPlayerFace(curPlayer, faceType):
- #清空玩家点击
- curPlayer.SetActionObj(None)
- #通知中断战斗对峙
- ExitPlayerConfronting(curPlayer)
- #通知停止移动
- curPlayer.StopMove()
- #通知客户端播放表情
- curPlayer.View_ShowPlayerFace(faceType)
return
#---------------------------------------------------------------------
@@ -1015,9 +964,6 @@
#刷新技能剩余时间
SkillCommon.RefreshAllSkillRemainTime(curPlayer, tick)
- #队伍玩家退出地图
- PlayerTeam.TeamPlayerLeaveMap(curPlayer, tick, isDisconnect)
-
#退出采集
NPCCommon.ClearCollectNPC(curPlayer)
@@ -1057,8 +1003,6 @@
CrossPlayerData.ClearCrossSyncDataCache(curPlayer)
PyGameData.g_fbBuyBuffTimeDict.pop(playerID, None)
#清除地图玩家缓存
- PyGameData.g_playerFuncAttrDict.pop(playerID, None)
- PyGameData.g_playerEquipPartAttrDict.pop(playerID, None)
PyGameData.g_playerReqEnterFBEx.pop(playerID, None)
NPCCommon.ClearPriWoodPile(curPlayer)
#移除地图缓存的境界难度玩家ID信息
@@ -1281,9 +1225,6 @@
NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FromFBLineID, lineID)
GameWorld.DebugLog("进入副本时,最后一次离开的可返回的副本ID更新!mapID=%s,lineID=%s,Pos(%s,%s)" % (mapID, lineID, posX, posY))
- # 离开地图
- PlayerAssist.OnPlayerLeaveMap(curPlayer)
-
# 从副本中切图
if GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull:
#默认回满血
@@ -1436,21 +1377,12 @@
if not FBLogic.OnEnterFBEvent(curPlayer, mapID, lineID, tick):
GameWorld.DebugLog(" OnEnterFBEvent False!", curPlayer.GetPlayerID())
- if mapID in [ChConfig.Def_FBMapID_CrossBattlefield]:
- NotifyCode(curPlayer, "GeRen_chenxin_268121")
- else:
- NotifyCode(curPlayer, "SingleEnterDefaul")
+ NotifyCode(curPlayer, "SingleEnterDefaul")
return
# 需要动态分布线路的地图,发送到跨服服务器进行分配
if mapID in ChConfig.Def_CrossDynamicLineMap:
extendInfo = {}
- if mapID == ChConfig.Def_FBMapID_CrossDemonKing:
- bossID = GameLogic_CrossDemonKing.GetCurFBLineBOSSID(mapID, lineID)
- if not bossID:
- return
- extendInfo["BossID"] = bossID
-
msgDict = {"PlayerID":curPlayer.GetPlayerID(), "MapID":mapID, "FuncLineID":lineID, "LV":curPlayer.GetLV()}
if extendInfo:
msgDict.update(extendInfo)
@@ -1485,10 +1417,6 @@
tick = GameWorld.GetGameWorld().GetTick()
if CheckMoveToFB(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, tick) != ShareDefine.EntFBAskRet_OK:
return
-# if mapID == ChConfig.Def_FBMapID_XMZZ:
-# #仙魔之争
-# GameLogic_XMZZ.XMZZStartFight(curPlayer)
-# return
if posX == 0 and posY == 0:
ipyEnterPosInfo = FBCommon.GetFBLineEnterPosInfo(mapID, lineID, fbLineIpyData)
retPos = FBLogic.OnGetFBEnterPos(curPlayer, mapID, lineID, ipyEnterPosInfo, tick)
@@ -1513,26 +1441,7 @@
if isSendToGameServer or mapID in ChConfig.Def_MapID_SendToGameServer \
or mapID in ReadChConfig.GetEvalChConfig("MapID_SendToGameServer"):
extendParamList = []
- if mapID == ChConfig.Def_FBMapID_SealDemon:
- newbielineList = IpyGameDataPY.GetFuncEvalCfg('SealDemonNewbieLine', 1)
- # 新手线路特殊处理,直接进入
- if lineID in newbielineList:
- GameWorld.DebugLog("封魔坛虚拟线路只能通过自定义场景进入挑战!")
- return
- else:
- bossID = GameLogic_SealDemon.CurFBLineBOSSID(lineID)
- extendParamList = [bossID]
- elif mapID == ChConfig.Def_FBMapID_ZhuXianBoss:
- bossID = GameLogic_ZhuXianBoss.CurFBLineBOSSID(lineID)
- extendParamList = [bossID, -1]
- enterCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_EnterFbCntDay % ChConfig.Def_FBMapID_ZhuXianBoss)
- if enterCnt >= FBCommon.GetEnterFBMaxCnt(curPlayer, ChConfig.Def_FBMapID_ZhuXianBoss):
- if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ZhuXianBossHelpCnt):
- extendParamList = [bossID, curPlayer.GetFamilyID()]
- elif mapID == ChConfig.Def_FBMapID_DemonKing:
- bossID = GameLogic_CrossDemonKing.GetCurFBLineBOSSID(mapID, lineID)
- extendParamList = [bossID]
- elif mapID in ChConfig.Def_MapID_LineIDToPropertyID:
+ if mapID in ChConfig.Def_MapID_LineIDToPropertyID:
enterCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_EnterFbCntDay % mapID)
extendParamList = [enterCnt]
elif mapID in ChConfig.MirrorBattleMapIDList:
@@ -1683,10 +1592,6 @@
# @return 无意义
# @remarks 刷新玩家时钟,切地图玩家时钟记录清空,处理相应逻辑
def RefreshPlayerTick(curPlayer):
- tick = GameWorld.GetGameWorld().GetTick()
-
- #防沉迷切线时间
- PlayerGameWallow.DoLogic_WallowOnlineTime(curPlayer, tick)
return
@@ -2651,7 +2556,7 @@
#---钱不够 返回假如果需要提示的话 提示信息---
if needMoneyCount < Price:
if needNotify and notifyCode:
- NotifyCode(curPlayer, notifyCode)
+ pass#NotifyCode(curPlayer, notifyCode)
GameWorld.DebugLog("货币不足: TYPE_Price=%s, Price=%s, curMoneyCount=%s" % (TYPE_Price, Price, needMoneyCount))
return False
@@ -2700,8 +2605,8 @@
gold = curPlayer.GetGold() # 元宝
if goldPaper + gold < Price: # 钱不够
- if needNotify:
- NotifyCode(curPlayer, "GoldErr")
+ #if needNotify:
+ # NotifyCode(curPlayer, "GoldErr")
return []
if goldPaper >= Price: # 只用礼券就够了
@@ -2836,11 +2741,11 @@
__PayMoneyAfter(curPlayer, type_Price, lostMoney, costType, infoDict, quantity, costVIPGold)
#通知客户端失去金钱
- if isNotify:
- if type_Price == ShareDefine.TYPE_Price_PayCoin:
- NotifyCode(curPlayer, "LostMoney", [type_Price, str(round(lostMoney/100.0, 2))])
- else:
- NotifyCode(curPlayer, "LostMoney", [type_Price, lostMoney])
+ #if isNotify:
+ # if type_Price == ShareDefine.TYPE_Price_PayCoin:
+ # NotifyCode(curPlayer, "LostMoney", [type_Price, str(round(lostMoney/100.0, 2))])
+ # else:
+ # NotifyCode(curPlayer, "LostMoney", [type_Price, lostMoney])
return True
## 付款以后后续操作
@@ -2881,11 +2786,29 @@
#轮回殿
PlayerActLunhuidian.AddLunhuidianValue(curPlayer, PlayerActLunhuidian.AwardType_PayMoney, type_Price, price)
if type_Price == ShareDefine.TYPE_Price_Xiantao:
+ # 累加未结算战锤 - 经验
unXiantaoCntExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntExp)
NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntExp, unXiantaoCntExp + price)
+ # 累加未结算战锤 - 装备
unXiantaoCntEquip = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntEquip)
NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntEquip, unXiantaoCntEquip + price)
+ # 累加未结算战锤 - 战利品
+ chapterID = GetMainLevelNowInfo(curPlayer)[0]
+ chapterIpyData = IpyGameDataPY.GetIpyGameData("MainChapter", chapterID)
+ if chapterIpyData:
+ DailyBootyUpperList = chapterIpyData.GetDailyBootyUpperList()
+ for itemID, upperCnt in DailyBootyUpperList:
+ if upperCnt <= 0:
+ continue
+ if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BootyDropToday % itemID) >= upperCnt:
+ continue
+ unXiantaoCntBooty = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_UnXiantaoCntBooty % itemID)
+ NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_UnXiantaoCntBooty % itemID, unXiantaoCntBooty + price)
+
PlayerPrestigeSys.AddRealmTaskValue(curPlayer, PlayerPrestigeSys.RealmTaskType_UseXiantao, price)
+ PlayerTask.AddTaskValue(curPlayer, ChConfig.TaskType_CutTree, price)
+
+
unitPrice = price if quantity == 1 else int(math.ceil(price * 1.0 / quantity)) # 单价
#reason_name = "Unknown" if not costType else costType
reason_name = costType
@@ -3120,12 +3043,12 @@
if priceType == ShareDefine.TYPE_Price_PayCoinDay:
priceType = ShareDefine.TYPE_Price_PayCoin
- if isSysHint and priceType != ShareDefine.TYPE_Price_BourseMoney:
- #通知客户端得到金钱
- if priceType == ShareDefine.TYPE_Price_PayCoin:
- NotifyCode(curPlayer, "GetMoney", [priceType, str(round(value/100.0, 2))])
- else:
- NotifyCode(curPlayer, "GetMoney", [priceType, value])
+ #if isSysHint and priceType != ShareDefine.TYPE_Price_BourseMoney:
+ # #通知客户端得到金钱
+ # if priceType == ShareDefine.TYPE_Price_PayCoin:
+ # NotifyCode(curPlayer, "GetMoney", [priceType, str(round(value/100.0, 2))])
+ # else:
+ # NotifyCode(curPlayer, "GetMoney", [priceType, value])
__GiveMoneyAfter(curPlayer, priceType, value, giveType, addDataDict)
if befMoney == 0:
@@ -3436,10 +3359,7 @@
def GetFabaoAddPoint(curPlayer):
#法宝额外增加玩家每级获得的灵根点
- mwID = IpyGameDataPY.GetFuncCfg('FabaoAddPoint', 1)
- if not PlayerMagicWeapon.GetIsActiveMagicWeapon(curPlayer, mwID, lv=1):
- return 0
- return IpyGameDataPY.GetFuncCfg('FabaoAddPoint', 2)
+ return 0
def DoAddPointOpen(curPlayer):
'''加点功能开启'''
@@ -3520,7 +3440,8 @@
# 杀怪
if expViewType == ShareDefine.Def_ViewExpType_KillNPC:
- exp_rate = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TotalExpRate)
+ #exp_rate = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TotalExpRate)
+ exp_rate = 10000
elif expViewType in [ShareDefine.Def_ViewExpType_GameEvent, ShareDefine.Def_ViewExpType_Sit]:
exp_rate = curPlayer.GetGameEventExpRate()
#exp_rate += GetFamilySitExpPer(curPlayer)
@@ -3649,10 +3570,6 @@
# 升级需要执行的游戏功能处理
GameFuncComm.DoFuncOpenLogic(curPlayer)
- #ChEquip.RefreshPlayerLingQiEquipAttr(curPlayer) # 灵器属性会随等级成长
- #if aftLV%10 == 0:
- # # 控制下刷新次数
- # PlayerPet.CalcPetItemAddPlayerAttr(curPlayer) # 宠物有随等级变化的技能
PlayerOnline.CalcRoleBase(curPlayer)
PlayerOnline.GetOnlinePlayer(curPlayer).RefreshRoleAttr()
@@ -3662,7 +3579,6 @@
#if curPlayer.GetMaxMP() > 0:
# curPlayer.SetMP(curPlayer.GetMaxMP())
- FBLogic.OnPlayerLVUp(curPlayer)
# 记录开服活动冲级数据
#OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_LV, curPlayer.GetLV())
#神秘限购
@@ -3892,8 +3808,6 @@
DoPlayerDead(curPlayer)
GameObj.ClearPyPlayerState(curPlayer)
-
- MirrorAttack.OnPlayerDead(curPlayer)
return
@@ -4270,104 +4184,22 @@
# return False
return True
-#------------------------------------------------------------------------------------
-##初始化玩家背包.
-# @param curPlayer 玩家实例
-# @return 返回值无意义
-# @remarks 初始化玩家背包
-def Init_ItemPack(curPlayer):
- packType = IPY_GameWorld.rptItem
-
- #初始化玩家背包
- if packType not in ChConfig.Def_Type_CanBuyPack_PlayerDict.keys():
- return
-
- #获取玩家背包
- curPack = curPlayer.GetItemManager().GetPack(packType)
-
- #默认14格子 + 开启的
- keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
- count = ItemCommon.GetPackInitCount(packType) + curPlayer.NomalDictGetProperty(keyName)
- curPack.SetCount(count)
-
- #通知客户端背包格子数目
-# curPlayer.Sync_ItemCount(curPack.GetCount())
- curPack.Sync_PackCanUseCount()
- return
#------------------------------------------------------------------------------------
-##初始化玩家仓库.
-# @param curPlayer 玩家实例
-# @return 返回值无意义
-# @remarks 初始化玩家仓库
-def Init_Warehouse(curPlayer):
-
- packType = IPY_GameWorld.rptWarehouse
-
- #初始化玩家背包
- if packType not in ChConfig.Def_Type_CanBuyPack_PlayerDict.keys():
- return
-
- #获取玩家背包
+
+def Init_PackCount(curPlayer, packType, defaultMax=False, isSync=True):
+ ## 初始化刷新玩家某个背包格子数
curPack = curPlayer.GetItemManager().GetPack(packType)
-
- #默认42格子 + 开启的
- keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
- count = ItemCommon.GetPackInitCount(packType) + curPlayer.NomalDictGetProperty(keyName)
-
- curPack.SetCount(count)
-
- #通知客户端
- curPack.Sync_PackCanUseCount()
+ maxCount = curPack.GetMaxCount()
+ if defaultMax:
+ curPack.SetCount(maxCount)
+ else:
+ count = ItemCommon.GetPackInitCount(packType) + ItemCommon.GetPackOpenItemCnt(curPlayer, packType)
+ curPack.SetCount(min(count, maxCount))
+ if isSync:
+ curPack.Sync_PackCanUseCount()
return
-def Init_HeroPack(curPlayer):
- packType = ShareDefine.rptHero
- #获取玩家背包
- curPack = curPlayer.GetItemManager().GetPack(packType)
- initCount = ItemCommon.GetPackInitCount(packType)
- if packType in ChConfig.Def_Type_CanBuyPack_PlayerDict.keys():
- keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
- initCount += curPlayer.NomalDictGetProperty(keyName)
- curPack.SetCount(initCount)
- #通知客户端背包格子数目
-# curPlayer.Sync_ItemCount(curPack.GetCount())
- curPack.Sync_PackCanUseCount()
- return
-
-
-##初始化寻宝背包
-# @param curPlayer 玩家实例
-# @return None
-def Init_TreasurePack(curPlayer):
- curPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptTreasure)
- curPack.SetCount(ItemCommon.GetPackInitCount(ShareDefine.rptTreasure))
-
- #通知客户端
- curPack.Sync_PackCanUseCount()
- return
-
-##初始化玩家收纳柜
-# @param curPlayer 玩家实例
-# @param packType 背包类型
-# @return 返回值无意义
-def Init_CabinetCountByType(curPlayer, packType):
- keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict.get(packType)[ChConfig.Def_PlayerPackDict_Index_Key]
- if keyName == None:
- GameWorld.ErrLog("Init_Pack Error type=%s" % packType)
- return
-
- #初始化时装武器背包
- curPack = curPlayer.GetItemManager().GetPack(packType)
- #默认14格子 + 开启的
- count = ChConfig.Def_PackCnt_WeaponCoat + curPlayer.NomalDictGetProperty(keyName)
- curPack.SetCount(count)
-
- #通知客户端
- curPack.Sync_PackCanUseCount()
- return
-
-#---------------------------------------------------------------------
def IsInOperationAction(curPlayer, actName, actIDKey, crossActName="", crossActIDKey=""):
## 玩家是否有正在进行中运营活动,不含参与结束阶段
@@ -4412,7 +4244,6 @@
def Sync_ExpRateChange(curPlayer):
totalExpRate = GetPlayerExpRate(curPlayer)
fightExpRate = curPlayer.GetFightExpRate() # 系统及功能累加
- fightExpRate += PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_FightExpRate) # VIP加成
fightExpRate += PlayerGoldInvest.GetAddFightExpRate(curPlayer)
actExpRateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_ExpRate, {})# 多倍经验活动加成
@@ -4579,11 +4410,17 @@
# @param wave: 第x波
value = ComMainLevelValue(chapterID, levelNum, wave)
SetMainLevelPassValue(curPlayer, value)
+ if wave == 0:
+ PlayerTask.UpdTaskValue(curPlayer, ChConfig.TaskType_MainLevel)
return value
def GetMainLevelPassInfo(curPlayer):
## 获取主线关卡过关进度信息
# @return: chapterID, levelNum, wave
- return GetMainLevelValue(GetMainLevelPassValue(curPlayer))
+ chapterID, levelNum, wave = GetMainLevelValue(GetMainLevelPassValue(curPlayer))
+ if not chapterID and not levelNum:
+ chapterID, levelNum, wave = 1, 1, 0
+ SetMainLevelPassValue(curPlayer, ComMainLevelValue(chapterID, levelNum, wave))
+ return chapterID, levelNum, wave
## 主线关卡当前进度值 = 章节*10000+关卡编号*100+第x波
def GetMainLevelNowValue(curPlayer): return curPlayer.GetExAttr2()
@@ -4599,7 +4436,14 @@
def GetMainLevelNowInfo(curPlayer):
## 获取主线关卡当前进度信息
# @return: chapterID, levelNum, wave
- return GetMainLevelValue(GetMainLevelNowValue(curPlayer))
+ chapterID, levelNum, wave = GetMainLevelValue(GetMainLevelNowValue(curPlayer))
+ if not chapterID and not levelNum:
+ chapterID, levelNum, wave = 1, 1, 1
+ SetMainLevelNowInfo(curPlayer, chapterID, levelNum, wave)
+ if not wave:
+ wave = 1
+ SetMainLevelNowInfo(curPlayer, chapterID, levelNum, wave)
+ return chapterID, levelNum, wave
def ComMainLevelValue(chapterID, levelNum, wave=0): return chapterID * 10000 + levelNum * 100 + wave
def GetMainLevelValue(value):
@@ -4874,68 +4718,6 @@
#===============================================================================
#---------------------------------------------------------------------------
-##获取可免费开启的格子数
-# @param curPlayer 玩家对象
-# @param packType 背包类型
-# @param openCnt 实际要开启的格子数
-# @return 获取可免费开启的格子数
-def GetCanAutoOpenPackCount(curPlayer, packType, openCnt, tick):
- if packType not in [IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]:
- return 0
- cfgObj = PlayerExpandPackCfgMgr.GetExpandPackCfg(curPlayer, packType)
- #找不到这种背包的配置信息对象
- if not cfgObj:
- return 0
- #已购买或自动开启的格子数
- keyName = ChConfig.Def_Type_CanBuyPack_PlayerDict[packType][ChConfig.Def_PlayerPackDict_Index_Key]
- curCount = curPlayer.NomalDictGetProperty(keyName)
-
-# nextCountIndex = curCount + 1
-# infoObj = cfgObj.GetAttrInfoByInex(nextCountIndex)
-# if None == infoObj:
-# return 0
-# #更新下玩家的在线时间
-# UpdateOnLineTime(curPlayer, tick)
-# onlineTime = curPlayer.GetOnlineTime()
-# #需要的时间
-# needOnlineTime = infoObj["OnlineTime"]
-# #最后一次自动开启背包的在线时间tick
-# lastAutoOpenPackTick = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_LastAutoOpenPackTick)
-# if onlineTime - lastAutoOpenPackTick > needOnlineTime:
-# return 1
-# return 0
-
- #最大可增加的背包数
- maxCanAddCount = cfgObj.GetCanAddCount()
- forCount = min(openCnt, maxCanAddCount - curCount)
-
- #可以再增加的格子数
- count = 0
- #遍历可增加的背包格子数
- UpdateOnLineTime(curPlayer, tick)
- onlineTime = curPlayer.GetOnlineTime()
- lastAutoOpenPackTick = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_LastAutoOpenPackTick % packType)
- lastInfoObj = cfgObj.GetTotalAddAttrInfoByCount(curCount)
- notOnlineTime = 0
- if lastInfoObj:
- notOnlineTime = lastInfoObj["OnlineTime"]
-# GameWorld.Log("get online time = %s"%onlineTime)
- for i in range(forCount):
- nextCount = curCount + i + 1
- infoObj = cfgObj.GetTotalAddAttrInfoByCount(nextCount)
- if None == infoObj:
- break
- # (小于0的不具有免费开启功能)
- if infoObj["OnlineTime"] < 0:
- continue
- needOnlineTime = infoObj["OnlineTime"] - notOnlineTime
-# GameWorld.Log("get need online time = %s"%needOnlineTime)
- #要求的在线时间,大于当前的在线时间,没办法加背包格子
- if needOnlineTime > onlineTime - lastAutoOpenPackTick:
- break
- count += 1
- return count
-
## 获取玩家当前等级升级所需总经验
# @param playerLv 玩家等级
# @return 返回值, 升级需要的总经验
@@ -5045,32 +4827,6 @@
# @param allAttrList 属性列表
# @return None
def CalcAttrDict_Type(attrType, value, allAttrList):
- if value == 0:
- return
-
- #[属性索引, 是否基础属性,(非)线性]
- attrInfo = ChConfig.ItemEffect_AttrDict.get(attrType, [])
- if attrInfo == []:
- return
-
- index = ChConfig.Def_CalcAttrIndexDict[(attrInfo[1], attrInfo[2])]
-
- attrDict = allAttrList[index]
- for i in attrInfo[0]:
- GameWorld.AddDictValue(attrDict, {i:value})
- return
-
-def CalcAttrDict_TypeEx(attrType, value, allAttrDict):
- ## 统计玩家属性,累加
- if value == 0:
- return
-
- #[属性索引, 是否基础属性,(非)线性]
- attrInfo = ChConfig.ItemEffect_AttrDict.get(attrType, [])
- if attrInfo == []:
- return
- for i in attrInfo[0]:
- GameWorld.AddDictValue(allAttrDict, {i:value})
return
## 培养境界等级
@@ -5175,32 +4931,6 @@
## 设置保存功能事先计算好的属性值
def SetCalcAttrListValue(curPlayer, funcIndex, allAttrList, insidePerAttrDict=None, customAttrDict=None):
- # 设置值之前先清空重置
- # @param customAttrDict: 自定义的属性信息,必须是格式 {"自定义属性描述名key":属性信息, ...} 自定义属性描述名key - 建议不同功能点之间不要重复
- ClearCalcAttrListValue(curPlayer, funcIndex)
- if insidePerAttrDict == None:
- insidePerAttrDict = {}
- if customAttrDict == None:
- customAttrDict = {}
-
- battleAttrDict = allAttrList[ChConfig.CalcAttr_Battle]
- if ChConfig.TYPE_Calc_PerLVAtk in battleAttrDict:
- # 每1级加的攻击力不一定满1点,所以这里按万分率来算,支持小数算法
- addAtk = int(curPlayer.GetLV() * battleAttrDict[ChConfig.TYPE_Calc_PerLVAtk] / float(ShareDefine.Def_MaxRateValue))
- battleAttrDict[ChConfig.TYPE_Calc_AttrATKMin] = battleAttrDict.get(ChConfig.TYPE_Calc_AttrATKMin, 0) + addAtk
- battleAttrDict[ChConfig.TYPE_Calc_AttrATKMax] = battleAttrDict.get(ChConfig.TYPE_Calc_AttrATKMax, 0) + addAtk
-
- if ChConfig.TYPE_Calc_PerLVMaxHP in battleAttrDict:
- # 每1级加的生命值不会少于1点,所以直接乘
- addMaxHP = curPlayer.GetLV() * battleAttrDict[ChConfig.TYPE_Calc_PerLVMaxHP]
- battleAttrDict[ChConfig.TYPE_Calc_AttrMaxHP] = battleAttrDict.get(ChConfig.TYPE_Calc_AttrMaxHP, 0) + addMaxHP
-
- playerID = curPlayer.GetPlayerID()
- if playerID not in PyGameData.g_playerFuncAttrDict:
- PyGameData.g_playerFuncAttrDict[playerID] = {}
- funcAttrDict = PyGameData.g_playerFuncAttrDict[playerID]
- funcAttrDict[funcIndex] = [allAttrList, insidePerAttrDict, customAttrDict]
- #GameWorld.DebugLog("保存功能点属性: funcIndex=%s, %s, %s" % (funcIndex, allAttrList, insidePerAttrDict))
return
def GetCalcAttrListValue(curPlayer, funcIndex):
@@ -5208,63 +4938,7 @@
attrList = [{} for _ in range(4)]
insidePerAttrDict = {}
customAttrDict = {}
- if isinstance(funcIndex, int):
- funcIndexList = [funcIndex]
- elif isinstance(funcIndex, list):
- funcIndexList = funcIndex
- else:
- return attrList, insidePerAttrDict, customAttrDict
-
- playerID = curPlayer.GetPlayerID()
- if playerID not in PyGameData.g_playerFuncAttrDict:
- return attrList, insidePerAttrDict, customAttrDict
- funcAttrDict = PyGameData.g_playerFuncAttrDict[playerID]
- for funcIndex in funcIndexList:
- if funcIndex not in funcAttrDict:
- continue
- funcAttrList, funcInsidePerAttrDict, funcCustomAttrDict = funcAttrDict[funcIndex]
- for i, attrDict in enumerate(attrList):
- curAttrDict = funcAttrList[i]
- AddAttrDictValue(attrDict, curAttrDict)
- customAttrDict.update(funcCustomAttrDict)
- AddAttrDictValue(insidePerAttrDict, funcInsidePerAttrDict)
return attrList, insidePerAttrDict, customAttrDict
-
-## 重置缓存
-def ClearCalcAttrListValue(curPlayer, funcIndex):
- playerID = curPlayer.GetPlayerID()
- if playerID not in PyGameData.g_playerFuncAttrDict:
- return
- funcAttrDict = PyGameData.g_playerFuncAttrDict[playerID]
- funcAttrDict.pop(funcIndex, None)
- return
-
-def AddAttrListValue(attrList):
- addAttrList = [{} for _ in range(4)]
- for aList in attrList:
- for i in ChConfig.CalcAttrIndexList:
- AddAttrDictValue(addAttrList[i], aList[i])
- return addAttrList
-
-## 属性值字典累加
-def AddAttrDictValue(dict1, dict2):
- for key, value in dict2.items():
- if key not in dict1:
- dict1[key] = value
- else:
- aValue = dict1[key]
- if key in ChConfig.TYPE_Calc_DeclineList:
- # 这种算法的属性一般是万分率的,最大不超过百分百,故暂默认万分率, 若有不是万分率的属性再做处理
- dict1[key] = 10000 - (10000 - aValue) * (10000 - value)
- else:
- dict1[key] = aValue + value
- return
-
-def GetLordAttr(curPlayer):
- ## 获取主公属性汇总
- lordAttrDict = {"Atk":curPlayer.GetMaxAtk(), "Def":curPlayer.GetDef(), "MaxHP":GameObj.GetMaxHP(curPlayer),
- "Hit":curPlayer.GetHit(), "Miss":curPlayer.GetMiss()}
- return lordAttrDict
#-------------------------------------------------------------------------------
## 设置玩家字典值, 存库
--
Gitblit v1.8.0