Jump to content
Sign in to follow this  
RenwickCustomer

Trigger activated carpet bombing script

Recommended Posts

I've been attempting to make a carpet bombing script for a mission.

At the moment i've been using this code:

_theObject = _this select 0

_ammotype = "Bo_GBU12_LGB"

_bombLoc = GetPos _theObject
_bombLocX = _bombLoc select 0
_bombLocY = _bombLoc select 1
_bombLocZ = _bombLoc select 2


_ammoType createVehicle[_bombLocX, _bombLocY, _bombLocZ+50]
~0.1
_ammoType createVehicle[_bombLocX+15, _bombLocY+15, _bombLocZ+50]
~0.1
_ammoType createVehicle[_bombLocX+25, _bombLocY+25, _bombLocZ+50]
~0.1
_ammoType createVehicle[_bombLocX+35, _bombLocY+35, _bombLocZ+50]
~0.1
_ammoType createVehicle[_bombLocX+45, _bombLocY+45, _bombLocZ+50]
~0.1
_ammoType createVehicle[_bombLocX+55, _bombLocY+55, _bombLocZ+50]
~0.1
_ammoType createVehicle[_bombLocX+65, _bombLocY+65, _bombLocZ+50]


exit

But it seems fairly inefficient (I have to get the coords exactly right, and there is only one row of bombs instead of two). I'm not amazing at scripting by any means, so I was wondering if there was a way to make it better. Is there a way to make it so it just has an equal distance added to the last bomb? A way to set the initial direction of the carpet bomb and have it go from there? This is literally way out of my depth but any help would be very very apprieciated. (and help me learn)

PS I know the height and distances are really strange but I was just attempting to see if it works

Rereading this it looks like i'm doing a 'write my script for me' but it's not my intention. Any hints on what to do or anything would be really apprieciated.

---------- Post added at 03:51 PM ---------- Previous post was at 03:21 PM ----------

OK so far I have got this:

_theObject = _this select 0
_direction = _this select 1
_velocity = _this select 2

_ammotype = "Bo_GBU12_LGB"

_bombLoc = GetPos _theObject
_bombLocX = _bombLoc select 0
_bombLocY = _bombLoc select 1
_bombLocZ = _bombLoc select 2



_ammoType createVehicle[_bombLocX, _bombLocY, _bombLocZ+50] setDir _direction setVelocity[_velocity, 0, 0]
~0.1
_ammoType createVehicle[_bombLocX+15, _bombLocY+15, _bombLocZ+50] setDir _direction setVelocity[_velocity, 0, 0]
~0.1
_ammoType createVehicle[_bombLocX+25, _bombLocY+25, _bombLocZ+50] setDir _direction setVelocity[_velocity, 0, 0]
~0.1
_ammoType createVehicle[_bombLocX+35, _bombLocY+35, _bombLocZ+50] setDir _direction setVelocity[_velocity, 0, 0]
~0.1
_ammoType createVehicle[_bombLocX+45, _bombLocY+45, _bombLocZ+50] setDir _direction setVelocity[_velocity, 0, 0]
~0.1
_ammoType createVehicle[_bombLocX+55, _bombLocY+55, _bombLocZ+50] setDir _direction setVelocity[_velocity, 0, 0]
~0.1
_ammoType createVehicle[_bombLocX+65, _bombLocY+65, _bombLocZ+50] setDir _direction setVelocity[_velocity, 0, 0]


exit

The setDir works, but the setVelocity command doesn't. I think it's the right command? I'm not sure. Even then I've just realised that it's not going to set the speed of the direction it's facing. arrrrgh

Edited by RenwickCustomer

Share this post


Link to post
Share on other sites

dont know if this helps. but here is my CarpetBomb script i use on a c130J

if (getpos player select 2 < 100) exitwith {vehicle player vehiclechat "you cant not drop bombs below 100M";};

if (!NUX_C130_CB) exitwith {vehicle player vehiclechat "you have no more bombs, you need to reloade the bombs to drop more.";};

