--- 特权BOSS副本 PrivilegeBoss = {} local this = {} --- 获取特权BOSS信息 ---@param actor 玩家对象 ---@param msgData 消息数据 function PrivilegeBoss.ReqPrivilegeBossPanel(actor, msgData) local configId = tonumber(msgData["configId"]) if configId == nil or configId <= 0 then gameDebug.printTraceback("PrivilegeBoss.ReqPrivilegeBossInfo param is wrong", msgData) return end local activityId = ConfigDataManager.getTableValue("cfg_rep", "type", "id", configId) local leftCount = getleftcountofactivity(actor, activityId) local activityInfo = getactivityinfo(activityId) local isOpen = activityInfo["open"] local nextOpenTime if isOpen then nextOpenTime = activityInfo["closetime"] else nextOpenTime = activityInfo["nextopentime"] end local resInfo = { configId = configId, leftCount = leftCount, isOpen = isOpen, nextOpenTime = tostring(nextOpenTime) } -- 特权BOSS面板协议 sendluamsg(actor, LuaMessageIdToClient.RES_PRIVILEGE_BOSS_PANEL, resInfo) end --- 请求进入特权BOSS副本 ---@param actor 玩家对象 ---@param configId 副本配置ID function PrivilegeBoss.ReqEnterPrivilegeBoss(actor, configId) -- 验证是否可以进入 local conditionResult = DuplicateCommon.CheckEnterConditonCommon(actor, configId) if conditionResult ~= EnterLimitResultConst.ALLOW then if conditionResult == EnterLimitResultConst.LEVEL then noticeTip.noticeinfo(actor, StringIdConst.CURRENT_LEVEL_INSUFFICIENT) return end if conditionResult == EnterLimitResultConst.COUNT then tipinfo(actor, "挑战次数不足") return end return end --寻找是否有可进入的副本,如果没有创建副本 local x, y = DuplicateCommon.GetEnterPointXYCommon(configId) local mapId = DuplicateCommon.CreateDupMapCommon(actor, configId, true) setplaydef(actor, PlayerDefKey.privilegeBoss.BOSS_IS_DIE, 0) --回蓝回血 DuplicateCommon.RecoverHPMP(actor) enterduplicate(actor, mapId, x, y) end --- 特权BOSS副本状态更新 function PrivilegeBoss.PrivilegeBossStateUpdate(system, id, state, nextStateStartTime, configId) if state == DuplicateState.FIGHT then --战斗阶段 local monsterId = ConfigDataManager.getTableValue("cfg_rep", "monster", "id", configId) DuplicateCommon.DupGenMonsterCommon(id, monsterId) --刷怪 end end --- 进入特权BOSS副本后返回客户端 function PrivilegeBoss.afterEnterPrivilegeBoss(actor, mapId, state, nextStateStartTime, configId) sendluamsg(actor, LuaMessageIdToClient.RES_PRIVILEGE_BOSS_STATUS, { configId = tonumber(configId), isDie = getplaydef(actor, PlayerDefKey.privilegeBoss.BOSS_IS_DIE) }) end --- 特权BOSS怪物死亡处理 ---@param mapId 副本ID ---@param killer 击杀者 ---@param monCfgId 怪物配置ID function PrivilegeBoss.PrivilegeBossMonsterDie(mapId, killer, monCfgId) -- 减少可挑战次数 local repId = ConfigDataManager.getTableValue("cfg_rep", "id", "monsterui", monCfgId) local activityId = ConfigDataManager.getTableValue("cfg_rep", "type", "id", repId) reduceactivitytimes(killer, activityId) setplaydef(killer, PlayerDefKey.privilegeBoss.BOSS_IS_DIE, 1) -- 更新副本状态到关闭 setduplicatestate(mapId, SetDuplicateStateConst.TO_FINISH) sendluamsg(killer, LuaMessageIdToClient.RES_PRIVILEGE_BOSS_STATUS, { configId = tonumber(repId), isDie = 1 }) -- 刷新任务进度 DuplicateCommon.FinishDupActivity(killer, repId) end --- 玩家复活后发送特权BOSS状态 function PrivilegeBoss.playerRelive(actor) local mapId = getbaseinfo(actor, "unimapid") local dupInfo = getduplicate(mapId) if table.isNullOrEmpty(dupInfo) then return end local type = dupInfo["type"] if type ~= DuplicateType.PRIVILEGE_BOSS then return end sendluamsg(actor, LuaMessageIdToClient.RES_PRIVILEGE_BOSS_STATUS, { configId = tonumber(dupInfo["activityid"]), isDie = getplaydef(actor, PlayerDefKey.privilegeBoss.BOSS_IS_DIE) }) end --- 服务器小时心跳增加特权BOSS挑战次数 function PrivilegeBoss.incrementedPrivilegeBossCount() local serverType = getbaseinfo("servertype") if serverType == 2 then return end local seconds = getbaseinfo("nowsec") local now = TimeUtil.timeToDate(seconds) if now.min == 0 then gameDebug.print("PrivilegeBoss.incrementedPrivilegeBossCount now.hour:", now.hour) gameDebug.print("PrivilegeBoss.incrementedPrivilegeBossCount now.min:", now.min) gameDebug.print("PrivilegeBoss.incrementedPrivilegeBossCount now.sec:", now.sec) local activityRule = ConfigDataManager.getTable("cfg_activity_rule", "id", DuplicateType.PRIVILEGE_BOSS) local numberTime = activityRule[1]["numbertime"] if not string.isNullOrEmpty(numberTime) then local split = string.split(numberTime, "#") local type = tonumber(split[1]) local numberTime1 = tonumber(split[2]) if type == 1 then if numberTime1 == now.hour then this.countHandle() end else local numberTime2 = tonumber(split[3]) if numberTime1 == now.wday and numberTime2 == now.hour then this.countHandle() end end end end end --- 特权BOSS挑战次数增加处理 function this.countHandle() local allRoleInfos = getallrolesummaryinfos() if table.isNullOrEmpty(allRoleInfos) then return end for _, roleInfo in pairs(allRoleInfos) do local actor = roleInfo["actor"] -- 如果开通了任意特权,增加对应的挑战次数 local currentCount = getleftcountofactivity(actor, DuplicateType.PRIVILEGE_BOSS) local numberAdd = ConfigDataManager.getTableValue("cfg_activity_rule", "numberadd", "id", DuplicateType.PRIVILEGE_BOSS) local countLimit = string.split(numberAdd, "#")[2] -- 如果使用了特权,增加对应的特权次数 if PrivilegeMonth.hasAnyPrivilege(actor) then local incrementCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.PRIVILEGE_BOSS_PRIVILEGE_COUNT) if not (tonumber(currentCount) + tonumber(incrementCount) > tonumber(countLimit)) then -- 使用减少挑战次数接口传负数来实现增加次数 reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -incrementCount) end end currentCount = PrivilegeBoss.addCount(actor, PrivilegeBossCountType.GOLD_CARD, currentCount, countLimit) currentCount = PrivilegeBoss.addCount(actor, PrivilegeBossCountType.DIAMOND_CARD, currentCount, countLimit) currentCount = PrivilegeBoss.addCount(actor, PrivilegeBossCountType.VIP, currentCount, countLimit) end end --- 增长特权BOSS挑战次数 ---@param actor table 玩家对象 ---@param count number 增长次数 ---@param type number 活动类型 function PrivilegeBoss.addCount(actor, type, currentCount, countLimit) if not currentCount then currentCount = getleftcountofactivity(actor, DuplicateType.PRIVILEGE_BOSS) local numberAdd = ConfigDataManager.getTableValue("cfg_activity_rule", "numberadd", "id", DuplicateType.PRIVILEGE_BOSS) countLimit = string.split(numberAdd, "#")[2] end local countInit = getplaydef(actor, PlayerDefKey.privilegeBoss.COUNT_INIT) if string.isNullOrEmpty(countInit) then local initCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.PRIVILEGE_BOSS_PRIVILEGE_COUNT) -- 使用特权卡后初始化次数 if PrivilegeMonth.hasAnyPrivilege(actor) then reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -initCount) end -- 使用黄金特权卡后初始化次数 if PrivilegeMonth.hasPrivilegeType(actor, PrivilegeCardId.GOLD1) then local incrementCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.PRIVILEGE_BOSS_GOLD_CARD) incrementCount = initCount + incrementCount reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -incrementCount) end -- 使用钻石特权卡后初始化次数 if PrivilegeMonth.hasPrivilegeType(actor, PrivilegeCardId.DIAMOND1) then local incrementCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.PRIVILEGE_BOSS_DIAMOND_CARD) incrementCount = initCount + incrementCount reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -incrementCount) end -- 开启vip后初始化次数 local isOpen, count = VipGiftPack.hasPrivilege(actor, VipPrivilege.Type.tqboss) if isOpen then count = initCount + count reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -count) end setplaydef(actor, PlayerDefKey.privilegeBoss.COUNT_INIT, true) return end -- 如果使用了黄金特权卡,增加对应的挑战次数 if type == PrivilegeBossCountType.GOLD_CARD and PrivilegeMonth.hasPrivilegeType(actor, PrivilegeCardId.GOLD1) then local incrementCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.PRIVILEGE_BOSS_GOLD_CARD) if not (tonumber(currentCount) + tonumber(incrementCount) > tonumber(countLimit)) then currentCount = currentCount + tonumber(incrementCount) -- 使用减少挑战次数接口传负数来实现增加次数 reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -incrementCount) end end -- 如果使用了钻石特权卡,增加对应的挑战次数 if type == PrivilegeBossCountType.DIAMOND_CARD and PrivilegeMonth.hasPrivilegeType(actor, PrivilegeCardId.DIAMOND1) then local incrementCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.PRIVILEGE_BOSS_DIAMOND_CARD) if not (tonumber(currentCount) + tonumber(incrementCount) > tonumber(countLimit)) then currentCount = currentCount + tonumber(incrementCount) -- 使用减少挑战次数接口传负数来实现增加次数 reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -incrementCount) end end -- 如果开启了vip,增加对应的挑战次数 if type == PrivilegeBossCountType.VIP then local isOpen, count = VipGiftPack.hasPrivilege(actor, VipPrivilege.Type.tqboss) if isOpen then if not (tonumber(currentCount) + tonumber(count) > tonumber(countLimit)) then currentCount = currentCount + tonumber(count) -- 使用减少挑战次数接口传负数来实现增加次数 reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, -count) end end end if tonumber(currentCount) > tonumber(countLimit) then reduceactivitytimes(actor, DuplicateType.PRIVILEGE_BOSS, tonumber(currentCount) - tonumber(countLimit)) end return currentCount end --- 怪物掉落奖励面板 ---@param actor table 玩家对象 ---@param monsterCfgId number 怪物配置ID ---@param mapId number 地图ID ---@param dropResult number 掉落结果 function PrivilegeBoss.resRewardPanel(actor, monsterCfgId, mapId, dropResult) if this.isPrivilegeBoss(monsterCfgId) and this.isPrivilegeMap(gamemap.parseMapKey(mapId)) then sendluamsg(actor, LuaMessageIdToClient.COMMON_REWARD_PANEL, dropResult) end end --- 判断是否为特权BOSS ---@param monsterCfgId number 怪物配置ID ---@return boolean 是否为特权BOSS function this.isPrivilegeBoss(monsterCfgId) local id = gettablevalue("cfg_rep", "id", "monster", monsterCfgId, "type", DuplicateType.PRIVILEGE_BOSS) return not string.isNullOrEmpty(id) end --- 判断是否为特权BOSS副本 ---@param mapId number 副本ID ---@return boolean 是否为特权BOSS副本 function this.isPrivilegeMap(mapId) return mapId == DuplicateType.PRIVILEGE_BOSS end