DayZ 1.24
Loading...
Searching...
No Matches
DamageSystem.c
Go to the documentation of this file.
3 proto native float GetDamage(string zoneName, string healthType);
5};
6
7//-----------------------------------------------------------------------------
8
11{
12 CLOSE_COMBAT, // 0
13 FIRE_ARM, // 1
15 STUN,
16 CUSTOM
17}
18
19//-----------------------------------------------------------------------------
20class DamageSystem
21{
24
26
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 }
64
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 }
93
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 }
114
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 }
122
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 }
139}
140
141typedef map<string, ref array<string>> DamageZoneMap; //<zone_name,<components>>
map< string, ref array< string > > DamageZoneMap
static string GetDamageDisplayName(EntityAI entity, string zone)
FIRE_ARM
Definition DamageSystem.c:1
static proto native void CloseCombatDamageName(EntityAI source, Object targetObject, string targetComponentName, string ammoTypeName, vector worldPos, int directDamageFlags=ProcessDirectDamageFlags.ALL_TRANSFER)
EXPLOSION
Definition DamageSystem.c:2
static bool GetDamageZoneMap(EntityAI entity, out DamageZoneMap zoneMap)
enum DamageType CloseCombatDamage(EntityAI source, Object targetObject, int targetComponentIndex, string ammoTypeName, vector worldPos, int directDamageFlags=ProcessDirectDamageFlags.ALL_TRANSFER)
static bool GetComponentNamesFromDamageZone(notnull EntityAI entity, string damageZone, out array< string > componentNames)
static proto native void ExplosionDamage(EntityAI source, Object directHitObject, string ammoTypeName, vector worldPos, int damageType)
static bool GetDamageZoneFromComponentName(notnull EntityAI entity, string component, out string damageZone)
Returns damage zone to which the named component belongs.
static void ResetAllZones(EntityAI entity)
CLOSE_COMBAT
Definition DamageSystem.c:0
CUSTOM
Definition DamageSystem.c:5
STUN
Definition DamageSystem.c:3
DamageType
exposed from C++ (do not change)
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
ProcessDirectDamageFlags
Definition Object.c:2
TODO doc.
Definition EnScript.c:118
proto native float GetDamage(string zoneName, string healthType)
proto native float GetHighestDamage(string healthType)
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.