76 lines
3.0 KiB
Lua
76 lines
3.0 KiB
Lua
|
local EventAction_PlayerDeadUpdateInfo = {
|
|||
|
DeadPlayerKey = -1;
|
|||
|
KillerPlayerKey = -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
|
|||
|
|
|||
|
-- 更新玩家得分
|
|||
|
self:UpdatePlayerScore()
|
|||
|
|
|||
|
return true
|
|||
|
end
|
|||
|
|
|||
|
function EventAction_PlayerDeadUpdateInfo:UpdatePlayerScore()
|
|||
|
local AddScore = GlobalConfigs.GetAddScore(self.WeaponID)
|
|||
|
|
|||
|
-- 增加玩家得分
|
|||
|
UGCGameSystem.GameState:AddScore(self.KillerPlayerKey, AddScore)
|
|||
|
-- 刷新玩家数据
|
|||
|
UGCGameSystem.GameState:UpdateAllPlayerScoreDatas()
|
|||
|
-- 夺取死亡玩家的能量
|
|||
|
self:SeizePlayerEnergy()
|
|||
|
if UGCGameSystem.GameState:GetSpecialModeType() == MapConfig.ESpecialModeType.ArmsRace then
|
|||
|
local Score = UGCGameSystem.GameState:GetPlayerScore(self.KillerPlayerKey)
|
|||
|
if Score > #WeaponGradientTable.ArmsRaceGradient[1] then
|
|||
|
UGCGameSystem.GameState:GameFinish()
|
|||
|
else
|
|||
|
-- 更新玩家梯度等级
|
|||
|
UGCGameSystem.GameState:PlayerAddWeaponGrade(self.KillerPlayerKey, AddScore)
|
|||
|
end
|
|||
|
UGCLogSystem.Log("[EventAction_PlayerDeadUpdateInfo_UpdatePlayerScore] Score:%s", tostring(Score))
|
|||
|
else
|
|||
|
-- 更新玩家梯度等级
|
|||
|
UGCGameSystem.GameState:PlayerAddWeaponGrade(self.KillerPlayerKey, AddScore)
|
|||
|
end
|
|||
|
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
|