Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_InspectCasualtyUserAction.c
Go to the documentation of this file.
2 {
3  //------------------------------------------------------------------------------------------------
4  override bool CanBeShownScript(IEntity user)
5  {
6  ChimeraCharacter userChar = ChimeraCharacter.Cast(user);
7  ChimeraCharacter ownerChar = ChimeraCharacter.Cast(GetOwner());
8  if (!userChar || !ownerChar)
9  return false;
10 
11  if (userChar == ownerChar)
12  return false;
13 
14  SCR_CharacterDamageManagerComponent damageMan = SCR_CharacterDamageManagerComponent.Cast(ownerChar.GetDamageManager());
15  if (!damageMan)
16  return false;
17 
18  HitZone hz = damageMan.GetDefaultHitZone();
19  if (!hz)
20  return false;
21 
22  if (hz.GetDamageState() == EDamageState.UNDAMAGED)
23  {
24  SCR_CharacterBloodHitZone bloodHZ = SCR_CharacterBloodHitZone.Cast(damageMan.GetBloodHitZone());
25  if (!bloodHZ)
26  return false;
27 
28  if (bloodHZ.GetDamageState() == EDamageState.UNDAMAGED)
29  return false;
30  }
31 
32  CompartmentAccessComponent userCompAccessComp = userChar.GetCompartmentAccessComponent();
33  CompartmentAccessComponent targetCompAccessComp = ownerChar.GetCompartmentAccessComponent();
34  if (!userCompAccessComp || !targetCompAccessComp)
35  return false;
36 
37  IEntity userVeh = userCompAccessComp.GetVehicleIn(userChar);
38  IEntity targetVeh = targetCompAccessComp.GetVehicleIn(ownerChar);
39 
40  // If inspector is not in vehicle return true
41  if (!userVeh)
42  return CanBePerformedScript(user);
43 
44  // If inspector and target are both in vehicle, check if they're in the same one, and if so, return true
45  if (userVeh && targetVeh && targetVeh == userVeh)
46  return CanBePerformedScript(user);
47 
48  return false;
49  }
50 
51  //------------------------------------------------------------------------------------------------
52  override bool CanBePerformedScript(IEntity user)
53  {
54  ChimeraCharacter char = ChimeraCharacter.Cast(GetOwner());
55  if (!char)
56  return false;
57 
58  // Don't inspect dead people
59  CharacterControllerComponent controller = char.GetCharacterController();
60  if (controller.GetLifeState() == ECharacterLifeState.DEAD)
61  return false;
62 
63  // Don't show inspect userAction when already showing SCR_InspectCasualtyWidget
64  SCR_InspectCasualtyWidget casualtyInspectDisplay;
65  array<BaseInfoDisplay> infoDisplays = {};
66 
67  PlayerController playerController = PlayerController.Cast(GetGame().GetPlayerController());
68  if (!playerController)
69  return false;
70 
71  HUDManagerComponent hudMan = playerController.GetHUDManagerComponent();
72  if (!hudMan)
73  return false;
74 
75  hudMan.GetInfoDisplays(infoDisplays);
76 
77  foreach (BaseInfoDisplay baseInfoDisplays : infoDisplays)
78  {
79  casualtyInspectDisplay = SCR_InspectCasualtyWidget.Cast(baseInfoDisplays);
80  if (!casualtyInspectDisplay)
81  continue;
82 
83  if (casualtyInspectDisplay.IsActive() && casualtyInspectDisplay.m_Target == GetOwner())
84  return false;
85  }
86 
87  return true;
88  }
89 
90  //------------------------------------------------------------------------------------------------
91  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
92  {
93  array<BaseInfoDisplay> infoDisplays = {};
94  GetGame().GetPlayerController().GetHUDManagerComponent().GetInfoDisplays(infoDisplays);
95  foreach (BaseInfoDisplay baseInfoDisplays : infoDisplays)
96  {
97  SCR_InspectCasualtyWidget casualtyInspectDisplay = SCR_InspectCasualtyWidget.Cast(baseInfoDisplays);
98  if (!casualtyInspectDisplay)
99  continue;
100 
101  casualtyInspectDisplay.SetTarget(pOwnerEntity);
102  casualtyInspectDisplay.ShowInspectCasualtyWidget(pOwnerEntity);
103  return;
104  }
105  }
106 
107  //------------------------------------------------------------------------------------------------
108  override void OnActionStart(IEntity pUserEntity)
109  {
110  ChimeraCharacter char = ChimeraCharacter.Cast(pUserEntity);
111  if (!char)
112  return;
113 
114  CharacterControllerComponent contr = char.GetCharacterController();
115  if(!contr)
116  return;
117 
118  if (contr.CanPartialLower() && !contr.IsPartiallyLowered())
119  contr.SetPartialLower(true);
120  }
121 
122  //------------------------------------------------------------------------------------------------
124  override bool HasLocalEffectOnlyScript()
125  {
126  return true;
127  }
128 
129  //------------------------------------------------------------------------------------------------
131  override bool CanBroadcastScript()
132  {
133  return false;
134  };
135 }
ECharacterLifeState
ECharacterLifeState
Definition: ECharacterLifeState.c:12
HitZone
Definition: HitZone.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
ScriptedUserAction
Definition: ScriptedUserAction.c:12
EDamageState
EDamageState
Definition: EDamageState.c:12
GetPlayerController
proto external PlayerController GetPlayerController()
Definition: SCR_PlayerDeployMenuHandlerComponent.c:307
SCR_CharacterBloodHitZone
Blood - does not receive damage directly, only via scripted events.
Definition: SCR_CharacterHitZone.c:480
SCR_InspectCasualtyWidget
Definition: SCR_InspectCasualtyWidget.c:1
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
BaseInfoDisplay
Definition: BaseInfoDisplay.c:12
SCR_InspectCasualtyUserAction
Definition: SCR_InspectCasualtyUserAction.c:1