From 9dc8590dcca4f0a51e24b2f31d72cc841f2c1408 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期三, 23 一月 2019 21:02:09 +0800
Subject: [PATCH] 5919 【后端】【1.5.100】诛仙塔功能开发(次数判断修改)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCustomRefresh.py | 92 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 89 insertions(+), 3 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCustomRefresh.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCustomRefresh.py
index 5a8c626..6e0c400 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCustomRefresh.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCustomRefresh.py
@@ -17,7 +17,7 @@
import ShareDefine
import ReadChConfig
import GameLogic_SealDemon
-import CrossRealmPlayer
+import GameLogic_ZhuXianBoss
import PlayerControl
import IPY_GameWorld
import IpyGameDataPY
@@ -26,6 +26,7 @@
import FBLogic
import random
+import time
#---------------------------------------------------------------------
## 所有npc刷新
@@ -401,6 +402,9 @@
if mapID == ChConfig.Def_FBMapID_SealDemon:
bossID = GameLogic_SealDemon.CurFBLineBOSSID()
stoneNPCID = 0
+ elif mapID == ChConfig.Def_FBMapID_ZhuXianBoss:
+ bossID = GameLogic_ZhuXianBoss.CurFBLineBOSSID()
+ stoneNPCID = 0
else:
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('BOSSInfo', {'RefreshMark':refreshMark, 'MapID':mapID}, isLogNone=False)
if not ipyData:
@@ -412,7 +416,6 @@
isNeedShunt = ipyData.GetIsNeedShunt()
if not bossID and not stoneNPCID:
return
-
gameFB = GameWorld.GetGameFB()
gameWorldMgr = GameWorld.GetGameWorld()
isActivityBoss = False # 是否活动boss
@@ -463,7 +466,7 @@
NPCCommon.SetDeadEx(curNPC)
# 非复活线 且 不需要分流的地图 且 不是封魔坛 不允许复活
- if lineID != rebornLineID and not isNeedShunt and mapID != ChConfig.Def_FBMapID_SealDemon:
+ if lineID != rebornLineID and not isNeedShunt and mapID not in [ChConfig.Def_FBMapID_SealDemon, ChConfig.Def_FBMapID_ZhuXianBoss]:
return
if isActivityBoss and activityBossRebornCount > 0:
@@ -900,3 +903,86 @@
################################################################################
+def ProcessMapRandomRefreshNPC(gameWorld, tick):
+ ''' 地图自定义随机刷怪,支持多点随机刷多种怪,标试点不可重复,支持跨服地图
+ 注意:同个虚拟线路中,标试点不可重复!标试点不可重复!标试点不可重复!
+ '''
+ mapID = gameWorld.GetMapID()
+ # {mapID:{编号:[[多个NPCID], [多个标试点], 单个点最大数量, 所有点总数量, 刷怪间隔秒], ...}, ...}
+ randRefreshNPCDict = IpyGameDataPY.GetFuncEvalCfg("RandomRefreshNPC", 1, {})
+ if mapID not in randRefreshNPCDict:
+ return
+ mapRandRefreshNPCDict = randRefreshNPCDict[mapID]
+
+ #copyMapID = gameWorld.GetCopyMapID()
+
+ gameFB = GameWorld.GetGameFB()
+ lastCheckTick = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_RandomRefreshNPCTick)
+ if lastCheckTick and tick - lastCheckTick < 1000:
+ return
+ gameFB.SetGameFBDict(ChConfig.Def_RMark_RandomRefreshNPCTick, tick)
+
+ curTime = int(time.time())
+ refreshNumList = []
+ for num, refreshInfo in mapRandRefreshNPCDict.items():
+ refreshCD = refreshInfo[-1]
+ numLastTime = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_RandomRefreshNPCNumTime % num)
+ if numLastTime and curTime - numLastTime < refreshCD:
+ continue
+ gameFB.SetGameFBDict(ChConfig.Def_RMark_RandomRefreshNPCNumTime % num, curTime)
+ refreshNumList.append(num)
+
+ if not refreshNumList:
+ #GameWorld.DebugLog("没有需要刷怪的", copyMapID)
+ return
+ npcCountDict = {} # 标识点对应NPC数量
+ rMarkNPCRefreshDict = {} # 标试点对应标试点实例 {标试点:IPY_CustomNPCRefresh, ...}
+ gameNPC = GameWorld.GetNPCManager()
+ for i in xrange(gameNPC.GetCustomNPCRefreshCount()):
+ npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)
+ npcCount = npcRefresh.GetCount()
+ #if not npcCount: # 因为要记录刷怪点实例,所以0的不屏蔽
+ # continue
+ rMark = npcRefresh.GetRefreshMark()
+ npcCountDict[rMark] = npcCountDict.get(rMark, 0) + npcCount
+ rMarkNPCRefreshDict[rMark] = npcRefresh
+
+ #GameWorld.DebugLog("npcCountDict=%s" % npcCountDict, copyMapID)
+ for num in refreshNumList:
+ npcIDList, markList, maxCount, totalMaxCount = mapRandRefreshNPCDict[num][:-1]
+
+ curTotalCount = 0
+ for rMark in markList:
+ curTotalCount += npcCountDict.get(rMark, 0)
+
+ refreshCount = totalMaxCount - curTotalCount
+
+ #GameWorld.DebugLog(" num=%s,markList=%s,curTotalCount=%s,totalMaxCount=%s,refreshCount=%s"
+ # % (num, markList, curTotalCount, totalMaxCount, refreshCount), copyMapID)
+ if refreshCount <= 0:
+ continue
+
+ random.shuffle(markList) # 随机打乱顺序
+ #GameWorld.DebugLog(" markList=%s" % markList, copyMapID)
+ for rMark in markList:
+ if rMark not in rMarkNPCRefreshDict:
+ #GameWorld.DebugLog(" 标试点不存在: rMark=%s" % rMark, copyMapID)
+ continue
+ if refreshCount <= 0:
+ #GameWorld.DebugLog(" 不需要刷怪了: rMark=%s" % rMark, copyMapID)
+ break
+ curCount = npcCountDict.get(rMark, 0)
+ if curCount >= maxCount:
+ #GameWorld.DebugLog(" 该点已经达到单点最大数: rMark=%s" % rMark, copyMapID)
+ continue
+ needRefreshCount = min(refreshCount, maxCount - curCount)
+ refreshCount -= needRefreshCount
+ npcID = npcIDList[0] if len(npcIDList) == 1 else random.choice(npcIDList)
+
+ #GameWorld.DebugLog(" 刷怪: rMark=%s,needRefreshCount=%s,还需=%s" % (rMark, needRefreshCount, refreshCount), copyMapID)
+ npcRefresh = rMarkNPCRefreshDict[rMark]
+ npcRefresh.Refresh(npcID, ChConfig.Def_NormalNPCAngryCount, needRefreshCount, False)
+ __InitNewBornNPC(npcRefresh , tick)
+
+ return
+
--
Gitblit v1.8.0