86 lines
5.0 KiB
C
86 lines
5.0 KiB
C
#ifdef WORKBENCH
|
|
modded class ERR_GameMode
|
|
{
|
|
IEntity m_BurialPlayer, m_BurialBody, m_BurialShovel;
|
|
ERR_BuryBodyAction m_BurialAction;
|
|
float m_BurialDeadline;
|
|
int m_BurialStage;
|
|
bool m_BurialStopped;
|
|
override protected void EOnInit(IEntity owner)
|
|
{
|
|
super.EOnInit(owner);
|
|
string kind;
|
|
if (SCR_Global.IsEditMode() || !System.GetCLIParam("errSmokeOutcome", kind) || kind != "body-burial") return;
|
|
GetGame().GetCallqueue().CallLater(ERR_TestBurialTick, 100, true);
|
|
}
|
|
bool ERR_BurialCheck(bool condition, string label)
|
|
{
|
|
if (condition) { Print("ERR SMOKE PASS: burial " + label); return true; }
|
|
Print("ERR SMOKE FAIL: burial " + label, LogLevel.ERROR);
|
|
m_BurialStopped = true; GetGame().GetCallqueue().Remove(ERR_TestBurialTick);
|
|
return false;
|
|
}
|
|
void ERR_TestBurialTick()
|
|
{
|
|
if (m_BurialStopped || !Active() || Phase() != ERR_Phase.PRISON) return;
|
|
float now = GetWorld().GetWorldTime();
|
|
if (m_BurialDeadline > 0 && now > m_BurialDeadline) { ERR_BurialCheck(false, "fixture stage deadline " + m_BurialStage); return; }
|
|
if (m_BurialStage == 0)
|
|
{
|
|
m_BurialPlayer = GetGame().GetPlayerController().GetControlledEntity();
|
|
if (!m_BurialPlayer || !Players().CurrentActor(m_BurialPlayer)) return;
|
|
m_BurialBody = ERR_Actors.Spawn("{C31F210ABE078199}Prefabs/ERR/ReconPilotWest.et", ERR_Actors.Ground(m_BurialPlayer.GetOrigin() + Vector(1.2,0,0)));
|
|
Own(m_BurialBody);
|
|
if (!ERR_BurialCheck(m_BurialBody != null, "native character spawned")) return;
|
|
BaseActionsManagerComponent actions = BaseActionsManagerComponent.Cast(m_BurialBody.FindComponent(BaseActionsManagerComponent));
|
|
array<BaseUserAction> list = {}; actions.GetActionsList(list);
|
|
foreach (BaseUserAction action : list) if (ERR_BuryBodyAction.Cast(action)) m_BurialAction = ERR_BuryBodyAction.Cast(action);
|
|
if (!ERR_BurialCheck(m_BurialAction != null, "inherited body action exists in native manager")) return;
|
|
if (!ERR_BurialCheck(!m_BurialAction.CanBeShownScript(m_BurialPlayer) && !ERR_Burial.Dead(m_BurialBody), "living character cannot be buried")) return;
|
|
DamageManagerComponent damage = DamageManagerComponent.Cast(m_BurialBody.FindComponent(DamageManagerComponent));
|
|
damage.SetHealthScaled(0);
|
|
m_BurialStage = 1; m_BurialDeadline = now + 10000; return;
|
|
}
|
|
if (m_BurialStage == 1)
|
|
{
|
|
if (!ERR_Burial.Dead(m_BurialBody)) return;
|
|
if (!ERR_BurialCheck(!m_BurialAction.CanBeShownScript(m_BurialPlayer) && !ERR_Burial.Permitted(m_BurialPlayer, m_BurialBody), "empty hands reject corpse burial")) return;
|
|
m_BurialShovel = ERR_Actors.Spawn("{6E35D94130954509}Prefabs/Items/Equipment/Accessories/ETool_ALICE/ETool_ALICE_FreeRoamBuilding_Gadget.et", m_BurialPlayer.GetOrigin());
|
|
SCR_InventoryStorageManagerComponent inventory = SCR_InventoryStorageManagerComponent.Cast(m_BurialPlayer.FindComponent(SCR_InventoryStorageManagerComponent));
|
|
if (!ERR_BurialCheck(m_BurialShovel && inventory.TryInsertItem(m_BurialShovel), "native shovel inserted into inventory")) return;
|
|
m_BurialStage = 2; m_BurialDeadline = now + 10000; return;
|
|
}
|
|
if (m_BurialStage == 2)
|
|
{
|
|
if (!ERR_BurialCheck(!ERR_Burial.ShovelHeld(m_BurialPlayer) && !m_BurialAction.CanBeShownScript(m_BurialPlayer), "carried shovel alone is insufficient")) return;
|
|
SCR_GadgetManagerComponent.GetGadgetManager(m_BurialPlayer).SetGadgetMode(m_BurialShovel, EGadgetMode.IN_HAND);
|
|
m_BurialStage = 3; m_BurialDeadline = now + 15000; return;
|
|
}
|
|
if (m_BurialStage == 3)
|
|
{
|
|
if (!ERR_Burial.ShovelHeld(m_BurialPlayer)) return;
|
|
PrintFormat("ERR BURIAL DIAG user=%1 corpse=%2 reason=%3", m_BurialPlayer.GetOrigin(), m_BurialBody.GetOrigin(), ERR_Burial.Rejection(m_BurialPlayer,m_BurialBody));
|
|
if (!ERR_BurialCheck(m_BurialAction.CanBeShownScript(m_BurialPlayer) && m_BurialAction.CanBePerformedScript(m_BurialPlayer) && ERR_Burial.Permitted(m_BurialPlayer,m_BurialBody), "equipped shovel permits nearby native corpse")) return;
|
|
vector near = m_BurialBody.GetOrigin();
|
|
m_BurialBody.SetOrigin(near + Vector(10,0,0));
|
|
if (!ERR_BurialCheck(!ERR_Burial.Permitted(m_BurialPlayer,m_BurialBody), "distant corpse is rejected")) return;
|
|
m_BurialBody.SetOrigin(near);
|
|
m_BurialAction.PerformAction(m_BurialPlayer, m_BurialPlayer);
|
|
if (!ERR_BurialCheck(m_BurialBody != null, "wrong action owner cannot remove corpse")) return;
|
|
// Real action callback; the duration is native UI configuration, not forged here.
|
|
m_BurialAction.PerformAction(m_BurialBody, m_BurialPlayer);
|
|
m_BurialStage = 4; m_BurialDeadline = now + 3000; return;
|
|
}
|
|
if (m_BurialStage == 4)
|
|
{
|
|
if (m_BurialBody) return;
|
|
if (!ERR_BurialCheck(ERR_Actors.CanFight(m_BurialPlayer) && m_BurialShovel && ERR_Burial.ShovelHeld(m_BurialPlayer), "replicated corpse removal preserves player and held shovel")) return;
|
|
ERR_Burial.Complete(m_BurialPlayer, m_BurialBody);
|
|
Print("ERR SMOKE PASS: burial duplicate completion is harmless");
|
|
Print("ERR SMOKE COMPLETE: body-burial");
|
|
m_BurialStopped = true; GetGame().GetCallqueue().Remove(ERR_TestBurialTick);
|
|
}
|
|
}
|
|
}
|
|
#endif
|