add day laser pointer

This commit is contained in:
commy2 2015-01-17 23:38:13 +01:00
parent fa2acfbb50
commit 8683667d24
12 changed files with 350 additions and 0 deletions

View File

@ -0,0 +1 @@
z\ace\addons\laserpointer

View 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));
};
};

View 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);
};
};
};

View 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";
};
};

View 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);
}];

View File

@ -0,0 +1,4 @@
#include "script_component.hpp"
PREP(drawLaserpoint);
PREP(onDraw);

View 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"

View 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
];

View 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);

View File

@ -0,0 +1 @@
#include "\z\ace\addons\laserpointer\script_component.hpp"

View 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"

View 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>&lt;t color='#9cf953'&gt;Use: &lt;/t&gt;Turn Laser ON/OFF</Original>
<English>&lt;t color='#9cf953'&gt;Use: &lt;/t&gt;Turn Laser ON/OFF</English>
<Czech>&lt;t color='#9cf953'&gt;Použití: &lt;/t&gt;Zapnout/vypnout laser</Czech>
<French>&lt;t color='#9cf953'&gt;Utiliser : &lt;/t&gt;laser on/off</French>
<German>&lt;t color='#9cf953'&gt;Benutzen: &lt;/t&gt;Laser EIN/AUS</German>
<Italian>&lt;t color='#9cf953'&gt;Uso: &lt;/t&gt;Laser ON/OFF</Italian>
<Polish>&lt;t color='#9cf953'&gt;Użyj: &lt;/t&gt;wł./wył. lasera</Polish>
<Portuguese>&lt;t color='#9cf953'&gt;Uso: &lt;/t&gt;Ativar/Desativar laser</Portuguese>
<Russian>&lt;t color='#9cf953'&gt;Использовать: &lt;/t&gt;вкл/выкл лазер</Russian>
<Spanish>&lt;t color='#9cf953'&gt;Usar: &lt;/t&gt;encender/apagar láser</Spanish>
</Key>
</Package>
</Project>