Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
soul_assassin

Tutorial: Creating custom vehicle muzzleflashes

Recommended Posts

Tutorial: Creating custom vehicle muzzleflashes

This should give some insight on creating custom main weapon muzzleflashes for vehicles.

First of all set up 2 sqf files. Put them both into your \my_addon\scripts\ directory:

1. init.sqf

/*******************************************************************************
* Special FX secton                                                            *
*******************************************************************************/
if (isNil "MYADDON_Effects_Init") then
{
MYADDON_Effects_Init = true;
MYADDON_Effects_EH_Fired = compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\fired.sqf";
MYADDON_Effects_EH_Killed = compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\killed.sqf";

MYADDON_Effects_HeavyCaliber=compile preprocessFileLineNumbers "\my_addon\scripts\heavycaliber.sqf";

//must use spawn command for these:
BIS_Effects_Burn=compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\destruction\burn.sqf";
BIS_Effects_AircraftVapour=compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\misc\aircraftvapour.sqf";
BIS_Effects_AirDestruction=compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\destruction\AirDestruction.sqf";
BIS_Effects_AirDestructionStage2=compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\destruction\AirDestructionStage2.sqf";
BIS_Effects_Secondaries=compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\destruction\Secondaries.sqf";
//BIS_Effects_RocketTrail=compile preprocessFileLineNumbers "\ca\Data\ParticleEffects\SCRIPTS\muzzle\rockettrail.sqf";
};

2) heavycaliber.sqf

private ["_u", "_sh","_i","_no","_int","_vel","_p3d","_light","_li"];
_u = _this select 0;
_sh = nearestobject [_u, _this select 4];
_i=1;
_no=2;

//Flash

drop [["\ca\Data\ParticleEffects\Universal\Universal",16,2,32], //objecct
"",																//Animation name
"Billboard",													//Type
1,																//Timer periods
(0.12 + 0.015*_i), 												//Life time
[0,0.7,0.1], 													//Position
[0,1,0],														//move velocity 
0, 																//rotation velocity
10,																//weight
0.5,															//volume
0.075,															//rubbing
[0.5, _i*1],														//size
[[1, 1, 1, -2],[1, 1, 1, -2], [1, 1, 1, -1], [1, 1, 1, -0]], 	//color
[3 + random 2],													//Animation Phase
0,																//Random dir
0, 																//Random dir intensity
"", 															//On timer
"", 															// before destroy
_sh];

// Night Light
_li = "#lightpoint" createVehicleLocal getpos _sh;
_li setLightBrightness 0.2;
_li setLightAmbient[0.8, 0.6, 0.2];
_li setLightColor[1, 0.5, 0.2];
//_li lightAttachObject [_u, [0,1.1,0.1]];


//Smoke
private ["_weh","_life"];
_u= _this select 0;
_sh = nearestobject [_u, _this select 4];
if ((_u iskindof "Helicopter") && (isengineOn _u)) then 
{
_weh=1;
_life= 0.8;
}
else
{
_weh = 0.104;
_life= 1.3 + random 0.6;
};

drop [["\ca\Data\ParticleEffects\Universal\Universal",16,12,8],
"", 

"Billboard",
1,
_life,
[0, 1.1, 0.1],
[0, 5 + random 4, 0],
0,
_weh,
0.08,
0.2,
[1.5, 5 + random 3],
[[0.7, 0.7, 0.7, 0.2 + random 0.1],
[0.8, 0.8, 0.8, 0]], 
[1/_life], 1, 0, "", "", _sh,random 360];

drop [["\ca\Data\ParticleEffects\Universal\Universal",16,12,8],
"", 
"Billboard",
1,
0.3,
[0, 1.1, 0.1],
[0, 0, 0],
0,
_weh,
0.08,
0.5,
[0.4, 2.5], 
[[0.3, 0.3, 0.3, 0],[0.5, 0.5, 0.5, 0.25],[0.7, 0.7, 0.7, 0]],
[2],
1,
0,
"",
"",
_sh,
random 360];

//remove light
_li spawn
{
sleep 0.05;
deletevehicle _this;
};

in that code tweak the second member of the position array for the specific length of the barrel. Also here tweak all the parameters of the flash, like size, speed, ammount etc.

In the cfgAmmo defenition of the ammunition of the weapon add a line:

muzzleEffect = "MYADDON_Effects_HeavyCaliber";

And finally make sure your EvenHandler defenition looks like this:

class EventHandlers 
       {
           init = "_this call compile preProcessFile ""\my_addon\scripts\init.sqf"";";
           fired = "_this call MYADDON_Effects_EH_Fired;"; // on weapon fired
    killed = "_this call MYADDON_Effects_EH_Killed;"; 
       };

That should be it :)!

Share this post


Link to post
Share on other sites

How would you completely disable the muzzleffects for a certain ammo type?

I tried

muzzleEffect = "NoEffect";

But the smoke is still visible.

Any help would be appreciated.

EDIT: Seems like the smoke is hardcoded in "WeaponCloudsGun". Anyone know

if that can be replaced in a custom config? I know of Sakeweaponfire, but that

hacks the game´s config.

Edited by Charon Productions

Share this post


Link to post
Share on other sites
Sign in to follow this  

×