Guest User

CreamyRecoilTweaker.ts

a guest
Jun 21st, 2024
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.58 KB | None | 0 0
  1. import { DependencyContainer } from "tsyringe";
  2. import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
  3. import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
  4.  
  5. class RecoilTweaker implements IPostDBLoadMod
  6. {
  7. private container: DependencyContainer
  8. private config = require("../config/config.json")
  9.  
  10. public postDBLoad(container: DependencyContainer): void
  11. {
  12.  
  13. this.container = container
  14. const tables = this.container.resolve<DatabaseServer>("DatabaseServer").getTables()
  15. const items = tables.templates.items
  16.  
  17. tables.globals.config.AimPunchMagnitude *= this.config.aimPunch; // Sets aim punch value.
  18. if (!this.config.hiddenBonusRecoilToggle)
  19. {
  20. tables.globals.config.Aiming.RecoilBackBonus = 0;
  21. tables.globals.config.Aiming.RecoilVertBonus = 0;
  22. }
  23. tables.globals.config.Aiming.RecoilCrank = this.config.recoilCrank;
  24. tables.globals.config.Aiming.RecoilDamping *= this.config.recoilDamping;
  25. tables.globals.config.Aiming.RecoilHandDamping *= this.config.recoilHandDamping;
  26. tables.globals.config.Aiming.AimProceduralIntensity = this.config.aimProceduralIntensity;
  27. tables.globals.config.Aiming.RecoilXIntensityByPose["x"] *= this.config.RecoilXIntensityByPoseX
  28. tables.globals.config.Aiming.RecoilXIntensityByPose["y"] *= this.config.RecoilXIntensityByPoseY
  29. tables.globals.config.Aiming.RecoilXIntensityByPose["z"] *= this.config.RecoilXIntensityByPoseZ
  30. tables.globals.config.Aiming.RecoilYIntensityByPose["x"] *= this.config.RecoilYIntensityByPoseX
  31. tables.globals.config.Aiming.RecoilYIntensityByPose["y"] *= this.config.RecoilYIntensityByPoseY
  32. tables.globals.config.Aiming.RecoilYIntensityByPose["z"] *= this.config.RecoilYIntensityByPoseZ
  33. tables.globals.config.Aiming.RecoilZIntensityByPose["x"] *= this.config.RecoilZIntensityByPoseX
  34. tables.globals.config.Aiming.RecoilZIntensityByPose["y"] *= this.config.RecoilZIntensityByPoseY
  35. tables.globals.config.Aiming.RecoilZIntensityByPose["z"] *= this.config.RecoilZIntensityByPoseZ
  36. tables.globals.config.Aiming.ProceduralIntensityByPose["x"] *= this.config.ProceduralIntensityByPoseX
  37. tables.globals.config.Aiming.ProceduralIntensityByPose["y"] *= this.config.ProceduralIntensityByPoseY
  38. tables.globals.config.Aiming.ProceduralIntensityByPose["z"] *= this.config.ProceduralIntensityByPoseZ
  39.  
  40. const weaponClassList = [
  41. "5447b5cf4bdc2d65278b4567", // Pistols
  42. "5447b5e04bdc2d62278b4567", // SMGs
  43. "5447b6094bdc2dc3278b4567", // Shotguns
  44. "5447b5f14bdc2d61278b4567", // Assault Rifles
  45. "5447b5fc4bdc2d87278b4567", // Carbines
  46. "5447bed64bdc2d97278b4568", // LMGs
  47. "5447b6194bdc2d67278b4567", // Marksman Rifles
  48. "5447b6254bdc2dc3278b4568" // Sniper Rifles
  49. ]
  50.  
  51. for (const eachItem in items)
  52. {
  53. const weapon = items[eachItem]._props
  54.  
  55. if (this.config.globalToggle)
  56. {
  57. if (weaponClassList.includes(items[eachItem]._parent))
  58. {
  59.  
  60. items[eachItem]._props.RecoilForceUp *= this.config.globalVerticalRecoil
  61. items[eachItem]._props.RecoilForceBack *= this.config.globalHorizontalRecoil
  62. items[eachItem]._props.RecoilReturnSpeedHandRotation *= this.config.globalConvergence
  63. items[eachItem]._props.RecolDispersion *= this.config.globalDispersion
  64. items[eachItem]._props.RecoilCamera *= this.config.globalCameraRecoil
  65. items[eachItem]._props.CameraSnap *= this.config.globalCameraSnap
  66. }
  67. }
  68. if (this.config.weaponClassToggle)
  69. {
  70. if (items[eachItem]._parent == "5447b5cf4bdc2d65278b4567") // Pistols
  71. {
  72. weapon.RecoilForceUp *= this.config.pistolVerticalRecoil
  73. weapon.RecoilForceBack *= this.config.pistolHorizontalRecoil
  74. weapon.RecoilReturnSpeedHandRotation *= this.config.pistolConvergence
  75. weapon.RecolDispersion *= this.config.pistolDispersion
  76. weapon.RecoilCamera *= this.config.pistolCameraRecoil
  77. weapon.CameraSnap *= this.config.pistolCameraSnap
  78. }
  79. if (items[eachItem]._parent == "5447b5e04bdc2d62278b4567") // SMGs
  80. {
  81. weapon.RecoilForceUp *= this.config.smgVerticalRecoil
  82. weapon.RecoilForceBack *= this.config.smgHorizontalRecoil
  83. weapon.RecoilReturnSpeedHandRotation *= this.config.smgConvergence
  84. weapon.RecolDispersion *= this.config.smgDispersion
  85. weapon.RecoilCamera *= this.config.smgCameraRecoil
  86. weapon.CameraSnap *= this.config.smgCameraSnap
  87. }
  88. if (items[eachItem]._parent == "5447b6094bdc2dc3278b4567") // Shotguns
  89. {
  90. weapon.RecoilForceUp *= this.config.shotgunVerticalRecoil
  91. weapon.RecoilForceBack *= this.config.shotgunHorizontalRecoil
  92. weapon.RecoilReturnSpeedHandRotation *= this.config.shotgunConvergence
  93. weapon.RecolDispersion *= this.config.shotgunDispersion
  94. weapon.RecoilCamera *= this.config.shotgunCameraRecoil
  95. weapon.CameraSnap *= this.config.shotgunCameraSnap
  96. }
  97. if (items[eachItem]._parent == "5447b5fc4bdc2d87278b4567") // Assault Carbines
  98. {
  99. weapon.RecoilForceUp *= this.config.carbineVerticalRecoil
  100. weapon.RecoilForceBack *= this.config.carbineHorizontalRecoil
  101. weapon.RecoilReturnSpeedHandRotation *= this.config.carbineConvergence
  102. weapon.RecolDispersion *= this.config.carbineDispersion
  103. weapon.RecoilCamera *= this.config.carbineCameraRecoil
  104. weapon.CameraSnap *= this.config.carbineCameraSnap
  105. }
  106. if (items[eachItem]._parent == "5447b5f14bdc2d61278b4567") // Assault Rifles
  107. {
  108. weapon.RecoilForceUp *= this.config.rifleVerticalRecoil
  109. weapon.RecoilForceBack *= this.config.rifleHorizontalRecoil
  110. weapon.RecoilReturnSpeedHandRotation *= this.config.rifleConvergence
  111. weapon.RecolDispersion *= this.config.rifleDispersion
  112. weapon.RecoilCamera *= this.config.rifleCameraRecoil
  113. weapon.CameraSnap *= this.config.rifleCameraSnap
  114. }
  115. if (items[eachItem]._parent == "5447bed64bdc2d97278b4568") // LMGs
  116. {
  117. weapon.RecoilForceUp *= this.config.mgVerticalRecoil
  118. weapon.RecoilForceBack *= this.config.mgHorizontalRecoil
  119. weapon.RecoilReturnSpeedHandRotation *= this.config.mgConvergence
  120. weapon.RecolDispersion *= this.config.mgDispersion
  121. weapon.RecoilCamera *= this.config.mgCameraRecoil
  122. weapon.CameraSnap *= this.config.mgCameraSnap
  123. }
  124. if (items[eachItem]._parent == "5447b6194bdc2d67278b4567") // Marksman Rifles
  125. {
  126. weapon.RecoilForceUp *= this.config.marksmanVerticalRecoil
  127. weapon.RecoilForceBack *= this.config.marksmanHorizontalRecoil
  128. weapon.RecoilReturnSpeedHandRotation *= this.config.marksmanConvergence
  129. weapon.RecolDispersion *= this.config.marksmanDispersion
  130. weapon.RecoilCamera *= this.config.marksmanCameraRecoil
  131. weapon.CameraSnap *= this.config.marksmanCameraSnap
  132. }
  133. if (items[eachItem]._parent == "5447b6254bdc2dc3278b4568") // Sniper Rifles
  134. {
  135. weapon.RecoilForceUp *= this.config.sniperVerticalRecoil
  136. weapon.RecoilForceBack *= this.config.sniperHorizontalRecoil
  137. weapon.RecoilReturnSpeedHandRotation *= this.config.sniperConvergence
  138. weapon.RecolDispersion *= this.config.sniperDispersion
  139. weapon.RecoilCamera *= this.config.sniperCameraRecoil
  140. weapon.CameraSnap *= this.config.sniperCameraSnap
  141. }
  142. }
  143. }
  144. }
  145. }
  146.  
  147. module.exports = { mod: new RecoilTweaker() }
Advertisement
Add Comment
Please, Sign In to add comment