Jump to content
Sign in to follow this  
jimsolo

Help with Random Mortar Script

Recommended Posts

This has been solved:

Paste this into a trigger:

_anyname = ["target1","G_Camel_HE",24] execVM "FireSupport.sqf";

"_anyname" can be whatever you want.

"target1" has to be what your marker name is.

"G_Camel_HE" is the ammo type. (reference the Wiki for ammo list)

"24" is number of rounds fired.

Copy this into a .SQF file and place it in the Mission folder:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Immersion Fire Support Script.   by:JimSolo
// Version 1.0
// License: Public (free to use & modify)
//-----------------------------------------------------------------------------------------------------------
// Special Thanks to: Joshii & CarlGustaffa
//
// Instructions -  Create Marker named "target1"
// Instructions -  Create Trigger with init: _anyname = ["target1","G_Camel_HE",24] execVM "FireSupport.sqf";
// Instructions -  Place Marker whereever you want fireworks.
//
// Notes: You can replace ammo type "G_Camel_HE" with whatever suits your needs.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

_impact = _this select 0;// Do NOT change.
_ammo = _this select 1;// Do NOT change.
_rnds = _this select 2;// Do NOT change.
_count = 0;// Do NOT change.
serial = 0;// Do NOT change.

//------------------------------------------------------------------------------------

while { _count < _rnds }  do // Infinite loop.
{
_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2.
_randomnumbery = ceil(random 2); // Creating a 2nd random number.
_impactx = getmarkerPos _impact select 0; // Assigning the x value of the impactzone to the variable.
_impacty = getmarkerPos _impact select 1; // Same with the y value.
switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player.
{
	case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number.
	case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number.
};
switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
{
	case 1: { _impacty = _impacty + (random(100)); };
	case 2: { _impacty = _impacty - (random(100)); };
};
_shellname = format ["shell%1", serial]; // Formating a unique round name.
_shellname = _ammo createVehicle ([_impactx, _impacty, 10]);
serial = serial + 1; // Changing the  round "serial" so the name stays unique.
_count = _count + 1;
       sleep random 5; // Adjusts the amount of time between impacts (You can play around with this).
};

Alternatively, you can down load the .SQF here:

http://www.hnltechs.com/Uploads/FireSupport.sqf

Edited by JimSolo

Share this post


Link to post
Share on other sites

I made one too for minfields but well still feel free to read and understand.

test1.sqf / This creates the mines

boompos = getMarkerPos "boom";

explosive = "Mine";

value = [];

done = false;

ufa = 1;

while { !done } do

{

ufa = ufa + 1;

sleep 0.1;

_x = (boompos select 0) + random 1000;

_y = (boompos select 1) + random 1000;

_z = 0;

randomPos = [_x, _y, _z];

string1 = format ["T%1",ufa];

string = subammo createVehicle (randomPos);

value = value + [randomPos+ [string1]];

};

test2.sqf // This marks the mines on map

done = true;

bd = count value;

counter = 0;

while { bd != counter } do {

t1 = format ["a%1", counter];

t1 = createMarker[value select counter select 3,[value select counter select 0,value select counter select 1]];

t1 setMarkerShape "ICON";

sleep 0.01;

value select counter select 3 setMarkerType "DOT";

value select counter select 3 setMarkerText t1;

counter = counter + 1;

};

just for your information: You gotta change 2 things to make it an unlimited artillery instead of a limited mine field.

Need help? Post back!

Share this post


Link to post
Share on other sites

shouldn't camcreate be createVehicle ?

-=EDIT=-

make sure "ARTY_Sh_82_HE" is actually in A2 / the mod you're using with it.

try use "Bo_GBU12_LGB" instead?

Edited by Ben_S

Share this post


Link to post
Share on other sites

@Ben_S

Thanks for the reply but the "ARTY_Sh_82_HE" came from the Arma 2 Weapons list on the Wiki so I dont see why that wouldnt work. Its a motar round and I'm trying to get random Mortar impacts. Wont look right with bigger explosions. What could I use for medium/Small explosions?

@Joshii

Your help is most welcome but Looking at this example you gave (re-posted below) Has alot of stuff I'm not familiar with. I assume its from my lack of knowledge and/or part of your mine script that I dont need...

Clarification of each part would do me alot of good if you have the time.

test1.sqf / This creates the mines

