Jump to content
Irishcream216

Trigger lightning module at random interval over time

Recommended Posts

First post here, long time lurker. 

I used the search function but was unable to find a solution to the problem at hand. I appreciate any advice. 

As the title suggests, I am attempting to generate a "ring of lightning" around an object for a cinematic effect. I am using the ZEUS lightning bolt modules in 3den, placed in a circle around said object. What I would like to happen is as follows: 

When the player(s) get within a certain range, the trigger(s) will activate the array of modules (one at a time, in quick succession) at random(z1 - z16), for a certain amount of time. When that time expires, they will then ALL fire at once for a brilliant flash finale. 

It sounds simple on the surface, but I cannot for the life of me get them to fire at random, even adjusting the trigger timer. After a set interval, they all fire at once. I have tried using multiple triggers in groups, and even having a separate trigger for each module covering an area of 250m radius each, centered on exactly the same point. I am VERY new to scripting, but previously have been able to do things without calling a function or a script from SQF.  

please advise, and thank you. 

 

-Irish

Edited by Irishcream216
clarity

Share this post


Link to post
Share on other sites

Nice, really nice idea!

Well, I cannot handle "modules' " stuff, but a few months ago, @pierremgi brought a lot of great improvements to a kind of "Zeus' Hammer" punishment that I used to apply upon dirty players on a public server. Although it was used within a new addAction (menu), I have just tested it, and it works really nice when activated by a trigger.

Please make this first attempt, at least to see whether such style could help in the direction you want.
Instead of modules, place at least three objects like the "Helipad (invisible)" (class name "Land_HelipadEmpty_F"), and give them the variable names of "thunderMk1", "thunderMk12" and "thunderMk13".

Place a trigger that should be activated by the player to start the show:
CONDITION: this
ON ACTIVATION: [] execVM "CircleOfThunder.sqf";

Create a file named "CircleOfThunder.sqf" inside your mission folder, and throw all the stuff bellow inside it.
If you want the lightning alone, without those extra "delayed" explosions, you can just delete all those lines starting from "_charge_11" until " _charge_88" (there are three blocks of them).
 

Spoiler



thunderMk1 spawn {
  _pos = getPosATL _this;
  _bolt = createvehicle ["LightningBolt",[0,0,0],[],0,"CAN_COLLIDE"];
  _bolt setposatl _pos;
  _bolt setdamage 1;
  if (_this isKindOf "CAManBase") then {_this addForce [_this vectorModelToWorld [0,0,3000], _this selectionPosition "rightfoot"]};
  _light = "#lightpoint" createvehicle _pos;
  _lightCode = compileFinal "
    params ['_light','_pos'];
    _light setposatl [_pos select 0,_pos select 1,(_pos select 2) + 10];
    _light setLightDayLight true;
    _light setLightBrightness 300;
    _light setLightAmbient [0.05, 0.05, 0.1];
    _light setlightcolor [1, 1, 2];
    sleep 0.9;
    _light setLightBrightness 0;
  ";
  [_light,_pos] remoteExec ["_lightCode"];
  sleep random 0.3;
  _class = selectRandom ["lightning1_F","lightning2_F"];
  _lightning = _class createvehicle [0,0,100];
  _lightning setdir random 360;
  _lightning setpos _pos;
  for "_i" from 0 to 3 + random 1 do {
    sleep 0.1;
    _bright = 100 + random 100;
    [_light,_bright] remoteExec ["setLightBrightness"];
  };
  deletevehicle _lightning;
  deletevehicle _light;
};


		_charge_11 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_11 setPosATL (thunderMk1 modelToWorldVisual [0,-7,-1]);
		_charge_11 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [0,-3,0]),[0,0,1]];
		_charge_11 setDamage [1,TRUE];
		_charge_22 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_22 setPosATL (thunderMk1 modelToWorldVisual [0,7,-1]);
		_charge_22 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [0,3,0]),[0,0,1]];
		_charge_22 setDamage [1,TRUE];
		_charge_33 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_33 setPosATL (thunderMk1 modelToWorldVisual [-7,0,-1]);
		_charge_33 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [-3,0,0]),[0,0,1]];
		_charge_33 setDamage [1,TRUE];
		_charge_44 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_44 setPosATL (thunderMk1 modelToWorldVisual [7,0,-1]);
		_charge_44 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [3,0,0]),[0,0,1]];
		_charge_44 setDamage [1,TRUE];
		
		_charge_55 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_55 setPosATL (thunderMk1 modelToWorldVisual [3,-7,-1]);
		_charge_55 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [7,-3,0]),[0,0,1]];
		_charge_55 setDamage [1,TRUE];
		_charge_66 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_66 setPosATL (thunderMk1 modelToWorldVisual [-3,7,-1]);
		_charge_66 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [-7,3,0]),[0,0,1]];
		_charge_66 setDamage [1,TRUE];
		_charge_77 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_77 setPosATL (thunderMk1 modelToWorldVisual [-7,3,-1]);
		_charge_77 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [-3,7,0]),[0,0,1]];
		_charge_77 setDamage [1,TRUE];
		_charge_88 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_88 setPosATL (thunderMk1 modelToWorldVisual [7,-3,-1]);
		_charge_88 setVectorDirAndUp [(thunderMk1 modelToWorld [0,0,0]) vectorFromTo (thunderMk1 modelToWorld [3,-7,0]),[0,0,1]];
		_charge_88 setDamage [1,TRUE];

