Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_HealthEditorAttribute.c
Go to the documentation of this file.
1
6{
7 //------------------------------------------------------------------------------------------------
8 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
9 {
10 //~ With the new health system health can no longer be set with just a slider.
11 //~ Todo: Create health system for individual parts that can be damaged
12 return null;
13
15 if (!editableEntity)
16 return null;
17
18 if (!IsValidEntityType(editableEntity.GetEntityType()))
19 return null;
20
21 IEntity owner = editableEntity.GetOwner();
22 if (!owner)
23 return null;
24
26 if (!damageComponent)
27 return null;
28
29 if (damageComponent.GetState() == EDamageState.DESTROYED)
30 return null;
31
32 return SCR_BaseEditorAttributeVar.CreateFloat(Math.Round(damageComponent.GetHealthScaled() * 100));
33 }
34
35 //------------------------------------------------------------------------------------------------
36 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
37 {
38 if (!var)
39 return;
41
42 IEntity owner = editableEntity.GetOwner();
43 if (!owner)
44 return;
45
46 SCR_DamageManagerComponent damageComponent = SCR_DamageManagerComponent.Cast(owner.FindComponent(SCR_DamageManagerComponent));
47 if (!damageComponent)
48 return;
49
50 if (!damageComponent.IsDamageHandlingEnabled())
51 return;
52
53 float health = var.GetFloat() * 0.01;
54 if (health == 0)
55 {
56 Instigator killer = Instigator.CreateInstigatorGM(playerID);
57 damageComponent.Kill(killer);
58 return;
59 }
60
61 HitZone defaultHitzone = damageComponent.GetDefaultHitZone();
62 defaultHitzone.SetHealthScaled(health);
63 }
64}
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
proto external Managed FindComponent(typename typeName)
Definition Math.c:13
static SCR_BaseEditorAttributeVar CreateFloat(float value)
EEditableEntityType GetEntityType(IEntity owner=null)
EDamageState