Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XM157 (NGSW-FC Smart Scope) Framework #8897

Merged
merged 11 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ PREP(removeSpecificMagazine);
PREP(requestCallback);
PREP(resetAllDefaults);
PREP(restoreVariablesJIP);
PREP(rscObjectHelper);
PREP(runAfterSettingsInit);
PREP(runTests);
PREP(sanitizeString);
Expand Down
64 changes: 64 additions & 0 deletions addons/common/functions/fnc_rscObjectHelper.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "script_component.hpp"
veteran29 marked this conversation as resolved.
Show resolved Hide resolved
/*
* Author: PabstMirror
* Convert between screen and 3d object cordinates
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
*
* Arguments:
* 0: Function <STRING>
* 1: Input array <CODE>
* 2: Scale (optional: 1) <NUMBER>
*
* Return Value:
* Value <ARRAY>
*
* Example:
* ["2d", [0,0,0], 1] call ace_common_fnc_rscObjectHelper
*
* Public: Maybe
*/

params ["_func", "_array", ["_scale", 1]];

private _adjustCam = 1;
private _topFOV = getResolution # 6;
private _leftFOV = getResolution # 7;

private _topLeftX = (_leftFOV-1)*0.5/_leftFOV;
private _bottomRightX = 1-_topLeftX;
private _topLeftY = 0;
private _bottomRightY = 1;

private _return = [];

switch (toLower _func) do {
case ("2d"): {
_array params ["_pointX", "_z", "_pointY"];

private _scrX = _pointX * (_bottomRightX - _topLeftX) + _topLeftX;
private _vX = _leftFOV * (_scrX - 0.5) * _adjustCam * _z;

private _scrY = _pointY * (_bottomRightY - _topLeftY) + _topLeftY;
private _vY = _topFOV * (0.5 - _scrY) * _adjustCam * _z;

_vX = _vX / _scale;
_vY = _vY / _scale;

_return = [_vX, _vY, _z];
};
case ("3d"): {
_array params ["_vX", "_vY", "_z"]; // z is distance from screen

_vX = _vX * _scale;
_vY = _vY * _scale;

private _scrX = _vX / (_leftFOV * _adjustCam * _z) + 0.5;
private _pointX = (_scrX - _topLeftX) / (_bottomRightX - _topLeftX);

private _scrY = 0.5 - _vY / (_topFOV * _adjustCam * _z);
private _pointY = (_scrY - _topLeftY) / (_bottomRightY - _topLeftY);

_return = [_pointX, _z, _pointY];
};
};

_return
1 change: 1 addition & 0 deletions addons/xm157/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\ace\addons\xm157
15 changes: 15 additions & 0 deletions addons/xm157/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_postInit));
};
};
6 changes: 6 additions & 0 deletions addons/xm157/CfgSounds.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CfgSounds {
class GVAR(click) {
sound[] = {QPATHTOF(sounds\click.wav), db-30, 3};
titles[] = {};
};
};
49 changes: 49 additions & 0 deletions addons/xm157/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class CfgWeapons {
PabstMirror marked this conversation as resolved.
Show resolved Hide resolved
class ItemCore;
class InventoryOpticsItem_Base_F;

class ace_xm157: ItemCore {
author="Pabst";
scope=2; // scope 1?
displayName="XM157 Prototype";
veteran29 marked this conversation as resolved.
Show resolved Hide resolved
descriptionShort="";
picture="\a3\Weapons_F\acc\Data\UI\icon_optic_tws_ca.paa";
model="\A3\weapons_f\acc\acco_tws_F";
inertia=0.2;

class CBA_ScriptedOptic {
bodyTexture = QPATHTOF(data\ace_vector_body_co.paa);
// bodyTextureNight = ".paa"; // optional
bodyTextureSize = 1;

hideMagnification = 1; // no point, and it flickers at 1x
disableTilt = 0;
};

weaponInfoType = QGVAR(info);
class ItemInfo: InventoryOpticsItem_Base_F {
mass=14;
optics=1;
modelOptics = "\x\cba\addons\optics\cba_optic_big_100.p3d";
class OpticsModes {
class lpvo {
opticsID=1;
useModelOptics=1;
opticsPPEffects[]={ "OpticsCHAbera1", "OpticsBlur1" };
opticsZoomMin = "8 call (uiNamespace getVariable 'cba_optics_fnc_setOpticMagnificationHelper')";
opticsZoomMax = "1 call (uiNamespace getVariable 'cba_optics_fnc_setOpticMagnificationHelper')";
opticsZoomInit = "1 call (uiNamespace getVariable 'cba_optics_fnc_setOpticMagnificationHelper')";
discreteDistance[] = {100};
discreteDistanceInitIndex = 0;
distanceZoomMin=100;
distanceZoomMax=100;
memoryPointCamera="opticView";
visionMode[] = {"Normal"};
opticsFlare=1;
opticsDisablePeripherialVision=1;
cameraDir="";
};
};
};
};
};
2 changes: 2 additions & 0 deletions addons/xm157/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ace_xm157
==========
79 changes: 79 additions & 0 deletions addons/xm157/RscInGameUI.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
class RscObject;
class RscControlsGroupNoScrollbars;

class RscText;
class GVAR(text): RscText {
font = "EtelkaMonospaceProBold";
SizeEx = 0.04;
colorText[]={1,0.1,0.05,0.95};
shadow = 0;
};
class GVAR(textMenu): GVAR(text) {
SizeEx = 0.09;
style = 2+16;
};

