Jump to content
Sign in to follow this  
Kydoimos

Blinking Street Light Effect

Recommended Posts

Hi all, I've edited the following code slightly (it was used in the East Wind campaign) - the strange thing is, I can get it to work on Stratis but not on Altis! Any idea why? There's nothing I can see in this .sqf that is map specific. The sound effects plays, but the light doesn't blink (no error messages appear either):

// Script Adapted from BIS 'EAST WIND' Campaign 

// Define

#define ON       0
#define OFF     0.97
#define LIGHT    "light_1_hitpoint"
#define DUMMY    "BIS_effectDummy"
#define DESTROYED "BIS_lightDestroyed"
#define SAMPLE  "electricity_loop"
#define HELIPAD  "Land_HelipadEmpty_F"
// Parameters
private ["_position", "_type", "_timing", "_delay", "_condition"];
_position = [nearestObject getMarkerPos "Lamp_A"] call BIS_fnc_param;
_type  = [_this, 1, "Land_LampShabby_F", [""]] call BIS_fnc_param;
_timing  = [_this, 2, [0.25, 0.50], [[]]] call BIS_fnc_param;
_delay  = [_this, 3, [1, 2], [[]]] call BIS_fnc_param;
_condition = [_this, 4, { true }, [{}]] call BIS_fnc_param;
// Find Related Objects
private "_object";
_object = nearestObject [_position, _type];
// Make Sure Object Found
if (isNull _object) exitWith {
["Object at position (%1), of type (%2) not found", _position, _type] call BIS_fnc_error;
};
// Light Starts Off
_object setHit [LIGHT, OFF];
//Hit Event Handler
_object addEventhandler ["Hit", { (_this select 0) setvariable [DESTROYED, true]; }];
// Effect
private "_setState";
_setState = {
private ["_object", "_on"];
_object = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
_on  = [_this, 1, true, [true]] call BIS_fnc_param;

// The Dummy Object
private "_dummy";
_dummy = objNull;

// Has the Dummy Object Been Created?

if (isNil { _object getVariable DUMMY }) then {

// Create Dummy Object
private "_dummy";
_dummy = createVehicle [HELIPAD, position _object, [], 0, "CAN_COLLIDE"];

// Attach to Light Object
_dummy attachTo [_object, [0,0,2]];

// Store
_object setVariable [DUMMY, _dummy];
} else {
_dummy = _object getVariable DUMMY;
};

// Effect On Or Off
if (_on) then {
// Play Effect
_dummy setDamage 0;
_dummy say3D SAMPLE;
_object setHit [LIGHT, ON];
} else {
// Destroy Effect
_dummy setDamage 1;
_object setHit [LIGHT, OFF];
};
};
// Flag
private "_lightOn";
_lightOn = false;
// Main Loop
while _condition do {
// Exit If Destroyed
if (!isNil { _object getvariable DESTROYED }) exitWith {
// Light Off
_object setHit [LIGHT, OFF];

// Log
["Light object (%1) was destroyed", _object] call BIS_fnc_log;
};

// Blinking Loop
for "_i" from 0 to 5 do {
// Set State
if (_lightOn) then {
[_object, false] call _setState;
_lightOn = false;
} else {
[_object, true] call _setState;
_lightOn = true;
};

// Timing
sleep (_timing call BIS_fnc_randomNum);
};

// Sleep
sleep (_delay call BIS_fnc_randomNum);
};
// Does It Exist?
if (!isNil { _object getVariable DUMMY }) then {
// The Dummy
private "_dummy";
_dummy = _object getVariable DUMMY;

// Detach And Delete

detach _dummy;
deleteVehicle _dummy;
};
// Return

true;


---------- Post added at 16:44 ---------- Previous post was at 16:25 ----------

I see - there's a bug with the street lamps in the Selakano region (they can't be destroyed) - one for the Feedback Tracker, I guess.

Share this post


Link to post
Share on other sites

Hey, mate.

I've tested it successfully with both "Land_LampShabby_F" and "Land_LampStreet_small_F" -- add "Land_Powerpolewooden_l_F" to that -- at Selakano. They did blink, along with playing the sound effect. Which lamps are the ones not working?

Edited by rakowozz

Share this post


Link to post
Share on other sites

Hiya, Rakowozz - thanks for the feedback! It's a nice little script huh? Strangely, the shabby lamp next to the asphalt playground (with the goal posts) wouldn't blink - it was indestructible too, very odd! I'll revisit the issue in the morning and see if I can work out what's going wrong!

Share this post


Link to post
Share on other sites

Searched for hours to find a simple script for a strobe light of some kind and the above is the closest thing so far. I'm assuming make an .sqf with the code above, reference that .sqf in the init? Then what code goes into the object or lamp? Im newish to editing so any help on how to make a strobe, whether it be static or a blinking street lamp would be insanely appreciated and I will give props in an eventual tutorial video I make since I can find no info on the net on how to create a strobe like you would find in a haunted house or club. Thanks in advance!

 

-Rogue

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
Sign in to follow this  

×