11enum WeaponWithAmmoFlags
41 const int SAMF_DEFAULT = WeaponWithAmmoFlags.CHAMBER | WeaponWithAmmoFlags.MAX_CAPACITY_MAG;
43 const int SAMF_RNG = WeaponWithAmmoFlags.CHAMBER_RNG | WeaponWithAmmoFlags.QUANTITY_RNG;
94 if ( ConfigIsExisting(
"simpleHiddenSelections") )
97 ConfigGetTextArray(
"simpleHiddenSelections",selectionNames);
101 int bulletIndex = selectionNames.Find(
"bullet");
102 if ( bulletIndex != -1 )
106 for (
int i = 2; i < 100; i++)
108 bulletIndex = selectionNames.Find(
string.Format(
"bullet%1",i));
109 if (bulletIndex != -1)
147 m_fsm.SetInitialState(initState);
150 SetGroundAnimFrameIndex(initState.m_animState);
175 float baseWeight = GetInventoryAndCargoWeight(forceRecalc);
178 string bulletTypeName, ammoTypeName;
180 int muzzleCount = GetMuzzleCount();
182 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
185 data1.
SetCalcDetails(
"TWPN: " + m_ConfigWeight+
"(item weight) + " + baseWeight +
"(contents weight)" );
188 for (
int muzzleIndex = 0; muzzleIndex < muzzleCount; muzzleIndex++)
191 if (!IsChamberEmpty(muzzleIndex))
193 ammoTypeName = GetChamberAmmoTypeName(muzzleIndex);
194 ammoWeight +=
g_Game.ConfigGetFloat(
string.Format(
"CfgMagazines %1 weight", ammoTypeName));
197 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
200 data2.
AddCalcDetails(
g_Game.ConfigGetFloat(
"CfgMagazines " + ammoTypeName +
" weight").ToString() +
"(chamber weight)");
206 if (HasInternalMagazine(muzzleIndex))
209 float debugInternalMagWeight;
211 int cartridgeCount = GetInternalMagazineCartridgeCount(muzzleIndex);
212 for (
int cartridgeIndex = 0; cartridgeIndex < cartridgeCount; cartridgeIndex++)
214 GetInternalMagazineCartridgeInfo(muzzleIndex, cartridgeIndex, ammoDamage, bulletTypeName);
217 debugInternalMagWeight +=
g_Game.ConfigGetFloat(
"CfgMagazines " + ammoTypeName +
" weight");
222 if (WeightDebug.m_VerbosityFlags & WeightDebugType.RECALC_FORCED)
231 return ammoWeight + baseWeight + GetConfigWeightModified();
249 for (
int i = 0; i < count; ++i)
320 m_fsm.ProcessAbortEvent(e, aa);
326 return CanChamberFromMag(muzzleIndex, mag) && (!
IsChamberFull(muzzleIndex) ||
IsChamberFiredOut(muzzleIndex) || !IsInternalMagazineFull(muzzleIndex));
332 SetGroundAnimFrameIndex(state);
341 void EEFired(
int muzzleType,
int mode,
string ammoType)
343 if ( !
GetGame().IsDedicatedServer() )
345 ItemBase suppressor = GetAttachedSuppressor();
348 ItemBase.PlayFireParticles(
this, muzzleType, ammoType,
this, suppressor,
"CfgWeapons" );
353 ItemBase.PlayFireParticles(
this, muzzleType, ammoType, suppressor, NULL,
"CfgVehicles" );
354 suppressor.IncreaseOverheating(
this, ammoType,
this, suppressor,
"CfgVehicles");
369 #ifdef DIAG_DEVELOPER
370 MiscGameplayFunctions.UnlimitedAmmoDebugCheck(
this);
394 SelectionBulletShow();
404 SelectionBulletHide();
413 int level = GetHealthLevel();
425 string chamberedAmmoTypeName;
426 float chamberedAmmoDmg;
428 if ( GetCartridgeInfo(0, chamberedAmmoDmg, chamberedAmmoTypeName) )
430 EffectBulletShow(0, chamberedAmmoDmg, chamberedAmmoTypeName);
433 SelectionBulletShow();
438 SelectionBulletHide();
464 int nMuzzles = GetMuzzleCount();
465 for (
int i = 0; i < nMuzzles; ++i)
472 GetCartridgeInfo(i, damage, ammoTypeName);
473 EffectBulletShow(i, damage, ammoTypeName);
481 Magazine mag = GetMagazine(i);
491 if ( !super.OnStoreLoad(ctx, version) )
497 int current_muzzle = 0;
498 if (!ctx.
Read(current_muzzle))
500 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read current muzzle!");
504 if (current_muzzle >= GetMuzzleCount() || current_muzzle < 0)
505 Error(
"Weapon.OnStoreLoad " +
this +
" trying to set muzzle index " + current_muzzle +
" while it only has " + GetMuzzleCount() +
" muzzles!");
507 SetCurrentMuzzle(current_muzzle);
513 if (!ctx.
Read(mode_count))
515 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read mode count!");
519 for (
int m = 0; m < mode_count; ++m)
524 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read mode[" + m +
"]");
529 SetCurrentMode(m, mode);
533 if ( version >= 106 )
537 Error(
"Weapon.OnStoreLoad cannot load jamming state");
544 if (!
m_fsm.OnStoreLoad(ctx, version))
550 SetGroundAnimFrameIndex(wss.m_animState);
557 if (!ctx.
Read(dummy))
568 if (
m_fsm.SaveCurrentFSMState(ctx))
573 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon=" +
this +
" state NOT saved.");
576 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon.SaveCurrentFSMState: trying to save weapon without FSM (or uninitialized weapon) this=" +
this +
" type=" +
GetType());
583 if (
m_fsm.LoadCurrentFSMState(ctx, version))
589 state.SyncAnimState();
601 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon=" +
this +
" did not load.");
607 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon.LoadCurrentFSMState: trying to load weapon without FSM (or uninitialized weapon) this=" +
this +
" type=" +
GetType());
616 int mi = GetCurrentMuzzle();
617 Magazine mag = GetMagazine(mi);
618 bool has_mag = mag != null;
619 bool has_bullet = !IsChamberEmpty(mi);
626 super.OnStoreSave(ctx);
629 int current_muzzle = GetCurrentMuzzle();
630 ctx.
Write(current_muzzle);
633 int mode_count = GetMuzzleCount();
634 ctx.
Write(mode_count);
635 for (
int m = 0; m < mode_count; ++m)
636 ctx.
Write(GetCurrentMode(m));
641 m_fsm.OnStoreSave(ctx);
655 return m_fsm.GetInternalStateID();
666 return m_fsm.GetCurrentStableStateID();
679 int mi = GetCurrentMuzzle();
680 Magazine mag = GetMagazine(mi);
681 bool has_mag = mag != null;
682 bool has_bullet = !IsChamberEmpty(mi);
685 m_fsm.RandomizeFSMStateEx(muzzleStates, has_mag, has_jam);
695 int nMuzzles = GetMuzzleCount();
696 for (
int i = 0; i < nMuzzles; ++i)
703 else if (IsChamberEmpty(i))
706 ErrorEx(
string.Format(
"Unable to identify chamber state of muzzle %1", i));
708 muzzleStates.Insert(state);
734 ErrorEx(
string.Format(
"%1 does not exist or is not a weapon.", weaponType));
738 wpn.SpawnAmmo(magazineType, flags);
748 bool SpawnAmmo(
string magazineType =
"",
int flags = WeaponWithAmmoFlags.CHAMBER )
774 if ( GetMagazineTypeCount(0) == 0 )
776 ErrorEx(
string.Format(
"No 'magazines' config entry for %1.",
this));
781 if ( magazineType ==
"" )
783 if ( flags & WeaponWithAmmoFlags.MAX_CAPACITY_MAG)
784 magazineType = GetMaxMagazineTypeName(0);
786 magazineType = GetRandomMagazineTypeName(0);
789 EntityAI magAI = GetInventory().CreateAttachment(magazineType);
797 if (!CastTo(mag, magAI))
804 if (flags & WeaponWithAmmoFlags.QUANTITY_RNG)
811 if(mag.ServerAcquireCartridge(dmg,bulletType))
818 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
819 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || chamberRng;
820 if (chamber || chamberRng)
842 if (!HasInternalMagazine(-1))
853 bool didSomething =
false;
854 bool needUpdateStateMachine =
false;
855 int muzzCount = GetMuzzleCount();
857 bool ammoRng = ammoType ==
"";
858 bool ammoFullRng = ammoRng && (flags & WeaponWithAmmoFlags.AMMO_MAG_RNG);
861 if (ammoRng && !ammoFullRng)
862 ammoType = GetRandomChamberableAmmoTypeName(0);
865 for (
int i = 0; i < muzzCount; ++i)
867 bool loadAnyBullet =
false;
868 int ammoCount = GetInternalMagazineMaxCartridgeCount(i);
871 if ( flags & WeaponWithAmmoFlags.QUANTITY_RNG )
878 for (
int j = 0; j < ammoCount; ++j)
882 ammoType = GetRandomChamberableAmmoTypeName(i);
884 PushCartridgeToInternalMagazine(i, 0, ammoType);
885 loadAnyBullet =
true;
892 ammoType = GetRandomChamberableAmmoTypeName(i);
895 needUpdateStateMachine =
true;
902 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
912 if( needUpdateStateMachine )
929 bool FillChamber(
string ammoType =
"",
int flags = WeaponWithAmmoFlags.CHAMBER )
931 bool didSomething =
false;
932 bool chamberFullRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG_SPORADIC);
933 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
934 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER);
937 if (chamber || chamberFullRng)
945 else if (!(flags & WeaponWithAmmoFlags.AMMO_CHAMBER_RNG))
947 ammoType = GetRandomChamberableAmmoTypeName(0);
951 int muzzCount = GetMuzzleCount();
952 int amountToChamber = muzzCount;
958 for (
int m = 0; m < muzzCount; ++m)
969 if (amountToChamber <= 0)
988 if(!IsChamberEmpty(muzzleIndex))
993 ammoType = GetRandomChamberableAmmoTypeName(muzzleIndex);
1001 return PushCartridgeToChamber(muzzleIndex, dmg, ammoType);
1013 int ac = GetInventory().AttachmentCount();
1014 int sc = GetInventory().GetAttachmentSlotsCount() + GetMuzzleCount();
1015 if (ac > sc) sc = ac;
1058 if ( !
GetGame().IsDedicatedServer() )
1062 if ( fireMode == 0 )
1081 Error(
"[wpn] Weapon_Base::DelayedValidateAndRepair m_DelayedValidationTimer not initialized.");
1089 m_fsm.ValidateAndRepair();
1107 super.OnInventoryEnter(player);
1113 super.OnInventoryExit(player);
1118 super.EEItemAttached(item, slot_name);
1125 super.EEItemDetached(item, slot_name);
1132 super.EEItemLocationChanged(oldLoc, newLoc);
1137 if (newLoc.GetParent() &&
PlayerBase.CastTo(player, newLoc.GetParent()))
1173 super.OnItemLocationChanged(old_owner,new_owner);
1179 player.SetReturnToOptics(
false);
1185 player.SwitchOptics(optics,
false);
1189 if (old_owner != new_owner &&
PlayerBase.Cast(new_owner))
1197 if ( !super.CanReleaseAttachment( attachment ) )
1199 Magazine mag = Magazine.Cast(attachment);
1205 if ( player.GetItemInHands() ==
this )
1227 if (GetInventory().GetCurrentInventoryLocation(il))
1253 p.StoreInputForRemotes(ctx);
1287 if (
GetGame().ConfigIsExisting(
"cfgWeapons " +
GetType() +
" PPDOFProperties"))
1297 if (
GetGame().ConfigIsExisting(
"cfgWeapons " +
GetType() +
" Reliability ChanceToJam"))
1308 if (ConfigIsExisting(
"WeaponLength"))
1320 if (ConfigIsExisting(
"WeaponLiftCheckVerticalOffset"))
1332 if (ConfigIsExisting(
"ShoulderDistance"))
1345 if (ConfigIsExisting(
"ObstructionDistance"))
1388 player.GetMovementState(ms);
1390 #ifdef DIAG_DEVELOPER
1411 isStatic = !isDynamic;
1414 #ifdef DIAG_DEVELOPER
1417 if (diagAlwaysDynamic && isDynamic)
1422 if (diagNeverStatic && isStatic)
1440 else if (obstructionValue > 0)
1450 bool isLift = player.IsLiftWeapon();
1452 if (isLift && obstructionValue > 0.9)
1457 if (!isLift && obstructionValue >= 1.0)
1462 #ifdef DIAG_DEVELOPER
1487 dst.Insert( 0.0, -1.0,
" 0.16 0.22 -0.04");
1488 dst.Insert( 0.0, -0.5,
" 0.14 0.13 0.00");
1489 dst.Insert( 0.0, 0.0,
" 0.13 0.04 -0.02");
1490 dst.Insert( 0.0, 0.5,
" 0.13 0.01 -0.03");
1491 dst.Insert( 0.0, 1.0,
" 0.14 -0.01 -0.04");
1495 dst.Insert( 0.0, -1.0,
" 0.120 -0.080 -0.030");
1496 dst.Insert( 0.0, -0.5,
" 0.120 -0.040 -0.040");
1497 dst.Insert( 0.0, 0.0,
" 0.120 0.010 -0.022");
1498 dst.Insert( 0.0, 0.5,
" 0.120 -0.080 -0.050");
1499 dst.Insert( 0.0, 1.0,
" 0.120 -0.160 -0.130");
1504 dst.Insert( 0.3, 0.0,
" 0.110 0.008 0.010");
1505 dst.Insert( 0.5, 0.0,
" 0.000 0.100 0.025");
1506 dst.Insert( 0.8, 0.0,
" 0.070 0.150 -0.014");
1507 dst.Insert( 1.0, 0.0,
" 0.140 -0.050 0.020");
1509 dst.Insert(-0.3, 0.0,
" 0.090 -0.100 -0.025");
1510 dst.Insert(-0.5, 0.0,
" 0.072 -0.064 -0.002");
1511 dst.Insert(-0.9, 0.0,
" 0.129 -0.080 0.015");
1512 dst.Insert(-1.0, 0.0,
" 0.140 -0.050 0.020");
1514 dst.Insert( 0.5, 1.0,
"-0.050 0.150 0.120");
1515 dst.Insert( 1.0, 1.0,
" 0.150 -0.035 0.030");
1516 dst.Insert(-0.5, 1.0,
" 0.050 -0.124 -0.040");
1517 dst.Insert(-1.0, 1.0,
" 0.150 -0.035 0.030");
1521 dst.Insert( 0.0, -1.0,
"0.13 0.14 0.082");
1522 dst.Insert( 0.0, -0.5,
"0.13 0.05 0.048");
1523 dst.Insert( 0.0, 0.0,
"0.13 0.01 -0.008");
1524 dst.Insert( 0.0, 0.5,
"0.13 0.00 -0.015");
1525 dst.Insert( 0.0, 1.0,
"0.13 -0.04 -0.016");
1538 const float LEAN_VERT_OFFSET = -0.1;
1539 const float LEAN_HORIZ_OFFSET_L = 0;
1540 const float LEAN_HORIZ_OFFSET_R = 0.01;
1542 float leanOffset = lean * aimStraightWeight;
1543 offset +=
Vector( leanOffset *
Math.
Lerp(LEAN_HORIZ_OFFSET_L, LEAN_HORIZ_OFFSET_R, lean * 0.5 + 0.5), leanOffset * LEAN_VERT_OFFSET, 0);
1548 float peakVelocity = 0.5;
1549 float moveAmount01 =
Math.
Clamp(maxVelocity / peakVelocity, 0.0, 1.0);
1550 if (moveAmount01 != 0.0)
1552 vector moveOffset =
"0 -0.2 -0.1";
1553 float ud01 = (ud11 * 0.5) + 0.5;
1554 float aimWeight =
Math.
Clamp(1.0 - (ud01 * 2), 0, 1);
1557 float moveWeight = moveAmount01 *
Math.
Pow(aimWeight, 2.0);
1558 offset = offset + (moveWeight * moveOffset);
1578 resTM[2] = direction;
1579 resTM[1] = resTM[2] * resTM[0];
1592 #ifdef DIAG_DEVELOPER
1602 float ud11 =
Math.
Clamp((ud01 * 2) - 1, -1, 1);
1604 float lr11 =
Math.
Clamp((lr01 * 2) - 1, -1, 1);
1607 #ifdef DIAG_DEVELOPER
1615 vector offset = aimOffsets.Blend(lr11, ud11);
1627 offset += moveOffset;
1633 offset[2] = offset[2] + 0.05;
1673 #ifdef DIAG_DEVELOPER
1677 Print(
"Error: No weapon owner for LiftWeaponCheckEx, returning.");
1683 player.GetMovementState(movementState);
1691 #ifdef DIAG_DEVELOPER
1715 yawPitchRoll[0] = yawPitchRoll[0] + xAimHandsOffset;
1725 if (player.m_DirectionToCursor !=
vector.
Zero)
1727 direction = player.m_DirectionToCursor;
1732 direction = MiscGameplayFunctions.GetHeadingVector(player);
1743 int boneIdx = player.GetBoneIndexByName(
"Neck");
1746 start = player.GetPosition()[1] + 1.5;
1750 start = player.GetBonePositionWS(boneIdx);
1755 velocity = player.VectorToLocal(velocity);
1766 float weaponEndDist = weaponStartDist + weaponLength;
1769 vector weaponStart = start + (weaponStartDist * direction);
1770 vector weaponEnd = start + (weaponEndDist * direction);
1777 if (baseObstructionLength==0)
1782 float weaponObstructionDist = baseObstructionLength + effectiveAttachmentLength;
1783 float rayRadius = 0.02;
1786 #ifdef DIAG_DEVELOPER
1787 float overrideObstDist =
PluginDiagMenuClient.GetWeaponLiftDiag().Data().m_ObstructionDistance;
1788 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetWeaponRayParams(start, direction, weaponStartDist, weaponEndDist, effectiveAttachmentLength,
m_ObstructionDistance, weaponObstructionDist, rayRadius);
1789 weaponObstructionDist = overrideObstDist;
1796 float rayEndDist = weaponEndDist + 0.30;
1797 vector rayEnd = start + rayEndDist * direction;
1802 rayParm.
type = ObjIntersect.Fire;
1816 int numRes = results.Count();
1819 hitResult = results[0];
1824 float maxDist =
float.MAX;
1825 for (
int i = 0, nr = results.Count(); i < nr; ++i)
1828 if (sqDist < maxDist)
1834 hitResult = results[bi];
1839 float len0 = (hitResult.
pos - start).Length();
1840 float len1 = (weaponEnd - start).Length();
1842 if (len0 <= 0 || len1 <= 0)
1848 hitFraction = len0 / len1;
1850 hitDist = hitFraction * weaponEndDist;
1860 #ifdef DIAG_DEVELOPER
1861 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetIntersectionParams(hitResult, hitFraction, hitDist);
1867 bool wantsLift = wasLift;
1870 const float inThreshold = 0.002;
1872 const float outThreshold = 0.003;
1873 const float noIsctOutThreshold = 0.01;
1876 const int maxNumMissedTicks = 10;
1883 if (hitFraction != 0)
1890 if (!wasLift && d > inThreshold)
1894 else if (wasLift && d < -outThreshold)
1914 vector v3 = (lastLiftPosition - start).Normalized();
1915 vector v4 = (weaponEnd-start).Normalized();
1926 float d3 =
vector.
Dot( lastLiftPosition - weaponEnd, (start-weaponEnd).Normalized() );
1927 if (d3 < -noIsctOutThreshold)
1934 int timeSinceHit = player.GetSimulationTimeStamp() -
m_LastLiftHit;
1935 if (timeSinceHit > maxNumMissedTicks)
1943 float l1 = (weaponEnd - start).Length();
1944 if (l0 <= 0 || l1 <= 0)
1950 hitFraction = l0 / l1;
1952 hitDist = hitFraction * weaponEndDist;
1962 float begDist = weaponObstructionDist;
1963 float endDist = weaponStartDist + weaponLength;
1966 if (begDist < endDist)
1970 outHitObject = hitResult.
obj;
1972 outObstruction = 1.0 - obstFraction;
1989 if (baseObstructionLength==0)
1996 return weaponEnd -
Math.
Lerp(weaponEnd, baseObstructionLength + effectiveAttachmentLength, obstruction01);
2002 return res.surface.IsSolid();
2012 attachment =
ItemBase.Cast(GetInventory().FindAttachment(bayonetIndex));
2016 attachment = GetAttachedSuppressor();
2021 return Math.
Max(attachment.m_ItemModelLength + attachment.m_ItemAttachOffset, 0);
2046 if (IsChamberEjectable(muzzleIndex))
2048 if (PopCartridgeFromChamber(muzzleIndex, ammoDamage, ammoTypeName))
2051 else if (GetInternalMagazineCartridgeCount(muzzleIndex) > 0)
2053 if (PopCartridgeFromInternalMagazine(muzzleIndex, ammoDamage, ammoTypeName))
2064 for (
int mi = 0; mi < src.GetMuzzleCount(); ++mi)
2066 if (!src.IsChamberEmpty(mi))
2068 if (src.GetCartridgeInfo(mi, damage, type))
2070 PushCartridgeToChamber(mi, damage, type);
2074 for (
int ci = 0; ci < src.GetInternalMagazineCartridgeCount(mi); ++ci)
2076 if (src.GetInternalMagazineCartridgeInfo(mi, ci, damage, type))
2078 PushCartridgeToInternalMagazine(mi, damage, type);
2083 int dummy_version =
int.MAX;
2128 if ( !
GetGame().IsDedicatedServer() )
2143 SelectionMagazineShow();
2151 SelectionMagazineHide();
2161 super.ProcessMeleeItemDamage();
2173 super.ProcessMeleeItemDamage();
2179 attachment.ProcessMeleeItemDamage();
2217 if (!ConfigGetBool(
"isSuicideWeapon"))
2220 return super.CanBeUsedForSuicide();
2231 Magazine mag = GetMagazine(GetCurrentMuzzle());
2243 Magazine mag = GetMagazine(GetCurrentMuzzle());
2252 SetNextMuzzleMode(muzzleIndex);
2272#ifdef TEST_WEAPON_SYSNC_REPAIR
2273 void SetSyncStable(
bool value)
2275 m_SyncStable = value;
2284 return m_SyncStable;
eBleedingSourceType GetType()
void wpnDebugPrint(string s)
void AddAction(typename actionName)
class Blend2D< Class T > Blend2DVector
const int ECE_PLACE_ON_SURFACE
EWeaponObstructionMode staticMode
!! all member variables must correspond with the cfggameplay.json file contents !!...
EWeaponObstructionMode dynamicMode
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)
proto native float GetTickTime()
Returns current time from start of the game.
override ScriptCallQueue GetCallQueue(int call_category)
bool ClearJunctureEx(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.
static EWeaponObstructionMode GetWeaponObstructionModeStatic()
static EWeaponObstructionMode GetWeaponObstructionModeDynamic()
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 bool IsChangingStance()
returns true if character is changing stance
proto native float GetAimingHandsOffsetUD()
returns aiming hands up/down (y) offset angle
proto native float GetWeaponObstruction()
return obstruction value
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()
Object obj
object,that we collide with (NULL if none), If hierLevel > 0 object is the proxy object
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)
override void InitStateMachine()
override void HideBullet(int muzzleIndex)
override void ShowBullet(int muzzleIndex)
override void GetApproximateAimOffsets(Blend2DVector dst, int characterStance)
override vector GetApproximateMovementOffset(vector localVelocity, int characterStance, float lean, float ud11, float lr11)
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()
float m_ObstructionDistance
void SetInitialState(WeaponStableState initState)
bool FillSpecificChamber(int muzzleIndex, float dmg=0, string ammoType="")
ref array< int > m_bulletSelectionIndex
ref Timer m_DelayedValidationTimer
vector GetApproximateMovementOffset(vector localVelocity, int characterStance, float lean, float ud11, float lr11)
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
float GetObstructionPenetrationDistance(float obstruction01)
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)
void ApproximateWeaponLiftTransform(inout vector start, inout vector direction, HumanMovementState hms, HumanInputController hic, HumanCommandWeapons hcw, HumanCommandMove hcm, vector localVelocity="0 0 0")
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...
bool LiftWeaponCheckEx(PlayerBase player, out float outObstruction, out Object outHitObject)
bool InitObstructionDistance()
gets weapon obstruction distance from shoulder at which the weapon is fully obstructed
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()
void GetApproximateAimOffsets(Blend2DVector dst, int characterStance)
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)
bool UseWeaponObstruction(PlayerBase player, float obstructionValue, Object hitObject)
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)
float ApproximateBaseObstructionLength()
Approximate ObstructionDistance for weapons with no configuration. Returned length doesn't account fo...
const int SAMF_RNG
Random bullet quantity + maybe chambered round.
bool MustBeChambered(int muzzleIndex)
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)
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
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.
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 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 Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
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 proto float Pow(float v, float power)
Return power of v ^ power.
static const float DEG2RAD
static proto float AbsFloat(float f)
Returns absolute value.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native bool dBodyIsDynamic(notnull IEntity ent)
class JsonUndergroundAreaTriggerData GetPosition