3 const float MAX_DROP_MAGAZINE_DISTANCE_SQ = 4;
30 protected int m_BurstOption;
81 if(
m_player.GetHumanInventory().GetEntityInHands() != wpn )
87 return !wpn.IsCoolDown();
96 if (
m_player.GetHumanInventory().GetEntityInHands() != wpn )
99 if ( wpn.IsDamageDestroyed())
108 if ( reservationCheck && (
m_player.GetInventory().HasInventoryReservation(wpn, null) ||
m_player.GetInventory().HasInventoryReservation(mag, null)))
114 mag.GetInventory().GetCurrentInventoryLocation(invLoc);
119 if (
Class.CastTo(wnp2, invLoc.GetParent()) )
122 int muzzleIndex = wpn.GetCurrentMuzzle();
124 if (wpn.CanAttachMagazine(muzzleIndex, mag))
137 if (
m_player.GetHumanInventory().GetEntityInHands() != wpn )
140 if ( mag.IsDamageDestroyed() || wpn.IsDamageDestroyed())
149 if ( reservationCheck && (
m_player.GetInventory().HasInventoryReservation(wpn, null) ||
m_player.GetInventory().HasInventoryReservation(mag, null)))
156 mag.GetInventory().GetCurrentInventoryLocation(invLoc);
160 if(
Class.CastTo(wnp2, invLoc.GetParent()) )
163 int muzzleIndex = wpn.GetCurrentMuzzle();
166 if( !
Class.CastTo(mag2, wpn.GetMagazine(muzzleIndex)) )
185 if (
m_player.GetHumanInventory().GetEntityInHands() != wpn )
188 if ( mag.GetHierarchyParent() != wpn )
194 if ( reservationCheck && (
m_player.GetInventory().HasInventoryReservation(wpn, null) ||
m_player.GetInventory().HasInventoryReservation(mag, null)))
205 if (
m_player.GetHumanInventory().GetEntityInHands() != wpn)
208 if (mag.IsDamageDestroyed() || wpn.IsDamageDestroyed())
217 if (reservationCheck && (
m_player.GetInventory().HasInventoryReservation(wpn, null) ||
m_player.GetInventory().HasInventoryReservation(mag, null)))
220 for (
int i = 0; i < wpn.GetMuzzleCount(); i++)
222 if (wpn.CanChamberBullet(i, mag))
236 if (
m_player.GetHumanInventory().GetEntityInHands() != wpn)
239 if (mag.IsDamageDestroyed() || wpn.IsDamageDestroyed())
248 if (reservationCheck && (
m_player.GetInventory().HasInventoryReservation(wpn, null) ||
m_player.GetInventory().HasInventoryReservation(mag, null)))
252 bool fireout =
false;
253 for (
int i = 0; i < wpn.GetMuzzleCount(); i++)
258 if (wpn.CanChamberBullet(i, mag) )
265 if (wpn.HasInternalMagazine(i))
267 if ((wpn.GetInternalMagazineCartridgeCount(i)) < wpn.GetInternalMagazineMaxCartridgeCount(i))
273 if (wpn.IsChamberFiredOut(i))
291 if(
m_player.GetHumanInventory().GetEntityInHands() != wpn)
294 if( wpn.IsDamageDestroyed())
300 if ( reservationCheck &&
m_player.GetInventory().HasInventoryReservation(wpn, null))
304 if( !wpn.IsJammed() )
315 if(
m_player.GetHumanInventory().GetEntityInHands() != wpn)
321 if( reservationCheck &&
m_player.GetInventory().HasInventoryReservation(wpn, null))
324 if( !wpn.CanEjectBullet() )
344 weapon.GetInventory().GetCurrentInventoryLocation(ilWeapon);
345 if (
m_player.GetInventory().HasInventoryReservation(weapon, ilWeapon) )
357 if (
m_player.GetInventory().HasInventoryReservation(invLoc.GetItem(),invLoc) )
359 m_player.GetInventory().ClearInventoryReservationEx(weapon, ilWeapon);
376 m_player.GetInventory().ClearInventoryReservationEx(weapon, ilWeapon);
379 m_player.GetInventory().ClearInventoryReservationEx(invLoc.GetItem(), invLoc);
410 if (PrepareInventoryLocationForMagazineSwap(
m_WeaponInHand, mag, il) )
439 return StartAction(
AT_WPN_UNJAM, NULL, NULL, control_action);
486 int mi = wpn.GetCurrentMuzzle();
487 if ( wpn.IsChamberFiredOut(mi) || wpn.IsJammed() || wpn.IsChamberEmpty(mi) )
489 wpn.ProcessWeaponEvent(
new WeaponEventTrigger(
m_player));
495 wpn.ProcessWeaponEvent(
new WeaponEventTriggerToJam(
m_player));
499 wpn.ProcessWeaponEvent(
new WeaponEventTrigger(
m_player));
506 return m_BurstOption;
509 void SetBurstOption(
int value)
511 m_BurstOption = value;
519 private void Synchronize( )
586 int AcknowledgmentID;
587 pCtx.Read(AcknowledgmentID);
602 weapon.GetInventory().GetCurrentInventoryLocation(ilWeapon);
603 m_player.GetInventory().ClearInventoryReservationEx(
m_player.GetItemInHands(),ilWeapon);
634 bool accepted =
false;
654 mi = wpn.GetCurrentMuzzle();
660 if ( !ctx.Read(mag) )
666 slotID = wpn.GetSlotFromMuzzleIndex(mi);
668 il.SetAttachment(wpn,mag,slotID);
669 if(
GetGame().AddInventoryJunctureEx(
m_player, mag, il,
false, 10000) )
677 if ( !ctx.Read(mag) )
681 if (!il.ReadFromContext(ctx))
687 if ( !wpn.GetMagazine(mi) )
700 if ( !il.ReadFromContext(ctx) )
709 Magazine det_mag = wpn.GetMagazine(mi);
710 mag = Magazine.Cast(il.GetItem());
711 if ( !det_mag || ( mag != det_mag) )
714 if (
GetGame().AddInventoryJunctureEx(
m_player, il.GetItem(), il,
true, 10000))
781 StartPendingAction();
799 if ( !
GetGame().IsMultiplayer() )
807 void StartPendingAction()
846 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventContinuousLoadBulletEnd(
m_player) );
851 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventUnjam(
m_player, NULL) );
856 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventMechanism(
m_player, NULL) );
861 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventSetNextMuzzleMode(
m_player, NULL) );
877 void SetRunning(
bool value)
887 void Update(
float deltaT )
901 SetSutableMagazines();
915 RefreshAnimationState();
919 if (!
GetGame().IsMultiplayer())
933 float actual_chance_to_jam;
945 StartPendingAction();
987 SetSutableMagazines();
995 void OnWeaponActionEnd()
1013 m_player.GetInventory().ClearInventoryReservationEx(
m_player.GetItemInHands(),il);
1040 void DelayedRefreshAnimationState(
int delay)
1046 RefreshAnimationState();
1052 void RefreshAnimationState()
1060 HumanCommandWeapons hcw =
m_player.GetCommandModifier_Weapons();
1063 hcw.SetInitState(state.m_animState);
1074 Magazine GetPreparedMagazine()
1080 if (!mag || mag.IsRuined() || (mag.GetHierarchyParent() && mag.GetHierarchyParent().IsWeapon()) )
1087 if(!mag.GetHierarchyParent() || mag.GetHierarchyParent().GetInventory().AreChildrenAccessible())
1089 if (mag.GetAmmoCount() > 0)
1097 Magazine GetNextPreparedMagazine( out
int startIdx )
1101 for (
int i = startIdx; i < count; i++)
1104 if (mag && mag.GetAmmoCount() > 0 && (!mag.GetHierarchyParent() || mag.GetHierarchyParent().GetInventory().AreChildrenAccessible()))
1113 void OnMagazineInventoryEnter(Magazine mag)
1124 MagazineStorage sMag = MagazineStorage.Cast(mag);
1137 if(CompareMagazinesSuitability(s_mag_i,sMag)<0)
1142 SetSutableMagazines();
1160 if(CompareMagazinesSuitability(mag_i,mag)<0)
1166 SetSutableMagazines();
1171 void OnMagazineInventoryExit(Magazine mag)
1175 MagazineStorage sMag = MagazineStorage.Cast(mag);
1188 void OnMagazineAttach(Magazine mag)
1190 OnMagazineInventoryExit(mag);
1193 void OnMagazineDetach(Magazine mag)
1195 OnMagazineInventoryEnter(mag);
1198 int CompareMagazinesSuitability( Magazine mag1, Magazine mag2 )
1200 return mag1.GetAmmoCount() - mag2.GetAmmoCount();
1203 void SortMagazineAfterLoad()
1207 int low_mag1, high_mag1;
1208 int low_mag2, high_mag2;
1214 mag.GetNetworkID(low_mag1,high_mag1);
1215 for( j = 0; j < magazines.Count(); j++)
1217 magazines.Get(j).GetNetworkID(low_mag2,high_mag2);
1218 if(low_mag1 > low_mag2)
1222 else if (low_mag1 == low_mag2)
1224 if( high_mag1 > high_mag2 )
1230 magazines.InsertAt(mag,j);
1239 pile.GetNetworkID(low_mag1,high_mag1);
1240 for( j = 0; j < magazines_piles.Count(); j++)
1242 magazines_piles.Get(j).GetNetworkID(low_mag2,high_mag2);
1243 if(low_mag1 > low_mag2)
1247 else if (low_mag1 == low_mag2)
1249 if( high_mag1 > high_mag2 )
1255 magazines_piles.InsertAt(pile,j);
1261 SetSutableMagazines();
1264 void SetSutableMagazines()
1331 string GetCurrentModeName()
1343 int muzzleIndex = wpn.GetCurrentMuzzle();
1344 Magazine old_mag = Magazine.Cast(wpn.GetMagazine(muzzleIndex));
1352 new_mag.GetInventory().GetCurrentInventoryLocation(new_il);
1353 new_il.SetItem(old_mag);
1361 new_il.SetGroundEx( old_mag,
m_player.GetPosition(), dir);