Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ConsumableSalineBag.c
Go to the documentation of this file.
2 {
3 }
4 
7 class SCR_ConsumableSalineBag : SCR_ConsumableEffectHealthItems
8 {
9  [Attribute("10", UIWidgets.EditBox, "Regeneration duration of related hitzone when consuming this item in seconds", category: "Consumable")]
10  protected float m_fItemRegenerationDuration;
11 
12  [Attribute("0", UIWidgets.EditBox, "Total amount of regeneration that will be applied to the related hitzone", category: "Consumable")]
13  protected float m_fItemAbsoluteRegenerationAmount;
14 
15  //------------------------------------------------------------------------------------------------
16  override void ApplyEffect(notnull IEntity target, notnull IEntity user, IEntity item, ItemUseParameters animParams)
17  {
18  super.ApplyEffect(target, user, item, animParams);
19 
20  ChimeraCharacter char = ChimeraCharacter.Cast(target);
21  if (!char)
22  return;
23 
25  if (!damageMgr)
26  return;
27 
28  SCR_CharacterBloodHitZone bloodHitZone = SCR_CharacterBloodHitZone.Cast(damageMgr.GetBloodHitZone());
29  if (!bloodHitZone)
30  return;
31 
32  SCR_InventoryStorageManagerComponent inventoryStorageComp = SCR_InventoryStorageManagerComponent.Cast(user.FindComponent(SCR_InventoryStorageManagerComponent));
33  if (!inventoryStorageComp)
34  return;
35 
36  SCR_SalineStorageComponent salineStorageComp = SCR_SalineStorageComponent.Cast(user.FindComponent(SCR_SalineStorageComponent));
37  if (!salineStorageComp)
38  return;
39 
40  if (salineStorageComp.AddSalineBagToSlot(target, ECharacterHitZoneGroup.RIGHTARM, item, m_fItemRegenerationDuration))
41  bloodHitZone.CustomRegeneration(target, m_fItemRegenerationDuration, 0, m_fItemAbsoluteRegenerationAmount);
42  }
43 
44  //------------------------------------------------------------------------------------------------
45  override bool CanApplyEffect(notnull IEntity target, notnull IEntity user,out SCR_EConsumableFailReason failReason = SCR_EConsumableFailReason.NONE)
46  {
47  ChimeraCharacter char = ChimeraCharacter.Cast(target);
48  if (!char)
49  return false;
50 
51  //Can only apply when SCR_CharacterBloodHitZone is damaged
53  if (!damageMgr || damageMgr.GetBloodHitZone().GetDamageState() == EDamageState.UNDAMAGED)
54  {
55  failReason = SCR_EConsumableFailReason.UNDAMAGED;
56  return false;
57  }
58 
59  //Character must have slot for the salinebag to move to
60  SCR_SalineStorageComponent salineStorageMan = SCR_SalineStorageComponent.Cast(target.FindComponent(SCR_SalineStorageComponent));
61  if (!salineStorageMan)
62  return false;
63 
64  array<IEntity> items = {};
65  salineStorageMan.GetAll(items);
66  if (!items.IsEmpty())
67  {
68  failReason = SCR_EConsumableFailReason.ALREADY_APPLIED;
69  return false;
70  }
71 
72  return true;
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  override bool CanApplyEffectToHZ(notnull IEntity target, notnull IEntity user, ECharacterHitZoneGroup group, out SCR_EConsumableFailReason failReason = SCR_EConsumableFailReason.NONE)
77  {
78  return CanApplyEffect(target, user, failReason);
79  }
80 
81  //------------------------------------------------------------------------------------------------
82  // constructor
83  void SCR_ConsumableSalineBag()
84  {
85  m_eConsumableType = SCR_EConsumableType.SALINE;
86  }
87 }
ECharacterHitZoneGroup
ECharacterHitZoneGroup
Definition: SCR_CharacterDamageManagerComponent.c:1
SCR_EConsumableType
SCR_EConsumableType
Type of consumable gadget.
Definition: SCR_ConsumableEffectBase.c:2
SCR_ConsumableEffectHealthItems
Definition: SCR_ConsumableEffectHealthItems.c:2
ItemUseParameters
Definition: ItemUseParameters.c:15
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_CharacterBloodHitZone
Blood - does not receive damage directly, only via scripted events.
Definition: SCR_CharacterHitZone.c:480
LoadoutSalineBagArea
Definition: SCR_ConsumableSalineBag.c:1
m_fItemRegenerationDuration
float m_fItemRegenerationDuration
Definition: SCR_SalineStorageComponent.c:9
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
GetDamageManager
proto external SCR_DamageManagerComponent GetDamageManager()
Returns component which handles damage.
SCR_SalineStorageComponent
Definition: SCR_SalineStorageComponent.c:29
LoadoutAreaType
Definition: LoadoutAreaType.c:12
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180