185 lines
6.2 KiB
Lua
185 lines
6.2 KiB
Lua
---@class BP_NirvanaActor_C:AActor
|
|
---@field P_Nirvana UParticleSystemComponent
|
|
---@field DefaultSceneRoot USceneComponent
|
|
---@field AddHealthPercentage float
|
|
---@field LifeTime float
|
|
---@field InvincibleTime float
|
|
---@field PlaceSound UAkAudioEvent
|
|
---@field RespawnSound UAkAudioEvent
|
|
---@field ShowLifeTimeWidgetClass UClass
|
|
---@field RespawnParticle UParticleSystem
|
|
--Edit Below--
|
|
local BP_NirvanaActor = {
|
|
OwnerPlayerPawn = nil;
|
|
TargetServerTime = -1;
|
|
TargetPlayerKey = -1;
|
|
}
|
|
|
|
function BP_NirvanaActor:SetOwnerPlayerPawn(InPawn)
|
|
UGCLogSystem.Log("[BP_NirvanaActor_SetOwnerPlayerPawn]")
|
|
if UGCGameSystem.IsServer() then
|
|
if self.OwnerPlayerPawn == nil and UE.IsValid(InPawn) then
|
|
self.OwnerPlayerPawn = InPawn
|
|
self.OwnerPlayerPawn:AddDamageModifyFunc(self.NirvanaDamageModify, self, 1e5)
|
|
self.TargetServerTime = UGCGameSystem.GameState:GetServerGameTime() + self.LifeTime
|
|
if self.OwnerPlayerPawn.PlayerKey then
|
|
UGCSendRPCSystem.ClientShowUI(self.OwnerPlayerPawn.PlayerKey, WidgetConfig.EUIType.Skill_NirvanaLifeTime, true, false, self.TargetServerTime, self.LifeTime)
|
|
end
|
|
UGCLogSystem.Log("[BP_NirvanaActor_SetOwnerPlayerPawn] Succeed")
|
|
end
|
|
self.DestroyHandle = UGCEventSystem.SetTimer(self, self.RemoveNirvanaActor, self.LifeTime)
|
|
end
|
|
end
|
|
|
|
function BP_NirvanaActor:GetOwnerPlayerPawn()
|
|
return self.OwnerPlayerPawn
|
|
end
|
|
|
|
function BP_NirvanaActor:NirvanaDamageModify(TargetPawn, DamageAmount, DamageType, EventInstigator, DamageCauser, Hit)
|
|
|
|
local PlayerHealth = UGCPawnAttrSystem.GetHealth(TargetPawn)
|
|
if PlayerHealth - DamageAmount < 1 then
|
|
DamageAmount = 0
|
|
self:Nirvana()
|
|
end
|
|
|
|
return DamageAmount
|
|
end
|
|
|
|
function BP_NirvanaActor:Nirvana()
|
|
UGCLogSystem.Log("[BP_NirvanaActor_Nirvana]")
|
|
|
|
-- 设置无敌状态
|
|
if self.InvincibleTime > 0 then
|
|
UGCPawnSystem.SetIsInvincible(self.OwnerPlayerPawn, true)
|
|
self.InvincibleHandle = UGCEventSystem.SetTimer(self, self.CloseInvincible, self.InvincibleTime)
|
|
end
|
|
|
|
-- 客户端播放特效
|
|
UGCSendRPCSystem.ActorRPCNotify(nil, self, "NirvanaEffect", VectorHelper.ToLuaTable(self.OwnerPlayerPawn:K2_GetActorLocation()))
|
|
|
|
-- 恢复血量
|
|
local MaxHealth = UGCPawnAttrSystem.GetHealthMax(self.OwnerPlayerPawn)
|
|
UGCPawnAttrSystem.SetHealth(self.OwnerPlayerPawn, MaxHealth * self.AddHealthPercentage)
|
|
|
|
-- 传送至涅槃地
|
|
self.OwnerPlayerPawn:K2_SetActorLocation(self:K2_GetActorLocation())
|
|
local PlayerController = self.OwnerPlayerPawn:GetPlayerControllerSafety()
|
|
PlayerController:ClientSetControlRotation(self:K2_GetActorRotation())
|
|
|
|
|
|
-- 停止生命周期自动删除的handle
|
|
UGCEventSystem.StopTimer(self.DestroyHandle)
|
|
self.DestroyHandle = nil
|
|
|
|
-- 移除Actor 不代表销毁
|
|
self:RemoveNirvanaActor()
|
|
|
|
|
|
--UGCSendRPCSystem.RPCEvent(TargetPawn.PlayerKey, EventEnum.AddTip, TipConfig.TipType.BeFatedNotToDieOwner, self.UsedBuffCount)
|
|
--if EventInstigator and EventInstigator.PlayerKey then
|
|
-- UGCSendRPCSystem.RPCEvent(EventInstigator.PlayerKey, EventEnum.AddTip, TipConfig.TipType.BeFatedNotToDieCauser)
|
|
--end
|
|
end
|
|
|
|
function BP_NirvanaActor:CloseInvincible()
|
|
if UE.IsValid(self.OwnerPlayerPawn) then
|
|
UGCPawnSystem.SetIsInvincible(self.OwnerPlayerPawn, false)
|
|
end
|
|
self.InvincibleHandle = nil
|
|
self:K2_DestroyActor()
|
|
end
|
|
|
|
function BP_NirvanaActor:RemoveNirvanaActor()
|
|
UGCLogSystem.Log("[BP_NirvanaActor_RemoveNirvanaActor]")
|
|
-- 移除伤害修改绑定
|
|
if UE.IsValid(self.OwnerPlayerPawn) then
|
|
self.OwnerPlayerPawn:RemoveDamageModifyFunc(self.NirvanaDamageModify, self, 1e5)
|
|
end
|
|
|
|
if self.InvincibleHandle == nil then
|
|
self:K2_DestroyActor()
|
|
UGCLogSystem.Log("[BP_NirvanaActor_RemoveNirvanaActor] Destroy")
|
|
else
|
|
-- 若不销毁则发送消息到客户端隐藏特效
|
|
UGCSendRPCSystem.ActorRPCNotify(nil, self, "CloseNirvanaEffect")
|
|
UGCLogSystem.Log("[BP_NirvanaActor_RemoveNirvanaActor] Hide Effect")
|
|
end
|
|
end
|
|
|
|
function BP_NirvanaActor:PlaceEffect()
|
|
-- 音效
|
|
UGCSoundManagerSystem.PlaySoundAtLocation(self.PlaceSound, self:K2_GetActorLocation(), VectorHelper.RotZero())
|
|
end
|
|
|
|
function BP_NirvanaActor:NirvanaEffect(DeadPos)
|
|
-- 音效
|
|
UGCSoundManagerSystem.PlaySoundAtLocation(self.RespawnSound, DeadPos, VectorHelper.RotZero())
|
|
UGCSoundManagerSystem.PlaySoundAtLocation(self.RespawnSound, self:K2_GetActorLocation(), VectorHelper.RotZero())
|
|
|
|
-- 粒子
|
|
GameplayStatics.SpawnEmitterAtLocation(UGCGameSystem.GameState, self.RespawnParticle, DeadPos, VectorHelper.RotZero(), Vector.New(1, 1, 1), true)
|
|
GameplayStatics.SpawnEmitterAtLocation(UGCGameSystem.GameState, self.RespawnParticle, self:K2_GetActorLocation(), VectorHelper.RotZero(), Vector.New(1, 1, 1), true)
|
|
|
|
-- 移除显示的LifeTime widget
|
|
self:RemoveWidget()
|
|
end
|
|
|
|
function BP_NirvanaActor:CloseNirvanaEffect()
|
|
self.P_Nirvana:SetHiddenInGame(true, true)
|
|
end
|
|
|
|
--function BP_NirvanaActor:ClientShowLifeTime(TargetServerTime)
|
|
-- self.LifeTimeWidget = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), self.ShowLifeTimeWidgetClass);
|
|
-- self.LifeTimeWidget:AddToViewport(WidgetConfig.EUILayerGroup.Top);
|
|
-- self.LifeTimeWidget:Active(TargetServerTime, self.LifeTime)
|
|
--end
|
|
|
|
function BP_NirvanaActor:RemoveWidget()
|
|
--if UE.IsValid(self.LifeTimeWidget) then
|
|
-- self.LifeTimeWidget:RemoveFromParent()
|
|
-- self.LifeTimeWidget = nil
|
|
--end
|
|
WidgetManager:ClosePanel(WidgetConfig.EUIType.Skill_NirvanaLifeTime)
|
|
end
|
|
|
|
|
|
function BP_NirvanaActor:ReceiveBeginPlay()
|
|
BP_NirvanaActor.SuperClass.ReceiveBeginPlay(self)
|
|
if UGCGameSystem.IsServer() then
|
|
else
|
|
self:PlaceEffect()
|
|
end
|
|
end
|
|
|
|
|
|
--[[
|
|
function BP_NirvanaActor:ReceiveTick(DeltaTime)
|
|
BP_NirvanaActor.SuperClass.ReceiveTick(self, DeltaTime)
|
|
end
|
|
--]]
|
|
|
|
|
|
function BP_NirvanaActor:ReceiveEndPlay()
|
|
if UGCGameSystem.IsServer() then
|
|
else
|
|
self:RemoveWidget()
|
|
end
|
|
BP_NirvanaActor.SuperClass.ReceiveEndPlay(self)
|
|
end
|
|
|
|
|
|
|
|
function BP_NirvanaActor:GetReplicatedProperties()
|
|
return
|
|
"TargetServerTime"
|
|
end
|
|
|
|
|
|
--[[
|
|
function BP_NirvanaActor:GetAvailableServerRPCs()
|
|
return
|
|
end
|
|
--]]
|
|
|
|
return BP_NirvanaActor |