342 {
344 return true;
345
347 return true;
348
349 bool success = true;
350 InventoryLocation oldMagTargetInventoryLocation = NULL;
351 InventoryLocation targetInventoryLocation = NULL;
352 InventoryLocation handInventoryLocation = NULL;
353
354 PlayerBase player = action_data.
m_Player;
355 AttachMagazineActionData am_action_data = AttachMagazineActionData.Cast(action_data);
356
357 Weapon_Base wpn = Weapon_Base.Cast(action_data.
m_MainItem);
358 int muzzle_index = wpn.GetCurrentMuzzle();
359
360 Magazine new_mag = Magazine.Cast(action_data.
m_Target.GetObject());
361
362 if (am_action_data.m_oldMagazine)
363 {
364 oldMagTargetInventoryLocation = new InventoryLocation;
365 if ( action_data.
m_Player.GetInventory().HasInventoryReservation( am_action_data.m_oldMagazine, am_action_data.m_ilOldMagazine) )
366 {
367 success = false;
368 }
369 else
370 {
371 player.GetInventory().AddInventoryReservationEx(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine,GameInventory.c_InventoryReservationTimeoutMS);
372 }
373 }
374
375 if (success)
376 {
377 targetInventoryLocation = new InventoryLocation;
378 targetInventoryLocation.
SetAttachment( wpn, new_mag, InventorySlots.MAGAZINE);
379 if ( action_data.
m_Player.GetInventory().HasInventoryReservation( new_mag, targetInventoryLocation) )
380 {
381 success = false;
382 if (am_action_data.m_oldMagazine)
383 {
384 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
385 }
386 }
387 else
388 {
389 action_data.
m_Player.GetInventory().AddInventoryReservationEx( new_mag, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
390 }
391 }
392
393 if (success)
394 {
395 handInventoryLocation = new InventoryLocation;
397
398 if ( action_data.
m_Player.GetInventory().HasInventoryReservation( wpn, handInventoryLocation) )
399 {
400 if (am_action_data.m_oldMagazine)
401 {
402 player.GetInventory().ClearInventoryReservation(am_action_data.m_oldMagazine,am_action_data.m_ilOldMagazine);
403 }
404 player.GetInventory().ClearInventoryReservation(new_mag, targetInventoryLocation);
405 success = false;
406 }
407 else
408 {
409 action_data.
m_Player.GetInventory().AddInventoryReservationEx( wpn, handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
410 }
411 }
412
413 if ( success )
414 {
415 if (am_action_data.m_ilOldMagazine)
417
418 if (targetInventoryLocation)
420
421 if (handInventoryLocation)
423 }
424
425 return success;
426 }
ref ActionTarget m_Target
ref array< ref InventoryLocation > m_ReservedInventoryLocations
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
sets current inventory location type to Attachment with slot id set to <slotId>