8533 【BT】【后端】宗门试炼助战修(增加可配置至多机器人人数、是否出现非社交关系玩家)
2个文件已修改
35 ■■■■ 已修改文件
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFBHelpBattle.py
@@ -243,9 +243,11 @@
    
    onlyFree = False
    goldCallCount = 0
    nowFreeRelationCount, nowRelationCount = 0, 0
    nowFreeRelationCount, nowRelationCount, nowRobotCount = 0, 0, 0
    atleastFreeRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 1) # 至少免费社交人数,无社交则忽略
    atleastRelationCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 2) # 至少社交人数,无社交则忽略(人数包含免费社交人数)
    atmostRobotCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 3) # 助战列表机器人至多数量
    allowNoRelation = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 4) # 助战列表是否出现非社交关系玩家
    GameWorld.DebugLog("    atleastFreeRelationCount=%s,atleastRelationCount=%s" % (atleastFreeRelationCount, atleastRelationCount))
    
    #已经召唤的保留
@@ -263,6 +265,7 @@
                    nowFreeRelationCount += 1
        # 机器人NPC
        elif 1 <= calledPlayerID <= MaxRobotID:
            nowRobotCount += 1
            helpBattlePlayerDict[calledPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, job)
        else:
            GameWorld.ErrLog("已召唤的助战玩家找不到镜像缓存!理论上不存在该情况,镜像缓存释放会比登记有效时长多半小时!")
@@ -280,6 +283,10 @@
    checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
    random.shuffle(checkInPlayerIDList)
    GameWorld.Log("    登记助战人数=%s" % (len(checkInPlayerIDList)), playerID)
    if not allowNoRelation:
        atleastRelationCount = maxHelpPlayerSelectCount
        GameWorld.DebugLog("不允许出现非社交人数,默认设置至少社交人数为最大可选择人数! %s" % atleastRelationCount)
    
    # 1. 至少社交关系人数还不足的,先处理至少社交关系人数
    if nowRelationCount < atleastRelationCount:
@@ -329,6 +336,7 @@
                    __AddHelpPlayer(curPlayer, helpBattlePlayer, helpBattlePlayerDict, needGoldCall, goldCallCount, nowRelationCount, nowFreeRelationCount)
    
    # 2. 常规添加助战人数        
    if allowNoRelation:
    for checkInPlayerID in checkInPlayerIDList:
        if len(helpBattlePlayerDict) >= maxHelpPlayerSelectCount:
            GameWorld.DebugLog("    超过最大个数了不处理, checkInPlayerID=%s" % checkInPlayerID)
@@ -346,11 +354,12 @@
    openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # 开放的职业
    lackCount = maxHelpPlayerSelectCount - len(helpBattlePlayerDict)
    robotID = 0 # 机器人NPC定义ID从1开始
    while lackCount > 0 and robotID < MaxRobotID:
    while lackCount > 0 and robotID < MaxRobotID and nowRobotCount < atmostRobotCount:
        robotID += 1
        if robotID in helpBattlePlayerDict:
            continue
        lackCount -= 1
        nowRobotCount += 1
        randJob = random.choice(openJobList)
        helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
    
@@ -473,6 +482,9 @@
    checkInValidHours = IpyGameDataPY.GetFuncCfg("HelpBattleCheckIn", 1) # 登记有效时长,小时
    checkInValidSeconds = checkInValidHours * 3600
    
    atmostRobotCount = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 3) # 助战列表机器人至多数量
    allowNoRelation = IpyGameDataPY.GetFuncCfg("HelpBattleCall2", 4) # 助战列表是否出现非社交关系玩家
    onlyFree = True
    checkInPlayerIDList = PyGameData.g_fbHelpBattleCheckInPlayerDict.keys()
    random.shuffle(checkInPlayerIDList) # 刷新纯随机
@@ -486,19 +498,23 @@
                                                   checkInValidSeconds, curTime, helpCountKey, dayFreeHelpCount, onlyFree)
        if not canHelp:
            continue
        helpBattlePlayer.todayHelpCountDict[helpCountKey] = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
        relation = __GetHelpBattleRelation(curPlayer, helpBattlePlayer)
        if not allowNoRelation and not relation:
            continue
        helpBattlePlayer.todayHelpCountDict[helpCountKey] = helpBattlePlayer.todayHelpCountDict.get(helpCountKey, 0) + 1
        helpBattlePlayerDict[checkInPlayerID] = __GetNotifyMapServerHelpPlayerInfoDict(helpBattlePlayer, needGoldCall, helpBattlePlayer.job, relation)
        
    nowRobotCount = 0
    # 不足的机器人NPC补足
    openJobList = IpyGameDataPY.GetFuncEvalCfg("OpenJob", 1) # 开放的职业
    lackCount = maxHelpPlayerCount - len(helpBattlePlayerDict)
    robotID = 0 # 机器人NPC定义ID从1开始
    while lackCount > 0 and robotID < MaxRobotID:
    while lackCount > 0 and robotID < MaxRobotID and nowRobotCount < atmostRobotCount:
        robotID += 1
        if robotID in helpBattlePlayerDict:
            continue
        lackCount -= 1
        nowRobotCount += 1
        randJob = random.choice(openJobList)
        helpBattlePlayerDict[robotID] = __GetNotifyMapServerHelpPlayerInfoDict(None, False, randJob)
    
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GameWorldLogic/FBProcess/FBHelpBattle.py
@@ -178,10 +178,11 @@
            for robotID in helpNPCRobotIDList[:lackCount]:
                calledPlayerDict[robotID] = 0     
                
        if calledCount + len(calledPlayerDict) < maxHelpPlayerCount:
            GameWorld.ErrLog("无法一键召唤!人数不足! calledCount=%s,calledPlayerDict=%s,maxHelpPlayerCount=%s"
                             % (calledCount, calledPlayerDict, maxHelpPlayerCount), playerID)
            return
# 修改了规则,无社交人数及机器人人数做了限制,所以可能出现人数不足的情况,故屏蔽此判断
#        if calledCount + len(calledPlayerDict) < maxHelpPlayerCount:
#            GameWorld.ErrLog("无法一键召唤!人数不足! calledCount=%s,calledPlayerDict=%s,maxHelpPlayerCount=%s"
#                             % (calledCount, calledPlayerDict, maxHelpPlayerCount), playerID)
#            return
    else:
        if calledPlayerID not in helpBattlePlayerDict:
            GameWorld.ErrLog("不存在该助战玩家,无法召唤!calledPlayerID=%s" % (calledPlayerID), playerID)
@@ -241,7 +242,7 @@
        NetPackCommon.SendFakePack(curPlayer, callResultPack)
        
    # 召唤满后
    if calledCount >= maxHelpPlayerCount:
    if calledCount >= len(helpBattlePlayerDict) or calledCount >= maxHelpPlayerCount:
        FBLogic.OnCallHelpBattleOK(curPlayer, tick)
        
    # ֪ͨGameServer