Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Daniel13579
- Title:
- Rapid lightning
- Description:
- Spawns random lightning around the player/object
- How to use the script:
- Put the lightning sqf file in the mission folder.
- Put the execution line underneath in the trigger activation field:
- startLightning = 1; null = [A, B, C, D] execVM "Lightning.sqf";
- A is the maximum distance each lightning can spawn from the given position.
- The distance ranges from 0 meters to the number you supply.
- B is the base number of seconds before a new lightning can be spawned.
- C is the maximum amount of more seconds randomly added to this delay.
- D is the object the lightning will be centered around. The player for example.
- startLightning = 1; will start the lightning
- startLightning = 0; will stop the lightning
- Example:
- startLightning = 1; null = [8000, 4, 4, player] execVM "Lightning.sqf";
- */
- // organize our arguments
- _lightningDist = _this select 0;
- _delay = _this select 1;
- _delayRandom = _this select 2;
- _lightningPos = _this select 3;
- // create loop for spawning lightning
- while { startLightning == 1 } do
- {
- _randomLightningDist = random _lightningDist;
- // make a perimeter around the player/object
- if (_randomLightningDist <= 50) then { _randomLightningDist = 50 };
- // get a random spot around the target
- private _pos = [_lightningPos, _randomLightningDist, random 360] call BIS_fnc_relPos;
- // make the lightning at that spot
- private _lightning = "Land_HelipadEmpty_F" createVehicle _pos;
- [_lightning, nil, true] spawn BIS_fnc_moduleLightning;
- // distance between player and lightning
- private _meters = player distance _lightning;
- // Lightning sounds
- [_lightning, _meters] spawn {
- params ["_lightning", "_meters"];
- if (_meters <= 500) then {
- // select random lightning sound
- _randomLightningSound = selectRandom ["A3\sounds_f\ambient\thunder\thunder_02.wss","A3\sounds_f\ambient\thunder\thunder_04.wss"];
- // play sound
- playSound3D [_randomLightningSound, _lightning, false, getPosASL _lightning, 5, 1, 20000];
- };
- if (_meters > 500) then {
- // play sound
- playSound3D ["A3\sounds_f\ambient\thunder\thunder_01.wss", _lightning, false, getPosASL _lightning, 5, 1, 20000];
- };
- };
- // delay plus random delay
- sleep (_delay + random _delayRandom);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement