Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_TourniquetUserAction.c
Go to the documentation of this file.
2 {
3 
4  //------------------------------------------------------------------------------------------------
7  override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity)
8  {
9  ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
10  if (!character)
11  return;
12 
13  CharacterControllerComponent controller = character.GetCharacterController();
14  if (!controller)
15  return;
16 
17  if (controller.GetLifeState() != ECharacterLifeState.ALIVE)
18  return;
19 
20  SCR_ConsumableItemComponent consumableComponent = GetConsumableComponent(character);
21  if (consumableComponent)
22  consumableComponent.SetAlternativeModel(false);
23  }
24 
25  //------------------------------------------------------------------------------------------------
26  override bool CanBeShownScript(IEntity user)
27  {
28  if (IsTourniquetted())
29  return true;
30 
31  if (!super.CanBeShownScript(user))
32  return false;
33 
34  // It is not allowed to perform healing useraction on self
35  if (!user || user == GetOwner())
36  return false;
37 
38  // Target character
39  ChimeraCharacter targetCharacter = ChimeraCharacter.Cast(GetOwner());
40  if (!targetCharacter)
41  return false;
42 
43  SCR_CharacterDamageManagerComponent charDamMan = SCR_CharacterDamageManagerComponent.Cast(targetCharacter.GetDamageManager());
44  if (!charDamMan || charDamMan.GetGroupDamageOverTime(m_eHitZoneGroup, EDamageType.BLEEDING) == 0)
45  {
46  SetCannotPerformReason(m_sNotBleeding);
47  return false;
48  }
49 
50  return true;
51  }
52 
53  //------------------------------------------------------------------------------------------------
54  protected bool IsTourniquetted()
55  {
56  // Target character
57  ChimeraCharacter targetCharacter = ChimeraCharacter.Cast(GetOwner());
58  if (!targetCharacter)
59  return false;
60 
61  SCR_CharacterDamageManagerComponent damageMan = SCR_CharacterDamageManagerComponent.Cast(targetCharacter.GetDamageManager());
62  if (!damageMan)
63  return false;
64 
65  return damageMan.GetGroupTourniquetted(m_eHitZoneGroup);
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  override bool CanBePerformedScript(IEntity user)
70  {
71  if (IsTourniquetted())
72  return true;
73 
74  // Target character
75  ChimeraCharacter targetCharacter = ChimeraCharacter.Cast(GetOwner());
76  if (!targetCharacter)
77  return false;
78 
79  // Medic character
80  ChimeraCharacter userCharacter = ChimeraCharacter.Cast(user);
81  if (!userCharacter)
82  return false;
83 
84  SCR_ConsumableItemComponent consumableComponent = GetConsumableComponent(userCharacter);
85  if (!consumableComponent)
86  return false;
87 
88  SCR_ConsumableTourniquet consumableTQ = SCR_ConsumableTourniquet.Cast(consumableComponent.GetConsumableEffect());
89  if (!consumableTQ)
90  return false;
91 
92  int reason;
93  if (consumableTQ.CanApplyEffectToHZ(targetCharacter, userCharacter, m_eHitZoneGroup, reason))
94  return true;
95 
96  if (reason == SCR_EConsumableFailReason.ALREADY_APPLIED)
97  SetCannotPerformReason(m_sAlreadyApplied);
98  else if (reason == SCR_EConsumableFailReason.NOT_BLEEDING)
99  SetCannotPerformReason(m_sNotBleeding);
100 
101  return false;
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
106  {
107  if (!IsTourniquetted())
108  {
109  super.PerformAction(pOwnerEntity, pUserEntity);
110  return;
111  }
112 
113  SCR_TourniquetStorageComponent tourniquetStorage = SCR_TourniquetStorageComponent.Cast(pOwnerEntity.FindComponent(SCR_TourniquetStorageComponent));
114  if (!tourniquetStorage)
115  return;
116 
117  if (tourniquetStorage.RemoveTourniquetFromSlot(m_eHitZoneGroup, pUserEntity))
118  SCR_UISoundEntity.SoundEvent(SCR_SoundEvent.SOUND_INV_OPEN);
119  }
120 
121  //------------------------------------------------------------------------------------------------
122  override bool GetActionNameScript(out string outName)
123  {
124  if (IsTourniquetted())
125  {
126  outName = ("#AR-RemoveTourniquetAction");
127  return true;
128  }
129 
130  return false;
131  }
132 
133  //------------------------------------------------------------------------------------------------
134  override bool HealingAllowedFromSeat(ChimeraCharacter char)
135  {
136  return false;
137  }
138 };
m_eHitZoneGroup
protected ECharacterHitZoneGroup m_eHitZoneGroup
Definition: SCR_InventoryHitZonePointUI.c:403
ECharacterLifeState
ECharacterLifeState
Definition: ECharacterLifeState.c:12
SCR_TourniquetUserAction
Definition: SCR_TourniquetUserAction.c:1
SCR_UISoundEntity
Definition: SCR_UISoundEntity.c:7
SCR_TourniquetStorageComponent
Definition: SCR_TourniquetStorageComponent.c:48
SCR_HealingUserAction
Definition: SCR_HealingUserAction.c:1
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_ConsumableTourniquet
Tourniquet effect.
Definition: SCR_ConsumableTourniquet.c:3
EDamageType
EDamageType
Definition: EDamageType.c:12