Jump to content
pierremgi

Custom Grenade Addon: working but standard grenades are no more throwable

Recommended Posts

Hi everybody,

I'm looking for hours and days with a "bug".

When in ARMA3 1.48 vanilia , player can throw a hand grenade. OK.

When i add my little addon, defining a custom smoke grenade, I can throw it (throwmuzzle, magazine, ammo are OK) but the standard handgrenade are no more throwable (present in inventory but no more selectable). I read some posts on how to make custom grenades but I didn't see anything about a loss of selection/muzzle for standard grenade.

Here is my code. in cfgPatches, i'm not sure to manage requiredAddons. In configWeapons i added all grenade classes with their magazines and the problem still remains. Why smoke are OK and not grenades? Please help! tks

class CfgPatches
{
   class MGI_Grenades 
   {
       units[] = {};
       weapons[] = {"MGI_LacrymoMuzzle"};
       requiredVersion = 0.1;
       requiredAddons[] = {"A3_Weapons_F","A3_Data_F","A3_Functions_F","A3_characters_F"};

   };
   author="Pierre_MGI";
   };

class CfgFunctions
{
   class MGI
   {
       //tag = "MGI";
       class MGI_Grenades
       {
           class smoke_init
            {
               postInit = 1;
               description = "Enable Tear gas and flashbang grenades";
               file = "\MGI_Grenades\smoke.sqf";
           };
       };
   };
};

class CfgAmmo 
{
   class Default;  // External class reference
   class GrenadeHand : Default {};
   class SmokeShell : GrenadeHand {};
   class MGI_Lacrymo_ammo : SmokeShell {
       timeToLive = 90;
       smokeColor[] = {1,1,1,0.5};
   };

};

class CfgMagazines
{
   class Default;  // External class reference
   class CA_Magazine : Default {};
   class HandGrenade : CA_Magazine {};
   //class 1Rnd_HE_Grenade_shell : CA_Magazine {};    
   class SmokeShell : HandGrenade {};
   //class 1Rnd_Smoke_Grenade_shell : 1Rnd_HE_Grenade_shell {};

   class MGI_Lacrymo_mag : SmokeShell
           {
           ammo = "MGI_Lacrymo_ammo";
           scope = 2;
           author = "Pierre MGI";
           descriptionShort = "Type: Smoke Grenade - Lacrymo<br />Rounds: 1<br />Used in: Hand";
           count = 1;
           displayName = $STR_MGI_lacrymo;
           displayNameShort = $STR_MGI_lacrymo_short;
           model = "\A3\Weapons_f\ammo\smokegrenade_white";
           picture = "\MGI_grenades\gear_teargasgrenade_ca.paa";
           class Library {
             libTextDesc = "These grenades alter the vision of player and inflict progressive damages to Ai units";};
           };
};


class CfgWeapons 
{

   class GrenadeLauncher;

   class Throw : GrenadeLauncher {
       muzzles[] = {"HandGrenade_Stone","HandGrenadeMuzzle","MiniGrenadeMuzzle","SmokeShellMuzzle","SmokeShellYellowMuzzle","SmokeShellGreenMuzzle","SmokeShellRedMuzzle","SmokeShellPurpleMuzzle","SmokeShellOrangeMuzzle","SmokeShellBlueMuzzle","ChemlightGreenMuzzle","ChemlightRedMuzzle","ChemlightYellowMuzzle","ChemlightBlueMuzzle","IRGrenade","MGI_LacrymoMuzzle"};