boompos = getMarkerPos "boom";

explosive = "Mine";

value = [];

done = false;

ufa = 1;

while { !done } do

{

ufa = ufa + 1;

sleep 0.1;

_x = (boompos select 0) + random 1000;

_y = (boompos select 1) + random 1000;

_z = 0;

randomPos = [_x, _y, _z];

string1 = format ["T%1",ufa];

string = subammo createVehicle (randomPos);

value = value + [randomPos+ [string1]];

};

...not sure what the stuff in red is even for.

I want to drop a trigger that launches the script when it detects BluFor. Then the script would detect the Marker position and drop in Motar rounds at random X/Y cords based on the Marker.

The script should be called with the ability to set these parameters:

Number of rounds

Marker Location.

Optionally these would be nice too:

Ammo Type

Dispersion.

Example:

[target1,100,50,"ARTY_Sh_82_HE",16] exec "PRESTO.sqs"

Red = Marker Position, Green = X & Y dispersion, Blue = Ammo Type, Black = number of Rounds.

PRESTO.sqs:

;-----Random Mortar Fire Script-----

hint "Splash"

_impact = _this select 0

_Xcord = _this select 1

_Ycord = _this select 2

_ammo = _this select 3

_rnds = _this select 4

_count = 0

#loop

x = _Xcord + random -50

y = _Ycord + random 50

_ammo camcreate [(getPos _impact select 0)+x,(getPos _impact select 1)+y, 10]

~2

_count = _count + 1

?_count < _rnds : goto"loop"

exit

or something to that effect.

So what parts do I have wrong?

Is the CamCreate totally wrong for what I'm trying to do?

Thanks for the help,

Jim

Share this post


Link to post
Share on other sites
this example you gave (re-posted below) Has alot of stuff I'm not familiar with.

Probably coz the SQS stuff is circa 2001 code. :)

I think "subammo" was supposed to read "explosive". The ufa+1 stuff just saves a value with the post and "Tx" where x = ufa for each run through the loop. That's used in the other script to make markers it looks like. I don't see where he stops the script however.

And yeah, use createVehicle to spawn things now, not camCreate.

Edited by kylania

Share this post


Link to post
Share on other sites

LOL I know I need to brush up on the new stuff. :D

Wife & three turdlets kinda slows down the Arma 2 time heh.

I will try and redo this in a SQF, Thanks :)

Share this post


Link to post
Share on other sites
Wont look right with bigger explosions. What could I use for medium/Small explosions?

That's a good question. My guess is trying the most appealing of these, but it'll take you a while. When I was doing something similar I wasn't able to find that perfect mortar, and the 82s are just too devastating to use.

In the hardcore missions I've played where light mortars are simulated this way, they tend to use grenades. Sounds, damage effects (and maybe visual effects) will be a bit on the weak side, but for single player mission should be easy enough at least to add a little extra punch to the sound.

Share this post


Link to post
Share on other sites

Ok I'm trying to convert this to SQF but having alittle trouble executing...

How do I call this because...

[target1,16] execvm "FireSupport.sqf"

Does NOT work.

ALSO can anyone see any mistakes in this so far?

_impact = _this select 0;

_ammo = _this select 1;

_rnds = _this select 2;

hint "SPLASH"/ For Testing Purposes

//----------------------------------------------------------------------

#loop

x = random (80)-40;

y = 30 + random 40;

"ARTY_8Rnd_82mmHE_2B14" createvehicle [(getPos _impact select 0)+x,(getPos _impact select 1)+y, 10];

sleep 2;

for [{_count = 0},{_count < _rnds},{_count = _count + 1}] exitwith {};

loop;

thx in advance,

Jim

Share this post


Link to post
Share on other sites

Ye right..

My variable names probably were not as clear.

So I will explain the stuff right now.

