9 protected const string DAMAGE_TYPE_NAMES[10] = {
"TRUE",
"COLLISION",
"MELEE",
"KINETIC",
"FRAGMENTATION",
"EXPLOSIVE",
"INCENDIARY",
"FIRE",
"REGENERATION",
"BLEEDING" };
10 protected ref array<IEntity> m_aToDamage = {};
13 override void EOnDiag(IEntity owner,
float timeSlice)
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);
85 hitzone = destructionComponent.GetDefaultHitZone();
90 for (
int i = 0; i < 10; i++)
92 DbgUI.Text(DAMAGE_TYPE_NAMES[i] +
": " + hitzone.GetDamageMultiplier(i));
103 if (destructibleEntity)
104 return destructibleEntity.GetDamageReduction();
106 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(
params.TraceEnt.FindComponent(SCR_DestructionDamageManagerComponent));
107 if (destructionComponent)
109 HitZone hitZone = destructionComponent.GetHitZone(
params.ColliderName);
111 hitZone = destructionComponent.GetDefaultHitZone();
116 return hitZone.GetDamageReduction();
128 if (destructibleEntity)
129 return destructibleEntity.GetDamageThreshold();
131 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(
params.TraceEnt.FindComponent(SCR_DestructionDamageManagerComponent));
132 if (destructionComponent)
134 HitZone hitZone = destructionComponent.GetHitZone(
params.ColliderName);
136 hitZone = destructionComponent.GetDefaultHitZone();
141 return hitZone.GetDamageThreshold();
149 void GetCameraMat(out vector mat[4])
151 CameraManager cameraManager =
GetGame().GetCameraManager();
155 CameraBase currentCamera = cameraManager.CurrentCamera();
159 currentCamera.GetTransform(mat);
168 GetCameraMat(cameraMat);
170 params.Start = cameraMat[3];
172 params.LayerMask = EPhysicsLayerDefs.Projectile;
173 params.Exclude =
GetGame().GetPlayerController().GetControlledEntity();
174 params.Flags = TraceFlags.ENTS;
184 void DealDamageUnderCursor(
float damageToDeal,
EDamageType damageType, notnull TraceParam
params)
189 DealDamage(
params.TraceEnt, damageToDeal, damageType,
params.SurfaceProps);
198 if (destructibleEntity)
199 return destructibleEntity.GetCurrentHealth();
201 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(entity.FindComponent(SCR_DestructionDamageManagerComponent));
202 if (destructionComponent)
203 return destructionComponent.GetHealth();
210 void SetOneHitPoint(
float range)
213 GetCameraMat(cameraMat);
217 for (
int i = m_aToDamage.Count() - 1; i >= 0; i--)
231 void DealDamage(IEntity entity,
float damageToDeal,
EDamageType damageType, SurfaceProperties surfaceProperties)
233 vector hitPosDirNorm[3];
236 if (destructibleEntity)
237 destructibleEntity.HandleDamage(damageType, damageToDeal, hitPosDirNorm);
239 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(entity.FindComponent(SCR_DestructionDamageManagerComponent));
240 if (destructionComponent)
244 destructionComponent.HandleDamage(damageContext);
253 void DealDamageRange(
float damageToDeal,
float range,
EDamageType damageType)
256 GetCameraMat(cameraMat);
260 foreach (IEntity toDamage : m_aToDamage)
262 DealDamage(toDamage, damageToDeal, damageType,
null);
272 bool AddEntity(IEntity e)
274 m_aToDamage.Insert(e);
294 super.OnPostInit(owner);
296 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_DESTRUCTION_ENABLE_DIAG,
"",
"Enable destruction diag",
"Destruction");
298 ConnectToDiagSystem(owner);
302 override void OnDelete(IEntity owner)
304 DisconnectFromDiagSystem(owner);
306 super.OnDelete(owner);