sleep 2;

thunderMk12 spawn {
  _pos = getPosATL _this;
  _bolt = createvehicle ["LightningBolt",[0,0,0],[],0,"CAN_COLLIDE"];
  _bolt setposatl _pos;
  _bolt setdamage 1;
  if (_this isKindOf "CAManBase") then {_this addForce [_this vectorModelToWorld [0,0,3000], _this selectionPosition "rightfoot"]};
  _light = "#lightpoint" createvehicle _pos;
  _lightCode = compileFinal "
    params ['_light','_pos'];
    _light setposatl [_pos select 0,_pos select 1,(_pos select 2) + 10];
    _light setLightDayLight true;
    _light setLightBrightness 300;
    _light setLightAmbient [0.05, 0.05, 0.1];
    _light setlightcolor [1, 1, 2];
    sleep 0.9;
    _light setLightBrightness 0;
  ";
  [_light,_pos] remoteExec ["_lightCode"];
  sleep random 0.3;
  _class = selectRandom ["lightning1_F","lightning2_F"];
  _lightning = _class createvehicle [0,0,100];
  _lightning setdir random 360;
  _lightning setpos _pos;
  for "_i" from 0 to 3 + random 1 do {
    sleep 0.1;
    _bright = 100 + random 100;
    [_light,_bright] remoteExec ["setLightBrightness"];
  };
  deletevehicle _lightning;
  deletevehicle _light;
};


		_charge_11 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_11 setPosATL (thunderMk12 modelToWorldVisual [0,-7,-1]);
		_charge_11 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [0,-3,0]),[0,0,1]];
		_charge_11 setDamage [1,TRUE];
		_charge_22 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_22 setPosATL (thunderMk12 modelToWorldVisual [0,7,-1]);
		_charge_22 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [0,3,0]),[0,0,1]];
		_charge_22 setDamage [1,TRUE];
		_charge_33 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_33 setPosATL (thunderMk12 modelToWorldVisual [-7,0,-1]);
		_charge_33 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [-3,0,0]),[0,0,1]];
		_charge_33 setDamage [1,TRUE];
		_charge_44 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_44 setPosATL (thunderMk12 modelToWorldVisual [7,0,-1]);
		_charge_44 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [3,0,0]),[0,0,1]];
		_charge_44 setDamage [1,TRUE];
		
		_charge_55 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_55 setPosATL (thunderMk12 modelToWorldVisual [3,-7,-1]);
		_charge_55 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [7,-3,0]),[0,0,1]];
		_charge_55 setDamage [1,TRUE];
		_charge_66 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_66 setPosATL (thunderMk12 modelToWorldVisual [-3,7,-1]);
		_charge_66 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [-7,3,0]),[0,0,1]];
		_charge_66 setDamage [1,TRUE];
		_charge_77 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_77 setPosATL (thunderMk12 modelToWorldVisual [-7,3,-1]);
		_charge_77 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [-3,7,0]),[0,0,1]];
		_charge_77 setDamage [1,TRUE];
		_charge_88 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_88 setPosATL (thunderMk12 modelToWorldVisual [7,-3,-1]);
		_charge_88 setVectorDirAndUp [(thunderMk12 modelToWorld [0,0,0]) vectorFromTo (thunderMk12 modelToWorld [3,-7,0]),[0,0,1]];
		_charge_88 setDamage [1,TRUE];


sleep 2;

