Tweaking PowderEffects/AirRestitance

This commit is contained in:
PabstMirror 2015-04-05 17:07:55 -05:00
parent 3e77eb9737
commit c768ef65b2
5 changed files with 121 additions and 68 deletions

View File

@ -4,19 +4,19 @@ Name: AGM_Artillery_fnc_simulateCalcRangeTableLine
Author: Pabst Mirror
Description:
Builds a rangeTable line for a certian range, given muzzle velocity and air friction, returns [] if out of range.
Builds a rangeTable line for a certian range, given muzzle velocity and air friction, returns [] if out of range.
Parameters:
0: NUMBER - Muzzle Velocity
1: NUMBER - Air Friction
2: NUMBER - Range To Hit
0: NUMBER - Muzzle Velocity
1: NUMBER - Air Friction
2: NUMBER - Range To Hit
Returns:
ARRAY - Range Table Line Data (see return line)
ARRAY - Range Table Line Data (see return line)
Example:
[300, -0.0001, 3000] call AGM_Artillery_fnc_simulateCalcRangeTableLine
*/
[300, -0.0001, 3000] call AGM_Artillery_fnc_simulateCalcRangeTableLine
*/
#include "script_component.hpp"
#define TIME_STEP (1/50)

View File

@ -44,7 +44,7 @@ _wind = [_crosswind, _tailWind, 0];
_gravity = [0,0,-9.8];
_currentPos = [0,0,0];
_muzzleVelocity = _muzzleVelocity * (1 + ((((_temp + 273.13) / 288.13 - 1) / 2.5 + 1 ) - 1));
_muzzleVelocity = _muzzleVelocity * (((_temp + 273.13) / 288.13 - 1) / 30 + 1);
_currentVelocity = [0, (_muzzleVelocity * cos _angleDeg), (_muzzleVelocity * sin _angleDeg)];
_currentTime = 0;

View File

@ -29,6 +29,27 @@ if (!GVAR(airResistanceEnabled)) exitWith {};
if (_unit distance ACE_player > 3000) exitWith {false}; // Large enough distance to not simulate any wind deflection.
if (!GVAR(EnableForAI) && !([_unit] call EFUNC(common,isPlayer))) exitWith {false};
//Hack Until these are intergrated:
if (isNil QEGVAR(weather,currentRelativeDensity)) then {
EGVAR(weather,currentRelativeDensity) = 1;
};
if (isNil QEGVAR(weather,currentTemperature)) then {
EGVAR(weather,currentTemperature) = 20;
};
//powder effects:
_temperature = EGVAR(weather,currentTemperature);
_newMuzzleVelocityCoefficent = (((_temperature + 273.13) / 288.13 - 1) / 30 + 1);
if (_newMuzzleVelocityCoefficent != 1) then {
_bulletVelocity = velocity _projectile;
systemChat format ["Start Vel: %1", _bulletVelocity];
_bulletSpeed = vectorMagnitude _bulletVelocity;
_bulletVelocity = (vectorNormalized _bulletVelocity) vectorMultiply (_bulletSpeed * _newMuzzleVelocityCoefficent);
systemChat format ["New Vel: %1", _bulletVelocity];
_projectile setVelocity _bulletVelocity;
_muzzleVelocity = _muzzleVelocity + _muzzleVelocityShift;
};
// if (_bullet isKindOf "BulletBase") then {
[{
@ -54,7 +75,7 @@ if (!GVAR(EnableForAI) && !([_unit] call EFUNC(common,isPlayer))) exitWith {fals
// _accelRef = (vectorNormalized _bulletVelocity) vectorMultiply (_dragRef);
// _bulletVelocity = _bulletVelocity vectorDiff _accelRef;
_drag = _deltaT * _airFriction * _trueSpeed;
_drag = _deltaT * _airFriction * _trueSpeed * EGVAR(weather,currentRelativeDensity);
_accel = _trueVelocity vectorMultiply (_drag);
_bulletVelocity = _bulletVelocity vectorAdd _accel;
@ -62,6 +83,6 @@ if (!GVAR(EnableForAI) && !([_unit] call EFUNC(common,isPlayer))) exitWith {fals
_shell setVelocity _bulletVelocity;
// TODO expand with advanced ballistics functionality.
}, 0, [_projectile, -0.0001, time]] call CBA_fnc_addPerFrameHandler;
}, 0, [_projectile, MK6_82mm_AIR_FRICTION, time]] call CBA_fnc_addPerFrameHandler;
// };

