30 protected int m_BurstOption;
81 if(
m_player.GetEntityInHands() != wpn )
87 return !wpn.IsCoolDown();
96 if (
m_player.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);
122 int muzzleIndex = wpn.GetCurrentMuzzle();
124 if (wpn.CanAttachMagazine(muzzleIndex, mag))
137 if (
m_player.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);
163 int muzzleIndex = wpn.GetCurrentMuzzle();
166 if( !
Class.
CastTo(mag2, wpn.GetMagazine(muzzleIndex)) )
185 if (
m_player.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.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++)
236 if (
m_player.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++)
265 if (wpn.HasInternalMagazine(i))
267 if ((wpn.GetInternalMagazineCartridgeCount(i)) < wpn.GetInternalMagazineMaxCartridgeCount(i))
273 if (wpn.IsChamberFiredOut(i))
291 if(
m_player.GetEntityInHands() != wpn)
294 if( wpn.IsDamageDestroyed())
300 if ( reservationCheck &&
m_player.GetInventory().HasInventoryReservation(wpn, null))
304 if( !wpn.IsJammed() )
315 if(
m_player.GetEntityInHands() != wpn)
321 if( reservationCheck &&
m_player.GetInventory().HasInventoryReservation(wpn, null))
345 weapon.GetInventory().GetCurrentInventoryLocation(ilWeapon);
453 int actual_time =
g_Game.GetTime();
487 int mi = wpn.GetCurrentMuzzle();
488 if ( wpn.IsChamberFiredOut(mi) || wpn.IsJammed() || wpn.IsChamberEmpty(mi) )
490 wpn.ProcessWeaponEvent(
new WeaponEventTrigger(
m_player));
496 wpn.ProcessWeaponEvent(
new WeaponEventTriggerToJam(
m_player));
500 wpn.ProcessWeaponEvent(
new WeaponEventTrigger(
m_player));
507 return m_BurstOption;
510 void SetBurstOption(
int value)
512 m_BurstOption = value;
587 int AcknowledgmentID;
588 pCtx.
Read(AcknowledgmentID);
604 weapon.GetInventory().GetCurrentInventoryLocation(ilWeapon);
636 bool accepted =
false;
656 mi = wpn.GetCurrentMuzzle();
662 if ( !ctx.
Read(mag) )
668 slotID = wpn.GetSlotFromMuzzleIndex(mi);
671 if(
g_Game.AddInventoryJunctureEx(
m_player, mag, il,
false, 10000) )
679 if ( !ctx.
Read(mag) )
689 if ( !wpn.GetMagazine(mi) )
711 Magazine det_mag = wpn.GetMagazine(mi);
712 mag = Magazine.Cast(il.
GetItem());
713 if ( !det_mag || ( mag != det_mag) )
801 if ( !
g_Game.IsMultiplayer() )
848 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventContinuousLoadBulletEnd(
m_player) );
853 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventUnjam(
m_player, NULL) );
858 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventMechanism(
m_player, NULL) );
863 m_player.GetDayZPlayerInventory().PostWeaponEvent(
new WeaponEventSetNextMuzzleMode(
m_player, NULL) );
921 if (!
g_Game.IsMultiplayer())
935 float actual_chance_to_jam;
1084 if (!mag || mag.IsRuined() || (mag.GetHierarchyParent() && mag.GetHierarchyParent().IsWeapon()) )
1091 if(!mag.GetHierarchyParent() || mag.GetHierarchyParent().GetInventory().AreChildrenAccessible())
1093 if (mag.GetAmmoCount() > 0)
1105 for (
int i = startIdx; i < count; ++i)
1108 if (mag && mag.GetAmmoCount() > 0 && (!mag.GetHierarchyParent() || mag.GetHierarchyParent().GetInventory().AreChildrenAccessible()))
1128 MagazineStorage sMag = MagazineStorage.Cast(mag);
1179 MagazineStorage sMag = MagazineStorage.Cast(mag);
1204 return mag1.GetAmmoCount() - mag2.GetAmmoCount();
1211 int low_mag1, high_mag1;
1212 int low_mag2, high_mag2;
1218 mag.GetNetworkID(low_mag1,high_mag1);
1219 for( j = 0; j < magazines.Count(); j++)
1221 magazines.Get(j).GetNetworkID(low_mag2,high_mag2);
1222 if(low_mag1 > low_mag2)
1226 else if (low_mag1 == low_mag2)
1228 if( high_mag1 > high_mag2 )
1234 magazines.InsertAt(mag,j);
1243 pile.GetNetworkID(low_mag1,high_mag1);
1244 for( j = 0; j < magazines_piles.Count(); j++)
1246 magazines_piles.Get(j).GetNetworkID(low_mag2,high_mag2);
1247 if(low_mag1 > low_mag2)
1251 else if (low_mag1 == low_mag2)
1253 if( high_mag1 > high_mag2 )
1259 magazines_piles.InsertAt(pile,j);
1347 int muzzleIndex = wpn.GetCurrentMuzzle();
1348 Magazine old_mag = Magazine.Cast(wpn.GetMagazine(muzzleIndex));
1356 new_mag.GetInventory().GetCurrentInventoryLocation(new_il);
1357 new_il.SetItem(old_mag);
1365 new_il.SetGroundEx( old_mag,
m_player.GetPosition(), dir);
const int AT_WPN_DETACH_MAGAZINE
const int AT_WPN_LOAD_MULTI_BULLETS_END
const int AT_WPN_ATTACH_MAGAZINE
const int AT_WPN_LOAD_BULLET
const int AT_WPN_SWAP_MAGAZINE
const int AT_WPN_LOAD_MULTI_BULLETS_START
const int AT_WPN_EJECT_BULLET
const int AT_WPN_SET_NEXT_MUZZLE_MODE
Super root of all classes in Enforce script.
static void SendWeaponJamChance(DayZPlayer pPlayer, float jamChance)
static const int SJ_WEAPON_ACTION_ACK_REJECT
static const int SJ_WEAPON_ACTION_ACK_ACCEPT
static const int SJ_WEAPON_SET_JAMMING_CHANCE
static void SendWeaponActionAcknowledgment(DayZPlayer pPlayer, int AckID, bool accept)
bool ClearInventoryReservationEx(EntityAI item, InventoryLocation dst)
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
const int c_InventoryReservationTimeoutMS
reservations
static proto native bool HasInventoryReservation(EntityAI item, InventoryLocation dst)
Internally: HasInventoryReservationEx(item, dst, FindInventoryReservationMode.LEGACY,...
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
bool AddInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
script counterpart to engine's class Inventory
proto native void SetInitState(int pFrameIndex)
proto native bool IsValid()
verify current set inventory location
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
proto native EntityAI GetParent()
returns parent of current inventory location
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
sets current inventory location type to Attachment with slot id set to <slotId>
bool ReadFromContext(ParamsReadContext ctx)
proto native EntityAI GetItem()
returns item of current inventory location
provides access to slot configuration
proto bool Write(void value_out)
proto bool Read(void value_in)
override bool CanEjectBullet()
override bool CanChamberBullet(int muzzleIndex, Magazine mag)
bool EjectBulletVerified(ActionBase control_action=NULL)
string GetCurrentModeName()
void SetSutableMagazines()
bool CanUnjam(Weapon_Base wpn, bool reservationCheck=true)
void DelayedRefreshAnimationState(int delay)
bool CanEjectBulletVerified()
bool CanLoadBullet(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
bool CanAttachMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
ActionBase m_ControlAction
int m_PendingWeaponActionAcknowledgmentID
ref array< Magazine > m_MagazinePilesInInventory
bool AttachMagazine(Magazine mag, ActionBase control_action=NULL)
int m_ForceEjectBulletTimestamp
bool LoadBullet(Magazine mag, ActionBase control_action=NULL)
bool CanEjectBullet(Weapon_Base wpn, bool reservationCheck=true)
bool LoadMultiBullet(Magazine mag, ActionBase control_action=NULL)
bool PrepareInventoryLocationForMagazineSwap(notnull Weapon_Base wpn, notnull Magazine new_mag, out InventoryLocation new_il)
Magazine m_PendingTargetMagazine
bool DetachMagazine(InventoryLocation invLoc, ActionBase control_action=NULL)
void LoadMultiBulletStop()
bool CanLoadMultipleBullet(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
int m_LastAcknowledgmentID
void SortMagazineAfterLoad()
bool m_WaitToSyncJamChance
ref array< Magazine > m_SuitableMagazines
void RefreshAnimationState()
bool CanSwapMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
Magazine GetNextPreparedMagazine(out int startIdx)
Weapon_Base m_WeaponInHand
bool SwapMagazine(Magazine mag, ActionBase control_action=NULL)
const float MAX_DROP_MAGAZINE_DISTANCE_SQ
void Update(float deltaT)
const int FORCE_EJECT_BULLET_TIMEOUT
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
ref array< MagazineStorage > m_MagazineStorageInInventory
bool CanFire(Weapon_Base wpn)
bool CanDetachMagazine(Weapon_Base wpn, Magazine mag, bool reservationCheck=true)
void OnSyncJuncture(int pJunctureID, ParamsReadContext pCtx)
void SetEjectBulletTryTimestamp()
Magazine m_PreparedMagazine
int CompareMagazinesSuitability(Magazine mag1, Magazine mag2)
bool Unjam(ActionBase control_action=NULL)
void SetRunning(bool value)
void WeaponManager(PlayerBase player)
ref InventoryLocation m_PendingInventoryLocation
bool SwapMagazineEx(Magazine mag, InventoryLocation invLoc, ActionBase control_action=NULL)
void Fire(Weapon_Base wpn)
ref InventoryLocation m_TargetInventoryLocation
bool EjectBullet(ActionBase control_action=NULL)
int m_PendingWeaponAction
bool StartAction(int action, Magazine mag, InventoryLocation il, ActionBase control_action=NULL)
MagazineStorage m_MagazineInHand
Magazine GetPreparedMagazine()
void OnMagazineDetach(Magazine mag)
int m_AnimationRefreshCooldown
void OnMagazineAttach(Magazine mag)
void OnMagazineInventoryExit(Magazine mag)
void OnMagazineInventoryEnter(Magazine mag)
void StartPendingAction()
bool InventoryReservation(Magazine mag, InventoryLocation invLoc)
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Serializer ParamsReadContext
void Error(string err)
Messagebox with error message.
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.