boompos = getMarkerPos "boom"; // Right this is just the marker position from where the random is added.
explosive = "Mine"; // Ammo type used in my case it's "Mine" you can change it to "ARTY_Sh_82_HE" though
value = []; // This value is just to create markers for my mine field. You can simply just delete this if you only want random mortars.
done = false; // This was my value to stop the artillery impact at some point. In my case it's executed when the markers are created.
ufa = 1; // Just a counter to later on get names for the markers. Not necessarily needed
while { !done } do // While loop running  whilst done is false. 
{
ufa = ufa + 1; // Starting to count how many times it's running.
sleep 0.1; // A sleep of 0.1 s so my CPU can cool down. + Otherwise it would be pure spamm it might be usefull to change this if you do not want an artillery shell every 0.1 seconds
_x = (boompos select 0) + random 1000; // x position of the marker + random 1000
_y = (boompos select 1) + random 1000; // y position of the marker + random 1000
_z = 0; // height of a mine = 0 usefull to change for artillery though so you actually see it dropping
randomPos = [_x, _y, _z]; // This is the position array it's [x,y,z]
string1 = format ["T%1",ufa]; // Formating a string so later on I could create markers.
string = subammo createVehicle (randomPos);  // Finally creating the impact
value = value + [randomPos+ [string1]]; // Saving the co-ordinates + the name of the shell in an array. 
// e.g with 2 shells this array looks like this 
// [[0,0,0, T1], [1,1,1, T2]];
// So if I do select 0 I had an array of [0,0,0, T1] the name of the first impact. 
// This means I can call the positions of the array with select 0, 1, 2 and the name with select 3
// This is however not really important for an artillery script
}; // Ending the while loop

// Now this script was executed for me when I had enough mines placed.
// I always had a hint running so I saw how many mines I had

done = true;  // Ending the while loop 
bd = count value; // Counting how many mines I had 
counter = 0; // Setting a counter to 0 
while { bd != counter } do  // While loop running while counter has not reached the last mine 
{ 
t1 = format ["a%1", counter]; // a name for the marker it has to be unique so it's the counter number plus the letter "a"
t1 = createMarker[value select counter select 3,[value select counter select 0,value select counter select 1]];
// The line above this is 
//     String = createMarker [name, position] 
//  String = t1    name = value select counter select 3 - Cause as said before select 3 always gives me the name of the mine
//  position = value select counter select 0,value select counter select 1 - This gives me the x and y co-ordinates of a marker

t1 setMarkerShape "ICON";  
sleep 0.01; // Sleep so my CPU won't over kill
value select counter select 3 setMarkerType "DOT";
value select counter select 3 setMarkerText t1;
// Creating the marker
counter = counter + 1; // Adding +1 to the counter when the mines if done
};

I agree this is not needed if you only want artillery still it's cool to learn how arrays work :P

Anyhow I will post an "artillery only" script here in about 10 minutes or so.

Edit1: For your post above mine your using SQS syntax in SQF.

e.g Loop is not SQF

http://community.bistudio.com/wiki/SQF

Edit2 artillery script :

explosive = "B_30mm_HE"; // Type of weapon
ammount = 0; // Counter to get unique vehicle names
while { true }  do // Infinite loop
{
                impactZone = getPos player; // Impactzone
	_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2 
	_randomnumbery = ceil(random 2); // Creating a 2nd random number
	_impactx = impactZone select 0; // assigning the x value of the impactzone to the variable
	_impacty = impactZone select 1; // same with the y value
	switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player
	{
		case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number
		case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number
	};
	switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
	{
		case 1: { _impacty = _impacty + (random(100)); };
		case 2: { _impacty = _impacty - (random(100)); };
	};
	_vehiclename = format ["shell%1", ammount]; // Formating a unique name
	_vehiclename = explosive createVehicle ([_impactx, _impacty, 10]);
	ammount = ammount + 1; // Changing the ammount + 1 so the name stays unique

	sleep 0.5; // So it's not 10 impacts per second and CPU cooldown

};

Tested and working if you have any questions feel free to ask.

Edited by Joshii
Adding artillery

Share this post


Link to post
Share on other sites

@Joshii: For the future, try to use code tags instead of quote tags, as they preserve indentation and doesn't cause some forum autocorrection (that can break the code if unlucky).

Great effort on putting comments on just about every line though. Me like, more of this. Comments FTW :) Invaluable for those learning.

Share this post


Link to post
Share on other sites

Thanks Joshii that makes more sense looking at it as an Artillery Script. :)

Couple things I dont understand yet though:

I can see that the loop is started with:

while { true }  do // Infinite loop
{
            };

But I dont know how you would STOP this script.

I can see it just needs to be set as False but how?

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

For my second question, whats the proper way to Execute this with Variables? I.E. [var1,var2] exec "blah.sqs"