thunderMk13 spawn {
  _pos = getPosATL _this;
  _bolt = createvehicle ["LightningBolt",[0,0,0],[],0,"CAN_COLLIDE"];
  _bolt setposatl _pos;
  _bolt setdamage 1;
  if (_this isKindOf "CAManBase") then {_this addForce [_this vectorModelToWorld [0,0,3000], _this selectionPosition "rightfoot"]};
  _light = "#lightpoint" createvehicle _pos;
  _lightCode = compileFinal "
    params ['_light','_pos'];
    _light setposatl [_pos select 0,_pos select 1,(_pos select 2) + 10];
    _light setLightDayLight true;
    _light setLightBrightness 300;
    _light setLightAmbient [0.05, 0.05, 0.1];
    _light setlightcolor [1, 1, 2];
    sleep 0.9;
    _light setLightBrightness 0;
  ";
  [_light,_pos] remoteExec ["_lightCode"];
  sleep random 0.3;
  _class = selectRandom ["lightning1_F","lightning2_F"];
  _lightning = _class createvehicle [0,0,100];
  _lightning setdir random 360;
  _lightning setpos _pos;
  for "_i" from 0 to 3 + random 1 do {
    sleep 0.1;
    _bright = 100 + random 100;
    [_light,_bright] remoteExec ["setLightBrightness"];
  };
  deletevehicle _lightning;
  deletevehicle _light;
};


		_charge_11 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_11 setPosATL (thunderMk13 modelToWorldVisual [0,-7,-1]);
		_charge_11 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [0,-3,0]),[0,0,1]];
		_charge_11 setDamage [1,TRUE];
		_charge_22 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_22 setPosATL (thunderMk13 modelToWorldVisual [0,7,-1]);
		_charge_22 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [0,3,0]),[0,0,1]];
		_charge_22 setDamage [1,TRUE];
		_charge_33 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_33 setPosATL (thunderMk13 modelToWorldVisual [-7,0,-1]);
		_charge_33 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [-3,0,0]),[0,0,1]];
		_charge_33 setDamage [1,TRUE];
		_charge_44 = createVehicle ["ClaymoreDirectionalMine_Remote_Ammo",[0,0,0]];
		_charge_44 setPosATL (thunderMk13 modelToWorldVisual [7,0,-1]);
		_charge_44 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [3,0,0]),[0,0,1]];
		_charge_44 setDamage [1,TRUE];
		
		_charge_55 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_55 setPosATL (thunderMk13 modelToWorldVisual [3,-7,-1]);
		_charge_55 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [7,-3,0]),[0,0,1]];
		_charge_55 setDamage [1,TRUE];
		_charge_66 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_66 setPosATL (thunderMk13 modelToWorldVisual [-3,7,-1]);
		_charge_66 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [-7,3,0]),[0,0,1]];
		_charge_66 setDamage [1,TRUE];
		_charge_77 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_77 setPosATL (thunderMk13 modelToWorldVisual [-7,3,-1]);
		_charge_77 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [-3,7,0]),[0,0,1]];
		_charge_77 setDamage [1,TRUE];
		_charge_88 = createVehicle ["GrenadeHand",[0,0,0]];
		_charge_88 setPosATL (thunderMk13 modelToWorldVisual [7,-3,-1]);
		_charge_88 setVectorDirAndUp [(thunderMk13 modelToWorld [0,0,0]) vectorFromTo (thunderMk13 modelToWorld [3,-7,0]),[0,0,1]];
		_charge_88 setDamage [1,TRUE];	


 

 

Share this post


Link to post
Share on other sites

If that small script does what you want, you could just add more objects, from 1 to 16 as you have initially planned, then copy and paste the code and change all the variable names you find inside it.

