diff --git a/addons/clgp/CfgAmmo.hpp b/addons/clgp/CfgAmmo.hpp index 909065e32a..9d48a150bf 100644 --- a/addons/clgp/CfgAmmo.hpp +++ b/addons/clgp/CfgAmmo.hpp @@ -6,7 +6,7 @@ class CfgAmmo { indirectHit = 200; indirectHitRange = 4; - GVAR(deployApplyDrag) = 1; + GVAR(artilleryDrag) = 1; GVAR(deployCondition) = QFUNC(copperhead_deployCondition); submunitionAmmo = "ace_155mm_m712_guidance"; submunitionCount = 1; @@ -99,7 +99,6 @@ class CfgAmmo { class Eventhandlers { fired = QUOTE(call FUNC(submunition_ammoFired)); }; - GVAR(deployApplyDrag) = -1; }; class MissileBase; diff --git a/addons/clgp/XEH_postInit.sqf b/addons/clgp/XEH_postInit.sqf index a98d308009..f298803b66 100644 --- a/addons/clgp/XEH_postInit.sqf +++ b/addons/clgp/XEH_postInit.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" -// Add shell config action to vehicles that can fire it +// Copperhead - Add shell interface action to vehicles that can fire it if (hasInterface) then { ["turret", { params ["_player", "_turret"]; @@ -10,9 +10,9 @@ if (hasInterface) then { if ((!alive _player) || {!alive _vehicle} || {_vehicle getVariable [QGVAR(actionsAdded), false]}) exitWith {}; _vehicle setVariable [QGVAR(actionsAdded), true]; - - if (((_vehicle weaponsTurret [0]) findIf {"ace_1rnd_155mm_m712" in (compatibleMagazines _x)}) != -1) then { - TRACE_2("adding copperhead action to object",_vehicle,typeOf _vehicle); + private _copperheadMag = ["ace_1rnd_155mm_m712"] call EFUNC(common,getConfigName); + if (((_vehicle weaponsTurret [0]) findIf {_copperheadMag in (compatibleMagazines _x)}) != -1) then { + TRACE_2("adding copperhead action to vehicle",_vehicle,typeOf _vehicle); private _action = [QGVAR(copperhead), LLSTRING(copperhead_action), "", LINKFUNC(copperhead_uiCreate), LINKFUNC(copperhead_uiCanOpen)] call EFUNC(interact_menu,createAction); [_vehicle, 1, ["ACE_SelfActions"], _action] call EFUNC(interact_menu,addActionToObject); }; diff --git a/addons/clgp/functions/fnc_submunition_ammoFired.sqf b/addons/clgp/functions/fnc_submunition_ammoFired.sqf index 04c9c9ea24..d7ea236589 100644 --- a/addons/clgp/functions/fnc_submunition_ammoFired.sqf +++ b/addons/clgp/functions/fnc_submunition_ammoFired.sqf @@ -1,7 +1,7 @@ #include "..\script_component.hpp" /* * Author: PabstMirror - * Generic handler for firing a clgp submuntion ammo + * Generic handler for firing a clgp submuntion ammo. Called from the ammo's fired EH. * * Arguments: * FiredEH diff --git a/addons/clgp/functions/fnc_submunition_submunitionCreated.sqf b/addons/clgp/functions/fnc_submunition_submunitionCreated.sqf index 7fc81593b5..1550b66957 100644 --- a/addons/clgp/functions/fnc_submunition_submunitionCreated.sqf +++ b/addons/clgp/functions/fnc_submunition_submunitionCreated.sqf @@ -30,18 +30,19 @@ if (_guidanceArgs isNotEqualTo []) then { // Inject the submunition projectile a [EFUNC(missileguidance,guidancePFH), 0, _guidanceArgs] call CBA_fnc_addPerFrameHandler; }; +// NOTE: Probably need to remove after frag-rewrite if (!isNil QEFUNC(frag,addPfhRound)) then { // todo make frag work for original and sub TRACE_1("-Starting frag track",_submunitionProjectile); [_firedEH # 0, _firedEH # 4, _submunitionProjectile] call EFUNC(frag,addPfhRound); }; -// if negative then ignore, any other value is a coefficent -private _deployApplyDrag = getNumber ((configOf _projectile) >> QGVAR(deployApplyDrag)); -TRACE_1("",_deployApplyDrag); -if (_deployApplyDrag >= 0) then { +private _deployArtilleryDragConfig = (configOf _projectile) >> QGVAR(artilleryDrag); +if (isNumber _deployArtilleryDragConfig) then { + private _deployArtilleryDrag = getNumber _deployArtilleryDragConfig; + if (_deployArtilleryDrag < 0) exitWith { TRACE_1("-Ignoring Drag",_deployArtilleryDrag); }; private _kFactor = _projectile getVariable [QEGVAR(artillerytables,kFactor), 0]; - _kFactor = _kFactor * _deployApplyDrag; // maybe be 0 from either source - TRACE_3("-Applying Drag",_submunitionProjectile,_deployApplyDrag,_kFactor); + TRACE_2("-Drag",_deployArtilleryDrag,_kFactor); + _kFactor = _kFactor * _deployArtilleryDrag; // Can be 0 from either source (0 is valid and will keep nose pointed) private _dragArray = [_submunitionProjectile, _kFactor, CBA_missionTime]; _submunitionProjectile setVariable [QGVAR(dragArray), _dragArray]; }; diff --git a/docs/wiki/framework/clgp-framework.md b/docs/wiki/framework/clgp-framework.md new file mode 100644 index 0000000000..91c4f579c3 --- /dev/null +++ b/docs/wiki/framework/clgp-framework.md @@ -0,0 +1,56 @@ +--- +layout: wiki +title: CLGP Framework +description: Explains how to set-up ammo for the cannon-launched-guided-projectile system. +group: framework +parent: wiki +order: 7 +mod: ace +version: + major: 3 + minor: 0 + patch: 0 +--- + +## 1. Overview + +CLGP allows firing submunition shells that will deploy into missiles that can use the Missile Guidance framework. + +## 2. Config Values + +### 2.1 Example Config +```cpp +class CfgAmmo { + class x_submunition: SubmunitionBase { // this ammo can be fired normally + ace_clgp_deployCondition = "your_fnc"; // function that returns true when it should be triggered + ace_clgp_artilleryDrag = 1; + submunitionAmmo = "x_missle"; + class Eventhandlers { + fired = "call ace_clgp_fnc_submunition_ammoFired"; // need to add the EH yourself to all ammos + }; + }; + + class x_missle: MissileBase { + class ace_missileguidance { + enabled = 2; + // rest of normal ace missile guidance config +``` + +### 2.2 Configs + +`ace_clgp_deployCondition` +- A function that will trigger the ammo when returning true, passed `[_projectile, _guidanceArgs]` +- Is optional, can just use normal submuntion triggers + +`ace_clgp_artilleryDrag` +- Optional (Leave undefined (or set to -1) to ignore) +- Used as a coefficient on drag from ace_artilleryTables's advancedCorrections +- Value of 0 is valid and will not apply drag but still keep nose pointed correctly (for unpowered missiles) + +## 3. Note on adding magazines via mission + +```cpp +if (local turretLocal [0]) then { + this addMagazineTurret ["ace_1rnd_155mm_m712", [0]]; +}; +```