local base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_TargetOnlyBossFight = class("Decision_TargetOnlyBossFight", base) local BuffSkillSystem = require"Battle/Logic/Entity/System/BuffSkillSystem" 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_TargetOnlyBossFight:initialize(entity) base.initialize(self,entity) --类型 self.Type = LuaConst.DecisionType.TargetOnlyBossFight --瞬时 self.IsOnce = false end --[[ 进入该Decision --]] function Decision_TargetOnlyBossFight:DecisionIn(entity, decisionData) base.DecisionIn(self,entity,decisionData) SystemManager.SetTarget(entity, nil) end --[[ 退出该Decision --]] function Decision_TargetOnlyBossFight:DecisionOut(entity, decisionData) SystemManager.SetTarget(entity,nil) entity.components.target:SetForceTarget(nil) base.DecisionOut(self, entity, decisionData) end --[[ 能否进入 --]] function Decision_TargetOnlyBossFight:CanEnter(entity, decisionData, command) local autoFightComponent = entity.components.autoFight return autoFightComponent.IsSyncAuto end --[[ 能否退出 --]] function Decision_TargetOnlyBossFight:CanExit(entity, decisionData, command) local autoFightComponent = entity.components.autoFight return not autoFightComponent.IsSyncAuto end local MONSTER_TYPE_2_SERACH_TYPE_PLUS = 100 function Decision_TargetOnlyBossFight: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_TargetOnlyBossFight: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 if targetComponent.Target == nil then self:SearchBoss(entity, targetComponent) 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 end until true end return Decision_TargetOnlyBossFight