mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Laser Pointer - Use engine method for visible lasers (#9411)
* initial commit * tweak numbers * nuke framework * cleanup JR
This commit is contained in:
parent
18739c23ce
commit
b84a84c0ff
@ -1,5 +0,0 @@
|
||||
class ACE_Settings {
|
||||
class GVAR(enabled) {
|
||||
movedToSQF = 1;
|
||||
};
|
||||
};
|
@ -1,17 +1,5 @@
|
||||
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));
|
||||
};
|
||||
};
|
||||
|
@ -7,6 +7,15 @@ class asdg_FrontSideRail: asdg_SlotInfo {
|
||||
};
|
||||
};
|
||||
|
||||
class SlotInfo;
|
||||
class PointerSlot: SlotInfo {
|
||||
compatibleItems[] += {
|
||||
"ACE_acc_pointer_red",
|
||||
"ACE_acc_pointer_green_IR",
|
||||
"ACE_acc_pointer_green"
|
||||
};
|
||||
};
|
||||
|
||||
class PointerSlot_Rail: PointerSlot {
|
||||
class compatibleItems {
|
||||
ACE_acc_pointer_red = 1;
|
||||
|
@ -1,9 +1,3 @@
|
||||
|
||||
class SlotInfo;
|
||||
class PointerSlot: SlotInfo {
|
||||
compatibleItems[] += {"ACE_acc_pointer_red","ACE_acc_pointer_green_IR","ACE_acc_pointer_green"};
|
||||
};
|
||||
|
||||
class CfgWeapons {
|
||||
class ItemCore;
|
||||
class InventoryFlashLightItem_Base_F;
|
||||
@ -15,69 +9,15 @@ class CfgWeapons {
|
||||
|
||||
displayName = CSTRING(red);
|
||||
descriptionUse = CSTRING(useLaser);
|
||||
};
|
||||
|
||||
class ACE_acc_pointer_red: ItemCore {
|
||||
MRT_SwitchItemNextClass = "acc_pointer_IR";
|
||||
MRT_SwitchItemPrevClass = "acc_pointer_IR";
|
||||
MRT_switchItemHintText = CSTRING(Laser);
|
||||
|
||||
ACE_laserpointer = 1;
|
||||
|
||||
author = ECSTRING(common,ACETeam);
|
||||
_generalMacro = "ACE_acc_pointer_red";
|
||||
scope = 1;
|
||||
displayName = CSTRING(red);
|
||||
descriptionUse = CSTRING(useLaser);
|
||||
picture = "\A3\weapons_F\Data\UI\gear_accv_pointer_CA.paa";
|
||||
model = "\A3\weapons_f\acc\accv_pointer_F";
|
||||
descriptionShort = CSTRING(Description);
|
||||
baseWeapon = "acc_pointer_IR";
|
||||
|
||||
class ItemInfo: InventoryFlashLightItem_Base_F {
|
||||
mass = 6;
|
||||
|
||||
class Pointer {
|
||||
irLaserPos = "laser pos";
|
||||
irLaserEnd = "laser dir";
|
||||
irDistance = 5;
|
||||
};
|
||||
|
||||
class FlashLight {
|
||||
color[] = {0,0,0};
|
||||
ambient[] = {0,0,0};
|
||||
intensity = 0;
|
||||
size = 0;
|
||||
innerAngle = 0;
|
||||
outerAngle = 0;
|
||||
coneFadeCoef = 5;
|
||||
position = "flash dir";
|
||||
direction = "flash";
|
||||
useFlare = 0;
|
||||
flareSize = 0;
|
||||
flareMaxDistance = "100.0f";
|
||||
dayLight = 0;
|
||||
|
||||
class Attenuation {
|
||||
start = 0;
|
||||
constant = 0;
|
||||
linear = 0;
|
||||
quadratic = 0;
|
||||
hardLimitStart = 0;
|
||||
hardLimitEnd = 0;
|
||||
};
|
||||
|
||||
scale[] = {0};
|
||||
};
|
||||
class Pointer;
|
||||
};
|
||||
|
||||
inertia = 0.1;
|
||||
};
|
||||
|
||||
class ACE_acc_pointer_green_IR: acc_pointer_IR {
|
||||
MRT_SwitchItemNextClass = "ACE_acc_pointer_green";
|
||||
MRT_SwitchItemPrevClass = "ACE_acc_pointer_green";
|
||||
MRT_switchItemHintText = CSTRING(IRLaser);
|
||||
|
||||
author = ECSTRING(common,ACETeam);
|
||||
_generalMacro = "ACE_acc_pointer_green";
|
||||
@ -86,17 +26,44 @@ class CfgWeapons {
|
||||
baseWeapon = "ACE_acc_pointer_green";
|
||||
};
|
||||
|
||||
class ACE_acc_pointer_red: acc_pointer_IR {
|
||||
MRT_SwitchItemNextClass = "acc_pointer_IR";
|
||||
MRT_SwitchItemPrevClass = "acc_pointer_IR";
|
||||
MRT_switchItemHintText = CSTRING(Laser);
|
||||
|
||||
author = ECSTRING(common,ACETeam);
|
||||
_generalMacro = "ACE_acc_pointer_red";
|
||||
scope = 1;
|
||||
descriptionShort = CSTRING(Description);
|
||||
baseWeapon = "acc_pointer_IR";
|
||||
|
||||
class ItemInfo: ItemInfo {
|
||||
class Pointer: Pointer {
|
||||
isIR = 0; // visible laser
|
||||
irDotSize = QUOTE(0.1/4); // default size / 4
|
||||
beamThickness = 0; // no visible beam
|
||||
dotColor[] = {8192, 0, 0}; // 5mW/low-vis
|
||||
beamColor[] = {0, 0, 0};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class ACE_acc_pointer_green: ACE_acc_pointer_red {
|
||||
MRT_SwitchItemNextClass = "ACE_acc_pointer_green_IR";
|
||||
MRT_SwitchItemPrevClass = "ACE_acc_pointer_green_IR";
|
||||
MRT_switchItemHintText = CSTRING(Laser);
|
||||
|
||||
ACE_laserpointer = 2;
|
||||
|
||||
author = ECSTRING(common,ACETeam);
|
||||
_generalMacro = "ACE_acc_pointer_green";
|
||||
scope = 2;
|
||||
displayName = CSTRING(green);
|
||||
baseWeapon = "ACE_acc_pointer_green";
|
||||
|
||||
class ItemInfo: ItemInfo {
|
||||
class Pointer: Pointer { // properties can't be inherited
|
||||
isIR = 0;
|
||||
beamThickness = 0;
|
||||
dotColor[] = {0, 16384, 0}; // high-vis
|
||||
beamColor[] = {0, 0, 0};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,3 +0,0 @@
|
||||
PREP(drawLaserpoint);
|
||||
PREP(getNearUnits);
|
||||
PREP(onDraw);
|
@ -1,98 +0,0 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
// fixes laser when being captured. Needed, because the selectionPosition of the right hand is used
|
||||
[QEGVAR(captives,setHandcuffed), {if (_this select 1) then {(_this select 0) action ["GunLightOff", _this select 0]};}] call CBA_fnc_addEventHandler;
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
GVAR(nearUnits) = [];
|
||||
GVAR(index) = -1;
|
||||
GVAR(laserClassesCache) = [] call CBA_fnc_createNamespace;
|
||||
GVAR(redLaserUnits) = [];
|
||||
GVAR(greenLaserUnits) = [];
|
||||
|
||||
["CBA_settingsInitialized", {
|
||||
// If not enabled, dont't add draw eventhandler or PFEH (for performance)
|
||||
if (!GVAR(enabled)) exitWith {
|
||||
["ACE_acc_pointer_red", { false }] call CBA_fnc_addAttachmentCondition;
|
||||
["ACE_acc_pointer_green", { false }] call CBA_fnc_addAttachmentCondition;
|
||||
["CBA_attachmentSwitched", {
|
||||
params ["_unit", "_prevItem", "_newItem", "_currWeaponType"];
|
||||
TRACE_4("CBA_attachmentSwitched eh",_unit,_prevItem,_newItem,_currWeaponType);
|
||||
if ((getNumber (configFile >> "CfgWeapons" >> _newItem >> "ACE_laserpointer")) > 0) then {
|
||||
TRACE_1("removing ACE_laserpointer",getNumber (configFile >> "CfgWeapons" >> _newItem >> "ACE_laserpointer"));
|
||||
[1, "next"] call CBA_accessory_fnc_switchAttachment;
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
[{
|
||||
private _oldNearUnits = GVAR(nearUnits);
|
||||
GVAR(nearUnits) = call FUNC(getNearUnits);
|
||||
|
||||
// remove units that moved away
|
||||
{
|
||||
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _x);
|
||||
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _x);
|
||||
} forEach (_oldNearUnits - GVAR(nearUnits));
|
||||
}, 5, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
|
||||
private _fnc_processUnit = {
|
||||
params ["_unit"];
|
||||
|
||||
private _weapon = currentWeapon _unit;
|
||||
if (!(_unit isFlashlightOn _weapon)) exitWith {
|
||||
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
|
||||
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
|
||||
};
|
||||
|
||||
private _laser = [(_unit weaponAccessories _weapon) select 1] param [0, ""];
|
||||
if (_laser isEqualTo "") exitWith {
|
||||
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
|
||||
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
|
||||
};
|
||||
|
||||
private _laserID = GVAR(laserClassesCache) getVariable _laser;
|
||||
|
||||
if (isNil "_laserID") then {
|
||||
_laserID = getNumber (configFile >> "CfgWeapons" >> _laser >> "ACE_laserpointer");
|
||||
GVAR(laserClassesCache) setVariable [_laser, _laserID];
|
||||
};
|
||||
TRACE_3("",_weapon,_laser,_laserID);
|
||||
|
||||
switch (_laserID) do {
|
||||
case 0: {
|
||||
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
|
||||
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
|
||||
};
|
||||
case 1: {
|
||||
GVAR(redLaserUnits) pushBackUnique _unit;
|
||||
GVAR(greenLaserUnits) deleteAt (GVAR(greenLaserUnits) find _unit);
|
||||
};
|
||||
case 2: {
|
||||
GVAR(greenLaserUnits) pushBackUnique _unit;
|
||||
GVAR(redLaserUnits) deleteAt (GVAR(redLaserUnits) find _unit);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// custom scheduler
|
||||
[{
|
||||
params ["_fnc_processUnit"];
|
||||
|
||||
ACE_player call _fnc_processUnit;
|
||||
|
||||
GVAR(index) = GVAR(index) + 1;
|
||||
private _unit = GVAR(nearUnits) param [GVAR(index), objNull];
|
||||
|
||||
if (isNull _unit) exitWith {
|
||||
GVAR(index) = -1;
|
||||
};
|
||||
|
||||
_unit call _fnc_processUnit;
|
||||
}, 0.1, _fnc_processUnit] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
addMissionEventHandler ["Draw3D", {call FUNC(onDraw)}];
|
||||
}] call CBA_fnc_addEventHandler;
|
@ -1,18 +1,3 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP_RECOMPILE_START;
|
||||
#include "XEH_PREP.hpp"
|
||||
PREP_RECOMPILE_END;
|
||||
|
||||
["visionMode", {
|
||||
params ["", "_visionMode"];
|
||||
|
||||
GVAR(isIR) = _visionMode isEqualTo 1;
|
||||
GVAR(isTI) = _visionMode isEqualTo 2;
|
||||
}] call CBA_fnc_addPlayerEventHandler;
|
||||
|
||||
#include "initSettings.sqf"
|
||||
|
||||
ADDON = true;
|
||||
|
@ -1,3 +0,0 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#include "XEH_PREP.hpp"
|
@ -14,7 +14,6 @@ class CfgPatches {
|
||||
};
|
||||
};
|
||||
|
||||
#include "ACE_Settings.hpp"
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgWeapons.hpp"
|
||||
|
@ -1,109 +0,0 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2 and esteldunedain
|
||||
* Draw a Laser Point
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Target unit <OBJECT>
|
||||
* 1: Range <NUMBER>
|
||||
* 2: is Green <BOOL>
|
||||
* 3: Brightness <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player, 10, false, 2] call ace_laserpointer_fnc_drawLaserpoint
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_target", "_range", "_isGreen", "_brightness"];
|
||||
|
||||
private _unit = ACE_player;
|
||||
|
||||
private _p0 = _target modelToWorldVisualWorld (_target selectionPosition "righthand");
|
||||
|
||||
// Find a system of orthogonal reference vectors
|
||||
// _v1 points in the direction of the weapon
|
||||
// _v2 points to the right of the weapon
|
||||
// _v3 points to the top side of the weapon
|
||||
private _v1 = _target weaponDirection currentWeapon _target;
|
||||
private _v2 = vectorNormalized (_v1 vectorCrossProduct [0,0,1]);
|
||||
private _v3 = _v2 vectorCrossProduct _v1;
|
||||
|
||||
// Offset over the 3 reference axis
|
||||
// This offset could eventually be configured by weapon in the config
|
||||
#define OFFV1 0.31
|
||||
#define OFFV2 0
|
||||
#define OFFV3 0.08
|
||||
|
||||
// Offset _p0, the start of the laser
|
||||
_p0 = _p0 vectorAdd (_v1 vectorMultiply OFFV1) vectorAdd (_v3 vectorMultiply OFFV3) vectorAdd (_v2 vectorMultiply OFFV2);
|
||||
|
||||
// Calculate _p1, the potential end of the laser
|
||||
private _p1 = _p0 vectorAdd (_v1 vectorMultiply _range);
|
||||
|
||||
private _pL = lineIntersectsSurfaces [_p0, _p1, _unit, vehicle _unit] select 0 select 0;
|
||||
|
||||
// no intersection found, quit (pointed to the sky or too far)
|
||||
if (isNil "_pL") exitWith {};
|
||||
|
||||
private _distance = _p0 vectorDistance _pL;
|
||||
|
||||
//systemChat str _distance;
|
||||
if (_distance < 0.5) exitWith {};
|
||||
|
||||
_pL = _p0 vectorAdd (_v1 vectorMultiply _distance);
|
||||
|
||||
private _pL2 = _p0 vectorAdd (_v1 vectorMultiply (_distance - 0.5));
|
||||
|
||||
_pL = ASLtoAGL _pL;
|
||||
|
||||
/*
|
||||
drawLine3D [
|
||||
_p0,
|
||||
_pL,
|
||||
[[1,0,0,1], [0,1,0,1]] select _isGreen
|
||||
];
|
||||
*/
|
||||
|
||||
//systemChat str [_target, "FIRE"] intersect [_camPos, _pL];
|
||||
|
||||
private _camPos = positionCameraToWorld [0,0,0.2];
|
||||
|
||||
// Check for blocking laser by player or external laser source (other player)
|
||||
private _blocked = false;
|
||||
if (_unit isEqualTo _target && {cameraView in ["INTERNAL","GUNNER"]}) then {
|
||||
// Laser belongs to player: check VIEW LOD
|
||||
// (it's less detailed & fallbacks to GEO if not present, but allows to draw laser mark behind bulletproof glass)
|
||||
if (count ([_unit, "VIEW"] intersect [_camPos, _pL]) > 0) exitWith { _blocked = true; };
|
||||
} else {
|
||||
// External laser: check FIRE GEO LOD (more detailed)
|
||||
if (count ([_target, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith { _blocked = true; };
|
||||
if (count ([_unit, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith { _blocked = true; };
|
||||
};
|
||||
|
||||
// Exit due to LOS blocked by source/player
|
||||
if (_blocked) exitWith {};
|
||||
|
||||
// Convert _camPos to ASL
|
||||
_camPos = AGLToASL _camPos;
|
||||
|
||||
// Check for blocking by terrain or object
|
||||
if (terrainIntersectASL [_camPos, _pL2]) exitWith {};
|
||||
if (lineIntersects [_camPos, _pL2]) exitWith {};
|
||||
|
||||
private _size = 2 * sqrt (1 / _distance) * (call EFUNC(common,getZoom));
|
||||
|
||||
drawIcon3D [
|
||||
format ["\a3\weapons_f\acc\data\collimdot_%1_ca.paa", ["red", "green"] select _isGreen],
|
||||
[[1,0.25,0.25,0.6*_brightness], [0.25,1,0.25,0.5*_brightness]] select _isGreen,
|
||||
_pL,
|
||||
_size,
|
||||
_size,
|
||||
45,
|
||||
"",
|
||||
0,
|
||||
0.05
|
||||
];
|
@ -1,29 +0,0 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2
|
||||
* Reports near units.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* Near Units <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* call ACE_laserpointer_fnc_getNearUnits
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
private _camPosAGL = positionCameraToWorld [0, 0, 0];
|
||||
|
||||
// handle RHS / bugged vehicle slots
|
||||
if !((_camPosAGL select 0) isEqualType 0) exitWith { [] };
|
||||
|
||||
private _nearUnits = [];
|
||||
|
||||
{
|
||||
_nearUnits append crew _x;
|
||||
} forEach nearestObjects [_camPosAGL, ["AllVehicles"], MAX_LASER_RANGE];
|
||||
|
||||
_nearUnits
|
@ -1,30 +0,0 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: commy2
|
||||
* Draw the visible laser beams of all cached units.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* call ACE_laserpointer_fnc_onDraw
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
if (count GVAR(redLaserUnits) + count GVAR(greenLaserUnits) > 0 && {!GVAR(isTI)}) then {
|
||||
private _brightness = 2 - call EFUNC(common,ambientBrightness);
|
||||
|
||||
{
|
||||
// red laser. draw green dot anyway in IR mode
|
||||
[_x, 100, GVAR(isIR), _brightness] call FUNC(drawLaserpoint);
|
||||
} count GVAR(redLaserUnits);
|
||||
|
||||
{
|
||||
// green laser
|
||||
[_x, 100, true, _brightness] call FUNC(drawLaserpoint);
|
||||
} count GVAR(greenLaserUnits);
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
[
|
||||
QGVAR(enabled), "CHECKBOX",
|
||||
LSTRING(DisplayName),
|
||||
ELSTRING(common,ACEKeybindCategoryWeapons),
|
||||
true,
|
||||
1
|
||||
] call CBA_fnc_addSetting;
|
@ -15,5 +15,3 @@
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
|
||||
#define MAX_LASER_RANGE 50
|
||||
|
Loading…
Reference in New Issue
Block a user