Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function int clamp (int x, int min, int max) {
- int realMin = min;
- int realMax = max;
- if (min > max) {
- realMax = min;
- realMin = max;
- }
- if (x > realMax)
- return realMax;
- else if (x < realMin)
- return realMin;
- else
- return x;
- }
- function int scaleValue (int x, int fromMin, int fromMax, int toMin, int toMax) {
- return (x - fromMin) * (toMax - toMin) / (fromMax - fromMin) + toMin;
- }
- function fixed scaleValueFixed (fixed x, fixed fromMin, fixed fromMax, fixed toMin, fixed toMax) {
- return fixedDiv (fixedMul (x - fromMin, toMax - toMin), fromMax - fromMin) + toMin;
- }
- script "S7_RecoilPitch" (fixed offset) { // Called like this in code: TNT1 A 0 acs_namedExecuteAlways ("S7_RecoilPitch", 0, 0.5 * 65535)
- fixed oldPitch = getActorPitch (0);
- fixed scaledoffset = scaleValueFixed (offset, -90.0, 90.0, -0.25, 0.25);
- fixed newPitch = clamp (oldPitch - scaledoffset, -0.25, 0.25);
- setActorPitch (0, newPitch);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement