Skip to content

Disposable Launchers

commy2 edited this page Jun 14, 2019 · 5 revisions

Disposable Launchers

This framework provides support for disposable launchers. They are loaded when taken out of a weapons crate or the Arsenal without having to take a magazine. When shot they are replaced by a used tube. The magazine can not be dropped via the inventory menu.

For this to work you need to create 3 separate weapon classes: the "normal" launcher, the preloaded launcher (which will be replaced with the normal launcher and the magazine) and the used launcher (which can no longer be fired).

The preloaded launcher is itself not compatible with the magazine and should have the mass of the normal launcher plus the magazine. The used launcher should have the same mass as the normal launcher.

The necessary config entries are shown below. Some of these are required for the arsenal to handle the items correctly, for the weapon optic of the used launcher to be usable and for the engine to handle the framework correctly in general. Be not afraid to set the magazineReloadTime to exactly 0.1. This just circumvents a bug with some script commands that would cause the launcher to not be usable for quite a while after selected the first time. The magazine reload time is otherwise ignored for person held weapons: it only affects vehicles. Person held weapons reload times are controlled entirely by their reload gesture animations. Disposable launchers are preloaded anyway.

This framework is not compiled or executed when no compatible launchers are in your mod set. CBA provides no such launchers.

Config example 1

#define LAUNCHER_MASS 80
#define LAUNCHER_MAGAZINE_MASS 40

class CBA_DisposableLaunchers {
    BWA3_PzF3[] = {"BWA3_PzF3_Loaded","BWA3_PzF3_Used"};
};

class CfgMagazines {
    class CA_LauncherMagazine;
    class BWA3_PzF3_Tandem: CA_LauncherMagazine {
        author = "$STR_BWA3_Author";
        scope = 2;

        mass = LAUNCHER_MAGAZINE_MASS;
    };
};

class CfgWeapons {
    class Launcher;
    class Launcher_Base_F: Launcher {
        class WeaponSlotsInfo;
    };

    class BWA3_PzF3: Launcher_Base_F {
        author = "$STR_BWA3_Author";
        scope = 1;
        scopeArsenal = 1;
        baseWeapon = "BWA3_PzF3_Loaded";

        magazines[] = {"BWA3_PzF3_Tandem"};
        magazineReloadTime = 0.1;
        reloadMagazineSound[] = {"",1,1};

        class EventHandlers {
            fired = "_this call CBA_fnc_firedDisposable"; // this weapon eventhandler is required!
        };

        class WeaponSlotsInfo: WeaponSlotsInfo {
            mass = LAUNCHER_MASS;
        };
    };

    class BWA3_PzF3_Loaded: BWA3_PzF3 {
        author = "$STR_BWA3_Author";
        scope = 2;
        scopeArsenal = 2;
        baseWeapon = "BWA3_PzF3_Loaded";

        magazines[] = {"CBA_FakeLauncherMagazine"};

        class WeaponSlotsInfo: WeaponSlotsInfo {
            mass = LAUNCHER_MASS + LAUNCHER_MAGAZINE_MASS;
        };
    };

    class BWA3_PzF3_Used: BWA3_PzF3 {
        author = "$STR_BWA3_Author";
        scope = 1;
        scopeArsenal = 1;
        baseWeapon = "BWA3_PzF3_Used";

        magazines[] = {"CBA_FakeLauncherMagazine"};

        class WeaponSlotsInfo: WeaponSlotsInfo {
            mass = LAUNCHER_MASS;
        };
    };
};

Config example 2

  • Disposable launcher backwards compatible with missions and vehicles that already use the weapon classname for object cargo.
class CBA_DisposableLaunchers {
    ACE_launch_NLAW_ready_F[] = {"launch_NLAW_F","ACE_launch_NLAW_used_F"};
};

class CfgWeapons {
    class Launcher;
    class Launcher_Base_F: Launcher {
        class WeaponSlotsInfo;
    };

    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);
        weaponPoolAvailable = 0;

        class WeaponSlotsInfo: WeaponSlotsInfo {
            mass = 100;
        };
    };
};

class CfgMagazines {
    class CA_LauncherMagazine;
    class NLAW_F: CA_LauncherMagazine {
        scope = 1;
        allowedSlots[] = {};
    };
};