| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #  | 
| ##@package E:/GameSVN/U3DGame/ProjectSServer/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCustomRefresh.py  | 
| # @todo:   | 
| #  | 
| # @author: Alee  | 
| # @date 2017-10-24 ÏÂÎç08:32:32  | 
| # @version 1.0  | 
| #  | 
| # @note:   | 
| #  | 
| #---------------------------------------------------------------------  | 
| #---------------------------------------------------------------------  | 
| import ChConfig  | 
| import NPCCommon  | 
| import ShareDefine  | 
| import ReadChConfig  | 
| import GameLogic_SealDemon  | 
| import GameLogic_ZhuXianBoss  | 
| import GameLogic_CrossDemonKing  | 
| import PlayerControl  | 
| import IPY_GameWorld  | 
| import IpyGameDataPY  | 
| import PyGameData  | 
| import GameWorld  | 
| import FBCommon  | 
| import FBLogic  | 
|   | 
| import random  | 
| import time  | 
| #---------------------------------------------------------------------  | 
|   | 
| ## ËùÓÐnpcˢР | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def ProcessAllNPCRefresh(tick):  | 
|     if GameWorld.GetMapCopyPlayerManager().GetPlayerCount() == 0 and \  | 
|                     GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull and \  | 
|                     GameWorld.GetMap().GetMapID() not in ChConfig.Def_NoPlayerNeedProcessRefreshPointMap:  | 
|         #¸±±¾ÎÞÍæ¼Ò²»´¦Àí  | 
|         return  | 
|       | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|       | 
|     if gameWorld.GetOpenState() != IPY_GameWorld.fbosOpen:  | 
|         #GameWorld.Log("¸±±¾¹Ø±Õ²»´¦Àí = %s State = %s" % (gameWorld.GetLineID(), gameWorld.GetOpenState()))  | 
|         return  | 
|   | 
|     gameNPC = GameWorld.GetNPCManager()  | 
|       | 
|     for i in range(0, gameNPC.GetCustomNPCRefreshCount()):  | 
|         __ProcessNPCRefresh(i, gameNPC.GetCustomNPCRefreshAt(i), tick)  | 
|       | 
|     return  | 
|   | 
|   | 
| ## Ö´ÐÐnpcˢР | 
| #  @param npcRefresh npcʵÀý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __ProcessNPCRefresh(pointIndex, npcRefresh, tick):  | 
|     funcName = "NPCRefresh_%d" % npcRefresh.GetRefreshMark()  | 
|       | 
|     if globals().has_key(funcName) and GameWorld.GetMap().GetMapID() != ChConfig.Def_FBMapID_ClearDevil:  | 
|         return globals()[funcName](npcRefresh, tick)  | 
|     else:  | 
|         #GameWorld.DebugLog("__NPCCommonRefresh mark = %s" % npcRefresh.GetRefreshMark())  | 
|         __NPCCommonRefresh(pointIndex, npcRefresh, tick)  | 
|     #else:  | 
|     #    GameWorld.Log("Error : ProcessNPCRefresh NPCRefreshID = %s" % funcName)  | 
|           | 
|     return  | 
|   | 
| #-------------------------¹«Óú¯ÊýÇø----------------------------------  | 
| ## ³õʼ»¯ÐÂÉú³öÀ´µÄNPC  | 
| #  @param npcRefresh Ë¢ÐÂʵÀý  | 
| #  @param tick µ±Ç°ÊµÀý  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def __InitNewBornNPC(npcRefresh, tick, value=0):  | 
|     refreshMark = npcRefresh.GetRefreshMark()  | 
|     #³õʼ»¯NPC  | 
|     for i in range(npcRefresh.GetNewBornNPCCount()):  | 
|         curNPC = npcRefresh.GetNewBornNPCAt(i)  | 
|         #³õʼ»¯NPC»ù´¡ÐÅÏ¢  | 
|         NPCCommon.InitNPC(curNPC)  | 
|         curNPC.SetDict(ChConfig.Def_NPC_Dict_FromRefreshMark, refreshMark)  | 
|         curNPC.SetDict(ChConfig.Def_NPC_Dict_FromRefreshValue, value)  | 
|         #ÉèÖÃNPCÖØÉú  | 
|         NPCCommon.NPCControl(curNPC).DoNPCRebornCommLogic(tick)  | 
|           | 
|     return  | 
| ##------------------------------------------------------------------------------  | 
|   | 
| ## µØÍ¼M¸öµãËæ»úË¢NÖ»¹Ö  | 
| #  @param npcRefresh Ë¢ÐÂʵÀý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks Õâ±ßÖ»×öË¢¹Ö£¬¾ßÌåË¢ÔÚÄĸö±êʶµã£¬Ë¢Ê²Ã´¹Ö£¬Ë¢¼¸Ö»Óɹ¦ÄÜ×Ô¼º¾ö¶¨  | 
| def NPCRefresh_82(npcRefresh, tick): return __RandomMapNPC(npcRefresh, tick)  | 
| def NPCRefresh_83(npcRefresh, tick): return __RandomMapNPC(npcRefresh, tick)  | 
|   | 
| def __RandomMapNPC(npcRefresh, tick):  | 
|     refreshMark = npcRefresh.GetRefreshMark()  | 
|   | 
|     gameFB = GameWorld.GetGameFB()  | 
|   | 
|     npcIDKey = ChConfig.Map_NPC_RandomMapNPCID % refreshMark  | 
|     needCntKey = ChConfig.Map_NPC_RandomMapNPCNeedCnt % refreshMark  | 
|     perMaxCntKey = ChConfig.Map_NPC_RandomMapNPCPerMaxCnt % refreshMark  | 
|       | 
|     npcID = gameFB.GetGameFBDictByKey(npcIDKey)  | 
|     needCnt = gameFB.GetGameFBDictByKey(needCntKey)  | 
|     maxCnt = gameFB.GetGameFBDictByKey(perMaxCntKey)  | 
|       | 
|     # ²»ÐèÒª²¹³ä£¬²»Ë¢¹Ö  | 
|     if needCnt <= 0:  | 
|         return  | 
|       | 
|     curCnt = npcRefresh.GetCount()  | 
|     curCanCnt = maxCnt - curCnt  | 
|     # ±¾µã×î´óË¢¹ÖÊýÒÑÂú£¬ÎÞ·¨ÔÙË¢£¡  | 
|     if curCanCnt <= 0:  | 
|         GameWorld.DebugLog("µØÍ¼Ëæ»úË¢¹Ö ±¾µã×î´óË¢¹ÖÊýÒÑÂú£¬ÎÞ·¨ÔÙË¢! refreshMark=%s,maxCnt=%s" % (refreshMark, maxCnt))  | 
|         return  | 
|       | 
|     # ±¾µãÊÇ·ñË¢¹Ö  | 
|     if random.randint(0, 1) == 0:  | 
|         GameWorld.DebugLog("µØÍ¼Ëæ»úË¢¹Ö ¸ÃË¢¹ÖµãûÓÐÃüÖУ¬²»Ë¢¹Ö! refreshMark=%s" % refreshMark)  | 
|         return  | 
|   | 
|     # Ë¢¹Ö  | 
|     npcRefresh.Refresh(npcID, ChConfig.Def_SuperBossAngryCount, 1, False)  | 
|       | 
|     # ³õʼ»¯NPC  | 
|     __InitNewBornNPC(npcRefresh, tick)  | 
|   | 
|     # ¸üл¹ÐèÊý  | 
|     updNeedCnt = max(0, needCnt - 1)  | 
|     gameFB.SetGameFBDict(needCntKey, updNeedCnt)  | 
|       | 
|     GameWorld.Log("µØÍ¼Ëæ»úË¢¹Ö mark=%s,npcID=%s,updNeedCnt=%s" % (refreshMark, npcID, updNeedCnt))  | 
|     return  | 
|   | 
|   | 
| ## Ëþ·À/¹¥³ÇÀàÐ͸±±¾Ë¢¹Ö, Ä¿Ç°Ö§³ÖͬÕŵØÍ¼4¸ö³ö¹ÖµãË¢¹Ö, Èç¹û¼Ó·Ïß, ¶à¼ÓÒ»¸ö²»Öظ´Ë¢¹Ö±êʶµã¼´¿É  | 
| def NPCRefresh_84(npcRefresh, tick): return __RefreshTDFBNPC(npcRefresh, tick)  | 
| def NPCRefresh_85(npcRefresh, tick): return __RefreshTDFBNPC(npcRefresh, tick)  | 
| def NPCRefresh_86(npcRefresh, tick): return __RefreshTDFBNPC(npcRefresh, tick)  | 
| def NPCRefresh_87(npcRefresh, tick): return __RefreshTDFBNPC(npcRefresh, tick)  | 
|   | 
| ## Ëþ·ÀÀàÐ͸±±¾Ë¢¹Ö  | 
| #  @remarks ±¾Âß¼3Ãë²Å»áÖ´ÐÐÒ»´Î£¬¹ÖÎïÊýͳ¼Æ¼°½øÈëÏÂÒ»´ó²¨½¨Òé·Å¸÷×Ô¸±±¾Âß¼×ÔÐÐÅжϣ¬·ÀÖ¹ÑÓ³Ù£¬Ó°ÏìÌåÑé  | 
| def __RefreshTDFBNPC(npcRefresh, tick):  | 
|     rMark = npcRefresh.GetRefreshMark()  | 
|       | 
|     gameFB = GameWorld.GetGameFB()  | 
|       | 
|     # ¿ªÊ¼Ë¢¹Ötick, 0´ú±í¹Ø±ÕË¢¹Ö  | 
|     startTickKey = ChConfig.Map_TDNPC_RefreshStartTick % rMark  | 
|     startTick = gameFB.GetGameFBDictByKey(startTickKey)  | 
|     if startTick <= 0:  | 
|         return  | 
|       | 
|     bigWheelNum = gameFB.GetGameFBDictByKey(ChConfig.Map_TDNPC_RefreshBigWheelNum % rMark)  | 
|     smallWheelNum = gameFB.GetGameFBDictByKey(ChConfig.Map_TDNPC_RefreshSmallWheelNum % rMark)  | 
|       | 
|     curWheelIsOverKey = ChConfig.Map_TDNPC_CurWheelIsOver % rMark  | 
|     curWheelIsOver = gameFB.GetGameFBDictByKey(curWheelIsOverKey)  | 
|     # µ±Ç°²¨ÒÑË¢Íê, ÔÝÍ£´¦Àí, µÈ´ýÏÂÒ»²¨Ë¢¹Ö  | 
|     if curWheelIsOver:  | 
|         #GameWorld.DebugLog("µ±Ç°²¨ÒÑË¢Íê, ÔÝÍ£´¦Àí, µÈ´ýÏÂÒ»²¨Ë¢¹Ö! %s - %s" % (bigWheelNum, smallWheelNum))  | 
|         return  | 
|       | 
|     fileNum = gameFB.GetGameFBDictByKey(ChConfig.Map_TDNPC_RefreshFileNum % rMark)  | 
|     signKey = gameFB.GetGameFBDictByKey(ChConfig.Map_TDNPC_RefreshSignKey % rMark)  | 
|       | 
|     fileName = "TD_%s_NPCID" % fileNum  | 
|     refreshNPCDict = ReadChConfig.GetEvalChConfig(fileName)  | 
|       | 
|     # ÅäÖôíÎó, ¹Ø±ÕË¢¹Ö  | 
|     if signKey not in refreshNPCDict:  | 
|         gameFB.SetGameFBDict(startTickKey, 0)  | 
|         GameWorld.ErrLog("TDË¢¹Ö±ê¼Çkey²»´æÔÚ: signKey=%s not in fileName=%s, rMark=%s" % (signKey, fileName, rMark))  | 
|         return  | 
|       | 
|     totalNPCList = refreshNPCDict[signKey]  | 
|     totalWheel = len(totalNPCList) # ×Ü´ó²¨Êý  | 
|       | 
|     # ÅäÖôíÎó, ¹Ø±ÕË¢¹Ö  | 
|     if bigWheelNum > totalWheel - 1:  | 
|         gameFB.SetGameFBDict(startTickKey, 0)  | 
|         GameWorld.ErrLog("TDË¢¹Ö²¨ÊýÅäÖò»´æÔÚ: fileName=%s,signKey=%s,bigWheelNum=%s" % (fileName, signKey, bigWheelNum))  | 
|         return  | 
|       | 
|     refreshCfgList = ReadChConfig.GetEvalChConfig("TD_%s_Cfg" % fileNum)  | 
|     if totalWheel != len(refreshCfgList):  | 
|         gameFB.SetGameFBDict(startTickKey, 0)  | 
|         GameWorld.ErrLog("TDË¢¹Ö×ܲ¨ÊýÓ벨ÊýÅäÖÃÐÅÏ¢ÌõÊý²»¶ÔÓ¦: fileName=%s,totalWheel=%s" % (fileName, totalWheel))  | 
|         return  | 
|       | 
|     bigWheelNPCList = totalNPCList[bigWheelNum] # ±¾´ó²¨ËùÓÐNPCÁÐ±í  | 
|     wheelInfoList = refreshCfgList[bigWheelNum]  | 
|     curWheelStartTick = gameFB.GetGameFBDictByKey(ChConfig.Map_TDNPC_CurWheelStartTick % rMark)  | 
|     prepareTime = wheelInfoList[FBCommon.Def_TDCfg_PrepareTime] # ´ó²¨¿ªÊ¼Ç°×¼±¸Ê±¼ä  | 
|     if prepareTime > 0 and tick - curWheelStartTick < prepareTime:  | 
|         #GameWorld.DebugLog("¿ªÊ¼Ë¢¹Ö×¼±¸ÖÐ...curWheel=%s, (%s - %s)=%s < %s"   | 
|         #                   % (bigWheelNum, tick, curWheelStartTick, tick - curWheelStartTick, prepareTime))  | 
|         return  | 
|       | 
|     curCnt = npcRefresh.GetCount()  | 
|       | 
|     # Ã»¹Ö¾ÍÖ±½ÓË¢£¬ÓйÖÔòÐèÅжÏˢмä¸ô  | 
|     refreshTick = 0  | 
|     if curCnt > 0 and smallWheelNum > 0:  | 
|         refreshTick += wheelInfoList[FBCommon.Def_TDCfg_SmallWheelSpace]  | 
|           | 
|     # Èç¹ûÓÐË¢¹Öʱ¼ä¼ä¸ô  | 
|     if refreshTick > 0 and tick - npcRefresh.GetRefreshTick() < refreshTick:  | 
|         return  | 
|       | 
|     curRefreshNpcIdList = bigWheelNPCList[smallWheelNum]  | 
|       | 
|     GameWorld.DebugLog("TDË¢¹Ö£ºfileNum=%s,signKey=%s,rMark=%s,bWheelNum=%s,sWheelNum=%s,npcList=%s"   | 
|                        % (fileNum, signKey, rMark, bigWheelNum, smallWheelNum, curRefreshNpcIdList))  | 
|     # Ë¢³ö±¾´ÎËùÓÐNPC  | 
|     for refreshNPCInfo in curRefreshNpcIdList:  | 
|         curNpcId = refreshNPCInfo[0]  | 
|         refreshCnt = refreshNPCInfo[1]  | 
|         angryCnt = ChConfig.Def_SummonNPC_Angry_Count if len(refreshNPCInfo) < 3 else refreshNPCInfo[2]  | 
|         npcRefresh.Refresh(curNpcId, angryCnt, refreshCnt, False)  | 
|           | 
|         #³õʼ»¯NPC  | 
|         __InitNewBornNPC(npcRefresh, tick, fileNum)  | 
|           | 
|     isLastBigWheel = bigWheelNum >= totalWheel - 1 # ÊÇ·ñ×îºóÒ»´ó²¨  | 
|     isLastSmallWheel = smallWheelNum >= len(bigWheelNPCList) - 1 # ÊÇ·ñ±¾´ó²¨×îºóһС²¨  | 
|       | 
|     # ËùÓйÖË¢ÐÂÍê±Ï£¬¹Ø±ÕË¢¹Ö  | 
|     if isLastBigWheel and isLastSmallWheel:  | 
|         gameFB.SetGameFBDict(startTickKey, 0)  | 
|         gameFB.SetGameFBDict(curWheelIsOverKey, 1)  | 
|         gameFB.SetGameFBDict(ChConfig.Map_TDNPC_AllWheelIsOver % rMark, 1)  | 
|         GameWorld.DebugLog("    ËùÓйÖË¢ÐÂÍê±Ï£¬¹Ø±ÕË¢¹Ö!rMark=%s" % rMark)  | 
|         FBLogic.OnTDAllWheelOver(tick)  | 
|       | 
|     # ×îºóһС²¨  | 
|     elif isLastSmallWheel:  | 
|         gameFB.SetGameFBDict(curWheelIsOverKey, 1)  | 
|         GameWorld.DebugLog("    ×îºóһС²¨¹ÖË¢ÐÂÍê±Ï(%s - %s)£¬ÔÝͣˢ¹Ö!rMark=%s" % (bigWheelNum, smallWheelNum, rMark))  | 
|         FBLogic.OnTDCurWheelOver(rMark, tick)  | 
|           | 
|     # Ð¡²¨Ë¢ÐÂÊý+1  | 
|     else:  | 
|         gameFB.SetGameFBDict(ChConfig.Map_TDNPC_RefreshSmallWheelNum % rMark, smallWheelNum + 1)  | 
|     return  | 
|   | 
|   | 
| ## ÊÀ½çbossË¢¹Ö90-100  | 
| #  @param npcRefresh Ë¢ÐÂʵÀý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def NPCRefresh_90(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_91(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_92(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_93(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_94(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_95(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_96(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_97(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_98(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_99(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_100(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_180(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_181(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_182(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_183(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_184(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_185(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_186(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_187(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_188(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_189(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_190(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_191(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_192(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_193(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_194(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_195(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_196(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_197(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_198(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_199(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_200(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_201(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_202(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_203(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_204(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_205(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_206(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_207(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_208(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_209(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_210(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_211(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_212(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_213(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_214(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_215(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_216(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_217(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_218(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_219(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_220(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_221(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_222(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_223(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_224(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_225(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_226(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_227(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_228(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_229(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
| def NPCRefresh_230(npcRefresh, tick):__DoRefreshWorldBoss(npcRefresh, tick)  | 
|   | 
| ## ÊÀ½çbossË¢¹Ö  | 
| #  @param npcRefresh Ë¢ÐÂʵÀý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def __DoRefreshWorldBoss(npcRefresh, tick):  | 
|     '''·Ç·ÖÁ÷µØÍ¼bossÖ»ÔÚÒ»ÏßË¢  | 
|        ·ÖÁ÷µØÍ¼bossÿÌõÏß¶¼Ë¢Ð£¬ÆäËû·ÖÁ÷Ïß·bossÔÚûÈË´òµÄÇé¿öÏÂͬÉúͬËÀ  | 
|     '''  | 
|     if GameWorld.IsCrossServer():  | 
|         __DoRefreshWorldBossCrossServer(npcRefresh, tick)  | 
|         return  | 
|     rebornLineID = 0  | 
|     assignLineID = 0  | 
|     mapID = GameWorld.GetMap().GetMapID()  | 
|     refreshMark = npcRefresh.GetRefreshMark()  | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     relatedType, relatedID = 0, ""  | 
|     isNeedShunt = 0  | 
|     if mapID == ChConfig.Def_FBMapID_SealDemon:  | 
|         bossID = GameLogic_SealDemon.CurFBLineBOSSID()  | 
|         stoneNPCID = 0  | 
|     elif mapID == ChConfig.Def_FBMapID_DemonKing:  | 
|         bossID = GameLogic_CrossDemonKing.GetCurFBLineBOSSID()  | 
|         stoneNPCID = 0  | 
|     elif mapID == ChConfig.Def_FBMapID_ZhuXianBoss:  | 
|         bossID = GameLogic_ZhuXianBoss.CurFBLineBOSSID()  | 
|         stoneNPCID = 0  | 
|     else:  | 
|         ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('BOSSInfo', {'RefreshMark':refreshMark, 'MapID':mapID}, True, isLogNone=False)  | 
|         if not ipyDataList:  | 
|             return  | 
|         if len(ipyDataList) == 1:  | 
|             ipyData = ipyDataList[0]  | 
|         else:  | 
|             # Í¬µØÍ¼Í¬±êÊÔµãÓжàÌõÊý¾ÝµÄÔòΪ²»Í¬Ö¸¶¨·ÖÏß  | 
|             ipyData = None  | 
|             for ipyD in ipyDataList:  | 
|                 refreshLine = ipyD.GetRefreshLine()  | 
|                 rebornLineID = refreshLine - 1  | 
|                 if rebornLineID == lineID:  | 
|                     ipyData = ipyD  | 
|                     break  | 
|         if not ipyData:  | 
|             return  | 
|         stoneNPCID = ipyData.GetStoneNPCID()  | 
|         bossID = ipyData.GetNPCID()  | 
|         relatedType = ipyData.GetRelatedType()  | 
|         relatedID = ipyData.GetRelatedID()  | 
|         isNeedShunt = ipyData.GetIsNeedShunt()  | 
|         assignLineID = ipyData.GetRefreshLine() # Ö¸¶¨Ë¢ÐµÄÏß·  | 
|         if assignLineID > 0:  | 
|             rebornLineID = assignLineID - 1  | 
|     if not bossID and not stoneNPCID:  | 
|         return  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     gameWorldMgr = GameWorld.GetGameWorld()  | 
|     forceReborn = False # Ç¿ÖÆÖØÉú  | 
|     actBossRebornSign = 0  | 
|     mapActBossRebornSign = 0  | 
|     # ¹ØÁªÈÕ³£»î¶¯  | 
|     if relatedType == 1:  | 
|         relatedID = int(relatedID)  | 
|         actionKey = ShareDefine.Def_Notify_WorldKey_DailyActionState % relatedID  | 
|         rebornBossState = 1 if gameWorldMgr.GetGameWorldDictByKey(actionKey) else 0  | 
|           | 
|     # ¹ØÁªÔËÓª»î¶¯£¬´ýÀ©Õ¹  | 
|     elif relatedType == 2:  | 
|         actNameInfo = relatedID.split("|")  | 
|         actName = actNameInfo[0]  | 
|         if actName in ShareDefine.MultiActNumOperationActNameList:  | 
|             actNum = GameWorld.ToIntDef(actNameInfo[1] if len(actNameInfo) > 1 else "10")  | 
|             actInfo = GameWorld.GetActInfo(actName, actNum)  | 
|             operationActionState = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|         else:  | 
|             operationActionInfo = PyGameData.g_operationActionDict.get(actName, {})  | 
|             operationActionState = operationActionInfo.get(ShareDefine.ActKey_State, 0)  | 
|         rebornBossState = 1 if operationActionState else 0  | 
|           | 
|     else:  | 
|         bosskey = ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID  | 
|         rebornBossState = gameWorldMgr.GetGameWorldDictByKey(bosskey)  | 
|           | 
|     activityLineID = 0 # »î¶¯Ïß, Ä¬ÈÏ1Ïß  | 
|     activityMapLineDict = IpyGameDataPY.GetFuncEvalCfg("MapLine", 2, {})  | 
|     if mapID in activityMapLineDict:  | 
|         activityLineID = max(0, activityMapLineDict[mapID] - 1)  | 
|           | 
|     # ¹ØÁª»î¶¯boss  | 
|     if relatedType:  | 
|         if assignLineID == 0: # Ã»ÓÐÖ¸¶¨Ë¢ÐÂÏß·µÄ£¬»î¶¯boss¹Ì¶¨Ë¢ÔڻÏß  | 
|             rebornLineID = activityLineID # »î¶¯bossֻˢÔڻÏß  | 
|               | 
|         # ²»ÊǻÏß   | 
|         if rebornBossState and lineID != rebornLineID:  | 
|             rebornBossState = 0  | 
|               | 
|         # ¹ØÁª»î¶¯bossÖ»Òª¸´»î±ê¼ÇÓëÉϴβ»Í¬£¬ÔòÇ¿ÖÆÖØÉú  | 
|         actBossRebornSign = gameWorldMgr.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ActionBossRebornSign % relatedID)  | 
|         mapActBossRebornSign = gameFB.GetGameFBDictByKey(ChConfig.Map_NPC_ActBossLastRebornSign % refreshMark)  | 
|         rebornBossState = rebornBossState and actBossRebornSign  | 
|         if rebornBossState and actBossRebornSign != mapActBossRebornSign:  | 
|             forceReborn = True  | 
|               | 
|     # ·Ç»î¶¯boss»î¶¯Ïß²»Ë¢, 1Ïß³ýÍâ  | 
|     else:  | 
|         if activityLineID and lineID == activityLineID:  | 
|             rebornBossState = 0  | 
|             stoneNPCID = 0 # »î¶¯ÏßÔݲ»Ë¢Ä¹±®  | 
|               | 
|     isNeedShunt = NPCCommon.IsMapNeedBossShunt(mapID) and isNeedShunt  | 
|       | 
|     curNPC = None  | 
|     if npcRefresh.GetCount() > 0:  | 
|         curNPC = npcRefresh.GetAt(0)  | 
|           | 
|     # ¸´»î״̬  | 
|     if rebornBossState:  | 
|         if curNPC:  | 
|             if not forceReborn and curNPC.GetNPCID() == bossID:  | 
|                 return  | 
|             #È¥µô·ÇbossNPC  | 
|             NPCCommon.SetDeadEx(curNPC)  | 
|               | 
|         # ·Ç¸´»îÏß ÇÒ ²»ÐèÒª·ÖÁ÷µÄµØÍ¼ ÇÒ ²»ÊÇ·âħ̳  ²»ÔÊÐí¸´»î  | 
|         if lineID != rebornLineID and not isNeedShunt and mapID not in [ChConfig.Def_FBMapID_SealDemon, ChConfig.Def_FBMapID_ZhuXianBoss]:  | 
|             return  | 
|           | 
|         if mapActBossRebornSign and actBossRebornSign == mapActBossRebornSign:  | 
|             #GameWorld.DebugLog("»î¶¯ÏßÒѾˢ¹ý²»ÔÙË¢»î¶¯boss: lineID=%s,rebornLineID=%s,refreshMark=%s,bossID=%s,actBossRebornSign=%s"   | 
|             #                   % (lineID, rebornLineID, refreshMark, bossID, actBossRebornSign))  | 
|             return  | 
|           | 
|     # ËÀÍö״̬  | 
|     else:  | 
|         if curNPC:  | 
|             # ·ÖÁ÷µÄboss  | 
|             if curNPC.GetNPCID() == bossID and isNeedShunt and IsShuntBossNeedProcess(curNPC):  | 
|                 return  | 
|             if curNPC.GetNPCID() == stoneNPCID:  | 
|                 return   | 
|             # »î¶¯µÄboss  | 
|             if curNPC.GetNPCID() == bossID and relatedType:  | 
|                 GameWorld.Log("»î¶¯boss£¬»î¶¯½áÊø£¬ÏµÍ³ÉèÖÃbossËÀÍö£¡bossID=%s" % bossID)  | 
|                 if relatedID == ShareDefine.DailyActionID_FamilyRobBoss:  | 
|                     PlayerControl.FBNotify("FairyGrabBossNoDead", [bossID])  | 
|                 elif relatedID == ShareDefine.OperationActionName_BossReborn:  | 
|                     pass  | 
|                   | 
|             #È¥µô·Çű®NPC  | 
|             NPCCommon.SetDeadEx(curNPC)  | 
|           | 
|         # ÑÓ³Ùˢű®  | 
|         bossDeadTick = gameFB.GetGameFBDictByKey(ChConfig.Map_NPC_WorldBossDeadTick % bossID)  | 
|         bossStoneDelayTime = IpyGameDataPY.GetFuncCfg('BossStoneDelayTime')  | 
|         if tick - bossDeadTick <= bossStoneDelayTime:  | 
|             return  | 
|         gameFB.SetGameFBDict(ChConfig.Map_NPC_WorldBossDeadTick % bossID, tick)  | 
|           | 
|     rebornNPCID = bossID if rebornBossState else stoneNPCID  | 
|     if not rebornNPCID:  | 
|         return  | 
|     key = ChConfig.Map_NPC_WorldBossLastReBornTick % rebornNPCID  | 
|     lastRebornTick = gameFB.GetGameFBDictByKey(key)  | 
|     if tick - lastRebornTick <= 50 * 1000:  | 
| #        GameWorld.DebugLog("BossRefresh mapID=%s,refreshMark=%s,rebornNPCID=%s,tick=%s,lastRebornTick=%s ²»Öظ´Ë¢Ð£¡"   | 
| #                         % (mapID,refreshMark, rebornNPCID, tick, lastRebornTick))  | 
|         return  | 
|          | 
|     npcRefresh.Refresh(rebornNPCID, ChConfig.Def_SuperBossAngryCount, 1, False)  | 
|     #³õʼ»¯NPC  | 
|     __InitNewBornNPC(npcRefresh, tick)  | 
|     gameFB.SetGameFBDict(key, tick)  | 
|       | 
|     if actBossRebornSign and rebornBossState:  | 
|         gameFB.SetGameFBDict(ChConfig.Map_NPC_ActBossLastRebornSign % refreshMark, actBossRebornSign)  | 
|           | 
|     GameWorld.DebugLog("BossRefresh mapID=%s,rebornLineID=%s,refreshMark=%s,rebornNPCID=%s,isNeedShunt=%s,OK!"   | 
|                        % (mapID, rebornLineID, refreshMark, rebornNPCID, isNeedShunt), lineID)  | 
|     return  | 
|   | 
| def IsShuntBossNeedProcess(curNPC):  | 
|     '''·ÖÁ÷bossÊÇ·ñÐèÒª´¦Àí  | 
|         ÎÞÉËѪ¡¢³ðºÞ¡¢Ã»ÈË¿´µ½Ëû¡¢Ëûû¿´µ½±ðÈË  | 
|     '''  | 
|     # ²ß»®ÔÝʱÐ޸ķÖÁ÷boss²»Í¬²½ËÀÍö  | 
|     return True  | 
| #    if curNPC.GetPlayerHurtList().GetHurtCount():  | 
| #        #GameWorld.DebugLog("·ÖÁ÷bossÓÐÉËѪ£¬²»¿ÉÒÔÇå³ý£¡npcID=%s" % curNPC.GetNPCID(), GameWorld.GetGameWorld().GetLineID())  | 
| #        return True  | 
| #      | 
| #    if curNPC.GetAttentionPlayersCount() or curNPC.GetInSightObjCount():  | 
| #        #GameWorld.DebugLog("·ÖÁ÷bossÓÐÈË¿´µ½£¬²»¿ÉÒÔÇå³ý£¡npcID=%s" % curNPC.GetNPCID(), GameWorld.GetGameWorld().GetLineID())  | 
| #        return True  | 
| #      | 
| #    GameWorld.DebugLog("·ÖÁ÷boss²»ÐèÒª´¦ÀíÁË£¬¿ÉÒÔÇå³ý£¡npcID=%s" % curNPC.GetNPCID(), GameWorld.GetGameWorld().GetLineID())  | 
| #    return False  | 
|   | 
| #===================================================================================================  | 
|   | 
| def __DoRefreshWorldBossCrossServer(npcRefresh, tick):  | 
|     ## ¿ç·þ·þÎñÆ÷Ë¢boss  | 
|       | 
|     mapID = GameWorld.GetGameWorld().GetMapID() # dataMapID  | 
|     if mapID not in ChConfig.Def_CrossMapIDList:  | 
|         return  | 
|       | 
|     refreshMark = npcRefresh.GetRefreshMark()  | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     realMapID = GameWorld.GetGameWorld().GetRealMapID()  | 
|     copyMapID = GameWorld.GetGameWorld().GetCopyMapID()  | 
|     relatedType, relatedID = 0, ""  | 
|       | 
|     if mapID == ChConfig.Def_FBMapID_CrossDemonKing:  | 
|         bossID = GameLogic_CrossDemonKing.GetCurFBLineBOSSID()  | 
|         stoneNPCID = 0  | 
|         zoneID = GameLogic_CrossDemonKing.GetCurFBLineZoneID()  | 
|           | 
|     else:  | 
|         bossIpyData = IpyGameDataPY.GetIpyGameDataByCondition('BOSSInfo', {'RefreshMark':refreshMark, 'MapID':mapID}, isLogNone=False)  | 
|         if not bossIpyData:  | 
|             return  | 
|           | 
|         stoneNPCID = bossIpyData.GetStoneNPCID()  | 
|         bossID = bossIpyData.GetNPCID()  | 
|         relatedType = bossIpyData.GetRelatedType()  | 
|         relatedID = bossIpyData.GetRelatedID()  | 
|           | 
|         if mapID not in ChConfig.Def_CrossZoneMapTableName:  | 
|             return  | 
|         tableName = ChConfig.Def_CrossZoneMapTableName[mapID]  | 
|         zoneIpyData = IpyGameDataPY.GetIpyGameDataNotLog(tableName, realMapID, mapID, copyMapID)  | 
|         if not zoneIpyData:  | 
|             return  | 
|         zoneID = zoneIpyData.GetZoneID()  | 
|           | 
|     if not zoneID:  | 
|         return  | 
|     if not bossID and not stoneNPCID:  | 
|         return  | 
|       | 
|     gameFB = GameWorld.GetGameFB()  | 
|     gameWorldMgr = GameWorld.GetGameWorld()  | 
|     forceReborn = False # Ç¿ÖÆÖØÉú  | 
|     actBossRebornSign = 0  | 
|     mapActBossRebornSign = 0  | 
|       | 
|     # ¹ØÁªÈÕ³£»î¶¯  | 
|     if relatedType == 1:  | 
|         relatedID = int(relatedID)  | 
|         actionKey = ShareDefine.Def_Notify_WorldKey_CrossDailyActionState % relatedID  | 
|         rebornBossState = 1 if gameWorldMgr.GetGameWorldDictByKey(actionKey) else 0  | 
|               | 
|     # ¹ØÁªÔËÓª»î¶¯£¬´ýÀ©Õ¹  | 
|     elif relatedType == 2:  | 
|         pass  | 
|       | 
|     else:  | 
|         bosskey = ShareDefine.Def_Notify_WorldKey_GameWorldBossRebornCross % (zoneID, bossID)  | 
|         rebornBossState = GameWorld.GetGameWorld().GetGameWorldDictByKey(bosskey)  | 
|           | 
|     # ¹ØÁª»î¶¯boss  | 
|     if relatedType:  | 
|         # ¹ØÁª»î¶¯bossÖ»Òª¸´»î±ê¼ÇÓëÉϴβ»Í¬£¬ÔòÇ¿ÖÆÖØÉú  | 
|         actBossRebornSign = gameWorldMgr.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ActionBossRebornSign % relatedID)  | 
|         mapActBossRebornSign = gameFB.GetGameFBDictByKey(ChConfig.Map_NPC_ActBossLastRebornSign % refreshMark)  | 
|         rebornBossState = rebornBossState and actBossRebornSign  | 
|         if rebornBossState and actBossRebornSign != mapActBossRebornSign:  | 
|             forceReborn = True  | 
|               | 
|     curNPC = None  | 
|     if npcRefresh.GetCount() > 0:  | 
|         curNPC = npcRefresh.GetAt(0)  | 
|           | 
|     # ¸´»î״̬  | 
|     if rebornBossState:  | 
|         if curNPC:  | 
|             if not forceReborn and curNPC.GetNPCID() == bossID:  | 
|                 return  | 
|             #È¥µô·ÇbossNPC  | 
|             NPCCommon.SetDeadEx(curNPC)  | 
|               | 
|         if mapActBossRebornSign and actBossRebornSign == mapActBossRebornSign:  | 
|             #GameWorld.DebugLog("»î¶¯ÏßÒѾˢ¹ý²»ÔÙË¢»î¶¯boss: lineID=%s,refreshMark=%s,bossID=%s,actBossRebornSign=%s"   | 
|             #                   % (lineID, refreshMark, bossID, actBossRebornSign))  | 
|             return  | 
|           | 
|     # ËÀÍö״̬  | 
|     else:  | 
|         if curNPC:  | 
|             if curNPC.GetNPCID() == stoneNPCID:  | 
|                 return  | 
|             #È¥µô·Çű®NPC  | 
|             NPCCommon.SetDeadEx(curNPC)  | 
|               | 
|         # ÑÓ³Ùˢű®  | 
|         bossDeadTick = gameFB.GetGameFBDictByKey(ChConfig.Map_NPC_WorldBossDeadTick % bossID)  | 
|         bossStoneDelayTime = IpyGameDataPY.GetFuncCfg('BossStoneDelayTime')  | 
|         if tick - bossDeadTick <= bossStoneDelayTime:  | 
|             return  | 
|         gameFB.SetGameFBDict(ChConfig.Map_NPC_WorldBossDeadTick % bossID, tick)  | 
|           | 
|     rebornNPCID = bossID if rebornBossState else stoneNPCID  | 
|     if not rebornNPCID:  | 
|         return  | 
|     rebornTickKey = ChConfig.Map_NPC_WorldBossLastReBornTick % rebornNPCID  | 
|     lastRebornTick = gameFB.GetGameFBDictByKey(rebornTickKey)  | 
|     if tick - lastRebornTick <= 50 * 1000:  | 
|         GameWorld.DebugLog("CrossBossRefresh mapID=%s,realMapID=%s,copyMapID=%s,refreshMark=%s,rebornNPCID=%s,tick=%s,lastRebornTick=%s ²»Öظ´Ë¢Ð£¡"   | 
|                            % (mapID, realMapID, copyMapID, refreshMark, rebornNPCID, tick, lastRebornTick))  | 
|         return  | 
|       | 
|     npcRefresh.Refresh(rebornNPCID, ChConfig.Def_SuperBossAngryCount, 1, False)  | 
|     #³õʼ»¯NPC  | 
|     __InitNewBornNPC(npcRefresh, tick)  | 
|     gameFB.SetGameFBDict(rebornTickKey, tick)  | 
|       | 
|     if actBossRebornSign and rebornBossState:  | 
|         gameFB.SetGameFBDict(ChConfig.Map_NPC_ActBossLastRebornSign % refreshMark, actBossRebornSign)  | 
|           | 
|     GameWorld.DebugLog("CrossBossRefresh mapID=%s,realMapID=%s,copyMapID=%s,refreshMark=%s,rebornNPCID=%s,OK!"   | 
|                        % (mapID, realMapID, copyMapID, refreshMark, rebornNPCID), lineID)  | 
|     return  | 
|   | 
| ################################ Í¨ÓÃË¢¹ÖÂß¼ ####################################  | 
| def GetNPCRefreshCountList(refreshID):  | 
|     ## »ñȡˢ¹Ö±êʶµã¹æÔòIDÐèҪˢеÄNPC¸öÊýÐÅÏ¢£»  | 
|     ## ¸Ãº¯ÊýÖ»ÊÊÓÃÓڹ̶¨Ë¢¹ÖµÄ¹æÔò  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("NPCCustomRefresh", refreshID)  | 
|     if not ipyData:  | 
|         return  | 
|     npcID = ipyData.GetRefreshNPCID()  | 
|     if npcID:  | 
|         return [(npcID, ipyData.GetTotalMaxCount())]  | 
|     npcCountList = ipyData.GetNPCIDCountList()  | 
|     if npcCountList:  | 
|         return npcCountList  | 
|     return  | 
|   | 
| def SetNPCRefreshByID(refreshID, angry=ChConfig.Def_NormalNPCAngryCount, isStart=True, refreshRightNow=True):  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("NPCCustomRefresh", refreshID)  | 
|     if not ipyData:  | 
|         return  | 
|     rMarkList = ipyData.GetRefreshMarkInfo()  | 
|     npcID = ipyData.GetRefreshNPCID()  | 
|     npcIDList = []  | 
|     if npcID:  | 
|         npcIDList = [npcID]  | 
|     else:  | 
|         randNPCIDList = ipyData.GetRandNPCIDList()  | 
|         npcCountList = ipyData.GetNPCIDCountList()  | 
|         if randNPCIDList:  | 
|             npcIDList = randNPCIDList  | 
|         elif npcCountList:  | 
|             npcIDList = npcCountList  | 
|               | 
|     if not npcIDList:  | 
|         GameWorld.ErrLog("Ë¢¹Ö±êÊÔµãûÓÐÅäÖÃҪˢеÄNPCIDÐÅÏ¢£¡ID=%s" % refreshID)  | 
|         return  | 
|       | 
|     # ±êʶµãËæ»ú  | 
|     rMark = None  | 
|     if len(rMarkList) > 1:  | 
|         gameFB = GameWorld.GetGameFB()  | 
|         for _ in xrange(100):  | 
|             randMark = random.choice(rMarkList)  | 
|             if not gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCID % (randMark, 0)):  | 
|                 rMark = randMark  | 
|                 #GameWorld.DebugLog("Ëæ»ú±êʶµãË¢¹Ö¹æÔò: ID=%s,rMark=%s,rMarkList=%s" % (refreshID, rMark, rMarkList))  | 
|                 break  | 
|     else:  | 
|         rMark = rMarkList[0]  | 
|         #GameWorld.DebugLog("¹Ì¶¨±êʶµãË¢¹Ö¹æÔò: ID=%s,rMark=%s" % (refreshID, rMark))  | 
|           | 
|     if rMark == None:  | 
|         GameWorld.ErrLog("ÎÞ·¨»ñµÃÖ¸¶¨µÄË¢¹Ö±êÊԵ㣡refreshID=%s" % refreshID)  | 
|         return  | 
|       | 
|     SetNPCRefresh(rMark, npcIDList, ipyData.GetMaxCount(), ipyData.GetTotalMaxCount(), angry, isStart,   | 
|                   ipyData.GetIsLineOneOnly(), ipyData.GetIsRepeat(), ipyData.GetRefreshTick(), refreshRightNow)  | 
|     return  | 
|   | 
| ## ÉèÖÃͨÓÃË¢¹ÖÐÅÏ¢  | 
| #  @param rMark Ë¢¹Ö±êʶµã  | 
| #  @param npcIDList npcIDÁбí, Ö§³ÖÁ½ÖÖģʽ: Ëæ»ú[npcID,npcID,...] »ò Ö¸¶¨[(npcID,¸öÊý),(npcID,¸öÊý),...]  | 
| #  @param maxCnt µ±Ç°µã×î´ó¹ÖÎïÊý, Ä¬ÈÏË¢1Ö»  | 
| #  @param totalMaxCnt ×Ü×î´ó¹ÖÎïÊý, Ä¬ÈÏË¢1Ö», Í¬Ò»ÕŵØÍ¼Í¬Ò»±êʶµã¿ÉÄÜÓжà¸ö; µ±Ñ»·Ë¢¹Öʱ£¬¸ÃÖµÎÞÓã¬Ö»Í¨¹ýÿ¸öµãµÄ×î´ó¹ÖÎïÊý¿ØÖÆ  | 
| #  @param angry ¹ÖÎï³ðºÞÖµ£¬Ä¬ÈÏÆÕͨNPC³ðºÞ  | 
| #  @param isStart ÊÇ·ñÂíÉÏ¿ªÆôË¢¹Ö  | 
| #  @param isLineOneOnly ÊÇ·ñ½öÔÚÒ»ÏßË¢¹Ö  | 
| #  @param isRepeat ÊÇ·ñÑ»·Ë¢¹Ö(·ÇÑ»·Ë¢¹ÖʱÔÚË¢¹Öµã¹ÖÎïÊý´ïµ½×î´óʱ»á×Ô¶¯¹Ø±ÕË¢¹Ö)  | 
| #  @param refreshTick Ë¢¹Ö¼ä¸ô  | 
| #  @param refreshRightNow ÊÇ·ñÂíÉÏ´¥·¢Ë¢¹ÖÂß¼  | 
| #  @param isForceRefresh Ç¿ÖƵãList£¬Îª¿ÕʱÕý³£Ë¢¹Ö¡£[rMark1, rMark2,...]  | 
| #  @return None  | 
| def SetNPCRefresh(rMark, npcIDList, maxCnt=1, totalMaxCnt=1, angry=ChConfig.Def_NormalNPCAngryCount,  | 
|                   isStart=True, isLineOneOnly=False, isRepeat=False, refreshTick=0, refreshRightNow=True, isForceRefreshList=[]):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     if not isinstance(npcIDList, list):  | 
|         return  | 
|       | 
|     pointCnt = len(isForceRefreshList)  | 
|     if pointCnt > 0:  | 
|         gameNPC = GameWorld.GetNPCManager()  | 
|         recordPointList = []  | 
|         for i in range(0, gameNPC.GetCustomNPCRefreshCount()):  | 
|             npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)  | 
|             if npcRefresh.GetRefreshMark() in isForceRefreshList:  | 
|                 recordPointList.append(i)  | 
|         totalCnt = len(recordPointList)  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_TotalForcePointCnt, totalCnt)  | 
|         for index, pointIndex in enumerate(recordPointList):  | 
|             gameFB.SetGameFBDict(ChConfig.Def_RMark_ForceRefreshPoint % index, pointIndex)  | 
|               | 
|   | 
|     npcIDLen = len(npcIDList)  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_NPCListLen % rMark, npcIDLen)  | 
|     for i, npcInfo in enumerate(npcIDList):  | 
|         if isinstance(npcInfo, int):  | 
|             npcID = npcInfo  | 
|             npcCnt = 0 # ´ú±íËæ»ú  | 
|         else:  | 
|             npcID, npcCnt = npcInfo  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_NPCID % (rMark, i), npcID)  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_NPCIDCnt % (rMark, i), npcCnt)  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_MaxCnt % rMark, maxCnt)  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_TotalMaxCnt % rMark, totalMaxCnt)  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_RefreshCnt % rMark, 0)  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_AngryCount % rMark, angry)  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_LineOneOnly % rMark, int(isLineOneOnly))  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_RefreshTick % rMark, refreshTick)  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_IsRepeat % rMark, int(isRepeat))  | 
|     if isStart:  | 
|         StartNPCRefresh(rMark)  | 
|     GameWorld.Log("ÉèÖñêʶµãÐÅÏ¢£ºmark=%s,npcList=%s,max=%s,tMax=%s,angry=%s,start=%s,lineOneOnly=%s,repeat=%s,refreshTick=%s,refreshRightNow=%s"   | 
|                   % (rMark, npcIDList, maxCnt, totalMaxCnt, angry, isStart, isLineOneOnly, isRepeat, refreshTick, refreshRightNow))  | 
|       | 
|     if isStart and refreshRightNow:  | 
|         tick = GameWorld.GetGameWorld().GetTick()  | 
|         ProcessAllNPCRefresh(tick)  | 
|     return  | 
|   | 
| ## ¿ªÆôͨÓÃNPCË¢¹Ö  | 
| #  @param rMark Ë¢¹Ö±êʶµã  | 
| #  @return None  | 
| def StartNPCRefresh(rMark):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_State % rMark, 1)  | 
|     return  | 
|   | 
| ## ¹Ø±ÕͨÓÃNPCË¢¹Ö  | 
| #  @param rMark Ë¢¹Ö±êʶµã  | 
| #  @return None  | 
| def CloseNPCRefresh(rMark, tick):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     if not gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_State % rMark):  | 
|         return  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_State % rMark, 0)  | 
|     FBLogic.OnCloseNPCRefresh(rMark, tick)  | 
|     GameWorld.DebugLog("CloseNPCRefresh rMark=%s" % rMark)  | 
|     return  | 
|   | 
| ## ¹Ø±Õ¸±±¾ËùÓÐͨÓÃNPCË¢¹Ö  | 
| def CloseFBCustomRefresh(tick):  | 
|     gameNPC = GameWorld.GetNPCManager()  | 
|     for i in xrange(gameNPC.GetCustomNPCRefreshCount()):  | 
|         npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)  | 
|         CloseNPCRefresh(npcRefresh.GetRefreshMark(), tick)  | 
|     return  | 
|   | 
| ## »ñÈ¡ÒѾˢеĹÖÎïÊý  | 
| def GetHadRefreshCnt(rMark):  | 
|     return GameWorld.GetGameFB().GetGameFBDictByKey(ChConfig.Def_RMark_RefreshCnt % rMark)  | 
|   | 
| ## Í¨ÓñêʶµãË¢¹ÖÂß¼  | 
| #  @param npcRefresh Ë¢ÐÂʵÀý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def __NPCCommonRefresh(pointIndex, npcRefresh, tick):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     rMark = npcRefresh.GetRefreshMark()  | 
|       | 
|     rMarkStateKey = ChConfig.Def_RMark_State % rMark  | 
|     # Ë¢¹ÖÊÇ·ñ¿ªÆô  | 
|     if gameFB.GetGameFBDictByKey(rMarkStateKey) == 0:  | 
|         return  | 
|       | 
|     # Ö»ÔÚÒ»ÏßË¢  | 
|     isLineOneOnlyKey = ChConfig.Def_RMark_LineOneOnly % rMark  | 
|     if gameFB.GetGameFBDictByKey(isLineOneOnlyKey) and GameWorld.GetGameWorld().GetLineID() != 0:  | 
|         return  | 
|       | 
|     refreshTick = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_RefreshTick % rMark)  | 
|     curMaxCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_MaxCnt % rMark)  | 
|     totalMaxCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_TotalMaxCnt % rMark)  | 
|     refreshCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_RefreshCnt % rMark)  | 
|     npcListLen = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCListLen % rMark)  | 
|     angryCount = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_AngryCount % rMark)  | 
|     isRepeat = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_IsRepeat % rMark)  | 
|     totalForceCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_TotalForcePointCnt)  | 
|     isForce = totalForceCnt > 0  | 
|     if npcListLen <= 0:  | 
|         return  | 
|     indexList = []  | 
|     # ÐèÒª²¹³ä¶àÉÙnpc  | 
|     needNPCCnt = curMaxCnt - npcRefresh.GetCount()  | 
|     if not isRepeat:  | 
|         needNPCCnt = min(needNPCCnt, totalMaxCnt - refreshCnt)  | 
|     if isForce:  | 
|         for index in xrange(totalForceCnt):  | 
|             indexList.append(gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_ForceRefreshPoint % index))  | 
|         if pointIndex in indexList:  | 
|             needNPCCnt = curMaxCnt  | 
|               | 
|     if needNPCCnt <= 0:  | 
|         if npcRefresh.GetRefreshTick() != 1:  | 
|             npcRefresh.SetRefreshTick(1)  | 
|         return  | 
|       | 
|     # npcËÀºó²Å¿ªÊ¼¼ÆÊ±  | 
|     lastRefreshTick = npcRefresh.GetRefreshTick()  | 
|     if lastRefreshTick == 1:  | 
|         npcRefresh.SetRefreshTick(tick)  | 
|     needSyc = False     | 
|     # µÚÒ»´ÎûÓÐË¢¹Ö¼ä¸ôÏÞÖÆ  | 
|     if lastRefreshTick > 0 and tick - npcRefresh.GetRefreshTick() < refreshTick * 1000:  | 
|         #²»ÊÇÇ¿ÖÆË¢Ð²»´¦Àí  | 
|         if isForce and pointIndex in indexList\  | 
|             and npcRefresh.GetCount() == 0 and gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_HasRefreshPoint % pointIndex) == 0:  | 
|             gameFB.SetGameFBDict(ChConfig.Def_RMark_HasRecordPoint % pointIndex, 1)  | 
|             for point in indexList:  | 
|                 mark = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_HasRecordPoint % point)  | 
|                 if not mark:  | 
|                     return  | 
|                 GameWorld.DebugLog("ͨ¹ý£¡£¡£¡£¡---%s--mark:%s"%(point,mark))  | 
|             gameFB.SetGameFBDict(ChConfig.Def_RMark_HasRefreshPoint % pointIndex, 1)  | 
|             passCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_PassCnt) + 1  | 
|             gameFB.SetGameFBDict(ChConfig.Def_RMark_PassCnt, passCnt)  | 
|             if passCnt == len(indexList):  | 
|                 for point2 in indexList:  | 
|                     gameFB.SetGameFBDict(ChConfig.Def_RMark_PassCnt, 0)  | 
|                     gameFB.SetGameFBDict(ChConfig.Def_RMark_HasRecordPoint % point2, 0)  | 
|                     gameFB.SetGameFBDict(ChConfig.Def_RMark_HasRefreshPoint % point2, 0)  | 
|                     needSyc = True  | 
|         else:  | 
|             return  | 
|     elif isForce:  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_PassCnt, 0)  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_HasRecordPoint % pointIndex, 0)  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_HasRefreshPoint % pointIndex, 0)  | 
|         timePassCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_TimePassCnt) + 1  | 
|         if timePassCnt == len(indexList):  | 
|             gameFB.SetGameFBDict(ChConfig.Def_RMark_TimePassCnt, 0)  | 
|             needSyc = True  | 
|         else:  | 
|             gameFB.SetGameFBDict(ChConfig.Def_RMark_TimePassCnt, timePassCnt)  | 
|               | 
|     if needSyc:  | 
|         refresh = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_RefreshStep) + 1  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_RefreshStep, refresh)  | 
|         FBLogic.OnPointRefresh(refresh,tick)  | 
|                   | 
|     npcID = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCID % (rMark, 0))  | 
|     npcCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCIDCnt % (rMark, 0))  | 
|     # Ö¸¶¨NPC¼°Ö»Êý  | 
|     if npcCnt > 0:  | 
|         for i in xrange(npcListLen):  | 
|             npcID = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCID % (rMark, i))  | 
|             npcCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCIDCnt % (rMark, i))  | 
|             if npcID <= 0:  | 
|                 continue  | 
|             GameWorld.DebugLog("Ö¸¶¨Ë¢¹Ö£ºrMark=%s,npcID=%s,angryCount=%s,refreshCnt=%s"   | 
|                                % (rMark, npcID, angryCount, npcCnt))  | 
|             npcRefresh.Refresh(npcID, angryCount, npcCnt, False)  | 
|             __InitNewBornNPC(npcRefresh , tick)  | 
|             refreshCnt += npcCnt  | 
|           | 
|     elif npcListLen > 1:  | 
|         for i in xrange(needNPCCnt):  | 
|             npcIndex = random.randint(0, npcListLen - 1)  | 
|             npcID = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCID % (rMark, npcIndex))  | 
|             if npcID <= 0:  | 
|                 continue  | 
|             GameWorld.DebugLog("Ëæ»úË¢¹Ö£ºrMark=%s,npcID=%s,angryCount=%s,refreshCnt=%s"   | 
|                                % (rMark, npcID, angryCount, 1))  | 
|             npcRefresh.Refresh(npcID, angryCount, 1, False)  | 
|             __InitNewBornNPC(npcRefresh , tick)  | 
|             refreshCnt += 1  | 
|     else:  | 
|         npcID = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_NPCID % (rMark, 0))  | 
|         if not npcID:  | 
|             return  | 
|         GameWorld.DebugLog("µ¥Ö»Ë¢¹Ö£ºrMark=%s,npcID=%s,angryCount=%s,refreshCnt=%s"   | 
|                            % (rMark, npcID, angryCount, needNPCCnt))  | 
|         npcRefresh.Refresh(npcID, angryCount, needNPCCnt, False)  | 
|         __InitNewBornNPC(npcRefresh , tick)  | 
|         refreshCnt += needNPCCnt  | 
|           | 
|     # ³õʼ»¯NPC  | 
|       | 
|     if not isRepeat:  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_RefreshCnt % rMark, refreshCnt)  | 
|       | 
|     # ·ÇÑ»·Ë¢¹ÖµÄ£¬Ë¢Íê¹Öºó¹Ø±ÕË¢¹Ö  | 
|       | 
|     GameWorld.DebugLog("ÒÑˢйÖÎï=%s,total=%s" % (refreshCnt, totalMaxCnt))  | 
|     if refreshCnt >= totalMaxCnt and not isRepeat:  | 
|         CloseNPCRefresh(rMark, tick)  | 
|     return  | 
|   | 
| ################################################################################  | 
|   | 
| def ProcessMapRandomRefreshNPC(gameWorld, tick):  | 
|     ''' µØÍ¼×Ô¶¨ÒåËæ»úË¢¹Ö£¬Ö§³Ö¶àµãËæ»úË¢¶àÖÖ¹Ö£¬±êÊԵ㲻¿ÉÖØ¸´£¬Ö§³Ö¿ç·þµØÍ¼  | 
|             ×¢Ò⣺ͬ¸öÐéÄâÏß·ÖУ¬±êÊԵ㲻¿ÉÖØ¸´£¡±êÊԵ㲻¿ÉÖØ¸´£¡±êÊԵ㲻¿ÉÖØ¸´£¡  | 
|     '''  | 
|     if gameWorld.GetOpenState() != IPY_GameWorld.fbosOpen:  | 
|         #ÒѾ¹Ø±ÕÁË  | 
|         return  | 
|     mapID = gameWorld.GetMapID()  | 
|     refreshIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("MapRefreshNPC", mapID)  | 
|     if not refreshIpyDataList:  | 
|         return  | 
|       | 
|     #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)  | 
|       | 
|     serverTime = GameWorld.GetCurrentTime()  | 
|     curHour, curMinute = serverTime.hour, serverTime.minute  | 
|     minuteTotal = curHour * 60 + curMinute  | 
|     needRefreshIpyDataList = []  | 
|     for ipyData in refreshIpyDataList:  | 
|         num = ipyData.GetRefreshNum()  | 
|         numLastTick = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_RandomRefreshNPCNumTime % num)  | 
|         if numLastTick:  | 
|             perMinutes = ipyData.GetRefreshPerMinutes()  | 
|             if perMinutes:  | 
|                 if minuteTotal % perMinutes != 0:  | 
|                     continue  | 
|                 refreshCD = 60 # 1·ÖÖÓÄÚ²»Öظ´Ë¢Ð  | 
|             else:  | 
|                 refreshCD = ipyData.GetRefreshSeconds()  | 
|                   | 
|             if not refreshCD:  | 
|                 continue  | 
|             if tick - numLastTick < refreshCD * 1000:  | 
|                 continue  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_RandomRefreshNPCNumTime % num, tick)  | 
|         needRefreshIpyDataList.append(ipyData)  | 
|           | 
|     if not needRefreshIpyDataList:  | 
|         #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("±êÊÔµã¹ÖÎïÊý: minuteTotal=%s,npcCountDict=%s" % (minuteTotal, npcCountDict), copyMapID)  | 
|     for ipyData in needRefreshIpyDataList:  | 
|         npcIDList = ipyData.GetNPCIDList()  | 
|         markList = ipyData.GetRefreshMarkList()  | 
|         maxCount = ipyData.GetPointMaxCount()  | 
|         totalMaxCount = ipyData.GetTotalMaxCount()  | 
|           | 
|         curTotalCount = 0  | 
|         for rMark in markList:  | 
|             curTotalCount += npcCountDict.get(rMark, 0)  | 
|               | 
|         refreshCount = totalMaxCount - curTotalCount  | 
|           | 
|         #GameWorld.DebugLog("    npcIDList=%s,markList=%s,curTotalCount=%s,totalMaxCount=%s,refreshCount=%s"   | 
|         #                   % (npcIDList, markList, curTotalCount, totalMaxCount, refreshCount), copyMapID)  | 
|         if refreshCount <= 0:  | 
|             continue  | 
|           | 
|         isNeedRandom = len(markList) != totalMaxCount  | 
|         if isNeedRandom:  | 
|             markList = list(markList)  | 
|             random.shuffle(markList) # Ëæ»ú´òÂÒ˳Ðò£¬Èç¹ûÐèÒªËæ»úµÄ»°¾ÍÓöà¸ö²»Í¬µÄ±êÊ﵋  | 
|         #GameWorld.DebugLog("    markList=%s" % str(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  | 
|   | 
| def GetCopyMapRandomRefreshNPCInfo():  | 
|     ## »ñÈ¡µ±Ç°ÐéÄâÏßÂ·Ëæ»úË¢¹ÖµãNPCÐÅÏ¢  | 
|       | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     mapID = gameWorld.GetMapID()  | 
|     refreshIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("MapRefreshNPC", mapID)  | 
|     if not refreshIpyDataList:  | 
|         return  | 
|       | 
|     lastRefreshTickDict = {}  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     for ipyData in refreshIpyDataList:  | 
|         num = ipyData.GetRefreshNum()  | 
|         lastRefreshTickDict[num] = gameFB.GetGameFBDictByKey(ChConfig.Def_RMark_RandomRefreshNPCNumTime % num)  | 
|           | 
|     markNPCDict = {}  # ±êʶµã¶ÔÓ¦NPCÊýÁ¿  | 
|     gameNPC = GameWorld.GetNPCManager()  | 
|     for i in xrange(gameNPC.GetCustomNPCRefreshCount()):  | 
|         npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)  | 
|         npcCount = npcRefresh.GetCount()  | 
|         if not npcCount:  | 
|             continue  | 
|           | 
|         rMark = npcRefresh.GetRefreshMark()  | 
|         npcIDCountDict = {}  | 
|         for j in xrange(npcCount):  | 
|             curNPC = npcRefresh.GetAt(j)  | 
|             npcID = curNPC.GetNPCID()  | 
|             npcIDCountDict[npcID] = npcIDCountDict.get(npcID, 0) + 1  | 
|         markNPCDict[rMark] = npcIDCountDict  | 
|     return lastRefreshTickDict, markNPCDict  | 
|   | 
| def OnFBOpenSetRandomRefreshNPCInfo(refreshNPCInfo, tick):  | 
|     ## ¸±±¾ÐéÄâÏß·Æô¶¯Ê±£¬¸ù¾Ý±£´æµÄ±êÊÔµãË¢¹ÖÐÅÏ¢ÉèÖÃË¢¹Ö  | 
|     lastRefreshTickDict, markNPCDict = refreshNPCInfo  | 
|           | 
|     gameFB = GameWorld.GetGameFB()  | 
|     gameFB.SetGameFBDict(ChConfig.Def_RMark_RandomRefreshNPCTick, tick)  | 
|     for num, setTick in lastRefreshTickDict.items():  | 
|         gameFB.SetGameFBDict(ChConfig.Def_RMark_RandomRefreshNPCNumTime % num, setTick)  | 
|           | 
|     gameNPC = GameWorld.GetNPCManager()  | 
|     for i in xrange(gameNPC.GetCustomNPCRefreshCount()):  | 
|         npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)  | 
|         rMark = npcRefresh.GetRefreshMark()  | 
|         if rMark not in markNPCDict:  | 
|             continue  | 
|         npcIDCountDict = markNPCDict[rMark]  | 
|         for npcID, count in npcIDCountDict.items():  | 
|             GameWorld.DebugLog("    ¸±±¾Æô¶¯Ë¢¹Ö: rMark=%s,npcID=%s,count=%s" % (rMark, npcID, count))  | 
|             npcRefresh.Refresh(npcID, ChConfig.Def_NormalNPCAngryCount, count, False)  | 
|             __InitNewBornNPC(npcRefresh , tick)  | 
|               | 
|     return  |