From c3bbd3b0263fc6c2127cd9f072f497f46f98758b Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期六, 07 二月 2026 21:43:20 +0800
Subject: [PATCH] 389 流向记录(简化战斗流向记录,只统计出场的武将ID;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py | 426 +++++++++++++++++++++++++++++++++++++---------------
1 files changed, 302 insertions(+), 124 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
index 5dda203..fb0f5cf 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/TurnAttack.py
@@ -29,11 +29,11 @@
import GameWorld
import PlayerLLMJ
import PlayerPrestigeSys
-import CrossServerPackLogic
import DataRecordPack
import PlayerSuccess
import IpyGameDataPY
import PlayerOnline
+import PlayerPreset
import NPCCommon
import ShareDefine
import PyGameData
@@ -44,6 +44,7 @@
import TurnBuff
import FBCommon
import CommFunc
+import CrossMsg
import FBLogic
import random
@@ -78,10 +79,11 @@
self.lineupInfo = {} # 传入初始化的阵容信息
self.shapeType = 0 # 阵型
self.fightPower = 0 # 阵容总战力
- self.posObjIDDict = {} # 站位对应战斗实体 {站位编号:batObjID, ...}, 站位编号小于0为非主战单位,如主公、红颜等
- self.heroObjIDDict = {} # 武将ID对应ObjID {heroID:batObjID, ...}
- self.lingshouObjIDDict = {} # 灵兽战斗单位 {位置编号:batObjID, ...}
- self.beautyObjIDDict = {} # 红颜战斗单位 {位置编号:batObjID, ...}
+
+ self._posObjIDDict = {} # 站位对应战斗实体 {站位编号:batObjID, ...},如主公、命格、灵兽等
+ self._heroObjIDDict = {} # 武将ID对应ObjID {heroID:batObjID, ...}
+ self._batHeroObjIDList = [] # 主战武将对象ID列表
+ self._minggeObjID = 0 # 命格对象ID
self.actionNum = ActionNumStart # 行动位置,从1开始
self.totalHurt = 0 # 阵容总输出
@@ -92,9 +94,9 @@
def getReqPlayerID(self): return self.turnFight.getReqPlayerID() # 发起的玩家ID
- def isEmpty(self): return not self.posObjIDDict
+ def isEmpty(self): return not self._batHeroObjIDList
- def setLineup(self, lineupInfo):
+ def setLineupInfo(self, lineupInfo):
## 设置阵容
# @param lineupInfo: 阵容信息
self.clearLineup()
@@ -110,26 +112,55 @@
def clearLineup(self):
## 清除阵容
batObjMgr = BattleObj.GetBatObjMgr()
- for objID in self.posObjIDDict.values():
- batObjMgr.delBatObj(objID)
- for objID in self.lingshouObjIDDict.values():
- batObjMgr.delBatObj(objID)
- for objID in self.beautyObjIDDict.values():
+ for objID in self._posObjIDDict.values():
batObjMgr.delBatObj(objID)
self.lineupInfo = {}
- self.posObjIDDict = {}
- self.heroObjIDDict = {}
- self.lingshouObjIDDict = {}
- self.beautyObjIDDict = {}
+ self._posObjIDDict = {}
+ self._heroObjIDDict = {}
+ self._batHeroObjIDList = []
+ self._minggeObjID = 0
self.fightPower = 0
self.totalHurt = 0
return
+
+ def addObj(self, batObj):
+ objID = batObj.GetID()
+ posNum = batObj.GetPosNum()
+ heroID = batObj.GetHeroID()
+ batObjType = batObj.GetBatObjType()
+ self._posObjIDDict[posNum] = objID
+ if heroID:
+ self._heroObjIDDict[heroID] = objID
+
+ if batObjType == ChConfig.BatObjType_BatHero:
+ if objID not in self._batHeroObjIDList:
+ self._batHeroObjIDList.append(objID)
+ elif batObjType == ChConfig.BatObjType_Mingge:
+ self._minggeObjID = objID
+ elif batObjType == ChConfig.BatObjType_Lingshou:
+ pass
+ return
+
+ def getPosObjIDDict(self): return self._posObjIDDict
+ def getAllPosObjIDList(self): return self._posObjIDDict.values()
+
+ def getBatHeroObjIDList(self): return self._batHeroObjIDList ## 获取主战武将对象ID列表
+
+ def getHeroObj(self, heroID):
+ if heroID not in self._heroObjIDDict:
+ return
+ return BattleObj.GetBatObjMgr().getBatObj(self._heroObjIDDict[heroID])
+
+ def getMinggeObj(self):
+ if not self._minggeObjID:
+ return
+ return BattleObj.GetBatObjMgr().getBatObj(self._minggeObjID)
def getDeadObjCnt(self):
## 获取本阵容目前死亡队员数
deadCnt = 0
batObjMgr = BattleObj.GetBatObjMgr()
- for objID in self.posObjIDDict.values():
+ for objID in self._batHeroObjIDList:
batObj = batObjMgr.getBatObj(objID)
if not batObj:
continue
@@ -137,11 +168,6 @@
continue
deadCnt += 1
return deadCnt
-
- def getHeroObj(self, heroID):
- if heroID not in self.heroObjIDDict:
- return
- return BattleObj.GetBatObjMgr().getBatObj(self.heroObjIDDict[heroID])
class BatFaction():
## 战斗阵营
@@ -290,24 +316,32 @@
if not lineupInfo:
continue
batLineup = batFaction.getBatlineup(num)
- batLineup.setLineup(lineupInfo)
+ batLineup.setLineupInfo(lineupInfo)
return
def sortActionQueue(self):
## 刷新出手顺序队列
+ batObjMgr = BattleObj.GetBatObjMgr()
sortList = []
for batFaction in self.factionDict.values():
faction = batFaction.faction
for num, batLineup in batFaction.lineupDict.items():
isPlayer = 1 if batLineup.ownerID else 0 # 玩家阵容优先攻击
+ atkSpeed = 0
+ for objID in batLineup.getBatHeroObjIDList():
+ batObj = batObjMgr.getBatObj(objID)
+ if not batObj:
+ continue
+ atkSpeed += batObj.GetBatAttrValue(ChConfig.AttrID_AtkSpeed)
fightPower = batLineup.fightPower
sortValue = -(faction * 10 + num)
- sortList.append([isPlayer, fightPower, sortValue, faction, num])
+ sortList.append([isPlayer, atkSpeed, fightPower, sortValue, faction, num])
sortList.sort(reverse=True) # 战力高的先手
self.actionIndex = 0
self.actionSortList = []
- for _, _, _, faction, num in sortList:
+ for sortInfo in sortList:
+ faction, num = sortInfo[-2:]
self.actionSortList.append([faction, num])
GameWorld.DebugLogEx("阵容战力排序[isPlayer, fp, sortV, f, n]: %s", sortList)
@@ -337,10 +371,7 @@
for batLineup in batFaction.lineupDict.values():
if not allKilled:
break
- for posNum, objID in batLineup.posObjIDDict.items():
- if posNum <= 0:
- # 非主战位置不判断
- continue
+ for objID in batLineup.getBatHeroObjIDList():
batObj = batObjMgr.getBatObj(objID)
if not batObj:
continue
@@ -401,10 +432,12 @@
tfLineup.OwnerID = batLineup.ownerID
tfLineup.ShapeType = batLineup.shapeType
tfLineup.ObjList = []
- for posNum, objID in batLineup.posObjIDDict.items():
+ for posNum, objID in batLineup.getPosObjIDDict().items():
batObj = batObjMgr.getBatObj(objID)
if not batObj:
continue
+ #if posNum == ChConfig.TFPosNum_Mingge: # 理论上要都同步,但是前端需要同步修改,等前端要改时再同步
+ # continue
tfObj = ChPyNetSendPack.tagSCTurnFightObj()
tfObj.ObjID = batObj.GetID()
tfObj.NPCID = batObj.GetNPCID()
@@ -420,6 +453,8 @@
else:
tfObj.PosNum = posNum
tfObj.AngreXP = batObj.GetXP()
+ tfObj.FightPower = batObj.GetFightPower() % ChConfig.Def_PerPointValue
+ tfObj.FightPowerEx = batObj.GetFightPower() / ChConfig.Def_PerPointValue
tfLineup.ObjList.append(tfObj)
tfLineup.ObjCnt = len(tfLineup.ObjList)
tfFaction.LineupList.append(tfLineup)
@@ -569,40 +604,52 @@
% (chapterID, levelNum, nowChapterID, fixNowValue), curPlayer.GetPlayerID())
return
-
-def GetCacheLineupFightPower(tagViewCache, lineupID):
- lineupInfo = GetCacheLineupInfo(tagViewCache, lineupID)
- return lineupInfo.get("FightPower", 0)
-def GetCacheLineupInfo(tagViewCache, lineupID):
+def GetCacheLineupFightPower(tagViewCache, batPresetType=ShareDefine.BatPreset_Main):
+ if not tagViewCache:
+ return 0
+ lineupInfo = GetCacheLineupInfo(tagViewCache, batPresetType)
+ return lineupInfo.get("FightPower", tagViewCache.GetFightPowerTotal())
+def GetCacheLineupInfo(tagViewCache, batPresetType=ShareDefine.BatPreset_Main):
## 根据查看缓存获取阵容信息,一般是 GetPlayerLineupInfo 返回的结果
plusDict = tagViewCache.GetPlusDict()
+ batPresetDict = plusDict.get("BatPreset", {})
+ batTypePresetDict = batPresetDict.get("%s" % batPresetType, {})
+ batPresetID = batTypePresetDict.get("%s" % ShareDefine.FuncPreset_Battle, 1)
+
lineupDict = plusDict.get("Lineup", {})
- lineupInfo = lineupDict.get("%s" % lineupID, {})
+ lineupInfo = lineupDict.get("%s" % batPresetID, {})
if not lineupInfo:
- lineupInfo = lineupDict.get("%s" % ShareDefine.Lineup_Main, {})
+ defBatPresetID = 1
+ lineupInfo = lineupDict.get("%s" % defBatPresetID, {})
return lineupInfo
-def GetPlayerLineupFightPower(curPlayer, lineupID):
+def GetPlayerLineupFightPower(curPlayer, batPresetType=ShareDefine.BatPreset_Main, exclusiveMapID=0):
## 获取玩家阵容战力,一般用于直接获取阵容战力记录用
- return GetPlayerLineup(curPlayer, lineupID).fightPower
-def GetPlayerLineup(curPlayer, lineupID):
+ return GetPlayerLineupByType(curPlayer, batPresetType, exclusiveMapID).fightPower
+def GetPlayerLineupByType(curPlayer, batPresetType=ShareDefine.BatPreset_Main, exclusiveMapID=0):
+ batPresetID = PlayerPreset.GetBatPresetID(curPlayer, batPresetType)
+ return GetPlayerLineupByID(curPlayer, batPresetID, exclusiveMapID)
+def GetPlayerLineupByID(curPlayer, batPresetID=0, exclusiveMapID=0):
## 获取玩家阵容
+ mainBatPresetID = PlayerPreset.GetBatPresetID(curPlayer, ShareDefine.BatPreset_Main)
+ if not batPresetID:
+ batPresetID = mainBatPresetID
olPlayer = PlayerOnline.GetOnlinePlayer(curPlayer)
- lineup = olPlayer.GetLineup(lineupID)
- if lineup.IsEmpty():
- GameWorld.DebugLogEx("玩家没有目标阵容默认取主阵容! lineupID=%s", lineupID, curPlayer.GetPlayerID())
- lineup = olPlayer.GetLineup(ShareDefine.Lineup_Main)
+ lineup = olPlayer.GetPresetLineup(batPresetID, exclusiveMapID=exclusiveMapID)
+ if lineup.IsEmpty() and batPresetID != mainBatPresetID:
+ GameWorld.DebugLogEx("玩家没有目标阵容默认取主线阵容! batPresetID=%s,mainBatPresetID=%s", (batPresetID, mainBatPresetID), curPlayer.GetPlayerID())
+ lineup = olPlayer.GetPresetLineup(mainBatPresetID, exclusiveMapID=exclusiveMapID)
return lineup
-
-def GetPlayerLineupInfo(curPlayer, lineupID):
+def GetPlayerLineupInfo(curPlayer, batPresetType=ShareDefine.BatPreset_Main, exclusiveMapID=0):
## 获取玩家阵容信息,可用于战斗或查看缓存,因为可能取玩家的缓存进行对战,所以统一使用json格式,前端通用
- # @param lineupID: 阵容ID
+ # @param exclusiveMapID: 专享阵容的地图ID,如定军阁
# @return: 阵容全部信息json字典,前端通用格式
-
+ batPresetID = PlayerPreset.GetBatPresetID(curPlayer, batPresetType)
playerID = curPlayer.GetPlayerID()
- lineup = GetPlayerLineup(curPlayer, lineupID)
+ lineup = GetPlayerLineupByID(curPlayer, batPresetID, exclusiveMapID)
if lineup.IsEmpty():
return {}
+ batPresetID = lineup.batPresetID
heroDict = {}
curPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptHero)
@@ -611,14 +658,16 @@
heroID = hero.heroID
itemIndex = hero.itemIndex
heroLV = 1
- star = 0
+ star, breakLV, awakeLV = 0, 0, 0
+ userData = "{}"
if itemIndex >= 0 and itemIndex < curPack.GetCount():
heroItem = curPack.GetAt(itemIndex)
if heroItem and not heroItem.IsEmpty():
heroLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroLV)
star = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroStar)
- #breakLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
- #awakeLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
+ breakLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroBreakLV)
+ awakeLV = heroItem.GetUserAttr(ShareDefine.Def_IudetHeroAwakeLV)
+ userData = heroItem.GetUserData()
skillIDlist = []
skillIDlist += hero.heroSkillIDList
@@ -627,8 +676,9 @@
"SkinID":hero.skinID,
"LV":heroLV,
"Star":star,
- #"BreakLV":breakLV,
- #"AwakeLV":awakeLV,
+ "Data":userData,
+ "BreakLV":breakLV,
+ "AwakeLV":awakeLV,
"FightPower":hero.fightPower,
"AttrDict":{str(k):v for k, v in hero.heroBatAttrDict.items() if v > 0},
"SkillIDList":skillIDlist,
@@ -637,14 +687,26 @@
if not heroDict:
return {}
- lineupInfo = {"PlayerID":playerID, "FightPower":lineup.fightPower, "ShapeType":lineup.shapeType, "Hero":heroDict}
+ mgPresetID = PlayerPreset.GetFuncPresetID(curPlayer, batPresetID, ShareDefine.FuncPreset_Mingge)
+ olPlayer = PlayerOnline.GetOnlineMgr().GetOnlinePlayer(curPlayer)
+ mgSkillLVDict = olPlayer.GetCalcSpecInfo(ChConfig.Def_CalcAttr_Mingge, mgPresetID)
+ mgSkillIDList = []
+ for skillTypeID, skillLV in mgSkillLVDict.items():
+ skillID = SkillCommon.GetSkillIDBySkillTypeID(skillTypeID, skillLV)
+ if skillID not in mgSkillIDList:
+ mgSkillIDList.append(skillID)
+ #shapeType = 0
+ lineupInfo = {"PlayerID":playerID, "FightPower":lineup.fightPower, "BatPresetID":batPresetID, "Hero":heroDict}
+ if mgSkillIDList:
+ lineupInfo["MGSkillIDList"] = mgSkillIDList
return lineupInfo
-def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0):
+def GetNPCLineupInfo(lineupID, strongerLV=0, difficulty=0, isLog=True, viewNPCID=0):
## 获取NPC阵容信息
# @param lineupID: 阵容ID
# @param npcLV: 成长NPC等级
# @param difficulty: 成长NPC难度系数
+ # @param viewNPCID: 查看指定的NPCID,供前端查询NPC属性用
# @return: 阵容全部信息json字典,前端通用格式
lineupInfo = GetGMTestNPCLineupInfo(lineupID, strongerLV, difficulty)
if lineupInfo:
@@ -662,10 +724,14 @@
npcID = getattr(ipyData, "GetPosNPCID%s" % posNum)()
if not npcID:
continue
- battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty)
+ if viewNPCID and viewNPCID != npcID:
+ continue
+ battleDict = GetNPCBattleDict(ipyData, npcID, strongerLV, difficulty, isLog)
if not battleDict:
continue
heroDict[str(posNum)] = battleDict
+ if viewNPCID:
+ break
lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict, "BossID":bossID, "BossPosView":bossPosView}
return lineupInfo
@@ -682,8 +748,8 @@
if not tagViewCache:
PlayerControl.NotifyCode(curPlayer, "TagNoViewCache")
return
- defLineupInfo = GetCacheLineupInfo(tagViewCache, ShareDefine.Lineup_Main)
- lineupDictA = {1:GetPlayerLineupInfo(curPlayer, ShareDefine.Lineup_Main)}
+ defLineupInfo = GetCacheLineupInfo(tagViewCache)
+ lineupDictA = {1:GetPlayerLineupInfo(curPlayer)}
lineupDictB = {1:defLineupInfo}
turnFight = DoTurnFightPVP(guid, mapID, funcLineID, lineupDictA, lineupDictB)
return turnFight.costTime if turnFight else None
@@ -775,7 +841,7 @@
lineupInfo = {"NPCLineupID":lineupID, "Hero":heroDict, "BossID":0, "BossPosView":0}
return lineupInfo
-def GetNPCBattleDict(lineupIpyData, npcID, strongerLV=0, difficulty=0):
+def GetNPCBattleDict(lineupIpyData, npcID, strongerLV=0, difficulty=0, isLog=True):
## 获取NPC战斗相关字典,支持成长NPC
# @param strongerLV: 成长等级
# @param difficulty: 难度系数
@@ -789,7 +855,16 @@
reModelID = lineupIpyData.GetReModelID()
lvReIpyData = None
heroIpyData = IpyGameDataPY.GetIpyGameData("Hero", heroID) if heroID else None
- npcStronger = IpyGameDataPY.GetIpyGameDataNotLog("NPCStronger", npcID)
+ npcStronger = None
+ npcStrongerList = IpyGameDataPY.GetIpyGameDataListNotLog("NPCStronger", npcID)
+ if npcStrongerList and strongerLV:
+ for strongerData in npcStrongerList:
+ if not strongerData.GetNPCLV() or strongerLV <= strongerData.GetNPCLV():
+ npcStronger = strongerData
+ break
+ if not npcStronger:
+ npcStronger = npcStrongerList[-1] # 找不到时取最后一条
+
if npcStronger and strongerLV:
lvReIpyData = IpyGameDataPY.GetIpyGameData("LVReValue", reModelID, strongerLV)
if lvReIpyData:
@@ -820,10 +895,10 @@
random.shuffle(randSkillIDExList)
randSkillIDExList = randSkillIDExList[:skillExCnt]
skillIDList += randSkillIDExList
- GameWorld.DebugLogEx("阵容boss技能: %s, 随机附加技能: %s", skillIDList, randSkillIDExList)
+ isLog and GameWorld.DebugLogEx("阵容boss技能: %s, 随机附加技能: %s", skillIDList, randSkillIDExList)
# 成长怪属性
- batAttrDict = GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty)
+ batAttrDict = GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty, isLog)
if not batAttrDict:
batAttrDict = {ChConfig.AttrID_Atk:npcData.GetAtk(), ChConfig.AttrID_Def:npcData.GetDef(), ChConfig.AttrID_MaxHP:npcData.GetMaxHP(),
ChConfig.AttrID_FinalDamPer:npcData.GetFinalDamPer(), ChConfig.AttrID_FinalDamPerDef:npcData.GetFinalDamPerDef(),
@@ -844,13 +919,13 @@
"SkinID":skinID,
"LV":npcLV,
"Star":star,
- #"BreakLV":breakLV,
- #"AwakeLV":awakeLV,
+ "BreakLV":breakLV,
+ "AwakeLV":awakeLV,
"AttrDict":{str(k):v for k, v in batAttrDict.items() if v > 0},
"SkillIDList":skillIDList,
}
- GameWorld.DebugLogEx("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,reModelID=%s,%s", npcID, strongerLV, difficulty, reModelID, battleDict)
+ isLog and GameWorld.DebugLogEx("GetNPCBattleDict npcID=%s,strongerLV=%s,difficulty=%s,reModelID=%s,%s", npcID, strongerLV, difficulty, reModelID, battleDict)
return battleDict
def GetNPCHeroSkillIDList(heroID, heroIpyData, breakLV, awakeLV):
@@ -867,6 +942,9 @@
skillID = breakIpyData.GetSkillID()
if skillID:
skillIDList.append(skillID)
+ skillIDExList = breakIpyData.GetSkillIDExList()
+ if skillIDExList:
+ skillIDList += skillIDExList
awakeIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("HeroAwake", heroID)
if awakeIpyDataList:
@@ -879,7 +957,7 @@
return skillIDList
-def GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty):
+def GetNPCStrongerAttrDict(npcID, lvReIpyData, npcStronger, difficulty, isLog=True):
## 获取NPC成长属性
# @param strongerLV: 成长等级
# @param difficulty: 难度系数
@@ -901,7 +979,7 @@
batAttrDict[attrID] = attrValue
#GameWorld.DebugLogEx(" attrID=%s,attrValue=%s,reValue=%s,ratio=%s,difficulty=%s", attrID, attrValue, reValue, ratio, difficulty)
- GameWorld.DebugLogEx("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s", npcID, lv, difficulty, batAttrDict)
+ isLog and GameWorld.DebugLogEx("NPC成长属性: npcID=%s,lv=%s,difficulty=%s,%s", npcID, lv, difficulty, batAttrDict)
return batAttrDict
def SummonLineupObjs(batLineup, faction, num, lineupInfo, reqPlayerID=0):
@@ -914,12 +992,33 @@
lineupPlayerID = lineupInfo.get("PlayerID", 0) # 阵容所属玩家ID
npcLineupID = lineupInfo.get("NPCLineupID", 0)
GameWorld.DebugLogEx("SummonLineupObjs faction:%s,num:%s,npcLineupID=%s,lineupPlayerID=%s", faction, num, npcLineupID, lineupPlayerID)
+ mgSkillIDList = lineupInfo.get("MGSkillIDList", [])
turnFight = batLineup.turnFight
tfGUID = turnFight.guid
heroDict = lineupInfo.get("Hero", {})
batObjMgr = BattleObj.GetBatObjMgr()
+
+ # 命格
+ #mgSkillIDList = [9000014] # 测试用
+ if mgSkillIDList:
+ minggeObj = batObjMgr.addBatObj()
+ if minggeObj:
+ minggeObj.SetOwnerID(lineupPlayerID)
+ minggeObj.SetTFGUID(tfGUID)
+ minggeObj.SetFaction(faction)
+ minggeObj.SetLineupPos(ChConfig.TFPosNum_Mingge, num)
+ skillManager = minggeObj.GetSkillManager()
+ skillManager.SkillReset()
+ for skillID in mgSkillIDList:
+ skillManager.LearnSkillByID(skillID)
+ batLineup.addObj(minggeObj)
+ GameWorld.DebugLogEx("AddBatObj 命格: faction:%s,num:%s,objID=%s,skillIDList=%s", faction, num, minggeObj.GetID(), skillManager.GetSkillIDList())
+ ResetObjSkill(minggeObj)
+ minggeObj.InitBatAttr({ChConfig.AttrID_MaxHP:1})
+
+ # 武将
initXP = IpyGameDataPY.GetFuncCfg("AngerXP", 1)
for posNumKey, heroInfo in heroDict.items():
posNum = int(posNumKey)
@@ -959,7 +1058,7 @@
batObj = batObjMgr.addBatObj()
if not batObj:
break
- objID = batObj.GetID()
+ #objID = batObj.GetID()
if npcID:
batObj.SetNPCID(npcID)
elif lineupPlayerID:
@@ -983,8 +1082,7 @@
for skillID in skillIDList:
skillManager.LearnSkillByID(skillID)
- batLineup.posObjIDDict[posNum] = objID
- batLineup.heroObjIDDict[heroID] = objID
+ batLineup.addObj(batObj)
GameWorld.DebugLogEx("AddBatObj %s,lv=%s,star=%s,skill=%s", GetObjName(batObj), lv, star, skillManager.GetSkillIDList())
ResetObjSkill(batObj)
@@ -1008,7 +1106,7 @@
GameWorld.DebugLogEx("切换小队重置玩家阵容武将...")
batLineup = batFaction.getBatlineup(1) # 只处理玩家阵容
batObjMgr = BattleObj.GetBatObjMgr()
- for objID in batLineup.posObjIDDict.values():
+ for objID in batLineup.getAllPosObjIDList():
batObj = batObjMgr.getBatObj(objID)
if not batObj:
continue
@@ -1084,21 +1182,17 @@
if not reqRet:
return
funcLineID = reqRet[1] if len(reqRet) > 1 else funcLineID
+ GameWorld.DebugLogEx(" funcLineID=%s", funcLineID, playerID)
fbIpyData = FBCommon.GetFBIpyData(mapID)
fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID, False)
if fbIpyData:
- if not fbLineIpyData:
- GameWorld.DebugLogEx("不存在该副本功能线路! mapID=%s,funcLineID=%s", mapID, funcLineID)
- return
+ #if not fbLineIpyData:
+ # GameWorld.DebugLogEx("不存在该副本功能线路! mapID=%s,funcLineID=%s", mapID, funcLineID)
+ # return
if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, funcLineID, fbIpyData, fbLineIpyData) != ShareDefine.EntFBAskRet_OK:
return
- # 攻防方所使用的阵容ID
- atkLineupID, defLineupID = FBLogic.GetFBPlayerLineupID(curPlayer, mapID, funcLineID)
- if atkLineupID not in ShareDefine.LineupList or defLineupID not in ShareDefine.LineupList:
- return
-
if CheckFightCD(curPlayer, tick, "TurnFightReqTick"):
return
@@ -1106,9 +1200,10 @@
playerServerID = GameWorld.GetPlayerServerID(curPlayer)
guid = GameWorld.GetGUID()
- atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkLineupID)
+ atkBatPresetType = ChConfig.MapAtkBatPresetTypeDict.get(mapID, ShareDefine.BatPreset_Main)
+ atkLineupInfo = GetPlayerLineupInfo(curPlayer, atkBatPresetType, exclusiveMapID=mapID)
if not atkLineupInfo:
- GameWorld.DebugLogEx("玩家没有该阵容数据! atkLineupID=%s", atkLineupID, playerID)
+ GameWorld.DebugLogEx("玩家没有主线阵容数据! mapID=%s", mapID, playerID)
return
# 玩家
@@ -1121,9 +1216,10 @@
PlayerControl.NotifyCode(curPlayer, "TagNoViewCache")
return
- defLineupInfo = GetCacheLineupInfo(tagViewCache, defLineupID)
+ defBatPresetType = ChConfig.MapDefBatPresetTypeDict.get(mapID, ShareDefine.BatPreset_Main)
+ defLineupInfo = GetCacheLineupInfo(tagViewCache, defBatPresetType)
if not defLineupInfo:
- GameWorld.DebugLogEx("目标玩家没有该阵容数据! tagPlayerID=%s,defLineupID=%s", tagPlayerID, defLineupID, playerID)
+ GameWorld.DebugLogEx("目标玩家没有该阵容预设数据! tagPlayerID=%s,defBatPresetType=%s", tagPlayerID, defBatPresetType, playerID)
PlayerControl.NotifyCode(curPlayer, "TagNoLineup")
return
@@ -1192,17 +1288,17 @@
isMultiMap = True
if isMultiMap:
- CrossServerPackLogic.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
+ CrossMsg.SendBattleRequest(reqInfo, guid, mapID, funcLineID, reqPlayerID)
else:
- SSMsg_BattleRequest(reqInfo, fromServerID)
+ S2B_BattleRequest(reqInfo, fromServerID)
return
-def SSMsg_BattleRequest(reqInfo, fromServerID, msgType=""):
+def S2B_BattleRequest(reqInfo, fromServerID, msgType=""):
## 请求执行战斗,由本地图或其他服务器地图分配过来的战斗请求
guid, mapID, funcLineID, lineupDictA, lineupDictB, reqPlayerID, playerServerID, npcLineupIDList, strongerLV, difficulty, reqData = reqInfo
- if msgType:
- GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s"
- % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
+ #if msgType:
+ # GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s"
+ # % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
if npcLineupIDList:
turnFight = DoTurnFightPVE(guid, mapID, funcLineID, reqPlayerID, playerServerID, lineupDictA, npcLineupIDList, strongerLV, difficulty)
@@ -1221,20 +1317,20 @@
# 本地图自己处理的
if fromServerID == GameWorld.GetGameWorld().GetServerID():
- SSMsg_BattleResult(retInfo, fromServerID)
+ B2S_BattleResult(retInfo, fromServerID)
# 其他服务器地图请求的,发送战斗结果回去
else:
- CrossServerPackLogic.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
+ CrossMsg.SendBattleResult(retInfo, fromServerID, guid, mapID, funcLineID, reqPlayerID)
return
-def SSMsg_BattleResult(retInfo, fromServerID, msgType=""):
+def B2S_BattleResult(retInfo, fromServerID, msgType=""):
## 收到战斗结果信息
guid, mapID, funcLineID, reqPlayerID, winFaction, statMsg, dateStr, reqData = retInfo
- if msgType:
- GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s"
- % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
+ #if msgType:
+ # GameWorld.Log("OnServerReceiveMsg => %s, fromServerID=%s,funcMapID=%s,funcLineID=%s,%s,%s"
+ # % (msgType, fromServerID, mapID, funcLineID, guid, time.time()), reqPlayerID)
curPlayer = None
if reqPlayerID:
@@ -1274,7 +1370,7 @@
for index, lineupID in enumerate(npcLineupIDList):
turnFight.lineupIndex = index
- GameWorld.DebugLogEx("对战NPC阵容: index=%s, lineupID=%s", index, lineupID)
+ GameWorld.DebugLogEx("对战NPC阵容: mapID=%s,funcLineID=%s,index=%s,lineupID=%s", mapID, funcLineID, index, lineupID)
if index > 0:
turnFight.nextTurnFight()
turnFight.setFactionLineup(ChConfig.Def_FactionB, {1:GetNPCLineupInfo(lineupID, strongerLV, difficulty)})
@@ -1453,7 +1549,7 @@
return
lineupID = lineupIDList[0] # NPC阵容ID
- lineupMainInfo = GetPlayerLineupInfo(curPlayer, ShareDefine.Lineup_Main)
+ lineupMainInfo = GetPlayerLineupInfo(curPlayer)
if not lineupMainInfo:
GameWorld.DebugLogEx("没有设置主阵容!", playerID)
return
@@ -1550,7 +1646,6 @@
turnFight.syncState(FightState_Fighting)
TurnFightPerTurnBigStart(turnFight, turnNum)
- # 红颜
# 灵兽
if turnFight.winFaction:
@@ -1564,14 +1659,15 @@
faction, num = turnFight.actionSortList[turnFight.actionIndex]
batFaction = turnFight.getBatFaction(faction)
batLineup = batFaction.getBatlineup(num)
+ posObjIDDict = batLineup.getPosObjIDDict()
for posNum in range(batLineup.actionNum, PosNumMax + 1):
#GameWorld.DebugLogEx("武将位置: faction=%s,posNum=%s", faction, posNum)
- if posNum not in batLineup.posObjIDDict:
+ if posNum not in posObjIDDict:
batLineup.actionNum = posNum + 1
#GameWorld.DebugLogEx("没有武将: faction=%s,posNum=%s", faction, posNum)
continue
- objID = batLineup.posObjIDDict[posNum]
+ objID = posObjIDDict[posNum]
batObj = batObjMgr.getBatObj(objID)
# 玩家自己阵营,预判可否行动
@@ -1638,11 +1734,12 @@
faction, num = turnFight.actionSortList[turnFight.actionIndex]
batFaction = turnFight.getBatFaction(faction)
batLineup = batFaction.getBatlineup(num)
+ posObjIDDict = batLineup.getPosObjIDDict()
for posNum in range(batLineup.actionNum, PosNumMax + 1):
batLineup.actionNum = posNum + 1
- if posNum not in batLineup.posObjIDDict:
+ if posNum not in posObjIDDict:
continue
- objID = batLineup.posObjIDDict[posNum]
+ objID = posObjIDDict[posNum]
batObj = batObjMgr.getBatObj(objID)
TurnFightHeroTurnStart(turnFight, batObj, turnNum)
isAction = OnObjAction(turnFight, batObj)
@@ -1690,7 +1787,7 @@
batFaction = turnFight.getBatFaction(faction)
batLineup = batFaction.getBatlineup(num)
batLineup.actionNum = ActionNumStart
- for objID in batLineup.posObjIDDict.values():
+ for objID in batLineup.getAllPosObjIDList():
batObj = batObjMgr.getBatObj(objID)
turnFight.ResetOneActionUseSkillCnt()
TurnPassive.OnTriggerPassiveEffect(turnFight, batObj, ChConfig.TriggerWay_FightStart)
@@ -1708,7 +1805,7 @@
batFaction = turnFight.getBatFaction(faction)
batLineup = batFaction.getBatlineup(num)
batLineup.actionNum = 1
- for objID in batLineup.posObjIDDict.values():
+ for objID in batLineup.getAllPosObjIDList():
batObj = batObjMgr.getBatObj(objID)
if not batObj:
continue
@@ -1735,7 +1832,7 @@
GameWorld.DebugLogEx("回合结束逻辑: turnNum=%s,faction=%s, num=%s", turnNum, faction, num)
batFaction = turnFight.getBatFaction(faction)
batLineup = batFaction.getBatlineup(num)
- for objID in batLineup.posObjIDDict.values():
+ for objID in batLineup.getAllPosObjIDList():
batObj = batObjMgr.getBatObj(objID)
if not batObj:
continue
@@ -1807,6 +1904,16 @@
if not curSkill:
continue
skillID = curSkill.GetSkillID()
+
+ # 每大回合重置能量
+ if curSkill.GetEnergy():
+ for eIndex in range(curSkill.GetEffectCount()):
+ effect = curSkill.GetEffect(eIndex)
+ if effect.GetEffectID() == ChConfig.PassiveEff_EnergySkill and effect.GetEffectValue(2) == 1:
+ curSkill.SetEnergy(0)
+ GameWorld.DebugLogEx(" 每大回合重置技能能量! curID=%s,skillID=%s", curID, skillID)
+ break
+
preTurnUseCnt = batObj.GetSkillTurnUseCnt(skillID)
remainTime = curSkill.GetRemainTime()
if remainTime <= 0:
@@ -2018,7 +2125,7 @@
batFaction = turnFight.getBatFaction(faction)
for lineupNum in batFaction.lineupDict.keys():
batLineup = batFaction.getBatlineup(lineupNum)
- for lineupObjID in batLineup.posObjIDDict.values():
+ for lineupObjID in batLineup.getBatHeroObjIDList():
lineupObj = batObjMgr.getBatObj(lineupObjID)
if not lineupObj.IsAlive():
continue
@@ -2099,29 +2206,33 @@
heroCount = 0
batObjMgr = BattleObj.GetBatObjMgr()
statInfo = {}
- drLineupInfo = {}
+ drHeroIDDict = {}
for faction in turnFight.factionDict.keys():
if str(faction) not in statInfo:
statInfo[str(faction)] = {}
facStatInfo = statInfo[str(faction)]
- if str(faction) not in drLineupInfo:
- drLineupInfo[str(faction)] = {}
- facDRLineupInfo = drLineupInfo[str(faction)]
+ if str(faction) not in drHeroIDDict:
+ drHeroIDDict[str(faction)] = {}
+ facDRHeroIDDict = drHeroIDDict[str(faction)]
batFaction = turnFight.getBatFaction(faction)
batFaction.totalHurt = 0
for num in batFaction.lineupDict.keys():
if str(num) not in facStatInfo:
facStatInfo[str(num)] = {}
lineupStatInfo = facStatInfo[str(num)]
+ if str(num) not in facDRHeroIDDict:
+ facDRHeroIDDict[str(num)] = {}
+ posHeroIDDict = facDRHeroIDDict[str(num)]
batLineup = batFaction.getBatlineup(num)
batLineup.totalHurt = 0
- facDRLineupInfo[str(num)] = batLineup.lineupInfo
GameWorld.DebugLogEx("阵容明细: faction=%s,num=%s", faction, num)
- for posNum, objID in batLineup.posObjIDDict.items():
+ for posNum, objID in batLineup.getPosObjIDDict().items():
+ if posNum == ChConfig.TFPosNum_Mingge:
+ #命格不统计
+ continue
batObj = batObjMgr.getBatObj(objID)
if not batObj:
continue
- heroCount += 1
objID = batObj.GetID()
npcID = batObj.GetNPCID()
heroID = batObj.GetHeroID()
@@ -2131,6 +2242,9 @@
batLineup.totalHurt += atkHurt
batFaction.totalHurt += atkHurt
dead = 0 if batObj.IsAlive() else 1
+ if heroID:
+ heroCount += 1
+ posHeroIDDict[str(posNum)] = heroID
GameWorld.DebugLogEx(" Pos:%s ID=%s,npcID=%s,heroID=%s,HP=%s/%s, 输出=%s,承伤=%s,治疗=%s",
posNum, objID, npcID, heroID, batObj.GetHP(), batObj.GetMaxHP(), atkHurt, defHurt, cureHP)
lineupStatInfo[str(posNum)] = {"ObjID":objID, "HeroID":heroID, "NPCID":npcID, "AtkHurt":atkHurt, "DefHurt":defHurt, "CureHP":cureHP,
@@ -2145,7 +2259,7 @@
# 流向记录
if mapID != ChConfig.Def_FBMapID_Main and reqPlayerID:
DataRecordPack.DR_FightStat(reqPlayerID, mapID, funcLineID, turnFight.isWin, turnFight.turnNum, turnFight.turnMax,
- heroCount, turnFight.costTime, statInfo, drLineupInfo)
+ heroCount, turnFight.costTime, drHeroIDDict, guid)
return
#// B4 14 查看战报 #tagCSTurnFightReportView
@@ -2156,19 +2270,83 @@
# char GUID[40]; //战报guid
#};
def OnTurnFightReportView(index, clientData, tick):
+ ## 改为下载文件
+ return
+
+#// B4 16 查看NPC属性 #tagCSViewNPCAttr
+#
+#struct tagCSViewNPCAttr
+#{
+# tagHead Head;
+# DWORD MapID; // 自定义地图ID,可用于绑定战斗地图场景功能(如主线boss、爬塔、竞技场等)
+# DWORD FuncLineID; // MapID对应的扩展值,如具体某个关卡等
+# DWORD ViewNPCID; // 指定查看某个NPCID,发0则查看该关卡阵容所有NPC
+#};
+def OnViewNPCAttr(index, clientData, tick):
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
- guid = clientData.GUID
+ mapID = clientData.MapID
+ funcLineID = clientData.FuncLineID
+ viewNPCID = clientData.ViewNPCID
+ SyncLineupNPCAttr(curPlayer, mapID, funcLineID, viewNPCID)
+ return
+
+def SyncLineupNPCAttr(curPlayer, mapID, funcLineID, viewNPCID=0):
+ lineupIDList = []
+ strongerLV, difficulty = 0, 0
- lastBatBufferInfo = PlayerOnline.GetOnlinePlayer(curPlayer).GetLastBatBuffer()
- if lastBatBufferInfo and len(lastBatBufferInfo) == 2 and guid == lastBatBufferInfo[0]:
- guid, reprot = lastBatBufferInfo
- SyncTurnFightReport(curPlayer, guid, reprot)
+ if mapID == ChConfig.Def_FBMapID_MainBoss:
+ chapterID = funcLineID / 100
+ levelNum = funcLineID % 100
+ levelIpyData = IpyGameDataPY.GetIpyGameData("MainLevel", chapterID, levelNum)
+ if not levelIpyData:
+ return
+ lineupIDList = levelIpyData.GetBossLineupIDList() # Boss波阵容ID列表,小队1阵容ID|小队2阵容ID|...
+ strongerLV = levelIpyData.GetNPCLV()
+ difficulty = levelIpyData.GetDifficulty()
+
+ else:
+ fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID)
+ if fbLineIpyData:
+ lineupIDList = fbLineIpyData.GetLineupIDList()
+ strongerLV = fbLineIpyData.GetNPCLV()
+ difficulty = fbLineIpyData.GetDifficulty()
+ else:
+ ret = FBLogic.GetFBNPCLineupInfo(curPlayer, mapID, funcLineID)
+ if not ret:
+ return
+ lineupIDList, strongerLV, difficulty = ret
+
+ if not lineupIDList:
return
- # 其他战报,一般是入库存储的,待扩展
-
- # 战报已过期
- PlayerControl.NotifyCode(curPlayer, "FightReportExpired")
+ npcAttrList = []
+ for lineupID in lineupIDList:
+ lineupInfo = GetNPCLineupInfo(lineupID, strongerLV, difficulty, False, viewNPCID=viewNPCID)
+ if not lineupInfo:
+ continue
+ heroDict = lineupInfo["Hero"]
+ for posNum, attrInfo in heroDict.items():
+ posNum = int(posNum)
+ npcAttr = ChPyNetSendPack.tagSCViewNPCAttr()
+ npcAttr.PosNum = posNum
+ npcAttr.NPCID = attrInfo["NPCID"]
+ npcAttr.HeroID = attrInfo["HeroID"]
+ npcAttr.LV = attrInfo["LV"]
+ npcAttr.Star = attrInfo["Star"]
+ npcAttr.BreakLV = attrInfo["BreakLV"]
+ npcAttr.AwakeLV = attrInfo["AwakeLV"]
+ npcAttr.AttrMsg = json.dumps(attrInfo["AttrDict"], ensure_ascii=False).replace(" ", "")
+ npcAttr.AttrLen = len(npcAttr.AttrMsg)
+ npcAttrList.append(npcAttr)
+ if not npcAttrList:
+ return
+ clientPack = ChPyNetSendPack.tagSCViewNPCAttrRet()
+ clientPack.MapID = mapID
+ clientPack.FuncLineID = funcLineID
+ clientPack.ViewNPCID = viewNPCID
+ clientPack.NPCAttrList = npcAttrList
+ clientPack.NPCCnt = len(clientPack.NPCAttrList)
+ NetPackCommon.SendFakePack(curPlayer, clientPack)
return
def SyncTurnFightReport(curPlayer, guid, reprot):
--
Gitblit v1.8.0