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

◆ HandleWeapons()

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

HandleWeapons

fire

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

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

Перекрестные ссылки 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().