Jump to content
Shpook

Shpook's Ambient Lightning Script

Recommended Posts

Shpook's Ambient Lightning Script



By Shpook

Script Version: 1.0

2014_07_11_00061.jpg

Description:

Hey everyone. Here's a small ambient lightning script I made for a mission, I figured people would enjoy using it. It's lightweight, and shouldn't affect mission performance at all. This is based on the Zeus lightning function from Bohemia. You can adjust the center the lightning spawns around, the radius the lightning spawns in, and the maximum duration between strikes.

Download:

You can download the script from Armaholic.

Usage:

Place the scripts folder in your mission folder. You can call the script from almost anywhere: init.sqf, a game logic, a player, or any other script. I prefer to use init.sqf.

Parameters:

_center - OBJECT, MARKER, or POSITION. Marker must have quotes(""). Position must be array[]. Default is player.

_radius - Radius around center that lightning is randomly spawned. Default is 800 meters.

_interval - Maximum duration in which lightning strikes. Default is 60 seconds.

nul = [_center, _radius, _interval] execVM "scripts\SHPambientLightning.sqf";

Spawn lightning with defaults of player center, 800m radius, and 60s interval:

nul = [] execVM "scripts\SHPambientLightning.sqf";

Spawn lightning with transportHelicopter as center, 300m radius, and 20s interval:

nul = [transportHelicopter, 300, 20] execVM "scripts\SHPambientLightning.sqf";

Spawn lightning with marker as center, 500m radius, and default interval:

nul = ["lightningCenter", 500] execVM "scripts\SHPambientLightning.sqf";

Spawn lightning with position array as center, default radius, and default interval:

nul = [[2482.0117,32.202206,22100.438]] execVM "scripts\SHPambientLightning.sqf";

To stop the lightning script, type the following in a trigger or script:

SHPLightningRun = false;
publicVariable "SHPLightningRun";

Video:



Known Issues:

It will most likely act strange in multiplayer, due to the mixture of localities. I haven't noticed any issues with smaller player counts, but it's not tested with more than a few players. Please let me know if you notice anything strange.

Todo:

Add a variable check to the loop to allow script cancellation during mission.

Licensing:

Feel free to do anything you want with this script. Also feel free to post any improvements, I'd love to see them.

Special Thanks:

Bohemia for providing both the Arma platform and the lightning function.

TEST Outfit, TEST Arma for helping with testing, especially Vezer0.

Changelog:

(7/11/2014) v1.0

- Initial release.

(7/13/2014) v1.1

- Added chance of building and structure strikes.

Added check variable to allow loop cancellation.

Fixed a bug preventing the center from following a moving player or object.

Edited by Shpook
v1.1 Update

Share this post


Link to post
Share on other sites
Guest

Thanks for sending us the release :cool:

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Edited by Guest
updated to latest!

Share this post


Link to post
Share on other sites

Updated. v1.1 is available in the first post. I added a chance for building and object strikes, thanks to a suggestion from Youtube user jtgibson01. Also added a variable, SHPLightningRun, that will stop the script when set to false. See first post.

(7/13/2014) v1.1 - Added chance of building and structure strikes.

Added check variable to allow loop cancellation.

Fixed a bug preventing the center from following a moving player or object.

Share this post


Link to post
Share on other sites

You'd better call it from a trigger with a condition that will activate the script itself when its folder is placed in the mission's folder.

 

0 = execVM "SHPambientLightning.sqf"

[] = execVM "SHPambientLightning.sqf"

 

Otherwise, just copy the script and place it in your init.sqf file which must be in the mission's folder. If you don't have any, then create one using any other .sqf file you have. Just rename it to ïnit.sqf" or use wordpat/notepad to create one. But it's a little bit harder.

Edited by black_hawk_mw2_87

Share this post


Link to post
Share on other sites

I have tried to activate the script, but it doesn't work properly. I have copied and pasted the folder called "scripts" inside my mission's folder. I have put a line of those mentioned above inside my init.sqf file, but when I load the mission, there's still an error on the screen containing information about some errors from inside the script itself. I tried with all types of the script lines - it's the same. I even tried to activate it with a trigger and load the file itself as I said in my previous comment. Still the same... I can see the lightning effects and I can hear the thunderbolts, but when this happens I receive the error messages every single time. Any idea what could be wrong?

Share this post


Link to post
Share on other sites

I deleted the "can collide" portion, and no error. However unsure if it still destroys things. Anyone still use this script?

Share this post


Link to post
Share on other sites
On 1/21/2019 at 3:11 PM, black_hawk_mw2_87 said:

I have tried to

 

20 minutes ago, CHICKENLICKEN said:

I deleted the "can collide"

 

Hello there Guys !

 

Just to know , every time that you are using something that is not close to the current date , might not working properly as well, due to the game updates.

 

If i have time and i'll try , i 'll have a check about it !

Share this post


Link to post
Share on other sites

The script actually works fine. Line 109 contains something that needs to be deleted or set to "none". It's in the brackets in the end of the line. Instead of […..] you must only use: []

SO, find these lines in the script:

 

_dir =random 360;

    _bolt = createvehicle ["LightningBolt",_strikeCenter,[],0,""];

 

As you can see, the brackets after _strikeCenter, ------ are empty.

That's it. It works great without errors now.

 

  • Like 1

Share this post


Link to post
Share on other sites
On 2/2/2019 at 1:47 AM, black_hawk_mw2_87 said:

The script actually works fine. Line 109 contains something that needs to be deleted or set to "none". It's in the brackets in the end of the line. Instead of […..] you must only use: []

SO, find these lines in the script:

 

_dir =random 360;

    _bolt = createvehicle ["LightningBolt",_strikeCenter,[],0,""];

 

As you can see, the brackets after _strikeCenter, ------ are empty.

That's it. It works great without errors now.

 

Thanks for this. I've got the script working in a limited fashion, but only the ambient light effect is playing. The bolt itself is not visible, and there is no audio played either. I realize this is an old script, but I can't find anything more recent, nor am I remotely skilled enough to make one from scratch. When you use it, does the audio play as well?

 

Edit: I've been able to get the effects to play, but have encountered a new problem. What is the maximum radius the lightning can spawn in? I've updated line 61 to a 2500m radius, and placed this into the init.sqf:

 

_nul = ["lightningCenter", 2500] execVM "scripts\SHPambientLightning.sqf";

Share this post


Link to post
Share on other sites

Really, really awesome script.

 

I was getting a couple bugs, as other users had also found, so here are the edits I made:

 

/*
Changed
	_bolt = createvehicle ["LightningBolt",_strikeCenter,[],0,"can collide"];
(line 109 by default) to
	_bolt = createvehicle ["LightningBolt",_strikeCenter,[],0,"can_collide"];
"can collide" not valid; must be "can_collide" as per createVehicle wiki description

Changed
	_buildings = nearestObjects [_center, _objectTypes, _radius];
(line 83  by default) to
	_buildings = nearestObjects [_centerPos, _objectTypes, _radius];
Was throwing an error when I used a marker for _center
*/

 

I also moved the loop start after definition of _centerPos, and moved the _buildings array generation to before loop start, as in the mission I'm making the _center stays the same, and the strike frequency is very high, so I figured I would remove these from the loop as it is not necessary for me to repeatedly redefine them.

 

Hope this helps someone 🙂 

  • Like 2

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

×