Jump to content
Sign in to follow this  
KingoftheSandbox

Zeus Lightning without module

Recommended Posts

found the function/script, how could i implement that in my mission without having zeus as depency?

dont know how to call the lighning on a gamelogic via trigger for example.

/*
Author: Karel Moricky

Description:
Zeus lightning strike

Parameter(s):
http://community.bistudio.com/wiki/Arma_3_Modules

Returns:
NONE
*/

_logic = _this select 0;
_activated = _this select 2;
if (_activated) then {
_pos = position _logic;
_dir = _logic getvariable ["dir",random 360];

//--- Play sound (tied to the explosion effect)
if (local _logic || {local _x} count (objectcurators _logic) > 0) then { //--- ToDo: Find out why 'local' returns false
	_bolt = createvehicle ["LightningBolt",_pos,[],0,"can collide"];
	_bolt setposatl _pos;
	_bolt setdamage 1;
};

_light = "#lightpoint" createvehiclelocal _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.1;
_light setLightBrightness 0;
sleep (random 0.1);

_class = ["lightning1_F","lightning2_F"] call bis_Fnc_selectrandom;
_lightning = _class createvehiclelocal [100,100,100];
_lightning setdir _dir;
_lightning setpos _pos;

_cursorTarget = _logic getvariable ["bis_fnc_curatorAttachObject_object",objnull];
_duration = if (isnull _cursorTarget) then {(3 + random 1)} else {1};

for "_i" from 0 to _duration do {
	_time = time + 0.1;
	_light setLightBrightness (100 + random 100);
	waituntil {
		//--- Attach to target under cursor
		if (local _logic && !isnull _cursorTarget) then {_lightning setpos position _cursorTarget;};
		time > _time
	};
};

deletevehicle _lightning;
deletevehicle _light;

//--- Disable engine lightnings
0 setlightnings 0;

//--- Delete curator placed module
if (count objectcurators _logic > 0) then {
	deletevehicle _logic;
};

//--- Save variable for outside use
if (_logic call bis_fnc_isCuratorEditable) then {
	uinamespace setvariable ["bis_fnc_moduleLightning_created",true];
};
};

Share this post


Link to post
Share on other sites

Try implementing this function and see if it does what you are asking, maybe even with some modifications.

zlb_target = {
private ["_targeter","_lasertarget","_center","_group","_zlb","_pos"];
_targeter = _this select 0;
_lasertarget = laserTarget _targeter;
if (isNull _lasertarget) exitWith {hint "No target selected !"};
_pos = getPos _lasertarget;
_center = createCenter sideLogic;    
_group = createGroup _center;
_list = nearestObjects [_lasertarget, ["MAN","CAR","TANK","AIR"],10];
_zlb = _group createUnit ["ModuleLightning_F",_lasertarget,[],0,""];
{
	_x setDamage 1;
} forEach _list;
};

Or maybe a onMapSingleClick application:

// Dialog Support TEMPLATE
// onMapSingleClick -->  BIS_fnc_addStackedEventHandler
// 
// Zeus Lightning Bolt
// 
//
//////////////////////////////////////////////////
private ["_caller"];
_caller = _this select 0;
omsz = false;

titleText ["Open Map and Click on Zeus Lightning Bolt Target location.", "PLAIN"];

["mk_zeuslb", "onMapSingleClick", {
titleText ["", "PLAIN"];

_center = createCenter sideLogic;    
_group = createGroup _center;  
_target = getPos (nearestObject _pos);
_zlb = _group createUnit ["ModuleLightning_F",_target,[],0,""];

["mk_zeuslb", "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
omscz = true;
true;
}] call BIS_fnc_addStackedEventHandler; 

Share this post


Link to post
Share on other sites
how would i define and call the first function? sorry but its late here=)^^

for the function call, usse an addAction like this:

place the above function in an sqf file and call it zlb_target.sqf then

In your mission's init.sqf:

[] spawn compile PP "scripts\zlb_target.sqf"; 

then call the function from a trigger, radio, or action_menu_script.sqf

player addAction ["<t color='#FF0000'>Zeus LB Target</t>", {[[player],'zlb_target',true,false] spawn BIS_fnc_MP}, [player], 1, false, true, ""]; 

