20 {
22 if (!target || !target.GetObject() || player.GetCommand_Ladder() || player.GetCommand_Fall() )
23 return false;
24
25 Building building;
26 if (!Class.CastTo(building, target.GetObject()))
27 return false;
28
29
30
32 if(lod == NULL)
33 return false;
34
35 array<Selection> memSelection = new array<Selection>();
37 return false;
38
39 array<string> selections = new array<string>();
40 string compName = "";
41 building.GetActionComponentNameList(target.GetComponentIndex(), selections);
42 foreach (string tmp : selections)
43 {
44 if (tmp.Length() >= 6 && tmp.Substring(0,6) == "ladder" && tmp.IndexOfFrom(6,"_") < 0)
45 {
46 compName = tmp;
47 break;
48 }
49 }
50
51 if (compName ==
string.
Empty)
52 return false;
53
54 string condCompName = string.Format("%1_con", compName);
55 vector pos = player.GetPosition();
56
57 bool found = false;
58 vector ladderEnterPointGlobal;
59 vector ladderDirPointGlobal;
60 float minDistanceSq = 100.0;
61
62 string dirCompName = string.Format("%1_con_dir", compName);
63
64 for ( int i = 0; i < memSelection.Count(); i++ )
65 {
66 if ( memSelection[i].
GetName() == condCompName )
67 {
68
69 for( int j = 0; j < memSelection[i].GetVertexCount(); j++ )
70 {
71 ladderEnterPointGlobal = building.ModelToWorld( memSelection[i].GetVertexPosition(lod, j) );
72 if( vector.DistanceSq(ladderEnterPointGlobal,pos) < UAMaxDistances.LADDERS * UAMaxDistances.LADDERS)
73 {
75 found = true;
76 break;
77 }
78 }
79 }
80 }
81
82 if (found)
83 {
84 for (int k = 0; k < memSelection.Count(); k++)
85 {
86 if( memSelection[k].
GetName() == dirCompName )
87 {
88 for( int l = 0; l < memSelection[k].GetVertexCount(); l++ )
89 {
90 vector dirPoint = building.ModelToWorld( memSelection[k].GetVertexPosition(lod, l) );
91 float dst = vector.DistanceSq(ladderEnterPointGlobal,dirPoint);
92 if( dst < minDistanceSq)
93 {
94 minDistanceSq = dst;
95 ladderDirPointGlobal = dirPoint;
96
97
98 }
99 }
100 }
101 }
102
103 pos = pos - ladderEnterPointGlobal;
104 ladderDirPointGlobal = ladderDirPointGlobal - ladderEnterPointGlobal;
105
107
108 if ( angle < 90 || angle > 270)
109 {
110 return true;
111 }
112 }
113
114 return false;
115 }
const string MEM_LOD_NAME
proto native bool GetSelections(notnull out array< Selection > selections)
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
void HumanCommandLadder()