mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
add day laser pointer
This commit is contained in:
parent
fa2acfbb50
commit
8683667d24
1
addons/laserpointer/$PBOPREFIX$
Normal file
1
addons/laserpointer/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
|||||||
|
z\ace\addons\laserpointer
|
12
addons/laserpointer/CfgEventHandlers.hpp
Normal file
12
addons/laserpointer/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
class Extended_PreInit_EventHandlers {
|
||||||
|
class ADDON {
|
||||||
|
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class Extended_PostInit_EventHandlers {
|
||||||
|
class ADDON {
|
||||||
|
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||||
|
};
|
||||||
|
};
|
42
addons/laserpointer/CfgVehicles.hpp
Normal file
42
addons/laserpointer/CfgVehicles.hpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
#define MACRO_ADDITEM(ITEM,COUNT) class _xx_##ITEM { \
|
||||||
|
name = #ITEM; \
|
||||||
|
count = COUNT; \
|
||||||
|
}
|
||||||
|
|
||||||
|
class CfgVehicles {
|
||||||
|
class NATO_Box_Base;
|
||||||
|
class Box_NATO_Support_F: NATO_Box_Base {
|
||||||
|
class TransportItems {
|
||||||
|
MACRO_ADDITEM(ACE_acc_pointer_red,4);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class EAST_Box_Base;
|
||||||
|
class Box_East_Support_F: EAST_Box_Base {
|
||||||
|
class TransportItems {
|
||||||
|
MACRO_ADDITEM(ACE_acc_pointer_green,4);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class IND_Box_Base;
|
||||||
|
class Box_IND_Support_F: IND_Box_Base {
|
||||||
|
class TransportItems {
|
||||||
|
MACRO_ADDITEM(ACE_acc_pointer_green,4);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class FIA_Box_Base_F;
|
||||||
|
class Box_FIA_Support_F: FIA_Box_Base_F {
|
||||||
|
class TransportItems {
|
||||||
|
MACRO_ADDITEM(ACE_acc_pointer_red,4);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class ACE_Box_Misc: Box_NATO_Support_F {
|
||||||
|
class TransportItems {
|
||||||
|
MACRO_ADDITEM(ACE_acc_pointer_red,4);
|
||||||
|
MACRO_ADDITEM(ACE_acc_pointer_green,4);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
62
addons/laserpointer/CfgWeapons.hpp
Normal file
62
addons/laserpointer/CfgWeapons.hpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
class SlotInfo;
|
||||||
|
class PointerSlot: SlotInfo {
|
||||||
|
compatibleItems[] += {"ACE_acc_pointer_red","ACE_acc_pointer_green"};
|
||||||
|
};
|
||||||
|
|
||||||
|
class CfgWeapons {
|
||||||
|
class ItemCore;
|
||||||
|
class InventoryFlashLightItem_Base_F;
|
||||||
|
|
||||||
|
class ACE_acc_pointer_red: ItemCore {
|
||||||
|
author = "$STR_ACE_Common_ACETeam";
|
||||||
|
_generalMacro = "ACE_acc_pointer_red";
|
||||||
|
scope = 2;
|
||||||
|
displayName = "$STR_ACE_Laserpointer_red";
|
||||||
|
descriptionUse = "$STR_ACE_Laserpointer_useLaser";
|
||||||
|
picture = "\A3\weapons_F\Data\UI\gear_accv_pointer_CA.paa";
|
||||||
|
model = "\A3\weapons_f\acc\accv_pointer_F";
|
||||||
|
descriptionShort = "$STR_ACE_Laserpointer_Description";
|
||||||
|
|
||||||
|
class ItemInfo: InventoryFlashLightItem_Base_F {
|
||||||
|
mass = 6;
|
||||||
|
|
||||||
|
class Pointer {};
|
||||||
|
|
||||||
|
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};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
inertia = 0.1;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ACE_acc_pointer_green: ACE_acc_pointer_red {
|
||||||
|
author = "$STR_ACE_Common_ACETeam";
|
||||||
|
_generalMacro = "ACE_acc_pointer_green";
|
||||||
|
displayName = "$STR_ACE_Laserpointer_green";
|
||||||
|
};
|
||||||
|
};
|
21
addons/laserpointer/XEH_postInit.sqf
Normal file
21
addons/laserpointer/XEH_postInit.sqf
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
GVAR(nearUnits) = [];
|
||||||
|
|
||||||
|
// @todo. Maybe move to common?
|
||||||
|
[{
|
||||||
|
private "_nearUnits";
|
||||||
|
_nearUnits = nearestObjects [ACE_player, ["CAManBase"], 50];
|
||||||
|
|
||||||
|
if (count _nearUnits > 10) then {
|
||||||
|
_nearUnits resize 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
GVAR(nearUnits) = _nearUnits;
|
||||||
|
|
||||||
|
} , 5, []] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
addMissionEventHandler ["Draw3D", {
|
||||||
|
call FUNC(onDraw);
|
||||||
|
}];
|
4
addons/laserpointer/XEH_preInit.sqf
Normal file
4
addons/laserpointer/XEH_preInit.sqf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PREP(drawLaserpoint);
|
||||||
|
PREP(onDraw);
|
17
addons/laserpointer/config.cpp
Normal file
17
addons/laserpointer/config.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
class CfgPatches {
|
||||||
|
class ADDON {
|
||||||
|
units[] = {};
|
||||||
|
weapons[] = {"AGM_acc_pointer_red","AGM_acc_pointer_green"};
|
||||||
|
requiredVersion = REQUIRED_VERSION;
|
||||||
|
requiredAddons[] = {"ace_common"};
|
||||||
|
author[] = {"commy2"};
|
||||||
|
authorUrl = "https://github.com/commy2";
|
||||||
|
VERSION_CONFIG;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "CfgEventHandlers.hpp"
|
||||||
|
#include "CfgVehicles.hpp"
|
||||||
|
#include "CfgWeapons.hpp"
|
111
addons/laserpointer/functions/fnc_drawLaserpoint.sqf
Normal file
111
addons/laserpointer/functions/fnc_drawLaserpoint.sqf
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_unit", "_range", "_isGreen"];
|
||||||
|
|
||||||
|
_unit = _this select 0;
|
||||||
|
_range = _this select 1;
|
||||||
|
_isGreen = _this select 2;
|
||||||
|
|
||||||
|
_p0 = _unit modelToWorld (_unit selectionPosition "righthand");
|
||||||
|
_d = _unit weaponDirection currentWeapon _unit;
|
||||||
|
|
||||||
|
_p1 = _p0 vectorAdd (_d vectorMultiply _range);
|
||||||
|
_pA = _p0 vectorAdd (_d vectorMultiply 0.5);
|
||||||
|
|
||||||
|
_offset0 = getTerrainHeightASL _p0;
|
||||||
|
_offset1 = getTerrainHeightASL _p1;
|
||||||
|
_offsetA = getTerrainHeightASL _pA;
|
||||||
|
|
||||||
|
_p1 = _p1 vectorAdd [0, 0, _offset0 - _offset1];
|
||||||
|
_p0 = _pA vectorAdd [0, 0, _offset0 - _offsetA];
|
||||||
|
|
||||||
|
_fnc_getDistance = {
|
||||||
|
private "_distance";
|
||||||
|
|
||||||
|
_pX = + _p0;
|
||||||
|
_line = [ATLToASL _p0, ATLToASL _pX];
|
||||||
|
|
||||||
|
_distance = _this;
|
||||||
|
_iteration = _distance;
|
||||||
|
|
||||||
|
while {
|
||||||
|
_iteration > 0.01 / 2
|
||||||
|
} do {
|
||||||
|
_iteration = _iteration / 2;
|
||||||
|
|
||||||
|
_pX = _p0 vectorAdd (_d vectorMultiply _distance);
|
||||||
|
|
||||||
|
_offsetX = getTerrainHeightASL _pX;
|
||||||
|
|
||||||
|
_pX = _pX vectorAdd [0, 0, _offset0 - _offsetX];
|
||||||
|
|
||||||
|
_line set [1, ATLToASL _pX];
|
||||||
|
|
||||||
|
_distance = _distance + (([1, -1] select (lineIntersects (_line + [_unit]) || {terrainIntersectASL _line})) * _iteration);
|
||||||
|
|
||||||
|
if (_distance > _this) exitWith {_distance = _this};
|
||||||
|
};
|
||||||
|
|
||||||
|
_distance
|
||||||
|
};
|
||||||
|
|
||||||
|
_distance = _range call _fnc_getDistance;
|
||||||
|
|
||||||
|
_units = nearestObjects [_unit, ["Man"], _distance];
|
||||||
|
_units deleteAt (_units find _unit);
|
||||||
|
|
||||||
|
_fnc_doesIntersect = {
|
||||||
|
_pX = _p0 vectorAdd (_d vectorMultiply (_this select 1));
|
||||||
|
|
||||||
|
_offsetX = getTerrainHeightASL _pX;
|
||||||
|
|
||||||
|
_pX = _pX vectorAdd [0, 0, _offset0 - _o1];
|
||||||
|
|
||||||
|
count ([_this select 0, "FIRE"] intersect [_p0, _pX]) > 0
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
if ([_x, _distance] call _fnc_doesIntersect) then {
|
||||||
|
_distance = _distance min (_unit distance _x);
|
||||||
|
};
|
||||||
|
} forEach _units;
|
||||||
|
|
||||||
|
//systemChat str _distance;
|
||||||
|
if (_distance < 0.5) exitWith {};
|
||||||
|
|
||||||
|
_pL = _p0 vectorAdd (_d vectorMultiply _distance);
|
||||||
|
_pL2 = _p0 vectorAdd (_d vectorMultiply (_distance - 0.5));
|
||||||
|
|
||||||
|
_offsetL = getTerrainHeightASL _pL;
|
||||||
|
_offsetL2 = getTerrainHeightASL _pL2;
|
||||||
|
|
||||||
|
_pL = _pL vectorAdd [0, 0, _offset0 - _offsetL];
|
||||||
|
_pL2 = _pL2 vectorAdd [0, 0, _offset0 - _offsetL2];
|
||||||
|
|
||||||
|
drawLine3D [
|
||||||
|
_p0,
|
||||||
|
_pL,
|
||||||
|
[[1,0,0,1], [0,1,0,1]] select _isGreen
|
||||||
|
];
|
||||||
|
|
||||||
|
_spL = worldToScreen _pL; //systemChat str _spL;
|
||||||
|
_size = 2 * (_range - (positionCameraToWorld [0,0,0] distance _pL)) / _range;
|
||||||
|
|
||||||
|
_camPos = positionCameraToWorld [0,0,0.2];
|
||||||
|
if (count ([_unit, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith {};
|
||||||
|
if (count ([ACE_player, "FIRE"] intersect [_camPos, _pL]) > 0) exitWith {};
|
||||||
|
if ( terrainIntersect [_camPos, _pL2]) exitWith {};
|
||||||
|
if (lineIntersects [ATLToASL _camPos, ATLToASL _pL2]) exitWith {};
|
||||||
|
|
||||||
|
drawIcon3D [
|
||||||
|
format ["\a3\weapons_f\acc\data\collimdot_%1_ca.paa", ["red", "green"] select _isGreen],
|
||||||
|
[[1,0.25,0.25,0.5*_brightness], [0.25,1,0.25,0.5*_brightness]] select _isGreen,
|
||||||
|
_pL,
|
||||||
|
_size,
|
||||||
|
_size,
|
||||||
|
45,
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
0.05
|
||||||
|
];
|
34
addons/laserpointer/functions/fnc_onDraw.sqf
Normal file
34
addons/laserpointer/functions/fnc_onDraw.sqf
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// by commy2
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
_brightness = 2 - call EFUNC(common,ambientBrightness);
|
||||||
|
_isIR = currentVisionMode ACE_player;
|
||||||
|
|
||||||
|
if (_isIR == 2) exitWith {};
|
||||||
|
|
||||||
|
_isIR = _isIR == 1;
|
||||||
|
|
||||||
|
{
|
||||||
|
_weapon = currentWeapon _x;
|
||||||
|
|
||||||
|
_laser = switch (_weapon) do {
|
||||||
|
case (""): {""};
|
||||||
|
case (primaryWeapon _x): {
|
||||||
|
primaryWeaponItems _x select 1;
|
||||||
|
};
|
||||||
|
case (secondaryWeapon _x): {
|
||||||
|
secondaryWeaponItems _x select 1;
|
||||||
|
};
|
||||||
|
case (handgunWeapon _x): {
|
||||||
|
handgunItems _x select 1;
|
||||||
|
};
|
||||||
|
default {""};
|
||||||
|
};
|
||||||
|
|
||||||
|
_laserID = ["ACE_acc_pointer_red", "ACE_acc_pointer_green"] find _laser;
|
||||||
|
|
||||||
|
if (_laserID > -1 && {_x isFlashlightOn _weapon}) then {
|
||||||
|
[_x, 30, _laserID == 1 || _isIR] call FUNC(drawLaserpoint);
|
||||||
|
};
|
||||||
|
|
||||||
|
} forEach GVAR(nearUnits);
|
1
addons/laserpointer/functions/script_component.hpp
Normal file
1
addons/laserpointer/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "\z\ace\addons\laserpointer\script_component.hpp"
|
12
addons/laserpointer/script_component.hpp
Normal file
12
addons/laserpointer/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#define COMPONENT laserpointer
|
||||||
|
#include "\z\ace\addons\main\script_mod.hpp"
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED_LASERPOINTER
|
||||||
|
#define DEBUG_MODE_FULL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENABLED_LASERPOINTER
|
||||||
|
#define DEBUG_SETTINGS DEBUG_ENABLED_LASERPOINTER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "\z\ace\addons\main\script_macros.hpp"
|
33
addons/laserpointer/stringtable.xml
Normal file
33
addons/laserpointer/stringtable.xml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project name="ACE">
|
||||||
|
<Package name="Laserpointer">
|
||||||
|
|
||||||
|
<Key ID="STR_ACE_Laserpointer_red">
|
||||||
|
<English>Laser Pointer (red)</English>
|
||||||
|
<German>Laserpointer (rot)</German>
|
||||||
|
</Key>
|
||||||
|
<Key ID="STR_ACE_Laserpointer_green">
|
||||||
|
<English>Laser Pointer (green)</English>
|
||||||
|
<German>Laserpointer (grün)</German>
|
||||||
|
</Key>
|
||||||
|
|
||||||
|
<Key ID="STR_ACE_Laserpointer_Description">
|
||||||
|
<English>Emits visible light. </English>
|
||||||
|
<German>Strahlt sichtbares Licht aus. </German>
|
||||||
|
</Key>
|
||||||
|
|
||||||
|
<Key ID="STR_ACE_Laserpointer_useLaser">
|
||||||
|
<Original><t color='#9cf953'>Use: </t>Turn Laser ON/OFF</Original>
|
||||||
|
<English><t color='#9cf953'>Use: </t>Turn Laser ON/OFF</English>
|
||||||
|
<Czech><t color='#9cf953'>Použití: </t>Zapnout/vypnout laser</Czech>
|
||||||
|
<French><t color='#9cf953'>Utiliser : </t>laser on/off</French>
|
||||||
|
<German><t color='#9cf953'>Benutzen: </t>Laser EIN/AUS</German>
|
||||||
|
<Italian><t color='#9cf953'>Uso: </t>Laser ON/OFF</Italian>
|
||||||
|
<Polish><t color='#9cf953'>Użyj: </t>wł./wył. lasera</Polish>
|
||||||
|
<Portuguese><t color='#9cf953'>Uso: </t>Ativar/Desativar laser</Portuguese>
|
||||||
|
<Russian><t color='#9cf953'>Использовать: </t>вкл/выкл лазер</Russian>
|
||||||
|
<Spanish><t color='#9cf953'>Usar: </t>encender/apagar láser</Spanish>
|
||||||
|
</Key>
|
||||||
|
|
||||||
|
</Package>
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user