local Base = require("Battle/Logic/Level/LevelFunction/LevelFunction") local SlgGvELevelFunction = class("SlgGvELevelFunction", Base) --有些特定的关卡buff,可加规则和执行规则是根据阵容来判断的,暂时写死,后续要扩展的话考虑加规则配置 local SameCountryBuff = 626001 --可加规则-同国别(必须满6人)则加这个buff local GoldBreakBuff = 626002 --执行规则-根据金\彩金将突破总等级累加伤害的buff local GoldBreakBuff_DmgRate_Value = 0.005 -- GoldBreakBuff = 626002 这个buff,每突破1级,伤害增加0.5% local StandardGS = DataSheetManager.SlgGvEConstData:GetDataByID(1).StandardGS --基准战力 function SlgGvELevelFunction:GetExpClass() local exp = require "Battle/Expression/ExpLevel/ExpLevelFunction/ExpSlgGvELevelFunction" return exp end function SlgGvELevelFunction:InitLevel() self.allArmyPosBuffs = {} --全军生效的buff self.totalBreakLevel = 0 self.buffIdForFightingEnemy = 0 self.isBuffAdded = false self.goldBreakBuff_DmgRateValue = FP.newV1(0)----需要覆盖公式的值,对应GoldBreakBuff的配置 self.dmgToBoss = FP.newV1(0) self:SetSlgGsData() Base.InitLevel(self) end --领地和贼兵走本地配置战力,boss走服务器战力 function SlgGvELevelFunction:SetSlgGsData() local slgData = LevelManager.GetSlgGveData() local serverGS = LevelManager.GetServerGs() self.buffIdForFightingEnemy = slgData.buffIdForFightingEnemy -- 特别注意:为了抵抗敌人而加的额外buff,是添加到武将身上的,不是添加在怪身上的 if serverGS <= 0 then --城池怪走服务器战力,这个值会大于0;否则发过来为0,本地设置,类似爬塔 if slgData.thiefId > 0 then --优先判断贼兵 local openDayData = DataSheetManager.SlgGvEOpenDay:GetDataByOpenDayid(slgData.openDayId) for _, v in ipairs(openDayData.EnemyScale_Table) do if v.EnemyLevel == slgData.thiefId then serverGS = v.EnemyGSScale break end end else serverGS = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(slgData.landId).GSScale end if serverGS <= 0 then logging.error(LTAG.ERROR, "无法设置本地战力") end serverGS = serverGS * StandardGS LevelManager.SetServerGs(serverGS) end end function SlgGvELevelFunction:IsMusouShowOpen(entity) return false end --是否三军武将同时上场 function SlgGvELevelFunction:IsAllHeroJoinBattle() return true end function SlgGvELevelFunction:OnHpChange(entity, caster, delta, op, realDelta) if delta < FP.Const.Zero and caster then local originEntity = caster:GetOriginEntity() if entity:IsBoss() and originEntity:IsHero() then self.dmgToBoss:Sub(delta) end end end --显示胜利pose的标识 function SlgGvELevelFunction:SetShowVictoryPoseFlag(flag) self.ShowVictoryPoseFlag = flag end function SlgGvELevelFunction:OnCreatePlayer() Base.OnCreatePlayer(self) local mainEntity = BattleDataGetter.GetHeroInHeroEntityTableByIndex(LuaConst.STANDALONE_PLAYER_PlayID, 1) self:StartAutoFight(mainEntity) self:CalculateLevelBuff(LevelPlayerManager.buffIdList) end --提前计算要加哪些buff function SlgGvELevelFunction:CalculateLevelBuff(levelBuffIdList) if levelBuffIdList then local isSameCountry, totalBreakLevel = self:CheckLevelBuff() self.totalBreakLevel = totalBreakLevel self.goldBreakBuff_DmgRateValue:Reset(GoldBreakBuff_DmgRate_Value):Mul(totalBreakLevel) for _, levelBuff in ipairs(levelBuffIdList) do if levelBuff == SameCountryBuff then if isSameCountry then table.insert(self.allArmyPosBuffs, levelBuff) --同国别才可加 end else --其他的添加规则,没有就先加上 table.insert(self.allArmyPosBuffs, levelBuff) end end end end --出战的主副将是否都属于同一国家,以及总共突破等级是多少 function SlgGvELevelFunction:CheckLevelBuff() local heroIds = {} local checkCountry local isSameCountry = true local totalBreakLevel = 0 local entityTable = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(LuaConst.STANDALONE_PLAYER_PlayID) local armyList = LevelPlayerManager.GetPlayerArmyByPlayerIDInRoom(LuaConst.STANDALONE_PLAYER_PlayID) --主副将都要检查 for i, entity in ipairs(entityTable) do local mainHeroID = entity:GetCharacterID() table.insert(heroIds, mainHeroID) local heroQuality = 0 if armyList[i].mainHeroAwaken then local heroData = DataSheetManager.AwakenHeroNum:GetDataByID(mainHeroID) heroQuality = heroData.HeroQuality else local heroData = DataSheetManager.HeroNum:GetDataByID(mainHeroID) heroQuality = heroData.HeroQuality end if heroQuality >= LuaConst.QualityColor.Gold then totalBreakLevel = totalBreakLevel + entity._logicInitData.HeroBreakNums end local adjutantEntity = entity.components.adjutant.AdjutantEntity if adjutantEntity then local adjutantID = entity.components.adjutant:GetAdjutantCharacterID() table.insert(heroIds, adjutantID) local adjutantHeroQuality = 0 if armyList[i].viceHeroAwaken then local adjutantHeroData = DataSheetManager.AwakenHeroNum:GetDataByID(adjutantID) adjutantHeroQuality = adjutantHeroData.HeroQuality else local adjutantHeroData = DataSheetManager.HeroNum:GetDataByID(adjutantID) adjutantHeroQuality = adjutantHeroData.HeroQuality end if adjutantHeroQuality >= LuaConst.QualityColor.Gold then totalBreakLevel = totalBreakLevel + entity.components.adjutant.AdjutantEntity._logicInitData.HeroBreakNums end end end if #heroIds == 6 then for _, heroId in ipairs(heroIds) do local heroData = DataSheetManager.HeroNum:GetDataByID(heroId) local curCountry = heroData.Kingdom if not checkCountry then checkCountry = curCountry elseif checkCountry ~= curCountry then isSameCountry = false break end end else isSameCountry = false end return isSameCountry, totalBreakLevel end function SlgGvELevelFunction:OnUpdate() if self.handleEndLevelFrame == LogicUpdateManager._clientHandleFrame then LevelItemManager.Global:HandleEndLevel(false, true) end --添加入场buff,参考BossChallengeLevelFunction if LogicUpdateManager._clientHandleFrame > 3 and not self.isBuffAdded then self.isBuffAdded = true local entityTable = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(LuaConst.STANDALONE_PLAYER_PlayID) --添加Buff for _, entity in ipairs(entityTable) do self:AddLevelBuff(entity) end end end function SlgGvELevelFunction:AddLevelBuff(entity) if self.buffIdForFightingEnemy > 0 then local addBuffId = DataSheetManager.SlgGvEEnemyBuff:GetDataBySkillSignID(self.buffIdForFightingEnemy).SkillID if self:CanAddBuffToEntity(addBuffId, entity) then SystemManager.AddBuff(entity, addBuffId, entity) end end if self.allArmyPosBuffs then for _, buffId in ipairs(self.allArmyPosBuffs) do local canAdd = self:CanAddBuffToEntity(buffId, entity) if canAdd then if buffId == GoldBreakBuff then --执行规则,根据突破等级修改公式 if self.totalBreakLevel > 0 then local ratio = FP.tonumberV1(self.goldBreakBuff_DmgRateValue) local buffCtrl = RuntimeDataManager.New_BuffCtrl() buffCtrl.BuffOverRideFomula = "aim:add(findmgvar," .. ratio .. ")" SystemManager.AddBuff(entity, buffId, entity, nil, buffCtrl) end else SystemManager.AddBuff(entity, buffId, entity, nil, nil) end end end end end function SlgGvELevelFunction:CanAddBuffToEntity(buffId, entity) local canAdd = false local buffData = DataSheetManager.BuffData:GetDataByBuffID(buffId) if buffData then if buffData.ArmyFilter == LuaConst.EArmyFilter.SAME_ARMY_POS then if BuffManager.IsMeetHeroTypeFilterOfBuff(buffData,entity:GetCharacterID()) or BuffManager.IsMeetHeroTypeFilterOfBuff(buffData,entity.components.adjutant:GetAdjutantCharacterID()) then canAdd = true end elseif buffData.ArmyFilter == LuaConst.EArmyFilter.SELF then if BuffManager.IsMeetHeroTypeFilterOfBuff(buffData,entity:GetCharacterID()) then canAdd = true end else canAdd = true end end return canAdd end function SlgGvELevelFunction:AfterSwitchHero(fromEntity, toEntity, dontBackground) Base.AfterSwitchHero(self, fromEntity, toEntity, dontBackground) local robotAI = self:GetRobotAI(toEntity) if robotAI then toEntity.components.aiBase:SetSingleCurrentAiByID(robotAI) end end function SlgGvELevelFunction:QuitRoom(entity) self.ShowVictoryPoseFlag = true self.handleEndLevelFrame = LogicUpdateManager._clientHandleFrame + 2 --这里直接HandleEndLevel会导致ShowVictoryPose播不出动画,所以异步到OnUpdate里面去 end function SlgGvELevelFunction:GetSubjugateDataPVEID() local slgData = LevelManager.GetSlgGveData() local success, slgGvEPlotData = DataSheetManager.SlgGvEPlotData:TryGetDataByGveMapID(slgData.landId) if success then return slgGvEPlotData.SubjugateDataPVE end return 0 end return SlgGvELevelFunction