Integarate laser code into SALH guidance + self_designate. Note todo items.

This commit is contained in:
jaynus 2015-04-12 11:01:22 -07:00
parent 40c5de8cfb
commit 01797fd3b9
9 changed files with 89 additions and 104 deletions

View File

@ -18,6 +18,7 @@ PREP(laserOff);
PREP(handleLaserOn);
PREP(handleLaserOff);
PREP(drawVisibleLaserTargets);
PREP(laser_init);

View File

@ -0,0 +1 @@
// @TODO: This is to draw the actual LaserTarget positions to utilize for laser shooting.

View File

@ -13,7 +13,7 @@
* Return value:
* String, UUID for sending to laserOff function.
*/
#include "script_component.hpp"
private ["_uuid", "_args"];

View File

@ -5,21 +5,23 @@ TRACE_1("enter", _this);
// Add the target to the global targets array
// Everyone tracks them
// Add the laser localized to the laser array, and give it the default localized code
PUSH(ACE_LASERS, _laserTarget);
// Check the vehicle, otherwise use the default
_laserTarget setVariable ["ACE_LASER_CODE", ACE_DEFAULT_LASER_CODE, false];
// Clean the lasers of any null objects while we are here
REM(ACE_LASERS, objNull);
if(!(local _laserTarget)) exitWith { };
// The target is local, so its on this client
if(!isDedicated) then {
_laserTarget setVariable ["ACE_LASERTARGET_SHOOTER", ACE_player, true];
_laserTarget setVariable [QGVAR(owner), ACE_player, true];
[FUNC(laserTargetPFH), 0, [_laserTarget, ACE_player]] call cba_fnc_addPerFrameHandler;
} else {
// server side ownership of laser
//_laserTarget setVariable ["ACE_LASERTARGET_SHOOTER", nil, false];
_laserTarget setVariable [QGVAR(owner), nil, true];
};

View File

@ -5,7 +5,8 @@ PREP(laserHudDesignateOn);
PREP(laserHudDesignateOff);
PREP(unitTurretHasDesignator);
GVAR(laser) = nil;
PREP(findLaserSource);
GVAR(active) = false;
FUNC(getPosASL) = {visiblePositionASL (_this select 0)};

View File

@ -0,0 +1,19 @@
//findLaserSource.sqf
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
private["_emitter", "_owner", "_gunnerInfo", "_turretInfo", "_povPos", "_povDir"];
_emmiter = _this select 0;
_owner = _this select 1;
_gunnerInfo = [_emmiter, (currentWeapon _emmiter)] call CBA_fnc_getFirer;
_turretInfo = [_emmiter, _gunnerInfo select 1] call EFUNC(common,getTurretDirection);
_povPos = _turretInfo select 0;
_povDir = _turretInfo select 1;
if(!isNil "_povPos" && !isNil "_povDir") exitWith {
[_povPos, _povDir]
};
[-1,-1]

View File

@ -1,28 +1,12 @@
#include "script_component.hpp"
if( (count _this) > 2) then {
EXPLODE_3_PVT(_this,_vehicle,_shooter,_laserTarget);
// We got the optional vehicle list, clear the parameters
_vehicle setVariable[QGVAR(currentTarget), [], true];
EXPLODE_3_PVT(_this,_shooter,_laserUuid, _localLaserTarget);
[_laserUuid] call EFUNC(laser,laserOff);
deleteVehicle _localLaserTarget;
};
if(isNil QGVAR(laser)) exitWith {
false
};
if(!local GVAR(laser)) then {
false
};
_handle = GVAR(laser) getVariable ["ACE_PFH_HANDLE", nil];
if(!isNil "_handle") then {
[_handle] call cba_fnc_removePerFrameHandler;
};
REM(ACE_LASERS, GVAR(laser));
deleteVehicle GVAR(laser);
GVAR(laser) = nil;
GVAR(active) = false;
true

View File

