laser_selfdesginate commit for commanche

This commit is contained in:
jaynus 2015-01-19 20:13:12 -08:00
parent 8e41bcce59
commit 16a296e92b
15 changed files with 285 additions and 2 deletions

View File

@ -0,0 +1 @@
z\ace\Addons\laser_selfdesignate

View File

@ -0,0 +1,27 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_pre_init));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_post_init));
};
};
class Extended_GetIn_EventHandlers {
class B_Heli_Attack_01_F {
class ADDON {
getIn = QUOTE(call FUNC(onGetin));
};
}
};
class Extended_GetOut_EventHandlers {
class B_Heli_Attack_01_F {
class ADDON {
getOut = QUOTE(call FUNC(onGetout));
};
};
};

View File

@ -0,0 +1,32 @@
class RscPicture;
class RscText;
class RscControlsGroupNoScrollbars;
/* This disables air radar. We need to make this a seperate HUD addon
class RscInGameUI
{
class RscUnitInfo
{
class CA_Radar: RscControlsGroupNoScrollbars
{
class controls
{
class CA_RadarBackground: RscPicture {
colorText[] = {0,0,0,0};
text = "";
};
class CA_RadarIcon: RscPicture {
colorText[] = {0,0,0,0};
};
class CA_Heading: RscText {
colorText[] = {0,0,0,0};
};
};
};
};
};
class CfgInGameUI
{
};
*/

View File

@ -0,0 +1,35 @@
class CfgVehicles {
class AllVehicles;
class Air: AllVehicles {
class Turrets;
};
class Helicopter: Air
{
class Turrets: Turrets {
class MainTurret;
};
// TODO: move these to a different HUD addon
// commanderCanSee = 2+32;
// gunnerCanSee = 2+32;
// driverCanSee = 2+32;
};
class Helicopter_Base_F: Helicopter {
class Turrets: Turrets {
class MainTurret: MainTurret {};
};
};
class Heli_Attack_01_base_F: Helicopter_Base_F {
class Turrets: Turrets {
class MainTurret: MainTurret {};
};
};
class B_Heli_Attack_01_F: Heli_Attack_01_base_F {
class Turrets: Turrets {
class MainTurret: MainTurret {
stabilizedInAxes = 4; // This stablizes the turret a bit more for laser designation
};
};
};
};

View File

@ -0,0 +1,10 @@
class CfgWeapons {
class LauncherCore;
class RocketPods: LauncherCore {
canLock = 1; // Disable locking unless newb mode
};
class missiles_DAGR: RocketPods {
canLock = 1; // Disable locking unless newb mode
};
};

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
NO_DEDICATED;

View File

@ -0,0 +1,12 @@
#include "script_component.hpp"
PREP(onGetIn);
PREP(onGetOut);
PREP(laserHudDesignateOn);
PREP(laserHudDesignateOff);
GVAR(laser) = nil;
GVAR(laserActive) = false;
FUNC(getPosASL) = {visiblePositionASL (_this select 0)};

View File

@ -0,0 +1,17 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = { "ace_main", "ace_laser" };
version = VERSION;
};
};
#include "CfgUI.hpp"
#include "CfgEventhandlers.hpp"
#include "CfgWeapons.hpp"
#include "CfgVehicles.hpp"

View File

@ -0,0 +1,20 @@
#include "script_component.hpp"
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(laserActive) = false;
true

View File

