mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
fcs for turrets
This commit is contained in:
parent
47d5befd12
commit
49f0b79962
@ -48,6 +48,7 @@ PREP(getConfigGunner);
|
||||
PREP(getDefaultAnim);
|
||||
PREP(getDoorTurrets);
|
||||
PREP(getForceWalkStatus);
|
||||
PREP(getGunner);
|
||||
PREP(getHitPoints);
|
||||
PREP(getHitPointsWithSelections);
|
||||
PREP(getInPosition);
|
||||
|
28
addons/common/functions/fnc_getGunner.sqf
Normal file
28
addons/common/functions/fnc_getGunner.sqf
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Get the gunner of a vehicle who uses the given weapon type. Requires every turret to have a different weapons.
|
||||
*
|
||||
* Argument:
|
||||
* 0: The vehicle (Object)
|
||||
* 1: weapon of the vehicle (String)
|
||||
*
|
||||
* Return value:
|
||||
* The turret gunner with this weapon (Object)
|
||||
*/
|
||||
|
||||
private ["_vehicle", "_weapon"];
|
||||
|
||||
_vehicle = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
|
||||
private "_gunner";
|
||||
_gunner = objNull;
|
||||
|
||||
{
|
||||
if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
|
||||
_gunner = _vehicle turretUnit _x;
|
||||
};
|
||||
} forEach allTurrets _vehicle;
|
||||
|
||||
_gunner
|
@ -28,7 +28,7 @@ class CfgVehicles {
|
||||
displayName = $STR_ACE_FCS_ResetFCS;
|
||||
enableInside = 1;
|
||||
condition = QUOTE(call FUNC(canResetFCS));
|
||||
statement = QUOTE([vehicle _player] call FUNC(reset););
|
||||
statement = QUOTE([ARR_2(_vehicle,[_player] call DEFUNC(common,getTurretIndex))] call FUNC(reset););
|
||||
showDisabled = 0;
|
||||
priority = 1;
|
||||
icon = "";
|
||||
@ -42,7 +42,7 @@ class CfgVehicles {
|
||||
displayName = $STR_ACE_FCS_ResetFCS;
|
||||
enableInside = 1;
|
||||
condition = QUOTE(call FUNC(canResetFCS));
|
||||
statement = QUOTE([vehicle _player] call FUNC(reset););
|
||||
statement = QUOTE([ARR_2(_vehicle,[_player] call DEFUNC(common,getTurretIndex))] call FUNC(reset););
|
||||
showDisabled = 0;
|
||||
priority = 1;
|
||||
icon = "";
|
||||
|
@ -13,17 +13,20 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicle", "_delta", "_min", "_max", "_distance"];
|
||||
private ["_vehicle", "_turret", "_delta", "_turretConfig", "_min", "_max", "_distance"];
|
||||
|
||||
_vehicle = _this select 0;
|
||||
_delta = _this select 1;
|
||||
_turret = _this select 1;
|
||||
_delta = _this select 2;
|
||||
|
||||
_min = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(MinDistance));
|
||||
_max = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(MaxDistance));
|
||||
_distance = _vehicle getVariable [QGVAR(Distance), _min];
|
||||
_turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
|
||||
|
||||
_min = getNumber (_turretConfig >> QGVAR(MinDistance));
|
||||
_max = getNumber (_turretConfig >> QGVAR(MaxDistance));
|
||||
_distance = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], _min];
|
||||
|
||||
_distance = _distance + _delta;
|
||||
_distance = _distance min _max;
|
||||
_distance = _distance max _min;
|
||||
|
||||
[_vehicle, 0, _distance] call FUNC(keyUp);
|
||||
[_vehicle, _turret, _distance] call FUNC(keyUp);
|
||||
|
@ -12,5 +12,4 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
ACE_player == gunner vehicle ACE_player
|
||||
&& {count ((vehicle ACE_player) getVariable [QGVAR(Magazines), []]) > 1}
|
||||
count ((vehicle ACE_player) getVariable [format ["%1_%2", QGVAR(Magazines), [vehicle ACE_player] call EFUNC(common,getTurretIndex)], []]) > 1
|
||||
|
@ -12,6 +12,5 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
ACE_player == gunner vehicle ACE_player
|
||||
&& {getNumber (configFile >> "CfgVehicles" >> typeOf vehicle ACE_player >> QGVAR(Enabled)) == 1}
|
||||
getNumber ([configFile >> "CfgVehicles" >> typeOf _vehicle, [_player] call EFUNC(common,getTurretIndex)] call EFUNC(common,getTurretConfigPath) >> QGVAR(Enabled)) == 1
|
||||
&& {cameraView == "GUNNER"}
|
||||
|
@ -12,38 +12,46 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weaponType", "_ammoType", "_magazineType", "_round", "_FCSMagazines", "_FCSElevation", "_offset"];
|
||||
private ["_vehicle", "_weapon", "_ammo", "_magazine", "_projectile"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_weaponType = _this select 1;
|
||||
_ammoType = _this select 4;
|
||||
_magazineType = _this select 5;
|
||||
_round = _this select 6;
|
||||
_vehicle = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
_ammo = _this select 4;
|
||||
_magazine = _this select 5;
|
||||
_projectile = _this select 6;
|
||||
|
||||
_FCSMagazines = _unit getVariable QGVAR(Magazines);
|
||||
_FCSElevation = _unit getVariable QGVAR(Elevation);
|
||||
private ["_gunner", "_turret"];
|
||||
|
||||
if (ACE_player != gunner _unit) exitWith {};
|
||||
if !(_magazineType in _FCSMagazines) exitWith {};
|
||||
_gunner = [_vehicle, _weapon] call EFUNC(common,getGunner);
|
||||
_turret = [_gunner] call EFUNC(common,getTurretIndex);
|
||||
|
||||
if (ACE_player != _gunner) exitWith {};
|
||||
|
||||
private ["_FCSMagazines", "_FCSElevation", "_offset"];
|
||||
|
||||
_FCSMagazines = _vehicle getVariable format ["%1_%2", QGVAR(Magazines), _turret];
|
||||
_FCSElevation = _vehicle getVariable format ["%1_%2", QGVAR(Elevation), _turret];
|
||||
|
||||
if !(_magazine in _FCSMagazines) exitWith {};
|
||||
|
||||
// GET ELEVATION OFFSET OF CURRENT MAGAZINE
|
||||
_offset = 0;
|
||||
{
|
||||
if (_x == _magazineType) exitWith {
|
||||
if (_x == _magazine) exitWith {
|
||||
_offset = _FCSElevation select _forEachIndex;
|
||||
};
|
||||
} forEach _FCSMagazines;
|
||||
|
||||
[_round, (_unit getVariable QGVAR(Azimuth)), _offset, 0] call EFUNC(common,changeProjectileDirection);
|
||||
[_projectile, (_vehicle getVariable format ["%1_%2", QGVAR(Azimuth), _turret]), _offset, 0] call EFUNC(common,changeProjectileDirection);
|
||||
|
||||
// Air burst missile
|
||||
// may need to get rewritten
|
||||
if (getNumber (configFile >> "CfgAmmo" >> _ammoType >> "ACE_Airburst") == 1) then {
|
||||
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_Airburst") == 1) then {
|
||||
_this spawn {
|
||||
_vehicle = _this select 0;
|
||||
_projectile = _this select 6;
|
||||
|
||||
_distance = _vehicle getVariable [QGVAR(Distance), currentZeroing _vehicle];
|
||||
_distance = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], currentZeroing _vehicle];
|
||||
|
||||
if (_distance < 50) exitWith {};
|
||||
if (_distance > 1500) exitWith {};
|
||||
|
@ -12,9 +12,11 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicle", "_distance", "_weaponDirection"];
|
||||
private ["_vehicle", "_turret", "_distance", "_weaponDirection"];
|
||||
|
||||
_vehicle = _this select 0;
|
||||
_turret = _this select 1;
|
||||
|
||||
_distance = call FUNC(getRange);
|
||||
|
||||
if !(call FUNC(canUseFCS)) exitWith {};
|
||||
@ -26,7 +28,7 @@ if (_distance == 0) then {
|
||||
_distance = [5, 5000, 0] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision
|
||||
};
|
||||
|
||||
_weaponDirection = _vehicle weaponDirection currentWeapon _vehicle;
|
||||
_weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret);
|
||||
|
||||
GVAR(Position) = [
|
||||
(getPos _vehicle select 0) + _distance * (_weaponDirection select 0),
|
||||
|
@ -12,18 +12,22 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicle", "_distance", "_magazines"];
|
||||
private ["_vehicle", "_turret", "_turretConfig", "_distance", "_magazines"];
|
||||
|
||||
_vehicle = _this select 0;
|
||||
_turret = _this select 1;
|
||||
|
||||
_turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
|
||||
|
||||
_distance = call FUNC(getRange);
|
||||
|
||||
_magazines = magazines _vehicle;
|
||||
|
||||
if (_distance == 0) then {
|
||||
_distance = [
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(DistanceInterval)), // @todo turret
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(MaxDistance)),
|
||||
getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(MinDistance))
|
||||
getNumber (_turretConfig >> QGVAR(DistanceInterval)),
|
||||
getNumber (_turretConfig >> QGVAR(MaxDistance)),
|
||||
getNumber (_turretConfig >> QGVAR(MinDistance))
|
||||
] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision
|
||||
};
|
||||
|
||||
@ -60,7 +64,7 @@ if (time - GVAR(time) > 1 and GVAR(time) != -1 and count _this < 3) then {
|
||||
private ["_magazineType", "_ammoType", "_initSpeed", "_airFriction", "_timeToLive", "_simulationStep"];
|
||||
|
||||
// estimate time to target
|
||||
_magazineType = currentMagazine _vehicle; // @todo turret magazine
|
||||
_magazineType = _vehicle currentMagazineTurret _turret;
|
||||
_ammoType = getText (configFile >> "CfgMagazines" >> _magazineType >> "ammo");
|
||||
_initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazineType >> "initSpeed");
|
||||
_airFriction = getNumber (configFile >> "CfgAmmo" >> _ammoType >> "airFriction");
|
||||
@ -111,7 +115,7 @@ GVAR(time) = -1;
|
||||
private ["_viewDiff", "_FCSAzimuth", "_FCSMagazines", "_FCSElevation"];
|
||||
|
||||
// CALCULATE AZIMUTH CORRECTION
|
||||
_viewDiff = _vehicle getVariable QGVAR(ViewDiff);
|
||||
_viewDiff = _vehicle getVariable format ["%1_%2", QGVAR(ViewDiff), _turret];
|
||||
_FCSAzimuth = _movingAzimuth;
|
||||
|
||||
if (_viewDiff != 0) then {
|
||||
@ -130,7 +134,7 @@ _FCSElevation = [];
|
||||
if !(getText (configFile >> "CfgAmmo" >> _ammoType >> "simulation") == "shotMissile") then {
|
||||
private ["_maxElev", "_initSpeed", "_airFriction", "_offset"];
|
||||
|
||||
_maxElev = getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "Turrets" >> "MainTurret" >> "maxElev"); // @todo turret
|
||||
_maxElev = getNumber (_turretConfig >> "maxElev");
|
||||
_initSpeed = getNumber (configFile >> "CfgMagazines" >> _x >> "initSpeed");
|
||||
_airFriction = getNumber (configFile >> "CfgAmmo" >> _ammoType >> "airFriction");
|
||||
|
||||
@ -142,9 +146,9 @@ _FCSElevation = [];
|
||||
};
|
||||
} forEach _magazines;
|
||||
|
||||
_vehicle setVariable [QGVAR(Distance), _distance, true];
|
||||
_vehicle setVariable [QGVAR(Magazines), _FCSMagazines, true];
|
||||
_vehicle setVariable [QGVAR(Elevation), _FCSElevation, true];
|
||||
_vehicle setVariable [QGVAR(Azimuth), _FCSAzimuth, true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Distance), _turret], _distance, true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Magazines), _turret], _FCSMagazines, true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation, true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Azimuth), _turret], _FCSAzimuth, true];
|
||||
|
||||
[format ["%1: %2", localize "STR_ACE_FCS_ZeroedTo", _distance]] call EFUNC(common,displayTextStructured);
|
||||
|
@ -16,29 +16,31 @@ private "_vehicle";
|
||||
|
||||
_vehicle = _this select 0;
|
||||
|
||||
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(Enabled)) == 1) then { // @todo for all turrets
|
||||
_vehicle addEventHandler ["Fired", {_this call FUNC(firedEH)}];
|
||||
{
|
||||
if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(Enabled)) == 1) then { // @todo for all turrets
|
||||
_vehicle addEventHandler ["Fired", {_this call FUNC(firedEH)}];
|
||||
|
||||
_vehicle setVariable [QGVAR(Distance), 0, true];
|
||||
_vehicle setVariable [QGVAR(Magazines), [], true];
|
||||
_vehicle setVariable [QGVAR(Elevation), [], true];
|
||||
_vehicle setVariable [QGVAR(Azimuth), 0, true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Distance), _x], 0, true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Magazines), _x], [], true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Elevation), _x], [], true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(Azimuth), _x], 0, true];
|
||||
|
||||
// calculate offset between gunner camera and muzzle position
|
||||
if !(_vehicle isKindOf "Air") then {
|
||||
private ["_turretConfig", "_gunBeg", "_gunnerView", "_gunBegPos", "_gunnerViewPos", "_viewDiff"];
|
||||
// calculate offset between gunner camera and muzzle position
|
||||
if !(_vehicle isKindOf "Air") then {
|
||||
private ["_turretConfig", "_gunBeg", "_gunnerView", "_gunBegPos", "_gunnerViewPos", "_viewDiff"];
|
||||
|
||||
_turretConfig = configFile >> "CfgVehicles" >> typeOf _vehicle >> "Turrets" >> "MainTurret";
|
||||
_turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _x] call EFUNC(common,getTurretConfigPath);
|
||||
|
||||
_gunBeg = getText (_turretConfig >> "gunBeg"); // @todo player turret path
|
||||
_gunnerView = getText (_turretConfig >> "memoryPointGunnerOptics"); // @todo player turret path
|
||||
_gunBeg = getText (_turretConfig >> "gunBeg"); // @todo player turret path
|
||||
_gunnerView = getText (_turretConfig >> "memoryPointGunnerOptics"); // @todo player turret path
|
||||
|
||||
_gunBegPos = (_vehicle selectionPosition _gunBeg) select 0;
|
||||
_gunnerViewPos = (_vehicle selectionPosition _gunnerView) select 0;
|
||||
_viewDiff = _gunBegPos - _gunnerViewPos;
|
||||
_gunBegPos = (_vehicle selectionPosition _gunBeg) select 0;
|
||||
_gunnerViewPos = (_vehicle selectionPosition _gunnerView) select 0;
|
||||
_viewDiff = _gunBegPos - _gunnerViewPos;
|
||||
|
||||
_vehicle setVariable [QGVAR(ViewDiff), _viewDiff, true];
|
||||
} else {
|
||||
_vehicle setVariable [QGVAR(ViewDiff), 0, true];
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(ViewDiff), _x], _viewDiff, true];
|
||||
} else {
|
||||
_vehicle setVariable [format ["%1_%2", QGVAR(ViewDiff), _x], 0, true];
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach allTurrets _vehicle;
|
||||
|
@ -9,7 +9,7 @@
|
||||
if !(!GVAR(enabled) && {call FUNC(canUseRangefinder) || FUNC(canUseFCS)}) exitWith {false};
|
||||
|
||||
// Statement
|
||||
[vehicle ACE_player] call FUNC(keyDown);
|
||||
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call FUNC(keyDown);
|
||||
// Return false so it doesn't block the rest weapon action
|
||||
false
|
||||
},
|
||||
@ -28,7 +28,7 @@
|
||||
if !(GVAR(enabled) && FUNC(canUseFCS)) exitWith {false};
|
||||
|
||||
// Statement
|
||||
[vehicle ACE_player] call FUNC(keyUp);
|
||||
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex)] call FUNC(keyUp);
|
||||
false
|
||||
},
|
||||
[15, [false, false, false]],
|
||||
@ -46,7 +46,7 @@
|
||||
if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false};
|
||||
|
||||
// Statement
|
||||
[vehicle ACE_player, 50] call FUNC(adjustRange);
|
||||
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), 50] call FUNC(adjustRange);
|
||||
true
|
||||
},
|
||||
[201, [false, false, false]],
|
||||
@ -64,7 +64,7 @@
|
||||
if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false};
|
||||
|
||||
// Statement
|
||||
[vehicle ACE_player, -50] call FUNC(adjustRange);
|
||||
[vehicle ACE_player, [ACE_player] call EFUNC(common,getTurretIndex), -50] call FUNC(adjustRange);
|
||||
true
|
||||
},
|
||||
[209, [false, false, false]],
|
||||
|
Loading…
Reference in New Issue
Block a user