9 protected static const string DAMAGE_TYPE_NAMES[10] = {
"TRUE",
"COLLISION",
"MELEE",
"KINETIC",
"FRAGMENTATION",
"EXPLOSIVE",
"INCENDIARY",
"FIRE",
"REGENERATION",
"BLEEDING" };
10 protected ref array<IEntity> m_aToDamage = {};
17 TraceParam
params =
new TraceParam();
20 DbgUI.Begin(
"Destruction");
22 float damageToDeal = 1000, range = 20;
24 DbgUI.InputFloat(
"Damage to deal", damageToDeal);
26 DbgUI.InputFloat(
"Range", range);
28 DbgUI.InputInt(
"Damage type", damageType);
32 DbgUI.Text(
"Damage types:");
33 DbgUI.Text(
"0 = TRUE");
34 DbgUI.Text(
"1 = COLLISION");
35 DbgUI.Text(
"2 = MELEE");
36 DbgUI.Text(
"3 = KINETIC");
37 DbgUI.Text(
"4 = FRAGMENTATION");
38 DbgUI.Text(
"5 = EXPLOSIVE");
39 DbgUI.Text(
"6 = INCENDIARY");
40 DbgUI.Text(
"7 = FIRE");
41 DbgUI.Text(
"8 = REGENERATION");
42 DbgUI.Text(
"9 = BLEEDING");
50 ShowDamageTypeMultipliers(
params);
53 if (DbgUI.Button(
"Deal damage in range"))
54 DealDamageRange(damageToDeal, range, damageType);
56 if (DbgUI.Button(
"Deal damage under cursor"))
57 DealDamageUnderCursor(damageToDeal, damageType,
params);
59 if (DbgUI.Button(
"Set 1 HP in range"))
60 SetOneHitPoint(range);
68 void ShowDamageTypeMultipliers(TraceParam
params)
71 if (destructibleEntity)
73 for (
int i = 0; i < 10; i++)
75 DbgUI.Text(DAMAGE_TYPE_NAMES[i] +
": " + destructibleEntity.GetDamageMultiplier(i));
79 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(
params.TraceEnt.FindComponent(SCR_DestructionDamageManagerComponent));
80 if (destructionComponent)
82 HitZone hitzone = destructionComponent.GetHitZone(
params.ColliderName);
84 hitzone = destructionComponent.GetDefaultHitZone();
86 for (
int i = 0; i < 10; i++)
88 DbgUI.Text(DAMAGE_TYPE_NAMES[i] +
": " + hitzone.GetDamageMultiplier(i));
99 if (destructibleEntity)
100 return destructibleEntity.GetDamageReduction();
102 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(
params.TraceEnt.FindComponent(SCR_DestructionDamageManagerComponent));
103 if (destructionComponent)
105 HitZone hitZone = destructionComponent.GetHitZone(
params.ColliderName);
107 hitZone = destructionComponent.GetDefaultHitZone();
109 return hitZone.GetDamageReduction();
121 if (destructibleEntity)
122 return destructibleEntity.GetDamageThreshold();
124 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(
params.TraceEnt.FindComponent(SCR_DestructionDamageManagerComponent));
125 if (destructionComponent)
127 HitZone hitZone = destructionComponent.GetHitZone(
params.ColliderName);
129 hitZone = destructionComponent.GetDefaultHitZone();
131 return hitZone.GetDamageThreshold();
139 void GetCameraMat(out vector mat[4])
141 CameraManager cameraManager =
GetGame().GetCameraManager();
145 CameraBase currentCamera = cameraManager.CurrentCamera();
149 currentCamera.GetTransform(mat);
158 GetCameraMat(cameraMat);
160 params.Start = cameraMat[3];
162 params.LayerMask = EPhysicsLayerDefs.Projectile;
163 params.Exclude =
GetGame().GetPlayerController().GetControlledEntity();
174 void DealDamageUnderCursor(
float damageToDeal,
EDamageType damageType, notnull TraceParam
params)
179 DealDamage(
params.TraceEnt, damageToDeal, damageType,
params.SurfaceProps);
188 if (destructibleEntity)
189 return destructibleEntity.GetCurrentHealth();
191 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(entity.
FindComponent(SCR_DestructionDamageManagerComponent));
192 if (destructionComponent)
193 return destructionComponent.GetHealth();
200 void SetOneHitPoint(
float range)
203 GetCameraMat(cameraMat);
207 for (
int i = m_aToDamage.Count() - 1; i >= 0; i--)
221 void DealDamage(
IEntity entity,
float damageToDeal,
EDamageType damageType, SurfaceProperties surfaceProperties)
223 vector hitPosDirNorm[3];
226 if (destructibleEntity)
227 destructibleEntity.HandleDamage(damageType, damageToDeal, hitPosDirNorm);
229 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(entity.
FindComponent(SCR_DestructionDamageManagerComponent));
230 if (destructionComponent)
232 SCR_DamageContext damageContext =
new SCR_DamageContext(damageType, damageToDeal, hitPosDirNorm, entity, null, null, surfaceProperties, -1, -1);
234 destructionComponent.HandleDamage(damageContext);
243 void DealDamageRange(
float damageToDeal,
float range,
EDamageType damageType)
246 GetCameraMat(cameraMat);
250 foreach (
IEntity toDamage : m_aToDamage)
252 DealDamage(toDamage, damageToDeal, damageType, null);
264 m_aToDamage.Insert(e);
284 super.OnPostInit(owner);
286 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_DESTRUCTION_ENABLE_DIAG,
"",
"Enable destruction diag",
"Destruction");
296 super.OnDelete(owner);
ArmaReforgerScripted GetGame()
bool FilterEntity(IEntity ent)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
SCR_EditableEntityComponent TraceEntity(vector cursorPos)
float GetDamageThreshold()
float GetDamageReduction()
void SCR_DestructibleEntity(IEntitySource src, IEntity parent)
enum EVehicleType IEntity
void DisconnectFromDiagSystem(IEntity owner)
void ConnectToDiagSystem(IEntity owner)
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
void EOnDiag(IEntity owner, float timeSlice)
proto external GenericEntity GetOwner()
Get owner entity.