87 lines
3.0 KiB
Lua
87 lines
3.0 KiB
Lua
local Action_CheckPlayers = {
|
||
-- 可配置参数定义,参数将显示在Action配置面板
|
||
-- 例:
|
||
-- MyIntParameter = 0
|
||
-- CheckPlayers
|
||
}
|
||
|
||
-- 触发器激活时,将执行Action的Execute
|
||
function Action_CheckPlayers:Execute(...)
|
||
UGCLogSystem.Log("[Action_CheckPlayers:Execute] 执行")
|
||
GlobalTickTool:AddTick(self, self.OnCheckPlayers, 10);
|
||
-- 检查
|
||
GlobalTickTool:AddTick(self, self.OnCheckInfinite, 3)
|
||
GlobalCheckPlayers = self;
|
||
return true
|
||
end
|
||
|
||
function Action_CheckPlayers:OnCheckPlayers(dt, st)
|
||
local PCs = UGCGameSystem.GetAllPlayerController(false)
|
||
if table.getCount(PCs) == 1 then
|
||
if table.isEmpty(GameState.PlayerDisconnect) then
|
||
-- 说明此时没有走玩家退出逻辑,开始执行结束
|
||
local LastPlayerKey = nil;
|
||
for i, PC in pairs(PCs) do
|
||
UGCLogSystem.Log("[Action_CheckPlayers:OnCheckPlayers] 111")
|
||
MiniManager.CurrMiniMode:HandlePlayerRank(PC.PlayerKey, true);
|
||
LastPlayerKey = PC.PlayerKey;
|
||
end
|
||
|
||
if table.getCount(UE.GetAccountInfo()) == 1 then
|
||
UGCLogSystem.Log("[Action_CheckPlayers:OnCheckPlayers] 333")
|
||
for i, v in pairs(UE.GetAccountInfo()) do
|
||
MiniManager.CurrMiniMode:SetGameOver(i);
|
||
end
|
||
else
|
||
for PlayerKey, Info in pairs(UE.GetAccountInfo()) do
|
||
if PlayerKey ~= LastPlayerKey then
|
||
UGCLogSystem.Log("[Action_CheckPlayers:OnCheckPlayers] 222")
|
||
table.func(MiniManager, "OnPlayerLeave", PlayerKey)
|
||
GlobalTickTool:RemoveAll(self);
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
-- 永远不要停
|
||
function Action_CheckPlayers:OnCheckInfinite()
|
||
UGCLogSystem.Log("[Action_CheckPlayers:OnCheckInfinite] 检测是否有无限子弹")
|
||
local Pawns = UGCGameSystem.GetAllPlayerPawn();
|
||
for _, Pawn in pairs(Pawns) do
|
||
-- 设置玩家无限子弹方式
|
||
if UE.IsValidPawn(Pawn) then
|
||
-- 检查是否是无限子弹模式
|
||
for _, Enum in pairs(AllWeaponEnums) do
|
||
local Weapon = UGCWeaponManagerSystem.GetWeaponBySlot(Pawn, Enum);
|
||
if Weapon and UE.IsValid(Weapon) and ItemTool.IsShootWeapon(Weapon) then
|
||
local ItemID = Weapon:GetWeaponItemID();
|
||
if table.isEmpty(WeaponSuits[ItemID]) then break ; end -- 因为只有一把枪,可以这样搞
|
||
-- 首先检查一下是否存在这个配件,
|
||
if WeaponSuits[ItemID][EWeaponPartType.Magazine] then
|
||
--- 获取武器是否有配件
|
||
local Parts = ItemTool.GetWeaponParts(Weapon);
|
||
|
||
local BestMagazineList = WeaponSuits[ItemID][EWeaponPartType.Magazine]
|
||
if table.isEmpty(BestMagazineList) then return; end
|
||
local BestMagazine = BestMagazineList[1];
|
||
UGCLogSystem.Log("[Action_CheckPlayers:OnCheckInfinite] BestMagazine = %d", BestMagazine);
|
||
local HasTheBest = false;
|
||
--- 检查是否存在
|
||
for _, PartId in pairs(Parts) do
|
||
if PartId == BestMagazine then HasTheBest = true; end
|
||
end
|
||
|
||
if not HasTheBest then
|
||
Pawn:ReplacePartId(BestMagazine, EWeaponPartType.Magazine);
|
||
end
|
||
end
|
||
end
|
||
end
|
||
ItemTool.SetAllWeaponInfinite(Pawn, EFillBulletType.ClipInfinite, true);
|
||
end
|
||
end
|
||
end
|
||
|
||
return Action_CheckPlayers |