Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #library "Recoils"
- #include "zcommon.acs"
- #define RECOIL_ICD 801
- #define SET_WEAPONID 840
- #define CALL_RECOV_RATIO 841
- #define CALL_CALIB_VAL 842
- int StoredRecoveryRatios[10][5] =
- {
- {65536, 65536, 65536, 65536, 65536,}, // Slot 0
- {65536, 65536, 65536, 65536, 65536,}, // Slot 1
- {65536, 65536, 65536, 65536, 65536,}, // ...and so on...
- {65536, 65536, 65536, 65536, 65536,},
- {65536, 65536, 65536, 65536, 65536,},
- {65536, 65536, 65536, 65536, 65536,},
- {65536, 65536, 65536, 65536, 65536,},
- {65536, 65536, 65536, 65536, 65536,},
- {65536, 65536, 65536, 65536, 65536,},
- {65536, 65536, 65536, 65536, 65536,},
- };
- int StoredCalibrationValues[10][8] = // This is to make up for the lack of division precision.
- {
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- {1.38, 1.38, 1.38, 1.38, 1.38,},
- };
- int WeaponID = 0; // Be sure to set slot & position in the DECORATE Select state.
- script SET_WEAPONID (int x) // This is called on weapon switch using the 10 digit
- { // as the slot number, and the unit digit as the position.
- WeaponID = x; // eg. For slot 3 pos 1, WeaponID should be 31.
- }
- script CALL_RECOV_RATIO (void) // This script calls the recovery ratio.
- {
- int SlotNumber = (WeaponID / 10);
- int PosNumber = (WeaponID % 10) -1;
- SetResultValue(StoredRecoveryRatios[SlotNumber][PosNumber]);
- }
- script CALL_CALIB_VAL (void) // This script calls the stored calibration values.
- {
- int SlotNumber = (WeaponID / 10);
- int PosNumber = (WeaponID % 10) -1;
- SetResultValue(StoredCalibrationValues[SlotNumber][PosNumber]);
- }
- /* Feel free to remove the clientside flag, this is for testing on Zandy.*/
- script RECOIL_ICD (int Amplitude, int TransLength, int DecayLength) clientside
- {
- int RecoilTotal = (Amplitude * 128) + Random(-64,64); // Calculate total pitch
- int PTDivisor = RecoilTotal / (TransLength * (TransLength + 1)/2); // Divide the recoil total up according to length.
- int PTMod = RecoilTotal % (TransLength * (TransLength + 1)/2); // Calculate the modulus, so that too much precision isn't lost.
- int PTRemainder = 0;
- int PTSub = 0; // This stores the sub-pitch values.
- int DecayRate = ACS_ExecuteWithResult(841);
- int DecayTotal = ( DecayRate * RecoilTotal) >> 16; // Calculates Decay using stored values.
- int PRDivisor = DecayTotal / (DecayLength * (DecayLength + 1));
- int PRMod = DecayTotal % (DecayLength * (DecayLength + 1));
- int PRRemainder = 0;
- int PRSub = 0;
- for (int a = 0; a < TransLength; a++) // Recoil Transient.
- {
- PTRemainder = PTRemainder + PTMod * (Translength + 1 - a);
- PTSub = PTRemainder / (TransLength * (TransLength + 1)/2);
- PTRemainder = PTRemainder % (TransLength * (TransLength + 1)/2);
- SetActorPitch(0, GetActorPitch(0) - (PTDivisor * (TransLength + 1 - a) + PTSub));
- PTSub = 0;
- Delay(1);
- }
- Delay(1);
- for (int b = 0; b < DecayLength; b++) // Recoil Recovery, part 1.
- {
- PRRemainder = PRRemainder + PRMod * b + 1;
- PRSub = PRRemainder / (DecayLength * (Decaylength + 1));
- PRRemainder = PRRemainder % (DecayLength * (Decaylength + 1));
- SetActorPitch(0, GetActorPitch(0) + (((PRDivisor * (b + 1) + PRSub) * ACS_ExecuteWithResult(842)) >> 16) );
- PRSub = 0;
- Delay(1);
- }
- for (int c = 0; c < DecayLength; c++) // Recoil Recovery, part 2.
- {
- PRRemainder = PRRemainder + PRMod * (DecayLength + 1 - c);
- PRSub = PRRemainder / (DecayLength * (Decaylength + 1));
- PRRemainder = PRRemainder % (DecayLength * (Decaylength + 1));
- SetActorPitch(0, GetActorPitch(0) + (((PRDivisor * (DecayLength + 1 - c) + PRSub ) * ACS_ExecuteWithResult(842)) >> 16) );
- PRSub = 0;
- Delay(1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement