--道具boss副本 ItemBoss = {} -- @description 请求进入道具boss场景 -- @param 玩家对象;cfg_rep的id -- @return function ItemBoss.ReqEnterItemBoss(actor, configId) --是否组队,组队需要拉队友 local personal = true local teamId = getbaseinfo(actor, "teamid") teamId = tostring(teamId) if teamId ~= "0" then local teamInfo = getteaminfo(actor, teamId) local size = #teamInfo["allteammemberinfo"] if size > 1 then personal = false end end if personal == false then --组队进入 DuplicateCommon.CallTeamMembersPrepare(actor, configId) else --个人进入 if DuplicateCommon.CheckEnterConditonCommon(actor, configId) ~= EnterLimitResultConst.ALLOW then return end --寻找是否有可进入的副本,如果没有创建副本 local mapId = DuplicateCommon.FindEnterableDupCommon(configId, 1) local x, y = DuplicateCommon.GetEnterPointXYCommon(configId) if mapId == 0 then mapId = DuplicateCommon.CreateDupMapCommon(actor, configId, true) end --回蓝回血 DuplicateCommon.RecoverHPMP(memberActor) ItemBoss.PlayerEnterItemBoss(actor, mapId, x, y, configId) end end -- @description 组队进入副本 -- @param 玩家对象;队伍id;副本配置 -- @return function ItemBoss.DoTeamEnter(actor, teamId, configId) local teamInfo = getteaminfo(actor, teamId) local members = teamInfo["allteammemberinfo"] for index, memberInfo in ipairs(members) do local memberId = memberInfo["rid"] local memberActor = getactor(actor, memberId) local check = DuplicateCommon.CheckEnterConditonCommon(memberActor, configId) if check ~= EnterLimitResultConst.ALLOW then error("组队进入成员条件不满足" .. memberId) return end end local memberActors = {} --扣除次数;扣除道具 for index, memberInfo in ipairs(members) do local memberId = memberInfo["rid"] local memberActor = getactor(actor, memberId) ItemBoss.RemoveItemBeforeEnter(memberActor, configId) table.insert(memberActors, memberActor) --回蓝回血 DuplicateCommon.RecoverHPMP(memberActor) end --组队进入 local size = #members --寻找是否有可进入的副本,如果没有创建副本 local mapId = DuplicateCommon.FindEnterableDupCommon(configId, size) local x, y = DuplicateCommon.GetEnterPointXYCommon(configId) if mapId == 0 then mapId = DuplicateCommon.CreateDupMapCommon(actor, configId, true) end enterduplicate(actor, mapId, x, y, memberActors) end -- @description 进入副本扣除次数和道具 -- @param -- @return function ItemBoss.RemoveItemBeforeEnter(actor, configId) -- 扣除次数 local activityId = ConfigDataManager.getTableValue("cfg_rep", "type", "id", configId) reduceactivitytimes(actor, activityId) -- 扣除道具 local itemConfig = ConfigDataManager.getTableValue("cfg_rep", "itemId", "id", configId) local itemMap = string.toIntIntMap(itemConfig, "#", "|") for key, value in pairs(itemMap) do removeitemfrombag(actor, key, value, 0, 9999, '道具Boss') end end -- @description 玩家传送进副本 -- @param 玩家对象;地图id;x坐标;y坐标;cfg_rep的id -- @return function ItemBoss.PlayerEnterItemBoss(actor, mapId, x, y, configId) -- 扣除道具 local itemConfig = ConfigDataManager.getTableValue("cfg_rep", "itemId", "id", configId) local itemMap = string.toIntIntMap(itemConfig, "#", "|") for key, value in pairs(itemMap) do removeitemfrombag(actor, key, value, 0, 9999, '道具Boss') end -- info("PlayerEnterItemBoss, mapId: " .. mapId .. ", x: " .. x .. ", y: " .. y) enterduplicate(actor, mapId, x, y) end --道具boss阶段更新 function ItemBoss.DupStateUpdate(system, id, state, nextStateStartTime, configId) if state == DuplicateState.PREPARE or state == DuplicateState.FIGHT then --战斗阶段,刷怪 local monsterId = ConfigDataManager.getTableValue("cfg_rep", "monster", "id", configId) ItemBoss.GenMonsterItemBoss(id, monsterId) ItemBoss.ResAllPlayCurrencyStateInfo(id) ItemBoss.ResAllPlayDupTaskUpdate(id) elseif state == DuplicateState.FINISH then --jprint("【道具boss】副本结束",configId,id,state) local dupInfo = getduplicate(id) local players = table.getValue(dupInfo, "players") --计算战斗时间 if players ~= nil then for _, actor in pairs(players) do ItemBoss.ResCurrencyStateInfo(actor, id) end end else local dupInfo = getduplicate(id) local players = table.getValue(dupInfo, "players") if players ~= nil then for _, actor in pairs(players) do quitduplicate(actor) end end end end -- @description 玩家进入副本后 -- @param 玩家对象;地图id;副本阶段;下一阶段开始时间戳;配置id(cfg_rep的id) -- @return function ItemBoss.AfterEnterItemBoss(actor, mapId, state, nextStateStartTime, configId) local dupInfo = getduplicate(mapId) local players = dupInfo["players"] local playerDupInfo = getplaydef(actor, ItemBossPlayerConst.ITEM_BOSS_MAP_INFO) -- 是否是新进入的副本 local newEnter = false if playerDupInfo == nil or playerDupInfo == "" then newEnter = true else local lastMapId = playerDupInfo[1] if mapId ~= lastMapId then newEnter = true end end if newEnter == true then -- 进入新的副本,初始化玩家变量 playerDupInfo = { mapId, configId } setplaydef(actor, ItemBossPlayerConst.ITEM_BOSS_MAP_INFO, playerDupInfo) end local maxCount = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.PREPARE_MAX_COUNT) --阶段信息 ItemBoss.ResCurrencyStateInfo(actor, mapId) setduplicatestate(mapId, SetDuplicateStateConst.TO_FIGHT) ItemBoss.ResDupTaskUpdate(actor, mapId) end -- @description 刷怪 -- @param 地图唯一id;刷怪表id -- @return function ItemBoss.GenMonsterItemBoss(mapId, genMonCfgId) --战斗阶段才可以刷怪 local dupInfo = getduplicate(mapId) if dupInfo["state"] ~= DuplicateState.FIGHT then return end --储存当前刷怪配置 setenvirvar(mapId, DuplicateVarConst.ITEM_BOSS_MONSTER_GEN_CONFIG, genMonCfgId) DuplicateCommon.DupGenMonsterCommon(mapId, genMonCfgId) end -- @description 击杀怪物 -- @param 归属者;默认掉落经验;怪物配置id -- @return 经验值 function ItemBoss.KillMonterInItemBoss(actor, mapId, exp, monCfgId) -- 当前波次击杀的怪物 -- local oldCount = getenvirvar(mapId, DuplicateVarConst.ITEM_BOSS_STATE_KILL_COUNT) -- local newCount = oldCount + 1 -- local genMonCfgId = getenvirvar(mapId, DuplicateVarConst.ITEM_BOSS_MONSTER_GEN_CONFIG) -- local totalCount = ConfigDataManager.getTableValue("cfg_repMonster", "kill", "id", genMonCfgId) -- if newCount >= tonumber(totalCount) then -- newCount = 0 -- --生成下一波怪 -- local nextGenMonCfgId = ConfigDataManager.getTableValue("cfg_repMonster", "nextID", "id", genMonCfgId) -- ItemBoss.GenMonsterItemBoss(mapId, nextGenMonCfgId) -- local oldState = getenvirvar(mapId, DuplicateVarConst.ITEM_BOSS_STATE) -- local newState = oldState + 1 -- setenvirvar(mapId, DuplicateVarConst.ITEM_BOSS_STATE, newState) -- end -- setenvirvar(mapId, DuplicateVarConst.ITEM_BOSS_STATE_KILL_COUNT, newCount) -- 调用退出副本接口 setduplicatestate(mapId, SetDuplicateStateConst.TO_FINISH) end -- @description 玩家副本结算 -- @param 玩家对象; -- @return function ItemBoss.PlayerSettleMentItemBoss(actor) -- 这里发放积分经验 -- additemtobag(actor, ItemConfigId.EXP, totalScoreExp, 0, 9999, '道具boss') local playerDupInfo = getplaydef(actor, ItemBossPlayerConst.ITEM_BOSS_MAP_INFO) local configId = playerDupInfo[2] -- -- 发回给客户端 local response = {} response["configId"] = configId --配置表id -- response["kill"] = killCount --击杀怪物数量 -- response["killExp"] = killExp --击杀怪物掉落的经验 -- response["scoreExp"] = totalScoreExp --积分经验 -- response["leftCount"] = leftCount --剩余次数 sendluamsg(actor, LuaMessageIdToClient.RES_ITEM_BOSS_SETTLEMENT, response) end -- @description 玩家进入任意地图事件 -- @param 玩家对象;上一个地图配置id;当前地图配置id -- @return function ItemBoss.EnterAllMapDS(actor, lastMapCfgId, mapCfgId) -- 判断发送副本结算 local dupInfo = getplaydef(actor, ItemBossPlayerConst.ITEM_BOSS_MAP_INFO) if dupInfo == nil or dupInfo == "" then return end local ItemBossId = dupInfo[1] local mapId = getbaseinfo(actor, "unimapid") local mapInfo = getmapinfobyid(mapId) local isDup = mapInfo["isdup"] if isDup == true and ItemBossId ~= mapId then error("道具boss有未结算的奖励") ItemBoss.ClearPlayerItemBossDef(actor) return end if ItemBossId ~= mapId then -- 结算 gameDebug.debug(LogManager.TriggerByType, actor, LogOpType.B_AND_D_CHALLENGE) ItemBoss.PlayerSettleMentItemBoss(actor) else -- info("道具boss进入副本,地图不同,结算失败") end end -- @description 清除玩家在道具boss副本中的变量 -- @param 玩家对象 -- @return function ItemBoss.ClearPlayerItemBossDef(actor) setplaydef(actor, ItemBossPlayerConst.ITEM_BOSS_MAP_INFO, "") end -- @description 响应给客户端当前阶段 -- @param 玩家对象;地图id -- @return function ItemBoss.ResCurrencyStateInfo(actor, mapId) local dupInfo = getduplicate(mapId) local state = dupInfo["state"] local configId = dupInfo["dupcfgid"] local nextStateStartTime = dupInfo["nextstatetime"] sendluamsg(actor, LuaMessageIdToClient.ITEM_BOSS_STATE, { state, tostring(nextStateStartTime), configId }) end -- @description 通知地图所有玩家更新当前阶段 -- @param 地图id -- @return function ItemBoss.ResAllPlayCurrencyStateInfo(mapId) local dupInfo = getduplicate(mapId) local players = dupInfo["players"] for index, actor in ipairs(players) do ItemBoss.ResCurrencyStateInfo(actor, mapId) end end -- @description 立即开启战斗 -- @param 玩家对象;请求参数 -- @return function ItemBoss.ChangeToFight(actor, msgData) local mapId = getbaseinfo(actor, "unimapid") setduplicatestate(mapId, SetDuplicateStateConst.TO_FIGHT) end -- @description 副本任务更新响应 -- @param 玩家对象;副本id -- @return function ItemBoss.ResDupTaskUpdate(actor, mapId) local dupInfo = getduplicate(mapId) local configId = dupInfo["dupcfgid"] --任务总数量 local genMonCfgId = getenvirvar(mapId, DuplicateVarConst.ITEM_BOSS_MONSTER_GEN_CONFIG) local totalCount = ConfigDataManager.getTableValue("cfg_repMonster", "kill", "id", genMonCfgId) local totalReward = ConfigDataManager.getTableValue("cfg_rep", "reward", "id", configId) local response = {} response["totalCount"] = totalCount response["rewardCount"] = totalReward -- response["score"] = killScore sendluamsg(actor, LuaMessageIdToClient.RES_ITEM_BOSS_TASK, response) end -- @description 通知地图所有玩家更新当前任务 -- @param 副本id -- @return function ItemBoss.ResAllPlayDupTaskUpdate(mapId) local dupInfo = getduplicate(mapId) local players = dupInfo["players"] for index, actor in ipairs(players) do ItemBoss.ResDupTaskUpdate(actor, mapId) end end