#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GM.Commands.NPCAttr
|
#
|
# @todo:Êä³öNPCÊôÐÔ
|
# @author hxp
|
# @date 2026-1-4
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: Êä³öNPCÊôÐÔ
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2026-1-4 11:00"""
|
#-------------------------------------------------------------------------------
|
|
import FBCommon
|
import GameWorld
|
import TurnAttack
|
import IpyGameDataPY
|
import NPCCommon
|
import ChConfig
|
import os
|
|
def OnExec(curPlayer, paramList):
|
|
if not paramList:
|
GameWorld.DebugAnswer(curPlayer, "Êä³ö¸±±¾ÊôÐÔ: NPCAttr mapID lineID")
|
GameWorld.DebugAnswer(curPlayer, "Êä³öÖ÷Ïßboss: NPCAttr 2 ÕÂ½Ú ¹Ø¿¨ID")
|
GameWorld.DebugAnswer(curPlayer, "µ¼³öÖ÷ÏßÊôÐÔ: NPCAttr e main")
|
return
|
|
value = paramList[0]
|
if value == "e":
|
__exportNPCAttr(curPlayer, paramList)
|
return
|
|
GameWorld.DebugAnswer(curPlayer, "---------------------------")
|
mapID = value
|
if mapID in [ChConfig.Def_FBMapID_Main, ChConfig.Def_FBMapID_MainBoss]:
|
chapterID = paramList[1] if len(paramList) > 1 else 1
|
levelNum = paramList[2] if len(paramList) > 2 else 1
|
levelIpyData = IpyGameDataPY.GetIpyGameData("MainLevel", chapterID, levelNum)
|
if not levelIpyData:
|
GameWorld.DebugAnswer(curPlayer, "²»´æÔÚ¸ÃÕ½ڹؿ¨! %s-%s" % (chapterID, levelNum))
|
return
|
lineupIDList = levelIpyData.GetBossLineupIDList() # Boss²¨ÕóÈÝIDÁÐ±í£¬Ð¡¶Ó1ÕóÈÝID|С¶Ó2ÕóÈÝID|...
|
strongerLV = levelIpyData.GetNPCLV()
|
difficulty = levelIpyData.GetDifficulty()
|
GameWorld.DebugAnswer(curPlayer, "Ö÷ÏßÕ¹Ø: %s-%s" % (chapterID, levelNum))
|
else:
|
funcLineID = paramList[1] if len(paramList) > 1 else 0
|
fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, funcLineID)
|
if not fbLineIpyData:
|
GameWorld.DebugAnswer(curPlayer, "²»´æÔڸø±±¾¹Ø¿¨! %s-%s" % (mapID, funcLineID))
|
return
|
lineupIDList = fbLineIpyData.GetLineupIDList()
|
strongerLV = fbLineIpyData.GetNPCLV()
|
difficulty = fbLineIpyData.GetDifficulty()
|
GameWorld.DebugAnswer(curPlayer, "¸±±¾¹Ø¿¨: %s-%s" % (mapID, funcLineID))
|
|
__printNPCLineupAttr(curPlayer, lineupIDList, strongerLV, difficulty)
|
return
|
|
def __exportNPCAttr(curPlayer, paramList):
|
## µ¼³öNPCÊôÐÔ£¬¹©²ß»®¼ì²é¶Ô±È
|
mapID = paramList[1] if len(paramList) > 1 else "main"
|
|
if mapID == "main":
|
__exportMainLevelNPCAttr(curPlayer, mapID)
|
|
return
|
|
def __printNPCLineupAttr(curPlayer, lineupIDList, npcLV, difficulty):
|
GameWorld.DebugAnswer(curPlayer, "ÕóÈÝ:%s,LV:%s,ÄѶÈ:%s" % (lineupIDList, npcLV, difficulty))
|
for lineupID in lineupIDList:
|
lineupInfo = TurnAttack.GetNPCLineupInfo(lineupID, npcLV, difficulty, False)
|
if not lineupInfo:
|
continue
|
heroDict = lineupInfo["Hero"]
|
bossID = lineupInfo["BossID"] # ÎÞbossʱΪ0
|
for posNum in range(1, 1 + 10):
|
if str(posNum) not in heroDict:
|
continue
|
attrInfo = heroDict[str(posNum)]
|
posNum = int(posNum)
|
npcID = attrInfo["NPCID"]
|
heroID = attrInfo["HeroID"]
|
#realNPCLV = attrInfo["LV"]
|
skillIDList = attrInfo["SkillIDList"]
|
attrDict = attrInfo["AttrDict"]
|
isBoss = 1 if bossID == npcID else 0
|
attrDict2 = {}
|
for attrID, value in attrDict.items():
|
attrID = int(attrID)
|
if not value:
|
continue
|
attrDict2[attrID] = value
|
|
npcData = NPCCommon.GetNPCDataPy(npcID)
|
if not npcData:
|
continue
|
|
GameWorld.DebugAnswer(curPlayer, "----------")
|
objName = GameWorld.CodeToGbk(npcData.GetNPCName())
|
if heroID:
|
objName += " Hero:%s" % heroID
|
if npcID:
|
objName += " NPC:%s" % npcID
|
objName = "P%s:%s" % (posNum, objName)
|
|
GameWorld.DebugAnswer(curPlayer, "%s%s" % (objName, "¡¾Boss¡¿" if isBoss else ""))
|
GameWorld.DebugAnswer(curPlayer, "¹¥:%s,·À:%s,HP:%s"
|
% (attrDict2.get(ChConfig.AttrID_Atk, 0),
|
attrDict2.get(ChConfig.AttrID_Def, 0),
|
attrDict2.get(ChConfig.AttrID_MaxHP, 0)))
|
|
attrStr = ""
|
attrIDList = attrDict2.keys()
|
attrIDList.sort()
|
for attrID in attrIDList:
|
if attrID in [ChConfig.AttrID_Atk, ChConfig.AttrID_Def, ChConfig.AttrID_MaxHP]:
|
continue
|
attrValue = attrDict2[attrID]
|
if attrValue:
|
attrStr += "%s=%s£»" % (attrID, attrValue)
|
GameWorld.DebugAnswer(curPlayer, "ÊôÐÔ:%s" % attrStr)
|
GameWorld.DebugAnswer(curPlayer, "¼¼ÄÜ: %s,%s" % (len(skillIDList), skillIDList))
|
|
return
|
|
def __exportMainLevelNPCAttr(curPlayer, mapID):
|
fieldList = ["Õ½Ú", "¹Ø¿¨", "²¨", "ÕóÈÝID", "IsBoss", "NPCID", "HeroID", "LV", "SkillIDList"]
|
valueList = []
|
attrIDList = []
|
ipyDataMgr = IpyGameDataPY.IPY_Data()
|
for index in range(ipyDataMgr.GetMainLevelCount()):
|
ipyData = ipyDataMgr.GetMainLevelByIndex(index)
|
chapterID = ipyData.GetChapterID()
|
levelNum = ipyData.GetLevelNum()
|
npcLV = ipyData.GetNPCLV()
|
difficulty = ipyData.GetDifficulty()
|
waveLineupIDList = []
|
for wave in range(1, 1 + 6):
|
if not hasattr(ipyData, "GetWaveLineupIDList%s" % wave):
|
break
|
lineupIDList = getattr(ipyData, "GetWaveLineupIDList%s" % wave)()
|
waveLineupIDList.append(lineupIDList)
|
bossLineupIDList = ipyData.GetBossLineupIDList() # Boss²¨ÕóÈÝIDÁбí
|
if bossLineupIDList:
|
waveLineupIDList.append(bossLineupIDList) # bossµ±×ö×îºóÒ»²¨
|
|
for wave, lineupIDList in enumerate(waveLineupIDList, 1):
|
for lineupID in lineupIDList:
|
lineupInfo = TurnAttack.GetNPCLineupInfo(lineupID, npcLV, difficulty, False)
|
if not lineupInfo:
|
continue
|
heroDict = lineupInfo["Hero"]
|
bossID = lineupInfo["BossID"] # ÎÞbossʱΪ0
|
for posNum, attrInfo in heroDict.items():
|
posNum = int(posNum)
|
npcID = attrInfo["NPCID"]
|
heroID = attrInfo["HeroID"]
|
realNPCLV = attrInfo["LV"]
|
skillIDList = attrInfo["SkillIDList"]
|
attrDict = attrInfo["AttrDict"]
|
isBoss = 1 if bossID == npcID else 0
|
attrDict2 = {}
|
for attrID, value in attrDict.items():
|
attrID = int(attrID)
|
if attrID not in attrIDList:
|
attrIDList.append(attrID)
|
attrDict2[attrID] = value
|
values = [chapterID, levelNum, wave, lineupID, isBoss, npcID, heroID, realNPCLV, skillIDList, attrDict2]
|
valueList.append(values)
|
|
|
# °´Ë³ÐòÕûÀí´æÔÚµÄÊôÐÔ
|
attrIDList.sort()
|
attrNameList = []
|
for attrID in attrIDList:
|
attrIpyData = IpyGameDataPY.GetIpyGameData("PlayerAttr", attrID)
|
attrName = attrIpyData.GetParameter() if attrIpyData else "%s" % attrID
|
attrNameList.append(attrName)
|
|
fieldList += attrNameList # ×îÖÕ×Ö¶Î
|
|
folderPath = os.path.join("C:\NPCAttr")
|
if not os.path.exists(folderPath):
|
os.makedirs(folderPath)
|
exportFilePath = os.path.join(folderPath, "NPCAttrMapID_%s.txt" % (mapID))
|
|
lineFormat = "%s" + "\t%s"*(len(fieldList) - 1)
|
|
fp = open(exportFilePath, "w")
|
fp.write("%s\n" % (lineFormat % tuple(fieldList)))
|
for values in valueList:
|
attrDict2 = values[-1]
|
writeValues = values[:-1]
|
for attrID in attrIDList:
|
writeValues.append(attrDict2.get(attrID, 0))
|
fp.write("%s\n" % (lineFormat % tuple(writeValues)))
|
fp.close()
|
GameWorld.DebugAnswer(curPlayer, "µ¼³ö:%s" % exportFilePath)
|
return
|