UGCProjects/AthleticMasters/Script/Global/EventManager/EventAction/EventAction_PlayerDeadUpdateInfo.lua
2025-01-04 23:00:19 +08:00

74 lines
2.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local EventAction_PlayerDeadUpdateInfo = {
DeadPlayerKey = -1;
KillerPlayerKey = -1;
AssisterPlayerKey = -1;
WeaponID = -1;
}
-- 触发器激活时将执行Action的Execute
function EventAction_PlayerDeadUpdateInfo:Execute(...)
if not UGCGameSystem.IsServer() then return end
-- 判断是否在游戏
if UGCGameSystem.GameState.GameStateType ~= CustomEnum.EGameState.Playing and UGCGameSystem.GameState.GameStateType ~= CustomEnum.EGameState.Waiting then
UGCGameSystem.GameMode:Server_RespawnPlayer(self.DeadPlayerKey)
return
end
-- 击杀队友不计算得分
if UGCPlayerStateSystem.GetTeamID(self.DeadPlayerKey) == UGCPlayerStateSystem.GetTeamID(self.KillerPlayerKey) then
return true
end
local KillerPlayerState = UGCGameSystem.GetPlayerStateByPlayerKey(self.KillerPlayerKey)
if UE.IsValid(KillerPlayerState) and self.DeadPlayerKey ~= self.KillerPlayerKey then
-- PlayerState记录击杀
KillerPlayerState:PlayerKill(self.DeadPlayerKey, self.WeaponID)
end
local DeadPlayerState = UGCGameSystem.GetPlayerStateByPlayerKey(self.DeadPlayerKey)
if UE.IsValid(DeadPlayerState) then
-- PlayerState记录死亡
DeadPlayerState:PlayerDead(self.KillerPlayerKey)
end
local AssisterPlayerState = UGCGameSystem.GetPlayerStateByPlayerKey(self.AssisterPlayerKey)
UGCLogSystem.Log("[EventAction_PlayerDeadUpdateInfo_Execute] AssisterPlayerKey:%s", tostring(self.AssisterPlayerKey))
if UE.IsValid(AssisterPlayerState) then
-- PlayerState记录助攻
AssisterPlayerState:PlayerAssist()
end
-- 更新玩家得分
self:UpdatePlayerScore()
return true
end
function EventAction_PlayerDeadUpdateInfo:UpdatePlayerScore()
local AddScore = GlobalConfigs.GetAddScore(self.WeaponID)
-- 更新玩家梯度等级
-- UGCGameSystem.GameState:PlayerAddWeaponGrade(self.KillerPlayerKey, AddScore)
-- 增加玩家金币
UGCGameSystem.GameState:AddPlayerCoin(self.KillerPlayerKey, WeaponShopTable.GetWeaponKillRewards(self.WeaponID))
-- 增加玩家得分
UGCGameSystem.GameState:AddScore(self.KillerPlayerKey, AddScore)
-- 刷新玩家数据
UGCGameSystem.GameState:UpdateAllPlayerScoreDatas()
---- 夺取死亡玩家的能量
-- --self:SeizePlayerEnergy()
end
function EventAction_PlayerDeadUpdateInfo:SeizePlayerEnergy()
if self.DeadPlayerKey ~= self.KillerPlayerKey and self.KillerPlayerKey > 0 then
local DeadPlayer = UGCGameSystem.GetPlayerPawnByPlayerKey(self.DeadPlayerKey)
local Killer = UGCGameSystem.GetPlayerPawnByPlayerKey(self.KillerPlayerKey)
if UE.IsValid(Killer) and UE.IsValid(DeadPlayer) then
local MechanismEnergy = DeadPlayer:GetMechanismEnergy()
Killer:AddMechanismEnergy(math.clamp(MechanismEnergy, 0, GlobalConfigs.GameSetting.SeizeEnergyMax))
end
end
end
return EventAction_PlayerDeadUpdateInfo