-
Notifications
You must be signed in to change notification settings - Fork 736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Ready) Adds more laser functionality to aircraft #7509
Changes from 4 commits
da7614a
0a62877
f3aefd6
131e868
8aebb02
544f961
c5e7576
8eb8423
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ if (hasInterface) then { | |
["ACE_controlledUAV", { | ||
params ["_UAV", "_seatAI", "_turret", "_position"]; | ||
TRACE_4("ACE_controlledUAV EH",_UAV,_seatAI,_turret,_position); | ||
if (!isNull _seatAI) then { | ||
if ( !isNull _seatAI) then { | ||
[_seatAI] call FUNC(showVehicleHud); | ||
} else { | ||
[ace_player] call FUNC(showVehicleHud); | ||
|
@@ -47,6 +47,71 @@ if (hasInterface) then { | |
}; | ||
}] call CBA_fnc_addEventHandler; | ||
|
||
|
||
["ace_laserOn", { | ||
params ["_uuid", "_args"]; | ||
private _vehicle = _args select 0; | ||
if (hasPilotCamera _vehicle) then { | ||
[_vehicle] call FUNC(laserPointTrack); | ||
}; | ||
}] call CBA_fnc_addEventHandler; | ||
|
||
["AllVehicles", "init", { | ||
params ["_vehicle"]; | ||
private _hasPilotCamera = hasPilotCamera _vehicle; | ||
private _hasLaserSensor = isClass (configfile >> "CfgVehicles" >> (typeOf _vehicle) >> "Components" >> "SensorsManagerComponent" >> "Components" >> "LaserSensorComponent"); | ||
|
||
|
||
if ( (_hasPilotCamera) && (_hasLaserSensor) ) then { | ||
_vehicle setVariable [QGVAR(hasLaserSpotTracker), true]; | ||
_vehicle setVariable [QGVAR(laserSpotTrackerOn), false]; | ||
private _actionOff = ["LSTOff", localize LSTRING(LSTOff), "", {[_this select 0] call FUNC(toggleLST)}, {(_this select 0) getVariable [QGVAR(laserSpotTrackerOn), false]}] call ace_interact_menu_fnc_createAction; | ||
[_vehicle, 1, ["ACE_SelfActions"], _actionOff] call ace_interact_menu_fnc_addActionToObject; | ||
private _actionOn = ["LSTOn", localize LSTRING(LSTOn), "", {[_this select 0] call FUNC(toggleLST)}, {!((_this select 0) getVariable [QGVAR(laserSpotTrackerOn), false])}] call ace_interact_menu_fnc_createAction; | ||
[_vehicle, 1, ["ACE_SelfActions"], _actionOn] call ace_interact_menu_fnc_addActionToObject; | ||
}; | ||
|
||
private _foundLaser = 0; | ||
private _weapons = weapons _vehicle; | ||
{ | ||
_weapons = _weapons + (_vehicle weaponsTurret _x); | ||
} forEach (allTurrets _vehicle); | ||
|
||
if (_weapons find "Laserdesignator_mounted" > -1) then { | ||
_foundLaser = 1; | ||
}; | ||
if (_weapons find "Laserdesignator_pilotCamera" > -1) then { | ||
_foundLaser = 2; | ||
}; | ||
|
||
if (_foundlaser == 0) exitWith {}; | ||
_vehicle setVariable [QGVAR(hasMarkerLaser), true]; | ||
_vehicle setVariable [QGVAR(laserMarkerOn), false]; | ||
|
||
private _actionOff = ["LaserMarkerOff", localize LSTRING(laserMarkOff), "", {[_this select 0] call FUNC(toggleMarker)}, {(_this select 0) getVariable [QGVAR(laserMarkerOn), false]}] call ace_interact_menu_fnc_createAction; | ||
[_vehicle, 1, ["ACE_SelfActions"], _actionOff] call ace_interact_menu_fnc_addActionToObject; | ||
private _actionOn = ["LaserMarkerOn", localize LSTRING(laserMarkOn), "", {[_this select 0] call FUNC(toggleMarker)}, {!((_this select 0) getVariable [QGVAR(laserMarkerOn), false])}] call ace_interact_menu_fnc_createAction; | ||
[_vehicle, 1, ["ACE_SelfActions"], _actionOn] call ace_interact_menu_fnc_addActionToObject; | ||
|
||
}, nil, nil, true] call CBA_fnc_addClassEventHandler; | ||
|
||
|
||
["CAManBase", "init", { | ||
params ["_unit"]; | ||
findDisplay 46 displayAddEventHandler ["KeyDown", { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not savegame compatible. |
||
params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"]; | ||
if (_ctrl) then {_key = _key + 486539264}; | ||
if (_shift) then {_key = _key + 704643072}; | ||
if (_alt) then {_key = _key + 939524096}; | ||
private _lightKeys = actionKeys "headlights"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not work. Floats too big. |
||
if (_lightKeys find _key > -1) then { | ||
if ( ((currentWeapon player) == "Laserdesignator")) then { | ||
[player] call FUNC(toggleMarkerHand); | ||
}; | ||
}; | ||
}]; | ||
}, nil, nil, true] call CBA_fnc_addClassEventHandler; | ||
|
||
// Shows detector and mine posistions in 3d when debug is on | ||
#ifdef DRAW_LASER_INFO | ||
addMissionEventHandler ["Draw3D", {_this call FUNC(dev_drawVisibleLaserTargets)}]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: LorenLuke | ||
* Used to draw laser line across all clients | ||
* | ||
* Arguments: | ||
* 0: start pos (AGL) <ARRAY> | ||
* 1: end pos (AGL) <ARRAY> | ||
* 2: 4 element color <ARRAY> | ||
* | ||
* Return Value: | ||
* Nothing | ||
* | ||
* Example: | ||
* [getpos Player, getpos (laserTarget Player), [1,1,1,1]] call ace_laser_fnc_drawLaserLine | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_list"]; | ||
|
||
if ((currentVisionMode ACE_player) > 0) then { | ||
{ | ||
_x params ["_start", "_end", "_color"]; | ||
drawLine3D [_start, _end, _color]; | ||
} forEach _list; | ||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,7 +19,7 @@ params [["_codeChange", 0, [0]]]; | |||||
|
||||||
TRACE_1("params",_codeChange); | ||||||
|
||||||
if ((!alive ACE_player) || {!([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith))}) exitWith {false}; | ||||||
if (( !alive ACE_player) || {!([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith))}) exitWith {false}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stray space added? |
||||||
|
||||||
private _currentShooter = objNull; | ||||||
private _currentWeapon = ""; | ||||||
|
@@ -40,8 +40,10 @@ if (isNull (ACE_controlledUAV param [0, objNull])) then { | |||||
}; | ||||||
|
||||||
TRACE_2("",_currentShooter,_currentWeapon); | ||||||
if (((getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> "laser")) == 0) && | ||||||
{(getNumber (configFile >> "CfgWeapons" >> _currentWeapon >> QGVAR(canSelect))) == 0}) exitWith {false}; | ||||||
private _currentWeaponCfg = configFile >> "CfgWeapons" >> _currentWeapon; | ||||||
if ((getNumber (_currentWeaponCfg >> "laser") == 0) && | ||||||
( !(_currentShooter getVariable [QGVAR(hasLaserSpotTracker), false]) ) && | ||||||
{(getNumber (_currentWeaponCfg >> QGVAR(canSelect))) == 0}) exitWith {false}; | ||||||
|
||||||
private _oldLaserCode = _currentShooter getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; | ||||||
private _newLaserCode = _oldLaserCode; | ||||||
|
@@ -61,6 +63,12 @@ TRACE_2("",_oldLaserCode,_newLaserCode); | |||||
if (_oldLaserCode != _newLaserCode) then { | ||||||
_currentShooter setVariable [QGVAR(code), _newLaserCode, true]; | ||||||
}; | ||||||
[format ["%1: %2", localize LSTRING(laserCode), _newLaserCode]] call EFUNC(common,displayTextStructured); | ||||||
private _string = ""; | ||||||
if (_currentShooter getVariable [QGVAR(hasLaserSpotTracker), false]) then { | ||||||
private _LSTmessage = localize ([LSTRING(LSTOff), LSTRING(LSTOn)] select (_currentShooter getVariable [QGVAR(laserSpotTrackerOn), false])); | ||||||
_string = format ["%1<br/>", _LSTmessage]; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say format is probably more expensive than +
Suggested change
|
||||||
}; | ||||||
_string = format ["%1%2: %3", _string, localize LSTRING(laserCode), _newLaserCode]; | ||||||
[_string] call EFUNC(common,displayTextStructured); | ||||||
|
||||||
true |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,46 @@ | ||||||
#include "script_component.hpp" | ||||||
/* | ||||||
* Author: LorenLuke | ||||||
* Toggles laser point tracking when a laser is on, for tracking coordinates; | ||||||
* | ||||||
* Arguments: | ||||||
* 0: Vehicle <OBJECT> | ||||||
* | ||||||
* Return Value: | ||||||
* Nothing | ||||||
* | ||||||
* Example: | ||||||
* [vehicle player] call ace_laser_fnc_laserPointTrack | ||||||
* | ||||||
* Public: No | ||||||
*/ | ||||||
|
||||||
|
||||||
params ["_vehicle"]; | ||||||
|
||||||
GVAR(TrackerpfID) = [{ | ||||||
params ["_args", "_pfID"]; | ||||||
_args params ["_vehicle"]; | ||||||
if ( !(hasPilotCamera _vehicle)) exitWith { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
[_pfID] call CBA_fnc_removePerFrameHandler; | ||||||
}; | ||||||
if (isNull(laserTarget _vehicle)) exitWith { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
[_pfID] call CBA_fnc_removePerFrameHandler; | ||||||
}; | ||||||
if ( !((getPilotCameraTarget _vehicle) select 0)) exitWith { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
if (isNull (getPilotCameraTarget _vehicle select 2)) then { | ||||||
private _distance = ((getPilotCameraTarget _vehicle) select 1) distance getPosASL (laserTarget _vehicle); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the line above you didn't put parenthesis around getPilotCameraTarget, why do it here? |
||||||
|
||||||
if (_distance > 0.15) then { | ||||||
private _vehPos = getPosASL _vehicle; | ||||||
private _vectorToLaser = _vehPos vectorFromTo (getPosASL (laserTarget _vehicle)); | ||||||
private _vectorToSpot = _vehPos vectorFromTo ((getPilotCameraTarget _vehicle) select 1); | ||||||
if (acos(_vectorToLaser vectorCos _vectorToSpot) < 0.025) then { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have me deleting extra spaces all around, why would there need to be one between acos and the parentheses (considering that my formatting is like a single-argument method)? |
||||||
_vehicle setPilotCameraTarget getPosASL(laserTarget _vehicle); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
}; | ||||||
}; | ||||||
}, 0, [_vehicle]] call CBA_fnc_addPerFrameHandler; | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,19 +12,24 @@ | |||||
* 4: Seeker wavelength sensitivity range, [1550,1550] is common eye safe <ARRAY> | ||||||
* 5: Seeker laser code. <NUMBER> | ||||||
* 6: Ignore 1 (e.g. Player's vehicle) <OBJECT> (default: objNull) | ||||||
* 7: Ignore 2 (e.g. Player's vehicle) <OBJECT> (default: objNull) | ||||||
* | ||||||
* Return Value: | ||||||
* [Strongest compatible laser spot ASL pos, owner object] Nil array values if nothing found <ARRAY> | ||||||
* | ||||||
* Example: | ||||||
* [getPosASL player, [0,1,0], 90, [1500, 1500], 1111, player] call ace_laser_fnc_seekerFindLaserSpot | ||||||
* [getPosASL player, [0,1,0], 90, [1500, 1500], 1111, player, vehiclePlayer] call ace_laser_fnc_seekerFindLaserSpot | ||||||
* | ||||||
* Public: No | ||||||
*/ | ||||||
|
||||||
BEGIN_COUNTER(seekerFindLaserSpot); | ||||||
|
||||||
params ["_posASL", "_dir", "_seekerFov", "_seekerMaxDistance", "_seekerWavelengths", "_seekerCode", ["_ignoreObj1", objNull]]; | ||||||
params ["_posASL", "_dir", "_seekerFov", "_seekerMaxDistance", "_seekerWavelengths", "_seekerCode", "_ignoreObj", "_ignoreBy"]; | ||||||
|
||||||
if(isNil "_ignoreBy") then { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
_ignoreBy = objNull; | ||||||
}; | ||||||
|
||||||
_dir = vectorNormalized _dir; | ||||||
_seekerWavelengths params ["_seekerWavelengthMin", "_seekerWavelengthMax"]; | ||||||
|
@@ -79,7 +84,9 @@ private _finalOwner = objNull; | |||||
private _testPointVector = _posASL vectorFromTo _testPoint; | ||||||
private _testDotProduct = _dir vectorDotProduct _testPointVector; | ||||||
if ((_testDotProduct > _seekerCos) && {(_testPoint vectorDistanceSqr _posASL) < _seekerMaxDistSq}) then { | ||||||
_spots pushBack [_testPoint, _owner]; | ||||||
if(_owner != _ignoreBy) then { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
_spots pushBack [_testPoint, _owner]; | ||||||
}; | ||||||
}; | ||||||
} forEach _resultPositions; | ||||||
} else { | ||||||
|
@@ -142,7 +149,7 @@ if ((count _spots) > 0) then { | |||||
_bucketList = _finalBuckets select _index; | ||||||
{ | ||||||
private _testPos = (_x select 0) vectorAdd [0,0,0.05]; | ||||||
private _testIntersections = lineIntersectsSurfaces [_posASL, _testPos, _ignoreObj1]; | ||||||
private _testIntersections = lineIntersectsSurfaces [_posASL, _testPos, _ignoreObj, objNull]; | ||||||
if ([] isEqualTo _testIntersections) then { | ||||||
_bucketList pushBack _x; | ||||||
}; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,66 @@ | ||||||||||||||
#include "script_component.hpp" | ||||||||||||||
/* | ||||||||||||||
* Author: LorenLuke | ||||||||||||||
* Toggles the laser spot tracker for any enabled vehicle; | ||||||||||||||
* | ||||||||||||||
* Arguments: | ||||||||||||||
* 0: Vehicle <OBJECT> | ||||||||||||||
* | ||||||||||||||
* Return Value: | ||||||||||||||
* Nothing | ||||||||||||||
* | ||||||||||||||
* Example: | ||||||||||||||
* [vehicle player] call ace_laser_fnc_toggleLST | ||||||||||||||
* | ||||||||||||||
* Public: No | ||||||||||||||
*/ | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
params ["_vehicle"]; | ||||||||||||||
|
||||||||||||||
if !(_vehicle getVariable [QGVAR(hasLaserSpotTracker), false]) exitWith {}; | ||||||||||||||
|
||||||||||||||
private _enabled = _vehicle getVariable [QGVAR(laserSpotTrackerOn), false]; | ||||||||||||||
_vehicle setVariable [QGVAR(laserSpotTrackerOn), ! _enabled]; | ||||||||||||||
|
||||||||||||||
private _LSTmessage = if (_vehicle getVariable [QGVAR(laserSpotTrackerOn), false]) then {localize LSTRING(LSTOn)} else {localize LSTRING(LSTOff)}; | ||||||||||||||
private _string = format ["%1<br/>", _LSTmessage]; | ||||||||||||||
private _laserCode = _vehicle getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; | ||||||||||||||
_string = format ["%1%2: %3<br/>",_string, localize LSTRING(laserCode), _laserCode]; | ||||||||||||||
[_string] call EFUNC(common,displayTextStructured); | ||||||||||||||
|
||||||||||||||
GVAR(TrackerpfID) = [{ | ||||||||||||||
params ["_args", "_pfID"]; | ||||||||||||||
_args params ["_vehicle"]; | ||||||||||||||
|
||||||||||||||
if ( !(_vehicle getVariable [QGVAR(laserSpotTrackerOn), false]) || ( !alive _vehicle)) exitWith { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
[_pfID] call CBA_fnc_removePerFrameHandler; | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
private _pos = _vehicle modelToWorldWorld [0,0,0]; | ||||||||||||||
|
||||||||||||||
private _pilotCameraPos = getPilotCameraPosition _vehicle; | ||||||||||||||
private _pilotCameraRotation = getPilotCameraRotation _vehicle; | ||||||||||||||
private _laserCode = _vehicle getVariable [QEGVAR(laser,code), ACE_DEFAULT_LASER_CODE]; | ||||||||||||||
|
||||||||||||||
private _angle = 30; | ||||||||||||||
if ((getPilotCameraTarget _vehicle) select 0) then { | ||||||||||||||
_angle = 0.75; | ||||||||||||||
}; | ||||||||||||||
private _pilotCameraLookPos = [sin(-deg(_pilotCameraRotation select 0)) * cos(-deg(_pilotCameraRotation select 1)), cos(-deg(_pilotCameraRotation select 0)) * cos(-deg(_pilotCameraRotation select 1)), sin(-deg(_pilotCameraRotation select 1))]; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
private _pilotCameraVector = _pos vectorFromTo (_vehicle modelToWorldWorld _pilotCameraLookPos); | ||||||||||||||
|
||||||||||||||
private _laserSource = _vehicle modelToWorldWorld _pilotCameraPos; | ||||||||||||||
|
||||||||||||||
private _laserResult = [_laserSource, _pilotCameraVector, _angle, 5000, [ACE_DEFAULT_LASER_WAVELENGTH,ACE_DEFAULT_LASER_WAVELENGTH], _laserCode, _vehicle, _vehicle] call FUNC(seekerFindLaserSpot); | ||||||||||||||
private _foundTargetPos = _laserResult select 0; | ||||||||||||||
|
||||||||||||||
if ((getPilotCameraTarget _vehicle) select 0) then { | ||||||||||||||
private _distance = ((getPilotCameraTarget _vehicle) select 1) distance _foundTargetPos; | ||||||||||||||
if (_distance > 0.75) then { | ||||||||||||||
_vehicle setPilotCameraTarget _foundTargetPos; | ||||||||||||||
}; | ||||||||||||||
} else { | ||||||||||||||
_vehicle setPilotCameraTarget _foundTargetPos; | ||||||||||||||
}; | ||||||||||||||
}, 0, [_vehicle]] call CBA_fnc_addPerFrameHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want something like
getNumber (configFile >> "CfgWeapons" >> (typeOf binocular ACE_PLAYER) >> QGVAR(whateverconfigname)) == 1
so that mods can add functionality without a headache