DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
AttachmentsOutOfReach.c
См. документацию.
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 {
9 PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
10 if( player.IsInVehicle() )
11 {
12 return false;
13 }
14 else
15 {
16
17 vector pos_att;
18 if ( slot_id != -1 )
19 {
20 att_slot_name = InventorySlots.GetSlotName(slot_id);
21 }
22 if( att_slot_name != "" )
23 {
24 if( e.MemoryPointExists(att_slot_name) )
25 {
26 vector mem_point = e.GetMemoryPointPos(att_slot_name);
27 pos_att = e.ModelToWorld(mem_point);
28 }
29 else
30 {
31 pos_att = e.ModelToWorld(GetAttachmentPosition(e, InventorySlots.GetSlotIdFromString( att_slot_name ) ));
32 }
33
34 }
35
36 vector pos_player = player.GetPosition();
37
38 float height_diff = Math.AbsFloat( pos_player[1] - pos_att[1] );
39 if( height_diff < range )
40 {
41 pos_player[1] = 0;
42 pos_att[1] = 0;
43 if ( vector.Distance(pos_player, pos_att) <= range )
44 {
45 return true;
46 }
47 return false;
48 }
49 else
50 {
51 return false;
52 }
53 }
54 }
55 else
56 {
57 return true;
58 }
59 }
60
61 static vector GetAttachmentPosition(EntityAI e, int slot_id)
62 {
63 if ( m_AttData == NULL )
64 {
66 }
67
68 string type_name = e.GetType();
69
70 if ( !m_AttData.Contains( type_name ) )
71 {
73
74 m_AttData.Insert( type_name, att );
75 }
76
77 return m_AttData.Get( type_name ).Get( slot_id );
78 }
79
81 {
82 map<int, vector> ret_val = new map<int, vector>();
83
84 string type_name = entity.GetType();
85 TStringArray cfg_attachments = new TStringArray;
86
87 string cfg_path;
88
89 if ( GetGame().ConfigIsExisting(CFG_VEHICLESPATH+" "+type_name) )
90 {
91 cfg_path = CFG_VEHICLESPATH+" "+type_name+" attachments";
92 }
93 else if ( GetGame().ConfigIsExisting(CFG_WEAPONSPATH+" "+type_name) )
94 {
95 cfg_path = CFG_WEAPONSPATH+" "+type_name+" attachments";
96 }
97 else if ( GetGame().ConfigIsExisting(CFG_MAGAZINESPATH+" "+type_name) )
98 {
99 cfg_path = CFG_MAGAZINESPATH+" "+type_name+" attachments";
100 }
101
102 GetGame().ConfigGetTextArray(cfg_path, cfg_attachments);
103
104 int child_count = GetGame().ConfigGetChildrenCount("CfgNonAIVehicles");
105
106 for ( int x = 0; x < child_count; ++x )
107 {
108 string child_name;
109 GetGame().ConfigGetChildName("CfgNonAIVehicles",x , child_name);
110
111 string inventory_slot_name;
112 GetGame().ConfigGetText("CfgNonAIVehicles "+ child_name +" inventorySlot", inventory_slot_name);
113
114 if ( cfg_attachments.Find( inventory_slot_name ) > 0 )
115 {
116 string model_path;
117 GetGame().ConfigGetText("CfgNonAIVehicles "+ child_name +" model", model_path);
118
119 if ( model_path.Length() > 5 )
120 {
121 LOD lod = entity.GetLODByName(LOD.NAME_VIEW);
122
123 if ( lod )
124 {
125 model_path = model_path.Substring(0, model_path.Length() - 4);
126 model_path.ToLower();
127
128 array<Selection> selections = new array<Selection>();
129 lod.GetSelections(selections);
130
131 for ( int i = 0; i < selections.Count(); ++i )
132 {
133 string selection = selections[i].GetName();
134 selection.ToLower();
135
136 if ( selection.Contains(model_path) )
137 {
138 ret_val.Set(InventorySlots.GetSlotIdFromString( inventory_slot_name ), selections[i].GetVertexPosition(lod, 0));
139 }
140 }
141 }
142 }
143 }
144 }
145
146 return ret_val;
147 }
148}
map
Определения ControlsXboxNew.c:4
Icon x
PlayerBase GetPlayer()
Определения ModifierBase.c:51
static ref map< string, ref map< int, vector > > m_AttData
Определения AttachmentsOutOfReach.c:3
static bool IsAttachmentReachable(EntityAI e, string att_slot_name="", int slot_id=-1, float range=1.5)
Определения AttachmentsOutOfReach.c:5
static vector GetAttachmentPosition(EntityAI e, int slot_id)
Определения AttachmentsOutOfReach.c:61
map< int, vector > CreateAttachmentPosition(EntityAI entity)
Определения AttachmentsOutOfReach.c:80
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
Определения Building.c:6
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
static const string NAME_VIEW
Определения gameplay.c:207
proto native bool GetSelections(notnull out array< Selection > selections)
LOD class.
Определения gameplay.c:204
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
Определения EnConvert.c:106
proto native CGame GetGame()
array< string > TStringArray
Определения EnScript.c:685
static proto float AbsFloat(float f)
Returns absolute value.
const string CFG_VEHICLESPATH
Определения constants.c:220
const string CFG_WEAPONSPATH
Определения constants.c:221
const string CFG_MAGAZINESPATH
Определения constants.c:222
proto native int Length()
Returns length of string.
bool Contains(string sample)
Returns true if sample is substring of string.
Определения EnString.c:286
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto int ToLower()
Changes string to lowercase. Returns length.