This commit is contained in:
puxuan 2025-06-03 15:15:01 +08:00
parent 722639abab
commit 5cfdb4c8d8
6 changed files with 181 additions and 188 deletions

View File

@ -331,39 +331,39 @@ function BattleUnitComp:beforeAttack(actionState)
end
end
function BattleUnitComp:useAssistingSkill(count, delay, callback)
local skill = self.unitEntity:getAssistingSkill()
if skill == nil then
callback()
return
end
local attrName = GConst.MATCH_ATTACK_NAME[self:getMatchType()]
self.assistingDmgAddition = count - 1
if self.assistingDmgAddition <= 0 then
self.assistingDmgAddition = 0
self.assistingDmgAddCount = 0
else
self.assistingDmgAddCount = self.unitEntity:addAttr(attrName, self.assistingDmgAddition*DEFAULT_FACTOR, true)
end
self.actionOverCallback = callback
if delay > 0 then
self.waitTime = delay
self.waitingState = UNIT_STATE.ASSISTING_ATTACK
if not self:changeState(UNIT_STATE.WAIT) then
if not self:changeState(UNIT_STATE.ASSISTING_ATTACK) then
self.actionOverCallback = nil
self.unitEntity:addAttr(attrName, -self.assistingDmgAddCount, false)
callback()
end
end
else
if not self:changeState(UNIT_STATE.ASSISTING_ATTACK) then
self.actionOverCallback = nil
self.unitEntity:addAttr(attrName, -self.assistingDmgAddCount, false)
callback()
end
end
end
-- function BattleUnitComp:useAssistingSkill(count, delay, callback)
-- local skill = self.unitEntity:getAssistingSkill()
-- if skill == nil then
-- callback()
-- return
-- end
-- local attrName = GConst.MATCH_ATTACK_NAME[self:getMatchType()]
-- self.assistingDmgAddition = count - 1
-- if self.assistingDmgAddition <= 0 then
-- self.assistingDmgAddition = 0
-- self.assistingDmgAddCount = 0
-- else
-- self.assistingDmgAddCount = self.unitEntity:addAttr(attrName, self.assistingDmgAddition*DEFAULT_FACTOR, true)
-- end
-- self.actionOverCallback = callback
-- if delay > 0 then
-- self.waitTime = delay
-- self.waitingState = UNIT_STATE.ASSISTING_ATTACK
-- if not self:changeState(UNIT_STATE.WAIT) then
-- if not self:changeState(UNIT_STATE.ASSISTING_ATTACK) then
-- self.actionOverCallback = nil
-- self.unitEntity:addAttr(attrName, -self.assistingDmgAddCount, false)
-- callback()
-- end
-- end
-- else
-- if not self:changeState(UNIT_STATE.ASSISTING_ATTACK) then
-- self.actionOverCallback = nil
-- self.unitEntity:addAttr(attrName, -self.assistingDmgAddCount, false)
-- callback()
-- end
-- end
-- end
function BattleUnitComp:useSkill(index, count, callback)
self.unitEntity:addActiveSkillReleaseCount(1)

View File

