DayZ 1.28
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ HandleWeapons()

void DayZPlayer::HandleWeapons ( float pDt,
Entity pInHands,
HumanInputController pInputs,
out bool pExitIronSights )
inlineprotected

HandleWeapons

fire

См. определение в файле DayZPlayerImplement.c строка 984

985 {
986 HumanCommandWeapons hcw = GetCommandModifier_Weapons();
987 GetDayZPlayerInventory().HandleWeaponEvents(pDt, pExitIronSights);
988
989 Weapon_Base weapon;
990 Class.CastTo(weapon, pInHands);
991 ItemOptics optic = weapon.GetAttachedOptics();
992
995
996 GetMovementState(m_MovementState);
997
998 // obstruction
999 bool wantedLift = m_LiftWeapon_player;
1000 bool currentLift = hcw.IsWeaponLifted();
1001 if (wantedLift != currentLift)
1002 {
1003 hcw.LiftWeapon(wantedLift);
1004 // Reset the velocity, cause at this point we might need to start moving in the opposite direction rather rapidly,
1005 // to prevent the obstruction from smashing the player's head while lifting
1007 }
1008
1009 float wantedObstruction = m_ObstructWeapon_player;
1010 float currentObstruction = hcw.GetWeaponObstruction();
1011 if (wantedObstruction != currentObstruction)
1012 {
1013 // The following times are times chosen by observation; the following values produced
1014 // consistent and relatively nicely looking results and were OK'd by the animators.
1015 const float outTime = 0.150; // duration when smoothing hi -> lo
1016 const float inTime = 0.010; // duration when smoothing lo -> hi
1017 const float inTimeLift = 0.100; // duration when smoothing in during lift
1018
1019 float smoothTime;
1020 if (wantedLift) // When lifting always transition rather quickly
1021 {
1022 wantedObstruction = 0.0;
1023 smoothTime = inTimeLift;
1024 }
1025 else // Otherwise we can take our time based on the delta
1026 {
1027 float t = Math.Clamp(Math.AbsFloat(wantedObstruction-currentObstruction), 0, 1);
1028 smoothTime = Math.Lerp(outTime, inTime, t);
1029 }
1030
1031 // Do the interpolation and clamp to wanted value if the change is below certain threshold, to prevent uneccessary interpolation
1032 m_fObstructionSmooth = Math.SmoothCD(m_fObstructionSmooth, wantedObstruction, m_fObstructionSmoothVelocity, smoothTime, 6.0, pDt);
1033 if (Math.AbsFloat(m_fObstructionSmooth-wantedObstruction) < 0.0001)
1034 {
1035 m_fObstructionSmooth = wantedObstruction;
1036 }
1037
1038 #ifdef DIAG_DEVELOPER
1039 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_DISABLE_OBSTRUCTION_INTERPOLATION))
1040 m_fObstructionSmooth = wantedObstruction;
1041 #endif
1042
1044
1045 #ifndef SERVER
1046 #ifdef DIAG_DEVELOPER
1047 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetInterpolation( inTime, inTimeLift, outTime, smoothTime, m_fObstructionSmooth, currentObstruction, wantedObstruction );
1048 #endif
1049 #endif
1050 }
1051 // !obstruction
1052
1053 // hold breath
1054 if (pInputs.IsHoldBreath() && m_MovementState.IsRaised() && (IsInIronsights() || IsInOptics()))
1055 {
1056 m_IsTryingHoldBreath = true;
1057 }
1058 else
1059 {
1060 m_IsTryingHoldBreath = false;
1061 }
1062
1063 if (pInputs.IsFireModeChange())
1064 {
1066 }
1067 if (pInputs.IsZeroingUp())
1068 {
1069 if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
1070 {
1071 optic.StepZeroingUp();
1072 }
1073 else
1074 {
1075 weapon.StepZeroingUpAllMuzzles();
1076 }
1077 }
1078 if (pInputs.IsZeroingDown())
1079 {
1080 if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
1081 {
1082 optic.StepZeroingDown();
1083 }
1084 else
1085 {
1086 weapon.StepZeroingDownAllMuzzles();
1087 }
1088 }
1089
1090 if (!m_LiftWeapon_player && (m_CameraIronsight || !weapon.CanEnterIronsights() || m_CameraOptics/*m_ForceHandleOptics*/)) // HACK straight to optics, if ironsights not allowed
1091 {
1092 if (optic)
1093 HandleOptic(optic, false, pInputs, pExitIronSights);
1094 }
1095
1096 if (!m_MovementState.IsRaised())
1097 {
1098 m_IsFireWeaponRaised = false; //legacy reasons
1099 if (weapon && weapon.IsInOptics())
1100 {
1101 weapon.ExitOptics();
1102 }
1103
1105
1106 return; // if not raised => return
1107 }
1108 else
1109 {
1110 m_IsFireWeaponRaised = true; //legacy reasons
1112 {
1113 m_WeaponRaiseTime += pDt;
1114 }
1115
1116 if (m_WeaponRaiseTime >= PlayerConstants.WEAPON_RAISE_BLEND_DELAY)
1117 {
1119 }
1120 }
1121
1123 if (GetWeaponManager().CanFire(weapon))
1124 {
1125 bool autofire = weapon.GetCurrentModeAutoFire(weapon.GetCurrentMuzzle()) && weapon.IsChamberEjectable(weapon.GetCurrentMuzzle());
1126 int burst = weapon.GetCurrentModeBurstSize(weapon.GetCurrentMuzzle());
1127 int burst_count = weapon.GetBurstCount();
1128 if (!autofire && (burst < 2 || burst_count < 1))
1129 {
1130 if (pInputs.IsAttackButtonDown() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
1131 {
1132 GetWeaponManager().Fire(weapon);
1133 }
1134 }
1135 else if (autofire || burst > 1)
1136 {
1137#ifdef DIAG_DEVELOPER
1138 int burst_option = GetWeaponManager().GetBurstOption();
1139 if (burst_option == 0)
1140 {
1141#endif
1142 if (pInputs.IsAttackButton() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
1143 {
1144 if (autofire || burst_count < burst)
1145 {
1146 GetWeaponManager().Fire(weapon);
1147 }
1148 }
1149 else
1150 {
1151 weapon.ResetBurstCount();
1152 }
1153#ifdef DIAG_DEVELOPER
1154 }
1155 else if (burst_option == 1)
1156 {
1157 if (burst > 1 && burst_count == burst)
1158 {
1159 weapon.ResetBurstCount();
1160 }
1161 else if (burst > 1 && burst_count < burst)
1162 {
1163 GetWeaponManager().Fire(weapon);
1164 }
1165 else
1166 {
1167 //Autofire
1168 if (pInputs.IsAttackButton())
1169 {
1170 GetWeaponManager().Fire(weapon);
1171 }
1172 }
1173 }
1174#endif
1175 }
1176 }
1177
1178 #ifdef PLATFORM_CONSOLE
1179 if (GetGame().GetInput().LocalRelease("UAFire", false) || m_ShouldReload)
1180 {
1181 if (!weapon.IsWaitingForActionFinish() && !IsFighting())
1182 {
1183 int muzzle_index = weapon.GetCurrentMuzzle();
1184
1185 if (weapon.IsChamberFiredOut(muzzle_index))
1186 {
1187 if (weapon.CanProcessWeaponEvents())
1188 {
1189 if (GetWeaponManager().CanEjectBullet(weapon))
1190 {
1192 pExitIronSights = true;
1193 m_ShouldReload = false;
1194 }
1195 }
1196 }
1197 }
1198 else
1199 {
1200 m_ShouldReload = true;
1201 }
1202 }
1203 #endif
1204 }
DiagMenuIDs
Определения EDiagMenuIDs.c:2
StarlightOptic ItemOptics
void ProcessLiftWeapon()
void ResetWeaponRaiseProgress()
Определения DayZPlayerImplement.c:896
WeaponManager GetWeaponManager()
Определения DayZPlayerImplement.c:978
float m_WeaponRaiseTime
Определения DayZPlayerImplement.c:136
bool IsWeaponRaiseCompleted()
Определения DayZPlayerImplement.c:902
void CompleteWeaponRaise()
Определения DayZPlayerImplement.c:887
bool m_CameraIronsight
Определения DayZPlayerImplement.c:139
bool m_IsFireWeaponRaised
Определения DayZPlayerImplement.c:3991
float m_fObstructionSmooth
Определения DayZPlayerImplement.c:190
bool IsInIronsights()
Определения DayZPlayerImplement.c:311
bool m_CameraOptics
Определения DayZPlayerImplement.c:140
bool IsFighting()
ref HumanMovementState m_MovementState
time step for gradual update of dead screen visibilibty up to full visbility [s]
Определения DayZPlayerImplement.c:116
bool IsInOptics()
Определения DayZPlayerImplement.c:316
bool m_IsTryingHoldBreath
Определения DayZPlayerImplement.c:144
bool m_LiftWeapon_player
Определения DayZPlayerImplement.c:158
DayZPlayerInventory GetDayZPlayerInventory()
Определения DayZPlayerImplement.c:907
float m_ObstructWeapon_player
Определения DayZPlayerImplement.c:159
void CheckLiftWeapon()
void HandleOptic(notnull ItemOptics optic, bool inHands, HumanInputController pInputs, out bool pExitOptics)
Определения DayZPlayerImplement.c:1206
float m_fObstructionSmoothVelocity[1]
Определения DayZPlayerImplement.c:191
bool m_ShouldReload
Определения DayZPlayerImplement.c:132
proto native void LiftWeapon(bool pState)
command for lifting weapon near obstacles (works only when weapon is raised)
proto native void ObstructWeapon(float pState01)
command for obstruction weapon near obstacles
proto native float GetWeaponObstruction()
return obstruction value
proto native bool IsWeaponLifted()
return if lifting weapon is active
proto native bool IsZeroingDown()
zeroing down
proto native bool IsAttackButton()
returns true if 'UAFire' button is pressed (== true for multiple ticks). Synced.
proto native bool IsHoldBreath()
holding breath
proto native bool IsFireModeChange()
fire mode has changed
proto native bool IsZeroingUp()
zeroing up
proto native bool IsAttackButtonDown()
returns true if 'UAFire' button has just been pressed (== true for 1 tick only). Synced.
proto native bool StepZeroingUp()
sets zeroing to next defined (respective to current) value in zeroing config array
proto native bool IsInOptics()
is weapon in optics mode or not
proto native bool IsUsingWeaponIronsightsOverride()
is optics using ironsights override settings or not
proto native bool StepZeroingDown()
sets zeroing to previous (respective to current) defined value in zeroing config array
bool SetNextMuzzleMode()
Определения WeaponManager.c:479
void Fire(Weapon_Base wpn)
Определения WeaponManager.c:484
bool EjectBullet(ActionBase control_action=NULL)
Определения WeaponManager.c:442
proto native CGame GetGame()
void HumanCommandWeapons()
Определения human.c:1126

Перекрестные ссылки Math::AbsFloat(), Class::CastTo(), CheckLiftWeapon(), Math::Clamp(), CompleteWeaponRaise(), GetDayZPlayerInventory(), GetGame(), DiagMenu::GetValue(), GetWeaponManager(), HumanCommandWeapons::GetWeaponObstruction(), HandleOptic(), HumanInputController::IsAttackButton(), HumanInputController::IsAttackButtonDown(), IsFighting(), HumanInputController::IsFireModeChange(), HumanInputController::IsHoldBreath(), IsInIronsights(), IsInOptics(), ItemOptics::IsInOptics(), ItemOptics::IsUsingWeaponIronsightsOverride(), HumanCommandWeapons::IsWeaponLifted(), IsWeaponRaiseCompleted(), HumanInputController::IsZeroingDown(), HumanInputController::IsZeroingUp(), Math::Lerp(), HumanCommandWeapons::LiftWeapon(), m_CameraIronsight, m_CameraOptics, m_fObstructionSmooth, m_fObstructionSmoothVelocity, m_IsFireWeaponRaised, m_IsTryingHoldBreath, m_LiftWeapon_player, m_MovementState, m_ObstructWeapon_player, m_ShouldReload, m_WeaponRaiseTime, HumanCommandWeapons::ObstructWeapon(), ProcessLiftWeapon(), ResetWeaponRaiseProgress(), Math::SmoothCD(), ItemOptics::StepZeroingDown(), ItemOptics::StepZeroingUp() и PlayerConstants::WEAPON_RAISE_BLEND_DELAY.

Используется в CommandHandler().