Whats the SQF way? and whats the purpose of the "name" at the beginning of:

[color="DarkRed"]_name[/color] = player execVM "test.sqf";

Also in this example, why does "player" or any other Object or thing need to Execute? I mean with SQS you never used "This" or "Player" to call scripts like:

this [] exec "blah.sqs

so its kinda confusing in that respect. :confused_o:

Share this post


Link to post
Share on other sites

You have two options that I can think of atm. Initialize some _check variable to true before the loop starts, and then check that variable instead of true. During the loop, you can set it to false whenever you feel it's time.

Another option is to set the name of the { ... loop ... } scope using scopeName, and breakOut when condition is met.

Tip: Indenting still wrong to make it look good.

_check = true;
while { _check }  do // Infinite loop
{
your code that sets _check = false when you think it should
};

player execVM "test.sqf"; //Not in an array

_unit = _this; //_this contains one element, not in an array

[player] execVM "test.sqf"; //In an array

_unit = _this select 0; //_this contains one element (item 0), which is in an array

_name means the script handle. With it you can check if it is running using scriptDone, or even terminate it.

Confused about this and _this (I think we all were at the beginning), read up on, err, this :p

You might want to check up on the tutorial at the bottom.

Edited by CarlGustaffa

Share this post


Link to post
Share on other sites

Not really confused on "this" or "_something = this"

I'm confused on how an SQF is called:

[color="DarkRed"]_name[/color] = [color="darkred"]player[/color] execVM "test.sqf";

Just the parts in red and why they are there.

I also want to know how to pass variables to the SQF.

---------- Post added at 10:47 AM ---------- Previous post was at 09:54 AM ----------

Ok just did a test run with new code and It didnt work.

All I got was the "hint"

I'm calling the script with this in a trigger:

_scpt1 = [target1,ARTY_8Rnd_82mmHE_2B14,16] execVM "FireSupport.sqf";

The Script looks like this:

_impact = _this select 0;
_ammo = _this select 1;
_rnds = _this select 2;
_check = true;
_count = 0;

hint "SPLASH"/ For Testing Purposes & can be removed.

//------------------------------------------------------------------------------------
while { true }  do // Infinite loop.
{
_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2.
_randomnumbery = ceil(random 2); // Creating a 2nd random number.
_impactx = _impact select 0; // Assigning the x value of the impactzone to the variable.
_impacty = _impact select 1; // Same with the y value.
switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player.
{
	case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number.
	case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number.
};
switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
{
	case 1: { _impacty = _impacty + (random(100)); };
	case 2: { _impacty = _impacty - (random(100)); };
};
_shellname = format ["shell%1", serial]; // Formating a unique round name.
_shellname = _ammo createVehicle ([_impactx, _impacty, 10]);
serial = serial + 1; // Changing the  round "serial" so the name stays unique.
sleep random 10; // Adjusts the amount of time between impacts.
};
for [{_count = 0},{_count < _rnds},{_count = _count + 1}] exitwith {_check = false};

sooo what did I do wrong?

Share this post


Link to post
Share on other sites

You have

hint "SPLASH"/ For Testing Purposes & can be removed.

instead of

hint "SPLASH"; // For Testing Purposes & can be removed.

I changed it but it is still not working so there is another issue with your script.

THis entire line

for [{_count = 0},{_count < _rnds},{_count = _count + 1}] exitwith {_check = false};

Is redundant just use my script like this and it works

explosive = "B_30mm_HE"; // Type of weapon
ammount = 0; // Counter to get unique vehicle names
rounds = 0;
_rounds1 = _this select 0;
rounds = rounds + _rounds1;  // To avoid problems if the script is called multiple times. 
while { ammount < rounds }  do // Infinite loop
{
                impactZone = getPos player; // Impactzone
	_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2 
	_randomnumbery = ceil(random 2); // Creating a 2nd random number
	_impactx = impactZone select 0; // assigning the x value of the impactzone to the variable
	_impacty = impactZone select 1; // same with the y value
	switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player
	{
		case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number
		case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number
	};
	switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
	{
		case 1: { _impacty = _impacty + (random(100)); };
		case 2: { _impacty = _impacty - (random(100)); };
	};
	_vehiclename = format ["shell%1", ammount]; // Formating a unique name
	_vehiclename = explosive createVehicle ([_impactx, _impacty, 10]);
	ammount = ammount + 1; // Changing the ammount + 1 so the name stays unique

	sleep 0.5; // So it's not 10 impacts per second and CPU cooldown

};

