5 static bool IsAttachmentReachable(
EntityAI e,
string att_slot_name =
"",
int slot_id = -1,
float range = 1.5)
7 if( !e.IgnoreOutOfReachCondition() )
10 if( player.IsInVehicle() )
22 if( att_slot_name !=
"" )
24 if( e.MemoryPointExists(att_slot_name) )
26 vector mem_point = e.GetMemoryPointPos(att_slot_name);
27 pos_att = e.ModelToWorld(mem_point);
31 pos_att = e.ModelToWorld(GetAttachmentPosition(e,
InventorySlots.GetSlotIdFromString( att_slot_name ) ));
36 vector pos_player = player.GetPosition();
38 float height_diff =
Math.AbsFloat( pos_player[1] - pos_att[1] );
39 if( height_diff < range )
43 if (
vector.Distance(pos_player, pos_att) <= range )
63 if ( m_AttData == NULL )
68 string type_name = e.GetType();
70 if ( !m_AttData.Contains( type_name ) )
74 m_AttData.Insert( type_name, att );
77 return m_AttData.Get( type_name ).Get( slot_id );
84 string type_name = entity.GetType();
102 GetGame().ConfigGetTextArray(cfg_path, cfg_attachments);
104 int child_count =
GetGame().ConfigGetChildrenCount(
"CfgNonAIVehicles");
106 for (
int x = 0;
x < child_count; ++
x )
109 GetGame().ConfigGetChildName(
"CfgNonAIVehicles",
x , child_name);
111 string inventory_slot_name;
112 GetGame().ConfigGetText(
"CfgNonAIVehicles "+ child_name +
" inventorySlot", inventory_slot_name);
114 if ( cfg_attachments.Find( inventory_slot_name ) > 0 )
117 GetGame().ConfigGetText(
"CfgNonAIVehicles "+ child_name +
" model", model_path);
119 if ( model_path.Length() > 5 )
121 LOD lod = entity.GetLODByName(
LOD.NAME_VIEW);
125 model_path = model_path.Substring(0, model_path.Length() - 4);
126 model_path.ToLower();
129 lod.GetSelections(selections);
131 for (
int i = 0; i < selections.Count(); ++i )
133 string selection = selections[i].GetName();
136 if ( selection.Contains(model_path) )
138 ret_val.Set(
InventorySlots.GetSlotIdFromString( inventory_slot_name ), selections[i].GetVertexPosition(lod, 0));