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

◆ HandleWeapons()

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

HandleWeapons

fire

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

1024 {
1025 HumanCommandWeapons hcw = GetCommandModifier_Weapons();
1026 GetDayZPlayerInventory().HandleWeaponEvents(pDt, pExitIronSights);
1027
1028 Weapon_Base weapon;
1029 Class.CastTo(weapon, pInHands);
1030 ItemOptics optic = weapon.GetAttachedOptics();
1031
1034
1035 GetMovementState(m_MovementState);
1036
1037 // obstruction
1038 bool wantedLift = m_LiftWeapon_player;
1039 bool currentLift = hcw.IsWeaponLifted();
1040 if (wantedLift != currentLift)
1041 {
1042 hcw.LiftWeapon(wantedLift);
1043 // Reset the velocity, cause at this point we might need to start moving in the opposite direction rather rapidly,
1044 // to prevent the obstruction from smashing the player's head while lifting
1046 }
1047
1048 float wantedObstruction = m_ObstructWeapon_player;
1049 float currentObstruction = hcw.GetWeaponObstruction();
1050 if (wantedObstruction != currentObstruction)
1051 {
1052 // The following times are times chosen by observation; the following values produced
1053 // consistent and relatively nicely looking results and were OK'd by the animators.
1054 const float outTime = 0.150; // duration when smoothing hi -> lo
1055 const float inTime = 0.010; // duration when smoothing lo -> hi
1056 const float inTimeLift = 0.100; // duration when smoothing in during lift
1057
1058 float smoothTime;
1059 if (wantedLift) // When lifting always transition rather quickly
1060 {
1061 wantedObstruction = 0.0;
1062 smoothTime = inTimeLift;
1063 }
1064 else // Otherwise we can take our time based on the delta
1065 {
1066 float t = Math.Clamp(Math.AbsFloat(wantedObstruction-currentObstruction), 0, 1);
1067 smoothTime = Math.Lerp(outTime, inTime, t);
1068 }
1069
1070 // Do the interpolation and clamp to wanted value if the change is below certain threshold, to prevent uneccessary interpolation
1071 m_fObstructionSmooth = Math.SmoothCD(m_fObstructionSmooth, wantedObstruction, m_fObstructionSmoothVelocity, smoothTime, 6.0, pDt);
1072 if (Math.AbsFloat(m_fObstructionSmooth-wantedObstruction) < 0.0001)
1073 {
1074 m_fObstructionSmooth = wantedObstruction;
1075 }
1076
1077 #ifdef DIAG_DEVELOPER
1078 if (DiagMenu.GetValue(DiagMenuIDs.WEAPON_DISABLE_OBSTRUCTION_INTERPOLATION))
1079 m_fObstructionSmooth = wantedObstruction;
1080 #endif
1081
1083
1084 #ifndef SERVER
1085 #ifdef DIAG_DEVELOPER
1086 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetInterpolation( inTime, inTimeLift, outTime, smoothTime, m_fObstructionSmooth, currentObstruction, wantedObstruction );
1087 #endif
1088 #endif
1089 }
1090 // !obstruction
1091
1092 // hold breath
1093 if (pInputs.IsHoldBreath() && m_MovementState.IsRaised() && (IsInIronsights() || IsInOptics()))
1094 {
1095 m_IsTryingHoldBreath = true;
1096 }
1097 else
1098 {
1099 m_IsTryingHoldBreath = false;
1100 }
1101
1102 if (pInputs.IsFireModeChange())
1103 {
1105 }
1106 if (pInputs.IsZeroingUp())
1107 {
1108 if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
1109 {
1110 optic.StepZeroingUp();
1111 }
1112 else
1113 {
1114 weapon.StepZeroingUpAllMuzzles();
1115 }
1116 }
1117 if (pInputs.IsZeroingDown())
1118 {
1119 if (optic && (optic.IsInOptics() || optic.IsUsingWeaponIronsightsOverride()))
1120 {
1121 optic.StepZeroingDown();
1122 }
1123 else
1124 {
1125 weapon.StepZeroingDownAllMuzzles();
1126 }
1127 }
1128
1129 if (!m_LiftWeapon_player && (m_CameraIronsight || !weapon.CanEnterIronsights() || m_CameraOptics/*m_ForceHandleOptics*/)) // HACK straight to optics, if ironsights not allowed
1130 {
1131 if (optic)
1132 HandleOptic(optic, false, pInputs, pExitIronSights);
1133 }
1134
1135 if (!m_MovementState.IsRaised())
1136 {
1137 m_IsFireWeaponRaised = false; //legacy reasons
1138 if (weapon && weapon.IsInOptics())
1139 {
1140 weapon.ExitOptics();
1141 }
1142
1144
1145 return; // if not raised => return
1146 }
1147 else
1148 {
1149 m_IsFireWeaponRaised = true; //legacy reasons
1151 {
1152 m_WeaponRaiseTime += pDt;
1153 }
1154
1155 if (m_WeaponRaiseTime >= PlayerConstants.WEAPON_RAISE_BLEND_DELAY)
1156 {
1158 }
1159 }
1160
1162 if (GetWeaponManager().CanFire(weapon))
1163 {
1164 bool autofire = weapon.GetCurrentModeAutoFire(weapon.GetCurrentMuzzle()) && weapon.IsChamberEjectable(weapon.GetCurrentMuzzle());
1165 int burst = weapon.GetCurrentModeBurstSize(weapon.GetCurrentMuzzle());
1166 int burst_count = weapon.GetBurstCount();
1167 if (!autofire && (burst < 2 || burst_count < 1))
1168 {
1169 if (pInputs.IsAttackButtonDown() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
1170 {
1171 GetWeaponManager().Fire(weapon);
1172 }
1173 }
1174 else if (autofire || burst > 1)
1175 {
1176#ifdef DIAG_DEVELOPER
1177 int burst_option = GetWeaponManager().GetBurstOption();
1178 if (burst_option == 0)
1179 {
1180#endif
1181 if (pInputs.IsAttackButton() && GetInputInterface().SyncedValue("UAWeaponMeleeAttack") == 0 && GetInputInterface().SyncedValue("UAHeavyMeleeAttack") == 0)
1182 {
1183 if (autofire || burst_count < burst)
1184 {
1185 GetWeaponManager().Fire(weapon);
1186 }
1187 }
1188 else
1189 {
1190 weapon.ResetBurstCount();
1191 }
1192#ifdef DIAG_DEVELOPER
1193 }
1194 else if (burst_option == 1)
1195 {
1196 if (burst > 1 && burst_count == burst)
1197 {
1198 weapon.ResetBurstCount();
1199 }
1200 else if (burst > 1 && burst_count < burst)
1201 {
1202 GetWeaponManager().Fire(weapon);
1203 }
1204 else
1205 {
1206 //Autofire
1207 if (pInputs.IsAttackButton())
1208 {
1209 GetWeaponManager().Fire(weapon);
1210 }
1211 }
1212 }
1213#endif
1214 }
1215 }
1216
1217 #ifdef PLATFORM_CONSOLE
1218 if (g_Game.GetInput().LocalRelease("UAFire", false) || m_ShouldReload)
1219 {
1220 if (!weapon.IsWaitingForActionFinish() && !IsFighting())
1221 {
1222 int muzzle_index = weapon.GetCurrentMuzzle();
1223
1224 if (weapon.IsChamberFiredOut(muzzle_index))
1225 {
1226 if (weapon.CanProcessWeaponEvents())
1227 {
1228 if (GetWeaponManager().CanEjectBullet(weapon))
1229 {
1231 pExitIronSights = true;
1232 m_ShouldReload = false;
1233 }
1234 }
1235 }
1236 }
1237 else
1238 {
1239 m_ShouldReload = true;
1240 }
1241 }
1242 #endif
1243 }
DayZGame g_Game
Определения DayZGame.c:4074
DiagMenuIDs
Определения EDiagMenuIDs.c:2
StarlightOptic ItemOptics
void ProcessLiftWeapon()
void ResetWeaponRaiseProgress()
Определения DayZPlayerImplement.c:929
WeaponManager GetWeaponManager()
Определения DayZPlayerImplement.c:1017
float m_WeaponRaiseTime
Определения DayZPlayerImplement.c:112
bool IsWeaponRaiseCompleted()
Определения DayZPlayerImplement.c:935
void CompleteWeaponRaise()
Определения DayZPlayerImplement.c:920
bool m_CameraIronsight
Определения DayZPlayerImplement.c:115
bool m_IsFireWeaponRaised
Определения DayZPlayerImplement.c:4113
float m_fObstructionSmooth
Определения DayZPlayerImplement.c:168
bool IsInIronsights()
Определения DayZPlayerImplement.c:292
bool m_CameraOptics
Определения DayZPlayerImplement.c:116
bool IsFighting()
ref HumanMovementState m_MovementState
time step for gradual update of dead screen visibilibty up to full visbility [s]
Определения DayZPlayerImplement.c:92
bool IsInOptics()
Определения DayZPlayerImplement.c:297
bool m_IsTryingHoldBreath
Определения DayZPlayerImplement.c:120
bool m_LiftWeapon_player
Определения DayZPlayerImplement.c:134
DayZPlayerInventory GetDayZPlayerInventory()
Определения DayZPlayerImplement.c:940
float m_ObstructWeapon_player
Определения DayZPlayerImplement.c:135
void CheckLiftWeapon()
void HandleOptic(notnull ItemOptics optic, bool inHands, HumanInputController pInputs, out bool pExitOptics)
Определения DayZPlayerImplement.c:1245
float m_fObstructionSmoothVelocity[1]
Определения DayZPlayerImplement.c:169
bool m_ShouldReload
Определения DayZPlayerImplement.c:108
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:480
void Fire(Weapon_Base wpn)
Определения WeaponManager.c:485
bool EjectBullet(ActionBase control_action=NULL)
Определения WeaponManager.c:443
void HumanCommandWeapons()
Определения human.c:1155

Перекрестные ссылки Math::AbsFloat(), Class::CastTo(), CheckLiftWeapon(), Math::Clamp(), CompleteWeaponRaise(), g_Game, GetDayZPlayerInventory(), 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().