Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
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) )]
5
6 [Attribute("0", UIWidgets.ComboBox, "Which consumabletype will be checked for conditions", enums:ParamEnumArray.FromEnum(SCR_EConsumableType) )]
8
9 [Attribute("#AR-FailReason_AlreadyApplied", UIWidgets.EditBox, "String for already applied healing gadgets")]
11
12 [Attribute("#AR-FailReason_NotBleeding", UIWidgets.EditBox, "String for when target hitzone isn't bleeding")]
14
15 [Attribute("#AR-FailReason_NoBloodLoss", UIWidgets.EditBox, "String for when blood hitzone isn't damaged")]
17
18 [Attribute("#AR-FailReason_NotDamaged", UIWidgets.EditBox, "String for when target hitzone isn't damaged")]
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
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 //------------------------------------------------------------------------------------------------
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 //------------------------------------------------------------------------------------------------
156};
int TAnimGraphCommand
Definition ECommandIDs.c:1
SCR_EConsumableType
Type of consumable gadget.
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external Managed FindComponent(typename typeName)
bool GetGroupIsBeingHealed(ECharacterHitZoneGroup hitZoneGroup)
EBandagingAnimationBodyParts FindAssociatedBandagingBodyPart(ECharacterHitZoneGroup hitZoneGroup)
override bool ActivateEffect(IEntity target, IEntity user, IEntity item, ItemUseParameters animParams=null)
TAnimGraphCommand GetReviveAnimCmnd(IEntity user)
ECharacterHitZoneGroup GetUserActionGroup()
override bool CanBeShownScript(IEntity user)
ECharacterHitZoneGroup m_eHitZoneGroup
LocalizedString m_sAlreadyApplied
SCR_EConsumableType m_eConsumableType
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
SCR_ConsumableItemComponent GetConsumableComponent(notnull ChimeraCharacter userChar)
bool HealingAllowedFromSeat(ChimeraCharacter char)
SCR_FieldOfViewSettings Attribute
EDamageState