mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
scopes: fixed errors, throttled sync of scope adjustment to all client and local calculation of deflections.
This commit is contained in:
parent
f163e307c8
commit
eadcd82366
@ -13,7 +13,7 @@ class Extended_PostInit_EventHandlers {
|
||||
class Extended_Fired_EventHandlers {
|
||||
class CAManBase {
|
||||
class ADDON {
|
||||
clientFired = QUOTE(if (_this select 0 == ACE_player) then { _this call FUNC(firedEH);};);
|
||||
fired = QUOTE(_this call FUNC(firedEH););
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ class RscTitles {
|
||||
movingEnable = 0;
|
||||
enableSimulation = 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;
|
||||
fadein = 0;
|
||||
fadeout = 0;
|
||||
|
@ -15,6 +15,8 @@ if !(hasInterface) exitWith {};
|
||||
while {True} do {
|
||||
waitUntil {[ACE_player, 0,0] call FUNC(canAdjustScope)};
|
||||
_layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false];
|
||||
call FUNC(showZeroing);
|
||||
|
||||
sleep 3;
|
||||
_layer cutFadeOut 2;
|
||||
|
||||
|
@ -8,6 +8,7 @@ PREP(firedEH);
|
||||
PREP(getOptics);
|
||||
PREP(hideZeroing);
|
||||
PREP(inventoryCheck);
|
||||
PREP(showZeroing);
|
||||
|
||||
GVAR(fadeScript) = scriptNull;
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
|
||||
private ["_unit", "_weapons", "_zeroing", "_pitchbankyaw", "_pitch", "_bank", "_yaw", "_hint"];
|
||||
|
||||
_unit = _this select 0;
|
||||
@ -23,15 +23,18 @@ _weapons = [
|
||||
handgunWeapon _unit
|
||||
];
|
||||
|
||||
if (isNil QGVAR(Adjustment)) then {
|
||||
GVAR(Adjustment) = [[0,0], [0,0], [0,0]];
|
||||
_adjustment = _unit getVariable QGVAR(Adjustment);
|
||||
if (isNil "_adjustment") then {
|
||||
_adjustment = [[0,0], [0,0], [0,0]];
|
||||
};
|
||||
|
||||
_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit));
|
||||
_zeroing = _adjustment select (_weapons find (currentWeapon _unit));
|
||||
_zeroing set [0, (round (((_zeroing select 0) + (_this select 1)) * 10)) / 10];
|
||||
_zeroing set [1, (round (((_zeroing select 1) + (_this select 2)) * 10)) / 10];
|
||||
|
||||
GVAR(Adjustment) set [_weapons find (currentWeapon _unit), _zeroing];
|
||||
_adjustment set [_weapons find (currentWeapon _unit), _zeroing];
|
||||
_unit setVariable [QGVAR(Adjustment), _adjustment];
|
||||
[_unit, QGVAR(Adjustment), 0.5] call EFUNC(common,throttledPublicVariable);
|
||||
|
||||
playSound (["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_Click_3"] select floor random 3);
|
||||
|
||||
@ -46,14 +49,6 @@ if (cameraView == "GUNNER") then {
|
||||
[_unit, _pitch, _bank, _yaw] call EFUNC(common,setPitchBankYaw)
|
||||
};
|
||||
|
||||
_display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull];
|
||||
if !(isNull _display) then {
|
||||
_vertical = _display displayCtrl 925002;
|
||||
_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);
|
||||
};
|
||||
@ -61,6 +56,7 @@ if (cameraView != "GUNNER") then {
|
||||
GVAR(fadeScript) = 0 spawn {
|
||||
_layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
||||
_layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false];
|
||||
call FUNC(showZeroing);
|
||||
sleep 3;
|
||||
_layer cutFadeOut 2;
|
||||
};
|
||||
|
@ -25,15 +25,16 @@ _weapons = [
|
||||
|
||||
if !(currentWeapon _unit in _weapons) exitWith {false};
|
||||
|
||||
if (isNil QGVAR(Adjustment)) then {
|
||||
GVAR(Adjustment) = [[0,0], [0,0], [0,0]];
|
||||
_adjustment = _unit getVariable QGVAR(Adjustment);
|
||||
if (isNil "_adjustment") then {
|
||||
_adjustment = [[0,0], [0,0], [0,0]];
|
||||
};
|
||||
|
||||
if (isNil QGVAR(Optics)) then {
|
||||
GVAR(Optics) = ["", "", ""];
|
||||
};
|
||||
|
||||
_zeroing = GVAR(Adjustment) select (_weapons find (currentWeapon _unit));
|
||||
_zeroing = _adjustment select (_weapons find (currentWeapon _unit));
|
||||
_zeroX = (_zeroing select 0) + (_this select 1);
|
||||
_zeroY = (_zeroing select 1) + (_this select 2);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi
|
||||
* Author: KoffeinFlummi and CAA-Picard
|
||||
*
|
||||
* Adjusts the flight path of the bullet according to the zeroing
|
||||
*
|
||||
@ -12,13 +12,17 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weaponType", "_ammoType", "_magazineType", "_round", "_weapons", "_zeroing", "_direction", "_azimuth", "_altitude", "_velocity"];
|
||||
private ["_unit", "_weaponType", "_round", "_weapons", "_zeroing", "_adjustment"];
|
||||
|
||||
_unit = _this select 0;
|
||||
|
||||
_adjustment = _unit getVariable QGVAR(Adjustment);
|
||||
if (isNil "_adjustment") exitWith {};
|
||||
|
||||
if !([_unit] call EFUNC(common,isPlayer)) exitWith {};
|
||||
|
||||
_weaponType = _this select 1;
|
||||
_ammoType = _this select 4;
|
||||
_round = _this select 5;
|
||||
_magazineType = _this select 6;
|
||||
|
||||
_weapons = [
|
||||
primaryWeapon _unit,
|
||||
@ -27,7 +31,7 @@ _weapons = [
|
||||
];
|
||||
if !(_weaponType in _weapons) exitWith {};
|
||||
|
||||
_zeroing = GVAR(Adjustment) select (_weapons find _weaponType);
|
||||
_zeroing = _adjustment select (_weapons find _weaponType);
|
||||
|
||||
// convert zeroing from mils to degrees
|
||||
_zeroing = [_zeroing, {_this * 0.05625}] call EFUNC(common,map);
|
||||
|
@ -10,13 +10,16 @@ if (isNil QGVAR(Optics)) then {
|
||||
GVAR(Optics) = ["", "", ""];
|
||||
};
|
||||
|
||||
if (isNil QGVAR(Adjustment)) then {
|
||||
GVAR(Adjustment) = [[0,0], [0,0], [0,0]];
|
||||
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
||||
if (isNil "_adjustment") then {
|
||||
ACE_player setVariable [QGVAR(Adjustment), [[0,0], [0,0], [0,0]]];
|
||||
[ACE_player, QGVAR(Adjustment), 0.5] call EFUNC(common,throttledPublicVariable);
|
||||
};
|
||||
|
||||
{
|
||||
if (_new select _forEachIndex != _x) then {
|
||||
GVAR(Adjustment) set [_forEachIndex, [0,0]];
|
||||
_adjustment set [_forEachIndex, [0,0]];
|
||||
[ACE_player, QGVAR(Adjustment), 0.5] call EFUNC(common,throttledPublicVariable);
|
||||
};
|
||||
} forEach GVAR(Optics);
|
||||
|
||||
|
26
addons/scopes/functions/fnc_showZeroing.sqf
Normal file
26
addons/scopes/functions/fnc_showZeroing.sqf
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
disableSerialization;
|
||||
|
||||
_display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull];
|
||||
if (isNull _display) exitWith {};
|
||||
|
||||
_weapons = [
|
||||
primaryWeapon ACE_player,
|
||||
secondaryWeapon ACE_player,
|
||||
handgunWeapon ACE_player
|
||||
];
|
||||
|
||||
if !((currentWeapon ACE_player) in _weapons) exitWith {};
|
||||
|
||||
_adjustment = ACE_player getVariable QGVAR(Adjustment);
|
||||
if (isNil "_adjustment") then {
|
||||
_adjustment = [[0,0], [0,0], [0,0]];
|
||||
};
|
||||
|
||||
_zeroing = _adjustment select (_weapons find (currentWeapon ACE_player));
|
||||
_vertical = _display displayCtrl 925002;
|
||||
_horizontal = _display displayCtrl 925003;
|
||||
_vertical ctrlSetText (str (_zeroing select 1));
|
||||
_horizontal ctrlSetText (str (_zeroing select 0));
|
@ -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