DayZ 1.27
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
40 string compName = building.GetActionComponentName( target.GetComponentIndex() );
41 if( compName.Length() < 6 || compName.Substring(0,6) != "ladder" )
42 {
43 return false;
44 }
45
46 // ze stringu compName dostat posledni cislo a to je index zebriku
47
48 //building.GetActionComponentNameList( action_data.m_Target.GetComponentIndex(), components );
49
50 string condCompName = string.Format("%1_con", compName);
51 vector pos = player.GetPosition();
52 //Print(w);
53 bool found = false;
54 vector ladderEnterPointGlobal;
55 vector ladderDirPointGlobal;
56 float minDistanceSq = 100.0;
57
58 string dirCompName = string.Format("%1_con_dir", compName);
59
60 for ( int i = 0; i < memSelection.Count(); i++ )
61 {
62 if ( memSelection[i].GetName() == condCompName )
63 {
64
65 for( int j = 0; j < memSelection[i].GetVertexCount(); j++ )
66 {
67 ladderEnterPointGlobal = building.ModelToWorld( memSelection[i].GetVertexPosition(lod, j) );
68 if( vector.DistanceSq(ladderEnterPointGlobal,pos) < UAMaxDistances.LADDERS * UAMaxDistances.LADDERS)
69 {
71 found = true;
72 break;
73 }
74 }
75 }
76 }
77
78 if (found)
79 {
80 for (int k = 0; k < memSelection.Count(); k++)
81 {
82 if( memSelection[k].GetName() == dirCompName )
83 {
84 for( int l = 0; l < memSelection[k].GetVertexCount(); l++ )
85 {
86 vector dirPoint = building.ModelToWorld( memSelection[k].GetVertexPosition(lod, l) );
87 float dst = vector.DistanceSq(ladderEnterPointGlobal,dirPoint);
88 if( dst < minDistanceSq)
89 {
90 minDistanceSq = dst;
91 ladderDirPointGlobal = dirPoint;
92 //HumanCommandLadder.DebugDrawLadder(building, HumanCommandLadder.DebugGetLadderIndex(compName));
93 //found = true;
94 }
95 }
96 }
97 }
98
99 pos = pos - ladderEnterPointGlobal;
100 ladderDirPointGlobal = ladderDirPointGlobal - ladderEnterPointGlobal;
101
102 float angle = Math.AbsFloat(pos.VectorToAngles()[0] - ladderDirPointGlobal.VectorToAngles()[0]);
103
104 if ( angle < 90 || angle > 270)
105 {
106 return true;
107 }
108 }
109
110 return false;
111 }
112
113 override void Start( ActionData action_data )
114 {
115 super.Start( action_data );
116 Building b;
117 Class.CastTo(b, action_data.m_Target.GetObject());
118
119 if (b)
120 {
121 string compName = b.GetActionComponentName( action_data.m_Target.GetComponentIndex() );
122 int ladderIndex = HumanCommandLadder.DebugGetLadderIndex(compName);
123
124 LOD geomLod = action_data.m_Target.GetObject().GetLODByName(GEOM_LOD_NAME);
125 string ladderType = "metal";
126
127 for (int i = 0; i < geomLod.GetPropertyCount(); ++i)
128 {
129 if (geomLod.GetPropertyName(i) == "laddertype")
130 {
131 ladderType = geomLod.GetPropertyValue(i);
132 break;
133 }
134 }
135
136 action_data.m_Player.SetClimbingLadderType(ladderType);
137 action_data.m_Player.StartCommand_Ladder(b, ladderIndex );
138 }
139
140
141 /* if( GetGame().IsServer() )
142 {
143 OnStartServer(action_data);
144 }
145 else
146 {
147 OnStartClient(action_data);
148 }*/
149 }
150
151/* override void WriteToContext (ParamsWriteContext ctx,ActionTarget target)
152 {
153 ctx.Write(INPUT_UDT_STANDARD_ACTION);
154 ctx.Write(GetType());
155
156 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
157 ActionManagerClient AM = ActionManagerClient.Cast( player.GetActionManager());
158 //ActionTarget target = AM.FindActionTarget();
159 Object targetObject = target.GetObject();
160 ctx.Write(targetObject);
161 Object targetParent = target.GetParent();
162 ctx.Write(targetParent);
163 int componentIndex = target.GetComponentIndex();
164 ctx.Write(componentIndex);
165 }
166
167 override void OnStartServer( ActionData action_data )
168 {
169 Print("psovis - server/single");
170
171 Building building;
172 if ( Class.CastTo(building, action_data.m_Target.GetObject()) )
173 {
174 ref array<Selection> memSelections = new array<Selection>();
175
176 // Get memory LOD from p3d and save all its selections
177 LOD lod = building.GetLODByName(MEM_LOD_NAME);
178 if(lod != NULL && lod.GetSelections(memSelections))
179 {
180 Print("Memory selections:");
181 for( int i =0; i < memSelections.Count(); i++ )
182 {
183 if (memSelections[i].GetVertexCount() > 0)
184 {
185 vector pos = memSelections[i].GetVertexPosition(lod, 0);
186 Print(memSelections[i].GetName());
187 Print(pos);
188 }
189 }
190 }
191 }
192 }*/
193
194 /*override void OnStartClient( ActionData action_data )
195 {
196 Print("psovis - client");
197 }*/
198
199 override bool IsLockTargetOnUse()
200 {
201 return false;
202 }
203
204 override bool IsInstant()
205 {
206 return true;
207
208 }
209
210 override bool CanBeUsedSwimming()
211 {
212 return true;
213 }
214};
ActionBase ActionData
Определения ActionBase.c:30
class ActionTargets ActionTarget
int m_StanceMask
Определения ActionBase.c:62
string m_Text
Определения ActionBase.c:58
ref CCIBase m_ConditionItem
Определения ActionBase.c:64
ref CCTBase m_ConditionTarget
Определения ActionBase.c:65
override bool CanBeUsedSwimming()
Определения ActionEnterLadder.c:210
override void CreateConditionComponents()
Определения ActionEnterLadder.c:13
override bool IsLockTargetOnUse()
Определения ActionEnterLadder.c:199
override void Start(ActionData action_data)
Определения ActionEnterLadder.c:113
override bool IsInstant()
Определения ActionEnterLadder.c:204
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:645
Определения InventoryItem.c:731
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:115
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:106
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 int Length()
Returns length of string.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto native owned string GetName()
Test name getter. Strictly for UI porposes!
Определения SyncedValue.c:119