63 lines
2.4 KiB
Lua
63 lines
2.4 KiB
Lua
|
local SimpleSkillTask = require("Script.SimpleSkill.Task.SimpleSkillTask")
|
||
|
local SimpleSkillTask_IceFrost = LuaClass("SimpleSkillTask_IceFrost", SimpleSkillTask)
|
||
|
|
||
|
function SimpleSkillTask_IceFrost:ctor(OwnerSkill)
|
||
|
SimpleSkillTask_IceFrost.super.ctor(self, OwnerSkill)
|
||
|
end
|
||
|
|
||
|
function SimpleSkillTask_IceFrost:InitTaskFromData(TaskData, CasterPawn)
|
||
|
SimpleSkillTask.InitTaskFromData(self, TaskData, CasterPawn)
|
||
|
end
|
||
|
|
||
|
function SimpleSkillTask_IceFrost:UpdateSkillLevel(NewSkillLevel)
|
||
|
SimpleSkillTask.UpdateSkillLevel(self, NewSkillLevel)
|
||
|
|
||
|
if self.SpawnedActor ~= nil and UE.IsValid(self.SpawnedActor) then
|
||
|
self.SpawnedActor:SetLevel(NewSkillLevel)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function SimpleSkillTask_IceFrost:ActivateTask()
|
||
|
SimpleSkillTask.ActivateTask(self)
|
||
|
end
|
||
|
|
||
|
function SimpleSkillTask_IceFrost:ActivateTaskInTimer()
|
||
|
local TargetPawn = nil
|
||
|
local TargetPawns = self:GetTargetPawns()
|
||
|
|
||
|
local MinDist = 999999
|
||
|
for _, Monster in pairs(TargetPawns) do
|
||
|
if Monster ~= nil and UE.IsValid(Monster) then
|
||
|
if UGCSimpleCharacterSystem.GetHealth(Monster) > 0 then
|
||
|
local MonsterLoc = Monster:K2_GetActorLocation()
|
||
|
local Dist = VectorHelper.GetDistance(PawnLoc, MonsterLoc)
|
||
|
if Dist <= MinDist then
|
||
|
MinDist = Dist
|
||
|
TargetPawn = Monster
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
local Location = nil
|
||
|
local Rotation = nil
|
||
|
if TargetPawn ~= nil then
|
||
|
Location = TargetPawn:K2_GetActorLocation()
|
||
|
Rotation = TargetPawn:K2_GetActorRotation()
|
||
|
Location.Z = Location.Z - TargetPawn.CapsuleComponent.CapsuleHalfHeight
|
||
|
else
|
||
|
local SpawnPos = VectorHelper.Add(self.CasterPawn:K2_GetActorLocation(), VectorHelper.MulNumber(KismetMathLibrary.Normal(self.CasterPawn:GetActorForwardVector()), 500))
|
||
|
Location = UGCGameSystem.GameState:GetDropLocation(SpawnPos)
|
||
|
Rotation = self.CasterPawn:K2_GetActorRotation()
|
||
|
end
|
||
|
|
||
|
self.SpawnedActor = self:SpawnSkillActor(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneObject/SkillActor/BP_Skill_IceFrost.BP_Skill_IceFrost_C'), self.CasterPawn, Location, Rotation)
|
||
|
end
|
||
|
|
||
|
function SimpleSkillTask_IceFrost:DeactivateTask()
|
||
|
if self.SpawnedActor ~= nil and UE.IsValid(self.SpawnedActor) then
|
||
|
self.SpawnedActor:K2_DestroyActor()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return SimpleSkillTask_IceFrost;
|