Modified - 4:08

Edited by Joshii

Share this post


Link to post
Share on other sites

@Joshii

I appreciate the use of your script but please understand I want to learn and not just leech scripts off everyone. :D

In your script, what is it that ENDS the loop?

ok version 2:

_scpt1 = ["target1","B_30mm_HE","16"] execVM "FireSupport.sqf";

_impact = _this select 0;
_ammo = _this select 1;
_rnds = _this select 2;
_count = 0;

hint "INCOMING"// For Testing Purposes & can be removed.

//------------------------------------------------------------------------------------
while { _count < _rnds }  do // Infinite loop.
{
_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2.
_randomnumbery = ceil(random 2); // Creating a 2nd random number.
_impactx = _impact select 0; // Assigning the x value of the impactzone to the variable.
_impacty = _impact select 1; // Same with the y value.
switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player.
{
	case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number.
	case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number.
};
switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
{
	case 1: { _impacty = _impacty + (random(100)); };
	case 2: { _impacty = _impacty - (random(100)); };
};
_shellname = format ["shell%1", serial]; // Formating a unique round name.
_shellname = _ammo createVehicle ([_impactx, _impacty, 10]);
serial = serial + 1; // Changing the  round "serial" so the name stays unique.
hint "SPLASH"// For Testing Purposes & can be removed.
_count = _count + 1;
sleep random 5; // Adjusts the amount of time between impacts.
};

Hows that look?

Edited by JimSolo

Share this post


Link to post
Share on other sites

It wasn't meant like "Eat my script or die!"

More like take it as an example.

I like the fact that you wanna learn instead of begging others to do work for you.

while{condition} do {code};

The loop ends as soon as the condition = false

while { ammount < rounds } do // Infinite loop

My // Infinite loop command is not accurate anymore sorry for not changing I just realized.

The script get started with

[5] execVM "RandomArtillery.sqf";

In that case

0 < 5 = true

after 3 runs

3 < 5 = true

after 5 runs

5 < 5 = false

While loop stops

Edit your version 2:

hint "INCOMING"// For Testing Purposes & can be removed.

Forgot the ;

hint "INCOMING"; // For Testing Purposes & can be removed.

Also in line 29 the other hint

hint "SPLASH"// For Testing Purposes & can be removed.

for the ;

hint "SPLASH"; // For Testing Purposes & can be removed.

Also the way you call it

You save it all as a string even though that not all of it are strings the " " defines if it's a script or not.

i.e

[10, "5"] execVM "example.sqf"

example.sqf
a = _this select 0;
b = _this select 1;
while{ a < b }

Output : ERROR EXPECTING NUMBER GOT STRING (( Or something like this )) 
Reason: "5" gives the 5 over as a string and not a number while 10 is a number so using  [10, 5] execVM "example.sqf"; would work

Edited by Joshii

Share this post


Link to post
Share on other sites

Something still isnt right...

latest build:

_scpt1 = [[color="DarkRed"]target1,B_30mm_HE,16[/color]] execVM "FireSupport.sqf";

[color="darkred"]_impact = _this select 0;
_ammo = _this select 1;
_rnds = _this select 2;
_count = 0;[/color]
hint "INCOMING";// For Testing Purposes & can be removed.

//------------------------------------------------------------------------------------
while { _count < _rnds }  do // Infinite loop.
{
_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2.
_randomnumbery = ceil(random 2); // Creating a 2nd random number.
_impactx = _impact select 0; // Assigning the x value of the impactzone to the variable.
_impacty = _impact select 1; // Same with the y value.
switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player.
{
	case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number.
	case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number.
};
switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
{
	case 1: { _impacty = _impacty + (random(100)); };
	case 2: { _impacty = _impacty - (random(100)); };
};
_shellname = format ["shell%1", serial]; // Formating a unique round name.
_shellname = _ammo createVehicle ([_impactx, _impacty, 10]);
serial = serial + 1; // Changing the  round "serial" so the name stays unique.
hint "SPLASH";// For Testing Purposes & can be removed.
[color="DarkRed"]_count = _count + 1;[/color]
       sleep random 5; // Adjusts the amount of time between impacts.
};

