DayZ 1.29
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
HandAnimated_Guards.c
См. документацию.
1int SlotToAnimType(notnull Man player, notnull InventoryLocation src, InventoryLocation dst = null)
2{
3 //Print("src.GetType() " + src.GetType());
5 //InventoryLocation invloc2 = new InventoryLocation;
6
7 if ( (dst && dst.GetParent() && !dst.GetParent().GetHierarchyRootPlayer()) || (src && src.GetParent() && !src.GetParent().GetHierarchyRootPlayer()) )
8 return -1;
9
10 if (dst && (dst.GetType() == InventoryLocationType.ATTACHMENT || dst.GetType() == InventoryLocationType.CARGO))
11 {
12 invloc1.Copy(dst);
13 //invloc2.Copy(src);
14 }
15 else if (src.GetType() == InventoryLocationType.ATTACHMENT || src.GetType() == InventoryLocationType.CARGO)
16 {
17 invloc1.Copy(src);
18 //invloc2.Copy(dst);
19 }
20 else
21 {
22 return -1;
23 }
24
25 int val = -1;
26 if ( invloc1.GetItem() && invloc1.GetItem().GetInventoryHandAnimation(invloc1,val) )
27 {
28 return val;
29 }
30
31 if (invloc1.GetType() == InventoryLocationType.ATTACHMENT /*|| src.GetType() == InventoryLocationType.HANDS*/)
32 {
33 //return WeaponHideShowTypes.HIDESHOW_SLOT_KNIFEBACK;
34 switch (invloc1.GetSlot())
35 {
36 case InventorySlots.SHOULDER:
37 {
38 if (invloc1.GetItem() && invloc1.GetItem().IsWeapon())
39 {
40 return WeaponHideShowTypes.HIDESHOW_SLOT_RFLLEFTBACK;
41 }
42 else if (invloc1.GetItem() && invloc1.GetItem().IsOneHandedBehaviour())
43 {
44 return WeaponHideShowTypes.HIDESHOW_SLOT_1HDLEFTBACK;
45 }
46 return WeaponHideShowTypes.HIDESHOW_SLOT_2HDLEFTBACK;
47 }
48 case InventorySlots.MELEE:
49 {
50 if (invloc1.GetItem() && invloc1.GetItem().IsWeapon())
51 {
52 return WeaponHideShowTypes.HIDESHOW_SLOT_RFLRIGHTBACK;
53 }
54 else if (invloc1.GetItem() && invloc1.GetItem().IsOneHandedBehaviour())
55 {
56 return WeaponHideShowTypes.HIDESHOW_SLOT_1HDRIGHTBACK;
57 }
58 return WeaponHideShowTypes.HIDESHOW_SLOT_2HDRIGHTBACK;
59 }
60 case InventorySlots.PISTOL:
61 {
62 EntityAI parent_item = invloc1.GetParent(); // belt
63 Man owner;
64 if (parent_item)
65 owner = parent_item.GetHierarchyRootPlayer(); // player
66 if (!owner)
67 return -1;
68
69 EntityAI item1 = owner.GetInventory().FindAttachment(InventorySlots.HIPS);
70 EntityAI item2 = parent_item.GetHierarchyParent();
71 if (owner && item1 == item2) // is the pistol in a belt holster?
72 {
73 return WeaponHideShowTypes.HIDESHOW_SLOT_PISTOLBELT;
74 }
75 return WeaponHideShowTypes.HIDESHOW_SLOT_PISTOLCHEST;
76 }
77 case InventorySlots.KNIFE:
78 return WeaponHideShowTypes.HIDESHOW_SLOT_KNIFEBACK;
79
80 /*case InventorySlots.VEST:
81 case InventorySlots.FEET:
82 case InventorySlots.BODY:
83 case InventorySlots.LEGS:
84 case InventorySlots.BACK:
85 case InventorySlots.HIPS:
86 case InventorySlots.HEADGEAR:
87 return WeaponHideShowTypes.HIDESHOW_SLOT_INVENTORY;*/
88
89 default:
90 return WeaponHideShowTypes.HIDESHOW_SLOT_INVENTORY;
91 //Print("[hndfsm] SlotToAnimType - not animated slot in src_loc=" + InventoryLocation.DumpToStringNullSafe(invloc1));
92 };
93 //
94 //if (InventorySlots.GetSlotIdFromString("Pistol"))
95 }
96 else if (invloc1.GetType() == InventoryLocationType.CARGO)
97 {
98 EntityAI item = invloc1.GetItem();
99 if (item)
100 {
101 GameInventory itemInventory = item.GetInventory();
102 if (itemInventory.HasInventorySlot(InventorySlots.SHOULDER) || itemInventory.HasInventorySlot(InventorySlots.MELEE))
103 {
104 //Print("Special inventory anim");
105 if (item.IsWeapon())
106 {
107 return WeaponHideShowTypes.HIDESHOW_SLOT_RFLRIGHTBACK;
108 }
109 else if (item.IsOneHandedBehaviour())
110 {
111 return WeaponHideShowTypes.HIDESHOW_SLOT_1HDRIGHTBACK;
112 }
113 return WeaponHideShowTypes.HIDESHOW_SLOT_2HDRIGHTBACK;
114 }
115 }
116 //Print("Default inventory anim");
117 return WeaponHideShowTypes.HIDESHOW_SLOT_INVENTORY; //default item animation
118 }
119 return -1;
120}
121
122bool SelectAnimationOfTakeToHands(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst, out int animType)
123{
124 if (player.IsInTransport())
125 return false;
126 if (src.GetType() == InventoryLocationType.GROUND)
127 return false;
128
129 if (src.GetItem().GetHierarchyRootPlayer() == player)
130 {
131 animType = SlotToAnimType(player, src);
132 if (animType != -1)
133 {
134 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfTakeToHands - selected animType=" + animType + " for item=" + src.GetItem());
135 return true;
136 }
137 }
138 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfTakeToHands - no animation");
139 return false;
140}
141
142bool SelectAnimationOfMoveFromHands(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst, out int animType)
143{
144 if (player.IsInTransport())
145 return false;
146
147 if (src.GetItem().GetHierarchyRootPlayer() == player)
148 {
149 animType = SlotToAnimType(player, dst);
150 if (animType != -1)
151 {
152 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfMoveFromHands guard - selected animType=" + animType + " for item=" + src.GetItem());
153 return true;
154 }
155 }
156 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfMoveFromHands - no animation");
157 return false;
158}
159
160bool SelectAnimationOfForceSwapInHands(notnull Man player, notnull InventoryLocation old_src, notnull InventoryLocation new_src, notnull InventoryLocation old_dst, notnull InventoryLocation new_dst, out int animType1, out int animType2)
161{
162 if (player.IsInTransport())
163 return false;
164
165 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SlotToAnimType - old_src=" + InventoryLocation.DumpToStringNullSafe(old_src) + " new_src=" + InventoryLocation.DumpToStringNullSafe(new_src) + " old_dst=" + InventoryLocation.DumpToStringNullSafe(old_dst) + " new_dst=" + InventoryLocation.DumpToStringNullSafe(new_dst));
166
167 if (old_src.GetItem().GetHierarchyRootPlayer() == player || new_src.GetItem().GetHierarchyRootPlayer() == player)
168 {
169 animType1 = SlotToAnimType(player, old_src, old_dst);
170 animType2 = SlotToAnimType(player, new_src, new_dst);
171 //Print("animType1 = " + animType1);
172 //Print("animType2 = " + animType2);
173 if (animType1 != -1 && animType2 != -1)
174 {
175 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfForceSwapInHands guard - selected animType1=" + animType1 + " animType2=" + animType2 + " for old_item=" + old_src.GetItem() + " for new_item=" + new_src.GetItem());
176 return true;
177 }
178 /*else if (animType1 != -1 || animType2 != -1) //HACK
179 {
180 animType1 = -1;
181 animType2 = -1;
182 return false;
183 }*/
184 }
185 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfForceSwapInHands - no animation");
186 return false;
187}
188
189
190class HandSelectAnimationOfTakeToHandsEvent extends HandGuardBase
191{
193
195 {
196 int animType = -1;
197 if (SelectAnimationOfTakeToHands(e.m_Player, e.GetSrc(), e.GetDst(), animType))
198 {
199 e.m_AnimationID = animType;
200 return true;
201 }
202 return false;
203 }
204};
205
206class HandSelectAnimationOfMoveFromHandsEvent extends HandGuardBase
207{
208 protected Man m_Player;
209
211 {
212 m_Player = p;
213 }
214
216 {
217 EntityAI eai = m_Player.GetEntityInHands();
218 if (eai)
219 {
221 if (eai.GetInventory().GetCurrentInventoryLocation(src))
222 {
223 if (e.m_IsJuncture == false && e.m_IsRemote == false)
224 {
226 {
228 {
229 hndDebugPrint("[hndfsm] HandSelectAnimationOfMoveFromHandsEvent - rejected");
230 }
231
232 return false;
233 }
234 }
235
236 int animType = -1;
237 if (SelectAnimationOfMoveFromHands(e.m_Player, src, e.GetDst(), animType))
238 {
239 e.m_AnimationID = animType;
240 return true;
241 }
242 return false;
243 }
244 }
245 return false;
246 }
247};
248
250{
251 protected Man m_Player;
252
254
255 bool ProcessSwapEvent(notnull HandEventBase e, out int animType1, out int animType2)
256 {
257 HandEventSwap es = HandEventSwap.Cast(e);
258 if (es)
259 return SelectAnimationOfForceSwapInHands(e.m_Player, es.m_Src, es.m_Src2, es.m_Dst, es.m_Dst2, animType1, animType2);
260 Error("HandSelectAnimationOfForceSwapInHandsEvent - not an swap event");
261 return false;
262 }
263
265 {
266 HandEventForceSwap es = HandEventForceSwap.Cast(e);
267 if (es)
268 {
270 {
271 hndDebugPrint("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent FSwap e=" + e.DumpToString());
272 }
273
274 if (!es.m_Src2.IsValid() || !es.m_Src.IsValid())
275 {
276 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - invalid item source");
277 return false;
278 }
279
280 bool allow = e.m_IsJuncture || e.m_IsRemote;
281 if (allow == false)
282 {
283 if (GameInventory.CanSwapEntitiesEx(es.GetSrc().GetItem(), es.m_Src2.GetItem()))
284 {
285 allow = true; // allow if ordinary swap
286 }
287 else if (es.m_Dst2)
288 {
289 if (GameInventory.CanForceSwapEntitiesEx(es.GetSrc().GetItem(), es.m_Dst, es.m_Src2.GetItem(), es.m_Dst2) == false)
290 {
291 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - no room at dst=" + InventoryLocation.DumpToStringNullSafe(es.m_Dst2));
292 }
293 else
294 {
295 allow = true;
296 }
297 }
298 }
299
300 if (allow)
301 {
302 int animType1 = -1;
303 int animType2 = -1;
304 if (ProcessSwapEvent(e, animType1, animType2))
305 {
306 e.m_AnimationID = animType1;
307 es.m_Animation2ID = animType2;
308 return true;
309 }
310 }
311 else
312 {
313 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - m_HasRoomGuard.GuardCondition failed");
314 }
315 }
316 else
317 {
318 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - not a swap event");
319 }
320 return false;
321 }
322};
323
324class HandSelectAnimationOfSwapInHandsEvent extends HandSelectAnimationOfForceSwapInHandsEvent
325{
327 {
328 HandEventSwap es = HandEventSwap.Cast(e);
329 if (es)
330 {
331 int animType1 = -1;
332 int animType2 = -1;
333 if (ProcessSwapEvent(e, animType1, animType2))
334 {
335 e.m_AnimationID = animType1;
336 es.m_Animation2ID = animType2;
337 return true;
338 }
339 }
340 else
341 Error("[hndfsm] HandSelectAnimationOfSwapInHandsEvent - not a swap event");
342 return false;
343 }
344};
345
map m_Player
bool SelectAnimationOfMoveFromHands(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst, out int animType)
Определения HandAnimated_Guards.c:142
int SlotToAnimType(notnull Man player, notnull InventoryLocation src, InventoryLocation dst=null)
Определения HandAnimated_Guards.c:1
bool SelectAnimationOfTakeToHands(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst, out int animType)
Определения HandAnimated_Guards.c:122
bool SelectAnimationOfForceSwapInHands(notnull Man player, notnull InventoryLocation old_src, notnull InventoryLocation new_src, notnull InventoryLocation old_dst, notnull InventoryLocation new_dst, out int animType1, out int animType2)
Определения HandAnimated_Guards.c:160
void hndDebugPrint(string s)
Определения HandFSM.c:1
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
proto native bool HasInventorySlot(int slotId)
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
script counterpart to engine's class Inventory
override InventoryLocation GetDst()
Определения Hand_Events.c:215
override string DumpToString()
Определения Hand_Events.c:338
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:212
Определения Hand_Events.c:726
void HandSelectAnimationOfTakeToHandsEvent(Man p=null)
Определения HandAnimated_Guards.c:192
Man m_Player
Определения Hand_Guards.c:83
void HandSelectAnimationOfForceSwapInHandsEvent(Man p=NULL)
Определения HandAnimated_Guards.c:253
void HandSelectAnimationOfMoveFromHandsEvent(Man p=null)
Определения HandAnimated_Guards.c:210
bool ProcessSwapEvent(notnull HandEventBase e, out int animType1, out int animType2)
Определения HandAnimated_Guards.c:255
override bool GuardCondition(HandEventBase e)
Определения HandAnimated_Guards.c:194
TODO(kumarjac): This guard is unused but it has a fault and doesn't conform with maximimal/minimal ch...
Определения Hand_Guards.c:7
override bool GuardCondition(HandEventBase e)
Определения HandAnimated_Guards.c:326
proto native EntityAI GetParent()
returns parent of current inventory location
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:233
proto native int GetSlot()
returns slot id if current type is Attachment
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
proto native int GetType()
returns type of InventoryLocation
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
provides access to slot configuration
Определения InventorySlots.c:6
static bool IsInventoryHFSMLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:766
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
WeaponHideShowTypes
Определения human.c:936