Jump to content
Sign in to follow this  
norm6669

Line of explosive, kinda like airstrike

Recommended Posts

It is so beautiful and simple, I thought I'd share the picture and the script with you.

http://www.pnorm.net/Boom.jpg

To simplify the script, I made it so the marker Boom1 must be WEST of the marker Boom2... just think about the reading direction for an easy remainder.

xBoom = (getMarkerPos "Boom1" select 0);
yBoom = (getMarkerPos "Boom1" select 1);

xLimit = (getMarkerPos "Boom2" select 0);

angle = atan( ( (getMarkerPos "Boom2" select 1) - yBoom ) / ( xLimit - xBoom ) );

xStep = (cos angle) * 10;
yStep = (sin angle) * 10;

while {xBoom <= xLimit} do {
bomb = "HelicopterExploBig" createvehicle [xBoom, yBoom, 0];
bomb = "ARTY_R_227mm_HE" createvehicle [xBoom, yBoom, 0];

xBoom = xBoom + xStep;
yBoom = yBoom + yStep;
}

You computer might jerk a little when you make long lines of explosives.

Edited by norm6669

Share this post


Link to post
Share on other sites

BabyAlien had an example like this in one of his videos, it was in SQS and featured less math and less PC crushing* instantanity, but here it is in SQF for comparison sake:

[color="SeaGreen"]//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: [KH]BabyAlien
// Converted to SQF by: 1ID-CPL. Venori
//////////////////////////////////////////////////////////////////

// Example script call --> nul = [theCar, howmany] execVM "napalm.sqf"
// using too many howmanys (eg 500) might cause lag :D

// start script

// grab the variables passed to the script [object, num][/color]
_theObject = _this select 0;
_howmany = _this select 1;

[color="SeaGreen"]// locate the first helepad to start bombing[/color]
_bombLoc =  GetPos _theObject; [color="SeaGreen"]// positions are a 3 digit array. For ex: [4,3,0] [/color]
_bombLocX = _bombLoc select 0; [color="SeaGreen"]// the first number being X axis (West/East)[/color]
_bombLocY = _bombLoc select 1; [color="SeaGreen"]// the second number being Y axis (South/North)[/color]
_bombLocZ = _bombLoc select 2; [color="SeaGreen"]// the third number being Z axis (Height above ground)[/color]

[color="SeaGreen"]// locate the end position to start bombing[/color]
_bombfinish = GetPos bombend;  [color="SeaGreen"]// Be sure to preplace an object called "bombend" where you want the bombing to stop.[/color]
_bombfinishX = _bombfinish select 0;
_bombfinishY = _bombfinish select 1;
_bombfinishZ = _bombfinish select 2;

[color="SeaGreen"]// find out the distances on both X & Y coordinates between start and finish[/color]
_shiftx = _bombfinishX - _bombLocX;
_shifty = _bombfinishY - _bombLocY;

[color="SeaGreen"]// find out the distance in gap between each bomb dropping[/color]
_shiftx = _shiftx / _howmany;
_shifty = _shifty / _howmany;

[color="SeaGreen"]// Creating the bombs, detonating them and moving along each gap counting down until
// less than 1 bomb remains (which should be 0) and then it exits (stops the bombing run)[/color]
while  {_howmany > 0} do {
"Bo_GBU12_LGB" createVehicle[_bombLocX, _bombLocY, _bombLocZ];
_theObject setdammage 1;
_howmany = _howmany - 1;
sleep 0.15;
_bombLocX = _bombLocx + _shiftx;
_bombLocY = _bombLocY + _shiftY;

};

Edited by kylania
* The PC crushing isn't from the math, it's from creating n * 2 explosions simultaneously across whatever distance you've set

Share this post


Link to post
Share on other sites

First, ONE atan, ONE sin and ONE cos isn't too much crushing for a PC... The while loop doesn't include difficult calculation and is similar to BabyAlien's.

Second, Baby's calculations are based on "howmany" bombs. Mine are based on distance between bomb (10m).

Third, both example work, in a different way. I prefer my code as it allow me to make explosive field of various dimension while keeping the bomb density constant.

(I also like the elegance of my code but I guess everyone prefer his own code)

Share this post


Link to post
Share on other sites
First, ONE atan, ONE sin and ONE cos isn't too much crushing for a PC... The while loop doesn't include difficult calculation and is similar to BabyAlien's.

Second, Baby's calculations are based on "howmany" bombs. Mine are based on distance between bomb (10m).

Third, both example work, in a different way. I prefer my code as it allow me to make explosive field of various dimension while keeping the bomb density constant.

(I also like the elegance of my code but I guess everyone prefer his own code)

You have no sleep command in your while loop. That will cause an issue as alot of things are tring to generate in a very small amount of time.

I'd recommend adding a small sleep. Its probably what the other poster meant.

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  

×