Stuff in red are biggest changes.

Share this post


Link to post
Share on other sites

_impact = _this select 0;
_ammo = _this select 1;
_rnds = _this select 2;
_count = 0;
serial = 0;


hint "INCOMING"; // For Testing Purposes & can be removed.

//------------------------------------------------------------------------------------
while { _count < _rnds }  do // Infinite loop.
{
_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2.
_randomnumbery = ceil(random 2); // Creating a 2nd random number.
_impactx = getPos _impact select 0; // Assigning the x value of the impactzone to the variable.
_impacty = getPos _impact select 1; // Same with the y value.
switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player.
{
	case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number.
	case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number.
};
switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
{
	case 1: { _impacty = _impacty + (random(100)); };
	case 2: { _impacty = _impacty - (random(100)); };
};
_shellname = format ["shell%1", serial]; // Formating a unique round name.
_shellname = _ammo createVehicle ([_impactx, _impacty, 10]);
serial = serial + 1; // Changing the  round "serial" so the name stays unique.
hint "SPLASH"; // For Testing Purposes & can be removed.
_count = _count + 1;
sleep random 5; // Adjusts the amount of time between impacts.
};

Issues fixed.

It was

1. You did not set serial = 0;

2. _scpt1 = [target1,"B_30mm_HE",16] execVM "FireSupport.sqf";

3. Getting the position was forgotten in your I changed that and added getPos at @ _impactX and y

4. Please note getPos only works if its an object not a marker if your using a marker change it accordingly ( Put it in a string and change it to getMarkerPos

Edited by Joshii

Share this post


Link to post
Share on other sites

hmmm...

it makes it to the "SPLASH" hint now but no explosions.

Since "target1" is a marker should I use getmarkerpos instead?

EDIT***

didnt work.

Also tried getPos and adding gamelogic named "target1" instead of marker.

Its soooo close I can feel it! :confused2:

---------- Post added at 12:36 PM ---------- Previous post was at 12:01 PM ----------

Finally works! Thanks ALL! :yay:

Call with:

 _anyname = ["target1","G_Camel_HE",24] execVM "FireSupport.sqf";

Actual .SQF:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Immersion Fire Support Script.   by:JimSolo
// Version 1.0
// License: Public (free to use & modify)
//-----------------------------------------------------------------------------------------------------------
// Special Thanks to: Joshii & CarlGustaffa
//
// Instructions -  Create Marker named "target1"
// Instructions -  Create Trigger with init: _anyname = ["target1","G_Camel_HE",24] execVM "FireSupport.sqf";
// Instructions -  Place Marker whereever you want fireworks.
//
// Notes: You can replace ammo type "G_Camel_HE" with whatever suits your needs.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

_impact = _this select 0;// Do NOT change.
_ammo = _this select 1;// Do NOT change.
_rnds = _this select 2;// Do NOT change.
_count = 0;// Do NOT change.
serial = 0;// Do NOT change.

//------------------------------------------------------------------------------------

while { _count < _rnds }  do // Infinite loop.
{
_randomnumberx = ceil(random 2); // Creating a random number result is either 1 or 2.
_randomnumbery = ceil(random 2); // Creating a 2nd random number.
_impactx = getmarkerPos _impact select 0; // Assigning the x value of the impactzone to the variable.
_impacty = getmarkerPos _impact select 1; // Same with the y value.
switch(_randomnumberx) do // Using the random number to either add or subtract an ammount to / of the x value otherwise the artillery would always be infront or behind the player.
{
	case 1: { _impactx = _impactx + (random(100));}; // If 1 is the random number.
	case 2: { _impactx = _impactx - (random(100));}; // If 2 is the random number.
};
switch(_randomnumbery) do  // Using the random number to either add or subtract an ammount to / of the y value this will make the impact left / right random.
{
	case 1: { _impacty = _impacty + (random(100)); };
	case 2: { _impacty = _impacty - (random(100)); };
};
_shellname = format ["shell%1", serial]; // Formating a unique round name.
_shellname = _ammo createVehicle ([_impactx, _impacty, 10]);
serial = serial + 1; // Changing the  round "serial" so the name stays unique.
_count = _count + 1;
       sleep random 5; // Adjusts the amount of time between impacts (You can play around with this).
};

...on to the next project lol

Edited by JimSolo

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  

×