Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ConsumableTourniquet.c
Go to the documentation of this file.
4 {
5  //Cached to remember which bodypart to remove tourniquet from
6  protected ECharacterHitZoneGroup m_eTargetHZGroup;
7 
8  //------------------------------------------------------------------------------------------------
9  override void ApplyEffect(notnull IEntity target, notnull IEntity user, IEntity item, ItemUseParameters animParams)
10  {
11  super.ApplyEffect(target, user, item, animParams);
12 
13  ChimeraCharacter char = ChimeraCharacter.Cast(target);
14  if (!char)
15  return;
16 
18  if (!damageMgr)
19  return;
20 
21  m_eTargetHZGroup = damageMgr.FindAssociatedHitZoneGroup(animParams.GetIntParam());
22 
24  if (!tqStorageComp)
25  {
26  Print("SCR_TourniquetStorageComponent missing", LogLevel.ERROR);
27  return;
28  }
29 
30  tqStorageComp.AddTourniquetToSlot(target, m_eTargetHZGroup, item);
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  override bool CanApplyEffect(notnull IEntity target, notnull IEntity user, out SCR_EConsumableFailReason failReason = SCR_EConsumableFailReason.NONE)
35  {
36  ChimeraCharacter char = ChimeraCharacter.Cast(target);
37  if (!char)
38  return false;
39 
41  if (!damageMgr || !damageMgr.IsDamagedOverTime(EDamageType.BLEEDING))
42  return false;
43 
44  return damageMgr.GetCharMostDOTHitzoneGroup(EDamageType.BLEEDING, true, true);
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  override bool CanApplyEffectToHZ(notnull IEntity target, notnull IEntity user, ECharacterHitZoneGroup group, out SCR_EConsumableFailReason failReason = SCR_EConsumableFailReason.NONE)
49  {
50  ChimeraCharacter char = ChimeraCharacter.Cast(target);
51  if (!char)
52  return false;
53 
55  if (!damageMgr)
56  return false;
57 
58  array<ECharacterHitZoneGroup> limbs = {};
59  damageMgr.GetAllExtremities(limbs);
60 
61  if (!limbs.Contains(group))
62  return false;
63 
64  if (damageMgr.GetGroupTourniquetted(group))
65  {
66  failReason = SCR_EConsumableFailReason.ALREADY_APPLIED;
67  return false;
68  }
69 
70  if (damageMgr.GetGroupDamageOverTime(group, EDamageType.BLEEDING) > 0)
71  return true;
72 
73  failReason = SCR_EConsumableFailReason.NOT_BLEEDING;
74  return false;
75  }
76 
77  //------------------------------------------------------------------------------------------------
78  override ItemUseParameters GetAnimationParameters(IEntity item, notnull IEntity target, ECharacterHitZoneGroup group = ECharacterHitZoneGroup.VIRTUAL)
79  {
80  ChimeraCharacter char = ChimeraCharacter.Cast(target);
81  if (!char)
82  return null;
83 
85  if (!damageMgr)
86  return null;
87 
89 
90  if (group != ECharacterHitZoneGroup.VIRTUAL)
91  {
92  if (!damageMgr.GetGroupIsBeingHealed(group))
93  bodyPartToBandage = damageMgr.FindAssociatedBandagingBodyPart(group);
94  }
95  else
96  {
97  group = damageMgr.GetCharMostDOTHitzoneGroup(EDamageType.BLEEDING, true, true, true);
98  if (!group)
99  return null;
100 
101  array<HitZone> groupHitZones = {};
102  damageMgr.GetHitZonesOfGroup(group, groupHitZones);
103 
104  SCR_CharacterHitZone charHitZone = SCR_CharacterHitZone.Cast(groupHitZones[0]);
105  if (!charHitZone)
106  return null;
107 
108  bodyPartToBandage = charHitZone.GetBodyPartToHeal();
109  }
110 
111  if (bodyPartToBandage == EBandagingAnimationBodyParts.Invalid)
112  return null;
113 
115  params.SetEntity(item);
116  params.SetAllowMovementDuringAction(false);
117  params.SetKeepInHandAfterSuccess(false);
118  params.SetCommandID(GetApplyToSelfAnimCmnd(target));
119  params.SetCommandIntArg(1);
120  params.SetCommandFloatArg(0.0);
121  params.SetMaxAnimLength(m_fApplyToSelfDuration);
122  params.SetIntParam(bodyPartToBandage);
123 
124  return params;
125  }
126 
127  //------------------------------------------------------------------------------------------------
129  ECharacterHitZoneGroup GetTargetHitZoneGroup()
130  {
131  return m_eTargetHZGroup;
132  }
133 
134  //------------------------------------------------------------------------------------------------
135  // constructor
137  {
138  m_eConsumableType = SCR_EConsumableType.TOURNIQUET;
139  }
140 }
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
SCR_CharacterHitZone
Definition: SCR_CharacterHitZone.c:55
SCR_TourniquetStorageComponent
Definition: SCR_TourniquetStorageComponent.c:48
ItemUseParameters
Definition: ItemUseParameters.c:15
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
GetDamageManager
proto external SCR_DamageManagerComponent GetDamageManager()
Returns component which handles damage.
SCR_ConsumableTourniquet
Tourniquet effect.
Definition: SCR_ConsumableTourniquet.c:3
EDamageType
EDamageType
Definition: EDamageType.c:12
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
EBandagingAnimationBodyParts
EBandagingAnimationBodyParts
Definition: SCR_CharacterHitZone.c:27
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