mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #956 from acemod/laserCodeSelection
Laser code selection & Designation
This commit is contained in:
commit
e8584fd68b
@ -17,4 +17,29 @@ class CfgVehicles {
|
||||
simulation = "LaserTarget";
|
||||
model = "\A3\Weapons_f\laserTgt.p3d";
|
||||
};
|
||||
|
||||
// Vehicle lockable configurations
|
||||
|
||||
class AllVehicles;
|
||||
class Air: AllVehicles {
|
||||
class Turrets;
|
||||
};
|
||||
|
||||
class Helicopter: Air {
|
||||
class Turrets {
|
||||
class MainTurret;
|
||||
};
|
||||
};
|
||||
|
||||
class Helicopter_Base_F: Helicopter {};
|
||||
|
||||
class Heli_Attack_01_base_F: Helicopter_Base_F {};
|
||||
|
||||
class B_Heli_Attack_01_F: Heli_Attack_01_base_F {
|
||||
class Turrets: Turrets {
|
||||
class MainTurret: MainTurret {
|
||||
GVAR(CanLockLaser) = 1; // Enable laser locking selection
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
@ -1,5 +1,7 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#include "initKeybinds.sqf"
|
||||
|
||||
["laser_laserOn", {_this call DFUNC(handleLaserOn)}] call EFUNC(common,addEventHandler);
|
||||
["laser_laserOff", {_this call DFUNC(handleLaserOff)}] call EFUNC(common,addEventHandler);
|
||||
|
||||
|
@ -24,6 +24,10 @@ PREP(laserTargetPFH);
|
||||
|
||||
GVAR(VanillaLasers) = [];
|
||||
|
||||
PREP(unitTurretCanLockLaser);
|
||||
PREP(keyLaserCodeUp);
|
||||
PREP(keyLaserCodeDown);
|
||||
|
||||
// Laser default variables
|
||||
ACE_DEFAULT_LASER_CODE = 1001;
|
||||
ACE_DEFAULT_LASER_WAVELENGTH = 1550;
|
||||
|
12
addons/laser/functions/fnc_keyLaserCodeDown.sqf
Normal file
12
addons/laser/functions/fnc_keyLaserCodeDown.sqf
Normal file
@ -0,0 +1,12 @@
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
private["_oldLaserCode", "_laserCode"];
|
||||
|
||||
_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE];
|
||||
if(_oldLaserCode > ACE_DEFAULT_LASER_CODE) then {
|
||||
_laserCode = _oldLaserCode - 1;
|
||||
ACE_player setVariable [QGVAR(code), _laserCode, false];
|
||||
};
|
||||
if(_laserCode != _oldLaserCode) then {
|
||||
[format ["%1: %2", localize "STR_ACE_laser_laserCode", _laserCode]] call EFUNC(common,displayTextStructured);
|
||||
};
|
10
addons/laser/functions/fnc_keyLaserCodeUp.sqf
Normal file
10
addons/laser/functions/fnc_keyLaserCodeUp.sqf
Normal file
@ -0,0 +1,10 @@
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
private["_oldLaserCode", "_laserCode"];
|
||||
|
||||
_oldLaserCode = ACE_player getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE];
|
||||
_laserCode = _oldLaserCode + 1;
|
||||
ACE_player setVariable [QGVAR(code), _laserCode, false];
|
||||
if(_laserCode != _oldLaserCode) then {
|
||||
[format ["%1: %2", localize "STR_ACE_laser_laserCode", _laserCode]] call EFUNC(common,displayTextStructured);
|
||||
};
|
21
addons/laser/functions/fnc_unitTurretCanLockLaser.sqf
Normal file
21
addons/laser/functions/fnc_unitTurretCanLockLaser.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: jaynus
|
||||
* Checks if the turret occupied by the given unit can lock a laser designator and select laser code.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Has designator? <BOOL>
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_1_PVT(_this,_unit);
|
||||
|
||||
// Get the player turret path
|
||||
private ["_turret","_config","_turretConfig"];
|
||||
_turret = [_unit] call EFUNC(common,getTurretIndex);
|
||||
_config = configFile >> "CfgVehicles" >> typeOf vehicle _unit;
|
||||
_turretConfig = [_config, _turret] call EFUNC(common,getTurretConfigPath);
|
||||
|
||||
getNumber (_turretConfig >> QGVAR(CanLockLaser)) > 0
|
27
addons/laser/initKeybinds.sqf
Normal file
27
addons/laser/initKeybinds.sqf
Normal file
@ -0,0 +1,27 @@
|
||||
["ACE3 Equipment", QGVAR(LaserCodeUp), localize "STR_ACE_laser_laserCodeUp",
|
||||
{
|
||||
if( EGVAR(laser_selfdesignate,active)
|
||||
||
|
||||
{ (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope.
|
||||
||
|
||||
{ [ACE_player] call FUNC(unitTurretCanLockLaser) }
|
||||
) then {
|
||||
[] call FUNC(keyLaserCodeUp);
|
||||
};
|
||||
},
|
||||
{false},
|
||||
[16, [false, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+Q)
|
||||
|
||||
["ACE3 Equipment", QGVAR(LaserCodeDown), localize "STR_ACE_laser_laserCodeDown",
|
||||
{
|
||||
if( EGVAR(laser_selfdesignate,active)
|
||||
||
|
||||
{ (currentWeapon ACE_player) == "Laserdesignator" && (call CBA_fnc_getFoV) select 1 > 5 } // If laserdesignator & FOV, we are in scope.
|
||||
||
|
||||
{ [ACE_player] call FUNC(unitTurretCanLockLaser) }
|
||||
) then {
|
||||
[] call FUNC(keyLaserCodeDown);
|
||||
};
|
||||
},
|
||||
{false},
|
||||
[18, [true, true, true]], false, 0] call CBA_fnc_addKeybind; // (ALT+CTRL+E)
|
14
addons/laser/stringtable.xml
Normal file
14
addons/laser/stringtable.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="laser">
|
||||
<Key ID="STR_ACE_laser_laserCode">
|
||||
<English>Laser Code</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_laser_laserCodeUp">
|
||||
<English>Laser - Cycle Code Up</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_laser_laserCodeDown">
|
||||
<English>Laser - Cycle Code Down</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
@ -21,4 +21,29 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Plane: Air {};
|
||||
class Plane_Base_F: Plane {
|
||||
class Turrets {
|
||||
class CopilotTurret;
|
||||
};
|
||||
};
|
||||
|
||||
/* @TODO: LGB GBU
|
||||
class Plane_CAS_01_base_F: Plane_Base_F {
|
||||
class Turrets: Turrets {
|
||||
class MainTurret: MainTurret {
|
||||
GVAR(Enabled) = 1; // Enable laser self-designation
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Plane_CAS_02_base_F: Plane_Base_F {
|
||||
class Turrets: Turrets {
|
||||
class MainTurret: MainTurret {
|
||||
GVAR(Enabled) = 1; // Enable laser self-designation
|
||||
};
|
||||
};
|
||||
};
|
||||
*/
|
||||
};
|
||||
|
@ -29,6 +29,10 @@ _seekerType = (vehicle _shooter) getVariable [QGVAR(seekerType), nil];
|
||||
_attackProfile = (vehicle _shooter) getVariable [QGVAR(attackProfile), nil];
|
||||
_lockMode = (vehicle _shooter) getVariable [QGVAR(lockMode), nil];
|
||||
|
||||
// @TODO: make this vehicle shooter, but we need to differentiate where its set in ace_laser
|
||||
_laserCode = _shooter getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE];
|
||||
_laserInfo = [_laserCode, ACE_DEFAULT_LASER_WAVELENGTH, ACE_DEFAULT_LASER_WAVELENGTH];
|
||||
|
||||
_launchPos = getPosASL (vehicle _shooter);
|
||||
|
||||
TRACE_3("Begin guidance", _target, _seekerType, _attackProfile);
|
||||
@ -69,7 +73,8 @@ _args = [_this,
|
||||
[_target, _targetPos, _launchPos],
|
||||
_seekerType,
|
||||
_attackProfile,
|
||||
_lockMode
|
||||
_lockMode,
|
||||
_laserInfo
|
||||
],
|
||||
[
|
||||
getNumber ( _config >> "minDeflection" ),
|
||||
|
@ -2,17 +2,19 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
|
||||
private["_angleFov", "_canSeeTarget", "_foundTargetPos", "_laserResult", "_launchParams", "_seekerParams", "_seekerTargetPos", "_sensorPos", "_target"];
|
||||
private["_angleFov", "_canSeeTarget", "_foundTargetPos", "_laserResult", "_launchParams", "_seekerParams", "_laserCode", "_laserParams", "_seekerTargetPos", "_sensorPos", "_target"];
|
||||
_seekerTargetPos = _this select 0;
|
||||
_launchParams = _this select 1;
|
||||
_seekerParams = _launchParams select 3;
|
||||
_angleFov = _seekerParams select 0;
|
||||
|
||||
_laserParams = (_launchParams select 1) select 5;
|
||||
TRACE_2("", _launchParams, _laserParams);
|
||||
if(!isNil "_target") then {
|
||||
// Handle AI or moving vanilla lasers
|
||||
_foundTargetPos = getPosASL _target;
|
||||
} else {
|
||||
_laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], ACE_DEFAULT_LASER_CODE] call EFUNC(laser,seekerFindLaserSpot);
|
||||
_laserResult = [(getPosASL _projectile), (velocity _projectile), _angleFov, [(_laserParams select 1),(_laserParams select 2)], (_laserParams select 0)] call EFUNC(laser,seekerFindLaserSpot);
|
||||
_foundTargetPos = _laserResult select 0;
|
||||
TRACE_1("Search", _laserResult);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user