For instance, keep the thunderMk1 / mk12 / mk13, and change all of them for every time you paste, using "z14", "thunder10" or whatever you like. You will notice that every variable name appears several times on each block of code, so you must change them all (I'd suggest "Find And Replace" function while in a nice editor like Notepad++).

But remember that such variable names MUST match the names you give to the invisible objects on mission editor - the ones marking places where you want the lightning strikes.

Play and mess with the delay time between each lightning, managed by those "sleep 2;" lines after every block.

And if you want the full blown at the end, you can just copy and paste it all over again, but removing such "sleep2;" lines so the script will apply all the lightnings again at once.
So the grand finale could be like this:
 

Spoiler



thunderMk1 spawn {
  _pos = getPosATL _this;
  _bolt = createvehicle ["LightningBolt",[0,0,0],[],0,"CAN_COLLIDE"];
  _bolt setposatl _pos;
  _bolt setdamage 1;
  if (_this isKindOf "CAManBase") then {_this addForce [_this vectorModelToWorld [0,0,3000], _this selectionPosition "rightfoot"]};
  _light = "#lightpoint" createvehicle _pos;
  _lightCode = compileFinal "
    params ['_light','_pos'];
    _light setposatl [_pos select 0,_pos select 1,(_pos select 2) + 10];
    _light setLightDayLight true;
    _light setLightBrightness 300;
    _light setLightAmbient [0.05, 0.05, 0.1];
    _light setlightcolor [1, 1, 2];
    sleep 0.9;
    _light setLightBrightness 0;
  ";
  [_light,_pos] remoteExec ["_lightCode"];
  sleep random 0.3;
  _class = selectRandom ["lightning1_F","lightning2_F"];
  _lightning = _class createvehicle [0,0,100];
  _lightning setdir random 360;
  _lightning setpos _pos;
  for "_i" from 0 to 3 + random 1 do {
    sleep 0.1;
    _bright = 100 + random 100;
    [_light,_bright] remoteExec ["setLightBrightness"];
  };
  deletevehicle _lightning;
  deletevehicle _light;
};

thunderMk12 spawn {
  _pos = getPosATL _this;
  _bolt = createvehicle ["LightningBolt",[0,0,0],[],0,"CAN_COLLIDE"];
  _bolt setposatl _pos;
  _bolt setdamage 1;
  if (_this isKindOf "CAManBase") then {_this addForce [_this vectorModelToWorld [0,0,3000], _this selectionPosition "rightfoot"]};
  _light = "#lightpoint" createvehicle _pos;
  _lightCode = compileFinal "
    params ['_light','_pos'];
    _light setposatl [_pos select 0,_pos select 1,(_pos select 2) + 10];
    _light setLightDayLight true;
    _light setLightBrightness 300;
    _light setLightAmbient [0.05, 0.05, 0.1];
    _light setlightcolor [1, 1, 2];
    sleep 0.9;
    _light setLightBrightness 0;
  ";
  [_light,_pos] remoteExec ["_lightCode"];
  sleep random 0.3;
  _class = selectRandom ["lightning1_F","lightning2_F"];
  _lightning = _class createvehicle [0,0,100];
  _lightning setdir random 360;
  _lightning setpos _pos;
  for "_i" from 0 to 3 + random 1 do {
    sleep 0.1;
    _bright = 100 + random 100;
    [_light,_bright] remoteExec ["setLightBrightness"];
  };
  deletevehicle _lightning;
  deletevehicle _light;
};

thunderMk13 spawn {
  _pos = getPosATL _this;
  _bolt = createvehicle ["LightningBolt",[0,0,0],[],0,"CAN_COLLIDE"];
  _bolt setposatl _pos;
  _bolt setdamage 1;
  if (_this isKindOf "CAManBase") then {_this addForce [_this vectorModelToWorld [0,0,3000], _this selectionPosition "rightfoot"]};
  _light = "#lightpoint" createvehicle _pos;
  _lightCode = compileFinal "
    params ['_light','_pos'];
    _light setposatl [_pos select 0,_pos select 1,(_pos select 2) + 10];
    _light setLightDayLight true;
    _light setLightBrightness 300;
    _light setLightAmbient [0.05, 0.05, 0.1];
    _light setlightcolor [1, 1, 2];
    sleep 0.9;
    _light setLightBrightness 0;
  ";
  [_light,_pos] remoteExec ["_lightCode"];
  sleep random 0.3;
  _class = selectRandom ["lightning1_F","lightning2_F"];
  _lightning = _class createvehicle [0,0,100];
  _lightning setdir random 360;
  _lightning setpos _pos;
  for "_i" from 0 to 3 + random 1 do {
    sleep 0.1;
    _bright = 100 + random 100;
    [_light,_bright] remoteExec ["setLightBrightness"];
  };
  deletevehicle _lightning;
  deletevehicle _light;
};		


 

 

Share this post


Link to post
Share on other sites

I can kinda see where the script is going, but for some reason it doesn't work quite like I had imagined. It also lags out the game and causes error messages to appear. I'll try tweaking my settings and playing with the values and see what I come up with. Thank you, at least it gives me a place to start. 

 

Share this post


Link to post
Share on other sites

Create a trigger with whatever conditions, activation and timings you like for each of the Lightning Modules and sync them.
Don't sync just a single trigger to all the modules. You need to have a trigger for each module.

Like so;

Spoiler

20241023063544_1.jpg?ex=6719dd28&is=6718


You'll need more modules than the example and even more for the final lightning display but you should have more of an idea now.

  • Like 1

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

×