mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #135 from KoffeinFlummi/syncedScopeAdjustment
Synced scope adjustment
This commit is contained in:
commit
a41299b05a
@ -82,7 +82,7 @@ enableCamShake true;
|
|||||||
|
|
||||||
}] call FUNC(addEventhandler);
|
}] call FUNC(addEventhandler);
|
||||||
|
|
||||||
GVAR(OldPlayerInventory) = ACE_player call FUNC(getAllGear);
|
GVAR(OldPlayerInventory) = [ACE_player] call FUNC(getAllGear);
|
||||||
GVAR(OldPlayerVisionMode) = currentVisionMode ACE_player;
|
GVAR(OldPlayerVisionMode) = currentVisionMode ACE_player;
|
||||||
GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312);
|
GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312);
|
||||||
GVAR(OldCameraView) = cameraView;
|
GVAR(OldCameraView) = cameraView;
|
||||||
@ -93,7 +93,7 @@ GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
|
|||||||
[{
|
[{
|
||||||
|
|
||||||
// "playerInventoryChanged" event
|
// "playerInventoryChanged" event
|
||||||
_newPlayerInventory = ACE_player call FUNC(getAllGear);
|
_newPlayerInventory = [ACE_player] call FUNC(getAllGear);
|
||||||
if !(_newPlayerInventory isEqualTo GVAR(OldPlayerInventory)) then {
|
if !(_newPlayerInventory isEqualTo GVAR(OldPlayerInventory)) then {
|
||||||
// Raise ACE event locally
|
// Raise ACE event locally
|
||||||
GVAR(OldPlayerInventory) = _newPlayerInventory;
|
GVAR(OldPlayerInventory) = _newPlayerInventory;
|
||||||
|
@ -75,6 +75,7 @@ PREP(getVehicleCargo);
|
|||||||
PREP(getVehicleCodriver);
|
PREP(getVehicleCodriver);
|
||||||
PREP(getVehicleCrew);
|
PREP(getVehicleCrew);
|
||||||
PREP(getWeaponAzimuthAndInclination);
|
PREP(getWeaponAzimuthAndInclination);
|
||||||
|
PREP(getWeaponIndex);
|
||||||
PREP(getWeaponType);
|
PREP(getWeaponType);
|
||||||
PREP(getWindDirection);
|
PREP(getWindDirection);
|
||||||
PREP(goKneeling);
|
PREP(goKneeling);
|
||||||
@ -128,6 +129,7 @@ PREP(toBin);
|
|||||||
PREP(toBitmask);
|
PREP(toBitmask);
|
||||||
PREP(toHex);
|
PREP(toHex);
|
||||||
PREP(toNumber);
|
PREP(toNumber);
|
||||||
|
PREP(throttledPublicVariable);
|
||||||
PREP(unmuteUnit);
|
PREP(unmuteUnit);
|
||||||
PREP(waitAndExecute);
|
PREP(waitAndExecute);
|
||||||
|
|
||||||
|
25
addons/common/functions/fnc_getWeaponIndex.sqf
Normal file
25
addons/common/functions/fnc_getWeaponIndex.sqf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
* Get the index of the weapon.
|
||||||
|
* 0 = primary, 1 = secondary, 2 = handgun, -1 = other
|
||||||
|
*
|
||||||
|
* Argument:
|
||||||
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Weapon <STRING>
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* Weapon index <NUMBER>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
EXPLODE_2_PVT(_this,_unit,_weapon);
|
||||||
|
|
||||||
|
if (_weapon = "") exitWith {-1};
|
||||||
|
|
||||||
|
[
|
||||||
|
primaryWeapon _unit,
|
||||||
|
secondaryWeapon _unit,
|
||||||
|
handgunWeapon _unit
|
||||||
|
] find _weapon
|
49
addons/common/functions/fnc_throttledPublicVariable.sqf
Normal file
49
addons/common/functions/fnc_throttledPublicVariable.sqf
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Author: CAA-Picard
|
||||||
|
* Schedules the publishment of an object variable to reduce network overhead
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unit <OBJECT>.
|
||||||
|
* 1: Variable name <STRING>
|
||||||
|
* 2: Maximum delay <NUMBER>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
EXPLODE_3_PVT(_this,_unit,_varName,_maxDelay);
|
||||||
|
|
||||||
|
// Create the publish scheduler PFH the first time
|
||||||
|
if (isNil QGVAR(publishSchedId)) then {
|
||||||
|
|
||||||
|
GVAR(publishVarNames) = [];
|
||||||
|
GVAR(publishNextTime) = 1e7;
|
||||||
|
|
||||||
|
GVAR(publishSchedId) = [{
|
||||||
|
|
||||||
|
if (diag_tickTime > GVAR(publishNextTime)) then {
|
||||||
|
{
|
||||||
|
EXPLODE_2_PVT(_x,_unit,_varName);
|
||||||
|
_unit setVariable [_varName, (_unit getVariable _varName), true];
|
||||||
|
} forEach GVAR(publishVarNames);
|
||||||
|
|
||||||
|
GVAR(publishVarNames) = [];
|
||||||
|
GVAR(publishNextTime) = 1e7;
|
||||||
|
};
|
||||||
|
}, 0, []] call cba_fnc_addPerFrameHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
// If the variable is not on the list
|
||||||
|
if (GVAR(publishVarNames) find [_unit,_varName] == -1) exitWith {
|
||||||
|
GVAR(publishVarNames) pushBack [_unit,_varName];
|
||||||
|
GVAR(publishNextTime) = GVAR(publishNextTime) min (diag_tickTime + _maxDelay);
|
||||||
|
};
|
||||||
|
|
||||||
|
// If the variable is on the list
|
||||||
|
GVAR(publishNextTime) = GVAR(publishNextTime) min (diag_tickTime + _maxDelay);
|
@ -13,39 +13,7 @@ class Extended_PostInit_EventHandlers {
|
|||||||
class Extended_Fired_EventHandlers {
|
class Extended_Fired_EventHandlers {
|
||||||
class CAManBase {
|
class CAManBase {
|
||||||
class ADDON {
|
class ADDON {
|
||||||
clientFired = QUOTE(if (_this select 0 == ACE_player) then { _this call FUNC(firedEH);};);
|
fired = QUOTE(_this call FUNC(firedEH););
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class Extended_Take_EventHandlers {
|
|
||||||
class CAManBase {
|
|
||||||
class ADDON {
|
|
||||||
clientTake = QUOTE(if (_this select 0 == ACE_player) then{ _this call FUNC(inventoryCheck);};);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class Extended_Put_EventHandlers {
|
|
||||||
class CAManBase {
|
|
||||||
class ADDON {
|
|
||||||
clientPut = QUOTE(if (_this select 0 == ACE_player) then {_this call FUNC(inventoryCheck);};);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class Extended_InitPost_EventHandlers {
|
|
||||||
class CAManBase {
|
|
||||||
class ADDON {
|
|
||||||
init = QUOTE(if (_this select 0 == call EFUNC(common,player)) then{ _this call FUNC(inventoryCheck);};);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class Extended_Respawn_EventHandlers {
|
|
||||||
class CAManBase {
|
|
||||||
class ADDON {
|
|
||||||
respawn = QUOTE(if (_this select 0 == call EFUNC(common,player)) then{ _this call FUNC(inventoryCheck);};);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@ class RscTitles {
|
|||||||
movingEnable = 0;
|
movingEnable = 0;
|
||||||
enableSimulation = 1;
|
enableSimulation = 1;
|
||||||
enableDisplay = 1;
|
enableDisplay = 1;
|
||||||
onLoad = QUOTE(_this spawn compile preprocessFileLineNumbers QUOTE(QUOTE(PATHTOF(scripts\zeroingOnLoad.sqf))); uiNamespace setVariable [ARR_2('ACE_Scopes_Debug', _this)];);
|
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(ZeroingDisplay)),_this select 0)];);
|
||||||
duration = 1e+011;
|
duration = 1e+011;
|
||||||
fadein = 0;
|
fadein = 0;
|
||||||
fadeout = 0;
|
fadeout = 0;
|
||||||
@ -13,7 +13,7 @@ class RscTitles {
|
|||||||
class RscText;
|
class RscText;
|
||||||
class controls {
|
class controls {
|
||||||
class ACE_Scopes_Zeroing_BG : RscPicture {
|
class ACE_Scopes_Zeroing_BG : RscPicture {
|
||||||
idc = 925001;
|
idc = 11;
|
||||||
type = 0;
|
type = 0;
|
||||||
text = PATHTOF(UI\scopes_bg.paa);
|
text = PATHTOF(UI\scopes_bg.paa);
|
||||||
style = 48 + 0x800;
|
style = 48 + 0x800;
|
||||||
@ -30,7 +30,7 @@ class RscTitles {
|
|||||||
h = 0.3 * safezoneH;
|
h = 0.3 * safezoneH;
|
||||||
};
|
};
|
||||||
class ACE_Scopes_Zeroing_Vertical : RscText {
|
class ACE_Scopes_Zeroing_Vertical : RscText {
|
||||||
idc = 925002;
|
idc = 12;
|
||||||
type = 0;
|
type = 0;
|
||||||
style = 2;
|
style = 2;
|
||||||
sizeEx = 0.04;
|
sizeEx = 0.04;
|
||||||
@ -47,7 +47,7 @@ class RscTitles {
|
|||||||
h = 0.025 * safezoneH;
|
h = 0.025 * safezoneH;
|
||||||
};
|
};
|
||||||
class ACE_Scopes_Zeroing_Horizontal : RscText {
|
class ACE_Scopes_Zeroing_Horizontal : RscText {
|
||||||
idc = 925003;
|
idc = 13;
|
||||||
type = 0;
|
type = 0;
|
||||||
style = 0;
|
style = 0;
|
||||||
sizeEx = 0.04;
|
sizeEx = 0.04;
|
||||||
|
@ -9,32 +9,27 @@
|
|||||||
|
|
||||||
if !(hasInterface) exitWith {};
|
if !(hasInterface) exitWith {};
|
||||||
|
|
||||||
// show overlay after changing weapon/optic
|
// Check inventory when it changes
|
||||||
0 spawn {
|
["playerInventoryChanged", {
|
||||||
_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
[ACE_player] call FUNC(inventoryCheck);
|
||||||
while {True} do {
|
}] call EFUNC(common,addEventhandler);
|
||||||
waitUntil {[ACE_player, 0,0] call FUNC(canAdjustScope)};
|
|
||||||
_layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false];
|
|
||||||
sleep 3;
|
|
||||||
_layer cutFadeOut 2;
|
|
||||||
|
|
||||||
_weapon = currentWeapon ACE_player;
|
|
||||||
_optics = [ACE_player] call FUNC(getOptics);
|
|
||||||
waitUntil {sleep 0.05; !(_optics isEqualTo ([ACE_player] call FUNC(getOptics))) or (currentWeapon ACE_player != _weapon)};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// instantly hide when scoping in
|
// Instantly hide knobs when scoping in
|
||||||
0 spawn {
|
["cameraViewChanged", {
|
||||||
_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
EXPLODE_2_PVT(_this,_player,_newCameraView);
|
||||||
while {True} do {
|
if (_newCameraView == "GUNNER") then {
|
||||||
waitUntil {sleep 0.05; cameraView == "GUNNER"};
|
private "_layer";
|
||||||
if !(isNull GVAR(fadeScript)) then {
|
_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
||||||
terminate GVAR(fadeScript);
|
|
||||||
};
|
|
||||||
_layer cutText ["", "PLAIN", 0];
|
_layer cutText ["", "PLAIN", 0];
|
||||||
|
|
||||||
|
|
||||||
|
if !(isNil QGVAR(fadePFH)) then {
|
||||||
|
[GVAR(fadePFH)] call cba_fnc_removePerFrameHandler;
|
||||||
|
GVAR(fadePFH) = nil;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
}] call EFUNC(common,addEventhandler);
|
||||||
|
|
||||||
|
|
||||||
// Add keybinds
|
// Add keybinds
|
||||||
|
@ -6,8 +6,8 @@ PREP(adjustScope);
|
|||||||
PREP(canAdjustScope);
|
PREP(canAdjustScope);
|
||||||
PREP(firedEH);
|
PREP(firedEH);
|
||||||
PREP(getOptics);
|
PREP(getOptics);
|
||||||
PREP(hideZeroing);
|
|
||||||
PREP(inventoryCheck);
|
PREP(inventoryCheck);
|
||||||
|
PREP(showZeroing);
|
||||||
|
|
||||||
GVAR(fadeScript) = scriptNull;
|
GVAR(fadeScript) = scriptNull;
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ class CfgPatches {
|
|||||||
units[] = {};
|
units[] = {};
|
||||||
weapons[] = {};
|
weapons[] = {};
|
||||||
requiredVersion = REQUIRED_VERSION;
|
requiredVersion = REQUIRED_VERSION;
|
||||||
requiredAddons[] = { "ace_main", "ace_common" };
|
requiredAddons[] = { "ace_common" };
|
||||||
author[] = {"KoffeinFlummi"};
|
author[] = {"KoffeinFlummi", "CAA-Picard"};
|
||||||
authorUrl = "https://github.com/KoffeinFlummi";
|
authorUrl = "https://github.com/KoffeinFlummi";
|
||||||
VERSION_CONFIG;
|
VERSION_CONFIG;
|
||||||
};
|
};
|
||||||
|
@ -1,42 +1,44 @@
|
|||||||
/*
|
/*
|
||||||
* Author: KoffeinFlummi
|
* Author: KoffeinFlummi
|
||||||
*
|
|
||||||
* Changes the adjustment for the current scope
|
* Changes the adjustment for the current scope
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Argument:
|
||||||
* 0: Horizontal adjustment
|
* 0: Unit <OBJECT>
|
||||||
* 1: Vertical adjustment
|
* 1: Horizontal adjustment <NUMBER>
|
||||||
|
* 2: Vertical adjustment <NUMBER>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return value:
|
||||||
* True
|
* True <BOOL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_weapons", "_zeroing", "_pitchbankyaw", "_pitch", "_bank", "_yaw", "_hint"];
|
private ["_unit", "_weapons", "_zeroing", "_pitchbankyaw", "_pitch", "_bank", "_yaw", "_hint"];
|
||||||
|
|
||||||
_unit = _this select 0;
|
_unit = _this select 0;
|
||||||
|
|
||||||
_weapons = [
|
_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
||||||
primaryWeapon _unit,
|
|
||||||
secondaryWeapon _unit,
|
|
||||||
handgunWeapon _unit
|
|
||||||
];
|
|
||||||
|
|
||||||
if (isNil QGVAR(Adjustment)) then {
|
_adjustment = _unit getVariable QGVAR(Adjustment);
|
||||||
GVAR(Adjustment) = [[0,0], [0,0], [0,0]];
|
if (isNil "_adjustment") then {
|
||||||
|
_adjustment = [[0,0], [0,0], [0,0]];
|
||||||
|
_unit setVariable [QGVAR(Adjustment), _adjustment];
|
||||||
};
|
};
|
||||||
|
|
||||||
_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit));
|
_zeroing = _adjustment select _weaponIndex;
|
||||||
_zeroing set [0, (round (((_zeroing select 0) + (_this select 1)) * 10)) / 10];
|
_zeroing set [0, (round (((_zeroing select 0) + (_this select 1)) * 10)) / 10];
|
||||||
_zeroing set [1, (round (((_zeroing select 1) + (_this select 2)) * 10)) / 10];
|
_zeroing set [1, (round (((_zeroing select 1) + (_this select 2)) * 10)) / 10];
|
||||||
|
|
||||||
GVAR(Adjustment) set [_weapons find (currentWeapon _unit), _zeroing];
|
// Change the adjustment array
|
||||||
|
_adjustment set [_weaponIndex, _zeroing];
|
||||||
|
[_unit, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic);
|
||||||
|
|
||||||
playSound (["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_Click_3"] select floor random 3);
|
playSound (["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_Click_3"] select floor random 3);
|
||||||
|
|
||||||
// slightly rotate the player if looking through optic
|
// slightly rotate the player if looking through optic
|
||||||
if (cameraView == "GUNNER") then {
|
if (cameraView == "GUNNER") then {
|
||||||
|
|
||||||
_pitchbankyaw = [_unit] call EFUNC(common,getPitchBankYaw);
|
_pitchbankyaw = [_unit] call EFUNC(common,getPitchBankYaw);
|
||||||
// these are not exact mil-to-degree conversions, but instead chosen
|
// these are not exact mil-to-degree conversions, but instead chosen
|
||||||
// to minimize the effect of rounding errors
|
// to minimize the effect of rounding errors
|
||||||
@ -44,26 +46,11 @@ if (cameraView == "GUNNER") then {
|
|||||||
_bank = _pitchbankyaw select 1;
|
_bank = _pitchbankyaw select 1;
|
||||||
_yaw = (_pitchbankyaw select 2) + ((_this select 1) * -0.04);
|
_yaw = (_pitchbankyaw select 2) + ((_this select 1) * -0.04);
|
||||||
[_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw)
|
[_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw)
|
||||||
};
|
|
||||||
|
|
||||||
_display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull];
|
} else {
|
||||||
if !(isNull _display) then {
|
|
||||||
_vertical = _display displayCtrl 925002;
|
[] call FUNC(showZeroing);
|
||||||
_horizontal = _display displayCtrl 925003;
|
|
||||||
_vertical ctrlSetText (str (_zeroing select 1));
|
|
||||||
_horizontal ctrlSetText (str (_zeroing select 0));
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!isNull (missionNamespace getVariable [QGVAR(fadeScript), scriptNull])) then {
|
|
||||||
terminate GVAR(fadeScript);
|
|
||||||
};
|
|
||||||
if (cameraView != "GUNNER") then {
|
|
||||||
GVAR(fadeScript) = 0 spawn {
|
|
||||||
_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
|
||||||
_layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false];
|
|
||||||
sleep 3;
|
|
||||||
_layer cutFadeOut 2;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -1,43 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* Author: KoffeinFlummi
|
* Author: KoffeinFlummi
|
||||||
*
|
|
||||||
* Checks if a player can adjust his optic in the given way.
|
* Checks if a player can adjust his optic in the given way.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Argument:
|
||||||
* 0: Horizontal adjustment
|
* 0: Unit <OBJECT>
|
||||||
* 1: Vertical adjustment
|
* 1: Horizontal adjustment <NUMBER>
|
||||||
|
* 2: Vertical adjustment <NUMBER>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return value:
|
||||||
* Can adjustment be done? (Bool)
|
* Can adjustment be done? <BOOL>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_weapons", "_zeroing", "_optic", "_maxHorizontal", "_maxVertical"];
|
private ["_unit", "_weaponIndex", "_zeroing", "_optic", "_maxHorizontal", "_maxVertical"];
|
||||||
|
|
||||||
_unit = _this select 0;
|
_unit = _this select 0;
|
||||||
|
|
||||||
_weapons = [
|
_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
||||||
primaryWeapon _unit,
|
if (_weaponIndex < 0) exitWith {false};
|
||||||
secondaryWeapon _unit,
|
|
||||||
handgunWeapon _unit
|
|
||||||
];
|
|
||||||
|
|
||||||
if !(currentWeapon _unit in _weapons) exitWith {false};
|
_adjustment = _unit getVariable QGVAR(Adjustment);
|
||||||
|
if (isNil "_adjustment") then {
|
||||||
if (isNil QGVAR(Adjustment)) then {
|
_adjustment = [[0,0], [0,0], [0,0]];
|
||||||
GVAR(Adjustment) = [[0,0], [0,0], [0,0]];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isNil QGVAR(Optics)) then {
|
if (isNil QGVAR(Optics)) then {
|
||||||
GVAR(Optics) = ["", "", ""];
|
GVAR(Optics) = ["", "", ""];
|
||||||
};
|
};
|
||||||
|
|
||||||
_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit));
|
_zeroing = _adjustment select _weaponIndex;
|
||||||
_zeroX = (_zeroing select 0) + (_this select 1);
|
_zeroX = (_zeroing select 0) + (_this select 1);
|
||||||
_zeroY = (_zeroing select 1) + (_this select 2);
|
_zeroY = (_zeroing select 1) + (_this select 2);
|
||||||
|
|
||||||
_optic = GVAR(Optics) select (_weapons find (currentWeapon _unit));
|
_optic = GVAR(Optics) select _weaponIndex;
|
||||||
_maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Horizontal");
|
_maxHorizontal = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Horizontal");
|
||||||
_maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Vertical");
|
_maxVertical = getArray (configFile >> "CfgWeapons" >> _optic >> "ACE_ScopeAdjust_Vertical");
|
||||||
if ((count _maxHorizontal < 2) or (count _maxVertical < 2)) exitWith {false};
|
if ((count _maxHorizontal < 2) or (count _maxVertical < 2)) exitWith {false};
|
||||||
|
@ -1,35 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
* Author: KoffeinFlummi
|
* Author: KoffeinFlummi and CAA-Picard
|
||||||
*
|
|
||||||
* Adjusts the flight path of the bullet according to the zeroing
|
* Adjusts the flight path of the bullet according to the zeroing
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Argument:
|
||||||
* Fired EH
|
* 0: Unit <OBJECT>
|
||||||
|
* 1: Weapon <STRING>
|
||||||
|
* 3: Muzzle <STRING>
|
||||||
|
* 4: Magazine <STRING>
|
||||||
|
* 5: Ammo <STRING>
|
||||||
|
* 6: Projectile <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return value:
|
||||||
* None
|
* None
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_weaponType", "_ammoType", "_magazineType", "_round", "_weapons", "_zeroing", "_direction", "_azimuth", "_altitude", "_velocity"];
|
private ["_unit", "_adjustment", "_weapon", "_projectile", "_weaponIndex", "_zeroing", "_adjustment"];
|
||||||
|
|
||||||
_unit = _this select 0;
|
_unit = _this select 0;
|
||||||
_weaponType = _this select 1;
|
|
||||||
_ammoType = _this select 4;
|
|
||||||
_round = _this select 5;
|
|
||||||
_magazineType = _this select 6;
|
|
||||||
|
|
||||||
_weapons = [
|
// Exit if the unit doesn't have any adjusment variable
|
||||||
primaryWeapon _unit,
|
_adjustment = _unit getVariable QGVAR(Adjustment);
|
||||||
secondaryWeapon _unit,
|
if (isNil "_adjustment") exitWith {};
|
||||||
handgunWeapon _unit
|
|
||||||
];
|
|
||||||
if !(_weaponType in _weapons) exitWith {};
|
|
||||||
|
|
||||||
_zeroing = GVAR(Adjustment) select (_weapons find _weaponType);
|
// Exit if the unit isn't a player
|
||||||
|
if !([_unit] call EFUNC(common,isPlayer)) exitWith {};
|
||||||
|
|
||||||
// convert zeroing from mils to degrees
|
_weapon = _this select 1;
|
||||||
|
_projectile = _this select 5;
|
||||||
|
|
||||||
|
_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
||||||
|
if (_weaponIndex < 0) exitWith {};
|
||||||
|
|
||||||
|
_zeroing = _adjustment select _weaponIndex;
|
||||||
|
|
||||||
|
// Convert zeroing from mils to degrees
|
||||||
_zeroing = [_zeroing, {_this * 0.05625}] call EFUNC(common,map);
|
_zeroing = [_zeroing, {_this * 0.05625}] call EFUNC(common,map);
|
||||||
|
|
||||||
[_round, _zeroing select 0, _zeroing select 1, 0] call EFUNC(common,changeProjectileDirection);
|
[_projectile, _zeroing select 0, _zeroing select 1, 0] call EFUNC(common,changeProjectileDirection);
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Author: commy2
|
* Author: commy2
|
||||||
*
|
|
||||||
* Gets the optic classnames of all currently equipped weapons.
|
* Gets the optic classnames of all currently equipped weapons.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Unit (Object)
|
* 0: Unit <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* [optic of primary, optic of secondary, optic of handgun] (Array)
|
* 0: Optic of primary <STRING>
|
||||||
|
* 1: Optic of secondary <STRING>
|
||||||
|
* 2: Optic of handgun <STRING>
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_array"];
|
EXPLODE_1_PVT(_this,_unit);
|
||||||
|
|
||||||
_unit = _this select 0;
|
|
||||||
|
|
||||||
|
private ["_array"];
|
||||||
_array = ["", "", ""];
|
_array = ["", "", ""];
|
||||||
|
|
||||||
if !(_unit isKindOf "CAManBase") exitWith {_array};
|
if !(_unit isKindOf "CAManBase") exitWith {_array};
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
// by commy2
|
|
||||||
|
|
||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
private ["_state", "_ctrl"];
|
|
||||||
|
|
||||||
_state = _this select 0;
|
|
||||||
|
|
||||||
disableSerialization;
|
|
||||||
_ctrl = (uiNamespace getVariable ['ACE_dlgWeaponZeroing', displayNull]) displayCtrl 168;
|
|
||||||
|
|
||||||
if (_state) then {
|
|
||||||
_ctrl ctrlSetPosition [0,0,0,0];
|
|
||||||
} else {
|
|
||||||
private "_config";
|
|
||||||
|
|
||||||
_config = configFile >> "RscInGameUI" >> "RscWeaponZeroing" >> "CA_Zeroing";
|
|
||||||
|
|
||||||
_ctrl ctrlSetPosition [
|
|
||||||
getNumber (_config >> "x"),
|
|
||||||
getNumber (_config >> "y"),
|
|
||||||
getNumber (_config >> "w"),
|
|
||||||
getNumber (_config >> "h")
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
_ctrl ctrlCommit 0;
|
|
@ -1,23 +1,42 @@
|
|||||||
// by KoffeinFlummi / commy2
|
/*
|
||||||
|
* Author: KoffeinFlummi and Commy2
|
||||||
|
* Check if weapon optics changed and reset zeroing if needed
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Player <OBJECT>
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private "_new";
|
EXPLODE_1_PVT(_this,_player);
|
||||||
|
|
||||||
_new = _this call FUNC(getOptics);
|
private ["_newOptics", "_adjustment"];
|
||||||
|
|
||||||
|
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
||||||
|
if (isNil "_adjustment") then {
|
||||||
|
_adjustment = [[0,0], [0,0], [0,0]];
|
||||||
|
ACE_player setVariable [QGVAR(Adjustment), _adjustment];
|
||||||
|
[ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic);
|
||||||
|
};
|
||||||
|
|
||||||
if (isNil QGVAR(Optics)) then {
|
if (isNil QGVAR(Optics)) then {
|
||||||
GVAR(Optics) = ["", "", ""];
|
GVAR(Optics) = ["", "", ""];
|
||||||
};
|
};
|
||||||
|
_newOptics = [_player] call FUNC(getOptics);
|
||||||
if (isNil QGVAR(Adjustment)) then {
|
|
||||||
GVAR(Adjustment) = [[0,0], [0,0], [0,0]];
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (_new select _forEachIndex != _x) then {
|
if (_newOptics select _forEachIndex != _x) then {
|
||||||
GVAR(Adjustment) set [_forEachIndex, [0,0]];
|
// The optic for this weapon changed, set adjustment to zero
|
||||||
|
if !((_adjustment select _foreachindex) isEqualTo [0,0]) then {
|
||||||
|
_adjustment set [_forEachIndex, [0,0]];
|
||||||
|
[ACE_player, QGVAR(Adjustment), _adjustment, 0.5] call EFUNC(common,setVariablePublic);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} forEach GVAR(Optics);
|
} forEach GVAR(Optics);
|
||||||
|
|
||||||
GVAR(Optics) = _new;
|
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
||||||
|
GVAR(Optics) = _newOptics;
|
||||||
|
59
addons/scopes/functions/fnc_showZeroing.sqf
Normal file
59
addons/scopes/functions/fnc_showZeroing.sqf
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Author: KoffeinFlummi and CAA-Picard
|
||||||
|
* Display the adjustment knobs, update their value and fade them out later
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
disableSerialization;
|
||||||
|
|
||||||
|
private ["_weaponIndex","_adjustment","_layer","_display","_zeroing","_vertical","_horizontal"];
|
||||||
|
|
||||||
|
_weaponIndex = [ACE_player, currentWeapon ACE_player] call EFUNC(common,getWeaponIndex);
|
||||||
|
if (_weaponIndex < 0) exitWith {};
|
||||||
|
|
||||||
|
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
||||||
|
if (isNil "_adjustment") then {
|
||||||
|
_adjustment = [[0,0], [0,0], [0,0]];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Display the adjustment knobs
|
||||||
|
_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
||||||
|
_layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false];
|
||||||
|
|
||||||
|
// Find the display
|
||||||
|
_display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull];
|
||||||
|
if (isNull _display) exitWith {};
|
||||||
|
|
||||||
|
// Update values
|
||||||
|
_zeroing = _adjustment select _weaponIndex;
|
||||||
|
_vertical = _display displayCtrl 12;
|
||||||
|
_horizontal = _display displayCtrl 13;
|
||||||
|
_vertical ctrlSetText (str (_zeroing select 1));
|
||||||
|
_horizontal ctrlSetText (str (_zeroing select 0));
|
||||||
|
|
||||||
|
// Set the time when to hide the knobs
|
||||||
|
GVAR(timeToHide) = diag_tickTime + 3.0;
|
||||||
|
|
||||||
|
if !(isNil QGVAR(fadePFH)) exitWith {};
|
||||||
|
|
||||||
|
// Launch a PFH to wait and fade out the knobs
|
||||||
|
GVAR(fadePFH) = [{
|
||||||
|
|
||||||
|
if (diag_tickTime >= GVAR(timeToHide)) exitWith {
|
||||||
|
private "_layer";
|
||||||
|
_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
||||||
|
_layer cutFadeOut 2;
|
||||||
|
|
||||||
|
GVAR(fadePFH) = nil;
|
||||||
|
[_this select 1] call cba_fnc_removePerFrameHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
}, 0.1, []] call CBA_fnc_addPerFrameHandler
|
@ -1 +0,0 @@
|
|||||||
#include "\z\ace\addons\scopes\script_component.hpp"
|
|
@ -1,20 +0,0 @@
|
|||||||
#include "script_component.hpp"
|
|
||||||
|
|
||||||
disableSerialization;
|
|
||||||
|
|
||||||
_display = _this select 0;
|
|
||||||
uiNamespace setVariable [QGVAR(ZeroingDisplay, _display];
|
|
||||||
_vertical = _display displayCtrl 925002;
|
|
||||||
_horizontal = _display displayCtrl 925003;
|
|
||||||
|
|
||||||
_weapons = [
|
|
||||||
primaryWeapon player,
|
|
||||||
secondaryWeapon player,
|
|
||||||
handgunWeapon player
|
|
||||||
];
|
|
||||||
|
|
||||||
if ((currentWeapon ACE_player) in _weapons) then {
|
|
||||||
_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon ACE_player));
|
|
||||||
_horizontal ctrlSetText (str (_zeroing select 0));
|
|
||||||
_vertical ctrlSetText (str (_zeroing select 1));
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user