NUX_C130_CB=false;
for [{_i=0},{_i<28},{_i=_i+1}] do
{
_pos = getpos vehicle player;
_vel = velocity vehicle player;
_rng = 1;

// left side of plane
_dir1 = (direction vehicle player)-90;
_pos1 = [(_pos select 0)+(sin _dir1*_rng),(_pos select 1)+(cos _dir1*_rng),(_pos select 2)-2];

// right side of plane
_dir2 = (direction vehicle player)+90;
_pos2 = [(_pos select 0)+(sin _dir2*_rng),(_pos select 1)+(cos _dir2*_rng),(_pos select 2)-2];


_bomb1 = "Bo_GBU12_LGB" createvehicle _pos1;
[_bomb1,[(getdir vehicle player),(asin(vectordir vehicle player select 2)),0]] call setVector;
_bomb1 setvelocity [_vel select 0,_vel select 1,(_vel select 2) - 15];

_bomb2 = "Bo_GBU12_LGB" createvehicle _pos2;
[_bomb2,[(getdir vehicle player),(asin(vectordir vehicle player select 2)),0]] call setVector;
_bomb2 setvelocity [_vel select 0,_vel select 1,(_vel select 2) - 15];

//Bo_GBU12_LGB
//Bo_Mk82

sleep 0.2;

};

but as you see i got a custom function for setting the vector for the bombs.

call setVector;

i guess you can use the bis functions instead.

BIS_fnc_getPitchBank
BIS_fnc_setPitchBank

this drops 2 rows of bombs. a total of 56 bombs. "28 *2" :)

Share this post


Link to post
Share on other sites

So this runs off a player flown C130? It has certainly helped me with understanding scripts (especially looping, which i have been looking for :)).

The problem is that I will have a static starting point, so I can't just have the getpos player to use as a point to create the bombs.

Maybe I could make an invincible C130 spawn then drop them using the same idea as your script? I might give that a go. Thanks for this dude.

Share this post


Link to post
Share on other sites

Thanks kylania, until about 2 minutes ago the first result wasn't applicable to me, but now that i've changed what i'm going to do it's more helpful.

And I didn't find the other result! Thankyou very much thats going to make it a lot easier. Sorry for that, I think I made the thread in a little too much of a rush.

Share this post


Link to post
Share on other sites
So this runs off a player flown C130?

yes..

Maybe I could make an invincible C130

why not just use invincible helipad

so in your script you refere to the pos of the invincible helipad.. just set the hight a bit up.

if you only want the effect of how it looks like you can use something like this

_rng = 10;
for [{_i=0},{_i<28},{_i=_i+1}] do
{
_pos = getpos ihp;
_dir1 = (direction ihp);
_pos1 = [(_pos select 0)+(sin _dir1*_rng),(_pos select 1)+(cos _dir1*_rng),1];
_bomb1 = "Bo_GBU12_LGB" createvehicle _pos1;
_rng = _rng + 10;
sleep 0.2;
};

where ihp is the name of the invincible helipad

Share this post


Link to post
Share on other sites

OK,

So I just set it up, put that code into bombtest.sqs and put down an invisible H, called it ihp. I made a radio trigger with

this exec "bombtest.sqs"

However, when I activate the radio trigger, nothing happens. I assume i'm missing something really obvious?

Share this post


Link to post
Share on other sites

on act of the trigger use

CB = [b]execvm[/b] "bombtest.sqf"

and dont mix up sqs & sqf files :p

i see your script is in old sqs. if your new to learning scripting in arma(2) go for sqf

as its superior to the old sqs

Edited by nuxil

Share this post


Link to post
Share on other sites

Wow, that really worked.

That's really impressive!

OK, now i'll go and mess around using that other script you posted to make two rows.

Thank you so much for helping a newbie out here, and thanks for telling me about the sqf, I thought I read somewhere that the sqs was the new one to use, durrr. :)

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  

×