---@class BTT_AccessoryMonster_Whirlwind_C:BTTask_LuaBase ---@field DelaySpawnWind float ---@field WaitTime float ---@field DelayGiveHurt float ---@field ForwardLength float --Edit Below-- local BTT_AccessoryMonster_Whirlwind = { CtrlPawn = nil, } -- entry point, task will stay active until FinishExecute is called function BTT_AccessoryMonster_Whirlwind:ReceiveExecuteAI(OwnerController, ControlledPawn) if not UGCGameSystem.IsServer() then self:FinishExecute(true) return end OwnerController:GetBlackboardComponent():SetValueAsBool("CanPlayWhirlwind", false) local PlayerLocation = OwnerController:GetBlackboardComponent():GetValueAsObject("TargetActor"):K2_GetActorLocation() PlayerLocation.Z = 0 local MonsterLocation = ControlledPawn:K2_GetActorLocation() local DropLocation = UGCGameSystem.GameState:GetDropLocation(MonsterLocation) MonsterLocation.Z = 0 local DestRot = KismetMathLibrary.FindLookAtRotation(MonsterLocation, PlayerLocation) ControlledPawn:K2_SetActorRotation(DestRot, false) self.CtrlPawn = ControlledPawn local SpawnForward = self.CtrlPawn:GetActorForwardVector() local SpawnLocation = VectorHelper.Add(DropLocation, VectorHelper.MulNumber(KismetMathLibrary.Normal(SpawnForward), self.ForwardLength)) local SpawnRotator = DestRot EventSystem.SetTimer( self.CtrlPawn, function() UGCGameSystem.SpawnActor( self.CtrlPawn, UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/Monster/Skill/BP_Whirlwind.BP_Whirlwind_C')), SpawnLocation, SpawnRotator, VectorHelper.ScaleOne(), self.CtrlPawn ) end, self.DelaySpawnWind ) EventSystem.SetTimer( self.CtrlPawn, function() local HitPawns = self:BoxTraceForward(ControlledPawn, OwnerController, 10000, 150, 200) if not table.isEmpty(HitPawns) then local CanDamagePlayers = self.CtrlPawn:GetCanDamagePlayer() if not table.isEmpty(CanDamagePlayers) then local CanAddAttack = false for k, TargetPawn in pairs(HitPawns) do if table.hasValue(CanDamagePlayers, TargetPawn) then self.CtrlPawn:MonsterApplyDamage(TargetPawn, self.CtrlPawn:GetAttack() * 10) CanAddAttack = true end end if CanAddAttack then self.CtrlPawn:AddAttack() end end end end, self.DelaySpawnWind + self.DelayGiveHurt ) EventSystem.SetTimer( self, function() self:FinishExecute(true) end, self.WaitTime ) end function BTT_AccessoryMonster_Whirlwind:BoxTraceForward(ControlledPawn, OwnerController, Length, Width, Height) local Forward = ControlledPawn:GetActorForwardVector() local BoxLoc = VectorHelper.Add(ControlledPawn:K2_GetActorLocation(), VectorHelper.MulNumber(KismetMathLibrary.Normal(Forward), Length / 2)) local CasterRotation = ControlledPawn:K2_GetActorRotation() local BoxRotation = {Yaw = CasterRotation.Yaw, Pitch = CasterRotation.Pitch, Roll = CasterRotation.Roll} local BoxExtent = {X = Length/2, Y = Width/2, Z = Height/2} local AllPlayers = UGCGameSystem.GetAllPlayerPawn() if not table.isEmpty(AllPlayers) then table.removeValue(AllPlayers, OwnerController:GetBlackboardComponent():GetValueAsObject("TargetActor"), true) end local ObjectTypes = {EObjectTypeQuery.ObjectTypeQuery3} local ActorClassFilter = UE.LoadClass(BPClassPath.PlayerPawn) local ActorsToIgnore = AllPlayers local RetVal, OutActors = KismetSystemLibrary.BoxOverlapActors(ControlledPawn, BoxLoc, BoxRotation, BoxExtent, ObjectTypes, ActorClassFilter, ActorsToIgnore) if RetVal then local ResultActors = {} for _, v in pairs(OutActors) do table.insert(ResultActors, v) end return ResultActors else return {} end end return BTT_AccessoryMonster_Whirlwind