113 lines
4.5 KiB
Lua
113 lines
4.5 KiB
Lua
---@class BTT_BossBoorishBaseSkill_C:BTTask_LuaBase
|
|
---@field SkillIndex int32
|
|
---@field SkillType TEnumAsByte<UTSkillEventType>
|
|
--Edit Below--
|
|
local BTT_BossBoorishBaseSkill = {
|
|
CtrlPawn = nil;
|
|
}
|
|
|
|
-- entry point, task will stay active until FinishExecute is called
|
|
function BTT_BossBoorishBaseSkill:ReceiveExecuteAI(OwnerController, ControlledPawn)
|
|
BTFunctionLibrary.SetBlackboardValueAsBool(self, self.ActiveBool, false)
|
|
|
|
self.CtrlPawn = ControlledPawn
|
|
local PlayerLocation, MoveLocation = self:GetMovablePosition()
|
|
if MoveLocation then
|
|
ControlledPawn:K2_SetActorLocation(MoveLocation, false, nil, false)
|
|
PlayerLocation.Z = 0
|
|
MoveLocation.Z = 0
|
|
ControlledPawn:K2_SetActorRotation(KismetMathLibrary.FindLookAtRotation(MoveLocation, PlayerLocation))
|
|
end
|
|
self:PlaySkill()
|
|
|
|
EventSystem.SetTimer(
|
|
self,
|
|
function()
|
|
local PawnForward = self.CtrlPawn:GetActorForwardVector()
|
|
local CenterPosition = VectorHelper.Add(self.CtrlPawn:K2_GetActorLocation(), VectorHelper.MulNumber(PawnForward, 350))
|
|
local GiveHurtPlayers = self.CtrlPawn:GetSphereActors(CenterPosition, 300, self.CtrlPawn:GetPawnClass())
|
|
if GiveHurtPlayers then
|
|
for k, Player in pairs(GiveHurtPlayers) do
|
|
self.CtrlPawn:MonsterApplyDamage(Player, self.CtrlPawn:GetAttack() * 5 + self.CtrlPawn:GetDefense() - self.CtrlPawn.BasePhysicalDefense)
|
|
end
|
|
end
|
|
if self.HurtTime > self.SkillTime then
|
|
self:FinishExecute(true)
|
|
end
|
|
end,
|
|
self.HurtTime
|
|
)
|
|
EventSystem.SetTimer(
|
|
self,
|
|
function ()
|
|
if self.SkillTime >= self.HurtTime then
|
|
self:FinishExecute(true)
|
|
end
|
|
end,
|
|
self.SkillTime
|
|
)
|
|
|
|
end
|
|
|
|
function BTT_BossBoorishBaseSkill:PlaySkill()
|
|
local SkillManager = self.CtrlPawn:GetSkillManagerComponent()
|
|
if SkillManager ~= nil then
|
|
SkillManager:TriggerEvent(self.SkillIndex, self.SkillType)
|
|
end
|
|
if self.CtrlPawn.UpdateSkillCount ~= nil then
|
|
self.CtrlPawn:UpdateSkillCount()
|
|
end
|
|
end
|
|
|
|
function BTT_BossBoorishBaseSkill:GetEightpoint(Length)
|
|
local Angle45Len = math.sqrt(2) / 2
|
|
return {
|
|
Vector.New(Length, 0, 0),
|
|
Vector.New(-Length, 0, 0),
|
|
Vector.New(0, Length, 0),
|
|
Vector.New(0, -Length, 0),
|
|
Vector.New(Length * Angle45Len, Length * Angle45Len, 0),
|
|
Vector.New(-Length * Angle45Len, Length * Angle45Len, 0),
|
|
Vector.New(Length * Angle45Len, -Length * Angle45Len, 0),
|
|
Vector.New(-Length * Angle45Len, -Length * Angle45Len, 0)
|
|
}
|
|
end
|
|
|
|
function BTT_BossBoorishBaseSkill:GetMovablePosition()
|
|
local ArenaPlayers = UGCGameSystem.GameState:GetPlayersInArena()
|
|
if not table.isEmpty(ArenaPlayers) then
|
|
local ResLocation = {}
|
|
for _, ArenaPlayer in pairs(ArenaPlayers) do
|
|
local PawnHelfHeight = ArenaPlayer.CapsuleComponent.CapsuleHalfHeight
|
|
local Playerlocation = ArenaPlayer:K2_GetActorLocation()
|
|
Playerlocation.Z = Playerlocation.Z + self.CtrlPawn.Capsule.CapsuleHalfHeight - PawnHelfHeight + 5
|
|
|
|
local EightLocation = self:GetEightpoint(350)
|
|
for k, AddLocation in pairs(EightLocation) do
|
|
local Beginlocation = VectorHelper.Add(Playerlocation, AddLocation)
|
|
local ObjectTypes = {EObjectTypeQuery.ObjectTypeQuery1}
|
|
local bHit, _ = KismetSystemLibrary.CapsuleTraceSingleForObjects(
|
|
self, Beginlocation, Beginlocation,
|
|
self.CtrlPawn.Capsule.CapsuleRadius, self.CtrlPawn.Capsule.CapsuleHalfHeight,
|
|
ObjectTypes, false, nil, EDrawDebugTrace.None,
|
|
nil, true, nil, nil, 20
|
|
)
|
|
|
|
if not bHit then
|
|
if ResLocation[ArenaPlayer] == nil then
|
|
ResLocation[ArenaPlayer] = {}
|
|
end
|
|
table.insert(ResLocation[ArenaPlayer], VectorHelper.ToLuaTable(Beginlocation))
|
|
end
|
|
end
|
|
end
|
|
if not table.isEmpty(ResLocation) then
|
|
local TempPlayer = table.getKeys(ResLocation)[math.random(1, table.getCount(ResLocation))]
|
|
local Locations = ResLocation[TempPlayer]
|
|
return VectorHelper.ToLuaTable(TempPlayer:K2_GetActorLocation()), Locations[math.random(1, #Locations)]
|
|
end
|
|
end
|
|
|
|
return nil
|
|
end
|
|
return BTT_BossBoorishBaseSkill |