Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BloodEditorAttribute.c
Go to the documentation of this file.
1 
6 {
7  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
8  {
10  if (!editableEntity)
11  return null;
12 
13  IEntity owner = editableEntity.GetOwner();
14  if (!owner)
15  return null;
16 
18  if (!characterDamageManager)
19  return null;
20 
21  if (characterDamageManager.GetState() == EDamageState.DESTROYED)
22  return null;
23 
24  HitZone bloodHitzone = characterDamageManager.GetBloodHitZone();
25  if (!bloodHitzone)
26  return null;
27 
28  //~Todo: Once an unconscious character can be revived, just use raw GetHealthScaled
29  float bloodLevelLoseDeath = bloodHitzone.GetDamageStateThreshold(ECharacterBloodState.DESTROYED);
30  float bloodLevelContiousness = bloodHitzone.GetDamageStateThreshold(ECharacterBloodState.UNCONSCIOUS);
31  float bloodLevel = Math.InverseLerp(bloodLevelLoseDeath, 1, bloodHitzone.GetHealthScaled());
32 
33  //~Safty Clamp
34  bloodLevel = Math.Clamp(bloodLevel, 0, 1);
35 
36  //~ Sends over current blood level, % needed to fall Unconscious and if Unconsciousness is premitted
37  return SCR_BaseEditorAttributeVar.CreateVector(Vector(Math.Round(bloodLevel * 100), bloodLevelContiousness, characterDamageManager.GetPermitUnconsciousness()));
38  }
39  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
40  {
41  if (!var)
42  return;
43  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
44 
45  IEntity owner = editableEntity.GetOwner();
46  if (!owner)
47  return;
48 
50  if (!characterDamageManager)
51  return;
52 
53  if (characterDamageManager.GetState() == EDamageState.DESTROYED)
54  return;
55 
56  HitZone bloodHitzone = characterDamageManager.GetBloodHitZone();
57  if (!bloodHitzone)
58  return;
59 
60  if (!characterDamageManager.IsDamageHandlingEnabled())
61  return;
62 
63  //~Todo: Once an unconscious character can be revived, just use raw SetHealthScaled
64  float bloodLevelLoseDeath = bloodHitzone.GetDamageStateThreshold(ECharacterBloodState.DESTROYED);
65  float bloodLevel = Math.Lerp(bloodLevelLoseDeath, 1, var.GetFloat() * 0.01);
66  bloodLevel = Math.Clamp(bloodLevel, 0, 1);
67  bloodHitzone.SetHealthScaled(bloodLevel);
68  }
69 };
HitZone
Definition: HitZone.c:12
EDamageState
EDamageState
Definition: EDamageState.c:12
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_BaseValueListEditorAttribute
Definition: SCR_BaseValueListEditorAttribute.c:5
SCR_CharacterDamageManagerComponent
Definition: SCR_CharacterDamageManagerComponent.c:18
SCR_BloodEditorAttribute
Definition: SCR_BloodEditorAttribute.c:5
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
ECharacterBloodState
ECharacterBloodState
Definition: SCR_CharacterHitZone.c:13
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