2025-01-09 13:36:39 +08:00
|
|
|
---@class UGCPlayerPawn_C:BP_UGCPlayerPawn_C
|
|
|
|
---@field StartItemID TArray<int32>
|
|
|
|
--Edit Below--
|
|
|
|
local UGCPlayerPawn = {}
|
|
|
|
|
|
|
|
|
|
|
|
-- 关闭盒子掉落
|
|
|
|
function UGCPlayerPawn:IsSkipSpawnDeadTombBox(EventInstigater)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function UGCPlayerPawn:ReceiveBeginPlay()
|
|
|
|
UGCPlayerPawn.SuperClass.ReceiveBeginPlay(self)
|
|
|
|
|
|
|
|
if UGCGameSystem.IsServer() then
|
|
|
|
|
|
|
|
self.OnDeath:Add(self.OnDeathCallBack, self)
|
|
|
|
|
|
|
|
UGCEventSystem.SetTimer(self, function()
|
|
|
|
if UE.IsValid(self) then
|
|
|
|
for i, v in pairs(self.StartItemID) do
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_ReceiveBeginPlay] ID:%s", tostring(v))
|
|
|
|
UGCBackPackSystem.AddItem(self, v, 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end, 5)
|
|
|
|
else
|
|
|
|
|
|
|
|
end
|
2025-01-14 15:38:12 +08:00
|
|
|
if not UGCGameSystem.IsServer() and self.CheckFXHandle == nil then
|
2025-01-09 13:36:39 +08:00
|
|
|
-- 这里防止未设置成功做的校验
|
|
|
|
self.CheckFXHandle = UGCEventSystem.SetTimerLoop(self, self.UpdateFX, 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
local TempRescueOtherComp = self:GetCharacterRescueOtherComponent()
|
|
|
|
local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor()
|
|
|
|
|
|
|
|
if UE.IsValid(TempRescueOtherComp) and UE.IsValid(TempPreViewActor) then
|
|
|
|
-- 配置倒地粒子 没有用这个方法
|
|
|
|
--TempRescueOtherComp.ShouldAddParticleWhenEnterLastBreath = true
|
|
|
|
--TempRescueOtherComp.ParticleTemplateToAddWhenEnterLastBreath = TempPreViewActor.KillParticle
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_ReceiveBeginPlay] Succeed")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--[[
|
|
|
|
function UGCPlayerPawn:ReceiveTick(DeltaTime)
|
|
|
|
UGCPlayerPawn.SuperClass.ReceiveTick(self, DeltaTime)
|
|
|
|
end
|
|
|
|
--]]
|
|
|
|
|
|
|
|
|
|
|
|
function UGCPlayerPawn:ReceiveEndPlay()
|
|
|
|
if UGCGameSystem.IsServer() then
|
|
|
|
self.OnDeath:Remove(self.OnDeathCallBack, self)
|
|
|
|
end
|
|
|
|
if self.CheckFXHandle then
|
|
|
|
UGCEventSystem.StopTimer(self.CheckFXHandle)
|
|
|
|
self.CheckFXHandle = nil
|
|
|
|
end
|
|
|
|
UGCPlayerPawn.SuperClass.ReceiveEndPlay(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--[[
|
|
|
|
function UGCPlayerPawn:GetReplicatedProperties()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
--]]
|
|
|
|
|
|
|
|
--[[
|
|
|
|
function UGCPlayerPawn:GetAvailableServerRPCs()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
--]]
|
|
|
|
|
|
|
|
-- 射击枪械槽类型
|
|
|
|
ShootWeaponEnums = {
|
|
|
|
ESurviveWeaponPropSlot.SWPS_MainShootWeapon1,
|
|
|
|
ESurviveWeaponPropSlot.SWPS_MainShootWeapon2,
|
|
|
|
ESurviveWeaponPropSlot.SWPS_SubShootWeapon,
|
|
|
|
};
|
|
|
|
|
|
|
|
function UGCPlayerPawn:OnPostGetWeapon(Weapon)
|
|
|
|
-- self:UpdateFX()
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_OnPostGetWeapon]")
|
2025-01-14 15:38:12 +08:00
|
|
|
self:WeaponAttachEffect(Weapon)
|
2025-01-09 13:36:39 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2025-01-14 15:38:12 +08:00
|
|
|
|
|
|
|
UGCPlayerPawn.BoundOnceEffectWeapons = {}
|
2025-01-09 13:36:39 +08:00
|
|
|
function UGCPlayerPawn:UpdateFX()
|
2025-01-14 15:38:12 +08:00
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_UpdateFX] PawnName:%s", KismetSystemLibrary.GetObjectName(self))
|
2025-01-09 13:36:39 +08:00
|
|
|
local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor()
|
|
|
|
if UE.IsValid(TempPreViewActor) then
|
|
|
|
for i, v in pairs(ShootWeaponEnums) do
|
|
|
|
local Weapon = UGCWeaponManagerSystem.GetWeaponBySlot(self, v);
|
2025-01-14 15:38:12 +08:00
|
|
|
self:WeaponAttachEffect(Weapon)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function UGCPlayerPawn:WeaponAttachEffect(Weapon)
|
|
|
|
local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor()
|
|
|
|
if UE.IsValid(TempPreViewActor) then
|
|
|
|
if UE.IsValid(Weapon) then
|
|
|
|
local Effect = Weapon:GetShootWeaponEffectComponent()
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_WeaponAttachEffect] WeaponName:%s", KismetSystemLibrary.GetObjectName(Weapon))
|
|
|
|
-- 枪口特效
|
|
|
|
local MuzzleFXParamName = {
|
|
|
|
"MuzzleFX",
|
|
|
|
"MuzzleFXOverride",
|
|
|
|
--"RemoteMuzzleFX",
|
|
|
|
--"ScopeMuzzleFX",
|
|
|
|
}
|
|
|
|
if UE.IsValid(Effect) and UE.IsValid(TempPreViewActor.MuzzleParticle) then
|
|
|
|
for i, v in pairs(MuzzleFXParamName) do
|
|
|
|
Effect[v] = TempPreViewActor.MuzzleParticle
|
2025-01-09 13:36:39 +08:00
|
|
|
end
|
2025-01-14 15:38:12 +08:00
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_WeaponAttachEffect] Succeed")
|
2025-01-09 13:36:39 +08:00
|
|
|
end
|
2025-01-14 15:38:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not UGCGameSystem.IsServer() and not table.hasValue(self.BoundOnceEffectWeapons, Weapon) then
|
|
|
|
|
|
|
|
local SKMesh = Weapon:GetWeaponSkeletalMeshComponent()
|
|
|
|
if not UE.IsValid(SKMesh) then
|
|
|
|
SKMesh = Weapon:GetWeaponStaticMeshComponent()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 枪口拖尾特效
|
|
|
|
if UE.IsValid(TempPreViewActor.TailedMuzzle) then
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_WeaponAttachEffect] 11111111111111111111111111")
|
|
|
|
if UE.IsValid(SKMesh) then
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_WeaponAttachEffect] 22222222222222222222222222222")
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_WeaponAttachEffect] Bind TailedMuzzle")
|
|
|
|
self.BoundOnceEffectWeapons[#self.BoundOnceEffectWeapons + 1] = Weapon
|
|
|
|
GameplayStatics.SpawnEmitterAttached(TempPreViewActor.TailedMuzzle, SKMesh, "MuzzleEffect", {X=0,Y=0,Z=0}, {Roll = 0, Pitch = 0, Yaw = 0}, {X=1,Y=1,Z=1}, EAttachLocation.SnapToTarget, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- 子弹拖尾特效
|
|
|
|
if TempPreViewActor.BulletParticle then
|
|
|
|
Weapon.OnBulletBeforeShootDelegate:Add(self.BindBulletTailFX, self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2025-01-09 13:36:39 +08:00
|
|
|
end
|
|
|
|
end
|
2025-01-14 15:38:12 +08:00
|
|
|
|
2025-01-09 13:36:39 +08:00
|
|
|
end
|
|
|
|
|
2025-01-14 15:38:12 +08:00
|
|
|
---@param Bullet ASTExtraShootWeaponBulletBase
|
|
|
|
function UGCPlayerPawn:BindBulletTailFX(Bullet)
|
|
|
|
local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor()
|
|
|
|
if UE.IsValid(TempPreViewActor) then
|
|
|
|
if UE.IsValid(Bullet) then
|
|
|
|
|
|
|
|
-- GameplayStatics.SpawnEmitterAttached(TempPreViewActor.BulletParticle, Bullet:K2_GetRootComponent(), "", {X=0,Y=0,Z=0}, {Roll = 0, Pitch = 0, Yaw = 0}, {X=1,Y=1,Z=1}, EAttachLocation.SnapToTarget, true)
|
|
|
|
|
|
|
|
local BulletTailFXActor = UGCGameSystem.GameState:GetBulletFXActor()
|
|
|
|
--BulletTailFXActor.ProjectileMovement.InitialSpeed = InitialSpeed
|
|
|
|
--BulletTailFXActor.ProjectileMovement.Velocity = VectorHelper.MulNumber(Bullet:GetActorForwardVector(), InitialSpeed)
|
|
|
|
local InitialSpeed = Bullet:GetMaxBulletFlySpeed()
|
|
|
|
local Velocity = VectorHelper.MulNumber(Bullet:GetActorForwardVector(), InitialSpeed)
|
|
|
|
BulletTailFXActor:ActiveFly(Bullet:K2_GetActorRotation(), Bullet:K2_GetActorLocation(), Velocity, TempPreViewActor.BulletParticle)
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_BindBulletTailFX] InitialSpeed:%s", tostring(InitialSpeed))
|
|
|
|
--Bullet.NormalTailFX = TempPreViewActor.BulletParticle
|
|
|
|
--Bullet.BeamTailFX = TempPreViewActor.BulletParticle
|
|
|
|
--
|
|
|
|
--Bullet.NormalTailFXComp:SetTemplate(TempPreViewActor.BulletParticle)
|
|
|
|
--Bullet.BeamTailFXComp:SetTemplate(TempPreViewActor.BulletParticle)
|
|
|
|
--
|
|
|
|
--Bullet.bShowNormalTailFXImpactInfo = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2025-01-09 13:36:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---@param DamageInfo FDamageInfoCollection
|
|
|
|
---@return VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue uint, uint, int, EDamageType, bool, float, float
|
|
|
|
function UGCPlayerPawn:GetDamageInfoCollectionInfo(DamageInfo)
|
|
|
|
local CauserController = DamageInfo.Instigator
|
|
|
|
local WeaponID = -1
|
|
|
|
local CauserKey = CauserController and CauserController.PlayerKey or -1
|
|
|
|
local VictimKey = self.PlayerKey
|
|
|
|
local CauserItemID = DamageInfo.CauserItemID
|
|
|
|
--- 近战投掷、投掷手雷
|
|
|
|
if CauserItemID then
|
|
|
|
WeaponID = CauserItemID
|
|
|
|
end
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_GetDamageInfoCollectionInfo] WeaponID:%d", WeaponID)
|
|
|
|
local Distance = 0.
|
|
|
|
if CauserController and CauserController.Pawn then
|
|
|
|
Distance = VectorHelper.GetDistance(self:K2_GetActorLocation(), CauserController.Pawn:K2_GetActorLocation())
|
|
|
|
end
|
|
|
|
|
|
|
|
local IsHeadShotDamage = (DamageInfo.Hit.BoneName == "head")
|
|
|
|
return VictimKey, CauserKey, WeaponID, DamageInfo.DamageType, IsHeadShotDamage, Distance, DamageInfo.Damage
|
|
|
|
end
|
|
|
|
|
|
|
|
---@param DamageInfo FDamageInfoCollection
|
|
|
|
function UGCPlayerPawn:PlayerDead(DamageInfo)
|
|
|
|
UGCLogSystem.LogTree("[UGCPlayerPawn_PlayerDead] DamageInfo:", UE.ToTable(DamageInfo))
|
|
|
|
local VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue = self:GetDamageInfoCollectionInfo(DamageInfo)
|
|
|
|
--UGCSendRPCSystem.RPCEvent(nil, EventEnum.PlayerDeathInfo, VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
|
|
|
|
--UGCEventSystem.SendEvent(EventEnum.PlayerDeathInfo, VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
|
|
|
|
UGCGameSystem.GameState:SetPlayerIsAlive(VictimKey, nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
---@param DamageInfo FDamageInfoCollection
|
|
|
|
---@param ReturnValue float
|
|
|
|
function UGCPlayerPawn:PlayerInjury(DamageInfo)
|
|
|
|
local VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue = self:GetDamageInfoCollectionInfo(DamageInfo)
|
|
|
|
UGCEventSystem.SendEvent(EventEnum.PlayerInjuryInfo, VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
|
|
|
|
UGCSendRPCSystem.RPCEvent(CauserKey, EventEnum.PlayerInjuryInfo, VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
|
|
|
|
end
|
|
|
|
|
|
|
|
function UGCPlayerPawn:OnDeathCallBack(DeadCharacter,Killer,DamageCauser,KillingHitInfo,KillingHitImpulseDir,KillingHitDamageTypeID,DamageTypeClass,IsHeadShotDamage)
|
|
|
|
local CauserKey = Killer and Killer.PlayerKey
|
|
|
|
local WeaponID = -1
|
|
|
|
local DamageType = EDamageType.UGCCustomDamageType + 1
|
|
|
|
UGCLogSystem.Log("[UGCPlayerPawn_TestOnDeath] PlayerKey:%s, CauserKey:%s", tostring(self.PlayerKey), tostring(CauserKey))
|
|
|
|
UGCSendRPCSystem.RPCEvent(nil, EventEnum.PlayerDeathInfo, self.PlayerKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, 0, 0)
|
|
|
|
UGCEventSystem.SendEvent(EventEnum.PlayerDeathInfo, self.PlayerKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, 0, 0)
|
|
|
|
|
|
|
|
|
|
|
|
-- 发送RPC倒地粒子
|
|
|
|
local SelfPos = self:K2_GetActorLocation()
|
|
|
|
SelfPos = {
|
|
|
|
X = SelfPos.X,
|
|
|
|
Y = SelfPos.Y,
|
|
|
|
Z = SelfPos.Z,
|
|
|
|
}
|
|
|
|
UnrealNetwork.CallUnrealRPC_Multicast(UGCGameSystem.GameState, "SpawnParticleAtPos", SelfPos);
|
|
|
|
end
|
|
|
|
|
|
|
|
return UGCPlayerPawn
|