Advertisement
ArcheKruz

For Hellser

Nov 23rd, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. #library "Recoils"
  2. #include "zcommon.acs"
  3.  
  4. #define RECOIL_ICD 801
  5. #define SET_WEAPONID 840
  6. #define CALL_RECOV_RATIO 841
  7. #define CALL_CALIB_VAL 842
  8.  
  9. int StoredRecoveryRatios[10][5] =
  10. {
  11. {65536, 65536, 65536, 65536, 65536,}, // Slot 0
  12. {65536, 65536, 65536, 65536, 65536,}, // Slot 1
  13. {65536, 65536, 65536, 65536, 65536,}, // ...and so on...
  14. {65536, 65536, 65536, 65536, 65536,},
  15. {65536, 65536, 65536, 65536, 65536,},
  16. {65536, 65536, 65536, 65536, 65536,},
  17. {65536, 65536, 65536, 65536, 65536,},
  18. {65536, 65536, 65536, 65536, 65536,},
  19. {65536, 65536, 65536, 65536, 65536,},
  20. {65536, 65536, 65536, 65536, 65536,},
  21. };
  22.  
  23. int StoredCalibrationValues[10][8] = // This is to make up for the lack of division precision.
  24. {
  25. {1.38, 1.38, 1.38, 1.38, 1.38,},
  26. {1.38, 1.38, 1.38, 1.38, 1.38,},
  27. {1.38, 1.38, 1.38, 1.38, 1.38,},
  28. {1.38, 1.38, 1.38, 1.38, 1.38,},
  29. {1.38, 1.38, 1.38, 1.38, 1.38,},
  30. {1.38, 1.38, 1.38, 1.38, 1.38,},
  31. {1.38, 1.38, 1.38, 1.38, 1.38,},
  32. {1.38, 1.38, 1.38, 1.38, 1.38,},
  33. {1.38, 1.38, 1.38, 1.38, 1.38,},
  34. {1.38, 1.38, 1.38, 1.38, 1.38,},
  35. };
  36.  
  37. int WeaponID = 0; // Be sure to set slot & position in the DECORATE Select state.
  38.  
  39. script SET_WEAPONID (int x) // This is called on weapon switch using the 10 digit
  40. { // as the slot number, and the unit digit as the position.
  41. WeaponID = x; // eg. For slot 3 pos 1, WeaponID should be 31.
  42. }
  43.  
  44. script CALL_RECOV_RATIO (void) // This script calls the recovery ratio.
  45. {
  46. int SlotNumber = (WeaponID / 10);
  47. int PosNumber = (WeaponID % 10) -1;
  48. SetResultValue(StoredRecoveryRatios[SlotNumber][PosNumber]);
  49. }
  50.  
  51. script CALL_CALIB_VAL (void) // This script calls the stored calibration values.
  52. {
  53. int SlotNumber = (WeaponID / 10);
  54. int PosNumber = (WeaponID % 10) -1;
  55. SetResultValue(StoredCalibrationValues[SlotNumber][PosNumber]);
  56. }
  57.  
  58. /* Feel free to remove the clientside flag, this is for testing on Zandy.*/
  59. script RECOIL_ICD (int Amplitude, int TransLength, int DecayLength) clientside
  60. {
  61. int RecoilTotal = (Amplitude * 128) + Random(-64,64); // Calculate total pitch
  62. int PTDivisor = RecoilTotal / (TransLength * (TransLength + 1)/2); // Divide the recoil total up according to length.
  63. int PTMod = RecoilTotal % (TransLength * (TransLength + 1)/2); // Calculate the modulus, so that too much precision isn't lost.
  64. int PTRemainder = 0;
  65. int PTSub = 0; // This stores the sub-pitch values.
  66. int DecayRate = ACS_ExecuteWithResult(841);
  67. int DecayTotal = ( DecayRate * RecoilTotal) >> 16; // Calculates Decay using stored values.
  68. int PRDivisor = DecayTotal / (DecayLength * (DecayLength + 1));
  69. int PRMod = DecayTotal % (DecayLength * (DecayLength + 1));
  70. int PRRemainder = 0;
  71. int PRSub = 0;
  72.  
  73. for (int a = 0; a < TransLength; a++) // Recoil Transient.
  74. {
  75. PTRemainder = PTRemainder + PTMod * (Translength + 1 - a);
  76. PTSub = PTRemainder / (TransLength * (TransLength + 1)/2);
  77. PTRemainder = PTRemainder % (TransLength * (TransLength + 1)/2);
  78. SetActorPitch(0, GetActorPitch(0) - (PTDivisor * (TransLength + 1 - a) + PTSub));
  79. PTSub = 0;
  80. Delay(1);
  81. }
  82. Delay(1);
  83.  
  84. for (int b = 0; b < DecayLength; b++) // Recoil Recovery, part 1.
  85. {
  86. PRRemainder = PRRemainder + PRMod * b + 1;
  87. PRSub = PRRemainder / (DecayLength * (Decaylength + 1));
  88. PRRemainder = PRRemainder % (DecayLength * (Decaylength + 1));
  89. SetActorPitch(0, GetActorPitch(0) + (((PRDivisor * (b + 1) + PRSub) * ACS_ExecuteWithResult(842)) >> 16) );
  90. PRSub = 0;
  91. Delay(1);
  92. }
  93. for (int c = 0; c < DecayLength; c++) // Recoil Recovery, part 2.
  94. {
  95. PRRemainder = PRRemainder + PRMod * (DecayLength + 1 - c);
  96. PRSub = PRRemainder / (DecayLength * (Decaylength + 1));
  97. PRRemainder = PRRemainder % (DecayLength * (Decaylength + 1));
  98. SetActorPitch(0, GetActorPitch(0) + (((PRDivisor * (DecayLength + 1 - c) + PRSub ) * ACS_ExecuteWithResult(842)) >> 16) );
  99. PRSub = 0;
  100. Delay(1);
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement