DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ActionEnterLadder.c
См. документацию.
1
3{
4 private const string GEOM_LOD_NAME = LOD.NAME_GEOMETRY;
5 private const string MEM_LOD_NAME = LOD.NAME_MEMORY;
6
8 {
9 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
10 m_Text = "#enter_ladder";
11 }
12
14 {
17 }
18
19 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
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 // TODO: direction tests
30 // Get memory LOD from p3d and save all its selections
31 LOD lod = building.GetLODByName(MEM_LOD_NAME);
32 if(lod == NULL)
33 return false;
34
35 array<Selection> memSelection = new array<Selection>();
36 if(!lod.GetSelections(memSelection))
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 //HumanCommandLadder.DebugDrawLadder(building, HumanCommandLadder.DebugGetLadderIndex(compName));
97 //found = true;
98 }
99 }
100 }
101 }
102
103 pos = pos - ladderEnterPointGlobal;
104 ladderDirPointGlobal = ladderDirPointGlobal - ladderEnterPointGlobal;
105
106 float angle = Math.AbsFloat(pos.VectorToAngles()[0] - ladderDirPointGlobal.VectorToAngles()[0]);
107
108 if ( angle < 90 || angle > 270)
109 {
110 return true;
111 }
112 }
113
114 return false;
115 }
116
117 override void Start( ActionData action_data )
118 {
119 super.Start(action_data);
120
121 Building building;
122 if (Class.CastTo(building, action_data.m_Target.GetObject()))
123 {
124 array<string> selections = new array<string>();
125 string compName = "";
126 building.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
127 foreach (string tmp : selections)
128 {
129 if (tmp.Length() >= 6 && tmp.Substring(0,6) == "ladder" && tmp.IndexOfFrom(6,"_") < 0)
130 {
131 compName = tmp;
132 break;
133 }
134 }
135
136 int ladderIndex = HumanCommandLadder.DebugGetLadderIndex(compName);
137 LOD geomLod = action_data.m_Target.GetObject().GetLODByName(GEOM_LOD_NAME);
138 string ladderType = "metal";
139
140 for (int i = 0; i < geomLod.GetPropertyCount(); ++i)
141 {
142 if (geomLod.GetPropertyName(i) == "laddertype")
143 {
144 ladderType = geomLod.GetPropertyValue(i);
145 break;
146 }
147 }
148
149 action_data.m_Player.SetClimbingLadderType(ladderType);
150 action_data.m_Player.StartCommand_Ladder(building, ladderIndex );
151 }
152 }
153
154 override bool IsLockTargetOnUse()
155 {
156 return false;
157 }
158
159 override bool IsInstant()
160 {
161 return true;
162
163 }
164
165 override bool CanBeUsedSwimming()
166 {
167 return true;
168 }
169};
string m_Text
Определения ActionBase.c:57
ref CCIBase m_ConditionItem
Определения ActionBase.c:63
ref CCTBase m_ConditionTarget
Определения ActionBase.c:64
int m_StanceMask
Определения ActionBase.c:61
void ActionTarget(Object object, Object parent, int componentIndex, vector cursorHitPos, float utility, string surfaceName="")
Определения ActionTargets.c:125
Empty
Определения Hand_States.c:14
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
Определения ActionBase.c:22
override bool CanBeUsedSwimming()
Определения ActionEnterLadder.c:165
override void CreateConditionComponents()
Определения ActionEnterLadder.c:13
override bool IsLockTargetOnUse()
Определения ActionEnterLadder.c:154
override void Start(ActionData action_data)
Определения ActionEnterLadder.c:117
override bool IsInstant()
Определения ActionEnterLadder.c:159
const string MEM_LOD_NAME
Определения ActionEnterLadder.c:5
void ActionEnterLadder()
Определения ActionEnterLadder.c:7
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Определения ActionEnterLadder.c:19
const string GEOM_LOD_NAME
Определения ActionEnterLadder.c:4
void ActionInteractBase()
Определения ActionInteractBase.c:43
Определения CCINone.c:2
Определения CCTCursor.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
proto static native bool DebugDrawLadder(Building pBuilding, int pLadderIndex)
debug draws any ladder
proto static native int DebugGetLadderIndex(string pComponentName)
Определения human.c:667
proto native owned string GetPropertyValue(int index)
static const string NAME_MEMORY
Определения gameplay.c:209
proto native int GetPropertyCount()
static const string NAME_GEOMETRY
Определения gameplay.c:206
proto native owned string GetPropertyName(int index)
proto native bool GetSelections(notnull out array< Selection > selections)
LOD class.
Определения gameplay.c:204
Определения EnMath.c:7
Определения PlayerBaseClient.c:2
const float LADDERS
Определения ActionConstants.c:117
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
proto vector VectorToAngles()
Converts vector to spherical coordinates with radius = 1.
Определения EnConvert.c:119
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto float AbsFloat(float f)
Returns absolute value.
proto native owned string GetName()
Test name getter. Strictly for UI porposes!
Определения SyncedValue.c:119