Page MenuHomeFeedback Tracker

Handheld weapon muzzles don't use their corresponding GunParticles class
Reviewed, NormalPublic

Description

While working on a secondary muzzle for a rifle, I noticed I couldn't change the firing smoke effect. Instead of using the particle effect that I defined for the muzzle, it uses the weapon's primary muzzle effect ("RifleAssaultCloud"). I verified that my code is set up properly using the config viewer, and I tried replacing the particle effect for the weapon itself. As expected, the effect is also applied to the secondary muzzle, which it shouldn't be.

I already came up with two alternatives, however they are far from pretty and can cause additional problems on the long run:

  • dynamically swap the unit's weapon to a derivated weapon class that uses the different particle effect in its "GunParticles" class (could lead to cloning / loss of weapon attachments, gain/loss of ammo, potentially performance heavy depending on how often the muzzle is used)
  • use a script to emit the particle effect via a "Fired" EH (worst alternative, as positioning and angling the particle effect is not accurately feasible with the current scripting commands, also potentially performance heavy as particle effect has to be broadcasted)

Neither of these alternatives is a real fix to the problem, but only a dirty workaround. A proper (engine-side) solution is needed.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 7 x64
Operating System Version
Windows 7 Home Premium
Category
Engine
Steps To Reproduce

To demonstrate that muzzles wrongly rely on the main weapon's GunParticles class - despite having a GunParticles class of their own - follow these steps:

  1. - Add the following code to an existing addon's config.cpp (or download the MuzzleGunClouds.pbo file attached in the next post):
class CfgWeapons {
        class Rifle;
        class Rifle_Base_F : Rifle {
                class GunParticles {
                        class FirstEffect;
                };
        };
        class arifle_ARX_base_F : Rifle_Base_F {
                class Secondary;
        };
        class arifle_ARX_blk_F : arifle_ARX_base_F {
                class Secondary : Secondary {
                        class GunParticles : GunParticles {
                                class FirstEffect : FirstEffect {
                                        effectName = "CannonFired";
                                };
                        };
                };
        };
};
  1. - Compile the addon and launch the game (with that addon enabled)
  1. - Go to the Virtual Arsenal and equip the "Type 115 6. 5mm (Black)" (weapon class: "arifle_ARX_blk_F"), load a magazine in the main muzzle (6.5mm) and one in the secondary muzzle (.50 BW)
  1. - Fire a round with each muzzle. Notice that both muzzles use the regular firing smoke effect.
  1. - Open the config viewer and browse to:
"CfgWeapons" >> "arifle_ARX_blk_F" >> "Secondary" >> "GunParticles" >> "FirstEffect"

Notice that the "effectName" entry has been changed to "CannonFire", yet the secondary muzzle isn't using that particle effect.

  1. - (Optional additional step: change the "effectName" entry in:
"CfgWeapons" >> "arifle_ARX_blk_F" >> "GunParticles" >> "FirstEffect"

to "CannonFire", and (after a config merge/game restart) fire a round with each muzzle. Notice that both muzzles are now using that particle effect.)

Additional Information

Instead of always relying on the weapon's GunParticles class, the engine should first check if there is a GunParticles in the muzzle's class, and use that if it exists. Otherwise, it should fall back to the current behaviour and use the weapon's GunParticles class.

Additional note: I didn't verify if this behaviour also applies to the sibling classes "GunFire" and "GunClouds", but they may also be affected.

Event Timeline

Cre8or created this task.Feb 14 2017, 12:20 AM
Cre8or added a comment.EditedFeb 14 2017, 8:19 AM

For quick testing, I made a .pbo file with the above config in it.

EDIT: I didn't have my cup of coffee yet; the file was meant to be called MuzzleGunParticles, not MuzzleGunClouds.

Cre8or edited Steps To Reproduce. (Show Details)Feb 14 2017, 8:23 AM
Fennek added a subscriber: Fennek.Feb 14 2017, 9:17 AM
Alwin claimed this task.Feb 14 2017, 3:20 PM
Alwin changed the task status from New to Reviewed.