253 lines
8.7 KiB
Lua
253 lines
8.7 KiB
Lua
|
---@class BP_BossCharm_C:BP_MonsterBoss_C
|
||
|
---@field UAESkillManager UUAESkillManagerComponent
|
||
|
---@field CharmMarshParticle UParticleSystem
|
||
|
---@field CharmCurseParticle UParticleSystem
|
||
|
--Edit Below--
|
||
|
-- local BP_BossCharm = {
|
||
|
-- SkillCount = 0,
|
||
|
-- CharmCurseSkilling = false,
|
||
|
-- PawnClass = nil,
|
||
|
-- PawnLocations = {},
|
||
|
-- SurvivalTime = 0.
|
||
|
-- };
|
||
|
|
||
|
local MonsterBoss = require('Script.Blueprint.Monster.BP_MonsterBoss')
|
||
|
|
||
|
local BP_BossCharm = setmetatable(
|
||
|
{
|
||
|
--SkillCount = 0,
|
||
|
CharmCurseSkilling = false,
|
||
|
PawnClass = nil,
|
||
|
PawnLocations = {},
|
||
|
SurvivalTime = 0.,
|
||
|
AttachPawnParticle = {},
|
||
|
ID = 10002,
|
||
|
MonsterName = "Boss",
|
||
|
EnableCharmMarshSkill = false,
|
||
|
},
|
||
|
{
|
||
|
__index = MonsterBoss,
|
||
|
__metatable = MonsterBoss
|
||
|
}
|
||
|
);
|
||
|
function BP_BossCharm:ReceiveBeginPlayEx()
|
||
|
MonsterBoss.ReceiveBeginPlayEx(self)
|
||
|
if self:HasAuthority() then
|
||
|
self:GetController():GetBlackboardComponent():SetValueAsBool("CanPlayCharmMarshSkill", false)
|
||
|
self:GetController():GetBlackboardComponent():SetValueAsBool("CanPlayCharmCurseSkill", false)
|
||
|
self:AddModifyDamageDelegationFun("EnableCharmMarshSkill",
|
||
|
function (DamageAmount, DamageEvent, EventInstigator, DamageCauser)
|
||
|
EventSystem.SetTimer(
|
||
|
self,
|
||
|
function()
|
||
|
self.EnableCharmMarshSkill = true
|
||
|
end,
|
||
|
10
|
||
|
)
|
||
|
self:RemoveModifyDamageDelegation("EnableCharmMarshSkill")
|
||
|
return DamageAmount
|
||
|
end
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
function BP_BossCharm:ReceiveTickEx(DeltaTime)
|
||
|
MonsterBoss.ReceiveTickEx(self, DeltaTime);
|
||
|
|
||
|
if self:HasAuthority() then
|
||
|
self.SurvivalTime = self.SurvivalTime + DeltaTime
|
||
|
if self.SurvivalTime >= 8 and not self.bIsDead then
|
||
|
if self.EnableCharmMarshSkill then
|
||
|
self.SurvivalTime = 0
|
||
|
self:GetController():GetBlackboardComponent():SetValueAsBool("CanPlayCharmMarshSkill", true)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_BossCharm:GetPawnClass()
|
||
|
if not self.PawnClass then
|
||
|
self.PawnClass = UE.LoadClass(BPClassPath.PlayerPawn)
|
||
|
end
|
||
|
return self.PawnClass
|
||
|
end
|
||
|
|
||
|
function BP_BossCharm:UpdateSkillCount()
|
||
|
if self:HasAuthority() then
|
||
|
self.SkillCount = self.SkillCount + 1
|
||
|
self:PlayCharmCurseSkill()
|
||
|
print("BP_BossCharm_UpdateSkillCount")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_BossCharm:PlayCharmCurseSkill()
|
||
|
if self.SkillCount >= 5 then
|
||
|
self:GetController():GetBlackboardComponent():SetValueAsBool("CanPlayCharmCurseSkill", true)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_BossCharm:PlayCharmCurseSkillExe()
|
||
|
self.SkillCount = 0
|
||
|
self.PawnsMaxWalkSpeed = {}
|
||
|
-- local InArenaPawns = UGCGameState:GetPlayersInArena()
|
||
|
local InArenaPawns = UGCGameSystem.GameState:GetPlayersInArena()
|
||
|
local InArenaPlayerKey = {}
|
||
|
for k, ArenaPawn in pairs(InArenaPawns) do
|
||
|
if ArenaPawn.bCanBeControlledByMonsters then
|
||
|
table.insert(InArenaPlayerKey, UGCPawnAttrSystem.GetPlayerKey(ArenaPawn))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
UnrealNetwork.CallUnrealRPC_Multicast(self, "MulticastRPC_SpawnParticleSystemAttach", InArenaPlayerKey)
|
||
|
|
||
|
|
||
|
local TargetPawns = InArenaPawns
|
||
|
-- local TargetPawns = GameplayStatics.GetAllActorsOfClass(self, self:GetPawnClass(), {})
|
||
|
|
||
|
for k, PawnTarget in pairs(TargetPawns) do
|
||
|
if UE.IsValid(PawnTarget) and PawnTarget.bCanBeControlledByMonsters then
|
||
|
UGCPawnAttrSystem.SetSpeedScale(PawnTarget, 0)
|
||
|
end
|
||
|
end
|
||
|
-- 广播到玩家身上绑定粒子
|
||
|
self.CharmCurseSkilling = true
|
||
|
|
||
|
EventSystem.SetTimer(self,
|
||
|
function ()
|
||
|
self.CharmCurseSkilling = false
|
||
|
-- local TargetPawns = GameplayStatics.GetAllActorsOfClass(self, self:GetPawnClass(), {})
|
||
|
for k, PawnTarget in pairs(TargetPawns) do
|
||
|
if UE.IsValid(PawnTarget) then
|
||
|
UGCPawnAttrSystem.SetSpeedScale(PawnTarget, 1)
|
||
|
end
|
||
|
end
|
||
|
end,
|
||
|
2.0
|
||
|
)
|
||
|
end
|
||
|
|
||
|
-- 获取半径范围内的Actor
|
||
|
function BP_BossCharm:GetSphereActors(CenterPosition,radius, TargetClass)
|
||
|
local TargetActors = GameplayStatics.GetAllActorsOfClass(self, TargetClass, {})
|
||
|
local resActors = {}
|
||
|
for k, TempActor in pairs(TargetActors) do
|
||
|
if VectorHelper.GetDistance(TempActor:K2_GetActorLocation(), CenterPosition) <= radius then
|
||
|
table.insert(resActors, TempActor)
|
||
|
end
|
||
|
end
|
||
|
return resActors
|
||
|
end
|
||
|
|
||
|
function BP_BossCharm:PlayCharmMarshSkillExe()
|
||
|
local TargetPawns = UGCGameSystem.GameState:GetPlayersInArena()
|
||
|
self.PawnLocations = {}
|
||
|
for k, PawnTarget in pairs(TargetPawns) do
|
||
|
|
||
|
local TempLocal = PawnTarget:K2_GetActorLocation()
|
||
|
local DropLocation = UGCGameSystem.GameState:GetDropLocation(TempLocal)
|
||
|
DropLocation.Z = DropLocation.Z + 5
|
||
|
table.insert(self.PawnLocations, DropLocation)
|
||
|
UnrealNetwork.CallUnrealRPC_Multicast(self, "MulticastRPC_SpawnParticleSystem", VectorHelper.ToLuaTable(DropLocation))
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
EventSystem.SetTimer(
|
||
|
self,
|
||
|
function ()
|
||
|
local InArenaPawns = UGCGameSystem.GameState:GetPlayersInArena()
|
||
|
for k, TempLocation in pairs(self.PawnLocations) do
|
||
|
for i, TempPawn in pairs(InArenaPawns) do
|
||
|
|
||
|
if VectorHelper.GetDistance(TempPawn:K2_GetActorLocation(), TempLocation) < 250 then
|
||
|
if self.CharmCurseSkilling then
|
||
|
self:MonsterApplyDamage(TempPawn, self:GetAttack() * 10)
|
||
|
else
|
||
|
self:MonsterApplyDamage(TempPawn, self:GetAttack() * 5)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end,
|
||
|
2.0
|
||
|
)
|
||
|
end
|
||
|
|
||
|
-- 客户端生成一个TempLocation的粒子
|
||
|
function BP_BossCharm:MulticastRPC_SpawnParticleSystem(TempLocation)
|
||
|
if TempLocation then
|
||
|
GameplayStatics.SpawnEmitterAtLocation(self, self.CharmMarshParticle, 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_BossCharm:MulticastRPC_SpawnParticleSystemAttach(InArenaPlayerKeys)
|
||
|
|
||
|
if not InArenaPlayerKeys then
|
||
|
print("MulticastRPC_SpawnParticleSystem_Fun InArenaPlayerKeys is nil")
|
||
|
return
|
||
|
end
|
||
|
|
||
|
local TargetPawns = {}
|
||
|
for k, Playerkey in pairs(InArenaPlayerKeys) do
|
||
|
table.insert(TargetPawns, ScriptGameplayStatics.GetPlayerPawnByPlayerKey(self,Playerkey))
|
||
|
end
|
||
|
|
||
|
|
||
|
if TargetPawns then
|
||
|
for k, TargetPawn in pairs(TargetPawns) do
|
||
|
if TargetPawn.Mesh and self.CharmCurseParticle then
|
||
|
local TempParticleComponent = GameplayStatics.SpawnEmitterAttached(self.CharmCurseParticle, TargetPawn.Mesh, "", Vector.New(0, 0, 50), VectorHelper.RotZero(), VectorHelper.ScaleOne(), EAttachLocation.SnapToTarget, true)
|
||
|
if TempParticleComponent then
|
||
|
table.insert(self.AttachPawnParticle, TempParticleComponent)
|
||
|
else
|
||
|
print("MulticastRPC_SpawnParticleSystem_Fun Position Adding TempParticleComponent is nil" )
|
||
|
end
|
||
|
else
|
||
|
print("MulticastRPC_SpawnParticleSystem_Fun Position Adding Failure" )
|
||
|
end
|
||
|
end
|
||
|
local WeakSelf
|
||
|
EventSystem.SetTimer(
|
||
|
self,
|
||
|
function ()
|
||
|
|
||
|
if self.AttachPawnParticle then
|
||
|
for k, particleCom in pairs(self.AttachPawnParticle) do
|
||
|
particleCom:K2_DestroyComponent(self)
|
||
|
end
|
||
|
self.AttachPawnParticle = {}
|
||
|
end
|
||
|
end,
|
||
|
2.0
|
||
|
)
|
||
|
else
|
||
|
print("MulticastRPC_SpawnParticleSystem_Fun Position is nil type: " .. type(TempLocation))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_BossCharm:MulticastRPC_DestroyParticleSystem()
|
||
|
if self.AttachPawnParticle then
|
||
|
for k, particleCom in pairs(self.AttachPawnParticle) do
|
||
|
particleCom:K2_DestroyComponent(self)
|
||
|
end
|
||
|
self.AttachPawnParticle = {}
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_BossCharm:ReceiveOnMonsterDeath()
|
||
|
MonsterBoss.ReceiveOnMonsterDeath(self)
|
||
|
|
||
|
if self:HasAuthority() then
|
||
|
if self.ReignSkillHandle then EventSystem.StopTimer(self.ReignSkillHandle) self.ReignSkillHandle = nil return end
|
||
|
else
|
||
|
if self.AttachPawnParticle then
|
||
|
for k, particleCom in pairs(self.AttachPawnParticle) do
|
||
|
particleCom:K2_DestroyComponent(self)
|
||
|
end
|
||
|
self.AttachPawnParticle = {}
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return BP_BossCharm;
|