Jump to content
davidoss

[Release] Dazzle the darkness

Recommended Posts

 A flare/chemlight booster. 😄

If someday gets dark you definitely wants to check it out.

Looks very cool 😄

 

usage:
place scripts directory in your mission root directory
add lines in:

 

init.sqf

if (hasInterface) then {
	chemlight_brg	= 0.3; //Brightness of the chemlights
	flare_brg		= 2.5; //Brightness of flares
	0 = [] spawn compile preprocessFileLineNumbers "scripts\dazzle_the_darkness\dazzle_the_darkness.sqf";
};

 

 

 

scripts overwiev:

dazzle_the_darkness

/*
by DaVidoSS
dazzle_the_darkness

Adds firedMan EH

usage:
place scripts directory in your mission root directory
add lines in: 

init.sqf

if (hasInterface) then {
	chemlight_brg	= 0.3; //Brightness of the chemlights
	flare_brg		= 2.5; //Brightness of flares
	0 = [] spawn compile preprocessFileLineNumbers "scripts\dazzle_the_darkness\dazzle_the_darkness.sqf";
};

*/
if (hasInterface) then {
fn_setLight = compileFinal preprocessFileLineNumbers "scripts\dazzle_the_darkness\functions\setLight.sqf";
fn_upgradeLight = compileFinal preprocessFileLineNumbers "scripts\dazzle_the_darkness\functions\upgradeLight.sqf";


	player addEventHandler ["FiredMan",{
		params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];

			private _lightSources = [
								toLower "F_40mm_White",
								toLower "F_40mm_Red",
								toLower "F_40mm_Yellow",
								toLower "F_40mm_Green",
								toLower "Chemlight_green",
								toLower "Chemlight_red",
								toLower "Chemlight_blue",
								toLower "Chemlight_yellow"
							];
		
				if ((toLower  (typeOf _projectile)) in _lightSources) then {

					0 = [_projectile] spawn fn_upgradeLight;
			
				};
	}];

};

 

fn_setLight

/*
by DaVidoSS
fn_setLight 

Set of adjustments to the light according to the parameters passed

param:
0 - object , lightpoint
1 - nummber, lightpoint size
2 - nummber, light intensity
3 - array, color
returns -  void
*/
params [["_light",objNull,[objNull]], ["_flareSize",300,[0]], ["_flareBrightness",0.2,[0]], ["_flareColor",[1,1,1],[[]]]];
if (isNull _light) exitWith {};
_light setLightFlareSize _flareSize;
_light setLightBrightness _flareBrightness;
_light setLightColor _flareColor;
_light setLightAmbient _flareColor;

 

fn_upgradeLight

/*
by DaVidoSS
fn_upgradeLight 

Detecting projectile type and customize its parameters
param:
0 - object , projectile
returns -  void
*/

params [["_flare",objNull,[objNull]]];

if (isNull _flare) exitWith {};		

private _lightAmmo = [ 
	[toLower "Chemlight_green",300,chemlight_brg,[0,1,0]], 
	[toLower "Chemlight_red",300,chemlight_brg,[1,0,0]], 
	[toLower "Chemlight_blue",300,chemlight_brg,[0,0,1]], 
	[toLower "Chemlight_yellow",300,chemlight_brg,[1,1,0]], 
	[toLower "F_40mm_White",1000,flare_brg,[1,1,1]], 
	[toLower "F_40mm_Red",1000,flare_brg,[1,0,0]], 
	[toLower "F_40mm_Yellow",1000,flare_brg,[1,1,0]], 
	[toLower "F_40mm_Green",1000,flare_brg,[0,1,0]]
];
private _getidx = ([_lightAmmo , toLower (typeOf _flare)] call BIS_fnc_findNestedElement) # 0;
private _size = _lightAmmo # _getidx # 1;
private _brth = _lightAmmo # _getidx # 2;
private _color = _lightAmmo # _getidx # 3;
							
private _light  = "#lightpoint" createVehicle (position _flare);
0 = [_light, [_flare, [0,0,0]]] remoteExecCall ["lightAttachObject", [0,-2] select isDedicated, _light];
0 = [_light, _size, _brth, _color] remoteExecCall ["fn_setLight", [0,-2] select isDedicated, _light];


0 = [_flare,_light] spawn {
	params [["_flare",objNull,[objNull]],["_light",objNull,[objNull]]];
	waitUntil {sleep 1; isNull _flare};
	deleteVehicle _light;
};

 

Dazzle_the_darkness

  • Like 6

Share this post


Link to post
Share on other sites

Looks great!

One little thing to fix:

[_light, _size, _brth, _power, _color] remoteExecCall ["fn_setLight", 0, false];

to this:

[_light, _size, _brth, _power, _color] remoteExecCall ["fn_setLight", 0, _light];

to make it more JIP-compatible.

Share this post


Link to post
Share on other sites
I thought myself that it will be no necessary to bother the JIP queue for such short process as burning flare.

But if so what a hell , fixed.

Thanks

Share this post


Link to post
Share on other sites

 

I thought myself that it will be no necessary to bother the JIP queue for such short process as burning flare.

But if so what a hell , fixed.

Thanks

 

Flares, yes, but chemlights can work for quite a time.

Share this post


Link to post
Share on other sites

Liking it.  Is there a way to fix the wobbling of the flare on the ground ?

Share this post


Link to post
Share on other sites

Ah you again with your astonishing avatar. Its just perfect gives a lot laugh.

I do not knew why the flares wobbling on the ground maybe the BIS dev predicted so?

 

Anyway to get this perfect we need to find a solution which ensure execution of this part:

        [_flare,_light] spawn {
        
        params ["_object", "_effect"];
        
            waitUntil {isNull _object};
            deleteVehicle _effect;
        
        
        };

even if the client where the code is waiting for {isNull _object} has disconnected in the meantime.

Any clues?

Share this post


Link to post
Share on other sites

How do I actually get this to work? Ive been trying for the past 30 mins without success.


 


Humbly,


Reed


Share this post


Link to post
Share on other sites

 

I do not knew why the flares wobbling on the ground maybe the BIS dev predicted so?

 

The flares wobbling on the ground has been a thing since alpha. It has something to do with physX not knowing what to do once the flare touches the ground, so it simply jitters in and out of the terrain until it burns out and gets deleted.

 

 If you check the velocity once the flare hits the ground it shoots up to ridiculous numbers (or ridiculous negative numbers) in the millions or even billions. I made a ticket back in the alpha regarding this and it was ignored, obviously not high priority for bis at this point.

Share this post


Link to post
Share on other sites
On 8/4/2016 at 11:09 PM, Jnr4817 said:

 

How do I actually get this to work? Ive been trying for the past 30 mins without success.

 

Humbly,

Reed

 

 

Not big deal just paste  all into init.sqf

Share this post


Link to post
Share on other sites

This command might help 

 

https://community.bistudio.com/wiki/lightAttachObject

 

to replace

 

        while {!(isTouchingGround _flare) || (speed _flare) > 0} do {
        
            _light setpos
(getpos _flare);
        
        
};

Share this post


Link to post
Share on other sites

Already tried that. Looks horrific.

 

 

When attached, movement is slow to update (jumpy). Use attachTo when attaching a light to moving objects.

 

Tried attachTo too, same result.

 

Anyway sometime the BIS_fnc_findNestedElement are too slow, are there any other possibility to arrange correct index search direct inside function?

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

×