local country_boss_pb = require 'Proto/country_boss_pb' local country_boss_def_pb = require 'Proto/country_boss_def_pb' local EventSystem = require('Event/EventSystem') local Base = require("Battle/Logic/Level/LevelFunction/SyncWorldBossLevelFunction") local SyncCountryEveningBossLevelFunction = class("SyncCountryEveningBossLevelFunction",Base) local SameCountryBuffID = 500461 --如果玩家跟boss的国家一致,则添加这个buff function SyncCountryEveningBossLevelFunction:GetExpClass() return require "Battle/Expression/ExpLevel/ExpLevelFunction/ExpSyncCountryEveningBossLevelFunction" end function SyncCountryEveningBossLevelFunction:InitLevel() Base.InitLevel(self) self.isFightModeFixed = true --伤害模式是否是固定的、无法改变的 self.dontIgnoreEnemy = true --不使用忽略敌人机制,节省性能 self.shouldCountDownAtFirst = true self:OpenPlayerToBossDamageRecord()--晚间boss需要伤害记录,用来判断尾刀(2023年1月16日) for _,data in DataSheetManager.CountryNightBoss:GetEnumerator() do if data.LevelID == LevelManager.GetCurLevelID() then self.bossCountryId = data.BossNation break end end end function SyncCountryEveningBossLevelFunction:OnCreateNewPlayerFinish(playerID) Base.OnCreateNewPlayerFinish(self, playerID) --self:StartAutoFight(LevelPlayerManager.GetPlayerActiveEntity(playerID)) --策划又要求不能开自动战斗了 end function SyncCountryEveningBossLevelFunction:InitPlayerStatistic(statistic) Base.InitPlayerStatistic(self, statistic) statistic[LuaConst.EStatisticType.DamageBossHP] = FP.newV1(0) end --只有随进随出玩法会调这个 function SyncCountryEveningBossLevelFunction:OnPlayerActived(playerID) Base.OnPlayerActived(self, playerID) self:ChangeRecordHpOfPlayer(playerID, LevelPlayerManager.GetPlayerDamageBefore(playerID)) -- 策划需求这个玩法出房间后再进,伤害值还得保留,在这里根据服务器的数据初始化一下伤害 local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID) if playerInfo.countryId == self.bossCountryId then local entities = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) for i,entity in ipairs(entities) do SystemManager.AddBuff(entity, SameCountryBuffID, entity) end end end function SyncCountryEveningBossLevelFunction:GetDefaultFightMode(worldBossId) return LuaConst.EFightMode.TEAM_GUILD end function SyncCountryEveningBossLevelFunction:AfterHanleHeroDead(killer, deadEntity, involveKillPlayerIDList, assistHeroEntityIDList, kStatistic) --最后一个参数填true,表示仅给killer增加击杀数(基类世界boss默认是给所有参与击杀的玩家增加击杀数,晚间boss要求仅给killer增加) Base.AfterHanleHeroDead(self, killer, deadEntity, involveKillPlayerIDList, assistHeroEntityIDList, kStatistic, true) end function SyncCountryEveningBossLevelFunction:CanHurtBoss(playerInfo) return true end function SyncCountryEveningBossLevelFunction:OnHpChange(entity, caster, delta, op) Base.OnHpChange(self, entity, caster, delta, op) self:TryAddDamageBossHPStatistic(entity, caster, delta, op) end function SyncCountryEveningBossLevelFunction:GetBattlePlayerInfos() local msg = country_boss_def_pb.CountryNightBossPlayerInfos() for _,playerID in ipairs(LevelPlayerManager.SyncPlayerIDList) do local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID) -- 玩家基础信息 local statisticInfo = self.PlayerStatisticDic[playerID] -- 玩法统计数据 if statisticInfo then -- 由于服务器校验时 ,一些战场是没人的,没人的战场传入的数据为null local subMsg = country_boss_def_pb.CountryNightBossPlayerInfo() subMsg.acid = playerInfo.acid -- 玩家acid local damage = self:GetDamageOfPlayer(playerID) if damage then damage = FP.tonumberV1(damage) else damage = 0 end subMsg.damage = damage subMsg.kill = statisticInfo[LuaConst.EStatisticType.RelaxHeroKillNum] -- 宽限击杀条件的击杀数:只要在1秒内参与伤害了就算是击杀了。-- 2023-3-28 subMsg.assist = statisticInfo[LuaConst.EStatisticType.RelaxAssistHeroKillNum] -- 宽限击杀条件的 助攻数 2023-3-28 subMsg.dead = statisticInfo[LuaConst.EStatisticType.DeadCount] -- 重伤数 (即玩家死亡主将数量) table.insert(msg.playerInfos, subMsg) end end return msg:SerializeToString() end --设置结算协议 function SyncCountryEveningBossLevelFunction:SendBattleResult(isSuccess) --不调用Base self.isResultSent = true logging.log(LTAG.LOG ,"[SyncCountryEveningBoss] : SendBattleResult ") local playerHerosHPDic = self:GetAllPlayerHerosHP() local checkStr = self:GetCheckStr() local msg = country_boss_pb.C2GUploadCountryNightBossResult() for _, playerID in ipairs(LevelPlayerManager.SyncPlayerIDList) do local fighter = country_boss_def_pb.FighterCNBResult() fighter.playerID = playerID fighter.damage = self:GetDamageOfPlayer(playerID) and math.floor(FP.tonumberV1(self:GetDamageOfPlayer(playerID))) or 0 local statisticInfo = self.PlayerStatisticDic[playerID] fighter.killNum = statisticInfo and statisticInfo[LuaConst.EStatisticType.RelaxHeroKillNum] or 0 -- 宽限击杀条件的击杀数:只要在1秒内参与伤害了就算是击杀了。-- 2023-3-28 fighter.assistNum = statisticInfo and statisticInfo[LuaConst.EStatisticType.RelaxAssistHeroKillNum] or 0 -- 宽限击杀条件的 助攻数 2023-3-28 fighter.deadNum = self:GetPlayerDeadHeroCount(playerID) fighter.playerAcid = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID) and LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(playerID).acid self:ClearKillNum(playerID) table.insert(msg.allFighterRes ,fighter) end msg.CheckInfo = checkStr if LogicUpdateManager.IsReplayOrServerCheck then -- 客户端重播或服务器校验的话,不要发送TCP logging.log(LTAG.LOG, "HYW : SyncCountryEveningBoss BattleCheckStr = ", checkStr) else EventSystem.Dispatch(EventID.CountryEveningBoss_SendResult, msg) end if USE_LUA_STANDALONE then BattleSimulator.SetCheckResult(checkStr, msg:SerializeToString()) end end return SyncCountryEveningBossLevelFunction