79 lines
3.2 KiB
Lua
79 lines
3.2 KiB
Lua
|
---@class UGCGameMode_C:BP_UGCGameBase_C
|
||
|
--Edit Below--
|
||
|
---@type UGCGameMode_C
|
||
|
local UGCGameMode = {};
|
||
|
function UGCGameMode:ReceiveBeginPlay()
|
||
|
self.SuperClass.ReceiveBeginPlay(self);
|
||
|
self.bIsOpenShovelingAbility = true
|
||
|
UGCBlueprintFunctionLibrary.InitGameModeStates();
|
||
|
end
|
||
|
|
||
|
---@param DamageType EDamageType
|
||
|
function UGCGameMode:LuaModifyDamage(Damage, DamageType, InstigatorPlayerState, VictimPlayerState)
|
||
|
UGCLogSystem.Log("[UGCGameMode:LuaModifyDamage] Damage = %s", tostring(Damage));
|
||
|
local EventInstigator = nil;
|
||
|
local InstigatorPawn = nil;
|
||
|
if InstigatorPlayerState then
|
||
|
EventInstigator = UGCGameSystem.GetPlayerControllerByPlayerKey(InstigatorPlayerState.PlayerKey);
|
||
|
InstigatorPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(InstigatorPlayerState.PlayerKey)
|
||
|
end
|
||
|
local VictimPC = UGCGameSystem.GetPlayerControllerByPlayerKey(VictimPlayerState.PlayerKey);
|
||
|
local VictimPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(VictimPlayerState.PlayerKey);
|
||
|
|
||
|
-- 非比赛阶段,无法产生伤害
|
||
|
if UGCGameSystem.GameState.RoundInfo.RoundState ~= RoundState.InRound then return 0; end
|
||
|
|
||
|
-- 是否开启友伤
|
||
|
local LocalTeamId = UGCPlayerStateSystem.GetTeamID(VictimPlayerState.PlayerKey);
|
||
|
if DamageType == EDamageType.FallingDamage then
|
||
|
Damage = 0;
|
||
|
return 0;
|
||
|
end
|
||
|
if DamageType ~= EDamageType.PoisonDamage then
|
||
|
if EventInstigator ~= nil then
|
||
|
local InstigatorId = UGCPlayerStateSystem.GetTeamID(InstigatorPlayerState.PlayerKey);
|
||
|
if not DefaultSettings.DamageByTeamPlayer then
|
||
|
if LocalTeamId == InstigatorId then return 0; end
|
||
|
end
|
||
|
Damage = Damage * VictimPawn.Defence;
|
||
|
if InstigatorPawn ~= nil and InstigatorPawn.Strong ~= nil then
|
||
|
--- 修改伤害值
|
||
|
Damage = InstigatorPawn:GetParam("Strong") * Damage;
|
||
|
end
|
||
|
|
||
|
local SoldierType = EventInstigator:GetSoldierType()
|
||
|
if SoldierType == SoldierConfig.ESoldierType.Demolitions then
|
||
|
if DamageType == EDamageType.BurningDamage or DamageType == EDamageType.RadialDamage then
|
||
|
Damage = Damage * SoldierConfig.Skills[SoldierType].Damage;
|
||
|
end
|
||
|
end
|
||
|
|
||
|
UGCEventSystem.SendEvent(EventTypes.PlayerCause, Damage, false, EventInstigator.PlayerKey, VictimPlayerState.PlayerKey);
|
||
|
UGCGameSystem.GameState:UpdateDamage(EventInstigator.PlayerKey, Damage);
|
||
|
end
|
||
|
else
|
||
|
--- 判断当前是什么造成的伤害
|
||
|
Damage = Damage * VictimPawn.PoisonDefence;
|
||
|
|
||
|
if not VictimPC.EnablePoison then return 0.; end
|
||
|
UGCEventSystem.SendEvent(EventTypes.PlayerCause, Damage, false, nil, VictimPawn.PlayerKey);
|
||
|
VictimPawn.PoisonDamage = Damage;
|
||
|
DOREPONCE(VictimPawn, "PoisonDamage");
|
||
|
UGCEventSystem.SendEvent(EventTypes.PlayerPoisonDamage, VictimPawn.PlayerKey, Damage);
|
||
|
UnrealNetwork.CallUnrealRPC(VictimPawn:GetController(), VictimPawn, "HandlePoisonDamage", Damage, UGCPawnAttrSystem.GetHealth(VictimPawn), UGCPawnAttrSystem.GetHealthMax(VictimPawn));
|
||
|
end
|
||
|
UGCLogSystem.Log("[UGCGameMode:LuaModifyDamage] 收到的伤害:%s", tostring(Damage));
|
||
|
if VictimPawn then
|
||
|
local VictimHealth = UGCPawnAttrSystem.GetHealthMax(VictimPawn);
|
||
|
if Damage > VictimHealth then Damage = VictimHealth; end
|
||
|
end
|
||
|
return Damage;
|
||
|
end
|
||
|
|
||
|
-- function UGCGameMode:ReceiveTick(DeltaTime)
|
||
|
|
||
|
-- end
|
||
|
-- function UGCGameMode:ReceiveEndPlay()
|
||
|
|
||
|
-- end
|
||
|
return UGCGameMode;
|