Edited by tomturner

Share this post


Link to post
Share on other sites

this is working, but i think you understood me wrong.

want it really simple. some gamelogics i give variables & then call the lightning there via trigger with blufor present

Edited by KingoftheSandbox

Share this post


Link to post
Share on other sites

sorry if it doesn't pertain but, this is what I use for ambient lightning, it was from a BI mission, and I have altered it slightly

//Parameters
private ["_position", "_direction", "_distance"];
_position 	= [_this, 0, position player, [[]]] call BIS_fnc_param;
_distance	= [_this, 1, 500, [0]] call BIS_fnc_param;
_direction 	= [_this, 2, random 360, [0]] call BIS_fnc_param;

//Relative positionn
private "_relativePosition";
_relativePosition = [_position, _distance, _direction] call bis_fnc_relPos;

//The bold
private "_bolt";
_bolt = createvehicle ["LightningBolt", _relativePosition, [], 0, "can_collide"];
_bolt setVelocity [0, 0, -10];

//The lighting
_lighting = "lightning_F" createvehiclelocal _relativePosition;
_lighting setdir random 360;
_lighting setpos _relativePosition;

//The light source
_light = "#lightpoint" createvehiclelocal _relativePosition;
_light setpos _relativePosition;
_light setLightBrightness 30;
_light setLightAmbient [0.5, 0.5, 1];
_light setlightcolor [1, 1, 2];

//Some delay
sleep (0.2 + random 0.1);

//Clean up
deletevehicle _bolt;
deletevehicle _light;
deletevehicle _lighting;

//Some delay
sleep (1 + random 1);

//Random thunder sample
private "_thunder";
_thunder = ["thunder_1", "thunder_2"] call BIS_fnc_selectRandom;

//Play thunder sound
playSound _thunder; 

Share this post


Link to post
Share on other sites

Don't know if this is already solved for you but the easiest way is to set-up a gamelogic and then use:

nul = [GL, nil, true] spawn BIS_fnc_moduleLightning;

Share this post


Link to post
Share on other sites

IndeedPete's instructions with fnc_moduleLightning isn't working for you? Did you name your gamelogic GL or replace the GL in the spawn parameters to this or the name of your game logic?

Share this post


Link to post
Share on other sites

Was the problem solved? Is it possible to combine PlacidPaul's

//Parameters

private ["_position", "_direction", "_distance"];

_position = [_this, 0, position player, [[]]] call BIS_fnc_param;

_distance = [_this, 1, 500, [0]] call BIS_fnc_param;

_direction = [_this, 2, random 360, [0]] call BIS_fnc_param;

//Relative positionn

private "_relativePosition";

_relativePosition = [_position, _distance, _direction] call bis_fnc_relPos;

//The bold

private "_bolt";

_bolt = createvehicle ["LightningBolt", _relativePosition, [], 0, "can_collide"];

_bolt setVelocity [0, 0, -10];

//The lighting

_lighting = "lightning_F" createvehiclelocal _relativePosition;

_lighting setdir random 360;

_lighting setpos _relativePosition;

//The light source

_light = "#lightpoint" createvehiclelocal _relativePosition;

_light setpos _relativePosition;

_light setLightBrightness 30;

_light setLightAmbient [0.5, 0.5, 1];

_light setlightcolor [1, 1, 2];

//Some delay

sleep (0.2 + random 0.1);

//Clean up

deletevehicle _bolt;

deletevehicle _light;

deletevehicle _lighting;

//Some delay

sleep (1 + random 1);

//Random thunder sample

private "_thunder";

_thunder = ["thunder_1", "thunder_2"] call BIS_fnc_selectRandom;

//Play thunder sound

playSound _thunder;

code with this zeus lighting

ModuleLightning_F

and it will also do damage?

Share this post


Link to post
Share on other sites

Why would you want to combine it? Without taking a closer look I'd say both scripts have similiar outcome. Only difference is that the Zeus lightning will cause extensive damage on the position where it is called.

Share this post


Link to post
Share on other sites

