From 7e0ecb9fda366097e9cb0bc3a79cb52c03da67f5 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 15 十一月 2022 18:11:05 +0800
Subject: [PATCH] 9727 【BT7】【主干】【越南】【后端】查看玩家装备缓存扩展到20阶(支持查看射雕装备17阶)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py
index 4cacc9f..2d04ffc 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCAI/AIType_21.py
@@ -81,6 +81,11 @@
return
mapID = GameWorld.GetMap().GetMapID()
lineID = FBCommon.GetFBPropertyMark()
+ dataMapID = FBCommon.GetRecordMapID(mapID)
+ fbRandMovePosDict = IpyGameDataPY.GetFuncEvalCfg("AI198Point", 2, {})
+ if str(dataMapID) in fbRandMovePosDict:
+ __RobotMove2(curNPC, fbRandMovePosDict[str(dataMapID)])
+ return
posKey = "%d%02d" % (mapID, lineID)
fbMovePosDict = IpyGameDataPY.GetFuncCfg("AI198Point", 1)
if posKey not in fbMovePosDict:
@@ -108,6 +113,107 @@
curNPC.Move(tagPosX, tagPosY)
return
+def __RobotMove2(curNPC, randPosList):
+ ''' 根据多条路径随机移动,不同路径间如果存在交叉点,那么可能随机改变路径
+ @param randPosList: [[[路径A点1x,y],[路径A点2x,y],...], [[路径B点1x,y],[路径B点2x,y],...], ...]
+ '''
+ if not randPosList:
+ return
+
+ #objID = curNPC.GetID()
+ #npcID = curNPC.GetNPCID()
+ RobotMoveIndexInfo = "RobotMoveIndexInfo" # 上次移动目标坐标点索引信息 i * 100 + j
+ RobotMovePosInfo = "RobotMovePosInfo" # 上次移动目标坐标点 posX * 10000 + posY
+ indexInfo = curNPC.GetDictByKey(RobotMoveIndexInfo)
+ posInfo = curNPC.GetDictByKey(RobotMovePosInfo)
+ tagI, tagJ = indexInfo / 100, indexInfo % 100
+ tagPosX, tagPosY = posInfo / 10000, posInfo % 10000
+ curPosX, curPosY = curNPC.GetPosX(), curNPC.GetPosY()
+
+
+ resetPosPath = True # 重置坐标路径,为True时重新搜索路径
+ # 已经有目标点
+ if tagPosX and tagPosY:
+ # 理论上配置没重读
+ if tagI < len(randPosList) and type(randPosList[tagI]) in [list, tuple] and tagJ < len(randPosList[tagI]) \
+ and randPosList[tagI][tagJ] == [tagPosX, tagPosY]:
+ resetPosPath = False
+
+ #GameWorld.DebugLog("__RobotMove2: objID=%s,npcID=%s,curPos(%s,%s),tagPos(%s,%s),tagIndex(%s,%s)"
+ # % (objID, npcID, curPosX, curPosY, tagPosX, tagPosY, tagI, tagJ))
+ #GameWorld.DebugLog(" resetPosPath=%s,randPosList=%s" % (resetPosPath, randPosList))
+
+ # 重置路径,先走向最近的点
+ if resetPosPath:
+ nearestDist = 99999999
+ for i, pathList in enumerate(randPosList):
+ for j, pos in enumerate(pathList):
+ posX, posY = pos
+ tagDist = GameWorld.GetDist(curPosX, curPosY, posX, posY)
+ if tagDist < nearestDist:
+ nearestDist = tagDist
+ tagI, tagJ = i, j
+ tagPosX, tagPosY = posX, posY
+ #GameWorld.DebugLog(" nearestDist=%s" % nearestDist)
+ else:
+ tagDist = GameWorld.GetDist(curPosX, curPosY, tagPosX, tagPosY)
+ #GameWorld.DebugLog(" tagDist=%s" % (tagDist))
+ # 快到达目标点了,预先寻找下个点
+ if tagDist < 2:
+ nearPosIndexList = __getNearPosIndexList(randPosList, tagI, tagJ)
+ #GameWorld.DebugLog(" nearPosIndexList=%s" % nearPosIndexList)
+ if nearPosIndexList:
+ tagI, tagJ = random.choice(nearPosIndexList)
+ tagPosX, tagPosY = randPosList[tagI][tagJ]
+
+ #GameWorld.DebugLog(" tagPos(%s,%s),tagIndex(%s,%s)" % (tagPosX, tagPosY, tagI, tagJ))
+ curNPC.SetDict(RobotMoveIndexInfo, tagI * 100 + tagJ)
+ curNPC.SetDict(RobotMovePosInfo, tagPosX * 10000 + tagPosY)
+ curNPC.Move(tagPosX, tagPosY)
+ return
+
+def __getNearPosIndexList(randPosList, tagI, tagJ):
+ ## 获取多条路径上相邻的点
+ pathPosList = randPosList[tagI]
+ if not pathPosList or len(pathPosList) <= 1:
+ return
+
+ tagPosX, tagPosY = randPosList[tagI][tagJ]
+ nearPosIndexList = __getNearIndexByPath(pathPosList, tagI, tagJ)
+ # 检查其他路径交叉点
+ for i, pathList in enumerate(randPosList):
+ if i == tagI:
+ # 本路径不处理
+ continue
+ for j, pos in enumerate(pathList):
+ posX, posY = pos
+ if posX == tagPosX and posY == tagPosY:
+ for ni, nj in __getNearIndexByPath(pathList, i, j):
+ if [ni, nj] not in nearPosIndexList:
+ nearPosIndexList.append([ni, nj])
+ return nearPosIndexList
+
+def __getNearIndexByPath(pathPosList, tagI, tagJ):
+ ## 获取某条路径上的相邻点索引信息
+ nearPosIndexList = []
+ # 起始点 或 最终点
+ if tagJ == 0 or tagJ == len(pathPosList) - 1:
+ # 起点=终点
+ if pathPosList[0] == pathPosList[-1]:
+ nearPosIndexList.append([tagI, 1])
+ nearPosIndexList.append([tagI, -2])
+ # 起点
+ elif tagJ == 0:
+ nearPosIndexList.append([tagI, 1])
+ else:
+ nearPosIndexList.append([tagI, -2])
+
+ # 中间点,取前后两点
+ else:
+ nearPosIndexList.append([tagI, tagJ - 1])
+ nearPosIndexList.append([tagI, tagJ + 1])
+ return nearPosIndexList
+
#---------------------------------------------------------------------
## npc攻击逻辑
# @param curNPC 当前npc
--
Gitblit v1.8.0