126 lines
4.3 KiB
Lua
126 lines
4.3 KiB
Lua
|
---@class BP_BossCareful_C:BP_MonsterBoss_C
|
||
|
---@field UAESkillManager UUAESkillManagerComponent
|
||
|
---@field ShieldParticle UParticleSystemComponent
|
||
|
---@field UpgradingManaParticle UParticleSystem
|
||
|
--Edit Below--
|
||
|
local MonsterBoss = require('Script.Blueprint.Monster.BP_MonsterBoss')
|
||
|
|
||
|
local BP_BossCareful = setmetatable(
|
||
|
{
|
||
|
ID = 10005,
|
||
|
MonsterName = "Boss",
|
||
|
ShieldValue = 0,
|
||
|
},
|
||
|
{
|
||
|
__index = MonsterBoss,
|
||
|
__metatable = MonsterBoss
|
||
|
}
|
||
|
);
|
||
|
|
||
|
|
||
|
function BP_BossCareful:ReceiveBeginPlayEx()
|
||
|
MonsterBoss.ReceiveBeginPlayEx(self)
|
||
|
if self:HasAuthority() then
|
||
|
EventSystem:AddListener(EventType.PlayerPawnDead, BP_BossCareful.KilledPlayer, self)
|
||
|
self:AddSkillCarefulBloodShield()
|
||
|
self:AddSkillCarefulUpgradingMana()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BP_BossCareful:AddSkillCarefulBloodShield()
|
||
|
self.ShieldValue = UGCSimpleCharacterSystem.GetHealthMax(self)
|
||
|
UnrealNetwork.CallUnrealRPC_Multicast(self, "MulticastRPC_SetParticleVisibility", true)
|
||
|
|
||
|
self:AddModifyDamageDelegationFun(
|
||
|
"SkillCarefulBloodShield",
|
||
|
function (DamageAmount, DamageEvent, EventInstigator, DamageCauser)
|
||
|
local WeaponType = GameDataManager.GetWeaponType(DamageCauser.WeaponActor.CurrentWeaponId)
|
||
|
if WeaponType == nil then
|
||
|
UE.Log("[BP_BossCareful:AddSkillCarefulBloodShield] Can't GetWeaponType, Data is nil")
|
||
|
return 0
|
||
|
end
|
||
|
if self.ShieldValue > 0 and WeaponType ~= EWeaponClassType.WT_MachineGun then
|
||
|
self.ShieldValue = self.ShieldValue - DamageAmount
|
||
|
if self.ShieldValue > 0 then
|
||
|
return 0
|
||
|
else
|
||
|
UnrealNetwork.CallUnrealRPC_Multicast(self, "MulticastRPC_SetParticleVisibility", false)
|
||
|
return -self.ShieldValue
|
||
|
end
|
||
|
else
|
||
|
return DamageAmount
|
||
|
end
|
||
|
end
|
||
|
)
|
||
|
|
||
|
EventSystem.SetTimer(
|
||
|
self,
|
||
|
function ()
|
||
|
local NowHealth = UGCSimpleCharacterSystem.GetHealth(self)
|
||
|
if self.BaseHealthMax ~= NowHealth then return end
|
||
|
|
||
|
self.AddHealthHandle = EventSystem.SetTimerLoop(
|
||
|
self,
|
||
|
function()
|
||
|
local NowHealth = UGCSimpleCharacterSystem.GetHealth(self)
|
||
|
local NowHealthMax = UGCSimpleCharacterSystem.GetHealthMax(self)
|
||
|
if NowHealthMax * 0.8 > NowHealth or (NowHealthMax / self.BaseHealthMax >= 1.5) then
|
||
|
EventSystem.StopTimer(self.AddHealthHandle)
|
||
|
self.AddHealthHandle = nil
|
||
|
return
|
||
|
end
|
||
|
UGCSimpleCharacterSystem.SetHealthMax(self, NowHealthMax + self.BaseHealthMax * 0.01)
|
||
|
UGCSimpleCharacterSystem.SetHealth(self, NowHealth + self.BaseHealthMax * 0.01)
|
||
|
end,
|
||
|
1
|
||
|
)
|
||
|
end,
|
||
|
10
|
||
|
)
|
||
|
end
|
||
|
|
||
|
function BP_BossCareful:AddSkillCarefulUpgradingMana()
|
||
|
EventSystem.SetTimer(
|
||
|
self,
|
||
|
function ()
|
||
|
self.AddAttackHandle = EventSystem.SetTimerLoop(
|
||
|
self,
|
||
|
function()
|
||
|
if self.bIsDead then
|
||
|
EventSystem.StopTimer(self.AddAttackHandle)
|
||
|
self.AddAttackHandle = nil
|
||
|
return
|
||
|
end
|
||
|
self:AddAdditionalAttack(self.AttackValue * 0.02)
|
||
|
|
||
|
end,
|
||
|
1
|
||
|
)
|
||
|
end,
|
||
|
10
|
||
|
)
|
||
|
end
|
||
|
|
||
|
function BP_BossCareful:MulticastRPC_SetParticleVisibility(IsShow)
|
||
|
self.ShieldParticle:SetVisibility(IsShow)
|
||
|
end
|
||
|
|
||
|
function BP_BossCareful:MulticastRPC_SpawnParticleSystemAttach()
|
||
|
local TempParticleComponent = GameplayStatics.SpawnEmitterAttached(self.UpgradingManaParticle, self.Mesh, "", Vector.New(30.0, 0, 10), VectorHelper.RotZero(), Vector.New(2, 2, 2), EAttachLocation.SnapToTarget, true)
|
||
|
EventSystem.SetTimer(
|
||
|
self,
|
||
|
function ()
|
||
|
TempParticleComponent:K2_DestroyComponent(self)
|
||
|
end,
|
||
|
1.5
|
||
|
)
|
||
|
end
|
||
|
|
||
|
function BP_BossCareful:KilledPlayer(DeadPlayerKey, Killer)
|
||
|
if Killer == self then
|
||
|
UnrealNetwork.CallUnrealRPC_Multicast(self, "MulticastRPC_SpawnParticleSystemAttach")
|
||
|
self:SetAttackScale(self.AttackScale + 0.2)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return BP_BossCareful;
|