local BuffSkillSystem = require"Battle/Logic/Entity/System/BuffSkillSystem" local base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_WorldBossFight = class("Decision_WorldBossFight", base) local SEARCH_ENEMY_DIS_SQR = FP.newV1(10000) local NEW_WANDER_POS_POSIBILITY = FP.newV1(0.05) local KEY_POS_GODBEAST = LuaConst.ESkillKeyPosition.BuffSkill2 function Decision_WorldBossFight:initialize(entity) base.initialize(self,entity) --类型 self.Type = LuaConst.DecisionType.WorldBossFight --瞬时 self.IsOnce = false self.SCENE_RADIUS = FP.newV1(22) self.CENTER = FP.newV2(90,0) self.REFRESH_FORCE_TARGET_FRAME_INTERVAL = DataSheetManager.ConstData:GetDataByID("WorldBossTeamSearchingForEnemyInterval").IntValue end local MY_CAMPID_WHEN_TUTORIAL = 1 local ENEMY_CAMPID_WHEN_TUTORIAL = 2 --[[ 进入该Decision --]] function Decision_WorldBossFight:DecisionIn(entity, decisionData) base.DecisionIn(self,entity,decisionData) SystemManager.SetTarget(entity,nil) --机器人支持↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ if entity._logicInitData.BattleMemberType == LuaConst.BattleMemberType.Robot_Hero then local campID = entity:GetCampID() if campID == MY_CAMPID_WHEN_TUTORIAL then --如果是我方机器人,则是来助战的,就盯着对面的人打,所以需要设置ForceTeam entity.components.target:SetForceTeam(1000) end end --↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ end --[[ 退出该Decision --]] function Decision_WorldBossFight:DecisionOut(entity, decisionData) SystemManager.SetTarget(entity,nil) entity.components.target:SetForceTarget(nil) entity.components.aiBase:ClearDecisionRecord(decisionData) end --[[ 能否进入 --]] function Decision_WorldBossFight:CanEnter(entity, decisionData, command) local autoFightComponent = entity.components.autoFight return autoFightComponent.IsSyncAuto end --[[ 能否退出 --]] function Decision_WorldBossFight:CanExit(entity, decisionData, command) local autoFightComponent = entity.components.autoFight return not autoFightComponent.IsSyncAuto end --会同时刷新ForceTarget和Target function Decision_WorldBossFight:RefreshForceTargetOfForceTeamAndSetTarget(decisionRecordDic, targetComponent) targetComponent:RefreshForceTargetOfForceTeam() if targetComponent.ForceTarget then targetComponent:SetTarget(targetComponent.ForceTarget) end decisionRecordDic.refreshForceTargetEla = 0 end function Decision_WorldBossFight:IntervalRefreshForceTarget(decisionRecordDic, aiBaseComponent, targetComponent) if decisionRecordDic.refreshForceTargetEla == nil or decisionRecordDic.refreshForceTargetEla >= self.REFRESH_FORCE_TARGET_FRAME_INTERVAL then self:RefreshForceTargetOfForceTeamAndSetTarget(decisionRecordDic, targetComponent) else decisionRecordDic.refreshForceTargetEla = decisionRecordDic.refreshForceTargetEla + aiBaseComponent:GetAiUpdateInterval() end end local MONSTER_TYPE_2_SERACH_TYPE_PLUS = 100 function Decision_WorldBossFight:SearchBoss(entity, targetComponent) local mainBoss = BattleDataGetter.GetMainBoss() if mainBoss then --找寻主Boss SystemManager.OnSearchTarget(entity, 1, SEARCH_ENEMY_DIS_SQR, 1, mainBoss._logicInitData._characterData.MonsterType + LuaConst.MONSTER_TYPE_2_SERACH_TYPE_PLUS) targetComponent:SetForceTarget(targetComponent.Target) end end local PAUSE_FRAME_AFTER_USER_INPUT = 10 --有玩家输入后,该Decision暂停几帧 --[[ 输出指令 --]] function Decision_WorldBossFight:SetCommand(entity, decisionData, command) repeat local aiBaseComponent = entity.components.aiBase local decisionRecordDic = aiBaseComponent:GetDecisionRecordDic(decisionData) if command.MoveDir ~= FP.Const.Vector2_Zero or command.SkillIndex ~= 0 then --如果有玩家输入,记录这个输入的时间,并跳出AI运行 decisionRecordDic.lastUserInputFrame = LogicUpdateManager._clientHandleFrame entity.components.target:SetForceTarget(nil) command.DontHandle = true break end if decisionRecordDic.lastUserInputFrame and LogicUpdateManager._clientHandleFrame - decisionRecordDic.lastUserInputFrame < PAUSE_FRAME_AFTER_USER_INPUT then --策划需求:如果玩家有输入,就得暂停AI运行一段时间 command.DontHandle = true break end local targetComponent = entity.components.target self:IntervalRefreshForceTarget(decisionRecordDic, aiBaseComponent, targetComponent)--间隔一定时间根据强制队伍刷新强制目标 if targetComponent.ForceTarget and targetComponent.ForceTarget:IsAlive() and targetComponent.ForceTarget:IsActive() then if targetComponent.Target ~= targetComponent.ForceTarget then SystemManager.SetTarget(entity,targetComponent.ForceTarget) end else if targetComponent.ForceTarget == nil then --没有强制目标,则优先以boss为目标 if targetComponent.Target == nil or targetComponent.Target:IsHero() then self:SearchBoss(entity, targetComponent) end else --如果有强制目标 且 强制目标死了/未激活 的情况 --※这里包含条件 not targetComponent.ForceTarget:IsAlive() or not targetComponent.ForceTarget:IsActive() if targetComponent.ForceTarget:HasTeam() then --如果强制目标有队伍,则立即刷新强制目标 self:RefreshForceTargetOfForceTeamAndSetTarget(decisionRecordDic, targetComponent) if targetComponent.ForceTarget == nil then --如果找不到合适的强制目标了,就找boss self:SearchBoss(entity, targetComponent) end else --强制目标没有队伍,那么直接找boss self:SearchBoss(entity, targetComponent) end end end if targetComponent.Target then --有目标就追击目标 self:CommandChaseUseSkill(entity,command,decisionData,decisionRecordDic) if self:CanUseBuffSkill(entity, decisionRecordDic, 2) then BuffSkillSystem.ReleaseBuffSkill(entity, KEY_POS_GODBEAST) --无脑调,如果放不了就不会放 end else --没目标就随机闲逛 command = self:CommandRandomWander(entity,aiBaseComponent,decisionData,entity:GetLogicPos(), self.CENTER, self.SCENE_RADIUS, command, NEW_WANDER_POS_POSIBILITY) end until true end return Decision_WorldBossFight