local Base = require("Battle/Logic/Level/LevelFunction/SyncGuildWarBaseLevelFunction") local SyncGuildWarMapSideLevelFunction = class("SyncGuildWarMapSideLevelFunction",Base) local guild_war_base_pb = require 'Proto/guild_war_base_pb' local EventSystem = require("Event/EventSystem") local FP = FP local BOSS_KILL_SCORE_COUNT = 5 local BOSS_KILL_SCORE_KEY_LIST = { "GuildWarBossPoint1", "GuildWarBossPoint2", "GuildWarBossPoint3", "GuildWarBossPoint4", "GuildWarBossPoint5", } local INFOTYPE_CATAPULT = LuaConst.EGuildWarAttackInfoType.SIDE_CATAPULT local INFOTYPE_SIDE_BOSS = LuaConst.EGuildWarAttackInfoType.SIDE_BOSS local EGuildWarInfoState = LuaConst.EGuildWarInfoState -- 投石车的MonsterFeatureID local Const_Catapult_FeatureID = 47 --boss的MonsterID字典 local BossCharacterIDDic = { [35501131] = true, [35501132] = true, [35501133] = true, } function SyncGuildWarMapSideLevelFunction:InitLevel() Base.InitLevel(self) self.bossDmgInfoListDic = {} --key 是boss的entityID,value是一个list,元素是{playerID, dmg}(玩家对这个boss造成的伤害) self.bossLastDmgFrame = -99999 --boss上次被打或者造成伤害的帧数,因为同一时间只有1个boss,所以只记录1个 self.catapultDmgFrame = -99999 --投石车次被打或者造成伤害的帧数,因为战场只有1个投石车,所以只记录1个 self.isBossDead = true --boss是否已经死了。初始没刷boss的时候就认为是死亡,所以默认值为true end --本场战斗有多少个营地 function SyncGuildWarMapSideLevelFunction:GetCampsiteCount() return 1 end function SyncGuildWarMapSideLevelFunction:GetMapAttackInfo() local msg = guild_war_base_pb.GuildWarMapAttackInfoList() local info = guild_war_base_pb.GuildWarMapAttackInfo() info.Id = INFOTYPE_CATAPULT if LogicUpdateManager._clientHandleFrame - 20 <= self.catapultDmgFrame then info.state = EGuildWarInfoState.ATTACKING else info.state = EGuildWarInfoState.NORMAL end if self.catapultEntityList[1] then if self.catapultEntityList[1].components.drive.BeDrivedByEntity then local playerInfo = LevelPlayerManager.GetPlayerInfoByPlayerIDInRoom(self.catapultEntityList[1].components.drive.BeDrivedByEntity:GetPlayerID()) info.Acid = playerInfo.acid end end table.insert(msg.attackInfos, info) info = guild_war_base_pb.GuildWarMapAttackInfo() info.Id = INFOTYPE_SIDE_BOSS if self.isBossDead then info.state = EGuildWarInfoState.DEAD elseif LogicUpdateManager._clientHandleFrame - 20 <= self.bossLastDmgFrame then info.state = EGuildWarInfoState.BEING_ATTACKED else info.state = EGuildWarInfoState.NORMAL end table.insert(msg.attackInfos, info) return msg:SerializeToString() end function SyncGuildWarMapSideLevelFunction:OnHpChange(entity, caster, delta, op) if op == "sub" and delta < FP.Const.Zero then -- 先不考虑加血的情况 ,如果有 ,需要改下面代码 if caster.featureID == Const_Catapult_FeatureID then self.catapultDmgFrame = LogicUpdateManager._clientHandleFrame end if BossCharacterIDDic[entity:GetCharacterID()] then EventSystem.Dispatch(EventID.GuildWar_Boss_Got_Damage, entity) self.bossLastDmgFrame = LogicUpdateManager._clientHandleFrame local dmgDealer = caster:GetOriginEntity() if dmgDealer.isHero then --↓ 统计英雄对boss的伤害量 local dmgDealerPlayerID = dmgDealer:GetPlayerID() local infoList = self.bossDmgInfoListDic[entity.EntityID] local info for i,v in ipairs(infoList) do if v.playerID == dmgDealerPlayerID then info = v break end end if info == nil then info = {playerID = dmgDealerPlayerID, campID = dmgDealer:GetCampID(), dmg = FP.newV1(0)} table.insert(infoList, info) end info.dmg:Sub(delta) --↑统计英雄对boss的伤害量 end elseif BossCharacterIDDic[caster:GetCharacterID()] then self.bossLastDmgFrame = LogicUpdateManager._clientHandleFrame end end Base.OnHpChange(self, entity, caster, delta, op) end function SyncGuildWarMapSideLevelFunction:OnEntityBorn(entity) Base.OnEntityBorn(self, entity) if BossCharacterIDDic[entity:GetCharacterID()] then self.bossDmgInfoListDic[entity.EntityID] = {} self.isBossDead = false end end local bossDmgInfoSorter = function(a, b) return a.dmg > b.dmg end function SyncGuildWarMapSideLevelFunction:OnEntityDead(entity, deadParams) Base.OnEntityDead(self, entity, deadParams) if BossCharacterIDDic[entity:GetCharacterID()] then self.isBossDead = true local killer = entity.components.record.KillerEntity local killerCamp = -1 if killer then killerCamp = killer:GetCampID() end local infoList = self.bossDmgInfoListDic[entity.EntityID] table.sort(infoList, bossDmgInfoSorter) local playerStatistic local count = 0 for i=1,#infoList do local info = infoList[i] if info and info.campID == killerCamp then count = count + 1 playerStatistic = self.PlayerStatisticDic[info.playerID] if playerStatistic then playerStatistic[LuaConst.EStatisticType.GwScorePlus] = playerStatistic[LuaConst.EStatisticType.GwScorePlus] + DataSheetManager.ConstData:GetDataByID(BOSS_KILL_SCORE_KEY_LIST[count]).IntValue end end if count == BOSS_KILL_SCORE_COUNT then break end end end end function SyncGuildWarMapSideLevelFunction:OnPlayerActived(playerID) Base.OnPlayerActived(self, playerID) self:SetBornItemIDOfPlayerByWeightListWithIndex(playerID, 1) -- 只有一个复活点【策划配置的关卡开始就设置时不会生效的因为当时entity还不存在】 end return SyncGuildWarMapSideLevelFunction