135 lines
4.5 KiB
Lua
135 lines
4.5 KiB
Lua
|
---@class BP_MonsterUnseal_C:BP_ActiveMonsterBase_C
|
||
|
---@field ParticleSystem UParticleSystemComponent
|
||
|
---@field UAESkillManager UUAESkillManagerComponent
|
||
|
---@field BlastParticle UParticleSystem
|
||
|
---@field GrowUpLevel int32
|
||
|
--Edit Below--
|
||
|
--local BP_MonsterUnseal = {};
|
||
|
local MonsterBase = require('Script.Blueprint.Monster.BP_ActiveMonsterBase')
|
||
|
|
||
|
local BP_MonsterUnseal = setmetatable(
|
||
|
{
|
||
|
BlastLocations = {};
|
||
|
SurvivalTime = 0;
|
||
|
ID = 1100;
|
||
|
MonsterName = "Unseal",
|
||
|
},
|
||
|
{
|
||
|
__index = MonsterBase,
|
||
|
__metatable = MonsterBase
|
||
|
}
|
||
|
);
|
||
|
|
||
|
function BP_MonsterUnseal:ReceiveBeginPlayEx()
|
||
|
MonsterBase.ReceiveBeginPlayEx(self)
|
||
|
if self:HasAuthority() then
|
||
|
self:AddSkillEvil()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_MonsterUnseal:ReceiveTickEx(DeltaTime)
|
||
|
MonsterBase.ReceiveTickEx(self, DeltaTime)
|
||
|
if self:HasAuthority() then
|
||
|
self.SurvivalTime = self.SurvivalTime + DeltaTime
|
||
|
if self.SurvivalTime >= 10.0 then
|
||
|
self.SurvivalTime = 0
|
||
|
self:AddSkillBlast()
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_MonsterUnseal:GetCanDamagePlayer()
|
||
|
if self:GetController() and self:GetController():GetBlackboardComponent() and self:GetController():GetBlackboardComponent():GetValueAsObject("TargetActor") then
|
||
|
local TargetActor = self:GetController():GetBlackboardComponent():GetValueAsObject("TargetActor")
|
||
|
if self.TargetPlayerKey > 0 and UE.IsValid(TargetActor) then
|
||
|
local PlayerPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(self.TargetPlayerKey)
|
||
|
if PlayerPawn and PlayerPawn.bIsAlive and PlayerPawn.IsInArena == false then
|
||
|
return {PlayerPawn}
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return {}
|
||
|
end
|
||
|
|
||
|
function BP_MonsterUnseal:AddSkillEvil()
|
||
|
self.SkillEvilHandle = EventSystem.SetTimerLoop(
|
||
|
self,
|
||
|
function ()
|
||
|
local Monsters = self:GetSphereActors(self:K2_GetActorLocation(), 500, self:GetMonsterClass())
|
||
|
if Monsters then
|
||
|
for k, Monster in pairs(Monsters) do
|
||
|
Monster:AddHealth(UGCSimpleCharacterSystem.GetHealthMax(Monster) * 0.05)
|
||
|
end
|
||
|
end
|
||
|
end,
|
||
|
1.0
|
||
|
)
|
||
|
end
|
||
|
|
||
|
function BP_MonsterUnseal:AddSkillBlast()
|
||
|
local CanDamagePlayers = self:GetCanDamagePlayer()
|
||
|
if CanDamagePlayers then
|
||
|
for k, TempPawn in pairs(CanDamagePlayers) do
|
||
|
local SkillLocation = TempPawn:K2_GetActorLocation()
|
||
|
SkillLocation.Z = SkillLocation.Z - TempPawn.CapsuleComponent.CapsuleHalfHeight + 10
|
||
|
|
||
|
table.insert(self.BlastLocations,SkillLocation)
|
||
|
UnrealNetwork.CallUnrealRPC_Multicast(self, "MulticastRPC_SpawnParticleSystem", VectorHelper.ToLuaTable(SkillLocation))
|
||
|
end
|
||
|
EventSystem.SetTimer(
|
||
|
self,
|
||
|
function ()
|
||
|
if self.BlastLocations then
|
||
|
for k, TempLocation in pairs(self.BlastLocations) do
|
||
|
local Players = self:GetSphereActors(TempLocation, 250, self:GetPawnClass())
|
||
|
if Players then
|
||
|
for _, TargetPlayer in pairs(Players) do
|
||
|
self:MonsterApplyDamage(TargetPlayer, self:GetAttack() * 20)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
self.BlastLocations = {}
|
||
|
end
|
||
|
end,
|
||
|
1.0
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_MonsterUnseal:SetGrowUpLevel(NewLevel)
|
||
|
if NewLevel < 1 then return false end
|
||
|
|
||
|
local Param = math.pow(1.25, NewLevel - 1)
|
||
|
|
||
|
local Health_Max = self.BaseHealthMax * Param
|
||
|
|
||
|
local Param1 = 1 + 0.5 * (self.GrowUpLevel - 1)
|
||
|
|
||
|
UGCSimpleCharacterSystem.SetHealthMax(self, Health_Max)
|
||
|
UGCSimpleCharacterSystem.SetHealth(self, Health_Max)
|
||
|
self.AttackValue = self.BaseAttackValue * Param
|
||
|
self.PhysicalDefense = self.BasePhysicalDefense * Param1
|
||
|
self.Gold = self.Gold * Param1
|
||
|
self.exp = self.exp * Param1
|
||
|
end
|
||
|
|
||
|
function BP_MonsterUnseal:MulticastRPC_SpawnParticleSystem(TempLocation)
|
||
|
if TempLocation then
|
||
|
GameplayStatics.SpawnEmitterAtLocation(self, self.BlastParticle, TempLocation, Rotator.New(0, 0, 0), Vector.New(1, 1, 1), true)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_MonsterUnseal:ReceiveOnMonsterDeath()
|
||
|
MonsterBase.ReceiveOnMonsterDeath(self)
|
||
|
if self:HasAuthority() then
|
||
|
if self.SkillEvilHandle then
|
||
|
EventSystem.StopTimer(self.SkillEvilHandle)
|
||
|
self.SkillEvilHandle = nil
|
||
|
return
|
||
|
end
|
||
|
else
|
||
|
self.ParticleSystem:SetVisibility(false)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return BP_MonsterUnseal;
|