View File

@ -30,65 +30,97 @@ case ((abs(_muzzleVelocity - 70) < 0.00001) && ((abs(_airFriction - -0.0001) < 0
["450","979","113","11.6","0.8","0.6","-0.5","1.2","-1.2","-0.2","0.2"]
]
};
case ((abs(_muzzleVelocity - 200) < 0.00001) && ((abs(_airFriction - -0.0001) < 0.00001))): {
case ((abs(_muzzleVelocity - 140) < 0.00001) && ((abs(_airFriction - -0.0001) < 0.00001))): {
[
["450","1527","1","37.3","13.4","6.3","-6.0","1.0","-1.0","-1.0","1.0"],
["500","1519","1","37.2","12.1","6.3","-6.0","1.1","-1.1","-1.1","1.1"],
["550","1510","1","37.2","11.0","6.4","-6.0","1.2","-1.2","-1.3","1.2"],
["600","1502","1","37.2","10.1","6.4","-6.1","1.3","-1.3","-1.4","1.3"],
["650","1494","1","37.2","9.4","6.5","-6.1","1.4","-1.4","-1.5","1.4"],
["700","1485","2","37.1","8.7","6.5","-6.2","1.5","-1.5","-1.6","1.5"],
["750","1477","2","37.1","8.2","6.6","-6.2","1.6","-1.6","-1.7","1.6"],
["800","1468","2","37.0","7.7","6.7","-6.3","1.7","-1.7","-1.8","1.8"],
["850","1460","2","37.0","7.2","6.7","-6.3","1.8","-1.8","-2.0","1.9"],
["900","1451","2","37.0","6.8","6.8","-6.4","1.9","-2.0","-2.1","2.0"],
["950","1443","2","36.9","6.5","6.9","-6.4","2.0","-2.1","-2.2","2.1"],
["1000","1434","2","36.9","6.2","6.9","-6.5","2.1","-2.2","-2.3","2.2"],
["1050","1425","2","36.8","5.9","7.0","-6.6","2.2","-2.3","-2.5","2.3"],
["1100","1417","3","36.8","5.6","7.1","-6.6","2.3","-2.4","-2.6","2.4"],
["1150","1408","3","36.7","5.4","7.1","-6.7","2.5","-2.5","-2.7","2.5"],
["1200","1399","3","36.6","5.2","7.2","-6.7","2.6","-2.6","-2.8","2.7"],
["1250","1390","3","36.6","5.0","7.3","-6.8","2.7","-2.7","-2.9","2.8"],
["1300","1381","3","36.5","4.8","7.4","-6.9","2.8","-2.8","-3.0","2.9"],
["1350","1372","3","36.4","4.6","7.4","-6.9","2.9","-2.9","-3.2","3.0"],
["1400","1362","4","36.4","4.4","7.5","-7.0","3.0","-3.0","-3.3","3.1"],
["1450","1353","4","36.3","4.3","7.6","-7.1","3.1","-3.1","-3.4","3.2"],
["1500","1344","4","36.2","4.2","7.7","-7.1","3.2","-3.2","-3.5","3.4"],
["1550","1334","4","36.1","4.0","7.7","-7.2","3.3","-3.3","-3.7","3.5"],
["1600","1324","4","36.0","3.9","7.8","-7.3","3.4","-3.4","-3.8","3.6"],
["1650","1314","4","35.9","3.8","7.9","-7.3","3.5","-3.5","-3.9","3.7"],
["1700","1304","5","35.8","3.7","7.9","-7.4","3.6","-3.6","-4.0","3.8"],
["1750","1294","5","35.7","3.6","8.0","-7.5","3.7","-3.7","-4.2","3.9"],
["1800","1284","5","35.6","3.5","8.1","-7.6","3.8","-3.9","-4.3","4.0"],
["1850","1274","5","35.5","3.4","8.2","-7.6","3.9","-4.0","-4.4","4.2"],
["1900","1263","6","35.4","3.3","8.2","-7.7","4.0","-4.1","-4.5","4.3"],
["1950","1253","6","35.2","3.2","8.3","-7.8","4.1","-4.2","-4.7","4.4"],
["2000","1242","6","35.1","3.1","8.4","-7.8","4.3","-4.3","-4.8","4.5"],
["2050","1231","7","35.0","3.0","8.4","-7.9","4.4","-4.4","-4.9","4.7"],
["2100","1219","7","34.8","2.9","8.5","-8.0","4.5","-4.5","-5.0","4.8"],
["2150","1208","7","34.7","2.9","8.5","-8.0","4.6","-4.6","-5.2","4.9"],
["2200","1196","8","34.5","2.8","8.6","-8.1","4.7","-4.7","-5.3","5.0"],
["2250","1184","8","34.3","2.7","8.7","-8.2","4.8","-4.8","-5.4","5.1"],
["2300","1171","9","34.2","2.7","8.7","-8.2","4.9","-4.9","-5.5","5.2"],
["2350","1158","9","34.0","2.6","8.8","-8.3","5.0","-5.0","-5.7","5.4"],
["2400","1145","10","33.8","2.5","8.8","-8.3","5.1","-5.1","-5.8","5.5"],
["2450","1132","10","33.6","2.5","8.9","-8.4","5.2","-5.2","-5.9","5.6"],
["2500","1118","11","33.3","2.4","8.9","-8.4","5.3","-5.3","-6.0","5.7"],
["2550","1103","12","33.1","2.4","9.0","-8.5","5.4","-5.4","-6.1","5.8"],
["2600","1088","13","32.8","2.3","9.0","-8.5","5.5","-5.5","-6.2","5.9"],
["2650","1072","14","32.6","2.2","9.0","-8.6","5.6","-5.6","-6.4","6.0"],
["2700","1056","15","32.3","2.2","9.0","-8.6","5.7","-5.8","-6.5","6.1"],
["2750","1038","16","31.9","2.1","9.1","-8.6","5.9","-5.9","-6.6","6.3"],
["2800","1020","18","31.6","2.1","9.1","-8.6","6.0","-6.0","-6.7","6.4"],
["2850","1000","20","31.2","2.0","9.1","-8.6","6.1","-6.1","-6.8","6.5"],
["2900","978","22","30.8","1.9","9.0","-8.6","6.2","-6.2","-6.9","6.5"],
["2950","954","26","30.3","1.9","9.0","-8.6","6.3","-6.3","-7.0","6.6"],
["3000","927","31","29.7","1.8","8.9","-8.5","6.4","-6.4","-7.1","6.7"],
["3050","894","38","29.0","1.7","8.8","-8.4","6.5","-6.6","-7.2","6.8"],
["3100","849","54","27.9","1.6","8.5","-8.3","6.6","-6.7","-7.2","6.8"]
["250","1527","2","27.2","9.9","2.6","-2.4","0.6","-0.6","-0.3","0.3"],
["300","1512","2","27.2","8.3","2.7","-2.4","0.7","-0.7","-0.4","0.4"],
["350","1497","3","27.1","7.1","2.7","-2.5","0.8","-0.9","-0.5","0.4"],
["400","1482","3","27.1","6.2","2.7","-2.5","1.0","-1.0","-0.5","0.5"],
["450","1467","3","27.0","5.6","2.8","-2.5","1.1","-1.1","-0.6","0.6"],
["500","1451","4","27.0","5.0","2.9","-2.6","1.2","-1.2","-0.6","0.6"],
["550","1436","4","26.9","4.6","2.9","-2.6","1.3","-1.3","-0.7","0.7"],
["600","1420","5","26.8","4.2","3.0","-2.7","1.4","-1.5","-0.8","0.8"],
["650","1404","5","26.8","3.9","3.0","-2.7","1.6","-1.6","-0.9","0.8"],
["700","1388","6","26.7","3.6","3.1","-2.8","1.7","-1.7","-0.9","0.9"],
["750","1372","6","26.6","3.4","3.2","-2.8","1.8","-1.8","-1.0","1.0"],
["800","1355","7","26.5","3.2","3.2","-2.9","1.9","-1.9","-1.1","1.1"],
["850","1338","8","26.4","3.0","3.3","-2.9","2.0","-2.1","-1.1","1.1"],
["900","1321","8","26.2","2.8","3.4","-3.0","2.2","-2.2","-1.2","1.2"],
["950","1303","9","26.1","2.7","3.4","-3.1","2.3","-2.3","-1.3","1.2"],
["1000","1285","10","26.0","2.6","3.5","-3.1","2.4","-2.4","-1.4","1.3"],
["1050","1266","11","25.8","2.4","3.5","-3.2","2.5","-2.5","-1.4","1.4"],
["1100","1247","12","25.7","2.3","3.6","-3.3","2.6","-2.7","-1.5","1.4"],
["1150","1228","13","25.5","2.2","3.7","-3.3","2.7","-2.8","-1.6","1.5"],
["1200","1207","14","25.3","2.1","3.7","-3.4","2.9","-2.9","-1.7","1.6"],
["1250","1186","15","25.1","2.0","3.8","-3.4","3.0","-3.0","-1.7","1.7"],
["1300","1163","17","24.8","1.9","3.8","-3.5","3.1","-3.1","-1.8","1.7"],
["1350","1140","19","24.6","1.9","3.9","-3.5","3.2","-3.2","-1.9","1.8"],
["1400","1115","21","24.3","1.8","3.9","-3.6","3.4","-3.4","-1.9","1.9"],
["1450","1088","24","23.9","1.7","4.0","-3.6","3.5","-3.5","-2.0","1.9"],
["1500","1060","27","23.6","1.6","4.0","-3.7","3.6","-3.6","-2.1","2.0"],
["1550","1028","32","23.1","1.5","4.0","-3.7","3.7","-3.7","-2.1","2.1"],
["1600","991","38","22.6","1.5","4.0","-3.7","3.8","-3.9","-2.2","2.1"],
["1650","947","49","21.9","1.4","4.0","-3.7","3.9","-4.0","-2.3","2.2"],
["1700","888","71","21.0","1.3","3.9","-3.6","4.1","-4.1","-2.3","2.2"]
]
};
case ((abs(_muzzleVelocity - 200) < 0.00001) && ((abs(_airFriction - -0.0001) < 0.00001))): {
[
["450","1527","1","37.3","13.4","6.3","-6.0","0.2","-0.2","-1.0","1.0"],
["500","1519","1","37.2","12.1","6.3","-6.0","0.2","-0.2","-1.1","1.1"],
["550","1510","1","37.2","11.0","6.4","-6.0","0.2","-0.2","-1.3","1.2"],
["600","1502","1","37.2","10.1","6.4","-6.1","0.2","-0.2","-1.4","1.3"],
["650","1494","1","37.2","9.4","6.5","-6.1","0.2","-0.3","-1.5","1.4"],
["700","1485","2","37.1","8.7","6.5","-6.2","0.2","-0.3","-1.6","1.5"],
["750","1477","2","37.1","8.2","6.6","-6.2","0.3","-0.3","-1.7","1.6"],
["800","1468","2","37.0","7.7","6.7","-6.3","0.3","-0.3","-1.8","1.8"],
["850","1460","2","37.0","7.2","6.7","-6.3","0.3","-0.3","-2.0","1.9"],
["900","1451","2","37.0","6.8","6.8","-6.4","0.3","-0.3","-2.1","2.0"],
["950","1443","2","36.9","6.5","6.9","-6.4","0.3","-0.4","-2.2","2.1"],
["1000","1434","2","36.9","6.2","6.9","-6.5","0.4","-0.4","-2.3","2.2"],
["1050","1425","2","36.8","5.9","7.0","-6.6","0.4","-0.4","-2.5","2.3"],
["1100","1417","3","36.8","5.6","7.1","-6.6","0.4","-0.4","-2.6","2.4"],
["1150","1408","3","36.7","5.4","7.1","-6.7","0.4","-0.4","-2.7","2.5"],
["1200","1399","3","36.6","5.2","7.2","-6.7","0.4","-0.4","-2.8","2.7"],
["1250","1390","3","36.6","5.0","7.3","-6.8","0.4","-0.4","-2.9","2.8"],
["1300","1381","3","36.5","4.8","7.4","-6.9","0.5","-0.5","-3.0","2.9"],
["1350","1372","3","36.4","4.6","7.4","-6.9","0.5","-0.5","-3.2","3.0"],
["1400","1362","4","36.4","4.4","7.5","-7.0","0.5","-0.5","-3.3","3.1"],
["1450","1353","4","36.3","4.3","7.6","-7.1","0.5","-0.5","-3.4","3.2"],
["1500","1344","4","36.2","4.2","7.7","-7.1","0.5","-0.5","-3.5","3.4"],
["1550","1334","4","36.1","4.0","7.7","-7.2","0.6","-0.5","-3.7","3.5"],
["1600","1324","4","36.0","3.9","7.8","-7.3","0.6","-0.6","-3.8","3.6"],
["1650","1314","4","35.9","3.8","7.9","-7.3","0.6","-0.6","-3.9","3.7"],
["1700","1304","5","35.8","3.7","7.9","-7.4","0.6","-0.6","-4.0","3.8"],
["1750","1294","5","35.7","3.6","8.0","-7.5","0.6","-0.6","-4.2","3.9"],
["1800","1284","5","35.6","3.5","8.1","-7.6","0.6","-0.7","-4.3","4.0"],
["1850","1274","5","35.5","3.4","8.2","-7.6","0.7","-0.7","-4.4","4.2"],
["1900","1263","6","35.4","3.3","8.2","-7.7","0.7","-0.7","-4.5","4.3"],
["1950","1253","6","35.2","3.2","8.3","-7.8","0.7","-0.7","-4.7","4.4"],
["2000","1242","6","35.1","3.1","8.4","-7.8","0.7","-0.7","-4.8","4.5"],
["2050","1231","7","35.0","3.0","8.4","-7.9","0.7","-0.7","-4.9","4.7"],
["2100","1219","7","34.8","2.9","8.5","-8.0","0.8","-0.7","-5.0","4.8"],
["2150","1208","7","34.7","2.9","8.5","-8.0","0.8","-0.8","-5.2","4.9"],
["2200","1196","8","34.5","2.8","8.6","-8.1","0.8","-0.8","-5.3","5.0"],
["2250","1184","8","34.3","2.7","8.7","-8.2","0.8","-0.8","-5.4","5.1"],
["2300","1171","9","34.2","2.7","8.7","-8.2","0.8","-0.8","-5.5","5.2"],
["2350","1158","9","34.0","2.6","8.8","-8.3","0.8","-0.8","-5.7","5.4"],
["2400","1145","10","33.8","2.5","8.8","-8.3","0.9","-0.8","-5.8","5.5"],
["2450","1132","10","33.6","2.5","8.9","-8.4","0.9","-0.9","-5.9","5.6"],
["2500","1118","11","33.3","2.4","8.9","-8.4","0.9","-0.9","-6.0","5.7"],
["2550","1103","12","33.1","2.4","9.0","-8.5","0.9","-0.9","-6.1","5.8"],
["2600","1088","13","32.8","2.3","9.0","-8.5","0.9","-0.9","-6.2","5.9"],
["2650","1072","14","32.6","2.2","9.0","-8.6","0.9","-0.9","-6.4","6.0"],
["2700","1056","15","32.3","2.2","9.0","-8.6","0.9","-1.0","-6.5","6.1"],
["2750","1038","16","31.9","2.1","9.1","-8.6","1.0","-1.0","-6.6","6.3"],
["2800","1020","18","31.6","2.1","9.1","-8.6","1.0","-1.0","-6.7","6.4"],
["2850","1000","20","31.2","2.0","9.1","-8.6","1.0","-1.0","-6.8","6.5"],
["2900","978","22","30.8","1.9","9.0","-8.6","1.0","-1.0","-6.9","6.5"],
["2950","954","26","30.3","1.9","9.0","-8.6","1.0","-1.1","-7.0","6.6"],
["3000","927","31","29.7","1.8","8.9","-8.5","1.1","-1.1","-7.1","6.7"],
["3050","894","38","29.0","1.7","8.8","-8.4","1.1","-1.1","-7.2","6.8"],
["3100","849","54","27.9","1.6","8.5","-8.3","1.1","-1.1","-7.2","6.8"]
]
};
default {systemChat "Error: MuzzleVelocity not found in LUT"; []};
};

View File

@ -11,4 +11,4 @@
#include "\z\ace\Addons\main\script_macros.hpp"
#define MK6_82mm_AIR_FRICTION -0.0001
#define MK6_82mm_AIR_FRICTION -0.000075