DayZ 1.24
Loading...
Searching...
No Matches
DamageSystem.c File Reference

Go to the source code of this file.

Classes

class  TotalDamageResult
 

Typedefs

typedef map< string, ref array< string > > DamageZoneMap
 

Enumerations

enum  DamageType
 exposed from C++ (do not change) More...
 

Functions

enum DamageType CloseCombatDamage (EntityAI source, Object targetObject, int targetComponentIndex, string ammoTypeName, vector worldPos, int directDamageFlags=ProcessDirectDamageFlags.ALL_TRANSFER)
 
static proto native void CloseCombatDamageName (EntityAI source, Object targetObject, string targetComponentName, string ammoTypeName, vector worldPos, int directDamageFlags=ProcessDirectDamageFlags.ALL_TRANSFER)
 
static proto native void ExplosionDamage (EntityAI source, Object directHitObject, string ammoTypeName, vector worldPos, int damageType)
 
static bool GetDamageZoneMap (EntityAI entity, out DamageZoneMap zoneMap)
 
static bool GetDamageZoneFromComponentName (notnull EntityAI entity, string component, out string damageZone)
 Returns damage zone to which the named component belongs.
 
static bool GetComponentNamesFromDamageZone (notnull EntityAI entity, string damageZone, out array< string > componentNames)
 
static string GetDamageDisplayName (EntityAI entity, string zone)
 
static void ResetAllZones (EntityAI entity)
 

Variables

 CLOSE_COMBAT
 
 FIRE_ARM
 
 EXPLOSION
 
 STUN
 
 CUSTOM
 

Typedef Documentation

◆ DamageZoneMap

Definition at line 141 of file DamageSystem.c.

Enumeration Type Documentation

◆ DamageType

exposed from C++ (do not change)

Definition at line 10 of file DamageSystem.c.

11{
12 CLOSE_COMBAT, // 0
13 FIRE_ARM, // 1
15 STUN,
16 CUSTOM
17}
FIRE_ARM
Definition DamageSystem.c:1
EXPLOSION
Definition DamageSystem.c:2
CLOSE_COMBAT
Definition DamageSystem.c:0
CUSTOM
Definition DamageSystem.c:5
STUN
Definition DamageSystem.c:3

Function Documentation

◆ CloseCombatDamage()

enum DamageType CloseCombatDamage ( EntityAI source,
Object targetObject,
int targetComponentIndex,
string ammoTypeName,
vector worldPos,
int directDamageFlags = ProcessDirectDamageFlags.ALL_TRANSFER )

◆ CloseCombatDamageName()

static proto native void CloseCombatDamageName ( EntityAI source,
Object targetObject,
string targetComponentName,
string ammoTypeName,
vector worldPos,
int directDamageFlags = ProcessDirectDamageFlags.ALL_TRANSFER )
static

◆ ExplosionDamage()

static proto native void ExplosionDamage ( EntityAI source,
Object directHitObject,
string ammoTypeName,
vector worldPos,
int damageType )
static

◆ GetComponentNamesFromDamageZone()

static bool GetComponentNamesFromDamageZone ( notnull EntityAI entity,
string damageZone,
out array< string > componentNames )
static

Definition at line 94 of file DamageSystem.c.

95 {
96 string path;
97
98 if (entity.IsWeapon())
100 else if (entity.IsMagazine())
102 else
104
105 path = string.Format("%1 %2 DamageSystem DamageZones %3 componentNames", path, entity.GetType(), damageZone);
106 if (GetGame().ConfigIsExisting(path))
107 {
108 GetGame().ConfigGetTextArray(path, componentNames);
109 return true;
110 }
111
112 return false;
113 }
proto native CGame GetGame()
const string CFG_VEHICLESPATH
Definition constants.c:209
const string CFG_WEAPONSPATH
Definition constants.c:210
const string CFG_MAGAZINESPATH
Definition constants.c:211
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.

References CFG_MAGAZINESPATH, CFG_VEHICLESPATH, CFG_WEAPONSPATH, string::Format(), GetGame(), and path.

◆ GetDamageDisplayName()

static string GetDamageDisplayName ( EntityAI entity,
string zone )
static

Definition at line 115 of file DamageSystem.c.

116 {
117 string component_name;
118 entity.GetEntityDamageDisplayNameMap().Find(zone.Hash(), component_name);
119 component_name = Widget.TranslateString(component_name);
120 return component_name;
121 }

◆ GetDamageZoneFromComponentName()

static bool GetDamageZoneFromComponentName ( notnull EntityAI entity,
string component,
out string damageZone )
static

Returns damage zone to which the named component belongs.

Definition at line 66 of file DamageSystem.c.

67 {
68 DamageZoneMap zoneMap = entity.GetEntityDamageZoneMap();
70 components = zoneMap.GetValueArray();
71 for (int i = 0; i < components.Count(); i++)
72 {
74 for (int j = 0; j < inner.Count(); j++)
75 {
76 string innerComponentName = inner.Get(j);
77 innerComponentName.ToLower();
78
79 //We don't have a component name, no need to proceed
80 if (innerComponentName == "")
81 break;
82
84 {
85 damageZone = zoneMap.GetKey(i);
86 return true;
87 }
88 }
89 }
90 damageZone = "";
91 return false;
92 }
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.

References component.

◆ GetDamageZoneMap()

static bool GetDamageZoneMap ( EntityAI entity,
out DamageZoneMap zoneMap )
static

Definition at line 27 of file DamageSystem.c.

28 {
29 string path_base;
30 string path;
31
32 if (entity.IsWeapon())
34 else if (entity.IsMagazine())
36 else
38
39 path_base = string.Format("%1 %2 DamageSystem DamageZones", path_base, entity.GetType());
40
41 if (!GetGame().ConfigIsExisting(path_base))
42 return false;
43 else
44 {
45 string zone;
48
49 entity.GetDamageZones(zone_names);
50 for (int i = 0; i < zone_names.Count(); i++)
51 {
53 zone = zone_names.Get(i);
54
55 path = string.Format("%1 %2 componentNames ", path_base, zone);
56 if (GetGame().ConfigIsExisting(path))
57 GetGame().ConfigGetTextArray(path, component_names);
59 }
60
61 return true;
62 }
63 }

References CFG_MAGAZINESPATH, CFG_VEHICLESPATH, CFG_WEAPONSPATH, string::Format(), GetGame(), and path.

◆ ResetAllZones()

static void ResetAllZones ( EntityAI entity)
static

Definition at line 123 of file DamageSystem.c.

124 {
126 DamageSystem.GetDamageZoneMap(entity, zonesMap);
127 array<string> zones = zonesMap.GetKeyArray();
128 entity.SetHealth("", "Health", entity.GetMaxHealth("", "Health"));
129 entity.SetHealth("", "Shock", entity.GetMaxHealth("", "Shock"));
130 entity.SetHealth("", "Blood", entity.GetMaxHealth("", "Blood"));
131
132 foreach (string zone : zones)
133 {
134 entity.SetHealth(zone, "Health", entity.GetMaxHealth(zone, "Health"));
135 entity.SetHealth(zone, "Shock", entity.GetMaxHealth(zone, "Shock"));
136 entity.SetHealth(zone, "Blood", entity.GetMaxHealth(zone, "Blood"));
137 }
138 }
map< string, ref array< string > > DamageZoneMap

Variable Documentation

◆ CLOSE_COMBAT

CLOSE_COMBAT

Definition at line 0 of file DamageSystem.c.

◆ CUSTOM

CUSTOM

Definition at line 4 of file DamageSystem.c.

◆ EXPLOSION

EXPLOSION

Definition at line 2 of file DamageSystem.c.

◆ FIRE_ARM

FIRE_ARM

Definition at line 1 of file DamageSystem.c.

◆ STUN

STUN

Definition at line 3 of file DamageSystem.c.