PlacidPaul's lightining is in the air and never comes to land, and the zeus's lightinig is coming from the air to land, dinamically creating danger.

Share this post


Link to post
Share on other sites

Yeah, my example really is only for ambient effect. Although it wasn't completely relevant to thread I thought it was useful. It's advantage would be that you could create a lighting storm when you want with the intensity you want. This is his BI used it.

Share this post


Link to post
Share on other sites

Thanks for all above! I've got this script working, which is giving random Zeus lightnings to the position of gamelogic "GL":

"SurfersStrobeLightning.sqf"

 

spawn {
 while {true} do {

nul = [GL, nil, true] spawn BIS_fnc_moduleLightning;

randomInterval = [0.5, 2, 5] call BIS_fnc_selectRandom;

sleep randomInterval;

 };
};

However I'm calling it from the init.sqf with this _nul = [player] execVM "SurfersStrobeLightning.sqf" but I would like to activate it from a trigger and most importantly deactivate it once the player is leaving the trigger area.

And as a second request, could you teach me how to trigger this as an alternative? I don't get it visible:

_bolt = createvehicle ["LightningBolt", _pos, [], 0, "can collide"]; 

or this from the init of an invisible object:

MyBolt = createvehicle ["LightningBolt", getpos this, [] ,0 ,"can collide"]; 

As a third question, would you know if this is safe in MP and JIP compatible since these are still Bömische Wälder for me.

Thanks a lot in advance!

Surf

Share this post


Link to post
Share on other sites

Might not be the answer you're looking for but you could also integrate that into the GL aproach I sent you the other day. :) (Sorry to any confused readers, it's about a PM conversation I had with Surfer.)

Share this post


Link to post
Share on other sites

Ah yeah, I totally put that aside when I moved back to the triggered option (to confuse readers even more). Will give it a try, you see I'm doing my first humble scripts ;-)

Share this post


Link to post
Share on other sites

Sure, but a lightning trigger should exactly work like the other triggers we've created for your mission. Still expecting MP issues though.^^

Share this post


Link to post
Share on other sites

"SurfersStrobeLightning.sqf"

 

spawn {
 while {true} do {

nul = [GL, nil, true] spawn BIS_fnc_moduleLightning;

randomInterval = [0.5, 2, 5] call BIS_fnc_selectRandom;

sleep randomInterval;

 };
};

However I'm calling it from the init.sqf with this _nul = [player] execVM "SurfersStrobeLightning.sqf" but I would like to activate it from a trigger and most importantly deactivate it once the player is leaving the trigger area.

Surf

To follow this up: I managed to exit the above .sqf via the command "if (ArgumentThatTurnsTrue) then exitWith {}" from inside the .sqf

So I've got my script working but if anybody could clear how the below can be made visible I would be grateful!

_bolt = createvehicle ["LightningBolt", _pos, [], 0, "can collide"];  

or this from the init of an invisible object: 

MyBolt = createvehicle ["LightningBolt", getpos this, [] ,0 ,"can collide"];

Share this post


Link to post
Share on other sites
sorry if it doesn't pertain but, this is what I use for ambient lightning, it was from a BI mission, and I have altered it slightly

Sorry for the bump. I'm simply wondering how I would use this script in a mission (I only need to preview it in the editor).

Share this post


Link to post
Share on other sites

I'm not very good at this but maybe the below will help your progress:

- Create a gamelogic item called GL in the editor.

- Create a radiotrigger for testing reasons.

- Inside this trigger put on activation:

    nul = [GL, nil, true] spawn BIS_fnc_moduleLightning;

The lightning should strike at the position of your GL.

This is not tested, so anybody please correct me if it doesn't work.

Share this post


Link to post
Share on other sites
I'm not very good at this but maybe the below will help your progress:

- Create a gamelogic item called GL in the editor.

- Create a radiotrigger for testing reasons.

- Inside this trigger put on activation:

    nul = [GL, nil, true] spawn BIS_fnc_moduleLightning;

The lightning should strike at the position of your GL.

This is not tested, so anybody please correct me if it doesn't work.

That works absolutely fine. I just wish I could create a somewhat realistic looking storm, but I appreciate your help!

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  

×