113 lines
4.5 KiB
Lua
113 lines
4.5 KiB
Lua
local SimpleSkillTask = require("Script.SimpleSkill.Task.SimpleSkillTask")
|
|
local SimpleSkillTask_Flowing = LuaClass("SimpleSkillTask_Flowing", SimpleSkillTask)
|
|
|
|
SimpleSkillTask_Flowing.AdditionDamageRateTable = {1.0, 1.2, 1.5, 2.0}
|
|
SimpleSkillTask_Flowing.CurDamageRate = 0.0
|
|
SimpleSkillTask_Flowing.DefenceReductionRateTable = {0.9, 0.85, 0.8, 0.7}
|
|
SimpleSkillTask_Flowing.CurDefenceReductionRate = 0.0
|
|
|
|
function SimpleSkillTask_Flowing:ctor(OwnerSkill)
|
|
SimpleSkillTask_Flowing.super.ctor(self, OwnerSkill)
|
|
end
|
|
|
|
function SimpleSkillTask_Flowing:InitTaskFromData(TaskData, CasterPawn)
|
|
SimpleSkillTask.InitTaskFromData(self, TaskData, CasterPawn)
|
|
|
|
self.TaskName = "Flowing"
|
|
end
|
|
|
|
function SimpleSkillTask_Flowing:UpdateSkillLevel(NewSkillLevel)
|
|
SimpleSkillTask.UpdateSkillLevel(self, NewSkillLevel)
|
|
|
|
self.CurDamageRate = self.AdditionDamageRateTable[NewSkillLevel]
|
|
self.CurDefenceReductionRate = self.DefenceReductionRateTable[NewSkillLevel]
|
|
end
|
|
|
|
function SimpleSkillTask_Flowing:ActivateTask()
|
|
SimpleSkillTask.ActivateTask(self)
|
|
end
|
|
|
|
function SimpleSkillTask_Flowing:ActivateTaskInTimer()
|
|
local TargetMonsters = self:GetRandBoxOverlapActors()
|
|
if TargetMonsters == nil then
|
|
return
|
|
end
|
|
|
|
local CachedMonsterDefence = {}
|
|
|
|
local DamageAmount = self.CurDamageRate * UGCGameSystem.GetPlayerStateByPlayerKey(self.CasterPawn.PlayerKey).Attributes[AttributeType.Base].Base_Attack
|
|
local EventInstigator = UGCGameSystem.GetPlayerControllerByPlayerKey(self.CasterPawn.PlayerKey)
|
|
|
|
for _, Monster in pairs(TargetMonsters) do
|
|
if Monster ~= nil and UE.IsValid(Monster) and UGCSimpleCharacterSystem.GetHealth(Monster) > 0 then
|
|
UGCGameSystem.ApplyDamage(Monster, DamageAmount, EventInstigator, self.CasterPawn, EDamageType.ShootDamage)
|
|
CachedMonsterDefence[Monster] = Monster.PhysicalDefense
|
|
Monster.PhysicalDefense = Monster.PhysicalDefense * self.CurDefenceReductionRate
|
|
end
|
|
end
|
|
|
|
EventSystem.SetTimer(UGCGameSystem.GameState, function()
|
|
for Monster, Defence in pairs(CachedMonsterDefence) do
|
|
if Monster ~= nil and UE.IsValid(Monster) and UGCSimpleCharacterSystem.GetHealth(Monster) > 0 then
|
|
Monster.PhysicalDefense = Defence
|
|
end
|
|
end
|
|
end, 3.0)
|
|
end
|
|
|
|
function SimpleSkillTask_Flowing:DeactivateTask()
|
|
|
|
end
|
|
|
|
function SimpleSkillTask_Flowing:GetRandBoxOverlapActors()
|
|
local BoxRotation = VectorHelper.RandomRotatorYaw(self.CasterPawn:K2_GetActorRotation())
|
|
local TraceForward = KismetMathLibrary.Conv_RotatorToVector(BoxRotation)
|
|
local BoxLoc = VectorHelper.Add(self.CasterPawn:K2_GetActorLocation(), VectorHelper.MulNumber(KismetMathLibrary.Normal(TraceForward), 400))
|
|
local BoxExtent = {X = 400, Y = 100, Z = 100}
|
|
|
|
local ObjectTypes = {}
|
|
local ActorClassFilter = UE.LoadClass(BPClassPath.MonsterBase)
|
|
local ActorsToIgnore = self:GetIgnoredActors()
|
|
local RetVal, OutActors = KismetSystemLibrary.BoxOverlapActors(self.CasterPawn, BoxLoc, BoxRotation, BoxExtent, ObjectTypes, ActorClassFilter, ActorsToIgnore)
|
|
|
|
self:EnableDirectionalEffect(29, self.CasterPawn, nil, 0, BoxRotation)
|
|
|
|
if GlobalConfigs.OpenDebug then
|
|
UnrealNetwork.CallUnrealRPC_Multicast(self.CasterPawn , "DrawDebugBox" , VectorHelper.ToLuaTable(BoxLoc), BoxExtent, {1,0,0,1}, BoxRotation)
|
|
end
|
|
|
|
if RetVal then
|
|
return OutActors
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
|
|
function SimpleSkillTask_Flowing:GetIgnoredActors()
|
|
local ActorsToIgnore = {}
|
|
table.insert(ActorsToIgnore, self.CasterPawn)
|
|
|
|
if self.CasterPawn.IsInArena then
|
|
local AllHangUpRoomSpawners = UGCGameSystem.GameState:GetAllHangUpRoomSpawners()
|
|
for _, HangUpRoomSpawner in pairs(AllHangUpRoomSpawners) do
|
|
for _, SpawnedMonster in pairs(HangUpRoomSpawner.SpawnedMonsters) do
|
|
if SpawnedMonster ~= nil and UE.IsValid(SpawnedMonster) and UGCSimpleCharacterSystem.GetHealth(SpawnedMonster) > 0 then
|
|
table.insert(ActorsToIgnore, SpawnedMonster)
|
|
end
|
|
end
|
|
end
|
|
else
|
|
local AttackWaveSpawner = UGCGameSystem.GameState:GetAttackWaveSpawner()
|
|
if AttackWaveSpawner then
|
|
for _, SpawnedMonster in pairs(AttackWaveSpawner.SpawnedMonsters) do
|
|
if SpawnedMonster ~= nil and UE.IsValid(SpawnedMonster) and UGCSimpleCharacterSystem.GetHealth(SpawnedMonster) > 0 then
|
|
table.insert(ActorsToIgnore, SpawnedMonster)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return ActorsToIgnore
|
|
end
|
|
|
|
return SimpleSkillTask_Flowing; |