Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DamagePassRule.c
Go to the documentation of this file.
1[BaseContainerProps(), SCR_DamagePassRuleContainerTitle()]
3{
4 [Attribute(uiwidget: UIWidgets.CheckBox, desc: "Pass to default hit zone of root damage manager")]
5 protected bool m_bPassToRoot;
6
7 [Attribute(uiwidget: UIWidgets.CheckBox, desc: "Pass to default hit zone of parent damage manager")]
8 protected bool m_bPassToParent;
9
10 [Attribute(uiwidget: UIWidgets.CheckBox, desc: "Pass to default hit zone of same damage manager")]
12
13 //------------------------------------------------------------------------------------------------
18 override void HandlePassedDamage(inout notnull BaseDamageContext damageContext, notnull SCR_HitZone srcHitZone, notnull SCR_DamageManagerComponent dmgManager)
19 {
20 // If damage types are defined, only allow passing specified damage types
21 if (!m_aSourceDamageTypes.IsEmpty() && !m_aSourceDamageTypes.Contains(damageContext.damageType))
22 return;
23
24 // If damage states are defined, only allow passing while damage state is allowed
25 if (!m_aDamageStates.IsEmpty() && !m_aDamageStates.Contains(srcHitZone.GetDamageState()))
26 return;
27
28 const BaseDamageContext contextCopy = BaseDamageContext.Cast(damageContext.Clone());
29 contextCopy.damageValue *= m_fMultiplier;
30
31 // Change passed damage type unless it is set to true
33 contextCopy.damageType = m_eOutputDamageType;
34
35 const IEntity owner = srcHitZone.GetOwner();
37 {
38 const SCR_HitZone defaultHitZone = SCR_HitZone.Cast(dmgManager.GetDefaultHitZone());
39 if (defaultHitZone == srcHitZone)
40 {
41#ifdef WORKBENCH
42 Debug.Error("SCR_DamagePassRule.HandlePassedDamage: Entity " + FilePath.StripPath(owner.GetPrefabData().GetPrefabName().GetPath()) + " has " + Type().ToString() + " on a default hit zone (" + srcHitZone.GetName() + "), and it tries to pass the damage to itself, because m_bPassToDefaultHitZone is selected!");
43#endif
44 m_bPassToDefaultHitZone = false; // disable so until someone fixes this in data, we will not waste time on this infinite loop in the future
45 }
46 else
47 {
48 contextCopy.struckHitZone = defaultHitZone;
49 dmgManager.HandleDamage(contextCopy);
50 }
51 }
52
54 {
55 const IEntity parentEnt = owner.GetParent();
56 if (parentEnt)
57 {
58 const SCR_DamageManagerComponent parentDmgManager = SCR_DamageManagerComponent.GetDamageManager(parentEnt);
59 if (parentDmgManager)
60 {
61 contextCopy.struckHitZone = SCR_HitZone.Cast(parentDmgManager.GetDefaultHitZone());
62 if (contextCopy.struckHitZone && contextCopy.struckHitZone != srcHitZone)
63 parentDmgManager.HandleDamage(contextCopy);
64 }
65 }
66 }
67
68 if (m_bPassToRoot)
69 {
70 const IEntity rootEnt = owner.GetRootParent();
71 SCR_DamageManagerComponent rootDmgManager;
72 if (owner == rootEnt)
73 {
75 {
76#ifdef WORKBENCH
77 Debug.Error("SCR_DamagePassRule.HandlePassedDamage: Entity " + FilePath.StripPath(owner.GetPrefabData().GetPrefabName().GetPath()) + " has " + Type().ToString() + " which tries to damage itself twice, as it is the root entity, while both m_bPassToDefaultHitZone and m_bPassToRoot are selected for " + srcHitZone.GetName() + "!");
78#endif
79 return; // dont do that twice
80 }
81
82 rootDmgManager = dmgManager;
83 }
84 else
85 {
86 rootDmgManager = SCR_DamageManagerComponent.GetDamageManager(rootEnt);
87 }
88
89 if (rootDmgManager)
90 {
91 contextCopy.struckHitZone = SCR_HitZone.Cast(rootDmgManager.GetDefaultHitZone());
92 if (contextCopy.struckHitZone && contextCopy.struckHitZone != srcHitZone)
93 rootDmgManager.HandleDamage(contextCopy);
94 }
95 }
96 }
97}
98
99//------------------------------------------------------------------------------------------------
100class SCR_DamagePassRuleContainerTitle : BaseContainerCustomTitle
101{
102 //------------------------------------------------------------------------------------------------
103 override bool _WB_GetCustomTitle(BaseContainer source, out string title)
104 {
105 title = string.Empty;
106
107 int type;
108 if (source.Get("m_eOutputDamageType", type))
109 {
110 if (type == EDamageType.TRUE)
111 title = "Pass as same type";
112 else
113 title = "Pass as " + SCR_Enum.GetEnumName(EDamageType, type);
114 }
115
116 float multiplier;
117 if (source.Get("m_fMultiplier", multiplier))
118 title += " x " + multiplier.ToString(-1, 3);
119
120 bool root;
121 if (source.Get("m_bPassToRoot", root) && root)
122 title += ", root";
123
124 bool parent;
125 if (source.Get("m_bPassToParent", parent) && parent)
126 title += ", parent";
127
128 bool defaultHitZone;
129 if (source.Get("m_bPassToDefaultHitZone", defaultHitZone) && defaultHitZone)
130 title += ", defaultHitZone";
131
132 return true;
133 }
134}
135
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
EDamageType type
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
int Type
Definition Debug.c:13
proto external EntityPrefabData GetPrefabData()
proto external IEntity GetParent()
proto external IEntity GetRootParent()
ref array< EDamageState > m_aDamageStates
ref array< EDamageType > m_aSourceDamageTypes
override void HandlePassedDamage(inout notnull BaseDamageContext damageContext, notnull SCR_HitZone srcHitZone, notnull SCR_DamageManagerComponent dmgManager)
SCR_FieldOfViewSettings Attribute
EDamageType
Definition EDamageType.c:13
class SCR_BaseManualCameraComponent _WB_GetCustomTitle(BaseContainer source, out string title)
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.