Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_HealingUserAction.c
Go to the documentation of this file.
2 {
3  [Attribute("0", UIWidgets.ComboBox, "Which hitzone group will be checked for conditions", enums:ParamEnumArray.FromEnum(ECharacterHitZoneGroup) )]
4  protected ECharacterHitZoneGroup m_eHitZoneGroup;
5 
6  [Attribute("0", UIWidgets.ComboBox, "Which consumabletype will be checked for conditions", enums:ParamEnumArray.FromEnum(SCR_EConsumableType) )]
7  protected SCR_EConsumableType m_eConsumableType;
8 
9  [Attribute("#AR-FailReason_AlreadyApplied", UIWidgets.EditBox, "String for already applied healing gadgets")]
10  protected LocalizedString m_sAlreadyApplied;
11 
12  [Attribute("#AR-FailReason_NotBleeding", UIWidgets.EditBox, "String for when target hitzone isn't bleeding")]
13  protected LocalizedString m_sNotBleeding;
14 
15  [Attribute("#AR-FailReason_NoBloodLoss", UIWidgets.EditBox, "String for when blood hitzone isn't damaged")]
16  protected LocalizedString m_sNoBloodLoss;
17 
18  [Attribute("#AR-FailReason_NotDamaged", UIWidgets.EditBox, "String for when target hitzone isn't damaged")]
19  protected LocalizedString m_sNotDamaged;
20 
21  //------------------------------------------------------------------------------------------------
22  protected SCR_ConsumableItemComponent GetConsumableComponent(notnull ChimeraCharacter userChar)
23  {
24  CharacterControllerComponent controller = userChar.GetCharacterController();
25  if (!controller)
26  return null;
27 
28  IEntity item = controller.GetAttachedGadgetAtLeftHandSlot();
29  if (!item)
30  return null;
31 
32  return SCR_ConsumableItemComponent.Cast(item.FindComponent(SCR_ConsumableItemComponent));;
33  }
34 
35  //------------------------------------------------------------------------------------------------
36  override bool CanBeShownScript(IEntity user)
37  {
38  // It is not allowed to perform healing useraction on self
39  if (!user || user == GetOwner())
40  return false;
41 
42  // Target character
43  ChimeraCharacter targetCharacter = ChimeraCharacter.Cast(GetOwner());
44  if (!targetCharacter)
45  return false;
46 
47  // Medic character
48  ChimeraCharacter userCharacter = ChimeraCharacter.Cast(user);
49  if (!userCharacter)
50  return false;
51 
52  // Medics' item use ability check
53  CharacterControllerComponent userController = userCharacter.GetCharacterController();
54  if (!userController || userController.IsUsingItem())
55  return false;
56 
57  // Check if character is in a vehicle and if healing is allowed from seat, if so
58  if (userCharacter.IsInVehicle() && !HealingAllowedFromSeat(userCharacter))
59  return false;
60 
61  // Can only see healing useractions when holding respective consumable
62  SCR_ConsumableItemComponent consumableComponent = GetConsumableComponent(userCharacter);
63  if (!consumableComponent || consumableComponent.GetConsumableType() != m_eConsumableType)
64  return false;
65 
66  // Cannot see healing useractions on dead people
67  SCR_CharacterDamageManagerComponent damageMan = SCR_CharacterDamageManagerComponent.Cast(targetCharacter.GetDamageManager());
68  if (!damageMan || damageMan.GetState() == EDamageState.DESTROYED)
69  return false;
70 
71  if (damageMan.GetGroupIsBeingHealed(m_eHitZoneGroup))
72  return false;
73 
74  return true;
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
79  {
80  // Target character
81  ChimeraCharacter targetCharacter = ChimeraCharacter.Cast(GetOwner());
82  if (!targetCharacter)
83  return;
84 
85  // Medic character
86  ChimeraCharacter userCharacter = ChimeraCharacter.Cast(pUserEntity);
87  if (!userCharacter)
88  return;
89 
90  SCR_CharacterControllerComponent userController = SCR_CharacterControllerComponent.Cast(userCharacter.GetCharacterController());
91  if (!userController)
92  return;
93 
94  IEntity item = userController.GetAttachedGadgetAtLeftHandSlot();
95  if (!item)
96  return;
97 
98  SCR_ConsumableItemComponent consumableComponent = GetConsumableComponent(userCharacter);
99  if (!consumableComponent)
100  return;
101 
102  consumableComponent.SetTargetCharacter(targetCharacter);
103  SCR_ConsumableEffectHealthItems consumableEffect = SCR_ConsumableEffectHealthItems.Cast(consumableComponent.GetConsumableEffect());
104  if (!consumableEffect)
105  return;
106 
107  TAnimGraphCommand desiredCmd;
108  if (pOwnerEntity == pUserEntity)
109  desiredCmd = consumableEffect.GetApplyToSelfAnimCmnd(pOwnerEntity);
110  else
111  desiredCmd = consumableEffect.GetApplyToOtherAnimCmnd(pOwnerEntity);
112 
113  SCR_CharacterControllerComponent targetController = SCR_CharacterControllerComponent.Cast(targetCharacter.GetCharacterController());
114  if (targetController && targetController.IsUnconscious())
115  desiredCmd = consumableEffect.GetReviveAnimCmnd(pOwnerEntity);
116 
117  SCR_CharacterDamageManagerComponent targetDamageMan = SCR_CharacterDamageManagerComponent.Cast(targetCharacter.GetDamageManager());
118  if (!targetDamageMan)
119  return;
120 
122  params.SetEntity(item);
123  params.SetAllowMovementDuringAction(false);
124  params.SetKeepInHandAfterSuccess(true);
125  params.SetCommandID(desiredCmd);
126  params.SetCommandIntArg(1);
127  params.SetCommandFloatArg(0.0);
128  params.SetMaxAnimLength(consumableEffect.GetApplyToOtherDuraction());
129  params.SetIntParam(targetDamageMan.FindAssociatedBandagingBodyPart(m_eHitZoneGroup));
130 
131  consumableEffect.ActivateEffect(pOwnerEntity, pUserEntity, item, params);
132  }
133 
134  //------------------------------------------------------------------------------------------------
135  bool HealingAllowedFromSeat(ChimeraCharacter char)
136  {
137  if (!char)
138  return false;
139 
140  CompartmentAccessComponent compartmentAccess = char.GetCompartmentAccessComponent();
141  if (!compartmentAccess)
142  return false;
143 
144  SCR_DoctorCompartmentSlot doctorSlot = SCR_DoctorCompartmentSlot.Cast(compartmentAccess.GetCompartment());
145  if (!doctorSlot)
146  return false;
147 
148  return doctorSlot.AllowHealingFromCompartment();
149  }
150 
151  //------------------------------------------------------------------------------------------------
152  ECharacterHitZoneGroup GetUserActionGroup()
153  {
154  return m_eHitZoneGroup;
155  }
156 };
ECharacterHitZoneGroup
ECharacterHitZoneGroup
Definition: SCR_CharacterDamageManagerComponent.c:1
SCR_EConsumableType
SCR_EConsumableType
Type of consumable gadget.
Definition: SCR_ConsumableEffectBase.c:2
m_eHitZoneGroup
protected ECharacterHitZoneGroup m_eHitZoneGroup
Definition: SCR_InventoryHitZonePointUI.c:403
SCR_ConsumableEffectHealthItems
Definition: SCR_ConsumableEffectHealthItems.c:2
SCR_HealingUserAction
Definition: SCR_HealingUserAction.c:1
ItemUseParameters
Definition: ItemUseParameters.c:15
ScriptedUserAction
Definition: ScriptedUserAction.c:12
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_CharacterControllerComponent
Definition: SCR_CharacterControllerComponent.c:35
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_DoctorCompartmentSlot
Definition: SCR_DoctorCompartmentSlot.c:1
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
LocalizedString
Definition: LocalizedString.c:21