11enum WeaponWithAmmoFlags
41 const int SAMF_DEFAULT = WeaponWithAmmoFlags.CHAMBER | WeaponWithAmmoFlags.MAX_CAPACITY_MAG;
43 const int SAMF_RNG = WeaponWithAmmoFlags.CHAMBER_RNG | WeaponWithAmmoFlags.QUANTITY_RNG;
93 if ( ConfigIsExisting(
"simpleHiddenSelections") )
96 ConfigGetTextArray(
"simpleHiddenSelections",selectionNames);
100 int bulletIndex = selectionNames.Find(
"bullet");
101 if ( bulletIndex != -1 )
105 for (
int i = 2; i < 100; i++)
107 bulletIndex = selectionNames.Find(
string.Format(
"bullet%1",i));
108 if (bulletIndex != -1)
145 m_fsm.SetInitialState(initState);
148 SetGroundAnimFrameIndex(initState.m_animState);
173 float baseWeight = GetInventoryAndCargoWeight(forceRecalc);
176 string bulletTypeName, ammoTypeName;
178 int muzzleCount = GetMuzzleCount();
180 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
183 data1.
SetCalcDetails(
"TWPN: " + m_ConfigWeight+
"(item weight) + " + baseWeight +
"(contents weight)" );
186 for (
int muzzleIndex = 0; muzzleIndex < muzzleCount; muzzleIndex++)
189 if (!IsChamberEmpty(muzzleIndex))
191 ammoTypeName = GetChamberAmmoTypeName(muzzleIndex);
192 ammoWeight +=
g_Game.ConfigGetFloat(
string.Format(
"CfgMagazines %1 weight", ammoTypeName));
195 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
198 data2.
AddCalcDetails(
g_Game.ConfigGetFloat(
"CfgMagazines " + ammoTypeName +
" weight").ToString() +
"(chamber weight)");
204 if (HasInternalMagazine(muzzleIndex))
207 float debugInternalMagWeight;
209 int cartridgeCount = GetInternalMagazineCartridgeCount(muzzleIndex);
210 for (
int cartridgeIndex = 0; cartridgeIndex < cartridgeCount; cartridgeIndex++)
212 GetInternalMagazineCartridgeInfo(muzzleIndex, cartridgeIndex, ammoDamage, bulletTypeName);
215 debugInternalMagWeight +=
g_Game.ConfigGetFloat(
"CfgMagazines " + ammoTypeName +
" weight");
220 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
229 return ammoWeight + baseWeight + GetConfigWeightModified();
247 for (
int i = 0; i < count; ++i)
318 m_fsm.ProcessAbortEvent(e, aa);
324 return CanChamberFromMag(muzzleIndex, mag) && (!
IsChamberFull(muzzleIndex) ||
IsChamberFiredOut(muzzleIndex) || !IsInternalMagazineFull(muzzleIndex));
330 SetGroundAnimFrameIndex(state);
339 void EEFired(
int muzzleType,
int mode,
string ammoType)
341 if ( !
GetGame().IsDedicatedServer() )
343 ItemBase suppressor = GetAttachedSuppressor();
346 ItemBase.PlayFireParticles(
this, muzzleType, ammoType,
this, suppressor,
"CfgWeapons" );
351 ItemBase.PlayFireParticles(
this, muzzleType, ammoType, suppressor, NULL,
"CfgVehicles" );
352 suppressor.IncreaseOverheating(
this, ammoType,
this, suppressor,
"CfgVehicles");
367 #ifdef DIAG_DEVELOPER
368 MiscGameplayFunctions.UnlimitedAmmoDebugCheck(
this);
392 SelectionBulletShow();
402 SelectionBulletHide();
411 int level = GetHealthLevel();
423 string chamberedAmmoTypeName;
424 float chamberedAmmoDmg;
426 if ( GetCartridgeInfo(0, chamberedAmmoDmg, chamberedAmmoTypeName) )
428 EffectBulletShow(0, chamberedAmmoDmg, chamberedAmmoTypeName);
431 SelectionBulletShow();
436 SelectionBulletHide();
462 int nMuzzles = GetMuzzleCount();
463 for (
int i = 0; i < nMuzzles; ++i)
470 GetCartridgeInfo(i, damage, ammoTypeName);
471 EffectBulletShow(i, damage, ammoTypeName);
479 Magazine mag = GetMagazine(i);
489 if ( !super.OnStoreLoad(ctx, version) )
495 int current_muzzle = 0;
496 if (!ctx.
Read(current_muzzle))
498 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read current muzzle!");
502 if (current_muzzle >= GetMuzzleCount() || current_muzzle < 0)
503 Error(
"Weapon.OnStoreLoad " +
this +
" trying to set muzzle index " + current_muzzle +
" while it only has " + GetMuzzleCount() +
" muzzles!");
505 SetCurrentMuzzle(current_muzzle);
511 if (!ctx.
Read(mode_count))
513 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read mode count!");
517 for (
int m = 0; m < mode_count; ++m)
522 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read mode[" + m +
"]");
527 SetCurrentMode(m, mode);
531 if ( version >= 106 )
535 Error(
"Weapon.OnStoreLoad cannot load jamming state");
542 if (!
m_fsm.OnStoreLoad(ctx, version))
548 SetGroundAnimFrameIndex(wss.m_animState);
555 if (!ctx.
Read(dummy))
566 if (
m_fsm.SaveCurrentFSMState(ctx))
571 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon=" +
this +
" state NOT saved.");
574 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon.SaveCurrentFSMState: trying to save weapon without FSM (or uninitialized weapon) this=" +
this +
" type=" +
GetType());
581 if (
m_fsm.LoadCurrentFSMState(ctx, version))
587 state.SyncAnimState();
599 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon=" +
this +
" did not load.");
605 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon.LoadCurrentFSMState: trying to load weapon without FSM (or uninitialized weapon) this=" +
this +
" type=" +
GetType());
614 int mi = GetCurrentMuzzle();
615 Magazine mag = GetMagazine(mi);
616 bool has_mag = mag != null;
617 bool has_bullet = !IsChamberEmpty(mi);
624 super.OnStoreSave(ctx);
627 int current_muzzle = GetCurrentMuzzle();
628 ctx.
Write(current_muzzle);
631 int mode_count = GetMuzzleCount();
632 ctx.
Write(mode_count);
633 for (
int m = 0; m < mode_count; ++m)
634 ctx.
Write(GetCurrentMode(m));
639 m_fsm.OnStoreSave(ctx);
653 return m_fsm.GetInternalStateID();
664 return m_fsm.GetCurrentStableStateID();
677 int mi = GetCurrentMuzzle();
678 Magazine mag = GetMagazine(mi);
679 bool has_mag = mag != null;
680 bool has_bullet = !IsChamberEmpty(mi);
683 m_fsm.RandomizeFSMStateEx(muzzleStates, has_mag, has_jam);
693 int nMuzzles = GetMuzzleCount();
694 for (
int i = 0; i < nMuzzles; ++i)
701 else if (IsChamberEmpty(i))
704 ErrorEx(
string.Format(
"Unable to identify chamber state of muzzle %1", i));
706 muzzleStates.Insert(state);
732 ErrorEx(
string.Format(
"%1 does not exist or is not a weapon.", weaponType));
736 wpn.SpawnAmmo(magazineType, flags);
746 bool SpawnAmmo(
string magazineType =
"",
int flags = WeaponWithAmmoFlags.CHAMBER )
772 if ( GetMagazineTypeCount(0) == 0 )
774 ErrorEx(
string.Format(
"No 'magazines' config entry for %1.",
this));
779 if ( magazineType ==
"" )
781 if ( flags & WeaponWithAmmoFlags.MAX_CAPACITY_MAG)
782 magazineType = GetMaxMagazineTypeName(0);
784 magazineType = GetRandomMagazineTypeName(0);
787 EntityAI magAI = GetInventory().CreateAttachment(magazineType);
795 if (!CastTo(mag, magAI))
802 if (flags & WeaponWithAmmoFlags.QUANTITY_RNG)
806 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
807 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || chamberRng;
808 if (chamber || chamberRng)
830 if (!HasInternalMagazine(-1))
841 bool didSomething =
false;
842 int muzzCount = GetMuzzleCount();
844 bool ammoRng = ammoType ==
"";
845 bool ammoFullRng = ammoRng && (flags & WeaponWithAmmoFlags.AMMO_MAG_RNG);
848 if (ammoRng && !ammoFullRng)
849 ammoType = GetRandomChamberableAmmoTypeName(0);
852 for (
int i = 0; i < muzzCount; ++i)
854 int ammoCount = GetInternalMagazineMaxCartridgeCount(i);
857 if ( flags & WeaponWithAmmoFlags.QUANTITY_RNG )
864 for (
int j = 0; j < ammoCount; ++j)
868 ammoType = GetRandomChamberableAmmoTypeName(i);
870 PushCartridgeToInternalMagazine(i, 0, ammoType);
877 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
895 bool FillChamber(
string ammoType =
"",
int flags = WeaponWithAmmoFlags.CHAMBER )
898 int muzzCount = GetMuzzleCount();
899 bool anyEmpty =
false;
901 for (
int m = 0; m < muzzCount; ++m)
903 if (IsChamberEmpty(m))
919 bool didSomething =
false;
920 bool chamberFullRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG_SPORADIC);
921 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
922 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER);
924 if (chamber || chamberRng || chamberFullRng)
926 int amountToChamber = muzzCount;
932 bool chamberAmmoRng = (ammoType ==
"");
933 bool chamberAmmoFullRng = chamberAmmoRng && (flags & WeaponWithAmmoFlags.AMMO_CHAMBER_RNG);
936 if (chamberAmmoRng && !chamberAmmoFullRng)
937 ammoType = GetRandomChamberableAmmoTypeName(0);
939 for (
int i = 0; i < muzzCount; ++i)
942 if (!IsChamberEmpty(i))
953 if ( chamberAmmoFullRng )
954 ammoType = GetRandomChamberableAmmoTypeName(i);
957 PushCartridgeToChamber(i, 0, ammoType);
962 if (amountToChamber <= 0)
988 int ac = GetInventory().AttachmentCount();
989 int sc = GetInventory().GetAttachmentSlotsCount() + GetMuzzleCount();
990 if (ac > sc) sc = ac;
1033 if ( !
GetGame().IsDedicatedServer() )
1037 if ( fireMode == 0 )
1056 Error(
"[wpn] Weapon_Base::DelayedValidateAndRepair m_DelayedValidationTimer not initialized.");
1064 m_fsm.ValidateAndRepair();
1082 super.OnInventoryEnter(player);
1088 super.OnInventoryExit(player);
1093 super.EEItemAttached(item, slot_name);
1100 super.EEItemDetached(item, slot_name);
1107 super.EEItemLocationChanged(oldLoc, newLoc);
1112 if (newLoc.GetParent() &&
PlayerBase.CastTo(player, newLoc.GetParent()))
1148 super.OnItemLocationChanged(old_owner,new_owner);
1154 player.SetReturnToOptics(
false);
1160 player.SwitchOptics(optics,
false);
1164 if (old_owner != new_owner &&
PlayerBase.Cast(new_owner))
1172 if ( !super.CanReleaseAttachment( attachment ) )
1174 Magazine mag = Magazine.Cast(attachment);
1180 if ( player.GetItemInHands() ==
this )
1202 if (GetInventory().GetCurrentInventoryLocation(il))
1228 p.StoreInputForRemotes(ctx);
1262 if (
GetGame().ConfigIsExisting(
"cfgWeapons " +
GetType() +
" PPDOFProperties"))
1272 if (
GetGame().ConfigIsExisting(
"cfgWeapons " +
GetType() +
" Reliability ChanceToJam"))
1283 if (ConfigIsExisting(
"WeaponLength"))
1295 if (ConfigIsExisting(
"WeaponLiftCheckVerticalOffset"))
1307 if (ConfigIsExisting(
"ShoulderDistance"))
1341 vector hit_pos, hit_normal;
1349 if ( HasSelection(
"Usti hlavne") )
1354 Print(
"Error: No weapon owner, returning");
1360 player.GetMovementState(movementState);
1384 yawPitchRoll[0] = yawPitchRoll[0] + xAimHandsOffset;
1392 if (player.GetInputController().CameraIsFreeLook())
1394 if (player.m_DirectionToCursor !=
vector.
Zero)
1396 direction = player.m_DirectionToCursor;
1401 direction = MiscGameplayFunctions.GetHeadingVector(player);
1410 idx = player.GetBoneIndexByName(
"Neck");
1412 { start = player.GetPosition()[1] + 1.5; }
1414 { start = player.GetBonePositionWS(idx); }
1426 resTM[2] = direction;
1427 resTM[1] = resTM[2] * resTM[0];
1432 player.GetMovementState(hms);
1439 #ifdef DIAG_DEVELOPER
1460 const int lastIndex = 2;
1464 int lo = a * lastIndex;
1465 int hi =
Math.
Clamp(lo+1, 0, lastIndex);
1468 float t =
Math.
Clamp(a * lastIndex - lo, 0, 1);
1487 offset += stanceOffsets[stanceOffsetIndex];
1508 vector weaponEnd = weaponStart + (distance * direction);
1511 #ifdef DIAG_DEVELOPER
1516 float diagPtsRadius = 0.025;
1517 Shape.CreateSphere(
COLOR_GREEN, diagPtsShpFlgs, weaponStart, diagPtsRadius);
1518 Shape.CreateSphere(
COLOR_YELLOW, diagPtsShpFlgs, diagNoAttachEnd, diagPtsRadius);
1519 Shape.CreateSphere(
COLOR_BLUE, diagPtsShpFlgs, weaponEnd, diagPtsRadius);
1525 end = weaponEnd + ((0.1 * distance) * direction);
1530 rayParm.type = ObjIntersect.Fire;
1532 #ifdef DIAG_DEVELOPER
1545 #ifdef DIAG_DEVELOPER
1562 DbgUI.
Text(
"Intersection with no surface");
1572 float len0 = (hit_pos - start).Length();
1573 float len1 = (end - start).Length();
1574 if (len0 <= 0 || len1 <= 0)
1580 hit_fraction = len0 / len1;
1589 #ifdef DIAG_DEVELOPER
1594 #ifdef DIAG_DEVELOPER
1597 const vector epsilon =
"0 0.0002 0";
1605 if (hit_fraction != 0)
1613 bool wantsLift = wasLift;
1616 const float inThreshold = 0.002;
1618 const float outThreshold = 0.003;
1619 const float noIsctOutThreshold = 0.01;
1622 const int maxNumMissedTicks = 10;
1629 if (hit_fraction != 0)
1631 vector v1 = hit_pos - weaponEnd;
1632 vector v2 = hit_pos - end;
1636 if (!wasLift && d > inThreshold)
1640 else if (wasLift && d < -outThreshold)
1660 vector v3 = (lastLiftPosition - start).Normalized();
1661 vector v4 = (end-start).Normalized();
1672 float d3 =
vector.
Dot( lastLiftPosition - weaponEnd, (start-end).Normalized() );
1673 if (d3 < -noIsctOutThreshold)
1680 int timeSinceHit = player.GetSimulationTimeStamp() -
m_LastLiftHit;
1681 if (timeSinceHit > maxNumMissedTicks)
1703 return res.surface.IsSolid();
1713 attachment =
ItemBase.Cast(GetInventory().FindAttachment(bayonetIndex));
1717 attachment = GetAttachedSuppressor();
1722 return Math.
Max(attachment.m_ItemModelLength + attachment.m_ItemAttachOffset, 0);
1747 if (IsChamberEjectable(muzzleIndex))
1749 if (PopCartridgeFromChamber(muzzleIndex, ammoDamage, ammoTypeName))
1752 else if (GetInternalMagazineCartridgeCount(muzzleIndex) > 0)
1754 if (PopCartridgeFromInternalMagazine(muzzleIndex, ammoDamage, ammoTypeName))
1765 for (
int mi = 0; mi < src.GetMuzzleCount(); ++mi)
1767 if (!src.IsChamberEmpty(mi))
1769 if (src.GetCartridgeInfo(mi, damage, type))
1771 PushCartridgeToChamber(mi, damage, type);
1775 for (
int ci = 0; ci < src.GetInternalMagazineCartridgeCount(mi); ++ci)
1777 if (src.GetInternalMagazineCartridgeInfo(mi, ci, damage, type))
1779 PushCartridgeToInternalMagazine(mi, damage, type);
1784 int dummy_version =
int.MAX;
1829 if ( !
GetGame().IsDedicatedServer() )
1844 SelectionMagazineShow();
1852 SelectionMagazineHide();
1862 super.ProcessMeleeItemDamage();
1874 super.ProcessMeleeItemDamage();
1880 attachment.ProcessMeleeItemDamage();
1918 if (!ConfigGetBool(
"isSuicideWeapon"))
1921 return super.CanBeUsedForSuicide();
1932 Magazine mag = GetMagazine(GetCurrentMuzzle());
1944 Magazine mag = GetMagazine(GetCurrentMuzzle());
1953 SetNextMuzzleMode(muzzleIndex);
eBleedingSourceType GetType()
void wpnDebugPrint(string s)
void AddAction(typename actionName)
const int ECE_PLACE_ON_SURFACE
WeaponEventID
identifier for events. mainly for rpc purposes
FirearmActionLoadBullet FirearmActionBase FirearmActionLoadBulletQuick()
void fsmDebugSpam(string s)
InventoryLocationType
types of Inventory Location
void IncreaseOverheating(ItemBase weapon, string ammoType, ItemBase muzzle_owner, ItemBase suppressor, string config_to_search)
bool OnStoreLoad(ParamsReadContext ctx, int version)
@ AMMO_CHAMBER_RNG
Fully randomizes the ammo type instead of picking one random for all chambers (needs to have type as ...
@ CHAMBER
Chambers bullets.
@ CHAMBER_RNG_SPORADIC
Maybe chambers bullets (full random) example: 0 1 0 0 1 1.
@ MAX_CAPACITY_MAG
Instead of randomizing when type is empty, it looks for the one which has the highest capacity.
@ QUANTITY_RNG
Randomizes the quantity of the bullets in the spawned magazine.
@ CHAMBER_RNG
Maybe chambers bullets (sequential rng) example: 1 1 1 0 0 0.
@ AMMO_MAG_RNG
Fully randomizes the ammo type instead of picking one random for the entire mag (needs to have type a...
enum FSMTransition WeaponTransition
bool IsChamberFiredOut(int idx)
bool IsChamberFull(int idx)
void AbilityRecord(int a, int at)
corresponds to Human::actionTypes == CHAMBERING_ONEBULLET_CLOSED, MECHANISM_CLOSED....
int m_actionType
corresponds to Human::actions == RELOAD, MECHANISM, ...
pair ( action, actionType )
static bool MagazineTypeToAmmoType(string magazineType, out string ammoType)
Helper method.
static float GetAmmoWeightByBulletType(string bulletType)
override ScriptCallQueue GetCallQueue(int call_category)
proto native bool ClearJuncture(Man player, notnull EntityAI item)
bool AddInventoryJunctureEx(Man player, notnull EntityAI item, InventoryLocation dst, bool test_dst_occupancy, int timeout_ms)
proto native vector GetCurrentCameraDirection()
proto native void ConfigGetFloatArray(string path, out TFloatArray values)
Get array of floats from config on path.
Super root of all classes in Enforce script.
static proto bool RaycastRVProxy(notnull RaycastRVParams in, out notnull array< ref RaycastRVResult > results, array< Object > excluded=null)
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Wrapper class for managing sound through SEffectManager.
represents transition src -— event[guard]/action -—|> dst
proto native void SetMeleeBlock(bool pBlock)
this enables/disables block
proto native float GetAimingHandsOffsetUD()
returns aiming hands up/down (y) offset angle
proto native float GetBaseAimingAngleLR()
returns base aiming angle LR - without sway/offsets/...
proto native float GetAimingHandsOffsetLR()
returns aiming hands left/right (x) offset angle
proto native float GetBaseAimingAngleUD()
returns base aiming angle UD - without sway/offsets/...
int m_iStanceIdx
current command's id
float m_fLeaning
current movement (0 idle, 1 walk, 2-run, 3-sprint), only if the command has a movement
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetType()
returns type of InventoryLocation
bool AllowsDOF()
returns 'true' for non-magnifying optics
proto native bool HasWeaponIronsightsOverride()
is weapon in optics mode or not
static bool IsWeaponLogEnable()
SurfaceInfo surface
surface material info handle
vector pos
position of collision (in world coord)
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
Manager class for managing Effect (EffectParticle, EffectSound)
proto void Call(func fn, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native ParamsReadContext GetReadContext()
proto native ParamsWriteContext GetWriteContext()
proto bool Write(void value_out)
proto bool Read(void value_in)
proto string GetSurfaceType()
proto bool IsPassthrough()
proto string GetEntryName()
override void InitStateMachine()
override void HideBullet(int muzzleIndex)
override void ShowBullet(int muzzleIndex)
override int GetBayonetAttachmentIdx()
override int GetButtstockAttachmentIdx()
ref array< float > GetWeaponDOF()
bool CopyWeaponStateFrom(notnull Weapon_Base src)
bool IsShowingChamberedBullet()
Magazine SpawnAttachedMagazine(string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to spawn and attach a magazine.
bool IsWaitingForActionFinish()
returns true if state machine started playing action/actionType and waits for finish
void SetWasIronSight(bool state)
bool JamCheck(int muzzleIndex)
void SyncEventToRemote(WeaponEventBase e)
void DelayedValidateAndRepair()
override bool HasBayonetAttached()
void SetInitialState(WeaponStableState initState)
ref array< int > m_bulletSelectionIndex
ref Timer m_DelayedValidationTimer
float m_WeaponLiftCheckVerticalOffset
void SyncSelectionState(bool has_bullet, bool has_mag)
float GetEffectiveAttachmentLength()
Returns effective length of attachments that influence total weapon length.
bool m_isJammed
weapon state machine
void EEFired(int muzzleType, int mode, string ammoType)
static Weapon_Base CreateWeaponWithAmmo(string weaponType, string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Create weapon with ammo.
int GetWeaponSpecificCommand(int weaponAction, int subCommand)
bool FillInnerMagazine(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the inner magazine.
int m_weaponHideBarrelIdx
bool InitWeaponLiftCheckVerticalOffset()
gets weapon vertical offset from config for weaponlift raycast
int m_BayonetAttachmentIdx
bool EjectCartridge(int muzzleIndex, out float ammoDamage, out string ammoTypeName)
unload bullet from chamber or internal magazine
ref array< float > m_DOFProperties
ref array< ref AbilityRecord > m_abilities
float GetWeightSpecialized(bool forceRecalc=false)
const float VALIDATE_DELAY
Validation on client side delay to have time properly synchronize attachments needed for check.
override int GetSlotsCountCorrect()
Returns number of slots for attachments corrected for weapons.
void HideWeaponBarrel(bool state)
bool InitShoulderDistance()
gets approximate weapon distance from shoulder from config
override bool CanReleaseAttachment(EntityAI attachment)
void ShowBullet(int muzzleIndex)
bool CanProcessAction(int action, int actionType)
void HideBullet(int muzzleIndex)
array< MuzzleState > GetMuzzleStates()
Helper method for RandomizeFSMState.
void SetCharged(bool value)
bool InitDOFProperties(out array< float > temp_array)
Initializes DOF properties for weapon's ironsight/optics cameras.
override void EEItemLocationChanged(notnull InventoryLocation oldLoc, notnull InventoryLocation newLoc)
void SetNextWeaponMode(int muzzleIndex)
bool AddJunctureToAttachedMagazine(PlayerBase player, int timeoutMS)
vector m_LastLiftPosition
const float DEFAULT_DAMAGE_ON_SHOT
override void OnInventoryExit(Man player)
int m_magazineSimpleSelectionIndex
animation state the weapon is in, -1 == uninitialized
ref WeaponFSM m_fsm
weapon abilities
void RandomizeFSMState()
With the parameters given, selects a random suitable state for the FSM of the weapon @WARNING: Weapon...
float GetSyncChanceToJam()
void SetSyncJammingChance(float jamming_chance)
override void OnDebugSpawn()
bool FillChamber(string ammoType="", int flags=WeaponWithAmmoFlags.CHAMBER)
Try to fill the chamber.
PhxInteractionLayers hit_mask
void SetWeaponAnimState(int state)
bool LiftWeaponRaycastResultCheck(notnull RaycastRVResult res)
Return whether provided material triggers weapon lift (true) or not (false).
bool HasActionAbility(int action, int actionType)
query if weapon supports action and actionType
void SetWeaponOpen(bool value)
void ForceSyncSelectionState()
bool LiftWeaponCheck(PlayerBase player)
override void AfterStoreLoad()
bool ProcessWeaponAbortEvent(WeaponEventBase e)
override bool CanRemoveFromHands(EntityAI parent)
override void SetButtstockAttached(bool pState, int slot_idx=-1)
PropertyModifiers GetPropertyModifierObject()
bool ProcessWeaponEvent(WeaponEventBase e)
weapon's fsm handling of events @NOTE: warning: ProcessWeaponEvent can be called only within DayZPlay...
WeaponStateBase GetCurrentState()
returns currently active state
ref array< float > m_ChanceToJam
void AssembleGun()
override on weapons with some assembly required
AbilityRecord GetAbility(int index)
override bool CanBeUsedForSuicide()
void ClearJunctureToAttachedMagazine(PlayerBase player)
RecoilBase SpawnRecoilObject()
override void EEItemDetached(EntityAI item, string slot_name)
int GetCurrentStableStateID()
tries to return identifier of current stable state (or nearest stable state if unstable state is curr...
ref PropertyModifiers m_PropertyModifierObject
const int SAMF_DEFAULT
Full highest capacity magazine + chambered round.
void OnFire(int muzzle_index)
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
int m_ButtstockAttachmentIdx
override void SetActions()
void ResetWeaponAnimState()
bool LoadCurrentFSMState(ParamsReadContext ctx, int version)
void SetCoolDown(float coolDownTime)
bool CanEnterIronsights()
override EntityAI ProcessMeleeItemDamage(int mode=0)
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override void OnStoreSave(ParamsWriteContext ctx)
bool CanChamberBullet(int muzzleIndex, Magazine mag)
bool CanProcessWeaponEvents()
void UpdateCoolDown(float dt)
bool SpawnAmmo(string magazineType="", int flags=WeaponWithAmmoFlags.CHAMBER)
General method trying to attch magazine, fill inner magazine and fill chamber.
void SaveCurrentFSMState(ParamsWriteContext ctx)
void OnFireModeChange(int fireMode)
override bool HasButtstockAttached()
void SetJammed(bool value)
const int SAMF_RNG
Random bullet quantity + maybe chambered round.
bool InitReliability(out array< float > reliability_array)
override void EEItemAttached(EntityAI item, string slot_name)
bool InitWeaponLength()
gets weapon length from config for weaponlift raycast
override void OnInventoryEnter(Man player)
override void SetBayonetAttached(bool pState, int slot_idx=-1)
attachment helpers (firearm melee)
void WriteToContext(ParamsWriteContext ctx)
WeaponEventID GetEventID()
returns id from enum WeaponEventID
signalize mechanism manipulation
weapon finite state machine
script counterpart to engine's class Weapon
override bool IsDischarged()
override bool HasBullet()
override bool HasMagazine()
represents weapon's stable state (i.e. the basic states that the weapon will spend the most time in)
represent weapon state base
void AddCalcDetails(string details)
void SetCalcDetails(string details)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool simple=true)
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
proto vector Multiply4(vector mat[4])
Transforms position.
static vector RotateAroundZeroDeg(vector vec, vector axis, float angle)
Rotate a vector around 0,0,0 by an angle in degrees.
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
static proto native vector Lerp(vector v1, vector v2, float t)
Lerp between two vectors.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
override string GetDebugName()
DayZPlayerInstanceType
defined in C++
DayZPlayerConstants
defined in C++
Serializer ParamsReadContext
proto native CGame GetGame()
Serializer ParamsWriteContext
void Error(string err)
Messagebox with error message.
proto void Print(void var)
Prints content of variable to console/log.
static proto native void End()
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
static proto void BeginCleanupScope()
static proto native void EndCleanupScope()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< string > TStringArray
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto void YawPitchRollMatrix(vector ang, out vector mat[3])
Creates rotation matrix from angles.
static proto void MatrixMultiply3(vector mat0[3], vector mat1[3], out vector res[3])
Transforms rotation matrix.
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Asin(float s)
Returns angle in radians from sinus.
static proto float Acos(float c)
Returns angle in radians from cosinus.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
static const float RAD2DEG
static const float DEG2RAD
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
class JsonUndergroundAreaTriggerData GetPosition