Merge pull request #6955 from acemod/cbaDisposable

Disposable - switch NLAW to CBA disposable system and remove ace_disposable functionality
This commit is contained in:
commy2 2019-10-17 20:57:14 +02:00 committed by GitHub
commit 2a6d555091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 74 additions and 452 deletions

View File

@ -1,33 +0,0 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
class Extended_DisplayLoad_EventHandlers {
class RscDisplayInventory {
ADDON = QUOTE([ARR_2(ACE_player, _this select 0)] call FUNC(updateInventoryDisplay));
};
};
// handle preloaded missile
class Extended_InitPost_EventHandlers {
class CAManBase {
class ADDON {
init = QUOTE([_this select 0] call FUNC(takeLoadedATWeapon));
};
};
};

View File

@ -1,15 +0,0 @@
class CfgMagazines {
class NLAW_F;
class ACE_PreloadedMissileDummy: NLAW_F { // The dummy magazine
author = ECSTRING(common,ACETeam);
scope = 1;
scopeArsenal = 1;
displayName = CSTRING(PreloadedMissileDummy);
picture = "\a3\ui_f\data\IGUI\Cfg\Targeting\Empty_ca.paa";
weaponPoolAvailable = 0;
mass = 0;
};
class ACE_FiredMissileDummy: ACE_PreloadedMissileDummy {
count = 0;
};
};

View File

@ -1,146 +1,8 @@
class CfgVehicles {
#define MACRO_NONLAW \
class TransportMagazines { \
class _xx_NLAW_F { \
count = 0; \
}; \
class Launcher_Base_F;
class Weapon_launch_NLAW_F: Launcher_Base_F {
class TransportMagazines {
delete NLAW_F;
};
class ReammoBox_F;
class NATO_Box_Base: ReammoBox_F {};
class Box_NATO_Ammo_F: NATO_Box_Base {
MACRO_NONLAW
};
class Box_NATO_WpsLaunch_F: NATO_Box_Base {
MACRO_NONLAW
};
class IND_Box_Base: ReammoBox_F {};
class Box_IND_WpsLaunch_F: IND_Box_Base {
MACRO_NONLAW
};
class Box_IND_Ammo_F: IND_Box_Base {
MACRO_NONLAW
};
class B_supplyCrate_F: ReammoBox_F {
MACRO_NONLAW
};
class I_supplyCrate_F: B_supplyCrate_F {
MACRO_NONLAW
};
class C_supplyCrate_F: ReammoBox_F {
MACRO_NONLAW
};
class B_AssaultPack_rgr;
class B_AssaultPack_rgr_LAT: B_AssaultPack_rgr {
MACRO_NONLAW
};
class B_AssaultPack_rgr_ReconLAT: B_AssaultPack_rgr {
MACRO_NONLAW
};
class B_Carryall_mcamo;
class B_AssaultPack_mcamo_Ammo: B_Carryall_mcamo {
MACRO_NONLAW
};
class B_Carryall_oli;
class I_Fieldpack_oli_Ammo: B_Carryall_oli {
MACRO_NONLAW
};
class B_AssaultPack_dgtl;
class I_Fieldpack_oli_LAT: B_AssaultPack_dgtl {
MACRO_NONLAW
};
class CargoNet_01_ammo_base_F;
class B_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F {
MACRO_NONLAW
};
class I_CargoNet_01_ammo_F: CargoNet_01_ammo_base_F {
MACRO_NONLAW
};
class Slingload_01_Base_F;
class B_Slingload_01_Cargo_F: Slingload_01_Base_F {
MACRO_NONLAW
};
class Tank_F;
class APC_Tracked_01_base_F: Tank_F {
MACRO_NONLAW
};
/*class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_rcws_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};
class B_APC_Tracked_01_AA_F: B_APC_Tracked_01_base_F {
MACRO_NONLAW
};*/
class Car_F;
class MRAP_01_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_01_gmg_base_F: MRAP_01_base_F {
MACRO_NONLAW
};
class MRAP_01_hmg_base_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_F: MRAP_01_base_F {
MACRO_NONLAW
};
class B_MRAP_01_gmg_F: MRAP_01_gmg_base_F {
MACRO_NONLAW
};
class B_MRAP_01_hmg_F: MRAP_01_hmg_base_F {
MACRO_NONLAW
};*/
class MRAP_03_base_F: Car_F {
MACRO_NONLAW
};
/*class MRAP_03_hmg_base_F: MRAP_03_base_F {
MACRO_NONLAW
};
class MRAP_03_gmg_base_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_F: MRAP_03_base_F {
MACRO_NONLAW
};
class I_MRAP_03_hmg_F: MRAP_03_hmg_base_F {
MACRO_NONLAW
};
class I_MRAP_03_gmg_F: MRAP_03_gmg_base_F {
MACRO_NONLAW
};*/
class Wheeled_APC_F: Car_F {};
class APC_Wheeled_03_base_F: Wheeled_APC_F {
MACRO_NONLAW
};
class APC_Wheeled_01_base_F: Wheeled_APC_F {
MACRO_NONLAW
};
/*class B_APC_Wheeled_01_base_F: APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class B_APC_Wheeled_01_cannon_F: B_APC_Wheeled_01_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_base_F: APC_Wheeled_03_base_F {
MACRO_NONLAW
};
class I_APC_Wheeled_03_cannon_F: I_APC_Wheeled_03_base_F {
MACRO_NONLAW
};*/
};

View File

@ -1,19 +1,52 @@
class CfgWeapons {
class Launcher_Base_F;
class launch_NLAW_F: Launcher_Base_F {
ACE_UsedTube = "ACE_launch_NLAW_Used_F"; // The class name of the used tube.
magazines[] = {"ACE_PreloadedMissileDummy"}; // The dummy magazine
class Launcher;
class Launcher_Base_F: Launcher {
class WeaponSlotsInfo;
};
class ACE_launch_NLAW_Used_F: launch_NLAW_F { // the used tube should be a sub class of the disposable launcher
EGVAR(nlaw,enabled) = 0; // disable guidance for the disposabled tube
scope = 1;
ACE_isUsedLauncher = 1;
class launch_NLAW_F: Launcher_Base_F {
scope = 2;
scopeArsenal = 2;
baseWeapon = "launch_NLAW_F";
magazines[] = {"CBA_FakeLauncherMagazine"};
magazineReloadTime = 0.1;
reloadMagazineSound[] = {"",1,1};
class WeaponSlotsInfo: WeaponSlotsInfo {
mass = 180; // launcher 100, magazine 80
};
};
class ACE_launch_NLAW_ready_F: launch_NLAW_F {
author = ECSTRING(common,ACETeam);
scope = 1;
scopeArsenal = 1;
baseWeapon = "launch_NLAW_F";
magazines[] = {"NLAW_F"};
class EventHandlers {
fired = "_this call CBA_fnc_firedDisposable"; // this weapon eventhandler is required!
};
class WeaponSlotsInfo: WeaponSlotsInfo {
mass = 100;
};
};
class ACE_launch_NLAW_used_F: launch_NLAW_F {
author = ECSTRING(common,ACETeam);
scope = 1;
scopeArsenal = 1;
baseWeapon = "ACE_launch_NLAW_used_F";
displayName = CSTRING(UsedTube);
descriptionShort = CSTRING(UsedTubeDescription);
magazines[] = {"ACE_FiredMissileDummy"}; // This will disable the used launcher class from being fired again.
//picture = ""; @todo
//model = ""; @todo
weaponPoolAvailable = 0;
class WeaponSlotsInfo: WeaponSlotsInfo {
mass = 100;
};
};
};

View File

@ -1,7 +1,7 @@
ace_disposable
==============
Makes the NLAW a disposable one-shot weapon and provides disposable launchers framework for use by other mods.
Makes the NLAW a disposable one-shot weapon using the [CBA Disposable Framework](https://github.com/CBATeam/CBA_A3/wiki/Disposable-Launchers).
## Maintainers

View File

@ -1,4 +0,0 @@
PREP(replaceATWeapon);
PREP(takeLoadedATWeapon);
PREP(updateInventoryDisplay);

View File

@ -1,15 +0,0 @@
// by commy2
#include "script_component.hpp"
if (!hasInterface) exitWith {};
["loadout", {
params ["_unit"];
[_unit] call FUNC(takeLoadedATWeapon);
[_unit] call FUNC(updateInventoryDisplay);
}] call CBA_fnc_addPlayerEventHandler;
// Register fire event handler
// Only for the local player and for AI. Non-local players will handle it themselves
["ace_firedPlayer", DFUNC(replaceATWeapon)] call CBA_fnc_addEventHandler;
["ace_firedNonPlayer", DFUNC(replaceATWeapon)] call CBA_fnc_addEventHandler;

View File

@ -1,9 +0,0 @@
#include "script_component.hpp"
ADDON = false;
PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
ADDON = true;

View File

@ -1,14 +0,0 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"
// Show warning for launchers still using disposables
{
private _nonInheritedCfg = configProperties [_x, "configName _x == 'ACE_UsedTube'", false];
if ((count _nonInheritedCfg) == 1) then {
private _weapon = configName _x;
if (_weapon != "launch_NLAW_F") then { // ignore the one we modifiy ourselves
WARNING_1("[%1] ACE_disposables functionality will be removed in a future version - switch to CBA Disposables",_weapon);
};
};
} forEach ("isText (_x >> 'ACE_UsedTube')" configClasses (configFile >> "CfgWeapons"));

View File

@ -4,7 +4,7 @@ class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
weapons[] = {"ACE_launch_NLAW_loaded_F","ACE_launch_NLAW_used_F"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
author = ECSTRING(common,ACETeam);
@ -14,7 +14,9 @@ class CfgPatches {
};
};
#include "CfgEventHandlers.hpp"
class CBA_DisposableLaunchers {
ACE_launch_NLAW_ready_F[] = {"launch_NLAW_F","ACE_launch_NLAW_used_F"};
};
#include "CfgWeapons.hpp"
#include "CfgMagazines.hpp"
#include "CfgVehicles.hpp"

View File

@ -1,69 +0,0 @@
#include "script_component.hpp"
/*
* Author: bux, commy2
* Replace the disposable launcher with the used dummy. Called from the unified fired EH.
*
* Arguments:
* None. Parameters inherited from EFUNC(common,firedEH)
*
* Return Value:
* None
*
* Example:
* [fromBisFiredEH] call ace_disposable_fnc_replaceATWeapon;
*
* Public: No
*/
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
if (!local _unit || {_weapon != secondaryWeapon _unit} || {_weapon != _muzzle}) exitWith {};
private _replacementTube = getText (configFile >> "CfgWeapons" >> _weapon >> "ACE_UsedTube");
if (_replacementTube == "") exitWith {}; //If no replacement defined just exit
// Save magazine of spotting muzzle (should be re-added to replacement weapon)
(((getUnitLoadout _unit) select 1) select 5) params [["_spottingMag", ""], ["_spottingRnds", 0]];
if (_spottingMag != "") then { _unit addMagazine [_spottingMag, _spottingRnds]; };
//Save array of items attached to launcher
private _items = secondaryWeaponItems _unit;
//Replace the orginal weapon with the 'usedTube' weapon
_unit addWeapon _replacementTube;
//Makes sure the used tube is still equiped
_unit selectWeapon _replacementTube;
//Re-add all attachments to the used tube
{
if (_x != "") then {_unit addSecondaryWeaponItem _x};
} count _items;
// AI - Remove the ai's missle launcher tube after the missle has exploded
if !([_unit] call EFUNC(common,isPlayer)) then {
[{
params ["_args","_idPFH"];
_args params ["_unit", "_tube", "_projectile"];
//don't do anything until projectile is null (exploded/max range)
if (isNull _projectile) then {
//Remove PFEH:
[_idPFH] call CBA_fnc_removePerFrameHandler;
//If (tube is dropped) OR (is dead) OR (is player) just exit
if (secondaryWeapon _unit != _tube || {!alive _unit} || {[_unit] call EFUNC(common,isPlayer)}) exitWith {};
//private _items = secondaryWeaponItems _unit;
private _container = createVehicle ["GroundWeaponHolder", position _unit, [], 0, "CAN_COLLIDE"];
_container setPosAsl (getPosAsl _unit);
_container addWeaponCargoGlobal [_tube, 1];
//This will duplicate attachements, because we will be adding a weapon that may already have attachments on it
//We either need a way to add a clean weapon, or a way to add a fully configured weapon to a container:
// {
// if (_x != "") then {_container addItemCargoGlobal [_x, 1];};
// } forEach _items;
_unit removeWeaponGlobal _tube;
};
}, 1, [_unit, _replacementTube, _projectile]] call CBA_fnc_addPerFrameHandler;
};

View File

@ -1,59 +0,0 @@
#include "script_component.hpp"
/*
* Author: commy2
* Handle the take event. Add a dummy magazine if a disposable rocket launcher is taken.
*
* Arguments:
* 0: unit - Object the event handler is assigned to <OBJECT>
*
* Return Value:
* None
*
* Example:
* [fromTakeEH] call ace_disposable_fnc_takeLoadedATWeapon;
*
* Public: No
*/
params ["_unit"];
TRACE_1("params",_unit);
if (!local _unit) exitWith {};
private _launcher = secondaryWeapon _unit;
private _config = configFile >> "CfgWeapons" >> _launcher;
if (isClass _config && {getText (_config >> "ACE_UsedTube") != ""} && {getNumber (_config >> "ACE_isUsedLauncher") != 1} && {count secondaryWeaponMagazine _unit == 0}) then {
private _magazine = getArray (_config >> "magazines") select 0;
private _isLauncherSelected = currentWeapon _unit == _launcher;
_unit removeMagazines _magazine;
if (backpack _unit == "") then {
_unit addBackpack "ACE_FakeBackpack";
_unit removeWeapon _launcher;
_unit addMagazine _magazine;
private _didAdd = _magazine in magazines _unit;
_unit addWeapon _launcher;
if (!_didAdd) then {
TRACE_1("Failed To Add Disposable Magazine Normally, doing backup method (no backpack)",_unit);
_unit addSecondaryWeaponItem _magazine;
};
removeBackpack _unit;
} else {
_unit removeWeapon _launcher;
_unit addMagazine _magazine;
private _didAdd = _magazine in magazines _unit;
_unit addWeapon _launcher;
if (!_didAdd) then {
TRACE_2("Failed To Add Disposable Magazine Normally, doing backup method",_unit,(backpack _unit));
_unit addSecondaryWeaponItem _magazine;
};
};
if (_isLauncherSelected) then {
_unit selectWeapon _launcher;
};
};

View File

@ -1,47 +0,0 @@
#include "script_component.hpp"
/*
* Author: bux, commy2
* Hide or show the secondary weapon magazine inventory slot to prevent unloading of dummy magazines.
*
* Arguments:
* 0: unit - Object the event handler is assigned to <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_disposable_fnc_updateInventoryDisplay;
*
* Public: No
*/
disableSerialization;
params ["_player", ["_display",(findDisplay 602),[displayNull]]];
TRACE_2("params",_player,_display);
_player removeMagazines "ACE_PreloadedMissileDummy";
_player removeMagazines "ACE_FiredMissileDummy";
if (isNull _display) exitWith {};
private _launcher = secondaryWeapon _player;
if (_launcher == "" || {getText (configFile >> "CfgWeapons" >> _launcher >> "ACE_UsedTube") == ""}) then {
private _control = _display displayCtrl 627;
private _config = configFile >> "RscDisplayInventory" >> "controls" >> "SlotSecondaryMagazine";
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;
_control = _display displayCtrl 1251;
_config = configFile >> "RscDisplayInventory" >> "controls" >> "BackgroundSlotSecondaryMagazine";
_control ctrlSetPosition [getNumber (_config >> "x"), getNumber (_config >> "y"), getNumber (_config >> "w"), getNumber (_config >> "h")];
_control ctrlCommit 0;
} else {
private _control = _display displayCtrl 627;
_control ctrlSetPosition [0, 0, 0, 0];
_control ctrlCommit 0;
_control = _display displayCtrl 1251;
_control ctrlSetPosition [0, 0, 0, 0];
_control ctrlCommit 0;
};

View File

@ -1 +0,0 @@
#include "\z\ace\addons\disposable\script_component.hpp"

View File

@ -218,6 +218,18 @@ class CfgWeapons {
};
};
class ACE_launch_NLAW_ready_F: launch_NLAW_F {
class WeaponSlotsInfo: WeaponSlotsInfo {
mass = 195; // 275 - 80
};
};
class ACE_launch_NLAW_used_F: launch_NLAW_F {
class WeaponSlotsInfo: WeaponSlotsInfo {
mass = 195; // 275 - 80
};
};
// - RPG-32 ---------------------------------------------------------------
class launch_RPG32_F: Launcher_Base_F {
class WeaponSlotsInfo: WeaponSlotsInfo {

View File

@ -5,7 +5,7 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common"};
requiredAddons[] = {"ace_common","ace_disposable"};
author = ECSTRING(common,ACETeam);
authors[] = {"BaerMitUmlaut"};
url = ECSTRING(main,URL);

View File

@ -14,7 +14,7 @@ version:
## 1. Overview
The NLAW is shoulder fired and disposable, firing just once before being needed to be disposed of. This feature makes the NLAW disposable and provides the tools for other addons to do the same.
The NLAW is shoulder fired and disposable, firing just once before being needed to be disposed of. This feature makes the NLAW disposable.
## 2. Dependencies

View File

@ -1,7 +1,7 @@
---
layout: wiki
title: Disposables Framework
description: Explains how to set-up custom disposable launchers with the ACE3 disposables system.
description: Notes on old ACE3 disposable framework and link to CBA's.
group: framework
order: 5
parent: wiki
@ -12,32 +12,11 @@ version:
patch: 0
---
<div class="panel callout">
<h5>Note:</h5>
<p>This is just the necessary to make a launcher disposable, this is not a guide to make your own launcher.</p>
</div>
## 1. Making a launcher disposable
### 1.1 CfgWeapons
Support for the ACE3 disposable framework will be dropped in 3.13.0!
Switch to the [CBA Disposable Framework](https://github.com/CBATeam/CBA_A3/wiki/Disposable-Launchers)
Old weapon configs that are no longer supported:
```cpp
class CfgWeapons {
class Launcher_Base_F;
class launch_banana: Launcher_Base_F {
ACE_UsedTube = "launch_banana_Used_F"; // The class name of the used tube
magazines[] = {"ACE_PreloadedMissileDummy"}; // The dummy magazine
};
class launch_banana_Used_F: launch_banana { // The used tube should be a sub class of the disposable launcher
scope = 1;
ACE_isUsedLauncher = 1;
author = "grandBanana";
displayName = "Used banana launcher";
descriptionShort = "A used banana launcher";
magazines[] = {"ACE_FiredMissileDummy"}; // This will disable the used launcher class from being fired again
//picture = ""; // Not supported yet
//model = ""; // Not supported yet
weaponPoolAvailable = 0;
};
};
ACE_UsedTube = "launch_banana_Used_F";
ACE_isUsedLauncher = 1;
```