@ -6,102 +6,72 @@ TRACE_1("enter", _this);
#define FCS_UPDATE_DELAY 1
FUNC(laserHudDesignatePFH) = {
private["_strongestResultPos", "_args", "_laserTarget", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turret", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"];
private["_strongestResultPos", "_args", "_localLaserTarget", "_laserResultPosition", "_laserResult", "_shooter", "_vehicle", "_weapon", "_gunnerInfo", "_turretInfo", "_pov", "_gunBeg", "_gunEnd", "_povPos", "_povDir", "_result", "_resultPositions", "_firstResult", "_forceUpdateTime"];
_args = _this select 0;
_laserTarget = _args select 0;
_shooter = _args select 1;
TRACE_1("", _args, (_laserTarget getVariable["ACE_LASER_CODE"]));
if((vehicle ACE_player) != _shooter || !alive _shooter || isNull _vehicle || isNull _laserTarget || !GVAR(active) ) exitWith {
[_vehicle, _shooter, _laserTarget] call FUNC(laserHudDesignateOff);
_shooter = _args select 0;
_localLaserTarget = _args select 2;
_vehicle = vehicle _shooter;
TRACE_1("", _args);
if((vehicle _shooter) == _shooter || !alive _shooter || isNull _vehicle || !GVAR(active) ) exitWith {
_args call FUNC(laserHudDesignateOff);
};
if(!([_shooter] call FUNC(unitTurretHasDesignator)) ) exitWith {
[_vehicle, _shooter, _laserTarget] call FUNC(laserHudDesignateOff);
_args call FUNC(laserHudDesignateOff);
};
if( (count _args) < 3) then {
_args set[2, diag_tickTime + FCS_UPDATE_DELAY];
if( (count _args) < 4) then {
_args set[3, diag_tickTime + FCS_UPDATE_DELAY];
};
_forceUpdateTime = _args select 2;
_vehicle = vehicle _shooter;
_weapon = currentWeapon _vehicle;
// Retrieve the gunner and turret memory point information
_gunnerInfo = [_vehicle, _weapon] call CBA_fnc_getFirer;
_forceUpdateTime = _args select 3;
_gunnerInfo = [_vehicle, (currentWeapon _vehicle)] call CBA_fnc_getFirer;
_turretInfo = [_vehicle, _gunnerInfo select 1] call EFUNC(common,getTurretDirection);
_povPos = _turretInfo select 0;
_povDir = _turretInfo select 1;
_targetInfo = _vehicle getVariable[QGVAR(currentTarget), [] ];
if( (count _targetInfo) > 0) then {
if(_laserTarget != (_targetInfo select 0) ) then {
_targetInfo = []
};
};
if( (count _targetInfo) < 1) then {
_targetInfo = [_laserTarget, 1001]; // TODO: set laser code
_vehicle setVariable[QGVAR(currentTarget), _targetInfo, true];
_laserTarget setVariable[QGVAR(owner), _vehicle, true];
};
_result = [_povPos, _povDir] call EFUNC(laser,shootCone);
if((count _result) > 0) then {
_resultPositions = _result select 2;
_laserResult = [_povPos, [1550,1550], 1001] call EFUNC(laser,seekerFindLaserSpot);
_laserResultPosition = _laserResult select 0;
TRACE_1("Search", _laserResult);
if((count _resultPositions) > 0) then {
_strongestResultPos = [_resultPositions, _povPos] call EFUNC(laser,findStrongestRay);
// If the laser has moved less than a half meter, then dont move it.
// Just regular use of lasers will commonly make them move this much,
// but not across multiple close frames.
// This loses accuracy a little, but saves position updates per frame.
TRACE_5("", diag_tickTime, _forceUpdateTime, getPosASL _laserTarget, _strongestResultPos, ((getPosASL _laserTarget) distance _pos));
if(diag_tickTime > _forceUpdateTime) then {
TRACE_1("FCS Update", "");
["ace_fcs_forceUpdate", []] call ace_common_fnc_localEvent;
};
//if( (_laserTarget distance _strongestResultPos) > 0.1) then {
TRACE_1("LaserPos Update", "");
_laserTarget setPosATL (ASLToATL _strongestResultPos);
//};
if(diag_tickTime > _forceUpdateTime) then {
_args set[2, diag_tickTime + FCS_UPDATE_DELAY];
};
#ifdef DEBUG_MODE_FULL
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], (getPosATL _laserTarget), 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"];
{
private["_position"];
_position = _x select 0;
drawLine3d [ASLToATL _povPos, ASLToATL _position, [0,0,1,1] ];
} forEach _resultPositions;
#endif
if((count _laserResult) > 0) then {
// If the laser has moved less than a half meter, then dont move it.
// Just regular use of lasers will commonly make them move this much,
// but not across multiple close frames.
// This loses accuracy a little, but saves position updates per frame.
TRACE_4("", diag_tickTime, _forceUpdateTime, _laserResultPosition, (_laserResultPosition vectorDistance _pos));
if(diag_tickTime > _forceUpdateTime) then {
TRACE_1("FCS Update", "");
["ace_fcs_forceUpdate", []] call ace_common_fnc_localEvent;
};
if(diag_tickTime > _forceUpdateTime) then {
_args set[3, diag_tickTime + FCS_UPDATE_DELAY];
};
_localLaserTarget setPosASL _laserResultPosition;
#ifdef DEBUG_MODE_FULL
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], _laserResultPosition, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"];
drawLine3d [ASLToATL _povPos, ASLToATL _laserResultPosition, [0,0,1,1] ];
#endif
};
_this set[0, _args];
};
private ["_laserTarget", "_handle", "_vehicle"];
private ["_laserTarget", "_handle", "_vehicle", "_laserUuid"];
if(isNil QGVAR(laser)) then {
_laserTarget = "LaserTargetW" createVehicle (getpos ACE_player);
if(!GVAR(active)) then {
GVAR(active) = true;
_handle = [FUNC(laserHudDesignatePFH), 0.1, [_laserTarget, ACE_player]] call cba_fnc_addPerFrameHandler;
_laserTarget setVariable ["ACE_PFH_HANDLE", _handle, false];
TRACE_1("Activating laser", "");
_laserUuid = [(vehicle ACE_player), ACE_player, FUNC(findLaserSource), 1550, 1001, 1] call EFUNC(laser,laserOn);
// Clear the vehicle parameters
_vehicle setVariable[QGVAR(currentTarget), [], true];
GVAR(laser) = _laserTarget;
// @TODO: Create the local target for the players side
_localLaserTarget = "LaserTargetW" createVehicleLocal (getpos ACE_player);
_handle = [FUNC(laserHudDesignatePFH), 0.25, [ACE_player, _laserUuid, _localLaserTarget]] call cba_fnc_addPerFrameHandler;
} else {
[] call FUNC(laserHudDesignateOff);
[] call FUNC(laserHudDesignateOn);

View File

@ -1,4 +1,4 @@
//#define DEBUG_MODE_FULL
#define DEBUG_MODE_FULL
#include "script_component.hpp"
EXPLODE_7_PVT(((_this select 1) select 0),_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
@ -10,8 +10,15 @@ _launchParams = _this select 1;
_seekerParams = _launchParams select 3;
// TODO: this needs to be shootCone/findStrongestRay after testing
_targets = [_projectile, ACE_DEFAULT_LASER_CODE, (_seekerParams select 0)] call ace_laser_fnc_findLaserDesignator;
_foundTargetPos = getPosASL (_targets select 1);
//_targets = [_projectile, ACE_DEFAULT_LASER_CODE, (_seekerParams select 0)] call ace_laser_fnc_findLaserDesignator;
//_foundTargetPos = getPosASL (_targets select 1);
_laserResult = [(getPosASL _projectile), [1550,1550], 1001] call EFUNC(laser,seekerFindLaserSpot);
_foundTargetPos = _laserResult select 0;
TRACE_1("Search", _laserResult);
// @TODO: Check angle to target from seeker head
TRACE_1("Seeker return target pos", _foundTargetPos);
_foundTargetPos;