From 36875ec5121152c3468d5b4f64fb0874fcafeb7b Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Thu, 3 Dec 2020 17:57:39 +0800 Subject: [PATCH] 宝藏怪 --- src/adv/Adv.lua | 181 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------- src/adv/AdvBattle.lua | 24 ++++++++++++++++++++---- src/adv/AdvMap.lua | 41 +++++++++++++++++++++++++++++++++++++++++ src/models/Role.lua | 3 ++- src/models/RoleTimeReset.lua | 11 +++++++++++ 5 files changed, 200 insertions(+), 60 deletions(-) diff --git a/src/adv/Adv.lua b/src/adv/Adv.lua index f5b1950..097960d 100644 --- a/src/adv/Adv.lua +++ b/src/adv/Adv.lua @@ -1953,73 +1953,144 @@ function Adv:enemyDead(enemy, escape) -- self:backDead(enemyId, changeV) self:backDead(enemyId) - local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) - if toClick then - toClick = toClick:effect() + local isMine = false -- 是不是宝藏怪 + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do + if mid == enemyId then + isMine = true + break + end end + if isMine then + local advMine = self.owner:getProperty("advMine") + advMine[1] = advMine[1] or {} + advMine[2] = advMine[2] or {} + local mineCo = advMine[1].co or {} + local mineCo2 = advMine[2].co or {} + local mineCh = advMine[2].ch or globalCsv.adv_egg_treasureLayer_showup + if monsterData.limit ~= 0 then + mineCo[enemyId] = (mineCo[enemyId] or 0) + 1 + end - local changItem = enemy:hadBuff(Buff.CHANGE_DROP) - if changItem then - changItem = table.pack(changItem:effect()) - end + local had = false + if math.randomInt(1, 100) <= mineCh then -- 刷出来了 + local mpool = {} + for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do + local layer = csvdb["event_buildingCsv"][mid] + if (not mineCo2[mid] or layer.limit == 0 or mineCo2[mid] < layer.limit) and layer.showup > 0 then + mpool[mid] = {layer.showup} + end + end + if next(mpool) then + local cId = math.randWeight(mpool, 1) + block:updateEvent({ + etype = AdvEventType.Build, + id = cId + }) + if csvdb["event_buildingCsv"][cId].limit ~= 0 then + mineCo2[cId] = (mineCo2[cId] or 0) + 1 + end + had = true + end + end + if had then + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100) + else + mineCh = nil + end - local addMult = 0 - local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数 - if dropBuff then - local team = enemy:getTeam(1, true) - addMult = addMult + 0.2 * #team - end + local drops = {} + for _, dropId in ipairs(monsterData.dropid:toArray(true, "=")) do + local dropData = csvdb["event_dropCsv"][dropId] + if dropData then + local cur = dropData["range"]:randWeight(true) + if cur and cur[1] ~= 0 then + drops[#drops + 1] = cur + end + end + end + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) + for _i, cblock in ipairs(blocks) do + cblock:updateEvent({ + etype = AdvEventType.Drop, + item = drops[_i] + }) + if cblock ~= block then + self:backBlockChange(cblock.room.roomId, cblock.blockId) + end + end + advMine[1].co = mineCo + advMine[2].co = mineCo2 + advMine[2].ch = mineCh + self.owner:setProperty("advMine", advMine) + else + local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK) + if toClick then + toClick = toClick:effect() + end - local dropIds = monsterData.dropid:toArray(true, "=") - local drops = {} - local cCcount = 0 -- 需要改变为click 的个数 - for _, dropId in ipairs(dropIds) do - local dropData = csvdb["event_dropCsv"][dropId] - if dropData then - local cur = dropData["range"]:randWeight(true) - if cur and cur[1] ~= 0 then - if toClick then - cCcount = cCcount + 1 - else - local item = changItem and changItem or cur - item[2] = math.floor(item[2] * (1 + addMult)) - drops[#drops + 1] = item + local changItem = enemy:hadBuff(Buff.CHANGE_DROP) + if changItem then + changItem = table.pack(changItem:effect()) + end + + local addMult = 0 + local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY) -- 根据敌人数量变化个数 + if dropBuff then + local team = enemy:getTeam(1, true) + addMult = addMult + 0.2 * #team + end + + local dropIds = monsterData.dropid:toArray(true, "=") + local drops = {} + local cCcount = 0 -- 需要改变为click 的个数 + for _, dropId in ipairs(dropIds) do + local dropData = csvdb["event_dropCsv"][dropId] + if dropData then + local cur = dropData["range"]:randWeight(true) + if cur and cur[1] ~= 0 then + if toClick then + cCcount = cCcount + 1 + else + local item = changItem and changItem or cur + item[2] = math.floor(item[2] * (1 + addMult)) + drops[#drops + 1] = item + end end end end - end - -- 这些奖励可能会有被动加成 - self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops}) + -- 这些奖励可能会有被动加成 + self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops}) - -- 自身带的掉落是不会被改变的 也不会被加成 - if block.event.item and block.event.item[1] ~= 0 then - table.insert(drops, 1, block.event.item) - end + -- 自身带的掉落是不会被改变的 也不会被加成 + if block.event.item and block.event.item[1] ~= 0 then + table.insert(drops, 1, block.event.item) + end - -- 清空当前的格子 - block:clear() + -- 清空当前的格子 + block:clear() - -- 掉落走一波 - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) - for _i, cblock in ipairs(blocks) do - cblock:updateEvent({ - etype = AdvEventType.Drop, - item = drops[_i] - }) - if cblock ~= block then - self:backBlockChange(cblock.room.roomId, cblock.blockId) + -- 掉落走一波 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops) + for _i, cblock in ipairs(blocks) do + cblock:updateEvent({ + etype = AdvEventType.Drop, + item = drops[_i] + }) + if cblock ~= block then + self:backBlockChange(cblock.room.roomId, cblock.blockId) + end end - end - -- 转换的click走一波 - local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount) - for _i, cblock in ipairs(blocks) do - cblock:updateEvent({ - etype = AdvEventType.Click, - id = clickId - }) - if cblock ~= block then - self:backBlockChange(cblock.room.roomId, cblock.blockId) + -- 转换的click走一波 + local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount) + for _i, cblock in ipairs(blocks) do + cblock:updateEvent({ + etype = AdvEventType.Click, + id = clickId + }) + if cblock ~= block then + self:backBlockChange(cblock.room.roomId, cblock.blockId) + end end end diff --git a/src/adv/AdvBattle.lua b/src/adv/AdvBattle.lua index a5c2f54..baab58d 100644 --- a/src/adv/AdvBattle.lua +++ b/src/adv/AdvBattle.lua @@ -366,18 +366,34 @@ function Battle:battleBegin(roomId, blockId, params) if not enemy then return end local player = params.player if not player then return end + local penemy = params.enemy + if not penemy then return end + + if player.hp ~= 0 then + if penemy.hp <= 0 then + enemy:kill() + self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) + else + -- 处理一下怪物 + if penemy.hp > enemy.hp then + enemy:recover(penemy.hp - enemy.hp) + else + enemy:hurt(math.max(0, math.ceil(enemy.hp - penemy.hp)), self.player, {hurtType = 5}) --战斗血量只会变少 + end + if penemy.escape and penemy.escape == 0 then + enemy.isDead = 1 + end + end + end -- 玩家没死就是怪死了 if player.hp > 0 then - enemy:kill() self.player:effectBattleBuff() - - self.adv.owner:checkTaskEnter("AdvBattleWin", {id = self.adv.chapterId}) if params.bySkill then self.player:triggerPassive(Passive.SKILL_KILL) end end if player.hp > self.player.hp then - self.player:recover(player.hp - self.player.hp, player) + self.player:recover(player.hp - self.player.hp) else self.player:hurt(math.max(0, math.ceil(self.player.hp - player.hp)), enemy, {hurtType = 5}) --战斗血量只会变少 end diff --git a/src/adv/AdvMap.lua b/src/adv/AdvMap.lua index aeeeee4..c42a457 100644 --- a/src/adv/AdvMap.lua +++ b/src/adv/AdvMap.lua @@ -812,6 +812,47 @@ createMap = function(self, mapId, isEnter, isNewRelay) end end + -- 宝藏怪刷新 + for idx = #(stagePool["global"][AdvCodeRandomStage] or {}), 1, -1 do + local c = stagePool["global"][AdvCodeRandomStage][idx] -- {room = roomId, block = blockId} + if mapInfo.rooms[c["room"]]["event"][c["block"]] then -- 存在 + table.remove(stagePool["global"][AdvCodeRandomStage], idx) + end + end + local ln = #(stagePool["global"][AdvCodeRandomStage] or {}) + local advMine = self.adv.owner:getProperty("advMine") + advMine[1] = advMine[1] or {} + local mineCh = advMine[1].ch or globalCsv.adv_egg_treasureMonster_showup + local mineCo = advMine[1].co or {} + local had = false + if ln > 0 then + if math.randomInt(1, 100) <= mineCh then -- 刷出来了 + local mpool = {} + for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do + local monster = csvdb["event_monsterCsv"][mid] + if (not mineCo[mid] or monster.limit == 0 or mineCo[mid] < monster.limit) and monster.showup > 0 then + mpool[mid] = {monster.showup} + end + end + if next(mpool) then + local idx = math.randomInt(1, ln) + local cur = stagePool["global"][AdvCodeRandomStage][idx] + giveEvent(cur["room"], cur["block"], AdvEventType.Monster, math.randWeight(mpool, 1)) + table.remove(stagePool["global"][AdvCodeRandomStage], idx) + ln = ln - 1 + had = true + end + end + end + if not had then + mineCh = math.min(mineCh + globalCsv.adv_egg_treasureMonster_showup_add, 100) + else + mineCh = nil + end + advMine[1].ch = mineCh + self.adv.owner:setProperty("advMine", advMine) + + if mapCsvData.clearType == 1 and not haveBoss then if not next(monsterEvents) then error("这个地图没有钥匙!!! mapId : " .. mapId) diff --git a/src/models/Role.lua b/src/models/Role.lua index 6d84ecd..c215180 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -99,7 +99,8 @@ Role.schema = { advLimit = {"table", {}}, -- 冒险事件每次的limit advC = {"number", 0}, -- 冒险次数(消耗体力) advCT = {"number", 0}, -- 冒险次数 上次恢复时间 - + advMine = {"table", {}}, -- -- {1 = {ch = 0, co = {id = count}}, 2 = {ch = 0, co = {id = count}}} 宝藏怪刷出概率 1 宝藏怪 2 宝藏洞 ch 概率 co 不同id 次数记录 + --挂机相关 hangPass = {"table", {}}, -- 挂机通过的最大关卡 hangGift = {"table", {}}, -- 挂机奖励 {id = 1} diff --git a/src/models/RoleTimeReset.lua b/src/models/RoleTimeReset.lua index 52adbda..8ecba88 100644 --- a/src/models/RoleTimeReset.lua +++ b/src/models/RoleTimeReset.lua @@ -17,6 +17,11 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) self:advRandomSupportEffect(not notify) self:checkExpireItem(not notify) + local advMine = self:getProperty("advMine") + if advMine[1] then + advMine[1].co = nil + end + self:setProperty("advMine", advMine) response.dTask = {} response.advSup = self:getProperty("advSup") @@ -24,10 +29,16 @@ ResetFunc["CrossDay"] = function(self, notify, response, now) end ResetFunc["CrossWeek"] = function(self, notify, response) + local advMine = self:getProperty("advMine") + if advMine[2] then + advMine[2].co = nil + end self:setProperties({ wTask = {}, dinerS = {}, + advMine = advMine, }) + response.wTask = {} response.dinerS = {} end -- libgit2 0.21.2