class RscInGameUI {
class CBA_ScriptedOptic_zooming;
class GVAR(info): CBA_ScriptedOptic_zooming {
onLoad = QUOTE(call FUNC(weaponInfo_onLoad));
class objects {
class Optic: RscObject { // first focal plane
idc = IDC_SCOPE_OBJECT;
type = 82;
model = "\A3\Misc_F\Helpers\UserTexture1m.p3d";
x = 0;
y = 0;
z = 0;
xBack = 0.9;
yBack = 0.9;
zBack = 0.3;
inBack = 0;
enableZoom = 1;
zoomDuration = 0.001;
class Areas {
class usertexture {
selection = "usertexture";
class controls {
class test: RscControlsGroupNoScrollbars {
idc = IDC_SCOPE_GROUP;
x = 0;
y = 0;
w = 1;
h = 4/3;
};
};
};
};
};
class Screen: RscObject {
idc = IDC_SCREEN_OBJECT;
type = 82;
model = "\A3\Misc_F\Helpers\UserTexture1m.p3d";
x = 0;
y = 0;
z = 0;
xBack = 0.9;
yBack = 0.9;
zBack = 0.3;
inBack = 1;
enableZoom = 1;
zoomDuration = 0.001;
class Areas {
class usertexture {
selection = "usertexture";
class controls {
class test: RscControlsGroupNoScrollbars {
idc = IDC_SCREEN_GROUP;
x = 0;
y = 0;
w = 1;
h = 4/3;
};
};
};
};
};
};
};
};
8 changes: 8 additions & 0 deletions addons/xm157/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LOG("prep");

PREP(ballistics_calculator);
PREP(ballistics_getData);
PREP(keyPress);
PREP(weaponInfo_draw);
PREP(weaponInfo_drawMenu);
PREP(weaponInfo_onLoad);
64 changes: 64 additions & 0 deletions addons/xm157/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"

GVAR(shown) = false;
GVAR(data) = createHashMap;
GVAR(data) set ["latitude", -1 * getNumber (configFile >> "CfgWorlds" >> worldName >> "latitude")];


// Add Keybinds
["ACE3 Equipment", QGVAR(range), ["Range", "##"], {
["range", true] call FUNC(keyPress);
}, {
["range", false] call FUNC(keyPress);
}, [DIK_TAB, [false, false, false]], false, 0] call CBA_fnc_addKeybind;

["ACE3 Equipment", QGVAR(left), ["Left", "##"], {
["right", true] call FUNC(keyPress);
}, {
["right", false] call FUNC(keyPress);
}, [DIK_END, [false, false, false]], false, 0] call CBA_fnc_addKeybind;

["ACE3 Equipment", QGVAR(right), ["Range", "##"], {
["left", true] call FUNC(keyPress);
}, {
["left", false] call FUNC(keyPress);
}, [DIK_DELETE, [false, false, false]], false, 0] call CBA_fnc_addKeybind;

["ACE3 Equipment", QGVAR(up), ["Range", "##"], {
["up", true] call FUNC(keyPress);
}, {
["up", false] call FUNC(keyPress);
}, [DIK_PGUP, [false, false, false]], false, 0] call CBA_fnc_addKeybind;

["ACE3 Equipment", QGVAR(down), ["Range", "##"], {
["down", true] call FUNC(keyPress);
}, {
["down", false] call FUNC(keyPress);
}, [DIK_PGDN, [false, false, false]], false, 0] call CBA_fnc_addKeybind;



// Dev stuff
player addPrimaryWeaponItem "ace_xm157";
[player] call CBA_fnc_addUnitTrackProjectiles;
player addItem "ACE_ATragMX";
player addItem "ace_rangecard";

["recompile", "recompile", "recompile", {
private _start = diag_tickTime;
[] call ACE_PREP_RECOMPILE;
[] call ace_common_fnc_dumpPerformanceCounters;
private _end = diag_tickTime;
systemChat format ["recompile took [%1 ms]", (1000 * (_end - _start)) toFixed 1];

if (productVersion #4 == "Diag") then {
call compile "diag_mergeConfigFile ['P:\z\ace\addons\xm157\config.cpp']";
};

private _windSpd = vectorMagnitude wind;
private _windDir = (wind select 0) atan2 (wind select 1);
systemChat format ["Wind %1 @ %2", _windSpd, _windDir + 180];

false
}, {false}, [0x21, [false, false, false]], false] call CBA_fnc_addKeybind; // F Key
9 changes: 9 additions & 0 deletions addons/xm157/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

ADDON = true;
3 changes: 3 additions & 0 deletions addons/xm157/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
27 changes: 27 additions & 0 deletions addons/xm157/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {"ace_xm157"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_advanced_ballistics", "ace_scopes"};
author = ECSTRING(common,ACETeam);
authors[] = {"PabstMirror"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};

#include "CfgEventHandlers.hpp"
#include "CfgSounds.hpp"
#include "CfgWeapons.hpp"
#include "RscInGameUI.hpp"

class asdg_OpticRail;
class asdg_OpticRail1913: asdg_OpticRail {
class compatibleItems {
ace_xm157 = 1;
};
};
Binary file added addons/xm157/data/ace_vector_body_co.paa
Binary file not shown.
Binary file added addons/xm157/data/mrad_10_ca.paa
Binary file not shown.
Binary file added addons/xm157/data/mrad_20_ca.paa
Binary file not shown.
Binary file added addons/xm157/data/mrad_40_ca.paa
Binary file not shown.
Loading