UGCProjects/GZJ/Script/Blueprint/Monster/BP_MonsterSkillMonster.lua

98 lines
3.5 KiB
Lua
Raw Normal View History

2025-01-08 22:46:12 +08:00
---@class BP_MonsterSkillMonster_C:BP_MonsterChallenge_C
---@field ParticleSystem UParticleSystemComponent
---@field UAESkillManager UUAESkillManagerComponent
---@field DoomsdayParticle UParticleSystem
--Edit Below--
--local BP_MonsterSkillMonster = {};
local MonsterChallenge = require('Script.Blueprint.Monster.BP_MonsterChallenge')
local BP_MonsterSkillMonster = setmetatable(
{
LastDoomsdayPositions = {};
BaseAttackValue = 0;
ID = 1004;
--TargetPlayerKey = -1;
Particles = {};
DoomsdaySkillHandle = nil;
MonsterName = "SkillMonster",
},
{
__index = MonsterChallenge,
__metatable = MonsterChallenge
}
);
function BP_MonsterSkillMonster:ReceiveBeginPlayEx()
MonsterChallenge.ReceiveBeginPlayEx(self)
if self:HasAuthority() then
self:AddDoomsdaySkill()
end
end
function BP_MonsterSkillMonster:ReceiveEndPlayEx()
self.SuperClass.ReceiveEndPlay(self);
self:ReceiveOnMonsterDeath()
end
function BP_MonsterSkillMonster:AddDoomsdaySkill()
-- body
self.DoomsdaySkillHandle = EventSystem.SetTimerLoop(
self,
function()
if self.LastDoomsdayPositions then
local CanDamagePlayers = self:GetCanDamagePlayer()
if CanDamagePlayers then
for k, TempDoomsdayPosition in pairs(self.LastDoomsdayPositions) do
local Players = self:GetSphereActors(TempDoomsdayPosition, 100, self:GetPawnClass())
if Players then
for k, TempPlayer in pairs(Players) do
if table.hasValue(CanDamagePlayers, TempPlayer) then
self:MonsterApplyDamage(TempPlayer, self:GetAttack() * 5)
end
self:AddAdditionalAttack(self.BaseAttackValue / 2)
end
end
end
end
end
self.LastDoomsdayPositions = {}
local CanDamagePlayers = self:GetCanDamagePlayer()
if CanDamagePlayers then
for k, TempPlayer in pairs(CanDamagePlayers) do
local TempLocation = TempPlayer:K2_GetActorLocation()
table.insert(self.LastDoomsdayPositions, TempLocation)
UnrealNetwork.CallUnrealRPC_Multicast(self, "MulticastRPC_SpawnParticleSystem", VectorHelper.ToLuaTable(TempLocation))
end
end
end,
1.0
)
end
function BP_MonsterSkillMonster:MulticastRPC_SpawnParticleSystem(TempLocation)
if TempLocation then
table.insert(self.Particles, GameplayStatics.SpawnEmitterAtLocation(self, self.DoomsdayParticle, TempLocation, Rotator.New(0, 0, 0), Vector.New(1, 1, 1), true))
else
print("MulticastRPC_SpawnParticleSystem_Fun Position is nil type: " .. type(TempLocation))
end
end
function BP_MonsterSkillMonster:ReceiveOnMonsterDeath()
MonsterChallenge.ReceiveOnMonsterDeath(self)
if self:HasAuthority() then
if self.DoomsdaySkillHandle then EventSystem.StopTimer(self.DoomsdaySkillHandle) self.DoomsdaySkillHandle = nil end
else
if self.Particles then
for TempParticle, T in pairs(self.Particles) do
if UE.IsValid(TempParticle) then
TempParticle:K2_DestroyComponent(self)
end
end
end
end
end
return BP_MonsterSkillMonster;