---@class UGCPlayerPawn_C:BP_UGCPlayerPawn_C ---@field StartItemID TArray --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 if self.CheckFXHandle == nil then -- 这里防止未设置成功做的校验 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]") local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor() local Effect = Weapon:GetShootWeaponEffectComponent() if UE.IsValid(TempPreViewActor) and UE.IsValid(Effect) and UE.IsValid(TempPreViewActor.MuzzleParticle) then Effect.MuzzleFX = TempPreViewActor.MuzzleParticle UGCLogSystem.Log("[UGCPlayerPawn_OnPostGetWeapon] Succeed") end end function UGCPlayerPawn:UpdateFX() UGCLogSystem.Log("[UGCPlayerPawn_UpdateFX]") local TempPreViewActor = UGCGameSystem.GameState:GetPreViewFXActor() if UE.IsValid(TempPreViewActor) then for i, v in pairs(ShootWeaponEnums) do local Weapon = UGCWeaponManagerSystem.GetWeaponBySlot(self, v); if UE.IsValid(Weapon) then local Effect = Weapon:GetShootWeaponEffectComponent() if UE.IsValid(Effect) and UE.IsValid(TempPreViewActor.MuzzleParticle) then Effect.MuzzleFX = TempPreViewActor.MuzzleParticle UGCLogSystem.Log("[UGCPlayerPawn_UpdateFX] Succeed") end end end end end ---@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