@ -0,0 +1,90 @@
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
TRACE_1("enter", _this);
FUNC(magnitude) = {
_this distance [0, 0, 0]
};
FUNC(mat_normalize3d) = {
private ["_mag"];
PARAMS_3(_vx,_vy,_vz);
_mag = _this call FUNC(magnitude);
if (_mag == 0) then {_mag = 1};
[(_vx/_mag), (_vy/_mag), (_vz/_mag)]
};
FUNC(laserHudDesignatePFH) = {
_args = _this select 0;
_laserTarget = _args select 0;
_shooter = _args select 1;
_vehicle = vehicle _shooter;
_weapon = currentWeapon _vehicle;
if(!alive _shooter || isNull _vehicle || isNull _laserTarget || !GVAR(laserActive) ) exitWith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
// Retrieve the gunner and turret memory point information
_gunnerInfo = [_vehicle, _weapon] call CBA_fnc_getFirer;
_turret = [_vehicle, _gunnerInfo select 1] call CBA_fnc_getTurret;
_pov = getText (_turret >> "memoryPointGunnerOptics");
_gunBeg = getText (_turret >> "gunBeg");
_gunEnd = getText (_turret >> "gunEnd");
TRACE_3("", _pov, _gunBeg, _gunEnd);
// Pull the PIP pov or barrel direction, depending on how the model is set up
_povPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _pov ) );
_povDir = [0,0,0];
if(_pov == "pip0_pos") then {
_pipDir = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition "pip0_dir" ) );
_povDir = [_povPos, _pipDir] call BIS_fnc_vectorDiff;
} else {
_gunBeginPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunBeg ) );
_gunEndPos = ATLtoASL ( _vehicle modelToWorld (_vehicle selectionPosition _gunEnd ) );
_povDir = [_gunEndPos, _gunBeginPos] call BIS_fnc_vectorDiff;
};
TRACE_4("", _povDir, _povPos, _gunBeginPos, _gunEndPos);
_result = [_povPos, _povDir] call EFUNC(laser,shootCone);
if((count _result) > 0) then {
_resultPositions = _result select 2;
if((count _resultPositions) > 0) then {
_firstResult = _resultPositions select 0;
_pos = _firstResult select 0;
// 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.
//if( ((getPosASL _laserTarget) distance _pos) > 0.5) then {
_laserTarget setPosATL (ASLToATL _pos);
//};
#ifdef DEBUG_MODE_FULL
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,1], ASLToATL _pos, 0.75, 0.75, 0, "", 0.5, 0.025, "TahomaB"];
#endif
};
};
};
if(isNil QGVAR(laser)) then {
_laserTarget = "LaserTarget" createVehicle (getpos player);
GVAR(laserActive) = true;
_handle = [FUNC(laserHudDesignatePFH), 0, [_laserTarget, player]] call cba_fnc_addPerFrameHandler;
_laserTarget setVariable ["ACE_PFH_HANDLE", _handle, false];
GVAR(laser) = _laserTarget;
} else {
[] call FUNC(laserHudDesignateOff);
[] call FUNC(laserHudDesignateOn);
};

View File

@ -0,0 +1,13 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
// TODO: we should do this differently eventually
private["_onActionId", "_offActionId"];
TRACE_1("ENTER", _this);
// TODO: THIS SHOULD NOT BE ACTIONS EVENTUALLY
_onActionId = player addAction ["Laser Designator On", { _this call FUNC(laserHudDesignateOn) }, [], 1, false, false, "", QUOTE( (gunner (vehicle player)) == player && !GVAR(laserActive))];
player setVariable[QGVAR(onActionId), _onActionId, false];
_offActionId = player addAction ["Laser Designator Off", { _this call FUNC(laserHudDesignateOff) }, [], 1, false, false, "", QUOTE( (gunner (vehicle player)) == player && GVAR(laserActive))];
player setVariable[QGVAR(offActionId), _offActionId, false];

View File

@ -0,0 +1,10 @@
#include "script_component.hpp"
_onActionId = player getVariable[QGVAR(onActionId), -1];
_offActionId = player getVariable[QGVAR(offActionId), -1];
player removeAction _onActionId;
player removeAction _offActionId;
player setVariable[QGVAR(onActionId), -1, false];
player setVariable[QGVAR(offActionId), -1, false];

View File

@ -0,0 +1 @@
#include "\z\ace\Addons\laser_selfdesignate\script_component.hpp"

View File

@ -0,0 +1,12 @@
#define COMPONENT laser_selfdesignate
#include "\z\ace\Addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_LASER_SELFDESIGNATE
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_LASER_SELFDESIGNATE
#define DEBUG_SETTINGS DEBUG_SETTINGS_LASER_SELFDESIGNATE
#endif
#include "\z\ace\Addons\main\script_macros.hpp"

View File

@ -6,6 +6,6 @@ PARAMS_7(_shooter,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile);
if(!local _shooter) exitWith { false };
if(_weapon == "missiles_DAGR") then {
//_this call FUNC(guidance_DAGR);
_this call FUNC(guidance_HellfireII);
_this call FUNC(guidance_DAGR);
//_this call FUNC(guidance_HellfireII);
};