Jump to content
reggaeman007jah

Can i generate explosions ahead of my position..? [solved]

Recommended Posts

So hello people, again I come looking for some advice.

 

I have been thinking for some time about how I can create some sort of hacky artillery script, allowing the player to simply initiate a spread of explosions ahead of their position using a radio trigger (and then maybe via a GUI when I get a bit braver). I know I can of course use in-game modules for artillery, but I'm trying to learn the ways of sqf so I'm interested in exploring this..

 

OK, so my question is: Can I generate an array of flares using the code below, and then make the flares explode (as if I was to run an IED/explosion script with the explosion linked to an object).

 

To expand slightly, I know how to generate IED explosions, and they are always (as far as I can tell) linked to named objects (e.g. water bottle, car etc). So I was thinking, I know how to generate flares ahead of my position. Could I generate the flares, and then use those flares as objects for explosions? 

 

If this were possible, I assume I'd need to name each flare, before I could link an explosion to it, and I have no idea how to do that. I also don't know if this is even needed - maybe I can simply generate map markers ahead of me, and link the explosions to those markers..?

 

Any advice would be greatly appreciated..

 

(ps, I have another thread running, linked to this subject, but this is a slightly different question).

 

Cheers dudes 

 

Flares:

Spoiler

flrObj = "F_40mm_white" createvehicle ((player) ModelToWorld [-20,050,100]); 
flrObj setVelocity [0,0,-5];   
flrObj = "F_40mm_white" createvehicle ((player) ModelToWorld [20,100,110]); 
flrObj setVelocity [0,0,-5];

// etc

 

*** EDIT ***

 

So a bit more research established that a solid way to trigger an explosion is to link it to a named vehicle, like this:

Spoiler

bomb="Bo_GBU12_LGB" createVehicle (getPos FLARE);

// FLARE is the name of the vehicle, and in this case I am assuming to link it to a flare I have spawned using the above script

 

So my guess is something along these lines...

 

bomb = "Bo_GBU12_LGB" createvehicle ((player) ModelToWorld [-20,050,100]); 

 

Gonna test it now.. :)

 

*** EDIT ***

 

So I think I have answered my own question - this works :)

 

Probably very obvious to you experienced coders, but not me lol.. anyway, to summarise (for the benefit of anyone else not very good at coding), this allows you to generate bombs ahead of your position. 

 

I want to try to work out an array of these, to be triggered simultaneously, so if I get any mileage on that Ill post back my results.

 

Cheers :)

 

*** Final Edit ***

 

OK, I am only posting this up in case it is of use to any newbie scripter, like myself :)

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

You can try something like this. May work a bit better depending on what you are looking for:

 

I put it in my init.sqf file:
 

Spoiler

 


Create_flare_bombs = {

	params ["_Obj","_howmany"];

	for "_i" from 1 to _howmany do {

		_pos = (_obj getPos [random 100, random 360]);
		_pos = [(_pos select 0),(_pos select 1),(75 + random 35)];

		private ["_flrObj"];
		_flrObj = createVehicle ["F_40mm_white", _pos, [], 0, "FLY"];
		_flrObj setVelocity [0,0,-10];

		_flrObj spawn {
			params ["_flrObj"];
			sleep 1;
			_timer = time + 14;
			WaitUntil {(getPosATL _flrObj) select 2 <=1 || time >_timer};
			_hitpos = [((getPos _flrObj) select 0),((getPos _flrObj) select 1),1];
			_bomb= createVehicle  ["Bo_GBU12_LGB", _hitpos, [], 0, "none"];
			_bomb setVelocity [0,0,-500];
			deleteVehicle _flrObj;
			hint "boom";

		};
		sleep random 1;
	};

};

 

 

I placed 1 civilian on map as my target and named him beggerm

 

Call it through init, a trigger, or by another script with this:

 

bustuup = [beggerm, 5] call Create_flare_bombs;

 

My internet is to slow to show the results with a video, but try it out and see maybe you'll like it. ;)

  • 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

×