DayZ 1.24
Loading...
Searching...
No Matches
HandAnimated_Guards.c
Go to the documentation of this file.
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 return -1;
22
23 int val = -1;
24 if (invloc1.GetItem() && invloc1.GetItem().GetInventoryHandAnimation(invloc1, val))
25 return val;
26
27 if (invloc1.GetType() == InventoryLocationType.ATTACHMENT /*|| src.GetType() == InventoryLocationType.HANDS*/)
28 {
29 //return WeaponHideShowTypes.HIDESHOW_SLOT_KNIFEBACK;
30 switch (invloc1.GetSlot())
31 {
32 case InventorySlots.SHOULDER:
33 {
34 if (invloc1.GetItem() && invloc1.GetItem().IsWeapon())
35 return WeaponHideShowTypes.HIDESHOW_SLOT_RFLLEFTBACK;
36 else if (invloc1.GetItem() && invloc1.GetItem().IsOneHandedBehaviour())
37 return WeaponHideShowTypes.HIDESHOW_SLOT_1HDLEFTBACK;
38 return WeaponHideShowTypes.HIDESHOW_SLOT_2HDLEFTBACK;
39 }
40 case InventorySlots.MELEE:
41 {
42 if (invloc1.GetItem() && invloc1.GetItem().IsWeapon())
43 return WeaponHideShowTypes.HIDESHOW_SLOT_RFLRIGHTBACK;
44 else if (invloc1.GetItem() && invloc1.GetItem().IsOneHandedBehaviour())
45 return WeaponHideShowTypes.HIDESHOW_SLOT_1HDRIGHTBACK;
46 return WeaponHideShowTypes.HIDESHOW_SLOT_2HDRIGHTBACK;
47 }
48 case InventorySlots.PISTOL:
49 {
50 EntityAI parent_item = invloc1.GetParent(); // belt
51 Man owner;
52 if (parent_item)
53 owner = parent_item.GetHierarchyRootPlayer(); // player
54 if (!owner)
55 return -1;
56
57 EntityAI item1 = owner.GetInventory().FindAttachment(InventorySlots.HIPS);
58 EntityAI item2 = parent_item.GetHierarchyParent();
59 if (owner && item1 == item2) // is the pistol in a belt holster?
60 return WeaponHideShowTypes.HIDESHOW_SLOT_PISTOLBELT;
61 return WeaponHideShowTypes.HIDESHOW_SLOT_PISTOLCHEST;
62 }
63 case InventorySlots.KNIFE:
64 return WeaponHideShowTypes.HIDESHOW_SLOT_KNIFEBACK;
65
66 /*case InventorySlots.VEST:
67 case InventorySlots.FEET:
68 case InventorySlots.BODY:
69 case InventorySlots.LEGS:
70 case InventorySlots.BACK:
71 case InventorySlots.HIPS:
72 case InventorySlots.HEADGEAR:
73 return WeaponHideShowTypes.HIDESHOW_SLOT_INVENTORY;*/
74
75 default:
76 return WeaponHideShowTypes.HIDESHOW_SLOT_INVENTORY;
77 //Print("[hndfsm] SlotToAnimType - not animated slot in src_loc=" + InventoryLocation.DumpToStringNullSafe(invloc1));
78 };
79 //
80 //if (InventorySlots.GetSlotIdFromString("Pistol"))
81 }
82 else if (invloc1.GetType() == InventoryLocationType.CARGO)
83 {
84 if (invloc1.GetItem() && (invloc1.GetItem().GetInventory().HasInventorySlot(InventorySlots.SHOULDER) || invloc1.GetItem().GetInventory().HasInventorySlot(InventorySlots.MELEE)))
85 {
86 //Print("Special inventory anim");
87 if (invloc1.GetItem() && invloc1.GetItem().IsWeapon())
88 return WeaponHideShowTypes.HIDESHOW_SLOT_RFLRIGHTBACK;
89 else if (invloc1.GetItem() && invloc1.GetItem().IsOneHandedBehaviour())
90 return WeaponHideShowTypes.HIDESHOW_SLOT_1HDRIGHTBACK;
91 return WeaponHideShowTypes.HIDESHOW_SLOT_2HDRIGHTBACK;
92 }
93 //Print("Default inventory anim");
94 return WeaponHideShowTypes.HIDESHOW_SLOT_INVENTORY; //default item animation
95 }
96 return -1;
97}
98
100{
101 if (player.IsInTransport())
102 return false;
103 if (src.GetType() == InventoryLocationType.GROUND)
104 return false;
105
106 if (src.GetItem().GetHierarchyRootPlayer() == player)
107 {
109 if (animType != -1)
110 {
111 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfTakeToHands - selected animType=" + animType + " for item=" + src.GetItem());
112 return true;
113 }
114 }
115 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfTakeToHands - no animation");
116 return false;
117}
118
120{
121 if (player.IsInTransport())
122 return false;
123
124 if (src.GetItem().GetHierarchyRootPlayer() == player)
125 {
127 if (animType != -1)
128 {
129 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfMoveFromHands guard - selected animType=" + animType + " for item=" + src.GetItem());
130 return true;
131 }
132 }
133 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfMoveFromHands - no animation");
134 return false;
135}
136
138{
139 if (player.IsInTransport())
140 return false;
141
143
144 if (old_src.GetItem().GetHierarchyRootPlayer() == player || new_src.GetItem().GetHierarchyRootPlayer() == player)
145 {
148 //Print("animType1 = " + animType1);
149 //Print("animType2 = " + animType2);
150 if (animType1 != -1 && animType2 != -1)
151 {
152 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfForceSwapInHands guard - selected animType1=" + animType1 + " animType2=" + animType2 + " for old_item=" + old_src.GetItem() + " for new_item=" + new_src.GetItem());
153 return true;
154 }
155 /*else if (animType1 != -1 || animType2 != -1) //HACK
156 {
157 animType1 = -1;
158 animType2 = -1;
159 return false;
160 }*/
161 }
162 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] SelectAnimationOfForceSwapInHands - no animation");
163 return false;
164}
165
166
167class HandSelectAnimationOfTakeToHandsEvent extends HandGuardBase
168{
170
172 {
173 int animType = -1;
174 if (SelectAnimationOfTakeToHands(e.m_Player, e.GetSrc(), e.GetDst(), animType))
175 {
176 e.m_AnimationID = animType;
177 return true;
178 }
179 return false;
180 }
181};
182
183class HandSelectAnimationOfMoveFromHandsEvent extends HandGuardBase
184{
185 protected Man m_Player;
186
191
193 {
194 EntityAI eai = m_Player.GetHumanInventory().GetEntityInHands();
195 if (eai)
196 {
198 if (eai.GetInventory().GetCurrentInventoryLocation(src))
199 {
200 if (e.m_IsJuncture == false && e.m_IsRemote == false)
201 {
203 {
205 hndDebugPrint("[hndfsm] HandSelectAnimationOfMoveFromHandsEvent - rejected");
206
207 return false;
208 }
209 }
210
211 int animType = -1;
212 if (SelectAnimationOfMoveFromHands(e.m_Player, src, e.GetDst(), animType))
213 {
214 e.m_AnimationID = animType;
215 return true;
216 }
217 return false;
218 }
219 }
220 return false;
221 }
222};
223
225{
226 protected Man m_Player;
227
229
231 {
233 if (es)
234 return SelectAnimationOfForceSwapInHands(e.m_Player, es.m_Src, es.m_Src2, es.m_Dst, es.m_Dst2, animType1, animType2);
235 Error("HandSelectAnimationOfForceSwapInHandsEvent - not an swap event");
236 return false;
237 }
238
240 {
241 HandEventForceSwap es = HandEventForceSwap.Cast(e);
242 if (es)
243 {
245 hndDebugPrint("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent FSwap e=" + e.DumpToString());
246
247 if (!es.m_Src2.IsValid() || !es.m_Src.IsValid())
248 {
249 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - invalid item source");
250 return false;
251 }
252
253 bool allow = e.m_IsJuncture || e.m_IsRemote;
254 if (allow == false)
255 {
256 if (GameInventory.CanSwapEntitiesEx(es.GetSrc().GetItem(), es.m_Src2.GetItem()))
257 {
258 allow = true; // allow if ordinary swap
259 }
260 else if (es.m_Dst2)
261 {
262 if (GameInventory.CanForceSwapEntitiesEx(es.GetSrc().GetItem(), es.m_Dst, es.m_Src2.GetItem(), es.m_Dst2) == false)
263 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - no room at dst=" + InventoryLocation.DumpToStringNullSafe(es.m_Dst2));
264 else
265 allow = true;
266 }
267 }
268
269 if (allow)
270 {
271 int animType1 = -1;
272 int animType2 = -1;
273 if (ProcessSwapEvent(e, animType1, animType2))
274 {
275 e.m_AnimationID = animType1;
276 es.m_Animation2ID = animType2;
277 return true;
278 }
279 }
280 else
281 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - m_HasRoomGuard.GuardCondition failed");
282 }
283 else
284 Error("[hndfsm] HandSelectAnimationOfForceSwapInHandsEvent - not a swap event");
285 return false;
286 }
287};
288
290{
292 {
294 if (es)
295 {
296 int animType1 = -1;
297 int animType2 = -1;
298 if (ProcessSwapEvent(e, animType1, animType2))
299 {
300 e.m_AnimationID = animType1;
301 es.m_Animation2ID = animType2;
302 return true;
303 }
304 }
305 else
306 Error("[hndfsm] HandSelectAnimationOfSwapInHandsEvent - not a swap event");
307 return false;
308 }
309};
310
DayZPlayer m_Player
Definition Hand_Events.c:42
bool SelectAnimationOfMoveFromHands(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst, out int animType)
int SlotToAnimType(notnull Man player, notnull InventoryLocation src, InventoryLocation dst=null)
bool SelectAnimationOfTakeToHands(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst, out int animType)
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)
void hndDebugPrint(string s)
Definition HandFSM.c:1
InventoryLocationType
types of Inventory Location
script counterpart to engine's class Inventory
Definition Inventory.c:79
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition Inventory.c:610
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition Inventory.c:645
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...
Abstracted event, not to be used, only inherited.
TODO(kumarjac): This guard is unused but it has a fault and doesn't conform with maximimal/minimal ch...
Definition Hand_Guards.c:7
void HandSelectAnimationOfTakeToHandsEvent(Man p=null)
void HandSelectAnimationOfForceSwapInHandsEvent(Man p=NULL)
void HandSelectAnimationOfMoveFromHandsEvent(Man p=null)
bool ProcessSwapEvent(notnull HandEventBase e, out int animType1, out int animType2)
override bool GuardCondition(HandEventBase e)
override bool GuardCondition(HandEventBase e)
InventoryLocation.
static string DumpToStringNullSafe(InventoryLocation loc)
provides access to slot configuration
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
WeaponHideShowTypes
Definition human.c:910