Jump to content
Sign in to follow this  
stephsen

Question: loop a ammo effect modul ?

Recommended Posts

Hey Guys,

i have a question ,when i set in Arma3 the effect modul "ammo 82mm_He" then comes the impact in 6- 10 seconds , but i want repeat this effect with a script or similar maybe with random intervals.

Is that possible ?

Thanks

Share this post


Link to post
Share on other sites

I am not sure about this but I think the module is only meant to activate once.

It would be easier to just spawn rounds using createVehicle and setVelocity and use a while loop with random sleep intervals.

The following code spawns red flares every 30-60 seconds at random locations around the marker "IOT_FlarePos_1" as long as "IOT_SpawnFlare_1 == true". Feel free to adapt as you see fit.

//Spawn flares function
IOT_SpawnFlare = {
_pos 		= [_this,0,[0,0,0],[[]]] call BIS_fnc_param;
_height 	= [_this,1,150,[0]] call BIS_fnc_param;
_radius 	= [_this,2,100,[0]] call BIS_fnc_param;
_class 		= [_this,3,"F_40mm_Red",[""]] call BIS_fnc_param;
_speed 		= [_this,4,15,[0]] call BIS_fnc_param;
_fallSpeed	= [_this,5,-1,[0]] call BIS_fnc_param;

_rx = random _speed;
_ry = sqrt(_speed*_speed - _rx*_rx);

if (random 1 > 0.5) Then {
	_rx = - _rx;
};
if (random 1 > 0.5) Then {
	_ry = - _ry;
};

_velocity = [_rx,_ry,_fallSpeed];

_pos set [2,(_pos select 2) + _height];

_flare = createVehicle [_class, _pos, [], _radius, "FLY"];
_flare setVelocity _velocity;
};

//Spawning flares at random intervals
[] spawn {
sleep 20;
IOT_SpawnFlare_1 = true;
[] spawn {
	waitUntil {sleep 1; missionNamespace getVariable ["IOT_SpawnFlare_1",false]};
	while {missionNamespace getVariable ["IOT_SpawnFlare_1",false]} do {
		[markerPos "IOT_FlarePos_1", 150, 50, "F_40mm_Red",15,-0.1] spawn IOT_SpawnFlare;
		sleep ((random 30) + 30);
	};
};
};

Share this post


Link to post
Share on other sites
I am not sure about this but I think the module is only meant to activate once.

It would be easier to just spawn rounds using createVehicle and setVelocity and use a while loop with random sleep intervals.

The following code spawns red flares every 30-60 seconds at random locations around the marker "IOT_FlarePos_1" as long as "IOT_SpawnFlare_1 == true". Feel free to adapt as you see fit.

//Spawn flares function
IOT_SpawnFlare = {
_pos 		= [_this,0,[0,0,0],[[]]] call BIS_fnc_param;
_height 	= [_this,1,150,[0]] call BIS_fnc_param;
_radius 	= [_this,2,100,[0]] call BIS_fnc_param;
_class 		= [_this,3,"F_40mm_Red",[""]] call BIS_fnc_param;
_speed 		= [_this,4,15,[0]] call BIS_fnc_param;
_fallSpeed	= [_this,5,-1,[0]] call BIS_fnc_param;

_rx = random _speed;
_ry = sqrt(_speed*_speed - _rx*_rx);

if (random 1 > 0.5) Then {
	_rx = - _rx;
};
if (random 1 > 0.5) Then {
	_ry = - _ry;
};

_velocity = [_rx,_ry,_fallSpeed];

_pos set [2,(_pos select 2) + _height];

_flare = createVehicle [_class, _pos, [], _radius, "FLY"];
_flare setVelocity _velocity;
};

//Spawning flares at random intervals
[] spawn {
sleep 20;
IOT_SpawnFlare_1 = true;
[] spawn {
	waitUntil {sleep 1; missionNamespace getVariable ["IOT_SpawnFlare_1",false]};
	while {missionNamespace getVariable ["IOT_SpawnFlare_1",false]} do {
		[markerPos "IOT_FlarePos_1", 150, 50, "F_40mm_Red",15,-0.1] spawn IOT_SpawnFlare;
		sleep ((random 30) + 30);
	};
};
};

