mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
commit
4a8f24b59c
BIN
ace_fcs.dll
BIN
ace_fcs.dll
Binary file not shown.
@ -122,6 +122,7 @@ PREP(moveToTempGroup);
|
|||||||
PREP(muteUnit);
|
PREP(muteUnit);
|
||||||
PREP(numberToDigits);
|
PREP(numberToDigits);
|
||||||
PREP(numberToDigitsString);
|
PREP(numberToDigitsString);
|
||||||
|
PREP(numberToString);
|
||||||
PREP(onAnswerRequest);
|
PREP(onAnswerRequest);
|
||||||
PREP(onLoadRscDisplayChannel);
|
PREP(onLoadRscDisplayChannel);
|
||||||
PREP(owned);
|
PREP(owned);
|
||||||
|
@ -19,40 +19,35 @@ private ["_projectile", "_adjustDir", "_adjustUp", "_adjustSpeed", "_vdir", "_di
|
|||||||
_projectile = _this select 0;
|
_projectile = _this select 0;
|
||||||
_adjustDir = _this select 1;
|
_adjustDir = _this select 1;
|
||||||
_adjustUp = _this select 2;
|
_adjustUp = _this select 2;
|
||||||
_adjustSpeed = _this select 3;
|
|
||||||
|
|
||||||
if (isNil "_adjustSpeed") then {
|
_adjustSpeed = if (count _this > 3) then {
|
||||||
_adjustSpeed = 0;
|
_this select 3
|
||||||
|
} else {
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
["CPD", [_fnc_scriptNameParent, _adjustDir, _adjustUp, _adjustSpeed], nil, false] call FUNC(log);
|
["CPD", [_fnc_scriptNameParent, _adjustDir, _adjustUp, _adjustSpeed], nil, false] call FUNC(log);
|
||||||
|
|
||||||
// get old direction vector
|
// get old direction vector
|
||||||
_vdir = vectorDir _projectile;
|
_vdir = vectorNormalized velocity _projectile;
|
||||||
|
|
||||||
// get azimuth and inclination and apply corrections
|
// get azimuth and inclination and apply corrections
|
||||||
_dir = (_vdir select 0) atan2 (_vdir select 1) + _adjustDir;
|
_dir = (_vdir select 0) atan2 (_vdir select 1) + _adjustDir;
|
||||||
_up = sqrt ((_vdir select 1) ^ 2 + (_vdir select 0) ^ 2) atan2 - (_vdir select 2) + _adjustUp;
|
_up = asin (_vdir select 2) + _adjustUp;
|
||||||
|
|
||||||
// get new direction vector (this is a unit vector)
|
// get new direction vector (this is a unit vector)
|
||||||
_vdir = [
|
_vdir = [
|
||||||
sin _dir * sin _up,
|
sin _dir * cos _up,
|
||||||
cos _dir * sin _up,
|
cos _dir * cos _up,
|
||||||
- cos _up
|
sin _up
|
||||||
];
|
];
|
||||||
|
|
||||||
// get best up vector
|
// get best up vector
|
||||||
_l = sqrt ((_vdir select 0) ^ 2 + (_vdir select 1) ^ 2); if (_l == 0) then {diag_log text format ["[ACE] ERROR: %1, %2, %3, %4, %5, %6, %7", _projectile, _adjustDir, _adjustUp, vectorDir _projectile, _vdir, _dir, _up]};
|
_vlat = vectorNormalized (_vdir vectorCrossProduct [0,0,1]);
|
||||||
_r = -(_vdir select 2) / _l;
|
_vup = _vlat vectorCrossProduct _vdir;
|
||||||
|
|
||||||
_vup = [
|
|
||||||
(_vdir select 0) * _r,
|
|
||||||
(_vdir select 1) * _r,
|
|
||||||
_l
|
|
||||||
];
|
|
||||||
|
|
||||||
// get new speed vector. Keep total speed, but change to new direction. Yay for vector commands.
|
// get new speed vector. Keep total speed, but change to new direction. Yay for vector commands.
|
||||||
_vel = _vdir vectorMultiply _adjustSpeed + vectorMagnitude velocity _projectile;
|
_vel = _vdir vectorMultiply (_adjustSpeed + vectorMagnitude velocity _projectile);
|
||||||
|
|
||||||
// set projectile direction dir and up. Projectiles are long objects, especially with tracers, so it would look dumb otherwise.
|
// set projectile direction dir and up. Projectiles are long objects, especially with tracers, so it would look dumb otherwise.
|
||||||
_projectile setVectorDirAndUp [_vdir, _vup];
|
_projectile setVectorDirAndUp [_vdir, _vup];
|
||||||
|
25
addons/common/functions/fnc_numberToString.sqf
Normal file
25
addons/common/functions/fnc_numberToString.sqf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
*
|
||||||
|
* Converts a number to a string without losing as much precission as str or format.
|
||||||
|
*
|
||||||
|
* Argument:
|
||||||
|
* 0: A number (Number)
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* The number as string (String)
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_number", "_decimals"];
|
||||||
|
|
||||||
|
_number = _this select 0;
|
||||||
|
|
||||||
|
_decimals = str (abs(_number) mod 1);
|
||||||
|
_decimals = toArray _decimals;
|
||||||
|
_decimals deleteAt 0;
|
||||||
|
|
||||||
|
if (_number < 0) exitWith {
|
||||||
|
format ["-%1%2", floor abs(_number), toString _decimals];
|
||||||
|
};
|
||||||
|
format ["%1%2", floor _number, toString _decimals];
|
@ -48,7 +48,8 @@ _offset = 0;
|
|||||||
_velocityCorrection = (vectorMagnitude velocity _projectile) -
|
_velocityCorrection = (vectorMagnitude velocity _projectile) -
|
||||||
getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
|
getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
|
||||||
|
|
||||||
[_projectile, (_vehicle getVariable format ["%1_%2", QGVAR(Azimuth), _turret]), _offset, _velocityCorrection] call EFUNC(common,changeProjectileDirection);
|
[_projectile, (_vehicle getVariable format ["%1_%2", QGVAR(Azimuth), _turret]), _offset, -_velocityCorrection] call EFUNC(common,changeProjectileDirection);
|
||||||
|
|
||||||
// Air burst missile
|
// Air burst missile
|
||||||
|
|
||||||
// handle locally only
|
// handle locally only
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_vehicle", "_turret", "_turretConfig", "_distance", "_magazines", "_userChange"];
|
private ["_vehicle", "_turret", "_turretConfig", "_distance", "_magazines", "_showHint", "_playSound"];
|
||||||
|
|
||||||
_vehicle = _this select 0;
|
_vehicle = _this select 0;
|
||||||
_turret = _this select 1;
|
_turret = _this select 1;
|
||||||
@ -162,11 +162,20 @@ _FCSElevation = [];
|
|||||||
[_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation] call EFUNC(common,setVariablePublic);
|
[_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation] call EFUNC(common,setVariablePublic);
|
||||||
[_vehicle, format ["%1_%2", QGVAR(Azimuth), _turret], _FCSAzimuth] call EFUNC(common,setVariablePublic);
|
[_vehicle, format ["%1_%2", QGVAR(Azimuth), _turret], _FCSAzimuth] call EFUNC(common,setVariablePublic);
|
||||||
|
|
||||||
_userChange = true;
|
_showHint = false;
|
||||||
if( (count _this) > 3) then {
|
if( (count _this) > 3) then {
|
||||||
_userChange = _this select 3;
|
_showHint = _this select 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
if(_userChange) then {
|
_playSound = true;
|
||||||
|
if( (count _this) > 3) then {
|
||||||
|
_playSound = _this select 4;
|
||||||
|
};
|
||||||
|
|
||||||
|
if(_playSound) then {
|
||||||
|
playSound "ACE_Sound_Click";
|
||||||
|
};
|
||||||
|
|
||||||
|
if(_showHint) then {
|
||||||
[format ["%1: %2", localize "STR_ACE_FCS_ZeroedTo", _distance]] call EFUNC(common,displayTextStructured);
|
[format ["%1: %2", localize "STR_ACE_FCS_ZeroedTo", _distance]] call EFUNC(common,displayTextStructured);
|
||||||
};
|
};
|
@ -4,4 +4,4 @@ if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) ex
|
|||||||
if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false};
|
if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false};
|
||||||
|
|
||||||
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -1, false] call FUNC(keyDown);
|
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -1, false] call FUNC(keyDown);
|
||||||
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -1, false] call FUNC(keyUp);
|
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -1, false, false] call FUNC(keyUp);
|
@ -58,12 +58,13 @@ double traceBullet(double initSpeed, double airFriction, double angle, double an
|
|||||||
while (i < MAXITERATIONS) {
|
while (i < MAXITERATIONS) {
|
||||||
lastPosX = posX;
|
lastPosX = posX;
|
||||||
lastPosY = posY;
|
lastPosY = posY;
|
||||||
simulationStep = 0.1 - 0.049 * (posX / posTargetX);
|
|
||||||
velMag = sqrt(pow(velX, 2) + pow(velY, 2));
|
velMag = sqrt(pow(velX, 2) + pow(velY, 2));
|
||||||
|
posX += velX * simulationStep * 0.5;
|
||||||
|
posY += velY * simulationStep * 0.5;
|
||||||
velX += simulationStep * (velX * velMag * airFriction);
|
velX += simulationStep * (velX * velMag * airFriction);
|
||||||
velY += simulationStep * (velY * velMag * airFriction - 9.81);
|
velY += simulationStep * (velY * velMag * airFriction - 9.80665);
|
||||||
posX += velX * simulationStep;
|
posX += velX * simulationStep * 0.5;
|
||||||
posY += velY * simulationStep;
|
posY += velY * simulationStep * 0.5;
|
||||||
if (posX >= posTargetX) { break; }
|
if (posX >= posTargetX) { break; }
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user