       class ThrowMuzzle: GrenadeLauncher {
           aidispersioncoefx = 6;
           aidispersioncoefy = 6;
           autoreload = 1;
           cursor = "EmptyCursor";
           cursoraim = "throw";
           enableattack = 0;
           keepininventory = 1;
           magazinereloadtime = 0;
           maxrange = 60;
           maxrangeprobab = 0.03;
           midrange = 45;
           midrangeprobab = 0.9;
           minrange = 10;
           minrangeprobab = 0.2;
           modeloptics = "";
           reloadsound[] = {"", 0.000316228, 1};
           reloadtime = 0;
           showempty = 0;
           sound[] = {"", 0.000316228, 1};
       };
       class HandGrenadeMuzzle: ThrowMuzzle {
           magazines[]= {"HandGrenade"};
           };
       class MiniGrenadeMuzzle: ThrowMuzzle {
           magazines[]= {"MiniGrenade"};
           };
       class HandGrenade_Stone: ThrowMuzzle {
           //magazines[]= {"HandGrenade_Stone"};
           //displayName="$STR_DN_STONE";
           minRange=5;
           minRangeProbab=0.0099999998;
           midRange=45;
           midRangeProbab=0.1;
           maxRange=80;
           maxRangeProbab=0.0099999998;
           };
       class MGI_LacrymoMuzzle : ThrowMuzzle {
           magazines[] = {"MGI_Lacrymo_mag"};
           };
       class SmokeShellMuzzle: ThrowMuzzle {
           //displayName="$STR_MN_SMOKE";
           magazines[]= {"SmokeShell"};
           };
       class SmokeShellYellowMuzzle: ThrowMuzzle {
           //displayName="$STR_MN_SMOKE";
           magazines[]= {"SmokeShellYellow"};
           };
       class SmokeShellRedMuzzle: ThrowMuzzle {
           //displayName="$STR_MN_SMOKE";
            magazines[]= {"SmokeShellRed"};
           };
       class SmokeShellGreenMuzzle: ThrowMuzzle {
           //displayName="$STR_MN_SMOKE";
           magazines[]= {"SmokeShellGreen"};
           };
       class SmokeShellPurpleMuzzle: ThrowMuzzle {
           //displayName="$STR_MN_SMOKE";
           magazines[]= {"SmokeShellPurple"};
           };
       class SmokeShellBlueMuzzle: ThrowMuzzle {
           //displayName="$STR_MN_SMOKE";
           magazines[]= {"SmokeShellBlue"};
           };
       class SmokeShellOrangeMuzzle: ThrowMuzzle {
           //displayName="$STR_MN_SMOKE";
           magazines[]= {"SmokeShellOrange"};
           };
       class ChemlightGreenMuzzle: ThrowMuzzle {
           //displayName="$STR_cfgWeapons_Throw_ChemlightMuzzle0";
           magazines[]= {"Chemlight_green"};
           };
       class ChemlightRedMuzzle: ChemlightGreenMuzzle {
           magazines[]= {"Chemlight_red"};
           };
       class ChemlightYellowMuzzle: ChemlightGreenMuzzle {
           magazines[]= {"Chemlight_yellow"};
           };
       class ChemlightBlueMuzzle: ChemlightGreenMuzzle {
           magazines[]= {"Chemlight_blue"};
           };
       class IRGrenade: ThrowMuzzle {
           //displayName="$STR_A3_cfgWeapons_Throw_IRGrenade0";
           magazines[]= {"B_IR_Grenade",
                   "O_IR_Grenade",
                   "I_IR_Grenade"};
           //cursorSize=1;
           };

       };

};

Share this post


Link to post
Share on other sites

You shouldn't be replacing the list of muzzles[] in your own addon. Even if you make sure the list is exactly the same as the original ARMA list (with your extra item) any future change to the ARMA 3 configs or loading any other mod with grenades will end up breaking things. Instead just add an entry to it with:

muzzles[] += {"MGI_LacrymoMuzzle"};

Also, you shouldn't be including the other muzzle classes (base A3 ones) in your own addon; e.g.:

class HandGrenadeMuzzle: ThrowMuzzle {
           magazines[]= {"HandGrenade"};
           };

They will be added back in by A3 when it merges your "Throw" class with the base class, and having them in your config will just cause problems down the road.

Once you've cleaned that up they may start working.

Share this post


Link to post
Share on other sites

Thank you for your answer.

I've done this and i get an error message: Warning Message: No entry 'config.bin/CfgWeapons/Throw.MGI_LacrymoMuzzle'.

And the problem is persistent: no more possibility to throw handgrenade!

here is my new cfgWeapon (rest unchanged):

class CfgWeapons