@ -2262,70 +2262,70 @@ function BattleBaseController:getRandomSkillList(getCount, onlyCommonSkill, excl
self.randomSkillNewSkillPool = table.clearOrCreate(self.randomSkillNewSkillPool)
self.randomSkillSkillWeight = table.clearOrCreate(self.randomSkillSkillWeight)
local cfg = ConfigManager:getConfig("skill_rogue")
local skillPool = self:getSkillPool()
-- local skillPool = self:getSkillPool()
local count = 0
if not onlyCommonSkill then
for elementType, list in pairs(skillPool) do -- 先遍历一下未解锁的技能
if not self:isUnlockedSkillElementType(elementType) then
local skillEntity = self:getSkillEntityByElement(elementType)
if skillEntity then
local skillId = skillEntity:getUnlockId()
if skillId and not self.randomSkillMap[skillId] then
local skillCfg = cfg[skillId]
table.insert(self.randomSkillNewSkillPool, skillId)
table.insert(self.randomSkillSkillWeight, skillCfg.weight)
count = count + 1
self.randomSkillMap[skillId] = true
end
end
end
end
-- if not onlyCommonSkill then
-- for elementType, list in pairs(skillPool) do -- 先遍历一下未解锁的技能
-- if not self:isUnlockedSkillElementType(elementType) then
-- local skillEntity = self:getSkillEntityByElement(elementType)
-- if skillEntity then
-- local skillId = skillEntity:getUnlockId()
-- if skillId and not self.randomSkillMap[skillId] then
-- local skillCfg = cfg[skillId]
-- table.insert(self.randomSkillNewSkillPool, skillId)
-- table.insert(self.randomSkillSkillWeight, skillCfg.weight)
-- count = count + 1
-- self.randomSkillMap[skillId] = true
-- end
-- end
-- end
-- end
if count >= 3 then -- 如果未解锁的技能大于等于3则直接返回三个解锁技能
for i = 1, 3 do
local index = GFunc.getRandomIndex(self.randomSkillSkillWeight)
local skillId = table.remove(self.randomSkillNewSkillPool, index)
table.remove(self.randomSkillSkillWeight, index)
count = count - 1
table.insert(self.randomSkillList, skillId)
end
-- if count >= 3 then -- 如果未解锁的技能大于等于3则直接返回三个解锁技能
-- for i = 1, 3 do
-- local index = GFunc.getRandomIndex(self.randomSkillSkillWeight)
-- local skillId = table.remove(self.randomSkillNewSkillPool, index)
-- table.remove(self.randomSkillSkillWeight, index)
-- count = count - 1
-- table.insert(self.randomSkillList, skillId)
-- end
return table.shuffle(self.randomSkillList)
end
-- return table.shuffle(self.randomSkillList)
-- end
if excludeMap then
for skillId, _ in pairs(excludeMap) do
self.randomSkillMap[skillId] = true
end
end
-- if excludeMap then
-- for skillId, _ in pairs(excludeMap) do
-- self.randomSkillMap[skillId] = true
-- end
-- end
for elementType, list in pairs(skillPool) do
if self:isUnlockedSkillElementType(elementType) then
for _, skillId in ipairs(list) do
local skillCfg = cfg[skillId]
if skillCfg and (not skillCfg.limit_times or self:getSkillCount(skillId) < skillCfg.limit_times) then
-- for elementType, list in pairs(skillPool) do
-- if self:isUnlockedSkillElementType(elementType) then
-- for _, skillId in ipairs(list) do
-- local skillCfg = cfg[skillId]
-- if skillCfg and (not skillCfg.limit_times or self:getSkillCount(skillId) < skillCfg.limit_times) then
if not self.randomSkillMap[skillId] and (not skillCfg.unlock or self:getSkillCount(skillCfg.unlock) > 0) then
table.insert(self.randomSkillNewSkillPool, skillId)
table.insert(self.randomSkillSkillWeight, skillCfg.weight)
count = count + 1
self.randomSkillMap[skillId] = true
end
end
end
end
end
-- if not self.randomSkillMap[skillId] and (not skillCfg.unlock or self:getSkillCount(skillCfg.unlock) > 0) then
-- table.insert(self.randomSkillNewSkillPool, skillId)
-- table.insert(self.randomSkillSkillWeight, skillCfg.weight)
-- count = count + 1
-- self.randomSkillMap[skillId] = true
-- end
-- end
-- end
-- end
-- end
if count > 0 then
local index = GFunc.getRandomIndex(self.randomSkillSkillWeight)
local skillId = table.remove(self.randomSkillNewSkillPool, index)
table.remove(self.randomSkillSkillWeight, index)
count = count - 1
table.insert(self.randomSkillList, skillId)
getCount = getCount - 1
end
end
-- if count > 0 then
-- local index = GFunc.getRandomIndex(self.randomSkillSkillWeight)
-- local skillId = table.remove(self.randomSkillNewSkillPool, index)
-- table.remove(self.randomSkillSkillWeight, index)
-- count = count - 1
-- table.insert(self.randomSkillList, skillId)
-- getCount = getCount - 1
-- end
-- end
for skillId, info in pairs(cfg) do
if not self:getNotInvolvedSkills()[skillId] then
@ -2378,7 +2378,7 @@ function BattleBaseController:onSelectSkill(skillId, value, pos, side)
BIReport:postFightSkillSelect(self.battleType, self.battleData, {skillId}, self.chapterId, self.totalDurationTime, self:getWaveIndex())
local elementType = ModuleManager.HeroManager:getSkillRoguePosition(skillId)
if elementType then
if elementType and pos then
if self.battleUI then
self.battleUI:gotOneSkillAni(skillId, elementType, function()
self:selectSKillNextToStep()
@ -3254,13 +3254,13 @@ local function _addCurRoundAttr(self, side, instruction, callback)
callback()
end
local function _assisting(self, side, instruction, callback)
local actionTeam = self.atkTeam
if side == SIDE_DEF then
actionTeam = self.defTeam
end
actionTeam:useAssistingSkill(instruction.assistingList, #self.instructions == 0, callback)
end
-- local function _assisting(self, side, instruction, callback)
-- local actionTeam = self.atkTeam
-- if side == SIDE_DEF then
-- actionTeam = self.defTeam
-- end
-- actionTeam:useAssistingSkill(instruction.assistingList, #self.instructions == 0, callback)
-- end
local function _generalAttack(self, side, instruction, callback)
local actionTeam = self.atkTeam
@ -3280,7 +3280,7 @@ end
BattleBaseController._doInstruction = {
[BattleConst.INSTRUCTION_NAME.ADD_CUR_ROUND_ATTR] = _addCurRoundAttr,
[BattleConst.INSTRUCTION_NAME.ASSISTING] = _assisting,
-- [BattleConst.INSTRUCTION_NAME.ASSISTING] = _assisting,
[BattleConst.INSTRUCTION_NAME.GENERAL_ATTACK] = _generalAttack,
[BattleConst.INSTRUCTION_NAME.PLAY_SKILL] = _playSkill,
}

View File

@ -109,38 +109,38 @@ function BattleTeam:useSkill(matchType, count, isFinalAction, effectType, action
end
end
function BattleTeam:useAssistingSkill(assistingList, isFinalAction, callback)
self.isFinalAction = isFinalAction
if self.mainUnit == nil then
return callback()
end
if self.mainUnit:getIsLimit() then
return callback()
end
local count = #assistingList
if count <= 0 then
return callback()
end
self:setCentralizedAttack(true)
local function finish()
count = count - 1
if count == 0 then
self:setCentralizedAttack(false)
callback()
end
end
local delay = 0
for _, v in ipairs(assistingList) do
local unit = self.unitMap[v.skillMatch]
if unit then
unit:resetBeforeAttack()
unit:useAssistingSkill(v.count, delay, finish)
delay = delay + BattleHelper:getSupportInterval()
else
finish()
end
end
end
-- function BattleTeam:useAssistingSkill(assistingList, isFinalAction, callback)
-- self.isFinalAction = isFinalAction
-- if self.mainUnit == nil then
-- return callback()
-- end
-- if self.mainUnit:getIsLimit() then
-- return callback()
-- end
-- local count = #assistingList
-- if count <= 0 then
-- return callback()
-- end
-- self:setCentralizedAttack(true)
-- local function finish()
-- count = count - 1
-- if count == 0 then
-- self:setCentralizedAttack(false)
-- callback()
-- end
-- end
-- local delay = 0
-- for _, v in ipairs(assistingList) do
-- local unit = self.unitMap[v.skillMatch]
-- if unit then
-- unit:resetBeforeAttack()
-- unit:useAssistingSkill(v.count, delay, finish)
-- delay = delay + BattleHelper:getSupportInterval()
-- else
-- finish()
-- end
-- end
-- end
function BattleTeam:mainUnitUseAllSkills(actionState, callback)
self.isFinalAction = true

View File

@ -54,8 +54,8 @@ function BattleBaseData:init(params, snapInfo)
BattleSkillEntity.sid = 0
self.atkTeam = self:initTeam(SIDE_ATK, params.atkFormation)
self.defTeam = self:initTeam(SIDE_DEF, params.defFormation)
self:initRogueSkills(SIDE_ATK, params.atkFormation)
self:initRogueSkills(SIDE_DEF, params.defFormation)
-- self:initRogueSkills(SIDE_ATK, params.atkFormation)
-- self:initRogueSkills(SIDE_DEF, params.defFormation)
self.atkFormation = params.atkFormation or {}
self.defFormation = params.defFormation or {}
self:setMaxBattleLv(nil)
@ -148,39 +148,32 @@ function BattleBaseData:setTimeSpeed(timeSpeed, timeScale)
self.data.timeSpeed = timeSpeed
end
function BattleBaseData:initRogueSkills(side, formation)
if not self.skillPool then
self.skillPool = {}
self.skillMap = {}
end
if not self.skillPool[side] then
self.skillPool[side] = {}
end
if not self.skillMap[side] then
self.skillMap[side] = {}
end
if not formation then
return
end
local skillmap = {}
for matchType, heroEntity in pairs(formation) do
local skillId = heroEntity:getBaseSkill()
local cfg = SKILL_CFG[skillId]
self.skillMap[side][cfg.position] = BATTLE_BOARD_SKILL_ENTITY:create(skillId, side)
self.skillMap[side][cfg.position]:addUpSkills(heroEntity:getRogueSkillList())
self.skillMap[side][cfg.position]:setUnlockId(heroEntity:getUnlockRogueId())
for _, id in ipairs(heroEntity:getActiveRogueSkills()) do
if not skillmap[id] then
if not self.skillPool[side][cfg.position] then
self.skillPool[side][cfg.position] = {}
end
table.insert(self.skillPool[side][cfg.position], id)
skillmap[id] = true
end
end
end
end
-- function BattleBaseData:initRogueSkills(side, formation)
-- self.skillPool = self.skillPool or {}
-- self.skillMap = self.skillMap or {}
-- self.skillPool[side] = self.skillPool[side] or {}
-- self.skillMap[side] = self.skillMap[side] or {}
-- if not formation then
-- return
-- end
-- local skillmap = {}
-- for matchType, heroEntity in pairs(formation) do
-- local skillId = heroEntity:getBaseSkill()
-- local cfg = SKILL_CFG[skillId]
-- self.skillMap[side][cfg.position] = BATTLE_BOARD_SKILL_ENTITY:create(skillId, side)
-- self.skillMap[side][cfg.position]:addUpSkills(heroEntity:getRogueSkillList())
-- self.skillMap[side][cfg.position]:setUnlockId(heroEntity:getUnlockRogueId())
-- for _, id in ipairs(heroEntity:getActiveRogueSkills()) do
-- if not skillmap[id] then
-- if not self.skillPool[side][cfg.position] then
-- self.skillPool[side][cfg.position] = {}
-- end
-- table.insert(self.skillPool[side][cfg.position], id)
-- skillmap[id] = true
-- end
-- end
-- end
-- end
function BattleBaseData:refreshBoard(board, boardEdge, blockIcon, snapshot)
local r = 1
@ -794,7 +787,7 @@ function BattleBaseData:initHeroData(formation)
modelId = heroEntity:getModelId(),
matchType = matchType,
normalSkills = heroEntity:getHurtSkill(),
assistingSkill = heroEntity:getAssistingSkill(),
rougeSkills = heroEntity:getActiveRogueSkills(),
body = 2, -- 英雄默认是中体型
skin = heroEntity:getSkinId(),
attr = {
@ -895,7 +888,6 @@ function BattleBaseData:addMonster(monsterId, newTeam, battleController)
normalSkillCount = monsterInfo.atk_times or 0,
activeSkills = monsterInfo.skill,
passiveSkills = monsterInfo.passive_skill,
assistingSkill = nil,
isBoss = monsterInfo.is_boss,
exp = monsterInfo.monster_exp or 0,
body = monsterInfo.body,

View File

@ -35,9 +35,6 @@ function BattleUnitEntity:initSkill()
self.normalSkillCount = self.unitData.normalSkillCount or 0
end
self.normalSkill = nil
if self.unitData.assistingSkill then
self.assistingSkill = BattleSkillEntity:create(self.unitData.assistingSkill, GConst.BattleConst.SKILL_TYPE_ASSISTING, self)
end
if self.unitData.activeSkills then
for k, v in ipairs(self.unitData.activeSkills) do
local skillShow
@ -55,6 +52,12 @@ function BattleUnitEntity:initSkill()
table.insert(self.passiveSkills, skill)
end
end
if self.unitData.rougeSkills then
for i,v in ipairs(self.unitData.rougeSkills) do
ModuleManager.BattleManager:onSelectSkill(v)
end
end
end
function BattleUnitEntity:getIsBoss()
@ -159,10 +162,6 @@ function BattleUnitEntity:getNormalSkill(reRandom)
return self.normalSkill
end
function BattleUnitEntity:getAssistingSkill()
return self.assistingSkill
end
function BattleUnitEntity:getActiveSkillCount()
return #self.activeSkills
end

View File

@ -341,10 +341,6 @@ function HeroEntity:getBaseSkill()
return self.config.base_skill
end
function HeroEntity:getAssistingSkill()
return self.config.support_skill
end
function HeroEntity:getHurtSkill()
return self.config.hurt_skill
end
@ -386,7 +382,7 @@ function HeroEntity:getMatchType()
end
function HeroEntity:getStarUpCostId()
return self.config.entry
return self.config.star_id
end
function HeroEntity:getStarAttrCfg()
@ -445,15 +441,21 @@ end
function HeroEntity:getActiveRogueSkills()
local list = {}
-- for i = 1, self:getActiveRogueCount() do
-- local id = self:getRogueSkillList()[i]
-- if id then
-- table.insert(list, id)
-- else
-- break
-- end
-- end
local count = 1
while true do
local ids = self.config["rouge_skill_" .. count]
if ids then
for i = #ids, 1, -1 do
if self.data.lv >= ids[i][1] then
table.insert(list, ids[i][2])
break
end
end
else
break
end
count = count + 1
end
return list
end
-- endregion