Skip to content

Commit

Permalink
Sight attach/detach on same vehicle
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Feb 3, 2019
1 parent 5c21a60 commit e074e55
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 128 deletions.
8 changes: 3 additions & 5 deletions addons/dragon/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ class Extended_PreInit_EventHandlers {
};
};

class Extended_Init_EventHandlers {
class GVAR(super_noSight) {
class lock {
init = QUOTE((_this select 0) lock true);
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
121 changes: 35 additions & 86 deletions addons/dragon/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
class MainTurret;
class CfgVehicles {
class LandVehicle;

class StaticWeapon : LandVehicle {
class Turrets {
class MainTurret;
};
};

class StaticMGWeapon: StaticWeapon{
class Turrets : Turrets {
class MainTurret : MainTurret {
class ViewOptics;
};
class StaticWeapon: LandVehicle {
class Turrets;
class MainTurret;
class ACE_Actions {
class ACE_MainActions {};
};
};

class GVAR(dragonStaticBase) : StaticMGWeapon {
class StaticATWeapon: StaticWeapon {};

class GVAR(staticBase): StaticATWeapon {
scope = 1;
displayName = CSTRING(dragonName);
author = ECSTRING(common,ACETeam);
displayname = CSTRING(dragonName);
side = 1;
faction = "BLU_F";
crew = "B_soldier_f";
model = QPATHTOF(models\ace_m47_static.p3d);
picture = "\A3\Static_F_Gamma\data\UI\gear_StaticTurret_AT_CA.paa";
UiPicture = "\A3\Static_F_Gamma\data\UI\gear_StaticTurret_AT_CA.paa";
Expand Down Expand Up @@ -47,32 +45,21 @@ class CfgVehicles {
optics = 1;
turretInfoType = "RscWeaponEmpty";
gunnerOpticsModel = QPATHTOF(models\optics_m47.p3d);
minElev = -60;
maxElev = 0;
weapons[] = {};
magazines[] = {};
minElev = -30;
maxElev = 20;
weapons[] = { QGVAR(dummyStatic) };
magazines[] = { QGVAR(super) };

gunnerAction = "gunner_static_low01";
gunnergetInAction = "";
gunnergetOutAction = "";

discreteDistance[] = {};
discreteDistanceInitIndex = 0;

class OpticsIn {
class Wide: ViewOptics {
initFov = 0.055;
minFov = 0.055; // 6 degree FOV
maxFov = 0.055;
gunnerOpticsModel = QPATHTOF(models\optics_m47.p3d);
gunnerOutOpticsModel = "\A3\weapons_f\reticle\optics_empty";
gunnerOpticsEffect[] = {"TankGunnerOptics1","OpticsBlur2","OpticsCHAbera2"};
};
};


displayName = CSTRING(dragonName);
class ViewOptics: ViewOptics {

class ViewOptics {
initAngleX = 0;
minAngleX = -30;
maxAngleX = 30;
Expand Down Expand Up @@ -118,83 +105,45 @@ class CfgVehicles {
soundGetOut[] = {"A3\sounds_f\dummysound",0.001,1,5};
soundGetIn[] = {"A3\sounds_f\dummysound",0.00031622776,1,5};
armorStructural = 10.0;
hiddenSelections[] = {"camo_launcher","camo_tube"};
};

class GVAR(super_noSight) : GVAR(dragonStaticBase) {
scope = 1;
author = ECSTRING(common,ACETeam);
displayname = CSTRING(dragonNoSight);
side = 1;
faction = "BLU_F";
crew = "B_soldier_f";
hiddenSelectionsTextures[] = {"\a3\weapons_f_beta\launchers\titan\data\launcher_co.paa","\a3\weapons_f_beta\launchers\titan\data\tubem_co.paa"};

class Turrets: Turrets {
class MainTurret: MainTurret {
class OpticsIn {
class Wide: ViewOptics {
gunnerOpticsModel = "";
};
};
};
};

class ACE_CSW {
disassembleTo = QGVAR(super);
};

class ACE_Actions {
class ACE_MainActions {
class ACE_Actions: ACE_Actions {
class ACE_MainActions: ACE_MainActions {
displayName = CSTRING(dragonName);
selection = "";
distance = 2;
condition = "true";
class GVAR(pickUp) {
displayName = ECSTRING(csw,Pickup_displayName);
condition = QUOTE(call FUNC(canPickupTripod));
statement = QUOTE(call EFUNC(csw,assemble_pickupTripod));
};
class GVAR(mountWeapon) {
class GVAR(attachSight) {
displayName = CSTRING(attachSight);
condition = QUOTE(call FUNC(canDeployWeapon));
statement = QUOTE([ARR_4(_this select 0, _this select 1, [], binocular (_this select 1))] call EFUNC(csw,assemble_deployWeapon));
condition = QUOTE(call FUNC(sightCanAttach));
statement = QUOTE(call FUNC(sightAttach));
};
class GVAR(detachSight) {
displayName = CSTRING(detachSight);
condition = QUOTE(call FUNC(sightCanDetach));
statement = QUOTE(call FUNC(sightDetach));
};
};
};

};

class GVAR(super_sight) : GVAR(dragonStaticBase) {
class GVAR(staticAssembled): GVAR(staticBase) {
scope = 2;
author = ECSTRING(common,ACETeam);
displayname = CSTRING(dragonSight);
side = 1;
faction = "BLU_F";
crew = "B_soldier_f";
hiddenSelectionsTextures[] = {"\a3\weapons_f_beta\launchers\titan\data\launcher_co.paa","\a3\weapons_f_beta\launchers\titan\data\tubem_co.paa"};

class AnimationSources: AnimationSources {
class optic_hide: optic_hide {
initPhase = 0;
};
};

class ACE_CSW {
enabled = 1;
disassembleFunc = QFUNC(onDisassemble);
disassembleWeapon = QGVAR(sight);
disassembleTurret = QGVAR(super_noSight);
desiredAmmo = 1;
ammoLoadTime = -1;
ammoUnloadTime = -1;
};

class Turrets: Turrets {
class MainTurret: MainTurret {
optics = 1;
weapons[] = { QGVAR(superStatic) };
magazines[] = { QGVAR(super) };
};
};
};
};
};
19 changes: 16 additions & 3 deletions addons/dragon/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class CfgWeapons {
class Launcher_Base_F;
class missiles_titan;
class Binocular;
class Default;
class missiles_titan_static: missiles_titan {
class WeaponSlotsInfo;
};
Expand All @@ -22,15 +23,15 @@ class CfgWeapons {
type = "mount";
deployTime = 2;
pickupTime = 2;
deploy = QGVAR(super_noSight);
deploy = QGVAR(staticBase);
};

class WeaponSlotsInfo: WeaponSlotsInfo {
mass = 253;
};
modes[] = {};
};

class GVAR(superStatic): missiles_titan_static {
EGVAR(overpressure,angle) = 90;
EGVAR(overpressure,range) = 30;
Expand All @@ -41,6 +42,18 @@ class CfgWeapons {
displayName = CSTRING(dragonName);
descriptionShort = CSTRING(dragonDescription);
magazines[] = { QGVAR(super) };
};

// need a weapon in order to rotate turret
class GVAR(dummyStatic): Default {
cursor = "";
cursorAim = "";
scope = 1;
displayName = CSTRING(dragonName);
reloadTime = 0;
canLock = 0;
optics = 0;
enableAttack = 0;
};

class GVAR(sight): Binocular {
Expand Down Expand Up @@ -74,4 +87,4 @@ class CfgWeapons {
mass = 68;
};
};
};
};
6 changes: 4 additions & 2 deletions addons/dragon/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
PREP(attackProfile_DRAGON);
PREP(canPickupTripod);
PREP(onFired);
PREP(onDisassemble);
PREP(canDeployWeapon);
PREP(sightAttach);
PREP(sightCanAttach);
PREP(sightCanDetach);
PREP(sightDetach);
41 changes: 41 additions & 0 deletions addons/dragon/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "script_component.hpp"

[QGVAR(detachSight), LINKFUNC(sightDetach)] call CBA_fnc_addEventHandler;
[QGVAR(attachSight), LINKFUNC(sightAttach)] call CBA_fnc_addEventHandler;

["vehicle", {
params ["","_vehicle"];
TRACE_2("vehicle change",_vehicle,typeOf _vehicle);
if (!(_vehicle isKindOf QGVAR(staticBase))) exitWith {};

_vehicle animate ["rest_rotate", 0];

if (isNil QGVAR(pfID)) then {GVAR(pfID) = -1};
[GVAR(pfID)] call CBA_fnc_removePerFrameHandler;

private _lastView = cameraView;
if (!(_lastView in ["INTERNAL", "EXTERNAL"])) then { _lastView == "INTERNAL"; };

GVAR(pfID) = [{
params ["_args"];
(_this select 0) params ["_vehicle", "_lastView"];

if ((!alive _vehicle) || {!alive ACE_player} || {(vehicle ACE_player) != _vehicle}) exitWith {
TRACE_1("exiting PFEH",GVAR(pfID));
[GVAR(pfID)] call CBA_fnc_removePerFrameHandler;
if ((!isNull _vehicle) && {!alive (gunner _vehicle)}) then {
TRACE_1("reseting rest anim",gunner _vehicle);
_vehicle animate ["rest_rotate", -0.35];
};
};

if (cameraView in ["INTERNAL", "EXTERNAL"]) then {
_args set [1, cameraView];
} else {
if ((cameraOn == _vehicle) && {!(_vehicle getVariable [QGVAR(sightAttached), ((typeOf _vehicle) == QGVAR(staticAssembled))])}) then {
_vehicle switchCamera _lastView;
};
};
}, 0, [_vehicle, _lastView]] call CBA_fnc_addPerFrameHandler;
TRACE_1("started PFEH",GVAR(pfID));
}, true] call CBA_fnc_addPlayerEventHandler;
7 changes: 6 additions & 1 deletion addons/dragon/functions/fnc_canPickupTripod.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
* Public: No
*/
params ["_target", "_unit"];
!(_target getVariable [QGVAR(fired), false]) && { [_target, _unit] call EFUNC(csw,assemble_canPickupTripod) }

(alive _target)
&& {!alive (gunner _target)}
&& {!(_target getVariable [QGVAR(fired), false])}
&& {!(_target getVariable [QGVAR(sightAttached), ((typeOf _target) == QGVAR(staticAssembled))])}
&& EFUNC(csw,assemble_canPickupTripod)

24 changes: 0 additions & 24 deletions addons/dragon/functions/fnc_onDisassemble.sqf

This file was deleted.

32 changes: 32 additions & 0 deletions addons/dragon/functions/fnc_sightAttach.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Attaches the sighting unit to the Dragon missile.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Unit Performing Action <OBJECT>
*
* Return Value:
* Can Attach Sighting Unit <BOOL>
*
* Example:
* [cursorObject, player] call ace_dragon_fnc_sightAttach
*
* Public: No
*/

params ["_target", "_unit", ["_event", false]];
TRACE_3("sightAttach",_target,_unit,_event);

if (_event isEqualTo true) then {
if (!(_target turretLocal [0])) exitWith {};
_target setVariable [QGVAR(sightAttached), true, true];
_target animate ["optic_hide", 0];
_target addWeapon QGVAR(superStatic);
_target removeWeapon QGVAR(dummyStatic);
TRACE_2("added sight",_target weaponsTurret [0],_target animationPhase "optic_hide");
} else {
_unit removeWeapon QGVAR(sight);
[QGVAR(attachSight), [_target, _unit, true]] call CBA_fnc_globalEvent;
};
24 changes: 24 additions & 0 deletions addons/dragon/functions/fnc_sightCanAttach.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Determines if you can attach the sighting unit to the Dragon missile.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Unit Performing Action <OBJECT>
*
* Return Value:
* Can Attach Sighting Unit <BOOL>
*
* Example:
* [cursorObject, player] call ace_dragon_fnc_sightCanAttach
*
* Public: No
*/

params ["_target", "_unit"];

(alive _target)
// && {!(_target getVariable [QGVAR(fired), false])}
&& {!(_target getVariable [QGVAR(sightAttached), ((typeOf _target) == QGVAR(staticAssembled))])}
&& {QGVAR(sight) in (weapons _unit)}
Loading

0 comments on commit e074e55

Please sign in to comment.