{

class GrenadeLauncher;

class Throw : GrenadeLauncher {

muzzles[] += {"MGI_LacrymoMuzzle"};

class ThrowMuzzle: GrenadeLauncher {

aidispersioncoefx = 6;

aidispersioncoefy = 6;

autoreload = 1;

cursor = "EmptyCursor";

cursoraim = "throw";

enableattack = 0;

keepininventory = 1;

magazinereloadtime = 0;

maxrange = 60;

maxrangeprobab = 0.03;

midrange = 45;

midrangeprobab = 0.9;

minrange = 10;

minrangeprobab = 0.2;

modeloptics = "";

reloadsound[] = {"", 0.000316228, 1};

reloadtime = 0;

showempty = 0;

sound[] = {"", 0.000316228, 1};

};

class HandGrenadeMuzzle: ThrowMuzzle {

magazines[]= {"HandGrenade"};

};

};

};

Share this post


Link to post
Share on other sites

Yeap, you can replace:

class ThrowMuzzle: GrenadeLauncher {
...

}

With just:

class ThrowMuzzle;

You want to avoid including any settings from the A3 configs (e.g. "aidispersioncoefx = 6") because like I said before if they change your addon will take them back to the old values and might cause issues.

Also it looks like you removed your own muzzle from "class Throw":

class MGI_LacrymoMuzzle : ThrowMuzzle {

magazines[] = {"MGI_Lacrymo_mag"};

};

If you add that back you should fix the error you're getting.

You can remove:

class HandGrenadeMuzzle ...

Too, as it is part of A3 as well.

Share this post


Link to post
Share on other sites

HI,

I've done all of this, and the problem is the same. I can throw IR grenades, smokes but nore grenades, mini-grenades.

Perhaps, the problem comes from other part than weapon class? Here is my last config:

class CfgPatches
{
    class MGI_Grenades 
    {
        units[] = {};
        weapons[] = {"MGI_LacrymoMuzzle"};
        requiredVersion = 0.1;
        requiredAddons[] = {"A3_Weapons_F","A3_Data_F","A3_Functions_F","A3_characters_F"};

    };
    author="Pierre_MGI";
};

class CfgFunctions
{
    class MGI
    {
        //tag = "MGI";
        class MGI_Grenades
        {
            class smoke_init
             {
                postInit = 1;
                description = "Enable Tear gas and flashbang grenades";
                file = "\MGI_Grenades\smoke.sqf";
            };
        };
    };
};

class CfgAmmo 
{
    class Default;  // External class reference
    class GrenadeHand : Default {};
    class SmokeShell : GrenadeHand {};
    class MGI_Lacrymo_ammo : SmokeShell {
        timeToLive = 90;
        smokeColor[] = {1,1,1,0.5};
    };

};

class CfgMagazines
{
    class Default;  // External class reference
    class CA_Magazine : Default {};
    class HandGrenade : CA_Magazine {};
    //class 1Rnd_HE_Grenade_shell : CA_Magazine {};    
    class SmokeShell : HandGrenade {};
    //class 1Rnd_Smoke_Grenade_shell : 1Rnd_HE_Grenade_shell {};

    class MGI_Lacrymo_mag : SmokeShell
            {
            ammo = "MGI_Lacrymo_ammo";
            scope = 2;
            author = "Pierre MGI";
            descriptionShort = "Type: Smoke Grenade - Lacrymo<br />Rounds: 1<br />Used in: Hand";
            count = 1;
            displayName = $STR_MGI_lacrymo;
            displayNameShort = $STR_MGI_lacrymo_short;
            model = "\A3\Weapons_f\ammo\smokegrenade_white";
            picture = "\MGI_grenades\gear_teargasgrenade_ca.paa";
            class Library {
              libTextDesc = "These grenades alter the vision of player and inflict progressive damages to Ai units";};
            };
};
   

class CfgWeapons 
{

    class GrenadeLauncher;

    class Throw : GrenadeLauncher {
        muzzles[] += {"MGI_LacrymoMuzzle"};
            
        class ThrowMuzzle;
        class MGI_LacrymoMuzzle : ThrowMuzzle {
            magazines[] = {"MGI_Lacrymo_mag"};
        };
    };
};

The good question could be: how modify this script to perform a throwable custom grenades addon without issue on the other grenades?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×