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: " +
EntityAIType.Cast(GetEntityType()).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);
343 auto player =
PlayerBase.Cast(GetHierarchyRootPlayer());
345 if ( !
g_Game.IsHeadlessOrDedicatedServer() )
347 ItemBase suppressor = GetAttachedSuppressor();
350 ItemBase.PlayFireParticles(
this, muzzleType,
ammoType,
this, suppressor,
"CfgWeapons" );
355 ItemBase.PlayFireParticles(
this, muzzleType,
ammoType, suppressor, NULL,
"CfgVehicles" );
356 suppressor.IncreaseOverheating(
this,
ammoType,
this, suppressor,
"CfgVehicles");
361 #ifdef DIAG_DEVELOPER
362 MiscGameplayFunctions.UnlimitedAmmoDebugCheck(
this);
386 SelectionBulletShow();
396 SelectionBulletHide();
405 int level = GetHealthLevel();
417 string chamberedAmmoTypeName;
418 float chamberedAmmoDmg;
420 if ( GetCartridgeInfo(0, chamberedAmmoDmg, chamberedAmmoTypeName) )
422 EffectBulletShow(0, chamberedAmmoDmg, chamberedAmmoTypeName);
425 SelectionBulletShow();
430 SelectionBulletHide();
456 int nMuzzles = GetMuzzleCount();
457 for (
int i = 0; i < nMuzzles; ++i)
464 GetCartridgeInfo(i, damage, ammoTypeName);
465 EffectBulletShow(i, damage, ammoTypeName);
473 Magazine mag = GetMagazine(i);
483 if ( !super.OnStoreLoad(ctx, version) )
489 int current_muzzle = 0;
490 if (!ctx.
Read(current_muzzle))
492 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read current muzzle!");
496 if (current_muzzle >= GetMuzzleCount() || current_muzzle < 0)
497 Error(
"Weapon.OnStoreLoad " +
this +
" trying to set muzzle index " + current_muzzle +
" while it only has " + GetMuzzleCount() +
" muzzles!");
499 SetCurrentMuzzle(current_muzzle);
505 if (!ctx.
Read(mode_count))
507 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read mode count!");
511 for (
int m = 0; m < mode_count; ++m)
516 Error(
"Weapon.OnStoreLoad " +
this +
" cannot read mode[" + m +
"]");
521 SetCurrentMode(m, mode);
525 if ( version >= 106 )
529 Error(
"Weapon.OnStoreLoad cannot load jamming state");
536 if (!
m_fsm.OnStoreLoad(ctx, version))
542 SetGroundAnimFrameIndex(wss.m_animState);
549 if (!ctx.
Read(dummy))
560 if (
m_fsm.SaveCurrentFSMState(ctx))
565 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon=" +
this +
" state NOT saved.");
568 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon.SaveCurrentFSMState: trying to save weapon without FSM (or uninitialized weapon) this=" +
this +
" type=" +
GetType());
575 if (
m_fsm.LoadCurrentFSMState(ctx, version))
581 state.SyncAnimState();
593 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon=" +
this +
" did not load.");
599 Error(
"[wpnfsm] " +
Object.GetDebugName(
this) +
" Weapon.LoadCurrentFSMState: trying to load weapon without FSM (or uninitialized weapon) this=" +
this +
" type=" +
GetType());
608 int mi = GetCurrentMuzzle();
609 Magazine mag = GetMagazine(mi);
610 bool has_mag = mag != null;
611 bool has_bullet = !IsChamberEmpty(mi);
618 super.OnStoreSave(ctx);
621 int current_muzzle = GetCurrentMuzzle();
622 ctx.
Write(current_muzzle);
625 int mode_count = GetMuzzleCount();
626 ctx.
Write(mode_count);
627 for (
int m = 0; m < mode_count; ++m)
628 ctx.
Write(GetCurrentMode(m));
633 m_fsm.OnStoreSave(ctx);
647 return m_fsm.GetInternalStateID();
658 return m_fsm.GetCurrentStableStateID();
671 int mi = GetCurrentMuzzle();
672 Magazine mag = GetMagazine(mi);
673 bool has_mag = mag != null;
674 bool has_bullet = !IsChamberEmpty(mi);
677 m_fsm.RandomizeFSMStateEx(muzzleStates, has_mag, has_jam);
687 int nMuzzles = GetMuzzleCount();
688 for (
int i = 0; i < nMuzzles; ++i)
695 else if (IsChamberEmpty(i))
698 ErrorEx(
string.Format(
"Unable to identify chamber state of muzzle %1", i));
700 muzzleStates.Insert(state);
726 ErrorEx(
string.Format(
"%1 does not exist or is not a weapon.", weaponType));
730 wpn.SpawnAmmo(magazineType, flags);
740 bool SpawnAmmo(
string magazineType =
"",
int flags = WeaponWithAmmoFlags.CHAMBER )
766 if ( GetMagazineTypeCount(0) == 0 )
768 ErrorEx(
string.Format(
"No 'magazines' config entry for %1.",
this));
773 if ( magazineType ==
"" )
775 if ( flags & WeaponWithAmmoFlags.MAX_CAPACITY_MAG)
776 magazineType = GetMaxMagazineTypeName(0);
778 magazineType = GetRandomMagazineTypeName(0);
781 EntityAI magAI = GetInventory().CreateAttachment(magazineType);
789 if (!CastTo(mag, magAI))
796 if (flags & WeaponWithAmmoFlags.QUANTITY_RNG)
803 if(mag.ServerAcquireCartridge(dmg,bulletType))
810 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
811 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || chamberRng;
812 if (chamber || chamberRng)
834 if (!HasInternalMagazine(-1))
845 bool didSomething =
false;
846 bool needUpdateStateMachine =
false;
847 int muzzCount = GetMuzzleCount();
850 bool ammoFullRng = ammoRng && (flags & WeaponWithAmmoFlags.AMMO_MAG_RNG);
853 if (ammoRng && !ammoFullRng)
854 ammoType = GetRandomChamberableAmmoTypeName(0);
857 for (
int i = 0; i < muzzCount; ++i)
859 bool loadAnyBullet =
false;
860 int ammoCount = GetInternalMagazineMaxCartridgeCount(i);
863 if ( flags & WeaponWithAmmoFlags.QUANTITY_RNG )
870 for (
int j = 0; j < ammoCount; ++j)
874 ammoType = GetRandomChamberableAmmoTypeName(i);
876 PushCartridgeToInternalMagazine(i, 0,
ammoType);
877 loadAnyBullet =
true;
884 ammoType = GetRandomChamberableAmmoTypeName(i);
887 needUpdateStateMachine =
true;
894 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER) || (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
904 if( needUpdateStateMachine )
923 bool didSomething =
false;
924 bool chamberFullRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG_SPORADIC);
925 bool chamberRng = (flags & WeaponWithAmmoFlags.CHAMBER_RNG);
926 bool chamber = (flags & WeaponWithAmmoFlags.CHAMBER);
929 if (chamber || chamberFullRng)
937 else if (!(flags & WeaponWithAmmoFlags.AMMO_CHAMBER_RNG))
939 ammoType = GetRandomChamberableAmmoTypeName(0);
943 int muzzCount = GetMuzzleCount();
944 int amountToChamber = muzzCount;
950 for (
int m = 0; m < muzzCount; ++m)
961 if (amountToChamber <= 0)
980 if(!IsChamberEmpty(muzzleIndex))
985 ammoType = GetRandomChamberableAmmoTypeName(muzzleIndex);
993 return PushCartridgeToChamber(muzzleIndex, dmg,
ammoType);
1005 int ac = GetInventory().AttachmentCount();
1006 int sc = GetInventory().GetAttachmentSlotsCount() + GetMuzzleCount();
1007 if (ac > sc) sc = ac;
1050 if ( !
g_Game.IsHeadlessOrDedicatedServer() )
1054 if ( fireMode == 0 )
1073 Error(
"[wpn] Weapon_Base::DelayedValidateAndRepair m_DelayedValidationTimer not initialized.");
1081 m_fsm.ValidateAndRepair();
1099 super.OnInventoryEnter(player);
1105 super.OnInventoryExit(player);
1110 super.EEItemAttached(item, slot_name);
1117 super.EEItemDetached(item, slot_name);
1126 super.EEItemLocationChanged(oldLoc, newLoc);
1131 if (newLoc.GetParent() &&
PlayerBase.CastTo(player, newLoc.GetParent()))
1167 super.OnItemLocationChanged(old_owner,new_owner);
1173 player.SetReturnToOptics(
false);
1179 player.SwitchOptics(optics,
false);
1183 if (old_owner != new_owner &&
PlayerBase.Cast(new_owner))
1191 if ( !super.CanReleaseAttachment( attachment ) )
1193 Magazine mag = Magazine.Cast(attachment);
1199 if ( player.GetItemInHands() ==
this )
1221 if (GetInventory().GetCurrentInventoryLocation(il))
1247 p.StoreInputForRemotes(ctx);
1281 if (
g_Game.ConfigIsExisting(
"cfgWeapons " +
GetType() +
" PPDOFProperties"))
1283 g_Game.ConfigGetFloatArray(
"cfgWeapons " +
GetType() +
" PPDOFProperties", temp_array);
1291 if (
g_Game.ConfigIsExisting(
"cfgWeapons " +
GetType() +
" Reliability ChanceToJam"))
1293 g_Game.ConfigGetFloatArray(
"cfgWeapons " +
GetType() +
" Reliability ChanceToJam", reliability_array);
1302 if (ConfigIsExisting(
"WeaponLength"))
1314 if (ConfigIsExisting(
"WeaponLiftCheckVerticalOffset"))
1326 if (ConfigIsExisting(
"ShoulderDistance"))
1339 if (ConfigIsExisting(
"ObstructionDistance"))
1382 player.GetMovementState(ms);
1384 #ifdef DIAG_DEVELOPER
1405 isStatic = !isDynamic;
1408 #ifdef DIAG_DEVELOPER
1411 if (diagAlwaysDynamic && isDynamic)
1416 if (diagNeverStatic && isStatic)
1434 else if (obstructionValue > 0)
1444 bool isLift = player.IsLiftWeapon();
1446 if (isLift && obstructionValue > 0.9)
1451 if (!isLift && obstructionValue >= 1.0)
1456 #ifdef DIAG_DEVELOPER
1481 dst.Insert( 0.0, -1.0,
" 0.16 0.22 -0.04");
1482 dst.Insert( 0.0, -0.5,
" 0.14 0.13 0.00");
1483 dst.Insert( 0.0, 0.0,
" 0.13 0.04 -0.02");
1484 dst.Insert( 0.0, 0.5,
" 0.13 0.01 -0.03");
1485 dst.Insert( 0.0, 1.0,
" 0.14 -0.01 -0.04");
1489 dst.Insert( 0.0, -1.0,
" 0.120 -0.080 -0.030");
1490 dst.Insert( 0.0, -0.5,
" 0.120 -0.040 -0.040");
1491 dst.Insert( 0.0, 0.0,
" 0.120 0.010 -0.022");
1492 dst.Insert( 0.0, 0.5,
" 0.120 -0.080 -0.050");
1493 dst.Insert( 0.0, 1.0,
" 0.120 -0.160 -0.130");
1498 dst.Insert( 0.3, 0.0,
" 0.110 0.008 0.010");
1499 dst.Insert( 0.5, 0.0,
" 0.000 0.100 0.025");
1500 dst.Insert( 0.8, 0.0,
" 0.070 0.150 -0.014");
1501 dst.Insert( 1.0, 0.0,
" 0.140 -0.050 0.020");
1503 dst.Insert(-0.3, 0.0,
" 0.090 -0.100 -0.025");
1504 dst.Insert(-0.5, 0.0,
" 0.072 -0.064 -0.002");
1505 dst.Insert(-0.9, 0.0,
" 0.129 -0.080 0.015");
1506 dst.Insert(-1.0, 0.0,
" 0.140 -0.050 0.020");
1508 dst.Insert( 0.5, 1.0,
"-0.050 0.150 0.120");
1509 dst.Insert( 1.0, 1.0,
" 0.150 -0.035 0.030");
1510 dst.Insert(-0.5, 1.0,
" 0.050 -0.124 -0.040");
1511 dst.Insert(-1.0, 1.0,
" 0.150 -0.035 0.030");
1515 dst.Insert( 0.0, -1.0,
"0.13 0.14 0.082");
1516 dst.Insert( 0.0, -0.5,
"0.13 0.05 0.048");
1517 dst.Insert( 0.0, 0.0,
"0.13 0.01 -0.008");
1518 dst.Insert( 0.0, 0.5,
"0.13 0.00 -0.015");
1519 dst.Insert( 0.0, 1.0,
"0.13 -0.04 -0.016");
1532 const float LEAN_VERT_OFFSET = -0.1;
1533 const float LEAN_HORIZ_OFFSET_L = 0;
1534 const float LEAN_HORIZ_OFFSET_R = 0.01;
1536 float leanOffset = lean * aimStraightWeight;
1537 offset +=
Vector( leanOffset *
Math.
Lerp(LEAN_HORIZ_OFFSET_L, LEAN_HORIZ_OFFSET_R, lean * 0.5 + 0.5), leanOffset * LEAN_VERT_OFFSET, 0);
1542 float peakVelocity = 0.5;
1543 float moveAmount01 =
Math.
Clamp(maxVelocity / peakVelocity, 0.0, 1.0);
1544 if (moveAmount01 != 0.0)
1546 vector moveOffset =
"0 -0.2 -0.1";
1547 float ud01 = (ud11 * 0.5) + 0.5;
1548 float aimWeight =
Math.
Clamp(1.0 - (ud01 * 2), 0, 1);
1551 float moveWeight = moveAmount01 *
Math.
Pow(aimWeight, 2.0);
1552 offset = offset + (moveWeight * moveOffset);
1572 resTM[2] = direction;
1573 resTM[1] = resTM[2] * resTM[0];
1586 #ifdef DIAG_DEVELOPER
1596 float ud11 =
Math.
Clamp((ud01 * 2) - 1, -1, 1);
1598 float lr11 =
Math.
Clamp((lr01 * 2) - 1, -1, 1);
1601 #ifdef DIAG_DEVELOPER
1609 vector offset = aimOffsets.Blend(lr11, ud11);
1621 offset += moveOffset;
1627 offset[2] = offset[2] + 0.05;
1667 #ifdef DIAG_DEVELOPER
1671 Print(
"Error: No weapon owner for LiftWeaponCheckEx, returning.");
1677 player.GetMovementState(movementState);
1685 #ifdef DIAG_DEVELOPER
1709 yawPitchRoll[0] = yawPitchRoll[0] + xAimHandsOffset;
1719 if (player.m_DirectionToCursor !=
vector.
Zero)
1721 direction = player.m_DirectionToCursor;
1726 direction = MiscGameplayFunctions.GetHeadingVector(player);
1731 direction =
g_Game.GetCurrentCameraDirection();
1737 int boneIdx = player.GetBoneIndexByName(
"Neck");
1740 start = player.GetPosition()[1] + 1.5;
1744 start = player.GetBonePositionWS(boneIdx);
1749 velocity = player.VectorToLocal(velocity);
1760 float weaponEndDist = weaponStartDist + weaponLength;
1763 vector weaponStart = start + (weaponStartDist * direction);
1764 vector weaponEnd = start + (weaponEndDist * direction);
1771 if (baseObstructionLength==0)
1776 float weaponObstructionDist = baseObstructionLength + effectiveAttachmentLength;
1777 float rayRadius = 0.02;
1780 #ifdef DIAG_DEVELOPER
1781 float overrideObstDist =
PluginDiagMenuClient.GetWeaponLiftDiag().Data().m_ObstructionDistance;
1782 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetWeaponRayParams(start, direction, weaponStartDist, weaponEndDist, effectiveAttachmentLength,
m_ObstructionDistance, weaponObstructionDist, rayRadius);
1783 weaponObstructionDist = overrideObstDist;
1790 float rayEndDist = weaponEndDist + 0.30;
1791 vector rayEnd = start + rayEndDist * direction;
1796 rayParm.
type = ObjIntersect.Fire;
1810 int numRes = results.Count();
1813 hitResult = results[0];
1818 float maxDist =
float.MAX;
1819 for (
int i = 0, nr = results.Count(); i < nr; ++i)
1822 if (sqDist < maxDist)
1828 hitResult = results[bi];
1833 float len0 = (hitResult.
pos - start).Length();
1834 float len1 = (weaponEnd - start).Length();
1836 if (len0 <= 0 || len1 <= 0)
1854 #ifdef DIAG_DEVELOPER
1861 bool wantsLift = wasLift;
1864 const float inThreshold = 0.002;
1866 const float outThreshold = 0.003;
1867 const float noIsctOutThreshold = 0.01;
1870 const int maxNumMissedTicks = 10;
1884 if (!wasLift && d > inThreshold)
1888 else if (wasLift && d < -outThreshold)
1908 vector v3 = (lastLiftPosition - start).Normalized();
1909 vector v4 = (weaponEnd-start).Normalized();
1920 float d3 =
vector.
Dot( lastLiftPosition - weaponEnd, (start-weaponEnd).Normalized() );
1921 if (d3 < -noIsctOutThreshold)
1928 int timeSinceHit = player.GetSimulationTimeStamp() -
m_LastLiftHit;
1929 if (timeSinceHit > maxNumMissedTicks)
1937 float l1 = (weaponEnd - start).Length();
1938 if (l0 <= 0 || l1 <= 0)
1956 float begDist = weaponObstructionDist;
1957 float endDist = weaponStartDist + weaponLength;
1960 if (begDist < endDist)
1964 outHitObject = hitResult.
obj;
1966 outObstruction = 1.0 - obstFraction;
1983 if (baseObstructionLength==0)
1990 return weaponEnd -
Math.
Lerp(weaponEnd, baseObstructionLength + effectiveAttachmentLength, obstruction01);
1996 return res.surface.IsSolid();
2006 attachment =
ItemBase.Cast(GetInventory().FindAttachment(bayonetIndex));
2010 attachment = GetAttachedSuppressor();
2041 if (IsChamberEjectable(muzzleIndex))
2043 if (PopCartridgeFromChamber(muzzleIndex, ammoDamage, ammoTypeName))
2046 else if (GetInternalMagazineCartridgeCount(muzzleIndex) > 0)
2048 if (PopCartridgeFromInternalMagazine(muzzleIndex, ammoDamage, ammoTypeName))
2059 for (
int mi = 0; mi < src.GetMuzzleCount(); ++mi)
2061 if (!src.IsChamberEmpty(mi))
2063 if (src.GetCartridgeInfo(mi, damage, type))
2065 PushCartridgeToChamber(mi, damage, type);
2069 for (
int ci = 0; ci < src.GetInternalMagazineCartridgeCount(mi); ++ci)
2071 if (src.GetInternalMagazineCartridgeInfo(mi, ci, damage, type))
2073 PushCartridgeToInternalMagazine(mi, damage, type);
2078 int dummy_version =
int.MAX;
2123 if ( !
g_Game.IsDedicatedServer() )
2138 SelectionMagazineShow();
2146 SelectionMagazineHide();
2156 super.ProcessMeleeItemDamage();
2168 super.ProcessMeleeItemDamage();
2174 attachment.ProcessMeleeItemDamage();
2212 if (!ConfigGetBool(
"isSuicideWeapon"))
2215 return super.CanBeUsedForSuicide();
2226 Magazine mag = GetMagazine(GetCurrentMuzzle());
2230 return g_Game.AddInventoryJunctureEx(player, mag, il,
false, timeoutMS);
2238 Magazine mag = GetMagazine(GetCurrentMuzzle());
2241 g_Game.ClearJunctureEx(player, mag);
2247 SetNextMuzzleMode(muzzleIndex);
2267#ifdef TEST_WEAPON_SYSNC_REPAIR
2268 void SetSyncStable(
bool value)
2270 m_SyncStable = value;
2273 m_SyncStableTime =
g_Game.GetTickTime();
2279 return m_SyncStable;
eBleedingSourceType GetType()
void wpnDebugPrint(string s)
bool IsDamageDestroyed(ActionTarget target)
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
bool OnStoreLoad(ParamsReadContext ctx, int version)
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)
@ 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 float GetAmmoWeightByBulletType(string bulletType)
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
float m_ItemModelLength float m_ItemAttachOffset
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 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
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)
override void EEFired(int muzzleType, int mode, string ammoType)
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
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.
class array< Class T > 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].
@ NONE
body is not in simulation, nor in collision world
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native bool dBodyIsDynamic(notnull IEntity ent)
vector GetPosition()
Get the world position of the Effect.