Hey ted,

that looks superb thanks man :)

but how it works ? ...maybe I create a init with this commandline and insert these in my mission folder,or i set a trigger in the game-editor and write in the activation field this commandline ?

then i go in the game-editor ,set a marker with this commandline "IOT_FlarePos_1" as long as "IOT_SpawnFlare_1 == true" ?

am really a script noob ^^

Share this post


Link to post
Share on other sites

The easiest way to do this would be to put the first part in your init.sqf.

//Spawn flares function
IOT_SpawnFlare = {
_pos 		= [_this,0,[0,0,0],[[]]] call BIS_fnc_param;
_height 	= [_this,1,150,[0]] call BIS_fnc_param;
_radius 	= [_this,2,100,[0]] call BIS_fnc_param;
_class 		= [_this,3,"F_40mm_Red",[""]] call BIS_fnc_param;
_speed 		= [_this,4,15,[0]] call BIS_fnc_param;
_fallSpeed	= [_this,5,-1,[0]] call BIS_fnc_param;

_rx = random _speed;
_ry = sqrt(_speed*_speed - _rx*_rx);

if (random 1 > 0.5) Then {
	_rx = - _rx;
};
if (random 1 > 0.5) Then {
	_ry = - _ry;
};

_velocity = [_rx,_ry,_fallSpeed];

_pos set [2,(_pos select 2) + _height];

_flare = createVehicle [_class, _pos, [], _radius, "FLY"];
_flare setVelocity _velocity;
};

And then put the second part in the onActivation field of a trigger. When you activate this trigger flares should start spawning in 20 seconds.


//Spawning flares at random intervals
[] spawn {
sleep 20;
IOT_SpawnFlare_1 = true;
[] spawn {
	waitUntil {sleep 1; missionNamespace getVariable ["IOT_SpawnFlare_1",false]};
	while {missionNamespace getVariable ["IOT_SpawnFlare_1",false]} do {
		[markerPos "IOT_FlarePos_1", 150, 50, "F_40mm_Red",15,-0.1] spawn IOT_SpawnFlare;
		sleep ((random 30) + 30);
	};
};
};

Then create a second trigger, and put this into its activation field. When this trigger fires flares stop spawning.

IOT_Spawnflare_1 = false;

And do remember to create a marker (F6) in the editor called "IOT_Flarepos_1" where you want your flares to spawn.

If you want mortar rounds just set spawn height to 0. In the second part of the script you can change the parameters for the spawn flare function.

//Change:
[markerPos "IOT_FlarePos_1", 150, 50, "F_40mm_Red",15,-0.1] spawn IOT_SpawnFlare;
//To:
[markerPos "IOT_FlarePos_1", 0, 50, "ammo 82mm_He",15,-0.1] spawn IOT_SpawnFlare;

I have not tested this on mortar rounds so you might have to adjust the params a bit. They are:

[spawn position, Spawn height, Random spawn radius, Ammo Classname, Horizontal speed (direction is random), Vertical speed]

Hope this helps. Cheers!

Share this post


Link to post
Share on other sites

My SMS and SFS systems may be of use to you (linked in my signature below).

Share this post


Link to post
Share on other sites

Oh thanks guys for the good answers ,i will both thoroughly test and then report back.

Share this post


Link to post
Share on other sites
OR you could just use a looping trigger, duh.

Who needs all that code? But, you asked scripters so OK.

how do you mean, a looping trigger without scripts ? how does this work ?

Share this post


Link to post
Share on other sites

Its my SECRET.

Jk, gimme like 2 min Ill get it.

---------- Post added at 21:59 ---------- Previous post was at 21:45 ----------

Create 1 trigger

Size: 0/0

Condition: conditiontime<time

Activation: conditiontime = time + 10

Set time mode to "Timeout"

Set a number, so for 40 second difference put 40 in all the spots for # under timeout (min, max, etc)

-----------Create a 2nd trigger----------

Size 0/0

condition: true

activation: conditiontime = time;

------------------------------------------

Link the 1st trigger with your module. I used this a bit differently, but tell me if it works (it should).

Share this post


Link to post
Share on other sites

Great dude :D, i will test it as soon as possible and I will refund immediately report...but first I need to sleep.

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  

×