DayZ 1.24
Loading...
Searching...
No Matches
AttachmentsOutOfReach.c
Go to the documentation of this file.
2{
4
5 static bool IsAttachmentReachable(EntityAI e, string att_slot_name = "", int slot_id = -1, float range = 1.5)
6 {
7 if (!e.IgnoreOutOfReachCondition())
8 {
10 if (player.IsInVehicle())
11 return false;
12 else
13 {
14
16 if (slot_id != -1)
18 if (att_slot_name != "")
19 {
20 if (e.MemoryPointExists(att_slot_name))
21 {
22 vector mem_point = e.GetMemoryPointPos(att_slot_name);
23 pos_att = e.ModelToWorld(mem_point);
24 }
25 else
27
28 }
29
30 vector pos_player = player.GetPosition();
31
33 if (height_diff < range)
34 {
35 pos_player[1] = 0;
36 pos_att[1] = 0;
38 return true;
39 return false;
40 }
41 else
42 return false;
43 }
44 }
45 else
46 return true;
47 }
48
50 {
51 if (m_AttData == NULL)
53
54 string type_name = e.GetType();
55
56 if (!m_AttData.Contains(type_name))
57 {
59
60 m_AttData.Insert(type_name, att);
61 }
62
63 return m_AttData.Get(type_name).Get(slot_id);
64 }
65
67 {
69
70 string type_name = entity.GetType();
72
73 string cfg_path;
74
75 if (GetGame().ConfigIsExisting(CFG_VEHICLESPATH + " " + type_name))
76 cfg_path = CFG_VEHICLESPATH + " " + type_name + " attachments";
77 else if (GetGame().ConfigIsExisting(CFG_WEAPONSPATH + " " + type_name))
78 cfg_path = CFG_WEAPONSPATH + " " + type_name + " attachments";
79 else if (GetGame().ConfigIsExisting(CFG_MAGAZINESPATH + " " + type_name))
80 cfg_path = CFG_MAGAZINESPATH + " " + type_name + " attachments";
81
82 GetGame().ConfigGetTextArray(cfg_path, cfg_attachments);
83
84 int child_count = GetGame().ConfigGetChildrenCount("CfgNonAIVehicles");
85
86 for (int x = 0; x < child_count; ++x)
87 {
88 string child_name;
89 GetGame().ConfigGetChildName("CfgNonAIVehicles", x, child_name);
90
92 GetGame().ConfigGetText("CfgNonAIVehicles " + child_name + " inventorySlot", inventory_slot_name);
93
95 {
96 string model_path;
97 GetGame().ConfigGetText("CfgNonAIVehicles " + child_name + " model", model_path);
98
99 if (model_path.Length() > 5)
100 {
101 LOD lod = entity.GetLODByName(LOD.NAME_VIEW);
102
103 if (lod)
104 {
105 model_path = model_path.Substring(0, model_path.Length() - 4);
106 model_path.ToLower();
107
109 lod.GetSelections(selections);
110
111 for (int i = 0; i < selections.Count(); ++i)
112 {
113 string selection = selections[i].GetName();
114 selection.ToLower();
115
116 if (selection.Contains(model_path))
118 }
119 }
120 }
121 }
122 }
123
124 return ret_val;
125 }
126}
Icon x
PlayerBase GetPlayer()
static ref map< string, ref map< int, vector > > m_AttData
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
static vector GetAttachmentPosition(EntityAI e, int slot_id)
map< int, vector > CreateAttachmentPosition(EntityAI entity)
provides access to slot configuration
static proto native owned string GetSlotName(int id)
converts slot_id to string
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
LOD class.
Definition gameplay.c:203
static const string NAME_VIEW
Definition gameplay.c:206
Definition EnMath.c:7
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
array< string > TStringArray
Definition EnScript.c:666
static proto float AbsFloat(float f)
Returns absolute value.
const string CFG_VEHICLESPATH
Definition constants.c:209
const string CFG_WEAPONSPATH
Definition constants.c:210
const string CFG_MAGAZINESPATH
Definition constants.c:211
bool Contains(string sample)
Returns true if sample is substring of string.
Definition EnString.c:286
proto int ToLower()
Changes string to lowercase. Returns length.